public void OnUndoRedoManagerChanged(UndoRedoManagerEventArgs eventt, bool done, Command command, bool isTransactionEndEvent, bool isNoTransactionOrTrailingEdge)
        {
            if (!Dispatcher.CheckAccess())
            {
#if DEBUG
                Debugger.Break();
#endif

#if NET40x
                Dispatcher.Invoke(DispatcherPriority.Normal,
                                  (Action <UndoRedoManagerEventArgs, bool, Command, bool, bool>)OnUndoRedoManagerChanged,
                                  eventt, done, command, isTransactionEndEvent, isNoTransactionOrTrailingEdge);
#else
                Dispatcher.Invoke(DispatcherPriority.Normal,
                                  (Action)(() => OnUndoRedoManagerChanged(eventt, done, command, isTransactionEndEvent, isNoTransactionOrTrailingEdge))
                                  );
#endif
                return;
            }

            //if (isTransactionEndEvent)
            //{
            //    return;
            //}

            if (command is CompositeCommand)
            {
#if DEBUG
                Debugger.Break();
#endif
            }

            if (isNoTransactionOrTrailingEdge)
            {
                //bool keyboardFocusWithin = this.IsKeyboardFocusWithin;

                Tuple <TreeNode, TreeNode> newTreeNodeSelection = m_UrakawaSession.GetTreeNodeSelection();
                refreshData(newTreeNodeSelection);

                //if (keyboardFocusWithin)
                //{
                //    CommandFocus.Execute();
                //}
            }
        }
示例#2
0
        public IEnumerable <AlternateContent> GetAltContents(string diagramElementName)
        {
            if (m_UrakawaSession.DocumentProject == null)
            {
                yield break;
            }

            Tuple <TreeNode, TreeNode> selection = m_UrakawaSession.GetTreeNodeSelection();
            TreeNode node = selection.Item2 ?? selection.Item1;

            if (node == null)
            {
                yield break;
            }

            AlternateContentProperty altProp = node.GetAlternateContentProperty();

            if (altProp == null)
            {
                yield break;
            }

            if (altProp.AlternateContents.Count <= 0)
            {
                yield break;
            }

            foreach (var altContent in altProp.AlternateContents.ContentsAs_Enumerable)
            {
                foreach (var metadata in altContent.Metadatas.ContentsAs_Enumerable)
                {
                    if (metadata.NameContentAttribute.Name.Equals(DiagramContentModelHelper.DiagramElementName, StringComparison.OrdinalIgnoreCase))
                    {
                        if (metadata.NameContentAttribute.Value.Equals(diagramElementName, StringComparison.OrdinalIgnoreCase))
                        {
                            yield return(altContent);
                        }
                    }
                }
            }

            yield break;
        }
        private bool CanShowDialog()
        {
            if (m_UrakawaSession.DocumentProject == null)
            {
                return(false);
            }

            if (m_UrakawaSession.isAudioRecording)
            {
                return(false);
            }

            Tuple <TreeNode, TreeNode> selection = m_UrakawaSession.GetTreeNodeSelection();
            TreeNode node = selection.Item2 ?? selection.Item1;

            return
                //m_TextElementForEdit != null ||
                (node != null &&
                 node.GetXmlElementLocalName() == "img"
                 //&& node.GetXmlElementLocalName() == "video"
                );
        }
示例#4
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();
            }
        }