示例#1
0
        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();
            }
        }
示例#2
0
        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));
            }
        }
示例#3
0
        private bool askUser(string message, string info)
        {
            m_Logger.Log("ShellView.askUser", Category.Debug, Priority.Medium);

            var label = new TextBlock
            {
                Text   = message,
                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.Left,
                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    = info
            };

            var windowPopup = new PopupModalWindow(m_ShellView,
                                                   message,
                                                   panel,
                                                   PopupModalWindow.DialogButtonsSet.YesNo,
                                                   PopupModalWindow.DialogButton.No,
                                                   true, 360, 200, details, 40, null);

            windowPopup.ShowModal();

            if (PopupModalWindow.IsButtonOkYesApply(windowPopup.ClickedDialogButton))
            {
                return(true);
            }

            return(false);
        }
示例#4
0
        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);
        }
示例#5
0
        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 string showTextEditorPopupDialog(string editedText, String dialogTitle)
        {
            m_Logger.Log("showTextEditorPopupDialog", Category.Debug, Priority.Medium);

            var editBox = new TextBoxReadOnlyCaretVisible
            {
                FocusVisualStyle = (Style)Application.Current.Resources["MyFocusVisualStyle"],

                Text          = editedText,
                TextWrapping  = TextWrapping.WrapWithOverflow,
                AcceptsReturn = true
            };

            var windowPopup = new PopupModalWindow(m_ShellView,
                                                   dialogTitle,
                                                   new ScrollViewer
            {
                Content = editBox,
                HorizontalScrollBarVisibility = ScrollBarVisibility.Disabled,
                VerticalScrollBarVisibility   = ScrollBarVisibility.Auto
            },
                                                   PopupModalWindow.DialogButtonsSet.OkCancel,
                                                   PopupModalWindow.DialogButton.Ok,
                                                   true, 350, 200, null, 40, m_DescriptionPopupModalWindow);

            windowPopup.EnableEnterKeyDefault = true;

            editBox.Loaded += new RoutedEventHandler((sender, ev) =>
            {
                editBox.SelectAll();
                FocusHelper.FocusBeginInvoke(editBox);
            });

            windowPopup.ShowModal();


            if (PopupModalWindow.IsButtonOkYesApply(windowPopup.ClickedDialogButton))
            {
                string str = editBox.Text == null ? "" : editBox.Text.Trim();
                //if (string.IsNullOrEmpty(str))
                //{
                //    return "";
                //}
                return(str);
            }

            return(null);
        }
示例#7
0
        private bool askUserAlt(string title, string message)
        {
            m_Logger.Log("ShellView.askUser", Category.Debug, Priority.Medium);

            var label = new TextBlock
            {
                Text   = message,
                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"), //help-browser
                m_ShellView.MagnificationLevel);

            var panel = new StackPanel
            {
                Orientation         = Orientation.Horizontal,
                HorizontalAlignment = HorizontalAlignment.Left,
                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,
                                                   title,
                                                   panel,
                                                   PopupModalWindow.DialogButtonsSet.OkCancel,
                                                   PopupModalWindow.DialogButton.Cancel,
                                                   true, 400, 200, null, 40, null);

            windowPopup.ShowModal();

            if (PopupModalWindow.IsButtonOkYesApply(windowPopup.ClickedDialogButton))
            {
                return(true);
            }

            return(false);
        }
示例#8
0
        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);
        }
示例#9
0
        public void messageBoxAlert(string message, Window owner)
        {
            m_Logger.Log(@"UrakawaSession_Save.messageBoxAlert", Category.Debug, Priority.Medium);


            var label = new TextBlock
            {
                Text   = message,
                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,
                                                   "Warning",
                                                   panel,
                                                   PopupModalWindow.DialogButtonsSet.Ok,
                                                   PopupModalWindow.DialogButton.Ok,
                                                   true, 600, 160, null, 40, owner);

            windowPopup.ShowModal();
        }
        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();
        }
示例#11
0
        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);
        }
示例#12
0
        private string askUserId(IShellView shellView, string title, string message, string info)
        {
            m_Logger.Log("Bootstrapper.askUserId", Category.Debug, Priority.Medium);

            var label = new TextBlock // TextBoxReadOnlyCaretVisible
            {
                //FocusVisualStyle = (Style)Application.Current.Resources["MyFocusVisualStyle"],

                //BorderThickness = new Thickness(1),
                //Padding = new Thickness(6),

                //TextReadOnly = message,
                Text       = message,
                FontWeight = FontWeights.Bold,

                Margin = new Thickness(8, 0, 8, 0),
                HorizontalAlignment = HorizontalAlignment.Stretch,
                VerticalAlignment   = VerticalAlignment.Center,
                Focusable           = true,
                TextWrapping        = TextWrapping.Wrap
            };

            var input = new TextBox()
            {
                HorizontalAlignment = HorizontalAlignment.Stretch,
                VerticalAlignment   = VerticalAlignment.Center,
                Text = ""
            };

            //var iconProvider = new ScalableGreyableImageProvider(
            //    m_ShellView.LoadTangoIcon("help-browser"),
            //    m_ShellView.MagnificationLevel);

            var panel = new StackPanel
            {
                Orientation         = Orientation.Vertical,
                HorizontalAlignment = HorizontalAlignment.Stretch,
                VerticalAlignment   = VerticalAlignment.Stretch,
            };

            //panel.Margin = new Thickness(8, 8, 8, 0);

            //panel.Children.Add(iconProvider.IconLarge);
            panel.Children.Add(label);
            panel.Children.Add(input);


            var checkBox = new CheckBox
            {
                FocusVisualStyle    = (Style)Application.Current.Resources["MyFocusVisualStyle"],
                IsThreeState        = false,
                IsChecked           = Settings.Default.UserId_DoNotAskAgain,
                VerticalAlignment   = VerticalAlignment.Center,
                Content             = Tobi_Common_Lang.DoNotShowMessageAgain,
                Margin              = new Thickness(0, 16, 0, 0),
                HorizontalAlignment = HorizontalAlignment.Left,
            };

            panel.Children.Add(checkBox);



            var details = new TextBoxReadOnlyCaretVisible
            {
                FocusVisualStyle = (Style)Application.Current.Resources["MyFocusVisualStyle"],

                BorderThickness = new Thickness(1),
                Padding         = new Thickness(6),
                TextReadOnly    = info
            };

            var windowPopup = new PopupModalWindow(shellView, // m_ShellView
                                                   title,
                                                   panel,
                                                   PopupModalWindow.DialogButtonsSet.OkCancel, // PopupModalWindow.DialogButtonsSet.YesNo
                                                   PopupModalWindow.DialogButton.Ok,           //PopupModalWindow.DialogButton.Yes
                                                   true, 425, 190, details, 70, null);

            windowPopup.ShowModal();

            Settings.Default.UserId_DoNotAskAgain = checkBox.IsChecked.Value;

            if (PopupModalWindow.IsButtonOkYesApply(windowPopup.ClickedDialogButton))
            {
                return(input.Text);
            }

            return(null);
        }
示例#13
0
        public void messageBoxText(string title, string text, string info)
        {
            m_Logger.Log(@"UrakawaSession_Save.messageBoxText", Category.Debug, Priority.Medium);

            if (String.IsNullOrEmpty(info))
            {
                info = "";
            }

            var label = new TextBlock
            {
                Text   = text,
                Margin = new Thickness(8, 0, 8, 0),
                HorizontalAlignment = HorizontalAlignment.Center,
                VerticalAlignment   = VerticalAlignment.Center,
                Focusable           = true,
                TextWrapping        = TextWrapping.Wrap,
                FontWeight          = FontWeights.Bold,
            };


            var textArea = new TextBoxReadOnlyCaretVisible()
            {
                FocusVisualStyle = (Style)Application.Current.Resources["MyFocusVisualStyle"],

                IsReadOnly   = true,
                TextReadOnly = info,

                BorderThickness = new Thickness(1),
                Padding         = new Thickness(6),

                HorizontalAlignment = HorizontalAlignment.Stretch,
                VerticalAlignment   = VerticalAlignment.Stretch,
                Focusable           = true,
                TextWrapping        = TextWrapping.Wrap
            };

            var scroll = new ScrollViewer
            {
                Content = textArea,

                Margin = new Thickness(6),
                VerticalScrollBarVisibility   = ScrollBarVisibility.Visible,
                HorizontalScrollBarVisibility = ScrollBarVisibility.Disabled
            };

            var panel = new StackPanel
            {
                Orientation         = Orientation.Horizontal,
                HorizontalAlignment = HorizontalAlignment.Center,
                VerticalAlignment   = VerticalAlignment.Stretch,
            };

            panel.Children.Add(label);
            //panel.Margin = new Thickness(8, 8, 8, 0);

            if (String.IsNullOrEmpty(info))
            {
                scroll = null;
            }

            var windowPopup = new PopupModalWindow(m_ShellView,
                                                   title,
                                                   panel,
                                                   PopupModalWindow.DialogButtonsSet.Ok,
                                                   PopupModalWindow.DialogButton.Ok,
                                                   true, 500, 160, scroll, 300, null);

            windowPopup.ShowModal();
        }
示例#14
0
        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);
        }
        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);
                    }
                }
            }
        }
        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 string showLineEditorPopupDialog(string editedText, string dialogTitle, List <string> predefinedCandidates, bool invalidSyntax)
        {
            m_Logger.Log("showTextEditorPopupDialog", Category.Debug, Priority.Medium);

            if (predefinedCandidates == null)
            {
                var editBox = new TextBoxReadOnlyCaretVisible
                {
                    FocusVisualStyle = (Style)Application.Current.Resources["MyFocusVisualStyle"],

                    //Watermark = TEXTFIELD_WATERMARK,
                    Text          = editedText,
                    TextWrapping  = TextWrapping.NoWrap,
                    AcceptsReturn = false
                };

                var panel = new StackPanel();
                panel.SetValue(StackPanel.OrientationProperty, Orientation.Vertical);
                panel.SetValue(FrameworkElement.VerticalAlignmentProperty, VerticalAlignment.Center);
                editBox.SetValue(FrameworkElement.VerticalAlignmentProperty, VerticalAlignment.Center);
                panel.Children.Add(editBox);

                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 windowPopup = new PopupModalWindow(m_ShellView,
                                                       dialogTitle,
                                                       panel,
                                                       PopupModalWindow.DialogButtonsSet.OkCancel,
                                                       PopupModalWindow.DialogButton.Ok,
                                                       true, 300, 160, null, 40, m_DescriptionPopupModalWindow);

                windowPopup.EnableEnterKeyDefault = true;

                editBox.SetValue(AutomationProperties.NameProperty, dialogTitle);

                editBox.Loaded += new RoutedEventHandler((sender, ev) =>
                {
                    editBox.SelectAll();
                    FocusHelper.FocusBeginInvoke(editBox);
                });

                WatermarkTextBoxBehavior.SetEnableWatermark(editBox, true);
                WatermarkTextBoxBehavior.SetLabel(editBox, TEXTFIELD_WATERMARK);

                Style style = (Style)Application.Current.Resources[@"WatermarkTextBoxStyle"];
                WatermarkTextBoxBehavior.SetLabelStyle(editBox, style);

                windowPopup.ShowModal();

                WatermarkTextBoxBehavior.SetEnableWatermark(editBox, false);

                if (PopupModalWindow.IsButtonOkYesApply(windowPopup.ClickedDialogButton))
                {
                    string str = editBox.Text == null ? "" : editBox.Text.Trim();
                    //if (string.IsNullOrEmpty(str))
                    //{
                    //    return "";
                    //}
                    return(str);
                }

                return(null);
            }
            else
            {
                var editBoxCombo_Name = new ComboBox //WithAutomationPeer
                {
                    FocusVisualStyle = (Style)Application.Current.Resources["MyFocusVisualStyle"],

                    Text                = editedText,
                    IsEditable          = true,
                    IsTextSearchEnabled = true,
#if NET40
                    IsTextSearchCaseSensitive = false
#endif //NET40
                };

                editBoxCombo_Name.ItemsSource = predefinedCandidates;

                var panel = new StackPanel();
                panel.SetValue(StackPanel.OrientationProperty, Orientation.Vertical);
                panel.SetValue(FrameworkElement.VerticalAlignmentProperty, VerticalAlignment.Center);
                editBoxCombo_Name.SetValue(FrameworkElement.VerticalAlignmentProperty, VerticalAlignment.Center);
                panel.Children.Add(editBoxCombo_Name);

                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 windowPopup = new PopupModalWindow(m_ShellView,
                                                       dialogTitle,
                                                       panel,
                                                       PopupModalWindow.DialogButtonsSet.OkCancel,
                                                       PopupModalWindow.DialogButton.Ok,
                                                       true, 300, 160, 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);
                });

                WatermarkComboBoxBehavior.SetEnableWatermark(editBoxCombo_Name, true);
                WatermarkComboBoxBehavior.SetLabel(editBoxCombo_Name, TEXTFIELD_WATERMARK);

                Style style = (Style)Application.Current.Resources[@"WatermarkTextBoxStyle"];
                WatermarkComboBoxBehavior.SetLabelStyle(editBoxCombo_Name, style);

                windowPopup.ShowModal();

                WatermarkComboBoxBehavior.SetEnableWatermark(editBoxCombo_Name, false);

                if (PopupModalWindow.IsButtonOkYesApply(windowPopup.ClickedDialogButton))
                {
                    string str = editBoxCombo_Name.Text == null ? "" : editBoxCombo_Name.Text.Trim();
                    //if (string.IsNullOrEmpty(str))
                    //{
                    //    return "";
                    //}
                    return(str);
                }

                return(null);
            }
        }
示例#18
0
        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);
        }
示例#19
0
        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();
            }
        }
示例#20
0
        public string messageBoxFilePick(string title, string exeOrBat)
        {
            m_Logger.Log(@"UrakawaSession_Save.messageBoxFilePick", Category.Debug, Priority.Medium);

            string ext = Path.GetExtension(exeOrBat);

            PopupModalWindow windowPopup = null;


            //var textArea = new TextBoxReadOnlyCaretVisible()
            //{
            //    FocusVisualStyle = (Style)Application.Current.Resources["MyFocusVisualStyle"],

            //    TextReadOnly = info,

            //    BorderThickness = new Thickness(1),
            //    Padding = new Thickness(6),

            //    HorizontalAlignment = HorizontalAlignment.Stretch,
            //    VerticalAlignment = VerticalAlignment.Stretch,
            //    Focusable = true,
            //    TextWrapping = TextWrapping.Wrap
            //};

            //var scroll = new ScrollViewer
            //{
            //    Content = textArea,

            //    Margin = new Thickness(6),
            //    VerticalScrollBarVisibility = ScrollBarVisibility.Visible,
            //    HorizontalScrollBarVisibility = ScrollBarVisibility.Disabled
            //};

            var fileText = new TextBoxReadOnlyCaretVisible
            {
                FocusVisualStyle = (Style)Application.Current.Resources["MyFocusVisualStyle"],

                BorderThickness = new Thickness(1),
                BorderBrush     = SystemColors.ControlDarkDarkBrush,
                //Padding = new Thickness(6),
                TextReadOnly = " ",
                //IsReadOnly = true,
                Width = 300,

                Margin  = new Thickness(0, 8, 0, 0),
                Padding = new Thickness(4),

                HorizontalAlignment = HorizontalAlignment.Stretch,
                VerticalAlignment   = VerticalAlignment.Stretch,
                Focusable           = true,
                TextWrapping        = TextWrapping.Wrap
            };

            //fileText.SetValue(KeyboardNavigation.TabIndexProperty, 12);
            KeyboardNavigation.SetTabIndex(fileText, 12);

            var label = new TextBlock
            {
                Text   = "Please locate [" + exeOrBat + "]",
                Margin = new Thickness(0, 0, 8, 0),
                HorizontalAlignment = HorizontalAlignment.Left,
                VerticalAlignment   = VerticalAlignment.Center,
                Focusable           = true,
                TextWrapping        = TextWrapping.Wrap,
                FontWeight          = FontWeights.Bold,
            };

            //label.SetValue(KeyboardNavigation.TabIndexProperty, 10);
            KeyboardNavigation.SetTabIndex(label, 10);


            var fileButton = new Button()
            {
                Content = "Browse...",
                Margin  = new Thickness(0, 0, 0, 0),
                Padding = new Thickness(8, 0, 8, 0),
            };

            //fileButton.SetValue(KeyboardNavigation.TabIndexProperty, 11);
            KeyboardNavigation.SetTabIndex(fileButton, 11);

            fileButton.Click += (sender, e) =>
            {
                var dlg_ = new Microsoft.Win32.OpenFileDialog
                {
                    FileName   = exeOrBat,
                    DefaultExt = ext,

                    Filter           = @"Executable (*" + ext + ")|*" + ext + "",
                    CheckFileExists  = false,
                    CheckPathExists  = false,
                    AddExtension     = true,
                    DereferenceLinks = true,
                    Title            =
                        @"Tobi: " +
                        "Pipeline2 (" + exeOrBat + ")"
                };

                bool?result_ = false;

                m_ShellView.DimBackgroundWhile(
                    () => { result_ = dlg_.ShowDialog(); }
                    , windowPopup
                    );

                if (result_ == true)
                {
                    fileText.TextReadOnly = dlg_.FileName;
                }
            };

            var filePanel = new DockPanel
            {
                HorizontalAlignment = HorizontalAlignment.Stretch,
                VerticalAlignment   = VerticalAlignment.Center,

                LastChildFill = true
            };

            //fileButton.SetValue(DockPanel.DockProperty, Dock.Right);
            DockPanel.SetDock(fileButton, Dock.Right);

            filePanel.Children.Add(fileButton);
            filePanel.Children.Add(label);

            var panel = new StackPanel
            {
                Orientation         = Orientation.Vertical,
                HorizontalAlignment = HorizontalAlignment.Center,
                VerticalAlignment   = VerticalAlignment.Center,
            };

            panel.Children.Add(filePanel);
            panel.Children.Add(fileText);
            //panel.Margin = new Thickness(8, 8, 8, 0);

            windowPopup = new PopupModalWindow(m_ShellView,
                                               title,
                                               panel,
                                               PopupModalWindow.DialogButtonsSet.OkCancel,
                                               PopupModalWindow.DialogButton.Ok,
                                               true, 380, 200,
                                               null,    //scroll,
                                               300, null);

            windowPopup.ShowModal();

            if (PopupModalWindow.IsButtonOkYesApply(windowPopup.ClickedDialogButton))
            {
                return(fileText.TextReadOnly);
            }

            return(null);
        }
示例#21
0
        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);
        }
示例#22
0
        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);
        }
示例#23
0
        //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();
            }
        }
示例#24
0
        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);
        }
示例#25
0
        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);
        }