/// <summary> /// This Constructor is called everytime to ensure consistency. /// This Constructor should be the one called DIRECTLY by all Test Harness applications. /// Allows you to call with your own IDialogService or Adornment that will not leave a Dialog or /// Message box on the Screen. /// </summary> /// <param name="iDlg"> </param> /// <param name="iSnd"></param> public SweeperViewModel(IDialogService iDlg, IAdornGameWithSounds iSnd) { if (System.Windows.Application.Current.MainWindow == null) { soundAdornment = new NullSoundAdornment(); // Turn off Sounds in Designer } else { soundAdornment = iSnd; } dialogService = iDlg; tmr = new Timer(1000); tmr.Elapsed += tmr_Elapsed; //Although this is Static it is ok because the two objects have the same lifetimes RelayCommand.NewCommandItemEvent += RelayCommand_NewCommandItemEvent; if (System.Windows.Application.Current.MainWindow == null) { NewGame(); } App.ChangeThemeEvent += App_ChangeThemeEvent; //UndoRedoView urv = new UndoRedoView(); RelayCommand.RefreshStacksEvent += RelayCommand_RefreshStacksEvent; //App.SetTheme("CHOCALATE"); Themes.Clear(); String [] l = (String [])App.Current.FindResource("Themes"); foreach (String s in l) { Themes.Add(s); } String[] gt = (String[])App.Current.FindResource("GameTypes"); foreach (String s in gt) { GameTypes.Add(s); } UrVm.RefreshCommand = RefreshStacksCommand; UrVm.RedoCommand = this.RedoAllOrLastCommand; UrVm.UndoCommand = this.UndoAllOrLastCommand; //UrV.DataContext = UrVm; }
/// <summary> /// This Constructor is called everytime to ensure consistency. /// This Constructor should be the one called DIRECTLY by all Test Harness applications. /// Allows you to call with your own IDialogService or Adornment that will not leave a Dialog or /// Message box on the Screen. /// </summary> /// <param name="iDlg"> </param> /// <param name="iSnd"></param> public SweeperViewModel(IDialogService iDlg, IAdornGameWithSounds iSnd) { if (Application.Current == null || Application.Current.MainWindow == null) { soundAdornment = new NullSoundAdornment(); // Turn off Sounds in Designer } else { soundAdornment = iSnd; } dialogService = iDlg; tmr = new Timer(1000); tmr.Elapsed += tmr_Elapsed; //Although this is Static it is ok because the two objects have the same lifetimes RelayCommand.NewCommandItemEvent += RelayCommand_NewCommandItemEvent; // if (System.Windows.Application.Current.MainWindow == null) NewGame(); App.ChangeThemeEvent += App_ChangeThemeEvent; RelayCommand.RefreshStacksEvent += RelayCommand_RefreshStacksEvent; Themes.Clear(); var sep = new char[] { ';' }; //String [] l = (String [])App.Current.FindResource("Themes"); var themesStr = "Chocalate;Copper;Default;KeyWest;Powder"; var l = themesStr.Split(sep); if (l == null || l.Count() == 0) { l = (String[])App.Current.FindResource("Themes"); } foreach (String s in l) { Themes.Add(s); } var gameTypesStr = "Beginner;Intermediate;Advanced;Custom"; var gt = gameTypesStr.Split(sep); if (gt == null || gt.Count() == 0) { gt = (String[])App.Current.FindResource("GameTypes"); } foreach (String s in gt) { GameTypes.Add(s); } UrVm.RefreshCommand = RefreshStacksCommand; UrVm.RedoCommand = this.RedoAllOrLastCommand; UrVm.UndoCommand = this.UndoAllOrLastCommand; //UrV.DataContext = UrVm; if (svm == null) { svm = this; } }