static Global() { s_dialogs = new DialogService(); s_dialogs.AddMapping(typeof(SettingsViewModel), typeof(SettingsWindow)); s_dialogs.AddMapping(typeof(EditPartViewModel), typeof(EditPartWindow)); s_dialogs.AddMapping(typeof(ActionDialogViewModel), typeof(ActionDialogWindow)); s_dialogs.AddMapping(typeof(UpdateViewModel), typeof(UpdateWindow)); }
public void TestGetTaskListsCommand() { var data = new DataService(); var navi = new NavigationService(); var dialog = new DialogService(); var vm = new TaskListsViewModel(data, navi, dialog); vm.GetTaskListsCommand.Execute(null); Assert.AreEqual(3, vm.TaskLists.Count); Assert.AreEqual("1", vm.SelectedTaskList.Id); Assert.AreEqual(10, vm.SelectedTaskList.Tasks.Count); }
public CustomGraphViewModel(string algorithmName, Graph graph) { this.AlgorithmName = algorithmName; this.AreInstructionsVisible = true; this.LoadGraphs = GetRandomGraphFromList; try { Func<INotifyPropertyChanged, Type> typeLocator = (t) => App.GetViewClassTypeLocalizer(t); _dialogService = new DialogService(null, typeLocator); List<Graph> graphList = new List<Graph>(); graphList.Add(graph); InitializeAlgorithmFromGraph(graphList); this.Instruction = _algorithm?.GetCurrentInstruction(); RaisePropertyChanged("CanvasNodes"); } catch (Exception ex) { MessageBox.Show("Wystąpil błąd: " + ex.Message, "Błąd", MessageBoxButton.OK, MessageBoxImage.Error); // Get the learning view window from static property and close it var openedWindows = App.Current.Windows; Window currentWindow = null; for (int i = 0; i < openedWindows.Count; i++) { if (openedWindows[i].DataContext?.GetType().Name == this.GetType().Name) { currentWindow = openedWindows[i]; break; } } // Can't close a window which practically wasn't opened yet. currentWindow.Loaded += new RoutedEventHandler((sender, e) => { (sender as Window).Close(); }); // So let's add closing handler to its Loaded event. (ProjektBD experience~ ) } }
protected override void OnStartup(StartupEventArgs e) { base.OnStartup(e); // Load settings and client versions from file (or defaults) this.CurrentSettings = LoadSettingsOrDefaults(App.SettingsFileName); this.ClientVersions = LoadClientVersionsOrDefaults(App.ClientVersionsFileName); // Initialize the main window and view model var window = new MainWindow(); var dialogService = new DialogService(window); var viewModel = new MainViewModel(this.CurrentSettings, this.ClientVersions, dialogService); // Bind the request close event to closing the window viewModel.RequestClose += delegate { window.Close(); }; // Assign the view model to the data context and display the main window window.DataContext = viewModel; window.Show(); }
static Global() { s_dialogs = new DialogService(); }
private void InitializeDialog() { IDialogService dialog = new DialogService(); dialog.Register(new Views.Dialogs.LookupContact()); dialog.Register(new Views.Dialogs.ComposeContact()); dialog.Register(new Views.Dialogs.ComposeMessage()); dialog.Register(new Views.Dialogs.Plugin()); dialog.Register(new Views.Dialogs.SerialPort()); ObjectPool.Instance.Register<IDialogService>().ImplementedBy(dialog); }
private Workspace() { Plugins = new ObservableCollection<Plugin>(); Services = new FilteredObservableCollection<Plugin>(Plugins, p => p.Type == PluginType.Service); Managers = new FilteredObservableCollection<Plugin>(Plugins, p => p.Type == PluginType.Manager); Components = new FilteredObservableCollection<Plugin>(Plugins, p => p.Type == PluginType.Component); Events = new ObservableCollection<StatementFactory>(); Actions = new ObservableCollection<StatementFactory>(); Statements = new ObservableCollection<StatementFactory>(); NewProjectCommand = new DelegateCommand(null, p => { var create = true; if (null != Project && CommandHistory.HasUnsavedChanges) { DialogService.Warn(Messages.NewProject, Messages.UnsavedMessage, MessageBoxButton.YesNoCancel, r => { if (r == MessageBoxResult.Yes) { SaveProject(); } else if (r == MessageBoxResult.Cancel) { create = false; } }); } if (create) { Game game = new Game("Untitled Game"); KglGameStorage.AddDefaultUsings(game); var service = new Service(GetPlugin(typeof(RenderService))); service.SetProperty("Width", new Value(800, true)); service.SetProperty("Height", new Value(600, true)); game.AddService(service); var scene = new Scene("Scene1"); var manager = new Manager(GetPlugin(typeof(RenderManager))); scene.AddManager(manager); game.AddScene(scene); game.FirstScene = scene; Project project = new Project(); project.Game = game; DialogService.ShowDialog<ProjectDialog>(project, (result) => { if (result == true) { ProjectStorage.CreateProject(project); Project = project; } }); } }); LoadProjectCommand = new DelegateCommand(null, p => { var load = true; if (null != Project && CommandHistory.HasUnsavedChanges) { DialogService.Warn(Messages.LoadProject, Messages.UnsavedMessage, MessageBoxButton.YesNoCancel, r => { if (r == MessageBoxResult.Yes) { SaveProject(); } else if (r == MessageBoxResult.Cancel) { load = false; } }); } if (load) { DialogService.ShowLoadDialog((result, fileName) => { if (result == true) { try { LoadProject(fileName); } catch (EditorException e) { DialogService.Warn(Messages.FailedToLoad, e.Message, MessageBoxButton.OK); } } }); } }); SaveProjectCommand = new DelegateCommand(p => null != project, p => { if (null == Project.Title) { DialogService.ShowSaveDialog( (result, fileName) => { if (result == true) { Project.Title = fileName; } } ); } if (null != Project.Title) { SaveProject(); } }); RevertProjectCommand = new DelegateCommand(p => null != Project, p => RevertProject()); Assembly core = typeof(Kinectitude.Core.Base.Component).Assembly; RegisterPlugins(core); DirectoryInfo path = new DirectoryInfo(Path.Combine(Environment.CurrentDirectory, PluginDirectory)); if (path.Exists) { FileInfo[] files = path.GetFiles("*.dll"); foreach (FileInfo file in files) { Assembly asm = Assembly.LoadFrom(file.FullName); RegisterPlugins(asm); } } CommandHistory = new CommandHistory(); DialogService = new DialogService(); }
/// <summary> /// Constructor adds a set list of cities to be picked from and then /// gets the 16 day forecast for the first one /// </summary> public MainController(Page view) { _navigationService = new NavigationService(view); DialogService = new DialogService(); _repo = new CityWeatherRepository(); _cityNamesToQuery.Add("Boulder, USA", "boulder,us"); _cityNamesToQuery.Add("Banff, Canada", "banff,ca"); _cityNamesToQuery.Add("Tokyo, Japan", "tokyo"); _cityNamesToQuery.Add("Seoul, South Korea", "seoul"); _cityNamesToQuery.Add("Shanghai, China", "shanghai"); _cityNamesToQuery.Add("New York, USA", "new,york,us"); _cityNamesToQuery.Add("Mexico City, Mexico", "mexico,city"); _cityNamesToQuery.Add("Moscow, Russia", "moscow,russia"); _cityNamesToQuery.Add("Los Angeles, USA", "los,angeles"); _cityNamesToQuery.Add("Buenos Aires, Argentina", "buenos,aires"); _cityNamesToQuery.Add("Rio de Janeiro, Brazil", "rio,de,janeiro"); _cityNamesToQuery.Add("Chicago, USA", "chicago"); CityNames = new List<string>(_cityNamesToQuery.Keys); _selectedCity = CityNames.First(); RefreshAsync(); }