Commit 5784a432 authored by Alexander Scharfenberg's avatar Alexander Scharfenberg
Browse files

many more changes

parent 2ab9dcf9
<Window x:Class="Raumverwaltung_HMWK.AddUserForRoomWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:local="clr-namespace:Raumverwaltung_HMWK"
mc:Ignorable="d"
Title="AddUserForRoomWindow" Height="200" Width="300" ResizeMode="NoResize">
<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="*"></ColumnDefinition>
<ColumnDefinition Width="*"></ColumnDefinition>
<ColumnDefinition Width="*"></ColumnDefinition>
</Grid.ColumnDefinitions>
<Grid.RowDefinitions>
<RowDefinition Height="*"></RowDefinition>
<RowDefinition Height="*"></RowDefinition>
<RowDefinition Height="*"></RowDefinition>
</Grid.RowDefinitions>
<TextBlock Grid.Row="0" Grid.Column="1" FontSize="12" VerticalAlignment="Center" HorizontalAlignment="Center">Nutzerauswahl:</TextBlock>
<ComboBox Grid.Row="1" Grid.Column="0" Grid.ColumnSpan="3" Name="AllUsers" VerticalAlignment="Center" Height="30" IsEditable="True"></ComboBox>
<Button Click="OK_OnClick" Grid.Row="2" Grid.Column="0" Name="OK" VerticalAlignment="Center" HorizontalAlignment="Right">Hinzufügen</Button>
<Button Click="ABBRUCH_OnClick" Grid.Row="2" Grid.Column="2" Name="ABBRUCH" VerticalAlignment="Center" HorizontalAlignment="Left">Abbrechen</Button>
</Grid>
</Window>
using System.Collections.Generic;
using System.Windows;
namespace Raumverwaltung_HMWK
{
public partial class AddUserForRoomWindow : Window
{
private List<User> users;
public AddUserForRoomWindow(int roomId)
{
InitializeComponent();
users = SqLiteDataAccess.LoadUsersNotinRoom(roomId);
for (int i = 0; i < users.Count; i++)
{
AllUsers.Items.Add(users[i]);
}
}
private void ABBRUCH_OnClick(object sender, RoutedEventArgs e)
{
Close();
}
private void OK_OnClick(object sender, RoutedEventArgs e)
{
if (AllUsers.SelectedItem != null)
{
//probiere aus und schau, ob index in Combobox und users gleich ist
User selectedUser = users[AllUsers.SelectedIndex];
//Add User to Room mit User-Id und weiterer SqLiteAccess-Funktion
}
}
}
}
\ No newline at end of file
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<connectionStrings>
<add name="Default" connectionString="Data Source=.\DB.db;Version=3;" providerName="System.Data.SqlClient"/>
</connectionStrings>
<startup>
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.8" />
</startup>
......
namespace Raumverwaltung_HMWK
using System.Collections.Generic;
namespace Raumverwaltung_HMWK
{
public class Building
{
private int id;
private int bId;
private string name;
private List<Floor> floors = new List<Floor>();
public Building()
{
......@@ -14,16 +18,21 @@
{
this.name = name;
}
public int Id
public int BId
{
get { return id; }
set { id = value; }
get { return bId; }
set { bId = value; }
}
public string Name
{
get { return name; }
set { name = value; }
}
public List<Floor> Floors
{
get { return floors; }
set { floors = value; }
}
}
......
namespace Raumverwaltung_HMWK
using System.Collections.Generic;
namespace Raumverwaltung_HMWK
{
public class Floor
{
......@@ -6,6 +8,7 @@
private string name;
private string image;
private int buildingId;
private List<Room> rooms = new List<Room>();
public Floor()
......@@ -38,7 +41,16 @@
get { return buildingId; }
set { buildingId = value; }
}
public List<Room> Rooms
{
get { return rooms; }
set { rooms = value; }
}
public override string ToString()
{
return name;
}
}
}
\ No newline at end of file
<Window x:Class="Raumverwaltung_HMWK.FloorWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:local="clr-namespace:Raumverwaltung_HMWK"
mc:Ignorable="d"
Title="FloorWindow" Height="950" Width="1100" ResizeMode="NoResize">
<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="50"/>
<RowDefinition Height="*"/>
<RowDefinition Height="120"/>
</Grid.RowDefinitions>
<Border Grid.Row="0" BorderThickness="1" BorderBrush="Gray"></Border>
<Border Grid.Row="1" BorderThickness="1" BorderBrush="Gray"></Border>
<Border Grid.Row="2" BorderThickness="1" BorderBrush="Gray"></Border>
<StackPanel Grid.Row="0" Orientation="Horizontal" Background="Thistle">
<Image Source="../Images/icon.PNG"/>
<TextBlock Background="Thistle" Name="Ueberschrift" FontSize="25" VerticalAlignment="Center" Margin="50,0,0,0"></TextBlock>
<Button Click="MoveButtons_OnClick" Width="130" Height="30" Margin="350,0,10,0">Buttons verschieben</Button>
<Button Click="SavePositions_OnClick" Width="130" Height="30">Positionen speichern</Button>
</StackPanel>
<Canvas Name="GUI" Grid.Row="1" Margin="10" PreviewMouseMove="GUI_OnPreviewMouseMove" PreviewMouseUp="GUI_OnPreviewMouseUp">
</Canvas>
<StackPanel Grid.Row="2" Margin="10" Orientation="Horizontal" Background="Lavender">
<StackPanel Orientation="Vertical">
<TextBlock>Notizfeld:</TextBlock>
<TextBox Name="Notefield" Margin="10" Height="70" Width="850"></TextBox>
</StackPanel>
<StackPanel VerticalAlignment="Bottom" HorizontalAlignment="Center" Width="80" Height="50">
<Button Content="Speichern" ></Button>
</StackPanel>
</StackPanel>
</Grid>
</Window>
using System;
using System.Collections.Generic;
using System.Linq;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using Point = System.Windows.Point;
namespace Raumverwaltung_HMWK
{
public partial class FloorWindow : Window
{
private Floor CurrentFloor;
private UIElement dragObject;
private Point offset;
public FloorWindow(int floorid)
{
CurrentFloor = SqLiteDataAccess.GetFloor(floorid);
CurrentFloor.Rooms = SqLiteDataAccess.GetRooms(floorid);
InitializeComponent();
Ueberschrift.Text = CurrentFloor.Name;
if (String.IsNullOrEmpty(CurrentFloor.Image))
{
GUI.Background = new ImageBrush(new BitmapImage(new Uri("../../Images/schwarz.png", UriKind.Relative)));
}
else
{
GUI.Background = new ImageBrush(new BitmapImage(new Uri(CurrentFloor.Image, UriKind.Relative)));
}
for (int i = 0; i < CurrentFloor.Rooms.Count;i++)
{
CreateButton(CurrentFloor.Rooms[i]);
}
}
private void GUI_OnPreviewMouseMove(object sender, MouseEventArgs e)
{
if (dragObject == null)
{
return;
}
var position = e.GetPosition(sender as IInputElement);
Canvas.SetTop(dragObject, position.Y - offset.Y);
Canvas.SetLeft(dragObject, position.X - offset.X);
}
private void GUI_OnPreviewMouseUp(object sender, MouseButtonEventArgs e)
{
dragObject = null;
GUI.ReleaseMouseCapture();
}
private void Btn_PreviewMouseDown(object sender, MouseButtonEventArgs e)
{
dragObject = sender as UIElement;
offset = e.GetPosition(GUI);
offset.Y -= Canvas.GetTop(dragObject);
offset.X -= Canvas.GetLeft(dragObject);
GUI.CaptureMouse();
}
private void CreateButton(Room room)
{
Button newBtn = new Button();
newBtn.Width = 50;
newBtn.Height = 30;
newBtn.Content = room.Name;
newBtn.Name = "_"+room.Id;
newBtn.FontSize = 15;
newBtn.Click += ClickRoomButton;
GUI.Children.Add(newBtn);
Canvas.SetLeft(newBtn,room.X);
Canvas.SetTop(newBtn,room.Y);
}
public void ClickRoomButton(object sender, RoutedEventArgs e)
{
Button btn = (Button) sender;
var window = new RoomWindow(int.Parse(btn.Name.Remove(0,1)));
window.Show();
}
private void MoveButtons_OnClick(object sender, RoutedEventArgs e)
{
foreach (var c in GUI.Children.OfType<Button>())
{
c.PreviewMouseDown += Btn_PreviewMouseDown;
}
MessageBox.Show("Verschiebung aktiviert.", "Achtung", MessageBoxButton.OK, MessageBoxImage.Information);
}
private void SavePositions_OnClick(object sender, RoutedEventArgs e)
{
foreach (var c in GUI.Children.OfType<Button>())
{
c.PreviewMouseDown -= Btn_PreviewMouseDown;
int roomId = int.Parse(c.Name.Remove(0,1));
//get y
double y = (double) c.GetValue(Canvas.TopProperty);
//get x
double x = (double) c.GetValue(Canvas.LeftProperty);
SqLiteDataAccess.SaveButtonPosition(roomId,x,y);
}
MessageBox.Show("Buttonpositionen gespeichert.", "Erfolgreich:", MessageBoxButton.OK,
MessageBoxImage.Information);
}
}
}
\ No newline at end of file
......@@ -5,8 +5,71 @@
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:local="clr-namespace:Raumverwaltung_HMWK"
mc:Ignorable="d"
Title="MainWindow" Height="350" Width="525">
Title="Raumverwaltung-HMWK" Height="500" Width="720">
<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="*"></ColumnDefinition>
<ColumnDefinition Width="*"></ColumnDefinition>
<ColumnDefinition Width="*"></ColumnDefinition>
</Grid.ColumnDefinitions>
<Grid.RowDefinitions>
<RowDefinition Height="80"></RowDefinition>
<RowDefinition Height="100"></RowDefinition>
<RowDefinition Height="*"></RowDefinition>
</Grid.RowDefinitions>
<StackPanel Grid.Row="0" Grid.Column="0" Grid.ColumnSpan="3" VerticalAlignment="Top">
<Menu Height="50">
<MenuItem Height="50" Width="60">
<MenuItem.Header>
<StackPanel>
<Image Source="../Images/icon.png" Width="50" Height="50"/>
</StackPanel>
</MenuItem.Header>
</MenuItem>
<MenuItem Header="Standort">
<MenuItem Header="Anlegen"/>
<MenuItem Header="Löschen"/>
</MenuItem>
<MenuItem Header="Benutzer">
<MenuItem Header="Anlegen"/>
<MenuItem Header="Löschen"/>
</MenuItem>
<MenuItem Header="Hilfe"></MenuItem>
</Menu>
</StackPanel>
<StackPanel Grid.Row="1" Grid.Column="0" Orientation="Vertical" VerticalAlignment="Center">
<TextBlock Text="Standorte:" HorizontalAlignment="Center" FontSize="15"></TextBlock>
<ComboBox Name="Standortauswahl" SelectionChanged="Standortauswahl_OnSelectionChanged" Height="30" Width="100"></ComboBox>
</StackPanel>
<StackPanel Grid.Row="1" Grid.Column="1" Orientation="Vertical" VerticalAlignment="Center">
<TextBlock Text="Stockwerke:" FontSize="15" HorizontalAlignment="Center"></TextBlock>
<ComboBox Name="Stockwerkauswahl" SelectionChanged="Stockwerkauswahl_OnSelectionChanged" Height="30" Width="100"></ComboBox>
</StackPanel>
<StackPanel Grid.Row="1" Grid.Column="2" Orientation="Vertical" VerticalAlignment="Center">
<TextBlock Text="Auswahl:" FontSize="15" HorizontalAlignment="Center"></TextBlock>
<TextBox Name="Result" Margin="0,10" Height="30" Width="100"></TextBox>
<Button Click="OpenFloor_OnClick" FontSize="15" IsEnabled="False" Name="OpenFloor" Content="Auswahl öffnen" Height="30" Width="120"></Button>
</StackPanel>
<StackPanel Grid.Row="2" Grid.Column="0" Grid.ColumnSpan="3">
<TextBlock Text="Raumüberblick:" FontSize="15" HorizontalAlignment="Center"></TextBlock>
<ListBox Height="260" Name="RoomList">
<ListBox.ItemTemplate>
<DataTemplate>
<WrapPanel>
<Image Source="{Binding MyImage}" Width="30" Height="30"/>
<TextBlock Text="{Binding RoomName}" FontSize="15" Margin="10,0,0,0"/>
<TextBlock Text="Raumgröße: " FontSize="15" Margin="10,0,0,0"/>
<TextBlock Text="{Binding RoomSize}" FontSize="15"/>
<TextBlock Text="m²" FontSize="15"/>
<TextBlock Text="Arbeitsplätze:" FontSize="15" Margin="10,0,0,0"/>
<TextBlock Text="{Binding MaxWp}" FontSize="15" Margin="5,0,0,0"/>
<TextBlock Text="/" FontSize="15"/>
<TextBlock Text="{Binding RealAmountUsers}" FontSize="15"></TextBlock>
<TextBlock Text="(belegt/gesamt)" FontSize="15" Margin="5,0,0,0"/>
</WrapPanel>
</DataTemplate>
</ListBox.ItemTemplate>
</ListBox>
</StackPanel>
</Grid>
</Window>
namespace Raumverwaltung_HMWK
using System;
using System.Collections.Generic;
using System.Linq;
using System.Windows;
using System.Windows.Controls;
namespace Raumverwaltung_HMWK
{
/// <summary>
/// Interaction logic for MainWindow.xaml
/// </summary>
public partial class MainWindow
{
private List<Building> buildings;
public MainWindow()
{
buildings = GetBuildings();
InitializeComponent();
FillStandortList();
Standortauswahl.SelectedIndex = 0;
}
private void FillStandortList()
{
for (int i = 0; i < buildings.Count; i++)
{
Standortauswahl.Items.Add(buildings[i].Name);
}
}
private void FillStockwerkList(string name)
{
for (int i = 0; i < buildings.Count; i++)
{
if (buildings[i].Name.Equals(name))
{
List<Floor> floors = buildings[i].Floors;
for (int j = 0; j < floors.Count; j++)
{
Stockwerkauswahl.Items.Add(floors[j].Name);
}
}
}
}
public List<Building> GetBuildings()
{
return SqLiteDataAccess.GetBuildings();
}
private void Standortauswahl_OnSelectionChanged(object sender, SelectionChangedEventArgs e)
{
ComboBox cbx = (ComboBox) sender;
if (cbx.SelectedItem != null)
{
Stockwerkauswahl.Items.Clear();
FillStockwerkList(cbx.SelectedItem.ToString());
Stockwerkauswahl.SelectedIndex = 0;
}
}
private void Stockwerkauswahl_OnSelectionChanged(object sender, SelectionChangedEventArgs e)
{
ComboBox cbx = (ComboBox) sender;
if(cbx.SelectedItem != null)
{
Result.Text = cbx.SelectedItem.ToString();
OpenFloor.IsEnabled = true;
FillOverview(cbx.SelectedItem.ToString());
}
}
private void OpenFloor_OnClick(object sender, RoutedEventArgs e)
{
try
{
int floorid = 0;
for (int i = 0; i < buildings.Count; i++)
{
for (int j = 0; j < buildings[i].Floors.Count; j++)
{
if (Result.Text.Equals(buildings[i].Floors[j].Name))
{
floorid = buildings[i].Floors[j].Id;
}
}
}
var window = new FloorWindow(floorid);
window.Show();
}
catch (Exception)
{
MessageBox.Show("Ups, das Stockwerk lässt sich nicht öffnen.", "Fehler", MessageBoxButton.OK,
MessageBoxImage.Error);
}
}
public void FillOverview(string stockwerk)
{
List<OverViewItem> overViewItems = new List<OverViewItem>();
for (int i = 0; i < buildings.Count; i++)
{
for (int j = 0; j < buildings[i].Floors.Count; j++)
{
if (buildings[i].Floors[j].Name.Equals(stockwerk))
{
Floor currentFloor = buildings[i].Floors[j];
for (int x = 0; x < currentFloor.Rooms.Count; x++)
{
Room currentRoom = currentFloor.Rooms[x];
OverViewItem overViewItem = new OverViewItem(currentRoom.Id, currentRoom.Name,
currentRoom.Size, currentRoom.MaxWp);
overViewItems.Add(overViewItem);
}
}
}
}
RoomList.ItemsSource = overViewItems;
}
}
}
\ No newline at end of file
using System;
using System.Configuration;
using System.Windows.Controls;
using System.Windows.Media.Imaging;
namespace Raumverwaltung_HMWK
{
public class OverViewItem
{
public int Id { get; set; }
public BitmapImage MyImage { get; set; }
public string RoomName{ get; set; }
public double RoomSize{ get; set; }
public int MaxWp{ get; set; }
public int RealAmountUsers { get; set; }
public OverViewItem(int id, string name, double roomSize,int maxWp)
{
Id = id;
RoomName = name;
RoomSize = roomSize;
MaxWp = maxWp;
RealAmountUsers = SqLiteDataAccess.GetUserAnzahlToRoom(id);
if (MaxWp != 0)
{
int difference = MaxWp - RealAmountUsers;
if (difference > 1)
{
MyImage = new BitmapImage(new Uri(@"../../Images/grün.png",UriKind.Relative));
}
if (difference == 1)
{
MyImage = new BitmapImage(new Uri(@"../../Images/gelb.png",UriKind.Relative));
}
if (difference < 1)
{
MyImage = new BitmapImage(new Uri(@"../../Images/rot.png",UriKind.Relative));
}
}
else
{
MyImage = new BitmapImage(new Uri(@"../../Images/blau.png",UriKind.Relative));
}
}
}
}
\ No newline at end of file
namespace Raumverwaltung_HMWK
{
public class Punkt
{
public double X => x;
public double Y => y;
private double x;
private double y;
public Punkt(double X, double Y)
{
x = X;
y = Y;
}
}
}
\ No newline at end of file
......@@ -34,9 +34,40 @@
<WarningLevel>4</WarningLevel>