/// <summary> /// Launches the Task Assistant for the appropriate Task. /// </summary> /// <param name="wrapper">Task Wrapper object.</param> public void LaunchTaskAssistant(TaskWrapper wrapper) { // (Konrad) In case that someone deletes the task using the web interface // this will trigger with a null value. If the window is open let's close it and reset. if (wrapper == null) { if (TaskView == null) { return; } ((Window)TaskView).Close(); TaskView = null; return; } // (Konrad) Sort out which task has shown up if (wrapper.GetType() == typeof(FamilyTaskWrapper)) { var familyTaskWrapper = (FamilyTaskWrapper)wrapper; var viewModel = new FamilyTaskAssistantViewModel(familyTaskWrapper); if (TaskView != null) { var view = TaskView as FamilyTaskAssistantView; if (view != null) { view.DataContext = viewModel; view.Activate(); } else { // (Konrad) Currently open Window is not of this type. Let's close it. ((Window)TaskView).Close(); // (Konrad) Let's open a new one TaskView = new FamilyTaskAssistantView { DataContext = viewModel }; var unused = new WindowInteropHelper((FamilyTaskAssistantView)TaskView) { Owner = Process.GetCurrentProcess().MainWindowHandle }; ((FamilyTaskAssistantView)TaskView).Show(); } } else { TaskView = new FamilyTaskAssistantView { DataContext = viewModel }; var unused = new WindowInteropHelper((FamilyTaskAssistantView)TaskView) { Owner = Process.GetCurrentProcess().MainWindowHandle }; ((FamilyTaskAssistantView)TaskView).Show(); } } else if (wrapper.GetType() == typeof(SheetTaskWrapper)) { var sheetTaskWrapper = (SheetTaskWrapper)wrapper; var viewModel = new SheetTaskAssistantViewModel(sheetTaskWrapper); if (TaskView != null) { var view = TaskView as SheetTaskAssistantView; if (view != null) { view.DataContext = viewModel; view.Activate(); } else { // (Konrad) Currently open Window is not of this type. Let's close it. ((Window)TaskView).Close(); // (Konrad) Let's open a new one TaskView = new SheetTaskAssistantView { DataContext = viewModel }; var unused = new WindowInteropHelper((SheetTaskAssistantView)TaskView) { Owner = Process.GetCurrentProcess().MainWindowHandle }; ((SheetTaskAssistantView)TaskView).Show(); } } else { // (Konrad) Let's open a new one TaskView = new SheetTaskAssistantView { DataContext = viewModel }; var unused = new WindowInteropHelper((SheetTaskAssistantView)TaskView) { Owner = Process.GetCurrentProcess().MainWindowHandle }; ((SheetTaskAssistantView)TaskView).Show(); } } }
/// <summary> /// Handles a message emmited by Closing a Family Task. /// </summary> /// <param name="msg"></param> private void OnFamilyTaskAssistantClosed(TaskAssistantClosedMessage msg) { SelectedTask = null; Model.TaskView = null; }