private void ShowDialog() { m_Logger.Log("ValidatorPlugin.ShowDialog", Category.Debug, Priority.Medium); m_ValidatorPaneView.SelectValidatorClass(m_validatorClassToShow); var windowPopup = new PopupModalWindow(m_ShellView, UserInterfaceStrings.EscapeMnemonic(Tobi_Plugin_Validator_Lang.CmdValidationCheck_ShortDesc), m_ValidatorPaneView, PopupModalWindow.DialogButtonsSet.Close, PopupModalWindow.DialogButton.Close, true, 700, 450, null, 0, null); windowPopup.ShowFloating(null); windowPopup.Closed += (o, args) => { m_DialogIsShowing = false; // This line is not strictly necessary, but this way we make sure the CanShowDialog method (CanExecute) is called to refresh the command visual enabled/disabled status. CommandManager.InvalidateRequerySuggested(); }; m_DialogIsShowing = true; }
public void Popup() { var windowPopup = new PopupModalWindow(m_ShellView, UserInterfaceStrings.EscapeMnemonic(Tobi_Plugin_MetadataPane_Lang.CmdShowMetadata_ShortDesc), this, PopupModalWindow.DialogButtonsSet.OkCancel, PopupModalWindow.DialogButton.Ok, true, 700, 400, null, 0, null); windowPopup.IgnoreEscape = true; m_UrakawaSession.DocumentProject.Presentations.Get(0).UndoRedoManager.StartTransaction (Tobi_Plugin_MetadataPane_Lang.TransactionMetadataEdit_ShortDesc, Tobi_Plugin_MetadataPane_Lang.TransactionMetadataEdit_LongDesc, "METADATA_EDIT"); windowPopup.ShowModal(); //if the user presses "Ok", then save the changes. otherwise, don't save them. if (windowPopup.ClickedDialogButton == PopupModalWindow.DialogButton.Ok) { m_ViewModel.removeEmptyMetadata(); m_UrakawaSession.DocumentProject.Presentations.Get(0).UndoRedoManager.EndTransaction(); } else { m_UrakawaSession.DocumentProject.Presentations.Get(0).UndoRedoManager.CancelTransaction(); } }
private void OnClick_ButtonTTSVoices(object sender, RoutedEventArgs e) { //ViewModel.m_ShellView.ExecuteShellProcess(AudioPaneViewModel.TTS_VOICE_MAPPING_DIRECTORY); string text; Dictionary <string, string> ttsVoiceMap = ViewModel.readTTSVoicesMapping(out text); var editBox = new TextBoxReadOnlyCaretVisible { Text = text, AcceptsReturn = true, TextWrapping = TextWrapping.WrapWithOverflow }; var windowPopup = new PopupModalWindow(ViewModel.m_ShellView, UserInterfaceStrings.EscapeMnemonic(Tobi_Plugin_AudioPane_Lang.TTSVoiceMapping), new ScrollViewer { Content = editBox }, PopupModalWindow.DialogButtonsSet.OkCancel, PopupModalWindow.DialogButton.Ok, true, 500, 600, null, 40, null); windowPopup.EnableEnterKeyDefault = false; editBox.Loaded += new RoutedEventHandler((send, ev) => { //editBox.SelectAll(); FocusHelper.FocusBeginInvoke(editBox); }); windowPopup.ShowModal(); if (PopupModalWindow.IsButtonOkYesApply(windowPopup.ClickedDialogButton)) { string str = editBox.Text; if (string.IsNullOrEmpty(str)) { str = " "; } StreamWriter streamWriter = new StreamWriter(AudioPaneViewModel.TTS_VOICE_MAPPING_FILE, false, Encoding.UTF8); try { streamWriter.Write(str); } finally { streamWriter.Close(); } string newText; ttsVoiceMap = ViewModel.readTTSVoicesMapping(out newText); //DebugFix.assert(newText.Equals(editBox.Text, StringComparison.Ordinal)); } }
public bool askUserConfirmOverwriteFileFolder(string path, bool folder, Window owner) { m_Logger.Log(@"UrakawaSession_Save.askUserConfirmOverwriteFileFolder", Category.Debug, Priority.Medium); var label = new TextBlock { Text = (folder ? Tobi_Plugin_Urakawa_Lang.OverwriteConfirm_Folder : Tobi_Plugin_Urakawa_Lang.OverwriteConfirm_File), Margin = new Thickness(8, 0, 8, 0), HorizontalAlignment = HorizontalAlignment.Center, VerticalAlignment = VerticalAlignment.Center, Focusable = true, TextWrapping = TextWrapping.Wrap }; var iconProvider = new ScalableGreyableImageProvider(m_ShellView.LoadTangoIcon(@"dialog-warning"), m_ShellView.MagnificationLevel); var panel = new StackPanel { Orientation = Orientation.Horizontal, HorizontalAlignment = HorizontalAlignment.Center, VerticalAlignment = VerticalAlignment.Stretch, }; panel.Children.Add(iconProvider.IconLarge); panel.Children.Add(label); //panel.Margin = new Thickness(8, 8, 8, 0); var details = new TextBoxReadOnlyCaretVisible { FocusVisualStyle = (Style)Application.Current.Resources["MyFocusVisualStyle"], BorderThickness = new Thickness(1), Padding = new Thickness(6), TextReadOnly = String.Format(Tobi_Plugin_Urakawa_Lang.UrakawaSession_SavePath, path) }; var windowPopup = new PopupModalWindow(m_ShellView, UserInterfaceStrings.EscapeMnemonic(Tobi_Plugin_Urakawa_Lang.Overwrite), panel, PopupModalWindow.DialogButtonsSet.YesNo, PopupModalWindow.DialogButton.No, false, 300, 160, details, 40, owner); windowPopup.ShowModal(); if (windowPopup.ClickedDialogButton == PopupModalWindow.DialogButton.Yes) { return(true); } return(false); }
public string SaveAs() { var shellPresenter = Container.Resolve <IShellPresenter>(); var window = shellPresenter.View as Window; var panel = new FileBrowserPanel(); var windowPopup = new PopupModalWindow(shellPresenter, UserInterfaceStrings.EscapeMnemonic( UserInterfaceStrings.SaveAs), panel, PopupModalWindow.DialogButtonsSet.OkCancel, PopupModalWindow.DialogButton.Ok, true, 500, 300); var iconComputer = new ScalableGreyableImageProvider(shellPresenter.LoadTangoIcon("computer")) { IconDrawScale = shellPresenter.View.MagnificationLevel }; var iconDrive = new ScalableGreyableImageProvider(shellPresenter.LoadTangoIcon("drive-harddisk")) { IconDrawScale = shellPresenter.View.MagnificationLevel }; var iconFolder = new ScalableGreyableImageProvider(shellPresenter.LoadTangoIcon("folder")) { IconDrawScale = shellPresenter.View.MagnificationLevel }; var iconFile = new ScalableGreyableImageProvider(shellPresenter.LoadTangoIcon("text-x-generic-template")) { IconDrawScale = shellPresenter.View.MagnificationLevel }; var viewModel = new ExplorerWindowViewModel(() => windowPopup.ForceClose(PopupModalWindow.DialogButton.Ok), iconComputer, iconDrive, iconFolder, iconFile); panel.DataContext = viewModel; windowPopup.ShowModal(); if (windowPopup.ClickedDialogButton != PopupModalWindow.DialogButton.Ok) { return(null); } if (viewModel.DirViewVM.CurrentItem != null && (ObjectType)viewModel.DirViewVM.CurrentItem.DirType == ObjectType.File) { return(viewModel.DirViewVM.CurrentItem.Path); } return(null); }
private void ShowDialog() { m_Logger.Log("SettingsPlugin.ShowDialog", Category.Debug, Priority.Medium); var view = m_Container.Resolve <SettingsView>(); var windowPopup = new PopupModalWindow(m_ShellView, UserInterfaceStrings.EscapeMnemonic(Tobi_Plugin_Settings_Lang.Preferences), view, PopupModalWindow.DialogButtonsSet.OkCancel, PopupModalWindow.DialogButton.Cancel, true, 800, 500, null, 0, null); windowPopup.IgnoreEscape = true; //view.OwnerWindow = windowPopup; m_SettingsAggregator.SaveAll(); // Not strictly necessary..but just to make double-sure we've got the current settings in persistent storage. windowPopup.ShowFloating(null); windowPopup.Closed += (o, args) => { m_DialogIsShowing = false; // This line is not strictly necessary, but this way we make sure the CanShowDialog method (CanExecute) is called to refresh the command visual enabled/disabled status. CommandManager.InvalidateRequerySuggested(); if (windowPopup.ClickedDialogButton == PopupModalWindow.DialogButton.Ok) { m_SettingsAggregator.SaveAll(); } else { m_SettingsAggregator.ReloadAll(); } view = null; // TODO: view is not collected ! (at least in VS debugger) // despite PartCreationPolicy(CreationPolicy.NonShared) //GC.Collect(); //GC.WaitForFullGCComplete(); }; m_DialogIsShowing = true; }
public static void RefreshMenuItemFromItsRichCommand(MenuItem menuItem) { var command = menuItem.Command as RichDelegateCommand; if (command == null) { #if DEBUG Debugger.Break(); #endif return; } menuItem.Header = command.ShortDescription; menuItem.ToolTip = command.LongDescription + (command.KeyGesture != null ? " " + command.KeyGestureText + " " : ""); menuItem.SetValue(AutomationProperties.NameProperty, UserInterfaceStrings.EscapeMnemonic(command.ShortDescription) + " / " + menuItem.ToolTip); //button.SetValue(AutomationProperties.HelpTextProperty, command.ShortDescription); menuItem.InputGestureText = command.KeyGestureText; //Image image = command.IconProvider.IconSmall; //image.Margin = new Thickness(0, 2, 0, 2); //image.VerticalAlignment = VerticalAlignment.Center; if (command.HasIcon) { var iconProvider = command.IconProviderNotShared; iconProvider.IconMargin_Small = new Thickness(0, 2, 0, 2); //menuItem.Icon = image; var binding = new Binding { Mode = BindingMode.OneWay, Source = iconProvider, Path = new PropertyPath( PropertyChangedNotifyBase.GetMemberName(() => iconProvider.IconSmall)) }; var expr = menuItem.SetBinding(MenuItem.IconProperty, binding); } }
public bool AskUserRenameXmlID() { var label = new TextBlock { Text = "Automatically rename linked identifiers?\n(recommended)", Margin = new Thickness(8, 0, 8, 0), HorizontalAlignment = HorizontalAlignment.Center, VerticalAlignment = VerticalAlignment.Center, Focusable = true, TextWrapping = TextWrapping.Wrap }; var iconProvider = new ScalableGreyableImageProvider(m_ShellView.LoadTangoIcon("help-browser"), m_ShellView.MagnificationLevel); var panel = new StackPanel { Orientation = Orientation.Horizontal, HorizontalAlignment = HorizontalAlignment.Center, VerticalAlignment = VerticalAlignment.Stretch, }; panel.Children.Add(iconProvider.IconLarge); panel.Children.Add(label); //panel.Margin = new Thickness(8, 8, 8, 0); var popup = new PopupModalWindow(m_ShellView, UserInterfaceStrings.EscapeMnemonic("Refactor identifiers?"), panel, PopupModalWindow.DialogButtonsSet.YesNo, PopupModalWindow.DialogButton.Yes, true, 300, 160, null, 0, m_DescriptionPopupModalWindow); popup.ShowModal(); popup.IgnoreEscape = true; return(popup.ClickedDialogButton == PopupModalWindow.DialogButton.Yes); }
//private readonly List<Uri> m_RecentFiles = new List<Uri>(); //public IEnumerable<Uri> RecentFiles //{ // get // { // foreach (var fileUrl in m_RecentFiles) // { // yield return fileUrl; // } // } //} private void InitializeRecentFiles() { OpenRecentCommand = new RichDelegateCommand( Tobi_Plugin_Urakawa_Lang.CmdOpenRecent_ShortDesc, Tobi_Plugin_Urakawa_Lang.CmdOpenRecent_LongDesc, null, // KeyGesture obtained from settings (see last parameters below) m_ShellView.LoadTangoIcon(@"folder-saved-search"), () => { m_Logger.Log("UrakawaSession.OpenRecentCommand", Category.Debug, Priority.Medium); var view = m_Container.Resolve <RecentFilesView>(); var windowPopup = new PopupModalWindow(m_ShellView, UserInterfaceStrings.EscapeMnemonic( Tobi_Plugin_Urakawa_Lang.Menu_OpenRecent //Tobi_Plugin_Urakawa_Lang.CmdOpenRecent_ShortDesc ), view, PopupModalWindow.DialogButtonsSet.OkCancel, PopupModalWindow.DialogButton.Ok, true, 800, 500, null, 0, null); //view.OwnerWindow = windowPopup; windowPopup.EnableEnterKeyDefault = true; windowPopup.ShowModal(); if (windowPopup.ClickedDialogButton == PopupModalWindow.DialogButton.Ok) { if (view.RecentFilesList.SelectedItem != null) { try { OpenFile(((RecentFileWrapper)view.RecentFilesList.SelectedItem).Uri.ToString()); } catch (Exception ex) { ExceptionHandler.Handle(ex, false, m_ShellView); } } } }, () => !isAudioRecording, Settings_KeyGestures.Default, PropertyChangedNotifyBase.GetMemberName(() => Settings_KeyGestures.Default.Keyboard_OpenRecent)); m_ShellView.RegisterRichCommand(OpenRecentCommand); // ClearRecentFilesCommand = new RichDelegateCommand(Tobi_Plugin_Urakawa_Lang.CmdMenuClearRecentFiles_ShortDesc, Tobi_Plugin_Urakawa_Lang.CmdMenuClearRecentFiles_LongDesc, null, m_ShellView.LoadGnomeNeuIcon(@"Neu_view-refresh"), ClearRecentFiles, () => !isAudioRecording, null, null); m_ShellView.RegisterRichCommand(ClearRecentFilesCommand); // RecentFiles = new ObservableCollection <Uri>(); if (!File.Exists(m_RecentFiles_FilePath)) { return; } StreamReader streamReader = new StreamReader(m_RecentFiles_FilePath, Encoding.UTF8); try { string recentFileUriString; while ((recentFileUriString = streamReader.ReadLine()) != null) { Uri recentFileUri; Uri.TryCreate(recentFileUriString, UriKind.Absolute, out recentFileUri); if (recentFileUri == null //|| //TODO: should we filter the URI scheme at this stage? //recentFileUri.Scheme.ToLower() != "file" //&& recentFileUri.Scheme.ToLower() != "http" ) { continue; } if (!RecentFiles.Contains(recentFileUri)) { RecentFiles.Add(recentFileUri); } } } finally { streamReader.Close(); } }
private void OnClick_ButtonAddMetadataAttr(object sender, RoutedEventArgs e) { if (MetadatasListView.SelectedIndex < 0) { return; } Metadata md = (Metadata)MetadatasListView.SelectedItem; var mdAttr = new MetadataAttribute(); mdAttr.Name = ""; // PROMPT_MD_NAME; mdAttr.Value = ""; // PROMPT_MD_VALUE; string newName = null; string newValue = null; bool invalidSyntax = false; bool ok = true; while (ok && ( invalidSyntax || string.IsNullOrEmpty(newName) || string.IsNullOrEmpty(newValue) //|| newName == PROMPT_MD_NAME //|| newValue == PROMPT_MD_VALUE ) ) { ok = showMetadataAttributeEditorPopupDialog("Name", "Value", mdAttr, out newName, out newValue, false, true, invalidSyntax); mdAttr.Name = newName; mdAttr.Value = newValue; if (!string.IsNullOrEmpty(newName) && !string.IsNullOrEmpty(newValue)) { invalidSyntax = m_ViewModel.IsIDInValid(newName) || ( (newName.Equals(XmlReaderWriterHelper.XmlId) || newName.Equals(DiagramContentModelHelper.DiagramElementName)) && m_ViewModel.IsIDInValid(newValue) ); } } if (!ok) { return; } //bool ok = showMetadataAttributeEditorPopupDialog(mdAttr, out newName, out newValue, false); //if (ok && // newName != mdAttr.Name && newValue != mdAttr.Value) //{ if (md.OtherAttributes != null) { foreach (MetadataAttribute mAtt in md.OtherAttributes.ContentsAs_Enumerable) { if (mAtt.Name == newName) { var label = new TextBlock { Text = "This attribute already exists.", Margin = new Thickness(8, 0, 8, 0), HorizontalAlignment = HorizontalAlignment.Center, VerticalAlignment = VerticalAlignment.Center, Focusable = true, TextWrapping = TextWrapping.Wrap }; var iconProvider = new ScalableGreyableImageProvider(m_ShellView.LoadTangoIcon("dialog-warning"), m_ShellView.MagnificationLevel); var panel = new StackPanel { Orientation = Orientation.Horizontal, HorizontalAlignment = HorizontalAlignment.Center, VerticalAlignment = VerticalAlignment.Stretch, }; panel.Children.Add(iconProvider.IconLarge); panel.Children.Add(label); //panel.Margin = new Thickness(8, 8, 8, 0); var windowPopup = new PopupModalWindow(m_ShellView, UserInterfaceStrings.EscapeMnemonic("Duplicate attribute!"), panel, PopupModalWindow.DialogButtonsSet.Ok, PopupModalWindow.DialogButton.Ok, true, 300, 160, null, 0, m_DescriptionPopupModalWindow); //view.OwnerWindow = windowPopup; windowPopup.ShowModal(); return; } } } m_ViewModel.AddMetadataAttr(md, newName, newValue); MetadataAttributesListView.Items.Refresh(); MetadataAttributesListView.SelectedIndex = MetadataAttributesListView.Items.Count - 1; //FocusHelper.FocusBeginInvoke(MetadataAttributesListView); }
private bool showMetadataAttributeEditorPopupDialog(string label1, string label2, MetadataAttribute metadataAttr, out string newName, out string newValue, bool isAltContentMetadata, bool isOptionalAttributes, bool invalidSyntax) { m_Logger.Log("Descriptions.MetadataAttributeEditor", Category.Debug, Priority.Medium); var label_Name = new TextBlock { Text = label1 + ": ", Margin = new Thickness(8, 0, 8, 0), HorizontalAlignment = HorizontalAlignment.Center, VerticalAlignment = VerticalAlignment.Center, Focusable = true, TextWrapping = TextWrapping.Wrap }; var label_Value = new TextBlock { Text = label2 + ": ", Margin = new Thickness(8, 0, 8, 0), HorizontalAlignment = HorizontalAlignment.Center, VerticalAlignment = VerticalAlignment.Center, Focusable = true, TextWrapping = TextWrapping.Wrap }; //var editBox_Name = new TextBox //{ // Text = metadataAttr.Name, // TextWrapping = TextWrapping.WrapWithOverflow //}; var editBoxCombo_Name = new ComboBox //WithAutomationPeer { FocusVisualStyle = (Style)Application.Current.Resources["MyFocusVisualStyle"], Text = metadataAttr.Name, IsEditable = true, IsTextSearchEnabled = true, #if NET40 IsTextSearchCaseSensitive = false #endif //NET40 }; //var binding = new Binding //{ // Mode = BindingMode.OneWay, // Source = new RelativeSource(RelativeSourceMode.Self), // Path = new PropertyPath("SelectedItem") //}; ////var expr = editBoxCombo_Name.SetBinding(AutomationProperties.NameProperty, binding); //editBoxCombo_Name.SetValue(AutomationProperties.NameProperty, "daniel"); //editBoxCombo_Name.SelectionChanged += new SelectionChangedEventHandler( // (object sender, SelectionChangedEventArgs e) => // { // //var expr = editBoxCombo_Name.GetBindingExpression(AutomationProperties.NameProperty); // //expr.UpdateTarget(); // //editBoxCombo_Name.NotifyScreenReaderAutomationIfKeyboardFocused(); // //var txt = editBoxCombo_Name.Text; // //editBoxCombo_Name.Text = "mike"; // //editBoxCombo_Name.Text = txt; // editBoxCombo_Name.NotifyScreenReaderAutomation(); // m_Logger.Log("UP TRAGET", Category.Debug, Priority.High); // } // ); var list = new List <String>(); if (isAltContentMetadata) { list.AddRange(DiagramContentModelHelper.DIAGRAM_ElementAttributes); #if true || SUPPORT_ANNOTATION_ELEMENT list.Add(DiagramContentModelHelper.Ref); list.Add(DiagramContentModelHelper.Role); list.Add(DiagramContentModelHelper.By); #endif //SUPPORT_ANNOTATION_ELEMENT } else { if (isOptionalAttributes) { list.AddRange(DiagramContentModelHelper.DIAGRAM_MetadataAdditionalAttributeNames); } else { list.AddRange(DiagramContentModelHelper.DIAGRAM_MetadataProperties); list.Add(DiagramContentModelHelper.NA); } } editBoxCombo_Name.ItemsSource = list; // col = new ObservableCollection<string> { "Eric", "Phillip" }; //combo.SetBinding(ItemsControl.ItemsSourceProperty, new Binding { Source = col }); var editBox_Value = new TextBoxReadOnlyCaretVisible { //Watermark = TEXTFIELD_WATERMARK, Text = metadataAttr.Value, TextWrapping = TextWrapping.WrapWithOverflow }; var panel = new StackPanel { Orientation = Orientation.Vertical, HorizontalAlignment = HorizontalAlignment.Stretch, VerticalAlignment = VerticalAlignment.Center, }; var panelName = new DockPanel { HorizontalAlignment = HorizontalAlignment.Stretch, VerticalAlignment = VerticalAlignment.Center, LastChildFill = true }; panelName.Margin = new Thickness(0, 0, 0, 8); label_Name.SetValue(DockPanel.DockProperty, Dock.Left); panelName.Children.Add(label_Name); panelName.Children.Add(editBoxCombo_Name); var panelValue = new DockPanel { HorizontalAlignment = HorizontalAlignment.Stretch, VerticalAlignment = VerticalAlignment.Center, }; label_Value.SetValue(DockPanel.DockProperty, Dock.Left); panelValue.Children.Add(label_Value); panelValue.Children.Add(editBox_Value); panel.Children.Add(panelName); panel.Children.Add(panelValue); if (invalidSyntax) { var msg = new TextBlock(new Run("(invalid syntax)")) { Margin = new Thickness(0, 6, 0, 0), Focusable = true, FocusVisualStyle = (Style)Application.Current.Resources["MyFocusVisualStyle"], }; panel.Children.Add(msg); } //var details = new TextBoxReadOnlyCaretVisible // { // TextReadOnly = Tobi_Lang.ExitConfirm //}; var windowPopup = new PopupModalWindow(m_ShellView, UserInterfaceStrings.EscapeMnemonic("Edit attribute"), panel, PopupModalWindow.DialogButtonsSet.OkCancel, PopupModalWindow.DialogButton.Ok, true, 310, 200, null, 40, m_DescriptionPopupModalWindow); windowPopup.EnableEnterKeyDefault = true; editBoxCombo_Name.Loaded += new RoutedEventHandler((sender, ev) => { var textBox = ComboBoxWithAutomationPeer.GetTextBox(editBoxCombo_Name); if (textBox != null) { textBox.FocusVisualStyle = (Style)Application.Current.Resources["MyFocusVisualStyle"]; textBox.SelectAll(); } FocusHelper.FocusBeginInvoke(editBoxCombo_Name); }); editBox_Value.Loaded += new RoutedEventHandler((sender, ev) => { editBox_Value.SelectAll(); //FocusHelper.FocusBeginInvoke(editBox_Name); }); WatermarkComboBoxBehavior.SetEnableWatermark(editBoxCombo_Name, true); WatermarkComboBoxBehavior.SetLabel(editBoxCombo_Name, TEXTFIELD_WATERMARK); Style style = (Style)Application.Current.Resources[@"WatermarkTextBoxStyle"]; WatermarkComboBoxBehavior.SetLabelStyle(editBoxCombo_Name, style); WatermarkTextBoxBehavior.SetEnableWatermark(editBox_Value, true); WatermarkTextBoxBehavior.SetLabel(editBox_Value, TEXTFIELD_WATERMARK); //Style style = (Style)Application.Current.Resources[@"WatermarkTextBoxStyle"]; WatermarkTextBoxBehavior.SetLabelStyle(editBox_Value, style); windowPopup.ShowModal(); WatermarkComboBoxBehavior.SetEnableWatermark(editBoxCombo_Name, false); WatermarkTextBoxBehavior.SetEnableWatermark(editBox_Value, false); if (PopupModalWindow.IsButtonOkYesApply(windowPopup.ClickedDialogButton)) { newName = editBoxCombo_Name.Text.Trim(); newValue = editBox_Value.Text.Trim(); return(true); } newName = null; newValue = null; return(false); }
private void InitializeXukSpines() { ShowXukSpineCommand = new RichDelegateCommand( Tobi_Plugin_Urakawa_Lang.CmdShowXukSpine_ShortDesc, Tobi_Plugin_Urakawa_Lang.CmdShowXukSpine_LongDesc, null, // KeyGesture obtained from settings (see last parameters below) m_ShellView.LoadTangoIcon(@"preferences-desktop-locale"), () => { m_Logger.Log("UrakawaSession.ShowXukSpineCommand", Category.Debug, Priority.Medium); var view = m_Container.Resolve <XukSpineView>(); var windowPopup = new PopupModalWindow(m_ShellView, UserInterfaceStrings.EscapeMnemonic( Tobi_Plugin_Urakawa_Lang.CmdShowXukSpine_ShortDesc //Tobi_Plugin_Urakawa_Lang.CmdOpenRecent_ShortDesc ), view, PopupModalWindow.DialogButtonsSet.OkCancel, PopupModalWindow.DialogButton.Ok, true, 400, 600, null, 0, null); //view.OwnerWindow = windowPopup; windowPopup.EnableEnterKeyDefault = true; windowPopup.ShowModal(); if (windowPopup.ClickedDialogButton == PopupModalWindow.DialogButton.Ok) { if (view.XukSpineItemsList.SelectedItem != null) { var item = (XukSpineItemWrapper)view.XukSpineItemsList.SelectedItem; string str = item.Data.Uri.IsFile ? item.Data.Uri.LocalPath : item.Data.Uri.ToString(); if (view.check.IsChecked.GetValueOrDefault() && item.SplitMerged) { string parentDir = Path.GetDirectoryName(str); string fileNameWithoutExtn = Path.GetFileNameWithoutExtension(str); string mergedDirName = MERGE_PREFIX + @"_" + fileNameWithoutExtn; string mergedDir = Path.Combine(parentDir, mergedDirName); str = Path.Combine(mergedDir, Path.GetFileName(str)); } try { OpenFile(str); } catch (Exception ex) { ExceptionHandler.Handle(ex, false, m_ShellView); } } } else if (windowPopup.ClickedDialogButton == PopupModalWindow.DialogButton.Apply) { // IsXukSpine ? DocumentFilePath : XukSpineProjectPath bool opened = true; if (!IsXukSpine) { opened = false; try { opened = OpenFile(XukSpineProjectPath, false); } catch (Exception ex) { ExceptionHandler.Handle(ex, false, m_ShellView); } } if (opened) { ExportCommand.Execute(); } } else if (windowPopup.ClickedDialogButton == PopupModalWindow.DialogButton.Close) { // IsXukSpine ? DocumentFilePath : XukSpineProjectPath bool opened = true; if (!IsXukSpine) { opened = false; try { opened = OpenFile(XukSpineProjectPath, false); } catch (Exception ex) { ExceptionHandler.Handle(ex, false, m_ShellView); } } if (opened) { MergeProjectCommand.Execute(); } } else if (windowPopup.ClickedDialogButton == PopupModalWindow.DialogButton.No) { // IsXukSpine ? DocumentFilePath : XukSpineProjectPath bool opened = true; if (!IsXukSpine) { opened = false; try { opened = OpenFile(XukSpineProjectPath, true); } catch (Exception ex) { ExceptionHandler.Handle(ex, false, m_ShellView); } } //if (opened) //{ // ShowXukSpineCommand.Execute(); //} } }, () => HasXukSpine && !isAudioRecording, Settings_KeyGestures.Default, PropertyChangedNotifyBase.GetMemberName(() => Settings_KeyGestures.Default.Keyboard_ShowXukSpine) ); m_ShellView.RegisterRichCommand(ShowXukSpineCommand); }
private bool askUserCleanup() { return(askUser( UserInterfaceStrings.EscapeMnemonic(Tobi_Plugin_Urakawa_Lang.CmdDataCleanup_STRICT_ShortDesc) + @"?", Tobi_Plugin_Urakawa_Lang.CmdDataCleanup_STRICT_LongDesc)); }
public static void RefreshButtonFromItsRichCommand(ButtonBase button, bool showTextLabel) { var command = button.Command as RichDelegateCommand; if (command == null) { #if DEBUG Debugger.Break(); #endif return; } button.ToolTip = command.LongDescription + (!String.IsNullOrEmpty(command.KeyGestureText) ? " " + command.KeyGestureText + " " : ""); button.SetValue(AutomationProperties.NameProperty, UserInterfaceStrings.EscapeMnemonic(command.ShortDescription) + " / " + button.ToolTip); //button.SetValue(AutomationProperties.HelpTextProperty, command.ShortDescription); if (command.HasIcon && (!showTextLabel || String.IsNullOrEmpty(command.ShortDescription))) { var iconProvider = command.IconProviderNotShared; //button.Content = image; iconProvider.IconMargin_Medium = new Thickness(2, 2, 2, 2); var richButt = button as ButtonRichCommand; var binding = new Binding { Mode = BindingMode.OneWay, Source = iconProvider, Path = new PropertyPath( richButt != null && richButt.UseSmallerIcon ? PropertyChangedNotifyBase.GetMemberName(() => iconProvider.IconSmall) : PropertyChangedNotifyBase.GetMemberName(() => iconProvider.IconMedium) ) }; var expr = button.SetBinding(Button.ContentProperty, binding); } else { if (button.Tag is ImageAndTextPlaceholder) { object currentImageContent = ((ImageAndTextPlaceholder)button.Tag).m_ImageHost.Content; if (currentImageContent is Image) { var image = currentImageContent as Image; ((ImageAndTextPlaceholder)button.Tag).m_Command.IconProviderDispose(image); } if (command.HasIcon) { var iconProvider = command.IconProviderNotShared; var binding = new Binding { Mode = BindingMode.OneWay, Source = iconProvider, Path = new PropertyPath( PropertyChangedNotifyBase.GetMemberName( () => iconProvider.IconMedium)) }; var bindingExpressionBase_ = ((ImageAndTextPlaceholder)button.Tag).m_ImageHost.SetBinding( ContentControl.ContentProperty, binding); } ((ImageAndTextPlaceholder)button.Tag).m_TextHost.Content = command.ShortDescription; button.ToolTip = command.LongDescription; button.SetValue(AutomationProperties.NameProperty, UserInterfaceStrings.EscapeMnemonic(command.ShortDescription) + " / " + button.ToolTip); //button.SetValue(AutomationProperties.HelpTextProperty, command.ShortDescription); ((ImageAndTextPlaceholder)button.Tag).m_Command = command; } else { button.Content = null; var panel = new StackPanel { Orientation = Orientation.Horizontal }; var imageHost = new ContentControl { Focusable = false }; if (command.HasIcon) { var iconProvider = command.IconProviderNotShared; //Image image = command.IconProvider.IconMedium; iconProvider.IconMargin_Medium = new Thickness(2, 2, 2, 2); var binding = new Binding { Mode = BindingMode.OneWay, Source = iconProvider, Path = new PropertyPath( PropertyChangedNotifyBase.GetMemberName( () => iconProvider.IconMedium)) }; var bindingExpressionBase = imageHost.SetBinding(ContentControl.ContentProperty, binding); } panel.Children.Add(imageHost); var tb = new Label { VerticalAlignment = VerticalAlignment.Center, Content = command.ShortDescription, //Margin = new Thickness(8, 0, 0, 0) }; //tb.Content = new Run(UserInterfaceStrings.EscapeMnemonic(command.ShortDescription)); panel.Children.Add(tb); button.Content = panel; button.ToolTip = command.LongDescription; button.SetValue(AutomationProperties.NameProperty, UserInterfaceStrings.EscapeMnemonic(command.ShortDescription) + " / " + button.ToolTip); //button.SetValue(AutomationProperties.HelpTextProperty, command.ShortDescription); button.Tag = new ImageAndTextPlaceholder(imageHost, tb) { m_Command = command }; } } }
public PagesPaneViewModel( IEventAggregator eventAggregator, ILoggerFacade logger, [Import(typeof(IShellView), RequiredCreationPolicy = CreationPolicy.Shared, AllowDefault = false)] IShellView view, [Import(typeof(IUrakawaSession), RequiredCreationPolicy = CreationPolicy.Shared, AllowDefault = false)] IUrakawaSession session) { m_EventAggregator = eventAggregator; m_Logger = logger; m_ShellView = view; m_session = session; m_Logger.Log("PagesPaneViewModel.initializeCommands", Category.Debug, Priority.Medium); CommandRenumberPages = new RichDelegateCommand( Tobi_Plugin_NavigationPane_Lang.CmdNavigationRenumberPages_ShortDesc, Tobi_Plugin_NavigationPane_Lang.CmdNavigationRenumberPages_LongDesc, null, // KeyGesture obtained from settings (see last parameters below) null, //m_ShellView.LoadTangoIcon("bookmark-new"), () => { if (PagesNavigator_Pages.Count <= 0) { return; } var textBox_pageNumberStringPrefix = new TextBox() { Text = "" }; var label_pageNumberStringPrefix = new TextBlock() { Text = Tobi_Plugin_NavigationPane_Lang.PageNumberPrefix + ": ", Margin = new Thickness(8, 0, 8, 0), HorizontalAlignment = HorizontalAlignment.Center, VerticalAlignment = VerticalAlignment.Center, Focusable = true, TextWrapping = TextWrapping.Wrap }; var panel_pageNumberStringPrefix = new DockPanel() { HorizontalAlignment = HorizontalAlignment.Stretch, VerticalAlignment = VerticalAlignment.Center, Margin = new Thickness(0, 0, 0, 18) }; label_pageNumberStringPrefix.SetValue(DockPanel.DockProperty, Dock.Left); panel_pageNumberStringPrefix.Children.Add(label_pageNumberStringPrefix); panel_pageNumberStringPrefix.Children.Add(textBox_pageNumberStringPrefix); var textBox_pageNumberIntegerStart = new TextBox() { Text = "1" }; var label_pageNumberIntegerStart = new TextBlock() { Text = Tobi_Plugin_NavigationPane_Lang.PageNumberStart + ": ", Margin = new Thickness(8, 0, 8, 0), HorizontalAlignment = HorizontalAlignment.Center, VerticalAlignment = VerticalAlignment.Center, Focusable = true, TextWrapping = TextWrapping.Wrap }; var panel_pageNumberIntegerStart = new DockPanel() { HorizontalAlignment = HorizontalAlignment.Stretch, VerticalAlignment = VerticalAlignment.Center, Margin = new Thickness(0, 0, 0, 0) }; label_pageNumberIntegerStart.SetValue(DockPanel.DockProperty, Dock.Left); panel_pageNumberIntegerStart.Children.Add(label_pageNumberIntegerStart); panel_pageNumberIntegerStart.Children.Add(textBox_pageNumberIntegerStart); var panel = new StackPanel { Orientation = Orientation.Vertical, HorizontalAlignment = HorizontalAlignment.Stretch, VerticalAlignment = VerticalAlignment.Center, }; panel.Children.Add(panel_pageNumberStringPrefix); panel.Children.Add(panel_pageNumberIntegerStart); var windowPopup = new PopupModalWindow(m_ShellView, UserInterfaceStrings.EscapeMnemonic(Tobi_Plugin_NavigationPane_Lang.CmdNavigationRenumberPages_ShortDesc), panel, PopupModalWindow.DialogButtonsSet.OkCancel, PopupModalWindow.DialogButton.Ok, false, 250, 160, null, 40, null); windowPopup.ShowModal(); if (windowPopup.ClickedDialogButton != PopupModalWindow.DialogButton.Ok) { return; } string prefix = ""; if (!String.IsNullOrEmpty(textBox_pageNumberStringPrefix.Text)) { prefix = textBox_pageNumberStringPrefix.Text; } int pageNumber = 1; if (!String.IsNullOrEmpty(textBox_pageNumberIntegerStart.Text)) { try { pageNumber = Int32.Parse(textBox_pageNumberIntegerStart.Text); } catch (Exception ex) { return; } } var treeNodes = new List <TreeNode>(PagesNavigator_Pages.Count); foreach (Page marked in PagesNavigator_Pages) { treeNodes.Add(marked.TreeNode); } string pageNumberStr = ""; m_session.DocumentProject.Presentations.Get(0).UndoRedoManager.StartTransaction(Tobi_Plugin_NavigationPane_Lang.CmdNavigationRenumberPages_ShortDesc, Tobi_Plugin_NavigationPane_Lang.CmdNavigationRenumberPages_LongDesc, "PAGE_BREAKS_RENUMBER"); foreach (TreeNode treeNode in treeNodes) { pageNumberStr = prefix + (pageNumber++); var cmd = treeNode.Presentation.CommandFactory.CreateTreeNodeChangeTextCommand(treeNode, pageNumberStr); treeNode.Presentation.UndoRedoManager.Execute(cmd); } m_session.DocumentProject.Presentations.Get(0).UndoRedoManager.EndTransaction(); }, () => m_session.DocumentProject != null && !m_session.isAudioRecording && !m_session.IsXukSpine, //SelectedTreeNode != null, //!m_UrakawaSession.IsSplitMaster && Settings_KeyGestures.Default, null) //PropertyChangedNotifyBase.GetMemberName(() => Settings_KeyGestures.Default.Keyboard_RemoveAllDocMarks) ; m_ShellView.RegisterRichCommand(CommandRenumberPages); CommandFindFocusPage = new RichDelegateCommand( @"PAGES CommandFindFocus DUMMY TXT", @"PAGES CommandFindFocus DUMMY TXT", null, // KeyGesture set only for the top-level CompositeCommand null, () => { m_ShellView.RaiseEscapeEvent(); if (View != null) { IsSearchVisible = true; FocusHelper.Focus(View.SearchBox); View.SearchBox.SelectAll(); } }, () => View != null //&& View.SearchBox.Visibility == Visibility.Visible && View.SearchBox.IsEnabled, null, //Settings_KeyGestures.Default, null //PropertyChangedNotifyBase.GetMemberName(() => Settings_KeyGestures.Default.Keyboard_Nav_TOCFindNext) ); CommandFindNextPage = new RichDelegateCommand( @"PAGES CommandFindNext DUMMY TXT", //UserInterfaceStrings.PageFindNext, @"PAGES CommandFindNext DUMMY TXT", //UserInterfaceStrings.PageFindNext_, null, // KeyGesture set only for the top-level CompositeCommand null, () => { m_ShellView.RaiseEscapeEvent(); PagesNavigator.FindNext(true); }, () => PagesNavigator != null && !string.IsNullOrEmpty(PagesNavigator.SearchTerm), null, //Settings_KeyGestures.Default, null //PropertyChangedNotifyBase.GetMemberName(() => Settings_KeyGestures.Default.Keyboard_Nav_PageFindNext) ); CommandFindPrevPage = new RichDelegateCommand( @"PAGES CommandFindPrevious DUMMY TXT", //UserInterfaceStrings.PageFindPrev, @"PAGES CommandFindPrevious DUMMY TXT", //UserInterfaceStrings.PageFindPrev_, null, // KeyGesture set only for the top-level CompositeCommand null, () => { m_ShellView.RaiseEscapeEvent(); PagesNavigator.FindPrevious(true); }, () => PagesNavigator != null && !string.IsNullOrEmpty(PagesNavigator.SearchTerm), null, //Settings_KeyGestures.Default, null //PropertyChangedNotifyBase.GetMemberName(() => Settings_KeyGestures.Default.Keyboard_Nav_PageFindPrev) ); m_EventAggregator.GetEvent <ProjectLoadedEvent>().Subscribe(onProjectLoaded, ProjectLoadedEvent.THREAD_OPTION); m_EventAggregator.GetEvent <ProjectUnLoadedEvent>().Subscribe(onProjectUnLoaded, ProjectUnLoadedEvent.THREAD_OPTION); m_EventAggregator.GetEvent <PageFoundByFlowDocumentParserEvent>().Subscribe(onPageFoundByFlowDocumentParser, PageFoundByFlowDocumentParserEvent.THREAD_OPTION); m_EventAggregator.GetEvent <TreeNodeSelectionChangedEvent>().Subscribe(OnTreeNodeSelectionChanged, TreeNodeSelectionChangedEvent.THREAD_OPTION); }
private void OnClick_ButtonExport(object sender, RoutedEventArgs e) { m_Logger.Log("DescriptionView.OnClick_ButtonExport", Category.Debug, Priority.Medium); Tuple <TreeNode, TreeNode> selection = m_Session.GetTreeNodeSelection(); TreeNode node = selection.Item2 ?? selection.Item1; if (node == null || node.GetAlternateContentProperty() == null || node.GetImageMedia() == null || !(node.GetImageMedia() is ManagedImageMedia)) { return; } SampleRate sampleRate = SampleRate.Hz22050; sampleRate = Urakawa.Settings.Default.AudioExportSampleRate; bool encodeToMp3 = true; encodeToMp3 = Urakawa.Settings.Default.AudioExportEncodeToMp3; var combo = new ComboBox { Margin = new Thickness(0, 0, 0, 12) }; ComboBoxItem item1 = new ComboBoxItem(); item1.Content = AudioLib.SampleRate.Hz11025.ToString(); combo.Items.Add(item1); ComboBoxItem item2 = new ComboBoxItem(); item2.Content = AudioLib.SampleRate.Hz22050.ToString(); combo.Items.Add(item2); ComboBoxItem item3 = new ComboBoxItem(); item3.Content = AudioLib.SampleRate.Hz44100.ToString(); combo.Items.Add(item3); switch (sampleRate) { case AudioLib.SampleRate.Hz11025: { combo.SelectedItem = item1; combo.Text = item1.Content.ToString(); break; } case AudioLib.SampleRate.Hz22050: { combo.SelectedItem = item2; combo.Text = item2.Content.ToString(); break; } case AudioLib.SampleRate.Hz44100: { combo.SelectedItem = item3; combo.Text = item3.Content.ToString(); break; } } var checkBox = new CheckBox { IsThreeState = false, IsChecked = encodeToMp3, HorizontalAlignment = System.Windows.HorizontalAlignment.Right, VerticalAlignment = VerticalAlignment.Center, }; var label_ = new TextBlock { Text = Tobi_Plugin_Urakawa_Lang.ExportEncodeMp3, Margin = new Thickness(8, 0, 8, 0), HorizontalAlignment = System.Windows.HorizontalAlignment.Right, VerticalAlignment = VerticalAlignment.Center, Focusable = true, TextWrapping = TextWrapping.Wrap }; var panel__ = new StackPanel { Orientation = System.Windows.Controls.Orientation.Horizontal, HorizontalAlignment = System.Windows.HorizontalAlignment.Right, VerticalAlignment = VerticalAlignment.Center, }; panel__.Children.Add(label_); panel__.Children.Add(checkBox); var panel_ = new StackPanel { Orientation = System.Windows.Controls.Orientation.Vertical, HorizontalAlignment = System.Windows.HorizontalAlignment.Stretch, VerticalAlignment = VerticalAlignment.Center, }; panel_.Children.Add(combo); panel_.Children.Add(panel__); var windowPopup_ = new PopupModalWindow(m_ShellView, UserInterfaceStrings.EscapeMnemonic(Tobi_Plugin_Urakawa_Lang.ExportSettings), panel_, PopupModalWindow.DialogButtonsSet.OkCancel, PopupModalWindow.DialogButton.Ok, false, 300, 180, null, 40, m_DescriptionPopupModalWindow); windowPopup_.EnableEnterKeyDefault = true; windowPopup_.ShowModal(); if (!PopupModalWindow.IsButtonOkYesApply(windowPopup_.ClickedDialogButton)) { return; } encodeToMp3 = checkBox.IsChecked.Value; Urakawa.Settings.Default.AudioExportEncodeToMp3 = checkBox.IsChecked.Value; if (combo.SelectedItem == item1) { sampleRate = SampleRate.Hz11025; Urakawa.Settings.Default.AudioExportSampleRate = sampleRate; } else if (combo.SelectedItem == item2) { sampleRate = SampleRate.Hz22050; Urakawa.Settings.Default.AudioExportSampleRate = sampleRate; } else if (combo.SelectedItem == item3) { sampleRate = SampleRate.Hz44100; Urakawa.Settings.Default.AudioExportSampleRate = sampleRate; } string rootFolder = Path.GetDirectoryName(m_Session.DocumentFilePath); var dlg = new FolderBrowserDialog { RootFolder = Environment.SpecialFolder.MyComputer, SelectedPath = rootFolder, ShowNewFolderButton = true, Description = @"Tobi: " + UserInterfaceStrings.EscapeMnemonic("Export DIAGRAM XML") }; DialogResult result = DialogResult.Abort; m_ShellView.DimBackgroundWhile(() => { result = dlg.ShowDialog(); }); if (result != DialogResult.OK && result != DialogResult.Yes) { return; } if (!Directory.Exists(dlg.SelectedPath)) { return; } ManagedImageMedia managedImage = (ManagedImageMedia)node.GetImageMedia(); string exportImageName = //Path.GetFileName FileDataProvider.EliminateForbiddenFileNameCharacters (managedImage.ImageMediaData.OriginalRelativePath) ; string imageDescriptionDirectoryPath = Daisy3_Export.GetAndCreateImageDescriptionDirectoryPath(false, exportImageName, dlg.SelectedPath); if (Directory.Exists(imageDescriptionDirectoryPath)) { if (!m_Session.askUserConfirmOverwriteFileFolder(imageDescriptionDirectoryPath, true, m_DescriptionPopupModalWindow)) { return; } FileDataProvider.TryDeleteDirectory(imageDescriptionDirectoryPath, true); } FileDataProvider.CreateDirectory(imageDescriptionDirectoryPath); PCMFormatInfo audioFormat = node.Presentation.MediaDataManager.DefaultPCMFormat; AudioLibPCMFormat pcmFormat = audioFormat.Data; if ((ushort)sampleRate != pcmFormat.SampleRate) { pcmFormat.SampleRate = (ushort)sampleRate; } Application.Current.MainWindow.Cursor = Cursors.Wait; this.Cursor = Cursors.Wait; //m_ShellView try { string descriptionFile = Daisy3_Export.CreateImageDescription( Urakawa.Settings.Default.AudioCodecDisableACM, pcmFormat, encodeToMp3, 0, imageDescriptionDirectoryPath, exportImageName, node.GetAlternateContentProperty(), null, null, null); } finally { Application.Current.MainWindow.Cursor = Cursors.Arrow; this.Cursor = Cursors.Arrow; //m_ShellView } m_ShellView.ExecuteShellProcess(imageDescriptionDirectoryPath); }
public void Popup() { var navView = m_Container.Resolve <DescriptionsNavigationView>(); if (navView != null) { navView.UpdateTreeNodeSelectionFromListItem(); } Tuple <TreeNode, TreeNode> selection = m_Session.GetTreeNodeSelection(); TreeNode node = selection.Item2 ?? selection.Item1; if (node == null) { return; } var navModel = m_Container.Resolve <DescriptionsNavigationViewModel>(); if (navModel.DescriptionsNavigator == null) { return; } bool found = false; foreach (DescribableTreeNode dnode in navModel.DescriptionsNavigator.DescribableTreeNodes) { found = dnode.TreeNode == node; if (found) { break; } } if (!found) { var label = new TextBlock { Text = "You must first select an image to describe.", Margin = new Thickness(8, 0, 8, 0), HorizontalAlignment = HorizontalAlignment.Center, VerticalAlignment = VerticalAlignment.Center, Focusable = true, TextWrapping = TextWrapping.WrapWithOverflow }; var iconProvider = new ScalableGreyableImageProvider(m_ShellView.LoadTangoIcon("dialog-warning"), m_ShellView.MagnificationLevel); var panel = new StackPanel { Orientation = Orientation.Horizontal, HorizontalAlignment = HorizontalAlignment.Center, VerticalAlignment = VerticalAlignment.Stretch, }; panel.Children.Add(iconProvider.IconLarge); panel.Children.Add(label); //panel.Margin = new Thickness(8, 8, 8, 0); var popup = new PopupModalWindow(m_ShellView, UserInterfaceStrings.EscapeMnemonic(Tobi_Plugin_Descriptions_Lang.CmdEditDescriptions_ShortDesc), panel, PopupModalWindow.DialogButtonsSet.Ok, PopupModalWindow.DialogButton.Ok, true, 340, 160, null, 0, null); popup.ShowModal(); return; } var windowPopup = new PopupModalWindow(m_ShellView, UserInterfaceStrings.EscapeMnemonic(Tobi_Plugin_Descriptions_Lang.CmdEditDescriptions_ShortDesc), this, PopupModalWindow.DialogButtonsSet.OkApplyCancel, PopupModalWindow.DialogButton.Apply, true, 1000, 600, null, 0, null); //this.OwnerWindow = windowPopup; DONE in ON PANEL LOADED EVENT windowPopup.IgnoreEscape = true; //var bindings = Application.Current.MainWindow.InputBindings; //foreach (var binding in bindings) //{ // if (binding is KeyBinding) // { // var keyBinding = (KeyBinding)binding; // if (keyBinding.Command == m_ShellView.ExitCommand) // { // continue; // } // windowPopup.InputBindings.Add(keyBinding); // } //} //windowPopup.InputBindings.AddRange(Application.Current.MainWindow.InputBindings); //windowPopup.KeyUp += (object sender, KeyEventArgs e) => // { // var key = (e.Key == Key.System // ? e.SystemKey // : (e.Key == Key.ImeProcessed ? e.ImeProcessedKey : e.Key)); // if (key == Key.Escape) // { // m_EventAggregator.GetEvent<EscapeEvent>().Publish(null); // } // }; //windowPopup.Closed += (sender, ev) => Dispatcher.BeginInvoke( // DispatcherPriority.Background, // (Action)(() => // { // // // })); m_Session.DocumentProject.Presentations.Get(0).UndoRedoManager.StartTransaction (Tobi_Plugin_Descriptions_Lang.CmdEditDescriptions_ShortDesc, Tobi_Plugin_Descriptions_Lang.CmdEditDescriptions_LongDesc, "EDIT_IMAGE_DESCRIPTIONS"); //Tuple<TreeNode, TreeNode> selection = m_Session.GetTreeNodeSelection(); //TreeNode node = selection.Item2 ?? selection.Item1; //if (node == null) return; bool hadAltProp = true; var altProp = node.GetAlternateContentProperty(); //node.GetAlternateContentProperty(); if (altProp == null) { hadAltProp = false; altProp = node.GetOrCreateAlternateContentProperty(); DebugFix.Assert(altProp != null); } m_DescriptionPopupModalWindow = windowPopup; windowPopup.ShowModal(); m_DescriptionPopupModalWindow = null; if (windowPopup.ClickedDialogButton == PopupModalWindow.DialogButton.Ok || windowPopup.ClickedDialogButton == PopupModalWindow.DialogButton.Apply) { altProp = node.GetAlternateContentProperty(); //node.GetAlternateContentProperty(); if (altProp != null) { removeEmptyDescriptions(altProp); } bool empty = m_Session.DocumentProject.Presentations.Get(0).UndoRedoManager.IsTransactionEmpty; m_Session.DocumentProject.Presentations.Get(0).UndoRedoManager.EndTransaction(); if (empty) { altProp = node.GetAlternateContentProperty(); //node.GetAlternateContentProperty(); if (altProp != null && !hadAltProp) { #if DEBUG DebugFix.Assert(altProp.IsEmpty); #endif //DEBUG node.RemoveProperty(altProp); } } } else { m_Session.DocumentProject.Presentations.Get(0).UndoRedoManager.CancelTransaction(); altProp = node.GetAlternateContentProperty(); //node.GetAlternateContentProperty(); if (altProp != null && !hadAltProp) { #if DEBUG DebugFix.Assert(altProp.IsEmpty); #endif //DEBUG node.RemoveProperty(altProp); } } if (windowPopup.ClickedDialogButton == PopupModalWindow.DialogButton.Apply) { Popup(); } }
private void OnClick_ButtonAddMetadata(object sender, RoutedEventArgs e) { Tuple <TreeNode, TreeNode> selection = m_Session.GetTreeNodeSelection(); TreeNode node = selection.Item2 ?? selection.Item1; if (node == null) { return; } var altProp = node.GetOrCreateAlternateContentProperty(); //if (altProp == null) return; //if (DescriptionsListView.SelectedIndex < 0) return; //AlternateContent altContent = (AlternateContent)DescriptionsListView.SelectedItem; //if (altProp.AlternateContents.IndexOf(altContent) < 0) return; var mdAttr = new MetadataAttribute(); mdAttr.Name = ""; // PROMPT_MD_NAME; mdAttr.Value = ""; // PROMPT_MD_VALUE; string newName = null; string newValue = null; bool invalidSyntax = false; bool ok = true; while (ok && ( invalidSyntax || string.IsNullOrEmpty(newName) || string.IsNullOrEmpty(newValue) //|| newName == PROMPT_MD_NAME //|| newValue == PROMPT_MD_VALUE ) ) { ok = showMetadataAttributeEditorPopupDialog("Property", "Content", mdAttr, out newName, out newValue, false, false, invalidSyntax); mdAttr.Name = newName; mdAttr.Value = newValue; if (!string.IsNullOrEmpty(newName) && !string.IsNullOrEmpty(newValue)) { invalidSyntax = m_ViewModel.IsIDInValid(newName) || ( (newName.Equals(XmlReaderWriterHelper.XmlId) || newName.Equals(DiagramContentModelHelper.DiagramElementName)) && m_ViewModel.IsIDInValid(newValue) ); } } if (!ok) { return; } //bool ok = showMetadataAttributeEditorPopupDialog(mdAttr, out newName, out newValue, false); //if (ok && // newName != mdAttr.Name && newValue != mdAttr.Value) //{ foreach (Metadata m in altProp.Metadatas.ContentsAs_Enumerable) { if (m.NameContentAttribute.Name == newName && ( newName.StartsWith(XmlReaderWriterHelper.NS_PREFIX_XML + ":") //newName.Equals(XmlReaderWriterHelper.XmlId) //|| newName.Equals(XmlReaderWriterHelper.XmlLang) ) ) { var label = new TextBlock { Text = Tobi.Plugin.Descriptions.Tobi_Plugin_Descriptions_Lang.AttributeAlreadyExists, Margin = new Thickness(8, 0, 8, 0), HorizontalAlignment = HorizontalAlignment.Center, VerticalAlignment = VerticalAlignment.Center, Focusable = true, TextWrapping = TextWrapping.Wrap }; var iconProvider = new ScalableGreyableImageProvider(m_ShellView.LoadTangoIcon("dialog-warning"), m_ShellView.MagnificationLevel); var panel = new StackPanel { Orientation = Orientation.Horizontal, HorizontalAlignment = HorizontalAlignment.Center, VerticalAlignment = VerticalAlignment.Stretch, }; panel.Children.Add(iconProvider.IconLarge); panel.Children.Add(label); //panel.Margin = new Thickness(8, 8, 8, 0); var windowPopup = new PopupModalWindow(m_ShellView, UserInterfaceStrings.EscapeMnemonic(Tobi.Plugin.Descriptions.Tobi_Plugin_Descriptions_Lang.DuplicateAttribute), panel, PopupModalWindow.DialogButtonsSet.Ok, PopupModalWindow.DialogButton.Ok, true, 300, 160, null, 0, m_DescriptionPopupModalWindow); //view.OwnerWindow = windowPopup; windowPopup.ShowModal(); return; } } m_ViewModel.AddMetadata(altProp, null, newName, newValue); MetadatasListView.Items.Refresh(); MetadatasListView.SelectedIndex = MetadatasListView.Items.Count - 1; //FocusHelper.FocusBeginInvoke(MetadatasListView); }
private void initializeCommands_View() { CommandStopPlayMonitorRecord = new RichDelegateCommand( Tobi_Plugin_AudioPane_Lang.CmdAudioStopRecord_ShortDesc, Tobi_Plugin_AudioPane_Lang.CmdAudioStopRecord_LongDesc, null, // KeyGesture obtained from settings (see last parameters below) //null, //ScalableGreyableImageProvider.ConvertIconFormat((DrawingImage)Application.Current.FindResource("Horizon_Image_Refresh")), null, () => { //Logger.Log("AudioPaneViewModel.CommandRefresh", Category.Debug, Priority.Medium); OnStopPlayMonitorRecord(); }, () => true, Settings_KeyGestures.Default, PropertyChangedNotifyBase.GetMemberName(() => Settings_KeyGestures.Default.Keyboard_Audio_StopPlayMonitorRecord)); m_ShellView.RegisterRichCommand(CommandStopPlayMonitorRecord); // CommandRefresh = new RichDelegateCommand( Tobi_Plugin_AudioPane_Lang.CmdAudioReload_ShortDesc, Tobi_Plugin_AudioPane_Lang.CmdAudioReload_LongDesc, null, // KeyGesture obtained from settings (see last parameters below) //null, //ScalableGreyableImageProvider.ConvertIconFormat((DrawingImage)Application.Current.FindResource("Horizon_Image_Refresh")), m_ShellView.LoadTangoIcon("view-refresh"), () => { //Logger.Log("AudioPaneViewModel.CommandRefresh", Category.Debug, Priority.Medium); //StartWaveFormLoadTimer(0); AudioPlayer_LoadWaveForm(false); }, () => CanManipulateWaveForm, //!IsWaveFormLoading, null, null); //IsAudioLoaded m_ShellView.RegisterRichCommand(CommandRefresh); // CommandZoomSelection = new RichDelegateCommand( Tobi_Plugin_AudioPane_Lang.CmdAudioZoomSelection_ShortDesc, Tobi_Plugin_AudioPane_Lang.CmdAudioZoomSelection_LongDesc, null, // KeyGesture obtained from settings (see last parameters below) ScalableGreyableImageProvider.ConvertIconFormat((DrawingImage)Application.Current.FindResource("Horizon_Image_Search")), //shellView.LoadTangoIcon("system-search"), () => { Logger.Log("AudioPaneViewModel.CommandZoomSelection", Category.Debug, Priority.Medium); View.ZoomSelection(); }, () => View != null && State.Audio.HasContent && CanManipulateWaveForm //&&!IsWaveFormLoading && IsSelectionSet, Settings_KeyGestures.Default, PropertyChangedNotifyBase.GetMemberName(() => Settings_KeyGestures.Default.Keyboard_Audio_ZoomSelection)); m_ShellView.RegisterRichCommand(CommandZoomSelection); // CommandZoomFitFull = new RichDelegateCommand( Tobi_Plugin_AudioPane_Lang.CmdAudioFitFull_ShortDesc, Tobi_Plugin_AudioPane_Lang.CmdAudioFitFull_LongDesc, null, // KeyGesture obtained from settings (see last parameters below) m_ShellView.LoadGnomeNeuIcon("Neu_utilities-system-monitor"), () => { Logger.Log("AudioPaneViewModel.CommandZoomFitFull", Category.Debug, Priority.Medium); View.ZoomFitFull(); }, () => View != null && State.Audio.HasContent && CanManipulateWaveForm, //&& !IsWaveFormLoading, Settings_KeyGestures.Default, PropertyChangedNotifyBase.GetMemberName(() => Settings_KeyGestures.Default.Keyboard_Audio_ZoomFitFull)); //Settings_KeyGestures.Default.Keyboard_Audio_Zoom_0 m_ShellView.RegisterRichCommand(CommandZoomFitFull); // CommandZoom_0 = new RichDelegateCommand( Tobi_Plugin_AudioPane_Lang.CmdAudioFitFull_ShortDesc, Tobi_Plugin_AudioPane_Lang.CmdAudioFitFull_LongDesc, null, // KeyGesture obtained from settings (see last parameters below) null, //m_ShellView.LoadGnomeNeuIcon("Neu_utilities-system-monitor"), () => { //Logger.Log("AudioPaneViewModel.CommandZoom_0", Category.Debug, Priority.Medium); //View.ZoomFitFull(); CommandZoomFitFull.Execute(); }, () => CommandZoomFitFull.CanExecute(), //&& !IsWaveFormLoading, Settings_KeyGestures.Default, PropertyChangedNotifyBase.GetMemberName(() => Settings_KeyGestures.Default.Keyboard_Audio_Zoom_0)); m_ShellView.RegisterRichCommand(CommandZoom_0); // CommandZoom_1 = new RichDelegateCommand( "Zoom 1", "Zoom 1", null, // KeyGesture obtained from settings (see last parameters below) null, //m_ShellView.LoadGnomeNeuIcon("Neu_utilities-system-monitor"), () => { Logger.Log("AudioPaneViewModel.CommandZoom_1", Category.Debug, Priority.Medium); View.Zoom_1(); }, () => CommandZoomFitFull.CanExecute(), //&& !IsWaveFormLoading, Settings_KeyGestures.Default, PropertyChangedNotifyBase.GetMemberName(() => Settings_KeyGestures.Default.Keyboard_Audio_Zoom_1)); m_ShellView.RegisterRichCommand(CommandZoom_1); // CommandZoom_2 = new RichDelegateCommand( "Zoom 2", "Zoom 2", null, // KeyGesture obtained from settings (see last parameters below) null, //m_ShellView.LoadGnomeNeuIcon("Neu_utilities-system-monitor"), () => { Logger.Log("AudioPaneViewModel.CommandZoom_2", Category.Debug, Priority.Medium); View.Zoom_2(); }, () => CommandZoomFitFull.CanExecute(), //&& !IsWaveFormLoading, Settings_KeyGestures.Default, PropertyChangedNotifyBase.GetMemberName(() => Settings_KeyGestures.Default.Keyboard_Audio_Zoom_2)); m_ShellView.RegisterRichCommand(CommandZoom_2); // CommandZoom_3 = new RichDelegateCommand( "Zoom 3", "Zoom 3", null, // KeyGesture obtained from settings (see last parameters below) null, //m_ShellView.LoadGnomeNeuIcon("Neu_utilities-system-monitor"), () => { Logger.Log("AudioPaneViewModel.CommandZoom_3", Category.Debug, Priority.Medium); View.Zoom_3(); }, () => CommandZoomFitFull.CanExecute(), //&& !IsWaveFormLoading, Settings_KeyGestures.Default, PropertyChangedNotifyBase.GetMemberName(() => Settings_KeyGestures.Default.Keyboard_Audio_Zoom_3)); m_ShellView.RegisterRichCommand(CommandZoom_3); // CommandZoom_4 = new RichDelegateCommand( "Zoom 4", "Zoom 4", null, // KeyGesture obtained from settings (see last parameters below) null, //m_ShellView.LoadGnomeNeuIcon("Neu_utilities-system-monitor"), () => { Logger.Log("AudioPaneViewModel.CommandZoom_4", Category.Debug, Priority.Medium); View.Zoom_4(); }, () => CommandZoomFitFull.CanExecute(), //&& !IsWaveFormLoading, Settings_KeyGestures.Default, PropertyChangedNotifyBase.GetMemberName(() => Settings_KeyGestures.Default.Keyboard_Audio_Zoom_4)); m_ShellView.RegisterRichCommand(CommandZoom_4); // CommandZoom_5 = new RichDelegateCommand( "Zoom 5", "Zoom 5", null, // KeyGesture obtained from settings (see last parameters below) null, //m_ShellView.LoadGnomeNeuIcon("Neu_utilities-system-monitor"), () => { Logger.Log("AudioPaneViewModel.CommandZoom_5", Category.Debug, Priority.Medium); View.Zoom_5(); }, () => CommandZoomFitFull.CanExecute(), //&& !IsWaveFormLoading, Settings_KeyGestures.Default, PropertyChangedNotifyBase.GetMemberName(() => Settings_KeyGestures.Default.Keyboard_Audio_Zoom_5)); m_ShellView.RegisterRichCommand(CommandZoom_5); // CommandZoom_6 = new RichDelegateCommand( "Zoom 6", "Zoom 6", null, // KeyGesture obtained from settings (see last parameters below) null, //m_ShellView.LoadGnomeNeuIcon("Neu_utilities-system-monitor"), () => { Logger.Log("AudioPaneViewModel.CommandZoom_6", Category.Debug, Priority.Medium); View.Zoom_6(); }, () => CommandZoomFitFull.CanExecute(), //&& !IsWaveFormLoading, Settings_KeyGestures.Default, PropertyChangedNotifyBase.GetMemberName(() => Settings_KeyGestures.Default.Keyboard_Audio_Zoom_6)); m_ShellView.RegisterRichCommand(CommandZoom_6); // CommandZoom_7 = new RichDelegateCommand( "Zoom 7", "Zoom 7", null, // KeyGesture obtained from settings (see last parameters below) null, //m_ShellView.LoadGnomeNeuIcon("Neu_utilities-system-monitor"), () => { Logger.Log("AudioPaneViewModel.CommandZoom_7", Category.Debug, Priority.Medium); View.Zoom_7(); }, () => CommandZoomFitFull.CanExecute(), //&& !IsWaveFormLoading, Settings_KeyGestures.Default, PropertyChangedNotifyBase.GetMemberName(() => Settings_KeyGestures.Default.Keyboard_Audio_Zoom_7)); m_ShellView.RegisterRichCommand(CommandZoom_7); // CommandZoom_8 = new RichDelegateCommand( "Zoom 8", "Zoom 8", null, // KeyGesture obtained from settings (see last parameters below) null, //m_ShellView.LoadGnomeNeuIcon("Neu_utilities-system-monitor"), () => { Logger.Log("AudioPaneViewModel.CommandZoom_8", Category.Debug, Priority.Medium); View.Zoom_8(); }, () => CommandZoomFitFull.CanExecute(), //&& !IsWaveFormLoading, Settings_KeyGestures.Default, PropertyChangedNotifyBase.GetMemberName(() => Settings_KeyGestures.Default.Keyboard_Audio_Zoom_8)); m_ShellView.RegisterRichCommand(CommandZoom_8); // CommandZoom_9 = new RichDelegateCommand( "Zoom 9", "Zoom 9", null, // KeyGesture obtained from settings (see last parameters below) null, //m_ShellView.LoadGnomeNeuIcon("Neu_utilities-system-monitor"), () => { Logger.Log("AudioPaneViewModel.CommandZoom_9", Category.Debug, Priority.Medium); View.Zoom_9(); }, () => CommandZoomFitFull.CanExecute(), //&& !IsWaveFormLoading, Settings_KeyGestures.Default, PropertyChangedNotifyBase.GetMemberName(() => Settings_KeyGestures.Default.Keyboard_Audio_Zoom_9)); m_ShellView.RegisterRichCommand(CommandZoom_9); // CommandAudioSettings = new RichDelegateCommand( Tobi_Plugin_AudioPane_Lang.CmdAudioSettings_ShortDesc, Tobi_Plugin_AudioPane_Lang.CmdAudioSettings_LongDesc, null, // KeyGesture obtained from settings (see last parameters below) m_ShellView.LoadGnomeNeuIcon("Neu_audio-x-generic"), () => { Logger.Log("AudioPaneViewModel.CommandAudioSettings", Category.Debug, Priority.Medium); var windowPopup = new PopupModalWindow(m_ShellView, UserInterfaceStrings.EscapeMnemonic(Tobi_Plugin_AudioPane_Lang.CmdAudioSettings_ShortDesc), new AudioSettings(this), PopupModalWindow.DialogButtonsSet.Close, PopupModalWindow.DialogButton.Close, true, 420, 220, null, 0,null); windowPopup.EnableEnterKeyDefault = true; windowPopup.ShowFloating(()=> { m_SpeechSynthesizer.SpeakAsyncCancelAll(); }); }, () => !IsRecording, Settings_KeyGestures.Default, null //PropertyChangedNotifyBase.GetMemberName(() => Settings_KeyGestures.Default.Keyboard_Audio_ShowOptions) ); m_ShellView.RegisterRichCommand(CommandAudioSettings); // #if DEBUG CommandShowAudioOptionsDialog = new RichDelegateCommand( @"Show audio options", null, null, // KeyGesture obtained from settings (see last parameters below) null, ()=> { Logger.Log("AudioPaneViewModel.CommandShowOptionsDialog", Category.Debug, Priority.Medium); //var window = shellView.View as Window; var pane = new AudioOptions { DataContext = this }; var windowPopup = new PopupModalWindow(m_ShellView, UserInterfaceStrings.EscapeMnemonic(@"Show audio options"), pane, PopupModalWindow.DialogButtonsSet.Close, PopupModalWindow.DialogButton.Close, true, 400, 500, null, 0,null); windowPopup.EnableEnterKeyDefault = true; windowPopup.Show(); }, () => true, Settings_KeyGestures.Default, PropertyChangedNotifyBase.GetMemberName(() => Settings_KeyGestures.Default.Keyboard_Audio_ExpertOptions) ); m_ShellView.RegisterRichCommand(CommandShowAudioOptionsDialog); #endif //DEBUG // CommandFocus = new RichDelegateCommand( Tobi_Plugin_AudioPane_Lang.CmdAudioFocus_ShortDesc, null, null, // KeyGesture obtained from settings (see last parameters below) m_ShellView.LoadTangoIcon("audio-volume-low"), () => { Logger.Log("AudioPaneViewModel.CommandFocus", Category.Debug, Priority.Medium); View.BringIntoFocus(); }, () => View != null, Settings_KeyGestures.Default, PropertyChangedNotifyBase.GetMemberName(() => Settings_KeyGestures.Default.Keyboard_Focus_Audio)); m_ShellView.RegisterRichCommand(CommandFocus); // CommandFocusStatusBar = new RichDelegateCommand( Tobi_Plugin_AudioPane_Lang.CmdAudioFocusStatusBar_ShortDesc, null, null, // KeyGesture obtained from settings (see last parameters below) m_ShellView.LoadGnomeNeuIcon("Neu_utilities-terminal"), () => { Logger.Log("AudioPaneViewModel.CommandFocusStatusBar", Category.Debug, Priority.Medium); View.BringIntoFocusStatusBar(); }, () => View != null, Settings_KeyGestures.Default, PropertyChangedNotifyBase.GetMemberName(() => Settings_KeyGestures.Default.Keyboard_Focus_StatusBar)); m_ShellView.RegisterRichCommand(CommandFocusStatusBar); // }
private bool askUserAppUpdate(string thisVersion, string latestVersion) { m_Logger.Log("ShellView.askUserAppUpdate", Category.Debug, Priority.Medium); var label = new TextBlock { Text = Tobi_Lang.TobiUpdate_Message, Margin = new Thickness(8, 0, 8, 0), HorizontalAlignment = HorizontalAlignment.Left, VerticalAlignment = VerticalAlignment.Center, Focusable = true, TextWrapping = TextWrapping.Wrap }; var label2 = new TextBlock { Text = "[" + thisVersion + " --> " + latestVersion + "]", Margin = new Thickness(8, 0, 8, 8), HorizontalAlignment = HorizontalAlignment.Left, VerticalAlignment = VerticalAlignment.Center, Focusable = true, TextWrapping = TextWrapping.Wrap }; var iconProvider = new ScalableGreyableImageProvider(LoadTangoIcon("help-browser"), MagnificationLevel); var panel = new StackPanel { Orientation = Orientation.Horizontal, HorizontalAlignment = HorizontalAlignment.Center, VerticalAlignment = VerticalAlignment.Center, }; panel.Children.Add(iconProvider.IconLarge); var panel2 = new StackPanel { Orientation = Orientation.Vertical, HorizontalAlignment = HorizontalAlignment.Left, VerticalAlignment = VerticalAlignment.Center, }; panel.Children.Add(panel2); panel2.Children.Add(label); panel2.Children.Add(label2); //panel.Margin = new Thickness(8, 8, 8, 0); //var details = new TextBoxReadOnlyCaretVisible // { // TextReadOnly = Tobi_Lang.ExitConfirm //}; var windowPopup = new PopupModalWindow(this, UserInterfaceStrings.EscapeMnemonic(Tobi_Lang.TobiUpdate_Title), panel, PopupModalWindow.DialogButtonsSet.YesNo, PopupModalWindow.DialogButton.No, true, 400, 200, null, 40, null); windowPopup.ShowModal(); if (PopupModalWindow.IsButtonOkYesApply(windowPopup.ClickedDialogButton)) { if (m_UrakawaSession != null && m_UrakawaSession.DocumentProject != null && m_UrakawaSession.IsDirty) { PopupModalWindow.DialogButton button = m_UrakawaSession.CheckSaveDirtyAndClose(PopupModalWindow.DialogButtonsSet.YesNoCancel, "exit"); if (PopupModalWindow.IsButtonEscCancel(button)) { return(false); } } return(true); } return(false); }
private void OnMouseDoubleClick_ListItemMetadataAltContent(object sender, MouseButtonEventArgs e) { Tuple <TreeNode, TreeNode> selection = m_Session.GetTreeNodeSelection(); TreeNode node = selection.Item2 ?? selection.Item1; if (node == null) { return; } var altProp = node.GetAlternateContentProperty(); if (altProp == null) { return; } if (DescriptionsListView.SelectedIndex < 0) { return; } AlternateContent altContent = (AlternateContent)DescriptionsListView.SelectedItem; if (altProp.AlternateContents.IndexOf(altContent) < 0) { return; } if (MetadatasAltContentListView.SelectedIndex < 0) { return; } Metadata md = (Metadata)MetadatasAltContentListView.SelectedItem; string newName = null; string newValue = null; var mdAttrTEMP = new MetadataAttribute(); mdAttrTEMP.Name = md.NameContentAttribute.Name; mdAttrTEMP.Value = md.NameContentAttribute.Value; bool invalidSyntax = false; bool ok = true; while (ok && ( invalidSyntax || string.IsNullOrEmpty(newName) || string.IsNullOrEmpty(newValue) ) ) { ok = showMetadataAttributeEditorPopupDialog(Tobi.Plugin.Descriptions.Tobi_Plugin_Descriptions_Lang.Name, Tobi.Plugin.Descriptions.Tobi_Plugin_Descriptions_Lang.Value, mdAttrTEMP, out newName, out newValue, true, false, invalidSyntax); if (!ok) { return; } else if (newName == md.NameContentAttribute.Name && newValue == md.NameContentAttribute.Value) { return; } mdAttrTEMP.Name = newName; mdAttrTEMP.Value = newValue; if (!string.IsNullOrEmpty(newName) && !string.IsNullOrEmpty(newValue)) { invalidSyntax = m_ViewModel.IsIDInValid(newName) || ( (newName.Equals(XmlReaderWriterHelper.XmlId) || newName.Equals(DiagramContentModelHelper.DiagramElementName)) && m_ViewModel.IsIDInValid(newValue) ); } } //bool ok = showMetadataAttributeEditorPopupDialog(md.NameContentAttribute, out newName, out newValue, true); //if (ok && // (newName != md.NameContentAttribute.Name || newValue != md.NameContentAttribute.Value)) //{ foreach (Metadata m in altContent.Metadatas.ContentsAs_Enumerable) { if (md == m) { continue; } if (m.NameContentAttribute.Name == newName) { var label = new TextBlock { Text = Tobi.Plugin.Descriptions.Tobi_Plugin_Descriptions_Lang.AttributeAlreadyExists, Margin = new Thickness(8, 0, 8, 0), HorizontalAlignment = HorizontalAlignment.Center, VerticalAlignment = VerticalAlignment.Center, Focusable = true, TextWrapping = TextWrapping.Wrap }; var iconProvider = new ScalableGreyableImageProvider(m_ShellView.LoadTangoIcon("dialog-warning"), m_ShellView.MagnificationLevel); var panel = new StackPanel { Orientation = Orientation.Horizontal, HorizontalAlignment = HorizontalAlignment.Center, VerticalAlignment = VerticalAlignment.Stretch, }; panel.Children.Add(iconProvider.IconLarge); panel.Children.Add(label); //panel.Margin = new Thickness(8, 8, 8, 0); var windowPopup = new PopupModalWindow(m_ShellView, UserInterfaceStrings.EscapeMnemonic(Tobi.Plugin.Descriptions.Tobi_Plugin_Descriptions_Lang.DuplicateAttribute), panel, PopupModalWindow.DialogButtonsSet.Ok, PopupModalWindow.DialogButton.Ok, true, 300, 160, null, 0, m_DescriptionPopupModalWindow); //view.OwnerWindow = windowPopup; windowPopup.ShowModal(); return; } } m_ViewModel.SetMetadataAttr(null, altContent, md, null, newName, newValue); MetadatasAltContentListView.Items.Refresh(); DescriptionsListView.Items.Refresh(); }
private bool doImport() { m_Logger.Log(String.Format(@"UrakawaSession.doImport() [{0}]", DocumentFilePath), Category.Debug, Priority.Medium); string ext = Path.GetExtension(DocumentFilePath); if (".opf".Equals(ext, StringComparison.OrdinalIgnoreCase)) { int levelsUp = 0; string parentDir = Path.GetDirectoryName(DocumentFilePath); DirectoryInfo parentDirInfo = new DirectoryInfo(parentDir); tryAgain: levelsUp++; #if NET40 IEnumerable <DirectoryInfo> metaInfDirs = parentDirInfo.EnumerateDirectories("META-INF", SearchOption.TopDirectoryOnly); #else DirectoryInfo[] metaInfDirs = parentDirInfo.GetDirectories("META-INF", SearchOption.TopDirectoryOnly); #endif bool found = false; foreach (DirectoryInfo dirInfo in metaInfDirs) { string containerXml = Path.Combine(dirInfo.FullName, "container.xml"); if (File.Exists(containerXml)) { DocumentFilePath = containerXml; ext = Path.GetExtension(DocumentFilePath); found = true; break; } } if (!found && levelsUp <= 2 && parentDirInfo.Parent != null) { parentDirInfo = parentDirInfo.Parent; goto tryAgain; } } if (DataProviderFactory.EPUB_EXTENSION.Equals(ext, StringComparison.OrdinalIgnoreCase)) { checkEpub(DocumentFilePath, null); } else if (DataProviderFactory.XML_EXTENSION.Equals(ext, StringComparison.OrdinalIgnoreCase) && FileDataProvider.NormaliseFullFilePath(DocumentFilePath).IndexOf( @"META-INF" //+ Path.DirectorySeparatorChar + '/' + @"container.xml" , StringComparison.OrdinalIgnoreCase) >= 0 //DocumentFilePath.IndexOf("container.xml", StringComparison.OrdinalIgnoreCase) >= 0 ) { string parentDir = Path.GetDirectoryName(DocumentFilePath); DirectoryInfo dirInfo = new DirectoryInfo(parentDir); if (dirInfo.Parent != null) { string checkEpubPath = dirInfo.Parent.FullName; checkEpub(checkEpubPath, "exp"); } } else if (".opf".Equals(ext, StringComparison.OrdinalIgnoreCase)) { if (!checkDAISY(DocumentFilePath)) { //checkEpub(DocumentFilePath, "opf"); assume container.xml was found (see above) } } else if (DataProviderFactory.HTML_EXTENSION.Equals(ext, StringComparison.OrdinalIgnoreCase) || DataProviderFactory.XHTML_EXTENSION.Equals(ext, StringComparison.OrdinalIgnoreCase)) { //MessageBox.Show messageBoxAlert("WARNING: single HTML import is an experimental and incomplete EPUB feature!", null); checkEpub(DocumentFilePath, "xhtml"); } else if (DataProviderFactory.XML_EXTENSION.Equals(ext, StringComparison.OrdinalIgnoreCase)) { //checkDAISY(DocumentFilePath); if (false && // TODO: Pipeline 2 with better support for DTBOOK validation (currently skips metadata values) askUser("DAISY Check?", DocumentFilePath)) { string pipeline_ExePath = obtainPipelineExe(); if (!string.IsNullOrEmpty(pipeline_ExePath)) { string outDir = Path.GetDirectoryName(DocumentFilePath); outDir = Path.Combine(outDir, Path.GetFileName(DocumentFilePath) + "_PIPEVAL"); bool success = false; Func <String, String> checkErrorsOrWarning = (string report) => { if (report.IndexOf("[DP2] DONE", StringComparison.Ordinal) < 0) { return("Pipeline job doesn't appear to have completed?"); } string reportFile = Path.Combine(outDir, "report.xhtml"); if (File.Exists(reportFile)) { string reportXmlSource = File.ReadAllText(reportFile); if (!string.IsNullOrEmpty(reportXmlSource)) { string xmlInfo = ""; XmlDocument xmlDoc = XmlReaderWriterHelper.ParseXmlDocumentFromString(reportXmlSource, false, false); IEnumerable <XmlNode> lis = XmlDocumentHelper.GetChildrenElementsOrSelfWithName( xmlDoc.DocumentElement, true, "li", null, false); foreach (XmlNode li in lis) { if (li.Attributes == null) { continue; } XmlNode classAttr = li.Attributes.GetNamedItem("class"); if (classAttr == null || classAttr.Value != "error") { continue; } xmlInfo += li.InnerText; xmlInfo += Environment.NewLine; } if (string.IsNullOrEmpty(xmlInfo)) { success = true; return(null); } return(xmlInfo); } } success = true; return(null); }; try { string workingDir = Path.GetDirectoryName(pipeline_ExePath); //Path.GetDirectoryName(System.Reflection.Assembly.GetExecutingAssembly().Location); executeProcess( workingDir, "DAISY Pipeline (validation)", //"\"" + pipeline_ExePath //+ "\"" , "dtbook-validator " + "--i-source \"" + DocumentFilePath + "\" " + "--x-output-dir \"" + outDir + "\" ", checkErrorsOrWarning); } catch (Exception ex) { messageBoxText("Oops :(", "Problem running DAISY Pipeline (validation)!", ex.Message + Environment.NewLine + ex.StackTrace); } if (Directory.Exists(outDir)) { //m_ShellView.ExecuteShellProcess(outDir); FileDataProvider.TryDeleteDirectory(outDir, false); } } } } string outputDirectory = Path.Combine( Path.GetDirectoryName(DocumentFilePath), Daisy3_Import.GetXukDirectory(DocumentFilePath)); //string xukPath = Daisy3_Import.GetXukFilePath(outputDirectory, DocumentFilePath); //if (File.Exists(xukPath)) if (Directory.Exists(outputDirectory)) { if (!askUserConfirmOverwriteFileFolder(outputDirectory, true, null)) { return(false); } FileDataProvider.TryDeleteDirectory(outputDirectory, true); } var combo = new ComboBox { Margin = new Thickness(0, 0, 0, 0), HorizontalAlignment = HorizontalAlignment.Stretch, VerticalAlignment = VerticalAlignment.Center, }; ComboBoxItem item1 = new ComboBoxItem(); item1.Content = AudioLib.SampleRate.Hz11025.ToString(); combo.Items.Add(item1); ComboBoxItem item2 = new ComboBoxItem(); item2.Content = AudioLib.SampleRate.Hz22050.ToString(); combo.Items.Add(item2); ComboBoxItem item3 = new ComboBoxItem(); item3.Content = AudioLib.SampleRate.Hz44100.ToString(); combo.Items.Add(item3); switch (Settings.Default.AudioProjectSampleRate) { case AudioLib.SampleRate.Hz11025: { combo.SelectedItem = item1; combo.Text = item1.Content.ToString(); break; } case AudioLib.SampleRate.Hz22050: { combo.SelectedItem = item2; combo.Text = item2.Content.ToString(); break; } case AudioLib.SampleRate.Hz44100: { combo.SelectedItem = item3; combo.Text = item3.Content.ToString(); break; } } var label_ = new TextBlock { Text = Tobi_Plugin_Urakawa_Lang.Stereo, Margin = new Thickness(0, 0, 8, 0), HorizontalAlignment = System.Windows.HorizontalAlignment.Right, VerticalAlignment = VerticalAlignment.Center, Focusable = true, TextWrapping = TextWrapping.Wrap }; var checkBox = new CheckBox { IsThreeState = false, IsChecked = Settings.Default.AudioProjectStereo, HorizontalAlignment = System.Windows.HorizontalAlignment.Right, VerticalAlignment = VerticalAlignment.Center, }; var panel__ = new StackPanel { Orientation = System.Windows.Controls.Orientation.Horizontal, HorizontalAlignment = System.Windows.HorizontalAlignment.Right, VerticalAlignment = VerticalAlignment.Center, Margin = new Thickness(0, 8, 0, 22), }; panel__.Children.Add(label_); panel__.Children.Add(checkBox); var label = new TextBlock { Text = Tobi_Plugin_Urakawa_Lang.UseSourceAudioFormat, Margin = new Thickness(0, 0, 8, 0), HorizontalAlignment = System.Windows.HorizontalAlignment.Right, VerticalAlignment = VerticalAlignment.Center, Focusable = true, TextWrapping = TextWrapping.Wrap }; var checkAuto = new CheckBox { IsThreeState = false, IsChecked = false, HorizontalAlignment = System.Windows.HorizontalAlignment.Right, VerticalAlignment = VerticalAlignment.Center, }; var panel_ = new StackPanel { Orientation = System.Windows.Controls.Orientation.Horizontal, HorizontalAlignment = System.Windows.HorizontalAlignment.Right, VerticalAlignment = VerticalAlignment.Center, Margin = new Thickness(0, 0, 0, 12), }; panel_.Children.Add(label); panel_.Children.Add(checkAuto); var panel = new StackPanel { Orientation = Orientation.Vertical, HorizontalAlignment = HorizontalAlignment.Stretch, VerticalAlignment = VerticalAlignment.Center, }; panel.Children.Add(combo); panel.Children.Add(panel__); panel.Children.Add(panel_); //var line = new Separator() //{ // Margin = new Thickness(0, 8, 0, 8), //}; //line.HorizontalAlignment = HorizontalAlignment.Stretch; //line.VerticalAlignment = VerticalAlignment.Center; //panel.Children.Add(line); var details = new TextBoxReadOnlyCaretVisible { FocusVisualStyle = (Style)Application.Current.Resources["MyFocusVisualStyle"], BorderThickness = new Thickness(1), Padding = new Thickness(6), TextReadOnly = Tobi_Plugin_Urakawa_Lang.UseSourceAudioFormatTip }; var windowPopup = new PopupModalWindow(m_ShellView, UserInterfaceStrings.EscapeMnemonic(Tobi_Plugin_Urakawa_Lang.ProjectAudioFormat), panel, PopupModalWindow.DialogButtonsSet.OkCancel, PopupModalWindow.DialogButton.Ok, false, 320, 200, details, 40, null); windowPopup.EnableEnterKeyDefault = true; windowPopup.ShowModal(); if (!PopupModalWindow.IsButtonOkYesApply(windowPopup.ClickedDialogButton)) { return(false); } Settings.Default.AudioProjectStereo = checkBox.IsChecked.Value; if (combo.SelectedItem == item1) { Settings.Default.AudioProjectSampleRate = SampleRate.Hz11025; } else if (combo.SelectedItem == item2) { Settings.Default.AudioProjectSampleRate = SampleRate.Hz22050; } else if (combo.SelectedItem == item3) { Settings.Default.AudioProjectSampleRate = SampleRate.Hz44100; } var converter = new Daisy3_Import(DocumentFilePath, outputDirectory, IsAcmCodecsDisabled, Settings.Default.AudioProjectSampleRate, Settings.Default.AudioProjectStereo, checkAuto.IsChecked.Value, Settings.Default.XUK_PrettyFormat ); //Directory.GetParent(bookfile).FullName //converter.VerifyHtml5OutliningAlgorithmUsingPipelineTestSuite(); bool cancelled = false; bool error = m_ShellView.RunModalCancellableProgressTask(true, Tobi_Plugin_Urakawa_Lang.Importing, converter, () => { cancelled = true; DocumentFilePath = null; DocumentProject = null; }, () => { cancelled = false; if (string.IsNullOrEmpty(converter.XukPath)) { return; } //DocumentFilePath = converter.XukPath; //DocumentProject = converter.Project; //AddRecentFile(new Uri(DocumentFilePath, UriKind.Absolute)); }); if (!cancelled) { //DebugFix.Assert(!report); string xukPath = converter.XukPath; if (string.IsNullOrEmpty(xukPath)) { return(false); } string projectDir = Path.GetDirectoryName(xukPath); DebugFix.Assert(outputDirectory == projectDir); string title = converter.GetTitle(); if (!string.IsNullOrEmpty(title)) { string fileName = Daisy3_Import.GetXukFilePath(projectDir, DocumentFilePath, title, false); fileName = Path.GetFileNameWithoutExtension(fileName); string parent = Path.GetDirectoryName(projectDir); //string fileName = Path.GetFileNameWithoutExtension(xukPath); ////while (fileName.StartsWith("_")) ////{ //// fileName = fileName.Substring(1, fileName.Length - 1); ////} //char[] chars = new char[] { '_' }; //fileName = fileName.TrimStart(chars); string newProjectDir = Path.Combine(parent, fileName); // + Daisy3_Import.XUK_DIR if (newProjectDir != projectDir) { bool okay = true; if (Directory.Exists(newProjectDir)) { if (askUserConfirmOverwriteFileFolder(newProjectDir, true, null)) { try { FileDataProvider.TryDeleteDirectory(newProjectDir, false); } catch (Exception ex) { #if DEBUG Debugger.Break(); #endif // DEBUG Console.WriteLine(ex.Message); Console.WriteLine(ex.StackTrace); okay = false; } } else { okay = false; } } if (okay) { Directory.Move(projectDir, newProjectDir); xukPath = Path.Combine(newProjectDir, Path.GetFileName(xukPath)); } } } DocumentFilePath = null; DocumentProject = null; try { OpenFile(xukPath); } catch (Exception ex) { ExceptionHandler.Handle(ex, false, m_ShellView); return(false); } } return(!cancelled); }
private bool saveAsCommand(string destinationFilePath, bool noUI) { bool interactive = string.IsNullOrEmpty(destinationFilePath); bool doCleanup = interactive && askUserCleanup(); if (doCleanup) { DataCleanup(true, false); } string ext = IsXukSpine ? OpenXukAction.XUK_SPINE_EXTENSION : OpenXukAction.XUK_EXTENSION; if (interactive) { var dialog = new SaveFileDialog { FileName = Path.GetFileNameWithoutExtension(DocumentFilePath), //@"tobi_project", DefaultExt = ext, Filter = @"XUK (*" + ext + ")|*" + ext, CheckFileExists = false, CheckPathExists = false, AddExtension = true, CreatePrompt = false, DereferenceLinks = true, OverwritePrompt = false, Title = @"Tobi: " + UserInterfaceStrings.EscapeMnemonic(Tobi_Plugin_Urakawa_Lang.CmdSaveAs_ShortDesc) }; bool?result = false; m_ShellView.DimBackgroundWhile(() => { result = dialog.ShowDialog(); }); if (result == false) { return(false); } destinationFilePath = dialog.FileName; } if (FileDataProvider.NormaliseFullFilePath(destinationFilePath) == FileDataProvider.NormaliseFullFilePath(DocumentFilePath)) { #if DEBUG Debugger.Break(); #endif return(false); } if (interactive && checkWarningFilePathLength(destinationFilePath)) { return(false); } if (File.Exists(destinationFilePath)) { if (!interactive) { return(false); } if (!askUserConfirmOverwriteFileFolder(destinationFilePath, false, null)) { return(false); } } Uri oldUri = DocumentProject.Presentations.Get(0).RootUri; string oldDataDir = DocumentProject.Presentations.Get(0).DataProviderManager.DataFileDirectory; string dirPath = Path.GetDirectoryName(destinationFilePath); string prefix = Path.GetFileNameWithoutExtension(destinationFilePath); DocumentProject.Presentations.Get(0).DataProviderManager.SetCustomDataFileDirectory(prefix); DocumentProject.Presentations.Get(0).RootUri = new Uri(dirPath + Path.DirectorySeparatorChar, UriKind.Absolute); if (saveAs(destinationFilePath, false, noUI)) { string destinationFolder = DocumentProject.Presentations.Get(0).DataProviderManager.DataFileDirectoryFullPath; DocumentProject.Presentations.Get(0).RootUri = oldUri; //string datafolderPathSavedAs = DocumentProject.Presentations.Get(0).DataProviderManager.DataFileDirectoryFullPath; DocumentProject.Presentations.Get(0).DataProviderManager.DataFileDirectory = oldDataDir; //string datafolderPath = DocumentProject.Presentations.Get(0).DataProviderManager.CopyFileDataProvidersToDataFolderWithPrefix(dirPath, prefix); //DebugFix.Assert(datafolderPath == datafolderPathSavedAs); bool cancelled = false; var copier = new DataFolderCopier(DocumentProject.Presentations.Get(0), //dirPath, prefix destinationFolder ); if (noUI) { copier.DoWork(); } else { bool error = m_ShellView.RunModalCancellableProgressTask(true, Tobi_Plugin_Urakawa_Lang.CopyingDataFiles, copier, () => { m_Logger.Log(@"CANCELED", Category.Debug, Priority.Medium); cancelled = true; }, () => { m_Logger.Log(@"DONE", Category.Debug, Priority.Medium); cancelled = false; }); } //DebugFix.Assert(outcome == !cancelled); if (interactive && askUserOpenSavedAs(destinationFilePath)) { try { OpenFile(destinationFilePath); } catch (Exception ex) { ExceptionHandler.Handle(ex, false, m_ShellView); } } return(!cancelled); } else { DocumentProject.Presentations.Get(0).RootUri = oldUri; DocumentProject.Presentations.Get(0).DataProviderManager.DataFileDirectory = oldDataDir; return(false); } }
//public RichDelegateCommand OpenImageDescriptionsManualCommand { get; private set; } private void initCommands() { m_Logger.Log(@"ShellView.initCommands", Category.Debug, Priority.Medium); OpenOnlineDocCommand = new RichDelegateCommand( Tobi_Lang.CmdDocOnline_ShortDesc, Tobi_Lang.CmdDocOnline_LongDesc, null, // KeyGesture obtained from settings (see last parameters below) null, () => { m_Logger.Log(@"ShellView.OpenOnlineDocCommand", Category.Debug, Priority.Medium); ExecuteShellProcess("http://www.daisy.org/tobi/doc"); }, () => !m_UrakawaSession.isAudioRecording, Settings_KeyGestures.Default, null //PropertyChangedNotifyBase.GetMemberName(() => Settings_KeyGestures.Default.Keyboard_Help) ); RegisterRichCommand(OpenOnlineDocCommand); OpenLocalDocCommand = new RichDelegateCommand( Tobi_Lang.CmdDocLocal_ShortDesc, Tobi_Lang.CmdDocLocal_LongDesc, null, // KeyGesture obtained from settings (see last parameters below) null, () => { m_Logger.Log(@"ShellView.OpenLocalDocCommand", Category.Debug, Priority.Medium); string appFolder = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location); string chmPath = Path.Combine(appFolder, "TobiHelp.chm"); ExecuteShellProcess(chmPath); }, () => !m_UrakawaSession.isAudioRecording, Settings_KeyGestures.Default, null //PropertyChangedNotifyBase.GetMemberName(() => Settings_KeyGestures.Default.Keyboard_Help) ); RegisterRichCommand(OpenLocalDocCommand); //OpenImageDescriptionsManualCommand = new RichDelegateCommand( // Tobi_Lang.CmdOpenImageDescriptionsManual_ShortDesc, // Tobi_Lang.CmdOpenImageDescriptionsManual_LongDesc, // null, // KeyGesture obtained from settings (see last parameters below) // null, // () => // { // m_Logger.Log(@"ShellView.OpenImageDescriptionsManualCommand", Category.Debug, Priority.Medium); // ExecuteShellProcess("http://www.daisy.org/tobi/image-description-manual"); // }, // () => true, // Settings_KeyGestures.Default, // null //PropertyChangedNotifyBase.GetMemberName(() => Settings_KeyGestures.Default.Keyboard_ShowTobiFolder) // ); //RegisterRichCommand(OpenImageDescriptionsManualCommand); // ExitCommand = new RichDelegateCommand( Tobi_Lang.CmdMenuExit_ShortDesc, Tobi_Lang.CmdMenuExit_LongDesc, null, // KeyGesture obtained from settings (see last parameters below) //UserInterfaceStrings.Menu_Exit_KEYS, LoadTangoIcon(@"system-log-out"), //ScalableGreyableImageProvider.ConvertIconFormat((DrawingImage)Application.Current.FindResource("Horizon_Image_Exit")), //LoadTangoIcon("document-save"), () => { m_Logger.Log(@"ShellView.ExitCommand", Category.Debug, Priority.Medium); if (askUserConfirmExit()) { exit(); } }, () => { m_Logger.Log(@"Application.Current.Windows.Count: " + Application.Current.Windows.Count + " -- " + Debugger.IsAttached, Category.Debug, Priority.Medium); return(Application.Current.Windows.Count == #if NET40 (Debugger.IsAttached ? 2 : 1) #else 1 #endif && !m_UrakawaSession.isAudioRecording); }, Settings_KeyGestures.Default, PropertyChangedNotifyBase.GetMemberName(() => Settings_KeyGestures.Default.Keyboard_AppExit)); RegisterRichCommand(ExitCommand); // MagnifyUiResetCommand = new RichDelegateCommand( Tobi_Lang.CmdUIResetMagnification_ShortDesc, Tobi_Lang.CmdUIResetMagnification_LongDesc, null, // KeyGesture obtained from settings (see last parameters below) LoadTangoIcon(@"weather-clear"), () => { m_Logger.Log(@"ShellView.MagnifyUiResetCommand", Category.Debug, Priority.Medium); MagnificationLevel = 1; }, () => !m_UrakawaSession.isAudioRecording, Settings_KeyGestures.Default, PropertyChangedNotifyBase.GetMemberName(() => Settings_KeyGestures.Default.Keyboard_UI_Zoom_Reset)); RegisterRichCommand(MagnifyUiResetCommand); // MagnifyUiIncreaseCommand = new RichDelegateCommand( Tobi_Lang.CmdUIIncreaseMagnification_ShortDesc, Tobi_Lang.CmdUIIncreaseMagnification_LongDesc, null, // KeyGesture obtained from settings (see last parameters below) //LoadTangoIcon("mail-forward"), ScalableGreyableImageProvider.ConvertIconFormat((DrawingImage)Application.Current.FindResource(@"Horizon_Image_Zoom_In")), () => { m_Logger.Log(@"ShellView.MagnifyUiIncreaseCommand", Category.Debug, Priority.Medium); MagnificationLevel += 0.15; }, () => !m_UrakawaSession.isAudioRecording, Settings_KeyGestures.Default, PropertyChangedNotifyBase.GetMemberName(() => Settings_KeyGestures.Default.Keyboard_UI_Zoom_Increase)); RegisterRichCommand(MagnifyUiIncreaseCommand); // MagnifyUiDecreaseCommand = new RichDelegateCommand( Tobi_Lang.CmdUIDecreaseMagnification_ShortDesc, Tobi_Lang.CmdUIDecreaseMagnification_LongDesc, null, // KeyGesture obtained from settings (see last parameters below) ScalableGreyableImageProvider.ConvertIconFormat((DrawingImage)Application.Current.FindResource(@"Horizon_Image_Zoom_out")), () => { m_Logger.Log(@"ShellView.MagnifyUiDecreaseCommand", Category.Debug, Priority.Medium); MagnificationLevel -= 0.15; }, () => !m_UrakawaSession.isAudioRecording, Settings_KeyGestures.Default, PropertyChangedNotifyBase.GetMemberName(() => Settings_KeyGestures.Default.Keyboard_UI_Zoom_Decrease)); RegisterRichCommand(MagnifyUiDecreaseCommand); // #if ICONS DisplayPreviewIconsDebugCommand = new RichDelegateCommand( UserInterfaceStrings.IconsDebug, null, UserInterfaceStrings.IconsDebug_KEYS, null, DisplayPreviewIconsDebugCommand_Executed, () => true); RegisterRichCommand(DisplayPreviewIconsDebugCommand); #endif #if DEBUG ManageShortcutsCommand = new RichDelegateCommand( Tobi_Lang.CmdManageShortcuts_ShortDesc, Tobi_Lang.CmdManageShortcuts_LongDesc, null, // KeyGesture obtained from settings (see last parameters below) LoadTangoIcon(@"preferences-desktop-keyboard-shortcuts"), () => { m_Logger.Log(@"ShellView.ManageShortcutsCommand_Executed", Category.Debug, Priority.Medium); var windowPopup = new PopupModalWindow(this, UserInterfaceStrings.EscapeMnemonic(Tobi_Lang.CmdManageShortcuts_ShortDesc), new KeyboardShortcuts(this), PopupModalWindow.DialogButtonsSet.Ok, PopupModalWindow.DialogButton.Ok, true, 500, 600, null, 0, null); windowPopup.ShowFloating(null); }, () => true, Settings_KeyGestures.Default, null //PropertyChangedNotifyBase.GetMemberName(() => Settings_KeyGestures.Default.Keyboard_DisplayShortcuts) ); RegisterRichCommand(ManageShortcutsCommand); #endif //#if DEBUG // ShowLogFilePathCommand = new RichDelegateCommand( // UserInterfaceStrings.ShowLogFilePath, // UserInterfaceStrings.ShowLogFilePath_, // null, // KeyGesture obtained from settings (see last parameters below) // null, //LoadTangoIcon(@"help-browser"), // () => // { // m_Logger.Log(@"ShellView.ShowLogFilePathCommand", Category.Debug, Priority.Medium); // var label = new TextBlock // { // Text = UserInterfaceStrings.ShowLogFilePath_, // Margin = new Thickness(8, 0, 8, 0), // HorizontalAlignment = HorizontalAlignment.Center, // VerticalAlignment = VerticalAlignment.Center, // Focusable = true, // TextWrapping = TextWrapping.Wrap // }; // var iconProvider = new ScalableGreyableImageProvider(LoadTangoIcon("edit-find"), MagnificationLevel); // var panel = new StackPanel // { // Orientation = Orientation.Horizontal, // HorizontalAlignment = HorizontalAlignment.Center, // VerticalAlignment = VerticalAlignment.Stretch, // }; // panel.Children.Add(iconProvider.IconLarge); // panel.Children.Add(label); // //panel.Margin = new Thickness(8, 8, 8, 0); // var details = new TextBoxReadOnlyCaretVisible(ApplicationConstants.LOG_FILE_PATH) // { // }; // var windowPopup = new PopupModalWindow(this, // UserInterfaceStrings.EscapeMnemonic( // UserInterfaceStrings.ShowLogFilePath), // panel, // PopupModalWindow.DialogButtonsSet.Close, // PopupModalWindow.DialogButton.Close, // true, 300, 160, details, 40); // windowPopup.ShowModal(); // }, // () => true, // Settings_KeyGestures.Default, // null //PropertyChangedNotifyBase.GetMemberName(() => Settings_KeyGestures.Default.Keyboard_DisplayLogFilePath) // ); // RegisterRichCommand(ShowLogFilePathCommand); // // //#endif //DEBUG // OpenTobiIsolatedStorageCommand = new RichDelegateCommand( Tobi_Lang.CmdOpenTobiIsolatedStorage_ShortDesc, Tobi_Lang.CmdOpenTobiIsolatedStorage_LongDesc, null, // KeyGesture obtained from settings (see last parameters below) LoadGnomeNeuIcon(@"Neu_applications-office"), () => { m_Logger.Log(@"ShellView.OpenTobiIsolatedStorageCommand", Category.Debug, Priority.Medium); ExecuteShellProcess(ExternalFilesDataManager.STORAGE_FOLDER_PATH); }, () => !m_UrakawaSession.isAudioRecording, Settings_KeyGestures.Default, null //PropertyChangedNotifyBase.GetMemberName(() => Settings_KeyGestures.Default.Keyboard_ShowTobiFolder) ); RegisterRichCommand(OpenTobiIsolatedStorageCommand); // OpenTobiFolderCommand = new RichDelegateCommand( Tobi_Lang.CmdOpenTobiFolder_ShortDesc, Tobi_Lang.CmdOpenTobiFolder_LongDesc, null, // KeyGesture obtained from settings (see last parameters below) LoadGnomeNeuIcon(@"Neu_user-home"), () => { m_Logger.Log(@"ShellView.OpenTobiFolderCommand", Category.Debug, Priority.Medium); ExecuteShellProcess(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location)); }, () => !m_UrakawaSession.isAudioRecording, Settings_KeyGestures.Default, null //PropertyChangedNotifyBase.GetMemberName(() => Settings_KeyGestures.Default.Keyboard_ShowTobiFolder) ); RegisterRichCommand(OpenTobiFolderCommand); // OpenTobiSettingsFolderCommand = new RichDelegateCommand( Tobi_Lang.CmdOpenTobiSettingsFolder_ShortDesc, Tobi_Lang.CmdOpenTobiSettingsFolder_LongDesc, null, // KeyGesture obtained from settings (see last parameters below) LoadGnomeFoxtrotIcon(@"Foxtrot_folder"), () => { m_Logger.Log(@"ShellView.OpenTobiSettingsFolderCommand", Category.Debug, Priority.Medium); Configuration config = ConfigurationManager.OpenExeConfiguration(ConfigurationUserLevel.PerUserRoamingAndLocal); string settingsPath = Path.GetDirectoryName(config.FilePath); ExecuteShellProcess(settingsPath); }, () => !m_UrakawaSession.isAudioRecording, Settings_KeyGestures.Default, null //PropertyChangedNotifyBase.GetMemberName(() => Settings_KeyGestures.Default.Keyboard_ShowTobiSettingsFolder) ); RegisterRichCommand(OpenTobiSettingsFolderCommand); // #if DEBUG HelpCommand = new RichDelegateCommand( Tobi_Lang.CmdHelp_ShortDesc, Tobi_Lang.CmdHelp_LongDesc, null, // KeyGesture obtained from settings (see last parameters below) LoadTangoIcon("help-browser"), () => { m_Logger.Log("ShellView.HelpCommand", Category.Debug, Priority.Medium); throw new NotImplementedException("Functionality not implemented, sorry :(", new ArgumentOutOfRangeException("First Inner exception", new FileNotFoundException("Second inner exception !"))); // try // { } //catch (Exception ex) //{ // ExceptionHandler.Handle(ex, false, this); //} }, () => true, Settings_KeyGestures.Default, PropertyChangedNotifyBase.GetMemberName(() => Settings_KeyGestures.Default.Keyboard_Help)); RegisterRichCommand(HelpCommand); #endif // //PreferencesCommand = new RichDelegateCommand( // UserInterfaceStrings.Preferences, // UserInterfaceStrings.Preferences_, // null, // KeyGesture obtained from settings (see last parameters below) // LoadTangoIcon("preferences-system"), // () => Debug.Fail("Functionality not implemented yet."), // () => true, // Settings_KeyGestures.Default, // PropertyChangedNotifyBase.GetMemberName(() => Settings_KeyGestures.Default.Keyboard_Preferences)); //RegisterRichCommand(PreferencesCommand); // //WebHomeCommand = new RichDelegateCommand(UserInterfaceStrings.WebHome, // UserInterfaceStrings.WebHome_, // UserInterfaceStrings.WebHome_KEYS, // //ScalableGreyableImageProvider.ConvertIconFormat((DrawingImage)Application.Current.FindResource("Home_icon")), // LoadTangoIcon("go-home"), // ()=> { throw new NotImplementedException("Functionality not implemented, sorry :("); }, ()=> true); //RegisterRichCommand(WebHomeCommand); //// //NavNextCommand = new RichDelegateCommand(UserInterfaceStrings.NavNext, // UserInterfaceStrings.NavNext_, // UserInterfaceStrings.NavNext_KEYS, // ScalableGreyableImageProvider.ConvertIconFormat((DrawingImage)Application.Current.FindResource("Horizon_Image_Forward")), // ()=> { throw new NotImplementedException("Functionality not implemented, sorry :("); }, ()=> true); //RegisterRichCommand(NavNextCommand); //// //NavPreviousCommand = new RichDelegateCommand(UserInterfaceStrings.NavPrevious, // UserInterfaceStrings.NavPrevious_, // UserInterfaceStrings.NavPrevious_KEYS, // ScalableGreyableImageProvider.ConvertIconFormat((DrawingImage)Application.Current.FindResource("Horizon_Image_Back")), // ()=> { throw new NotImplementedException("Functionality not implemented, sorry :("); }, ()=> true); //RegisterRichCommand(NavPreviousCommand); }
public static void Handle(Exception rootException, bool doExit, IShellView shellView) { if (rootException == null) { return; } if (!Dispatcher.CurrentDispatcher.CheckAccess()) { #if DEBUG Debugger.Break(); #endif Dispatcher.CurrentDispatcher.Invoke((Action <Exception, bool, IShellView>)Handle, rootException, doExit, shellView); return; } Exception ex = rootException; if (rootException is TargetInvocationException) { if (rootException.InnerException != null) { ex = rootException.InnerException.GetRootException(); } else { ex = rootException.GetRootException(); } ex = rootException.InnerException; } LogException(ex); var margin = new Thickness(0, 0, 0, 8); var panel = new DockPanel { LastChildFill = true }; //var panel = new StackPanel { Orientation = Orientation.Vertical }; var labelMsg = new TextBoxReadOnlyCaretVisible { TextReadOnly = String.Format(Tobi_Common_Lang.UnhandledException, Environment.NewLine, ApplicationConstants.LOG_FILE_NAME, ApplicationConstants.LOG_FILE_PATH), BorderThickness = new Thickness(1), Padding = new Thickness(6), FontWeight = FontWeights.ExtraBlack, Margin = margin, BorderBrush = Brushes.Red }; //var binding = new Binding // { // Mode = BindingMode.OneWay, // Source = UserInterfaceStrings.UnhandledException, // Path = new PropertyPath(".") // }; //var expr = labelMsg.SetBinding(TextBox.TextProperty, binding); //labelMsg.PreviewKeyDown += ((sender, e) => // { // if (!(e.Key == Key.Down || e.Key == Key.Up || e.Key == Key.Left || e.Key == Key.Right || e.Key == Key.Home || e.Key == Key.End || e.Key == Key.PageDown || e.Key == Key.PageUp || e.Key == Key.Tab)) // e.Handled = true; // }); labelMsg.SetValue(DockPanel.DockProperty, Dock.Top); panel.Children.Add(labelMsg); //var exMessage = UserInterfaceStrings.UnhandledException; //exMessage += Environment.NewLine; //exMessage += @"==============="; //exMessage += Environment.NewLine; var exMessage = "[" + ex.GetType().FullName + "] " + ex.Message; Exception exinnerd = ex; while (exinnerd.InnerException != null) { if (!String.IsNullOrEmpty(exinnerd.InnerException.Message)) { exMessage += Environment.NewLine; exMessage += @"======"; exMessage += Environment.NewLine; exMessage += "[" + exinnerd.GetType().FullName + "] "; exMessage += exinnerd.InnerException.Message; } exinnerd = exinnerd.InnerException; } var compEx = ex as CompositionException; if (compEx != null) { foreach (var error in compEx.Errors) { exMessage += Environment.NewLine; exMessage += @"======"; exMessage += Environment.NewLine; exMessage += error.Description; if (error.Exception != null) { exMessage += Environment.NewLine; exMessage += @"======"; exMessage += Environment.NewLine; exMessage += "[" + error.Exception.GetType().FullName + "] "; exMessage += error.Exception.Message; exinnerd = error.Exception; while (exinnerd.InnerException != null) { if (!String.IsNullOrEmpty(exinnerd.InnerException.Message)) { exMessage += Environment.NewLine; exMessage += @"======"; exMessage += Environment.NewLine; exMessage += "[" + exinnerd.InnerException.GetType().FullName + "] "; exMessage += exinnerd.InnerException.Message; } exinnerd = exinnerd.InnerException; } } } } var labelSummary = new TextBoxReadOnlyCaretVisible { TextReadOnly = exMessage, Padding = new Thickness(6), FontWeight = FontWeights.ExtraBlack, //Margin = margin, BorderBrush = null, BorderThickness = new Thickness(0) }; var scroll = new ScrollViewer { Content = labelSummary, //Margin = margin, BorderBrush = SystemColors.ControlDarkBrush, //BorderBrush = Brushes.Red, BorderThickness = new Thickness(1), HorizontalAlignment = HorizontalAlignment.Stretch, VerticalAlignment = VerticalAlignment.Stretch }; //scroll.SetValue(DockPanel.DockProperty, Dock.Top); panel.Children.Add(scroll); // DETAILS: var exStackTrace = ex.StackTrace; Exception exinner = ex; while (exinner.InnerException != null) { if (!String.IsNullOrEmpty(exinner.InnerException.StackTrace)) { exStackTrace += Environment.NewLine; exStackTrace += "========================="; exStackTrace += Environment.NewLine; exStackTrace += "-------------------------"; exStackTrace += Environment.NewLine; exStackTrace += exinner.InnerException.StackTrace; } exinner = exinner.InnerException; } if (compEx != null) { foreach (var error in compEx.Errors) { if (error.Exception != null) { exStackTrace += Environment.NewLine; exStackTrace += "========================="; exStackTrace += Environment.NewLine; exStackTrace += "-------------------------"; exStackTrace += Environment.NewLine; exStackTrace += error.Exception.StackTrace; exinner = error.Exception; while (exinner.InnerException != null) { if (!String.IsNullOrEmpty(exinner.InnerException.StackTrace)) { exStackTrace += Environment.NewLine; exStackTrace += "========================="; exStackTrace += Environment.NewLine; exStackTrace += "-------------------------"; exStackTrace += Environment.NewLine; exStackTrace += exinner.InnerException.StackTrace; } exinner = exinner.InnerException; } } } } var stackTrace = new TextBoxReadOnlyCaretVisible { TextReadOnly = exStackTrace, Padding = new Thickness(6), BorderBrush = null, BorderThickness = new Thickness(0) }; var details = new ScrollViewer { Content = stackTrace, Margin = margin, BorderBrush = SystemColors.ControlDarkDarkBrush, BorderThickness = new Thickness(1), HorizontalAlignment = HorizontalAlignment.Stretch, VerticalAlignment = VerticalAlignment.Stretch }; //panel.Children.Add(scroll); /* * var logStr = String.Format("CANNOT OPEN [{0}] !", logPath); * * var logFile = File.Open(logPath, FileMode.Open, FileAccess.Read, FileShare.Read); * if (logFile.CanRead) * { * logFile.Close(); * //logFile.Read(bytes, int, int) * logStr = File.ReadAllText(logPath); * } * * var log = new TextBlock * { * Text = logStr, * Margin = new Thickness(15), * HorizontalAlignment = HorizontalAlignment.Left, * VerticalAlignment = VerticalAlignment.Top, * TextWrapping = TextWrapping.Wrap, * }; * * var scroll2 = new ScrollViewer * { * Content = log, * HorizontalAlignment = HorizontalAlignment.Stretch, * }; * panel.Children.Add(scroll2); * */ var windowPopup = new PopupModalWindow(shellView, UserInterfaceStrings.EscapeMnemonic(Tobi_Common_Lang.Unexpected), panel, PopupModalWindow.DialogButtonsSet.Ok, PopupModalWindow.DialogButton.Ok, !doExit, 500, 250, (String.IsNullOrEmpty(exStackTrace) ? null : details), 130, null); AudioCues.PlayExclamation(); try { windowPopup.ShowModal(); } catch (TargetInvocationException exx1) { try { Dispatcher.CurrentDispatcher.Invoke((Action)(windowPopup.ShowModal)); } catch (TargetInvocationException exx2) { throw exx2.InnerException; } } if (windowPopup.ClickedDialogButton == PopupModalWindow.DialogButton.Ok && doExit) { Application.Current.Shutdown(); //Environment.Exit(1); } }
public void ImportMetadata() { //m_ShellView.ExecuteShellProcess(MetadataPaneViewModel.METADATA_IMPORT_DIRECTORY); string text; List <Tuple <string, string> > metadatas = readMetadataImport(out text); var editBox = new TextBoxReadOnlyCaretVisible { Text = text, AcceptsReturn = true, TextWrapping = TextWrapping.WrapWithOverflow }; var windowPopup = new PopupModalWindow(m_ShellView, UserInterfaceStrings.EscapeMnemonic(Tobi_Plugin_MetadataPane_Lang.Import), new ScrollViewer { Content = editBox }, PopupModalWindow.DialogButtonsSet.OkCancel, PopupModalWindow.DialogButton.Ok, true, 500, 600, null, 40, null); windowPopup.EnableEnterKeyDefault = false; editBox.Loaded += new RoutedEventHandler((sender, ev) => { //editBox.SelectAll(); FocusHelper.FocusBeginInvoke(editBox); }); windowPopup.ShowModal(); if (PopupModalWindow.IsButtonOkYesApply(windowPopup.ClickedDialogButton)) { if (!string.IsNullOrEmpty(editBox.Text)) { StreamWriter streamWriter = new StreamWriter(METADATA_IMPORT_FILE, false, Encoding.UTF8); try { streamWriter.Write(editBox.Text); } finally { streamWriter.Close(); } string newText; metadatas = readMetadataImport(out newText); //DebugFix.assert(newText.Equals(editBox.Text, StringComparison.Ordinal)); Presentation presentation = m_UrakawaSession.DocumentProject.Presentations.Get(0); foreach (Tuple <string, string> md in metadatas) { List <NotifyingMetadataItem> toRemove = new List <NotifyingMetadataItem>(); foreach (NotifyingMetadataItem m in this.MetadataCollection.Metadatas) { if (m.Name.Equals(md.Item1, StringComparison.Ordinal)) { if (!m.Definition.IsRepeatable) { if (!toRemove.Contains(m)) { toRemove.Add(m); } } } } foreach (var m in toRemove) { RemoveMetadata(m); } Metadata metadata = presentation.MetadataFactory.CreateMetadata(); metadata.NameContentAttribute = new MetadataAttribute { Name = md.Item1, NamespaceUri = "", Value = md.Item2 }; MetadataAddCommand cmd = presentation.CommandFactory.CreateMetadataAddCommand (metadata); presentation.UndoRedoManager.Execute(cmd); } } } }