internal FrameworkElement ElementFromDocument(VmcDocument document) { FrameworkElement frameworkElement = this.documents.First((FrameworkElement o) => o.DataContext == document); if (frameworkElement != null && VisualTreeHelper.GetChildrenCount(frameworkElement) > 0) { return((FrameworkElement)VisualTreeHelper.GetChild(frameworkElement, 0)); } return(null); }
private void TabItemCloseButton_MouseLeftButtonDown(object sender, MouseButtonEventArgs e) { FrameworkElement frameworkElement = (FrameworkElement)sender; FrameworkElement frameworkElement2 = (FrameworkElement)frameworkElement.DataContext; VmcDocument vmcDocument = (VmcDocument)frameworkElement2.DataContext; if (!this.QueryClose(vmcDocument)) { VmcStudioUtil.Application.Documents.Remove(vmcDocument); } }
private void StartMenuExecuted(object sender, ExecutedRoutedEventArgs e) { VmcStudioApp application = VmcStudioUtil.Application; VmcDocument vmcDocument = application.Documents.FirstOrDefault((VmcDocument o) => o is StartMenuDocument); if (vmcDocument == null) { vmcDocument = new StartMenuDocument(application); application.Documents.Add(vmcDocument); } application.SelectedDocument = vmcDocument; e.Handled = true; }
private bool QueryClose(VmcDocument document) { if (document.IsDirty) { FrameworkElement target = this.ElementFromDocument(document); if (ApplicationCommands.Save.CanExecute(null, target)) { MessageBoxResult messageBoxResult = MessageBox.Show(this, string.Format("Do you want to save changes to {0}?", document.Name), VmcStudioUtil.ApplicationTitle, MessageBoxButton.YesNoCancel, MessageBoxImage.Question, MessageBoxResult.Cancel); if (messageBoxResult == MessageBoxResult.Yes) { ApplicationCommands.Save.Execute(null, target); } else { if (messageBoxResult == MessageBoxResult.Cancel) { return(true); } } } } return(false); }
internal FrameworkElement ElementFromDocument(VmcDocument document) { FrameworkElement frameworkElement = this.documents.First((FrameworkElement o) => o.DataContext == document); if (frameworkElement != null && VisualTreeHelper.GetChildrenCount(frameworkElement) > 0) { return (FrameworkElement)VisualTreeHelper.GetChild(frameworkElement, 0); } return null; }
private bool QueryClose(VmcDocument document) { if (document.IsDirty) { FrameworkElement target = this.ElementFromDocument(document); if (ApplicationCommands.Save.CanExecute(null, target)) { MessageBoxResult messageBoxResult = MessageBox.Show(this, string.Format("Do you want to save changes to {0}?", document.Name), VmcStudioUtil.ApplicationTitle, MessageBoxButton.YesNoCancel, MessageBoxImage.Question, MessageBoxResult.Cancel); if (messageBoxResult == MessageBoxResult.Yes) { ApplicationCommands.Save.Execute(null, target); } else { if (messageBoxResult == MessageBoxResult.Cancel) { return true; } } } } return false; }