finish create module form
This commit is contained in:
@@ -5,64 +5,30 @@ using System.Windows;
|
||||
using System.Windows.Input;
|
||||
using Server_Dashboard_Socket;
|
||||
using System;
|
||||
using System.Data;
|
||||
|
||||
namespace Server_Dashboard {
|
||||
|
||||
/// <summary>
|
||||
/// View Model for the Dashboard
|
||||
/// </summary>
|
||||
class DashboardViewModel : BaseViewModel {
|
||||
internal class DashboardViewModel : BaseViewModel {
|
||||
|
||||
#region Private Values
|
||||
private readonly DashboardModuleViewModel dmvm = new DashboardModuleViewModel();
|
||||
#endregion
|
||||
|
||||
private readonly DashboardModuleViewModel dmvm;
|
||||
|
||||
#endregion Private Values
|
||||
|
||||
#region Properties
|
||||
|
||||
private string serverName;
|
||||
public string ServerName {
|
||||
get { return serverName; }
|
||||
set {
|
||||
if(serverName != value)
|
||||
serverName = value;
|
||||
OnPropertyChanged(nameof(serverName));
|
||||
}
|
||||
}
|
||||
|
||||
private string moduleName;
|
||||
public string ModuleName {
|
||||
get { return moduleName; }
|
||||
set {
|
||||
if (moduleName != value)
|
||||
moduleName = value;
|
||||
OnPropertyChanged(nameof(moduleName));
|
||||
}
|
||||
}
|
||||
|
||||
private string ipAdress;
|
||||
public string IPAdress {
|
||||
get { return ipAdress; }
|
||||
set {
|
||||
if (ipAdress != value)
|
||||
ipAdress = value;
|
||||
OnPropertyChanged(nameof(ipAdress));
|
||||
}
|
||||
}
|
||||
|
||||
private string port;
|
||||
public string Port {
|
||||
get { return port; }
|
||||
set {
|
||||
if (port != value)
|
||||
port = value;
|
||||
OnPropertyChanged(nameof(port));
|
||||
}
|
||||
}
|
||||
|
||||
//The Username displayed defaults to Username
|
||||
private string userName = "Username";
|
||||
private string userName;
|
||||
|
||||
public string UserName {
|
||||
get { return userName; }
|
||||
set {
|
||||
if(userName != value)
|
||||
set {
|
||||
if (userName != value)
|
||||
userName = value;
|
||||
OnPropertyChanged(nameof(userName));
|
||||
}
|
||||
@@ -70,37 +36,43 @@ namespace Server_Dashboard {
|
||||
|
||||
//List that contains every Module
|
||||
private ObservableCollection<DashboardModule> modules;
|
||||
|
||||
public ObservableCollection<DashboardModule> Modules {
|
||||
get { return modules; }
|
||||
set {
|
||||
if(value != modules)
|
||||
if (value != modules)
|
||||
modules = value;
|
||||
OnPropertyChanged(nameof(modules));
|
||||
}
|
||||
}
|
||||
#endregion
|
||||
|
||||
#endregion Properties
|
||||
|
||||
#region Constructor
|
||||
public DashboardViewModel() {
|
||||
//Creates a new echo server, remove b4 release
|
||||
EchoServer echoServer = new EchoServer();
|
||||
echoServer.Start();
|
||||
|
||||
public DashboardViewModel(string username) {
|
||||
UserName = username;
|
||||
//Command inits
|
||||
OpenLinkCommand = new RelayCommand(OpenLink);
|
||||
OpenNewModuleWindowCommand = new RelayCommand(OpenNewModuleWindow);
|
||||
CreateModuleCommand = new RelayCommand(CreateModule);
|
||||
|
||||
DataTable Userdata = DatabaseHandler.GetUserData(username);
|
||||
dmvm = new DashboardModuleViewModel(Userdata);
|
||||
//Sets the local module to the dashboardviewmodule modules
|
||||
Modules = dmvm.Modules;
|
||||
}
|
||||
#endregion
|
||||
|
||||
#endregion Constructor
|
||||
|
||||
#region ICommands
|
||||
|
||||
public ICommand OpenLinkCommand { get; set; }
|
||||
public ICommand OpenNewModuleWindowCommand { get; set; }
|
||||
public ICommand CreateModuleCommand { get; set; }
|
||||
#endregion
|
||||
|
||||
#endregion ICommands
|
||||
|
||||
#region Commands
|
||||
|
||||
/// <summary>
|
||||
/// Opens a given link in the default browser
|
||||
/// </summary>
|
||||
@@ -108,7 +80,7 @@ namespace Server_Dashboard {
|
||||
private void OpenLink(object param) {
|
||||
Process.Start(new ProcessStartInfo((string)param) { UseShellExecute = true });
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Creates a new window to create a new Module
|
||||
/// </summary>
|
||||
@@ -116,25 +88,14 @@ namespace Server_Dashboard {
|
||||
private void OpenNewModuleWindow(object param) {
|
||||
//Creates a new CreateModulePopup and sets this view model as datacontext
|
||||
CreateModulePopup cmp = new CreateModulePopup {
|
||||
DataContext = this
|
||||
DataContext = new CreateModuleViewModel(UserName)
|
||||
};
|
||||
//Opens it in the middle of the screen, setting the parent window as owner causes the
|
||||
//Opens it in the middle of the screen, setting the parent window as owner causes the
|
||||
//application to crash when NOT in debug mode(???)
|
||||
cmp.WindowStartupLocation = WindowStartupLocation.CenterScreen;
|
||||
cmp.ShowDialog();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// No function yes
|
||||
/// </summary>
|
||||
/// <param name="param">Nothing</param>
|
||||
private void CreateModule(object param) {
|
||||
if (!String.IsNullOrWhiteSpace(IPAdress)) {
|
||||
|
||||
} else {
|
||||
//error
|
||||
}
|
||||
}
|
||||
#endregion
|
||||
#endregion Commands
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user