This event argument class is used to handle right clicks in SimpleRootSite objects. If someone handles the event, then they should set EventHandled to true, so the regular mouse processing is skipped.
		void InterlinDocForAnalysis_RightMouseClickedEvent(SimpleRootSite sender, FwRightMouseClickEventArgs e)
		{
			e.EventHandled = true;
			// for the moment we always claim to have handled it.
			ContextMenuStrip menu = new ContextMenuStrip();

			// Add spelling items if any (i.e., if we clicked a squiggle word).
			int hvoObj, tagAnchor;
			if (GetTagAndObjForOnePropSelection(e.Selection, out hvoObj, out tagAnchor) &&
				(tagAnchor == SegmentTags.kflidFreeTranslation || tagAnchor == SegmentTags.kflidLiteralTranslation ||
				tagAnchor == NoteTags.kflidContent))
			{
				var helper = new SpellCheckHelper(Cache);
				helper.MakeSpellCheckMenuOptions(e.MouseLocation, this, menu);
			}

			int hvoNote;
			if (CanDeleteNote(e.Selection, out hvoNote))
			{
				if (menu.Items.Count > 0)
				{
					menu.Items.Add(new ToolStripSeparator());
				}
				// Add the delete item.
				string sMenuText = ITextStrings.ksDeleteNote;
				ToolStripMenuItem item = new ToolStripMenuItem(sMenuText);
				item.Click += OnDeleteNote;
				menu.Items.Add(item);
			}
			if (menu.Items.Count > 0)
			{
				e.Selection.Install();
				menu.Show(this, e.MouseLocation);
			}
		}
Esempio n. 2
0
		void HandleRightMouseClickedEvent(SimpleRootSite sender, FwRightMouseClickEventArgs e)
		{
			string sMenu = XmlUtils.GetOptionalAttributeValue(this.ConfigurationNode, "contextMenu");
			if (String.IsNullOrEmpty(sMenu))
				return;
			e.EventHandled = true;
			e.Selection.Install();
			XWindow xwind = (XWindow)this.Mediator.PropertyTable.GetValue("window");
			xwind.ShowContextMenu(sMenu, new Point(Cursor.Position.X, Cursor.Position.Y), null, null);
		}
			private void ReversalIndexEntrySliceView_RightMouseClickedEvent(SimpleRootSite sender,
				FwRightMouseClickEventArgs e)
			{
				e.EventHandled = true;
				e.Selection.Install();
				ContextMenuStrip menu = new ContextMenuStrip();
				string sMenuText = LexEdStrings.ksShowInReversalIndex;
				ToolStripMenuItem item = new ToolStripMenuItem(sMenuText);
				item.Click += new EventHandler(OnShowInReversalIndex);
				menu.Items.Add(item);
				menu.Show(this, e.MouseLocation);
			}
Esempio n. 4
0
		/// <summary>
		/// The user has chosen a keyboard combination which requests a context menu.
		/// Handle it, given the active selection and a point around the center of it.
		/// </summary>
		protected virtual bool HandleContextMenuFromKeyboard(IVwSelection vwsel, Point center)
		{
			if (RightMouseClickedEvent != null)
			{
				FwRightMouseClickEventArgs args = new FwRightMouseClickEventArgs(center, vwsel);
				RightMouseClickedEvent(this, args);
				if (args.EventHandled)
					return true;
			}
			return false;
		}
Esempio n. 5
0
		/// -----------------------------------------------------------------------------------
		/// <summary>
		/// Process right mouse button up (typically show a context menu).
		/// Was mouse Down in an earlier life, but we concluded that the usual convention
		/// is context menu on mouse up. There may be vestiges.
		/// </summary>
		/// <param name="pt"></param>
		/// <param name="rcSrcRoot"></param>
		/// <param name="rcDstRoot"></param>
		/// <returns>true if handled, false otherwise</returns>
		/// -----------------------------------------------------------------------------------
		protected virtual bool OnRightMouseUp(Point pt, Rectangle rcSrcRoot,
			Rectangle rcDstRoot)
		{
			IVwSelection invSel = null;
			try
			{
				// Make an invisible selection to see if we are in editable text, also it may
				// be useful to DoContextMenu.
				invSel = m_rootb.MakeSelAt(pt.X, pt.Y, rcSrcRoot, rcDstRoot, false);
				// Notify any delegates.
				if (RightMouseClickedEvent != null)
				{
					if (invSel != null)
					{
						FwRightMouseClickEventArgs args = new FwRightMouseClickEventArgs(pt, invSel);
						RightMouseClickedEvent(this, args);
						if (args.EventHandled)
							return true;
					}
				}
			}
			catch
			{
			}

			if (DataUpdateMonitor.IsUpdateInProgress())
				return true; //discard this event
			if (IsFollowLinkMsgPending)
			{
				// REVIEW (TimS): This uninit graphics doesn't appear to be needed... is there
				// a reason it was put in? It could cause problems because we init the graphics
				// outside of this method and have no idea what might happen if this method and
				// the method that calls this method both uninit the graphics object. Although
				// no known problems have been seen, it was commented out.
				//UninitGraphics();
				return true; //discard this event
			}

			return DoContextMenu(invSel, pt, rcSrcRoot, rcDstRoot);
		}
Esempio n. 6
0
		/// <summary>
		/// We got a right click event. Bring up the appropriate menu if any.
		/// </summary>
		/// <param name="sender"></param>
		/// <param name="e"></param>
		private void InterlinDocChild_RightMouseClickedEvent(SimpleRootSite sender, FwRightMouseClickEventArgs e)
		{
			e.EventHandled = true; // for the moment we always claim to have handled it.
			int hvoAnnotation;
			if (!CanDeleteFF(e.Selection, out hvoAnnotation))
				return;
			e.Selection.Install();
			ContextMenuStrip menu = new ContextMenuStrip();

			// Add spelling items if any (i.e., if we clicked a squiggle word).
			Rectangle rcSrcRoot, rcDstRoot;
			GetCoordRects(out rcSrcRoot, out rcDstRoot);
			EditingHelper.MakeSpellCheckMenuOptions(e.MouseLocation, m_rootb, rcSrcRoot, rcDstRoot, menu);
			if (menu.Items.Count > 0)
			{
				menu.Items.Add(new ToolStripSeparator());
			}

			// Add the delete item.
			// We need to choose the proper menu id for the selected annotation.
			string sMenuText = GetTextForDeleteFreeform(hvoAnnotation);
			ToolStripMenuItem item = new ToolStripMenuItem(sMenuText);
			item.Click += new EventHandler(OnDeleteFreeform);
			menu.Items.Add(item);

			menu.Show(this, e.MouseLocation);

			//// We need to choose the proper menu id for the selected annotation.
			//string sMenuId = "mnuIText-Note";
			//ISilDataAccess sda = Cache.MainCacheAccessor;
			//int hvo = sda.get_ObjectProp(hvoAnnotation,
			//    (int)CmAnnotation.CmAnnotationTags.kflidAnnotationType);
			//// Only one Free Translation annotation and one Literal Translation annotation
			//// is allowed for each segment!
			//if (hvo == m_vc.FtSegmentDefn)
			//    sMenuId = "mnuIText-FreeTrans";
			//if (hvo == m_vc.LtSegmentDefn)
			//    sMenuId = "mnuIText-LitTrans";
			//XCore.XWindow window = (XCore.XWindow)m_mediator.PropertyTable.GetValue("window");
			//Point pt = new Point(e.MouseLocation.X, e.MouseLocation.Y);
			//ClientToScreen(m_rootb, ref pt);
			//window.ShowContextMenu(sMenuId,
			//    pt,
			//    null, // No temporary XCore colleague.
			//    null);
			//    // Using the sequencer here now causes problems.
			//    // If a safe blocking mechanism can be found for the context menu, we can restore the original behavior
			//    // which will have this code do the setup and teardown work.
			//    //(this as IReceiveSequentialMessages).Sequencer);
		}
Esempio n. 7
0
		public void OnFwRightMouseClick(SimpleRootSite sender, FwRightMouseClickEventArgs e)
		{
			CheckDisposed();

			XmlBrowseView browseView = sender as XmlBrowseView;
			if (browseView != null)
			{
				IVwSelection sel = e.Selection;
				int clev = sel.CLevels(false); // anchor
				int hvoRoot, tag, ihvo, cpropPrevious;
				IVwPropertyStore vps;
				sel.PropInfo(false, clev - 1, out hvoRoot, out tag, out ihvo, out cpropPrevious, out vps);
				// First make the selection so it will be highlighted before the context menu popup.
				if (browseView.SelectedIndex != ihvo) // No sense in waking up the beast for no reason.
					browseView.SelectedIndex = ihvo;
				int hvo = browseView.HvoAt(ihvo);
				CmObjectUi ui = CmObjectUi.MakeUi(Cache, hvo);
				if (ui != null)
					e.EventHandled = ui.HandleRightClick(m_mediator, sender, true, "mnuBrowseView");
			}
		}