示例#1
0
        /// <summary>
        /// Manages event handlers in the store so that the tool window
        /// contents can be updated to reflect any model changes.
        /// </summary>
        protected override void ManageEventHandlers(Store store, ModelingEventManager eventManager, EventHandlerAction action)
        {
            ReadingsViewForm form          = myForm;
            ReadingEditor    readingEditor = (form != null) ? form.ReadingEditor : null;

            if (readingEditor != null)
            {
                readingEditor.ManageEventHandlers(store, eventManager, action);
            }
        }
示例#2
0
 public ReadingsViewForm(ORMReadingEditorToolWindow toolWindow)
 {
     myReadingEditor = new ReadingEditor(toolWindow);
     this.Controls.Add(myReadingEditor);
     System.Drawing.Point location = this.Controls[this.Controls.Count - 1].Location;
     myReadingEditor.Dock         = DockStyle.Fill;
     myReadingEditor.Visible      = false;
     myNoSelectionLabel           = new Label();
     myNoSelectionLabel.TextAlign = System.Drawing.ContentAlignment.MiddleCenter;
     myNoSelectionLabel.Text      = ResourceStrings.ModelReadingEditorUnsupportedSelectionText;
     this.Controls.Add(myNoSelectionLabel);
     myNoSelectionLabel.Dock    = DockStyle.Fill;
     myNoSelectionLabel.Visible = true;
 }
示例#3
0
        /// <summary>
        /// Provides a first chance to handle any command that MSOLE.IOleCommandTarget.QueryStatus
        /// informed the shell to pass to this window. Implements IOleCommandTarget.Exec
        /// </summary>
        protected int Exec(ref Guid pguidCmdGroup, uint nCmdID, uint nCmdexecopt, IntPtr pvaIn, IntPtr pvaOut)
        {
            int  hr      = 0;
            bool handled = true;

            // Only handle commands from the Office 97 Command Set (aka VSStandardCommandSet97).
            if (pguidCmdGroup == VSConstants.GUID_VSStandardCommandSet97)
            {
                ReadingsViewForm   form   = myForm;
                ReadingEditor      editor = form.ReadingEditor;
                ReadingRichTextBox activeRichTextEditor = myActiveInlineEditor as ReadingRichTextBox;
                // Default to a not-supported status.
                switch ((VSConstants.VSStd97CmdID)nCmdID)
                {
                case VSConstants.VSStd97CmdID.Cut:
                    if (activeRichTextEditor != null)
                    {
                        activeRichTextEditor.Cut();
                        hr = VSConstants.S_OK;
                    }
                    else
                    {
                        goto default;
                    }
                    break;

                case VSConstants.VSStd97CmdID.Copy:
                    if (activeRichTextEditor != null)
                    {
                        activeRichTextEditor.Copy();
                        hr = VSConstants.S_OK;
                    }
                    else
                    {
                        goto default;
                    }
                    break;

                case VSConstants.VSStd97CmdID.Paste:
                    if (activeRichTextEditor != null)
                    {
                        activeRichTextEditor.Paste();
                        hr = VSConstants.S_OK;
                    }
                    else
                    {
                        goto default;
                    }
                    break;

                case VSConstants.VSStd97CmdID.SelectAll:
                    if (activeRichTextEditor != null)
                    {
                        activeRichTextEditor.SelectAll();
                        hr = VSConstants.S_OK;
                    }
                    else
                    {
                        goto default;
                    }
                    break;

                case VSConstants.VSStd97CmdID.Undo:
                    if (activeRichTextEditor != null)
                    {
                        activeRichTextEditor.Undo();
                        hr = VSConstants.S_OK;
                    }
                    else
                    {
                        goto default;
                    }
                    break;

                case VSConstants.VSStd97CmdID.Delete:
                    // If we aren't in label edit (in which case the commands should be passed down to the
                    // VirtualTreeView control), handle the delete command and set the hresult to a handled status.
                    if (!editor.EditingFactType.IsEmpty)
                    {
                        if (!editor.InLabelEdit)
                        {
                            if (editor.IsReadingPaneActive && editor.CurrentReading != null)
                            {
                                editor.OnMenuDeleteSelectedReading();
                            }
                        }
                        else
                        {
                            Control editControl = editor.LabelEditControl;
                            if (editControl != null)
                            {
                                HandleRef editHandle = new HandleRef(editControl, editControl.Handle);
                                // WM_KEYDOWN == 0x100
                                SendMessage(editHandle, 0x100, (int)Keys.Delete, 1);
                                // WM_KEYUP == 0x101
                                SendMessage(editHandle, 0x101, (int)Keys.Delete, 0x40000001);
                            }
                        }
                        // We enabled the command, so we say we handled it regardless of the further conditions
                        hr = VSConstants.S_OK;
                    }
                    else
                    {
                        goto default;
                    }
                    break;

                case VSConstants.VSStd97CmdID.EditLabel:
                    // If we aren't in label edit (in which case the commands should be passed down to the
                    // VirtualTreeView control), handle the edit command and set the hresult to a handled status.
                    if (!editor.EditingFactType.IsEmpty)
                    {
                        if (!editor.InLabelEdit)
                        {
                            if (editor.IsReadingPaneActive)
                            {
                                editor.EditSelection();
                            }
                        }
                        else
                        {
                            Control editControl = editor.LabelEditControl;
                            if (editControl != null)
                            {
                                HandleRef editHandle = new HandleRef(editControl, editControl.Handle);
                                // WM_KEYDOWN == 0x100
                                SendMessage(editHandle, 0x100, (int)Keys.F2, 1);
                                // WM_KEYUP == 0x101
                                SendMessage(editHandle, 0x101, (int)Keys.F2, 0x40000001);
                            }
                        }
                    }
                    // We enabled the command, so we say we handled it regardless of the further conditions
                    hr = VSConstants.S_OK;
                    break;

                default:
                    // If the command is from our command set, but not explicitly handled, inform the shell
                    // that we didn't handle the command.
                    handled = false;
                    hr      = (int)MSOLE.Constants.OLECMDERR_E_NOTSUPPORTED;
                    break;
                }
            }
            // The command is from an unknown group.
            else
            {
                handled = false;
                hr      = (int)MSOLE.Constants.OLECMDERR_E_UNKNOWNGROUP;
            }
            if (!handled)
            {
                Debug.Assert(ErrorHandler.Failed(hr));
                ModelingDocData docData = CurrentDocument;
                Microsoft.VisualStudio.Modeling.Shell.UndoManager undoManager;
                MSOLE.IOleCommandTarget forwardTo;
                if ((docData != null &&
                     null != (undoManager = docData.UndoManager) &&
                     null != (forwardTo = undoManager.VSUndoManager as MSOLE.IOleCommandTarget)) ||
                    null != (forwardTo = GetService(typeof(MSOLE.IOleCommandTarget)) as MSOLE.IOleCommandTarget))
                {
                    // If the command wasn't handled already, give the undo manager a chance to handle the command.
                    hr = forwardTo.Exec(ref pguidCmdGroup, nCmdID, nCmdexecopt, pvaIn, pvaOut);
                }
            }
            return(hr);
        }
示例#4
0
			public ReadingsViewForm(ORMReadingEditorToolWindow toolWindow)
			{
				myReadingEditor = new ReadingEditor(toolWindow);
				this.Controls.Add(myReadingEditor);
				System.Drawing.Point location = this.Controls[this.Controls.Count - 1].Location;
				myReadingEditor.Dock = DockStyle.Fill;
				myReadingEditor.Visible = false;
				myNoSelectionLabel = new Label();
				myNoSelectionLabel.TextAlign = System.Drawing.ContentAlignment.MiddleCenter;
				myNoSelectionLabel.Text = ResourceStrings.ModelReadingEditorUnsupportedSelectionText;
				this.Controls.Add(myNoSelectionLabel);
				myNoSelectionLabel.Dock = DockStyle.Fill;
				myNoSelectionLabel.Visible = true;
			}