public JobEditorViewModel(IShellService shellService, IJobService jobService, IForcesService forcesService, Job job) { this.shellService = shellService; this.jobService = jobService; this.forcesService = forcesService; this.Job = job ?? new Job(); this.BeginJobEdit(this.Job); this.isSaveRequested = false; this.forcesList = new ObservableCollection <Force>(); this.ForcesView = new ListCollectionView(this.forcesList); // Set up messenger completion values this.jobService.GetAllJobs().Select(j => j.Messenger).Distinct().ToList() .ForEach(messenger => this.MessengerValues.Add(messenger)); this.AddMessengerValueIfNotExists("Leitstelle"); // Configure shell this.ShellViewState = ShellViewState.Embedded; this.undockingCommandBarButton = new ShellCommandBarButton { ImageUri = new Uri("pack://application:,,/Resources/Images/ShellIcons/open_in_shell.scale-150.png"), Label = "Abdocken", Command = new RelayCommand(() => { this.View.DataContext = new JobEditorViewModel(this.shellService, this.jobService, this.forcesService); var newView = new JobEditorView { DataContext = this }; this.shellService.ShowInNewTab("Neuer Auftrag", newView, this, true); }), Width = 284, Visibility = this.Job.IsNew ? Visibility.Visible : Visibility.Collapsed }; this.showInTabCommandBarButton = new ShellCommandBarButton { ImageUri = new Uri("pack://application:,,/Resources/Images/ShellIcons/open_in_shell.scale-150.png"), Label = "Im Hauptfenster andocken", Command = new RelayCommand(() => { this.shellService.ShowWindowInNewTab(this.window); this.window = null; }), Visibility = Visibility.Collapsed }; this.showInWindowCommandBarButton = new ShellCommandBarButton { ImageUri = new Uri("pack://application:,,/Resources/Images/ShellIcons/open_in_window.scale-150.png"), Label = "In Fenster öffnen", Command = new RelayCommand(() => { var shellViewModel = SimpleIoc.Default.GetInstance <ShellViewModel>(); var shellTab = shellViewModel.ShellTabs.Single(tab => Equals(tab.View, this.View)); this.window = this.shellService.ShowTabInNewWindow(shellTab); }), Visibility = this.Job.IsNew ? Visibility.Collapsed : Visibility.Visible }; this.saveAndCloseCommandBarButton = new ShellCommandBarButton { ImageUri = new Uri("pack://application:,,/Resources/Images/ShellIcons/save_green.scale-150.png"), Label = "Speichern und schließen", Command = this.SaveJobCommand, Visibility = this.Job.IsNew ? Visibility.Collapsed : Visibility.Visible }; this.saveAndNextCommandBarButton = new ShellCommandBarButton { ImageUri = new Uri("pack://application:,,/Resources/Images/ShellIcons/save_green.scale-150.png"), Label = "Speichern und neuen Auftrag anlegen", Command = this.SaveJobCommand, Visibility = this.Job.IsNew ? Visibility.Visible : Visibility.Collapsed }; this.cancelCommandBarButton = new ShellCommandBarButton { ImageUri = new Uri("pack://application:,,/Resources/Images/ShellIcons/delete_sign_red.scale-150.png"), Label = "Abbrechen", Command = this.CancelJobEditCommand, Visibility = this.Job.IsNew ? Visibility.Visible : Visibility.Collapsed }; this.cancelAndCloseCommandBarButton = new ShellCommandBarButton { ImageUri = new Uri("pack://application:,,/Resources/Images/ShellIcons/delete_sign_red.scale-150.png"), Label = "Abbrechen und schließen", Command = this.CancelJobEditCommand, Visibility = this.Job.IsNew ? Visibility.Collapsed : Visibility.Visible }; this.CommandBarItems = new ObservableCollection <ShellCommandBarItem> { this.undockingCommandBarButton, this.showInTabCommandBarButton, this.showInWindowCommandBarButton, new ShellCommandBarSeparator(), this.saveAndCloseCommandBarButton, this.saveAndNextCommandBarButton, this.cancelAndCloseCommandBarButton, this.cancelCommandBarButton }; }
public JobToForceViewModel(IShellService shellService, IForcesService forceService, IJobService jobService, Force force) { this.shellService = shellService; this.forceService = forceService; this.jobService = jobService; this.SelectedForce = force; // this.selectedJob = new Job(); this.availableJobsList = new ObservableCollection <Job>(); this.AvailableJobsView = new ListCollectionView(this.availableJobsList); this.assignedJobsList = new ObservableCollection <Job>(); this.AssignedJobsView = new ListCollectionView(this.assignedJobsList); this.changedJobs = new ObservableCollection <Job>(); // Configure shell this.ShellViewState = ShellViewState.Embedded; this.undockingCommandBarButton = new ShellCommandBarButton { ImageUri = new Uri("pack://application:,,/Resources/Images/ShellIcons/open_in_shell.scale-150.png"), Label = "Abdocken", Command = new RelayCommand(() => { this.View.DataContext = new ForceToJobViewModel(this.shellService, this.forceService, this.jobService, this.SelectedJob); var newView = new ForceToJob { DataContext = this }; this.shellService.ShowInNewTab("Neue Zuweisung", newView, this, true); }), Width = 284 }; this.showInTabCommandBarButton = new ShellCommandBarButton { ImageUri = new Uri("pack://application:,,/Resources/Images/ShellIcons/open_in_shell.scale-150.png"), Label = "Im Hauptfenster andocken", Command = new RelayCommand(() => { this.shellService.ShowWindowInNewTab(this.window); this.window = null; }), Visibility = Visibility.Collapsed }; this.showInWindowCommandBarButton = new ShellCommandBarButton { ImageUri = new Uri("pack://application:,,/Resources/Images/ShellIcons/open_in_window.scale-150.png"), Label = "In Fenster öffnen", Command = new RelayCommand(() => { var shellViewModel = SimpleIoc.Default.GetInstance <ShellViewModel>(); var shellTab = Enumerable.Single(shellViewModel.ShellTabs, tab => Equals(tab.View, this.View)); this.window = this.shellService.ShowTabInNewWindow(shellTab); }) }; this.saveAndCloseCommandBarButton = new ShellCommandBarButton { ImageUri = new Uri("pack://application:,,/Resources/Images/ShellIcons/save_green.scale-150.png"), Label = "Speichern und schließen", Command = this.SaveJobAssignmentCommand }; this.cancelAndCloseCommandBarButton = new ShellCommandBarButton { ImageUri = new Uri("pack://application:,,/Resources/Images/ShellIcons/delete_sign_red.scale-150.png"), Label = "Abbrechen und schließen", Command = this.CancelJobAssignmentCommand }; this.CommandBarItems = new ObservableCollection <ShellCommandBarItem> { this.undockingCommandBarButton, this.showInTabCommandBarButton, this.showInWindowCommandBarButton, new ShellCommandBarSeparator(), this.saveAndCloseCommandBarButton, this.cancelAndCloseCommandBarButton }; }
public ForceEditorViewModel(IShellService shellService, IForcesService forceService, Force force) { this.shellService = shellService; this.forceService = forceService; this.Force = force ?? new Force(); this.BeginForceEdit(this.Force); //this.personsUnmodified = this.Force.Persons.Clone().ToList(); //foreach (var p in this.Force.Persons) // personsUnmodified.Add(p); //this.Persons = new ObservableCollection<Person>(this.Force.Persons); //this.PersonsView = new ListCollectionView(this.Force.Persons); this.ShellViewState = ShellViewState.Embedded; this.undockingCommandBarButton = new ShellCommandBarButton { ImageUri = new Uri("pack://application:,,/Resources/Images/ShellIcons/open_in_shell.scale-150.png"), Label = "Abdocken", Command = new RelayCommand(() => { this.View.DataContext = new ForceEditorViewModel(this.shellService, this.forceService); var newView = new ForceEditorView { DataContext = this }; this.shellService.ShowInNewTab("Neue Einheit", newView, this, true); }), Width = 284, Visibility = this.Force.IsNew ? Visibility.Visible : Visibility.Collapsed }; this.showInTabCommandBarButton = new ShellCommandBarButton { ImageUri = new Uri("pack://application:,,/Resources/Images/ShellIcons/open_in_shell.scale-150.png"), Label = "Im Hauptfenster andocken", Command = new RelayCommand(() => { this.shellService.ShowWindowInNewTab(this.window); this.window = null; }), Visibility = Visibility.Collapsed }; this.showInWindowCommandBarButton = new ShellCommandBarButton { ImageUri = new Uri("pack://application:,,/Resources/Images/ShellIcons/open_in_window.scale-150.png"), Label = "In Fenster öffnen", Command = new RelayCommand(() => { var shellViewModel = SimpleIoc.Default.GetInstance <ShellViewModel>(); var shellTab = shellViewModel.ShellTabs.Single(tab => Equals(tab.View, this.View)); this.window = this.shellService.ShowTabInNewWindow(shellTab); }), Visibility = this.Force.IsNew ? Visibility.Collapsed : Visibility.Visible }; this.saveAndCloseCommandBarButton = new ShellCommandBarButton { ImageUri = new Uri("pack://application:,,/Resources/Images/ShellIcons/save_green.scale-150.png"), Label = "Speichern und schließen", Command = this.SaveForceCommand, Visibility = this.Force.IsNew ? Visibility.Collapsed : Visibility.Visible }; this.saveAndNextCommandBarButton = new ShellCommandBarButton { ImageUri = new Uri("pack://application:,,/Resources/Images/ShellIcons/save_green.scale-150.png"), Label = "Speichern und neue Einheit anlegen", Command = this.SaveForceCommand, Visibility = this.Force.IsNew ? Visibility.Visible : Visibility.Collapsed }; this.CommandBarItems = new ObservableCollection <ShellCommandBarItem> { this.undockingCommandBarButton, this.showInTabCommandBarButton, this.showInWindowCommandBarButton, new ShellCommandBarSeparator(), this.saveAndCloseCommandBarButton, this.saveAndNextCommandBarButton, new ShellCommandBarButton { ImageUri = new Uri("pack://application:,,/Resources/Images/ShellIcons/delete_sign_red.scale-150.png"), Label = "Abbrechen", Command = this.CancelForceEditCommand } }; }