Change folder structure
This commit is contained in:
167
Source/LogDashboard.UI/ViewModel/MainWindowViewModel.cs
Normal file
167
Source/LogDashboard.UI/ViewModel/MainWindowViewModel.cs
Normal file
@@ -0,0 +1,167 @@
|
||||
//******************************************************************************//
|
||||
// MainWindowViewModel.cs
|
||||
// 12/4/2023
|
||||
//
|
||||
// RAYTHEON PROPRIETARY: THIS DOCUMENT CONTAINS DATA OR INFORMATION
|
||||
// PROPRIETARY TO RAYTHEON COMPANY AND IS RESTRICTED TO USE ONLY BY PERSONS
|
||||
// AUTHORIZED BY RAYTHEON COMPANY IN WRITING TO USE IT. DISCLOSURE TO
|
||||
// UNAUTHORIZED PERSONS WOULD LIKELY CAUSE SUBSTANTIAL COMPETITIVE HARM TO
|
||||
// RAYTHEON COMPANY'S BUSINESS POSITION. NEITHER SAID DOCUMENT NOR ITS
|
||||
// CONTENTS SHALL BE FURNISHED OR DISCLOSED TO OR COPIED OR USED BY PERSONS
|
||||
// OUTSIDE RAYTHEON COMPANY WITHOUT THE EXPRESS WRITTEN APPROVAL OF RAYTHEON
|
||||
// COMPANY.
|
||||
//
|
||||
// THIS PROPRIETARY NOTICE IS NOT APPLICABLE IF DELIVERED TO THE U.S. GOVERNMENT
|
||||
//
|
||||
// UNPUBLISHED WORK - COPYRIGHT RAYTHEON COMPANY.
|
||||
//
|
||||
// WARNING: THIS DOCUMENT CONTAINS TECHNICAL DATA AND / OR TECHNOLOGY WHOSE
|
||||
// EXPORT OR DISCLOSURE TO NON-U.S. PERSONS, WHEREVER LOCATED, IS RESTRICTED
|
||||
// BY THE INTERNATIONAL TRAFFIC IN ARMS REGULATIONS (ITAR) (22 C.F.R. SECTION
|
||||
// 120-130) OR THE EXPORT ADMINISTRATION REGULATIONS (EAR) (15 C.F.R. SECTION
|
||||
// 730-774). THIS DOCUMENT CANNOT BE EXPORTED (E.G., PROVIDED TO A SUPPLIER
|
||||
// OUTSIDE OF THE UNITED STATES) OR DISCLOSED TO A NON-U.S. PERSON, WHEREVER
|
||||
// LOCATED, UNTIL A FINAL JURISDICTION AND CLASSIFICATION DETERMINATION HAS
|
||||
// BEEN COMPLETED AND APPROVED BY RAYTHEON, AND ANY REQUIRED U.S. GOVERNMENT
|
||||
// APPROVALS HAVE BEEN OBTAINED. VIOLATIONS ARE SUBJECT TO SEVERE CRIMINAL
|
||||
// PENALTIES.
|
||||
//
|
||||
// DOD 5220.22-M, INDUSTRIAL SECURITY MANUAL, CHAPTER 5, SECTION 1 THROUGH 9 :
|
||||
// FOR CLASSIFIED DOCUMENTS FOLLOW THE PROCEDURES IN OR DOD 5200.1-R,
|
||||
// INFORMATION SECURITY PROGRAM, CHAPTER 6. FOR UNCLASSIFIED, LIMITED DOCUMENTS
|
||||
// DESTROY BY ANY METHOD THAT WILL PREVENT DISCLOSURE OF CONTENTS OR
|
||||
// RECONSTRUCTION OF THE DOCUMENT.
|
||||
// POC: Alex Kravchenko (1118268)
|
||||
//******************************************************************************//
|
||||
using ControlzEx.Theming;
|
||||
using GalaSoft.MvvmLight;
|
||||
using GalaSoft.MvvmLight.Messaging;
|
||||
using MahApps.Metro.Controls.Dialogs;
|
||||
using System.Windows;
|
||||
using System.Windows.Media;
|
||||
|
||||
namespace Raytheon.LogDashboard.ViewModel
|
||||
{
|
||||
public class MainWindowViewModel : ViewModelBase
|
||||
{
|
||||
protected static LogDashViewModelLocator LocatorInstance;
|
||||
private IDialogCoordinator _dialogCoordinator;
|
||||
|
||||
public MainWindowViewModel(IDialogCoordinator instance)
|
||||
{
|
||||
_dialogCoordinator = instance;
|
||||
|
||||
Messenger.Default.Register<string>(this, "ColorChange", ColorChangeHandler);
|
||||
Messenger.Default.Register<string>(this, "ThemeChange", ThemeChangeHandler);
|
||||
|
||||
Messenger.Default.Register<string>(this, "DisplayCustomMessage", DisplayCustomMessageHandler);
|
||||
|
||||
LocatorInstance = (Application.Current.Resources["LogDashLocator"] as LogDashViewModelLocator);
|
||||
}
|
||||
|
||||
private void ThemeChangeHandler(string theme)
|
||||
{
|
||||
if(!string.IsNullOrEmpty(theme))
|
||||
{
|
||||
if(theme.Contains("Dark"))
|
||||
{
|
||||
ThemeManager.Current.ChangeThemeBaseColor(Application.Current.MainWindow, "Dark");
|
||||
}
|
||||
else
|
||||
{
|
||||
ThemeManager.Current.ChangeThemeBaseColor(Application.Current.MainWindow, "Light");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void ColorChangeHandler(string selectedColor)
|
||||
{
|
||||
if(!string.IsNullOrEmpty(selectedColor) && Application.Current.MainWindow != null)
|
||||
{
|
||||
ThemeManager.Current.ChangeThemeColorScheme(Application.Current.MainWindow, selectedColor);
|
||||
|
||||
Application.Current.Resources["MahApps.Brushes.ToggleSwitch.FillOn"] = ColorConverter.ConvertFromString(selectedColor);
|
||||
|
||||
RaisePropertyChanged(() => IconColor);
|
||||
}
|
||||
}
|
||||
|
||||
public SolidColorBrush IconColor
|
||||
{
|
||||
get => LocatorInstance.SelectedColorTheme.Color;
|
||||
}
|
||||
|
||||
public static double PreviousWindowHeight
|
||||
{
|
||||
get { return Properties.Settings.Default.PreviousWindowHeight; }
|
||||
set { Properties.Settings.Default.PreviousWindowHeight = value; }
|
||||
}
|
||||
public static double CurrentWindowHeight
|
||||
{
|
||||
get { return Properties.Settings.Default.CurrentWindowHeight; }
|
||||
set
|
||||
{
|
||||
Properties.Settings.Default.PreviousWindowHeight = Properties.Settings.Default.CurrentWindowHeight;
|
||||
Properties.Settings.Default.CurrentWindowHeight = value;
|
||||
Properties.Settings.Default.Save();
|
||||
}
|
||||
}
|
||||
|
||||
public static double PreviousWindowWidth
|
||||
{
|
||||
get { return Properties.Settings.Default.PreviousWindowWidth; }
|
||||
set { Properties.Settings.Default.PreviousWindowWidth = value; }
|
||||
}
|
||||
public static double CurrentWindowWidth
|
||||
{
|
||||
get { return Properties.Settings.Default.CurrentWindowWidth; }
|
||||
set
|
||||
{
|
||||
Properties.Settings.Default.PreviousWindowWidth = Properties.Settings.Default.CurrentWindowWidth;
|
||||
Properties.Settings.Default.CurrentWindowWidth = value;
|
||||
Properties.Settings.Default.Save();
|
||||
}
|
||||
}
|
||||
|
||||
public static double PreviousWindowLeft
|
||||
{
|
||||
get { return Properties.Settings.Default.PreviousWindowLeft; }
|
||||
set { Properties.Settings.Default.PreviousWindowLeft = value; }
|
||||
}
|
||||
public static double CurrentWindowLeft
|
||||
{
|
||||
get { return Properties.Settings.Default.CurrentWindowLeft; }
|
||||
set
|
||||
{
|
||||
Properties.Settings.Default.PreviousWindowLeft = Properties.Settings.Default.CurrentWindowLeft;
|
||||
Properties.Settings.Default.CurrentWindowLeft = value;
|
||||
Properties.Settings.Default.Save();
|
||||
}
|
||||
}
|
||||
|
||||
public static double PreviousWindowTop
|
||||
{
|
||||
get { return Properties.Settings.Default.PreviousWindowTop; }
|
||||
set { Properties.Settings.Default.PreviousWindowTop = value; }
|
||||
}
|
||||
public static double CurrentWindowTop
|
||||
{
|
||||
get { return Properties.Settings.Default.CurrentWindowTop; }
|
||||
set
|
||||
{
|
||||
Properties.Settings.Default.PreviousWindowTop = Properties.Settings.Default.CurrentWindowTop;
|
||||
Properties.Settings.Default.CurrentWindowTop = value;
|
||||
Properties.Settings.Default.Save();
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// handles custom message with single Okay button
|
||||
/// </summary>
|
||||
/// <param name="message"></param>
|
||||
private async void DisplayCustomMessageHandler(string message)
|
||||
{
|
||||
await _dialogCoordinator.ShowMessageAsync(this, "Log Dashboard", message).ConfigureAwait(false);
|
||||
}
|
||||
}
|
||||
}
|
||||
58
Source/LogDashboard.UI/ViewModel/ViewModelLocator.cs
Normal file
58
Source/LogDashboard.UI/ViewModel/ViewModelLocator.cs
Normal file
@@ -0,0 +1,58 @@
|
||||
//******************************************************************************//
|
||||
// ViewModelLocator.cs
|
||||
// 12/4/2023
|
||||
//
|
||||
// RAYTHEON PROPRIETARY: THIS DOCUMENT CONTAINS DATA OR INFORMATION
|
||||
// PROPRIETARY TO RAYTHEON COMPANY AND IS RESTRICTED TO USE ONLY BY PERSONS
|
||||
// AUTHORIZED BY RAYTHEON COMPANY IN WRITING TO USE IT. DISCLOSURE TO
|
||||
// UNAUTHORIZED PERSONS WOULD LIKELY CAUSE SUBSTANTIAL COMPETITIVE HARM TO
|
||||
// RAYTHEON COMPANY'S BUSINESS POSITION. NEITHER SAID DOCUMENT NOR ITS
|
||||
// CONTENTS SHALL BE FURNISHED OR DISCLOSED TO OR COPIED OR USED BY PERSONS
|
||||
// OUTSIDE RAYTHEON COMPANY WITHOUT THE EXPRESS WRITTEN APPROVAL OF RAYTHEON
|
||||
// COMPANY.
|
||||
//
|
||||
// THIS PROPRIETARY NOTICE IS NOT APPLICABLE IF DELIVERED TO THE U.S. GOVERNMENT
|
||||
//
|
||||
// UNPUBLISHED WORK - COPYRIGHT RAYTHEON COMPANY.
|
||||
//
|
||||
// WARNING: THIS DOCUMENT CONTAINS TECHNICAL DATA AND / OR TECHNOLOGY WHOSE
|
||||
// EXPORT OR DISCLOSURE TO NON-U.S. PERSONS, WHEREVER LOCATED, IS RESTRICTED
|
||||
// BY THE INTERNATIONAL TRAFFIC IN ARMS REGULATIONS (ITAR) (22 C.F.R. SECTION
|
||||
// 120-130) OR THE EXPORT ADMINISTRATION REGULATIONS (EAR) (15 C.F.R. SECTION
|
||||
// 730-774). THIS DOCUMENT CANNOT BE EXPORTED (E.G., PROVIDED TO A SUPPLIER
|
||||
// OUTSIDE OF THE UNITED STATES) OR DISCLOSED TO A NON-U.S. PERSON, WHEREVER
|
||||
// LOCATED, UNTIL A FINAL JURISDICTION AND CLASSIFICATION DETERMINATION HAS
|
||||
// BEEN COMPLETED AND APPROVED BY RAYTHEON, AND ANY REQUIRED U.S. GOVERNMENT
|
||||
// APPROVALS HAVE BEEN OBTAINED. VIOLATIONS ARE SUBJECT TO SEVERE CRIMINAL
|
||||
// PENALTIES.
|
||||
//
|
||||
// DOD 5220.22-M, INDUSTRIAL SECURITY MANUAL, CHAPTER 5, SECTION 1 THROUGH 9 :
|
||||
// FOR CLASSIFIED DOCUMENTS FOLLOW THE PROCEDURES IN OR DOD 5200.1-R,
|
||||
// INFORMATION SECURITY PROGRAM, CHAPTER 6. FOR UNCLASSIFIED, LIMITED DOCUMENTS
|
||||
// DESTROY BY ANY METHOD THAT WILL PREVENT DISCLOSURE OF CONTENTS OR
|
||||
// RECONSTRUCTION OF THE DOCUMENT.
|
||||
// POC: Alex Kravchenko (1118268)
|
||||
//******************************************************************************//
|
||||
|
||||
// Ignore Spelling: Locator
|
||||
|
||||
using CommonServiceLocator;
|
||||
using GalaSoft.MvvmLight;
|
||||
using GalaSoft.MvvmLight.Ioc;
|
||||
using MahApps.Metro.Controls.Dialogs;
|
||||
|
||||
namespace Raytheon.LogDashboard.ViewModel
|
||||
{
|
||||
public class ViewModelLocator : ViewModelBase
|
||||
{
|
||||
public ViewModelLocator()
|
||||
{
|
||||
ServiceLocator.SetLocatorProvider(() => SimpleIoc.Default);
|
||||
|
||||
SimpleIoc.Default.Register(() => new MainWindowViewModel(DialogCoordinator.Instance));
|
||||
SimpleIoc.Default.Register<LogDashboardViewModel>();
|
||||
}
|
||||
public static MainWindowViewModel Main => ServiceLocator.Current.GetInstance<MainWindowViewModel>();
|
||||
public static LogDashboardViewModel LogDashboard => ServiceLocator.Current.GetInstance<LogDashboardViewModel>();
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user