Issue #5
This commit is contained in:
@@ -4,19 +4,14 @@ using System.Collections.ObjectModel;
|
||||
using System.Text;
|
||||
|
||||
namespace Server_Dashboard {
|
||||
/// <summary>
|
||||
/// View Model for the modules
|
||||
/// </summary>
|
||||
class DashboardModuleViewModel : BaseViewModel {
|
||||
//List with all Modules inside
|
||||
public ObservableCollection<DashboardModule> Modules { get; set; }
|
||||
private int gpuUsage;
|
||||
|
||||
public int GPUUsage {
|
||||
get { return gpuUsage; }
|
||||
set {
|
||||
if(value != gpuUsage)
|
||||
gpuUsage = value;
|
||||
OnPropertyChanged(nameof(gpuUsage));
|
||||
}
|
||||
}
|
||||
|
||||
//Creates Default Modules, remove before release and when implementing the actual data comming from the socket
|
||||
public DashboardModuleViewModel() {
|
||||
Modules = new ObservableCollection<DashboardModule>();
|
||||
for (int i = 0; i < 10; i++) {
|
||||
|
||||
@@ -6,10 +6,17 @@ using System.Windows.Input;
|
||||
using Server_Dashboard_Socket;
|
||||
|
||||
namespace Server_Dashboard {
|
||||
/// <summary>
|
||||
/// View Model for the Dashboard
|
||||
/// </summary>
|
||||
class DashboardViewModel : BaseViewModel {
|
||||
private string userName = "Username";
|
||||
private DashboardModuleViewModel dmvm = new DashboardModuleViewModel();
|
||||
#region Private Values
|
||||
private readonly DashboardModuleViewModel dmvm = new DashboardModuleViewModel();
|
||||
#endregion
|
||||
|
||||
#region Properties
|
||||
//The Username displayed defaults to Username
|
||||
private string userName = "Username";
|
||||
public string UserName {
|
||||
get { return userName; }
|
||||
set {
|
||||
@@ -19,8 +26,8 @@ namespace Server_Dashboard {
|
||||
}
|
||||
}
|
||||
|
||||
//List that contains every Module
|
||||
private ObservableCollection<DashboardModule> modules;
|
||||
|
||||
public ObservableCollection<DashboardModule> Modules {
|
||||
get { return modules; }
|
||||
set {
|
||||
@@ -29,32 +36,59 @@ namespace Server_Dashboard {
|
||||
OnPropertyChanged(nameof(modules));
|
||||
}
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region Constructor
|
||||
public DashboardViewModel() {
|
||||
//Creates a new echo server, remove b4 release
|
||||
EchoServer echoServer = new EchoServer();
|
||||
echoServer.Start();
|
||||
//Command inits
|
||||
OpenLinkCommand = new RelayCommand(OpenLink);
|
||||
OpenNewModuleWindowCommand = new RelayCommand(OpenNewModuleWindow);
|
||||
CreateModuleCommand = new RelayCommand(CreateModule);
|
||||
//Sets the local module to the dashboardviewmodule modules
|
||||
Modules = dmvm.Modules;
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region ICommands
|
||||
public ICommand OpenLinkCommand { get; set; }
|
||||
public ICommand OpenNewModuleWindowCommand { get; set; }
|
||||
public ICommand CreateModuleCommand { get; set; }
|
||||
#endregion
|
||||
|
||||
#region Commands
|
||||
/// <summary>
|
||||
/// Opens a given link in the default browser
|
||||
/// </summary>
|
||||
/// <param name="param">The Link to be opened e.g. https://github.com/Crylia/Server-Dashboard </param>
|
||||
private void OpenLink(object param) {
|
||||
Process.Start(new ProcessStartInfo((string)param) { UseShellExecute = true });
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Creates a new window to create a new Module
|
||||
/// </summary>
|
||||
/// <param name="param">Nothing</param>
|
||||
private void OpenNewModuleWindow(object param) {
|
||||
//Creates a new CreateModulePopup and sets this view model as datacontext
|
||||
CreateModulePopup cmp = new CreateModulePopup {
|
||||
DataContext = this
|
||||
};
|
||||
//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) {
|
||||
|
||||
}
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user