protected override void OnMouseDown(MouseEventArgs e) { base.OnMouseDown(e); if (_readOnly) { return; } hideSelectorList(); int x = e.X; int y = e.Y; int nh = 1; float yOffset = 0; float xOffset = this.AutoScrollPosition.X; SizeF size = mathExp.ExpSize; if (size.Height > 0) { while (y > (nh * (size.Height + 8))) { yOffset += (size.Height + 8); xOffset -= this.ClientSize.Width; nh++; } y -= (int)yOffset; x -= (int)xOffset; } MathNode hit = mathExp.HitTest(new PointF(x, y)); if (hit != null) { mathExp.SetFocus(hit); } else { mathExp.SetFocus(null); } this.Refresh(); if (e.Button == MouseButtons.Right) { MathNode selectedNode = Root.FocusedNode; ContextMenu cm = new ContextMenu(); MenuItem mi; BinOperatorNode bin = selectedNode as BinOperatorNode; if (bin != null) { BinOperatorNode bin2 = bin[1] as BinOperatorNode; if (bin2 != null) { //modify it from {0} b {b2} to //{0} b {b2[0]} b2 {b2[1]} //new b[1] = {b2[0]} //new b2[0] = new b => {0} b {b2[0]} //new b2[1] = {b2[1]} mi = new MenuItemWithBitmap("Separate", mnu_separate, Resource1._separate.ToBitmap()); cm.MenuItems.Add(mi); } } if (OnFinish != null) { if (cm.MenuItems.Count > 0) { cm.MenuItems.Add("-"); } mi = new MenuItemWithBitmap("Finish", OnFinish, Resource1._ok.ToBitmap()); cm.MenuItems.Add(mi); } if (OnCancel != null) { mi = new MenuItemWithBitmap("Cancel", OnCancel, Resource1._cancel.ToBitmap()); cm.MenuItems.Add(mi); } if (OnCreateCompound != null) { } // if (cm.MenuItems.Count > 0) { cm.Show(this, new Point(e.X, e.Y)); } } }