protected override void OnPaint(PaintEventArgs e) { base.OnPaint(e); for (int i = 0; i < 20; i++) { IWindow redWindow = WindowFactory.GetWindow("Red"); redWindow.Draw( e.Graphics, this.GetRandomNumber(), this.GetRandomNumber(), this.GetRandomNumber(), this.GetRandomNumber()); } for (int i = 0; i < 20; i++) { IWindow stoneTile = WindowFactory.GetWindow("Blue"); stoneTile.Draw( e.Graphics, this.GetRandomNumber(), this.GetRandomNumber(), this.GetRandomNumber(), this.GetRandomNumber()); } this.lblObjectCounter.Text = "Total Objects Created : " + Convert.ToString(RedWindow.ObjectCounter + BlueWindow.ObjectCounter); }
private void InitCommands() { WatchSaintCommand = new RelayCommand(x => { WatchSaintViewModel watchSaint = new WatchSaintViewModel(); watchSaint.SelectedSaint = Saints.Get((int)x); factory.GetWindow(watchSaint, "WatchSaintView").ShowDialog(); }); SaveCommand = new RelayCommand(x => { dataService.Save(Saints); }); LoadCommand = new RelayCommand(x => { Repository <Saint> loaded = dataService.Load(); Saints.Data.Clear(); foreach (var i in loaded.Data) { saints.Data.Add(i); } SaintsView.Refresh(); }); StartupLoadCommand = new RelayCommand(x => { Repository <Saint> loaded = dataService.StartupLoad(); foreach (var i in loaded.Data) { saints.Data.Add(i); } SaintsView.Refresh(); }); AddCommand = new RelayCommand(x => { Saint saint = new Saint(); saint.ImagePath = @"../images/default.png"; saint.Name = "[Name]"; saint.Id = (Saints.Data.Max(b => b.Id)) + 1; Saints.Add(saint); }); RemoveCommand = new RelayCommand(x => { Saints.Delete((int)x); }); GetSaints = new RelayCommand(x => { foreach (Saint saint in Saint.GetSaints()) { Saints.Add(saint); } Notify(); }); EditImageCommand = new RelayCommand(x => { OpenFileDialog dlg = new OpenFileDialog(); dlg.Filter = "Image Files|*.jpg;*.jpeg;*.png;*.gif;*.tif;..."; var result = dlg.ShowDialog(); if (result == true) { Saint saint = Saints.Get((int)x); saint.ImagePath = dlg.FileName; } }); CloseWindowCommand = new RelayCommand(x => { dataService.ClosingSave(Saints); if (x is Window window) { window.Close(); } }); ChangeThemeCommand = new RelayCommand(x => { if ((string)x == "Dark") { foreach (var resource in Theme.GetLightTheme()) { Application.Current.Resources.MergedDictionaries.Remove(resource); } foreach (var resource in Theme.GetDarkTheme()) { Application.Current.Resources.MergedDictionaries.Add(resource); } } else { foreach (var resource in Theme.GetDarkTheme()) { Application.Current.Resources.MergedDictionaries.Remove(resource); } foreach (var resource in Theme.GetLightTheme()) { Application.Current.Resources.MergedDictionaries.Add(resource); } } }); SortCommand = new RelayCommand(x => { SaintsView.SortDescriptions.Clear(); SaintsView.SortDescriptions.Add(new SortDescription(x.ToString(), ListSortDirection.Ascending)); }); ChangeLanguageCommand = new RelayCommand(x => { var ru = Language.GetRussian(); var eng = Language.GetEnglish(); if ((string)x == "eng") { Application.Current.Resources.MergedDictionaries.Remove(ru); Application.Current.Resources.MergedDictionaries.Add(eng); } else { Application.Current.Resources.MergedDictionaries.Remove(eng); Application.Current.Resources.MergedDictionaries.Add(ru); } }); }
/// <summary> /// Gets the window view. /// Init view in collection WINDOWS and view impliment interface IWindow /// </summary> /// <returns>The window view.</returns> /// <typeparam name="T">The 1st type parameter.</typeparam> protected IWindow GetWindow <T>() where T : IWindow { return(WindowFactory .GetWindow(this, typeof(T).Name)); }