コード例 #1
0
        public static ToolStripItem GetNextItem(this ToolStripItem item)
        {
            var i = item.GetIndex() + 1;
            var c = item.GetCurrentParent().Items.Count;

            return(i >= c ? null : item.GetCurrentParent().Items[i]);
        }
コード例 #2
0
        protected override void InitializeItem(ToolStripItem item)
        {
            base.InitializeItem(item);

            if (item is ToolStripButton)
            {
                item.MouseEnter += (object sender, System.EventArgs e) => { item.GetCurrentParent().Cursor = Cursors.Hand; };
                item.MouseLeave += (object sender, System.EventArgs e) => { item.GetCurrentParent().Cursor = Cursors.Default; };
            }
        }
コード例 #3
0
ファイル: Extension.cs プロジェクト: brozuni9/GIT
        public static ContextMenuStrip GetContextMenuStrip(this ToolStripItem item)
        {
            ToolStripItem itemCheck = item;

            while (!(itemCheck.GetCurrentParent() is ContextMenuStrip) && itemCheck.GetCurrentParent() is ToolStripDropDown)
            {
                itemCheck = (itemCheck.GetCurrentParent() as ToolStripDropDown).OwnerItem;
            }

            return(itemCheck.GetCurrentParent() as ContextMenuStrip);
        }
コード例 #4
0
 private void SetToolStripItemText(ToolStripItem toolStripItem, string text)
 {
     if (toolStripItem.GetCurrentParent().InvokeRequired)
     {
         toolStripItem.GetCurrentParent().Invoke(new Action <ToolStripItem, string>(SetToolStripItemText), new object[] { toolStripItem, text });
     }
     else
     {
         toolStripItem.Text = text;
     }
 }
コード例 #5
0
 public static void SetStatusLabel(ToolStripItem _label, string Text)
 {
     if (_label.GetCurrentParent().InvokeRequired)
     {
         _label.GetCurrentParent().Invoke(new MethodInvoker(delegate
         {
             _label.Text = Text;
         }));
     }
     else
     {
         _label.Text = Text;
     }
 }
コード例 #6
0
ファイル: ToolTip.cs プロジェクト: orf53975/src
        // Event attached to System.Windows.Forms.ToolStripItem object.
        private void tsiMouseEnter(object sender, EventArgs e)
        {
            ToolStripItem anItem = (ToolStripItem)sender;

            _control = anItem.GetCurrentParent();
            switch (_location)
            {
            case ToolTipLocation.Auto:
                Rectangle itemRect = new Rectangle(anItem.Bounds.X, 0, anItem.Bounds.Width, _control.Height - 2);
                show(_control, itemRect);
                break;

            case ToolTipLocation.MousePointer:
                show(_control);
                break;

            case ToolTipLocation.CustomClient:
                show(_control, _customLocation);
                break;

            case ToolTipLocation.CustomScreen:
                Point clientLocation = _control.PointToClient(_customLocation);
                show(_control, clientLocation);
                break;
            }
        }
コード例 #7
0
        //

        void ScreenMenuClick(object sender, EventArgs e)
        {
            if (!formOpen)
            {
                ToolStripItem screen_item = (ToolStripItem)sender;
                OpenNewScreen(Convert.ToInt32(screen_item.Tag));

                MenuStrip strip = screen_item.GetCurrentParent() as MenuStrip;

            }
            else
            {
                DialogResult result = MessageBox.Show("Only one window supported - do you want to close it?", "Window already open", MessageBoxButtons.OKCancel);
                if (result == DialogResult.OK)
                {
                    form3.Close();

                    ToolStripItem screen_item = (ToolStripItem)sender;
                    OpenNewScreen(Convert.ToInt32(screen_item.Tag));

                    MenuStrip strip = screen_item.GetCurrentParent() as MenuStrip;
                }

            }
        }
コード例 #8
0
        private void ReadOnly(ToolStripItem item)
        {
            Sessions.Session defaultInstance = Session.DefaultInstance;
            if (item == null || defaultInstance == null)
            {
                return;
            }

            GVItem gvItem = ((item.GetCurrentParent() as ContextMenuStrip).SourceControl as GridView).SelectedItems.FirstOrDefault <GVItem>();

            if (gvItem == null)
            {
                return;
            }

            string guid = (gvItem.Tag as PipelineInfo).GUID;

            if (string.IsNullOrEmpty(guid))
            {
                return;
            }

            if (MessageBox.Show(FormWrapper.EncompassForm, "You only have read-only access to this loan file. You won't be able to save any changes. Do you still want to open this loan?", "Read Only", MessageBoxButtons.YesNo, MessageBoxIcon.Asterisk) == DialogResult.Yes)
            {
                defaultInstance.Application.GetService <ILoanConsole>().OpenLoan(guid, LoanInfo.LockReason.NotLocked, true);
            }
        }
コード例 #9
0
        // Returns true if oldSelection and newSelection have a commonParent.
        private bool CommonParent(ToolStripItem oldSelection, ToolStripItem newSelection)
        {
            ToolStrip oldSelectionParent = oldSelection.GetCurrentParent();
            ToolStrip newSelectionParent = newSelection.GetCurrentParent();

            return(oldSelectionParent == newSelectionParent);
        }
コード例 #10
0
        private bool CommonParent(ToolStripItem oldSelection, ToolStripItem newSelection)
        {
            ToolStrip currentParent = oldSelection.GetCurrentParent();
            ToolStrip strip2        = newSelection.GetCurrentParent();

            return(currentParent == strip2);
        }
コード例 #11
0
        private void ShowColumnType(object sender, EventArgs e)
        {
            ToolStripItem    _sitm = (ToolStripItem)sender;
            ContextMenuStrip _mstp = (ContextMenuStrip)_sitm.GetCurrentParent();
            int _rowIND            = Convert.ToInt32(_mstp.Name.Replace("sagtus_", ""));

            Dg_FieldList[5, _rowIND].Value = _sitm.Text;
        }
コード例 #12
0
        internal static void UpdateToolstripImage(ToolStripItem item, string name)
        {
            int    size;
            string set;

            GetToolstripSizeAndSet(item.GetCurrentParent(), out size, out set);
            UpdateToolstripImage(item, name, size, set);
        }
コード例 #13
0
        private void zoomAufTagToolStripMenuItem_Click(object sender, EventArgs e)
        {
            ToolStripItem menuItem = sender as ToolStripItem;
            var           parent   = menuItem.GetCurrentParent();
            var           args     = new ContextMenuItemClickedEventArgs((TreeNodeTagObject)parent.Tag);

            InvokeZoomToTag(args);
        }
コード例 #14
0
        private void konfigurationToolStripMenuItem_Click(object sender, EventArgs e)
        {
            ToolStripItem menuItem = sender as ToolStripItem;
            var           parent   = menuItem.GetCurrentParent();
            var           args     = new ContextMenuItemClickedEventArgs((TreeNodeTagObject)parent.Tag);

            InvokeShowTagConfig(args);
        }
コード例 #15
0
ファイル: Form1.cs プロジェクト: SnowCat6/GPIOReadGraph
        void cellMenu_ItemClicked(object sender, EventArgs e)
        {
            ToolStripItem    item = sender as ToolStripItem;
            ContextMenuStrip menu = item.GetCurrentParent() as ContextMenuStrip;

            // your code here
            m_GPIO_color[(string)menu.Tag] = (Color)item.Tag;
            m_GPIO_DataTable.Invalidate();
        }
コード例 #16
0
ファイル: misc.cs プロジェクト: psryland/rylogic_code
        public static void ShowHint(ToolStripItem item, string caption, int duration = 5000)
        {
            var parent = item.GetCurrentParent();

            if (parent == null)
            {
                return;
            }
            ShowHint(parent, caption, item.Bounds.Centre(), duration);
        }
コード例 #17
0
ファイル: misc.cs プロジェクト: psryland/rylogic_code
        public static void ShowHint(ToolStripItem item, string caption, Point offset, int duration = 5000)
        {
            var parent = item.GetCurrentParent();

            if (parent == null)
            {
                return;
            }
            ShowHint(parent, caption, offset, duration);
        }
コード例 #18
0
ファイル: Form1.cs プロジェクト: SnowCat6/GPIOReadGraph
        void cellMenu_ItemModeClicked(object sender, EventArgs e)
        {
            ToolStripItem    item = sender as ToolStripItem;
            ContextMenuStrip menu = item.GetCurrentParent() as ContextMenuStrip;

            int     nRowIndex = m_GPIO_DataTable.CurrentRow.Index;
            gpioPin pin       = getRowPin(nRowIndex);

            String[] mode = (string[])item.Tag;

            setPinValue(pin, pin.getPinIndex(mode[0]), int.Parse(mode[1]));
        }
コード例 #19
0
        void UICommand_Click(object sender, EventArgs e)
        {
            ToolStripButton   pTempBtn      = sender as ToolStripButton;
            ToolStripMenuItem pTempMenuItem = sender as ToolStripMenuItem;
            ToolStripItem     pItem         = pTempBtn;

            if (null == pTempBtn)
            {
                pItem = pTempMenuItem;
            }
            if (null == pItem)
            {
                return;
            }
            string strKey = pItem.AccessibleName;

            //当前Command被按下时,CurrentTool设置为null
            //MapControl和PageLayoutControl的也设置为null
            _App.CurrentTool                   = null;
            _App.MapControl.CurrentTool        = null;
            _App.PageLayoutControl.CurrentTool = null;
            //一切在Command被按下前未完成的Tool操作都可能使Tool的Checked为true
            //此项必须设置为False
            //遍历所有的Command,设置每一个Command的选择状态为False
            ToolStripButton UICmd = null;

            foreach (var item in pItem.GetCurrentParent().Items)
            {
                UICmd = item as ToolStripButton;
                if (null == UICmd)
                {
                    continue;
                }
                UICmd.Checked = false;
            }
            NBGIS.PluginEngine.ICommand cmd = _CommandCol[strKey];
            ////在状态栏显示插件信息
            this.toolStripStatusLabel1.Text = cmd.Message;
            if (null != pTempBtn)
            {
                pTempBtn.Checked = true;
            }
            //((ToolStripButton)sender).Checked = true;
            //设置Map控件的鼠标
            axMapControl.MousePointer = esriControlsMousePointer.esriPointerDefault;
            cmd.OnClick();
            //((ToolStripButton)sender).Checked = false;
            if (null != pTempBtn)
            {
                pTempBtn.Checked = false;
            }
        }
コード例 #20
0
        public void InvokeIfRequired(MethodInvoker del)
        {
            var toolStrip = ToolStripItem.GetCurrentParent();

            if (toolStrip != null && toolStrip.InvokeRequired)
            {
                toolStrip.BeginInvoke(del, new object[0]);
            }
            else
            {
                del();
            }
        }
コード例 #21
0
ファイル: Form2.cs プロジェクト: JorisBosma/TestProject
        private void btnVerwijderen_Click(object sender, EventArgs e)
        {
            //set sender as toolstrip item to make properties accessable
            ToolStripItem button = sender as ToolStripItem;
            //then ask for the parent and put it in pbutton
            ContextMenuStrip pbutton = (ContextMenuStrip)button.GetCurrentParent();
            //then put the parent's tag into treeview
            TreeView   treeView     = (TreeView)pbutton.Tag;
            MyTreeNode selectedNode = (MyTreeNode)treeView.SelectedNode;
            MyTreeNode pNode        = (MyTreeNode)selectedNode.Parent;

            pNode.nNode.RemoveNode(selectedNode.nNode);
            selectedNode.Remove();
        }
コード例 #22
0
ファイル: Form1.cs プロジェクト: JorisBosma/TestProject
        private void propertiesToolStripMenuItem_Click(object sender, EventArgs e)
        {
            //set sender as toolstrip item to make properties accessable
            ToolStripItem button = sender as ToolStripItem;
            //then ask for the parent and put it in pbutton
            ContextMenuStrip pbutton = (ContextMenuStrip)button.GetCurrentParent();
            //then put the parent's tag into treeview
            TreeView   treeView     = (TreeView)pbutton.Tag;
            MyTreeNode selectedNode = (MyTreeNode)treeView.SelectedNode;
            //Open new form and give the (new) parent node
            Form propForm = new PropertyForm(selectedNode);

            propForm.Show();
        }
コード例 #23
0
ファイル: MonoToolStripHelper.cs プロジェクト: zrnzrn50/Mesen
        public static void DropdownOpening(object sender, EventArgs e)
        {
            ToolStripDropDownItem ddItem = (ToolStripDropDownItem)sender;

            if (!ddItem.GetCurrentParent().Visible)
            {
                ddItem.DropDown.Close();
                return;
            }

            HashSet <object> parents = new HashSet <object>();

            parents.Add(ddItem.GetCurrentParent());
            ToolStripItem parent = ddItem.OwnerItem;

            if (parent != null)
            {
                parents.Add(parent);
                parents.Add(parent.GetCurrentParent());
                while ((parent = parent.OwnerItem) != null)
                {
                    parents.Add(parent);
                    parents.Add(parent.GetCurrentParent());
                }
            }

            foreach (ToolStripDropDown openedDropdown in _openedDropdowns.ToList())
            {
                //Close all non-parent dropdowns when opening a new dropdown
                if (!parents.Contains(openedDropdown.OwnerItem) && !parents.Contains(openedDropdown))
                {
                    openedDropdown.Close();
                }
            }

            _openedDropdowns.Add(ddItem.DropDown);
        }
コード例 #24
0
        private void DrawSeparatorInternal(Graphics g, ToolStripItem item, bool vertical, Rectangle bounds, Color darkColor)
        {
            if (item is ToolStripSeparator)
            {
                if (vertical)
                {
                    if (!item.IsOnDropDown)
                    {
                        // center so that it matches office
                        bounds.Y     += 1;
                        bounds.Height = Math.Max(0, bounds.Height - 3);
                    }
                }
                else
                {
                    // offset after the image margin
                    if (item.GetCurrentParent() is ToolStripDropDownMenu dropDownMenu)
                    {
                        if (dropDownMenu.RightToLeft == RightToLeft.No)
                        {
                            // scoot over by the padding (that will line you up with the text - but go two PX before so that it visually looks
                            // like the line meets up with the text).
                            bounds.X    += dropDownMenu.Padding.Left - 2;
                            bounds.Width = dropDownMenu.Width - bounds.X;
                        }
                        else
                        {
                            // scoot over by the padding (that will line you up with the text - but go two PX before so that it visually looks
                            // like the line meets up with the text).
                            bounds.X    += 2;
                            bounds.Width = dropDownMenu.Width - bounds.X - dropDownMenu.Padding.Right;
                        }
                    }
                }
            }

            using (Pen foreColorPen = new Pen(darkColor))
            {
                if (vertical)
                {
                    g.DrawLine(foreColorPen, bounds.Width / 2, bounds.Top, bounds.Width / 2, bounds.Bottom - 1);
                }
                else
                {
                    g.DrawLine(foreColorPen, bounds.Left, bounds.Height / 2, bounds.Right - 1, bounds.Height / 2);
                }
            }
        }
コード例 #25
0
        private static void HighlightUndoRedoItems(ToolStripItem activeItem)
        {
            if (!activeItem.Selected)
            {
                return;
            }
            var items = activeItem.GetCurrentParent().Items;
            var index = items.IndexOf(activeItem);

            foreach (ToolStripItem item in items)
            {
                item.BackColor = Color.FromKnownColor(items.IndexOf(item) <= index
                    ? KnownColor.GradientActiveCaption
                    : KnownColor.Control);
            }
        }
コード例 #26
0
        private static void InvertToolStripItem(ToolStripItem item)
        {
            if (item is ToolStripDropDownItem dropDown)
            {
                dropDown.DropDownItems.Cast <ToolStripItem>().ForEach(InvertToolStripItem);
            }

            if (item.Image != null)
            {
                item.Image = InvertImage(new Bitmap(item.Image));
            }
            if (string.IsNullOrWhiteSpace(item.GetCurrentParent().Name))
            {
                InvertColors(item);
            }
        }
コード例 #27
0
 public static ICollection CopyDragObjects(ICollection objects, IServiceProvider svcProvider)
 {
     if ((objects != null) && (svcProvider != null))
     {
         Cursor current = Cursor.Current;
         try
         {
             Cursor.Current = Cursors.WaitCursor;
             ComponentSerializationService service = svcProvider.GetService(typeof(ComponentSerializationService)) as ComponentSerializationService;
             IDesignerHost host = svcProvider.GetService(typeof(IDesignerHost)) as IDesignerHost;
             if ((service != null) && (host != null))
             {
                 SerializationStore store = null;
                 store = service.CreateStore();
                 foreach (IComponent component in GetCopySelection(objects, host))
                 {
                     service.Serialize(store, component);
                 }
                 store.Close();
                 ICollection is2  = service.Deserialize(store);
                 ArrayList   list = new ArrayList(objects.Count);
                 foreach (IComponent component2 in is2)
                 {
                     Control control = component2 as Control;
                     if ((control != null) && (control.Parent == null))
                     {
                         list.Add(component2);
                     }
                     else if (control == null)
                     {
                         ToolStripItem item = component2 as ToolStripItem;
                         if ((item != null) && (item.GetCurrentParent() == null))
                         {
                             list.Add(component2);
                         }
                     }
                 }
                 return(list);
             }
         }
         finally
         {
             Cursor.Current = current;
         }
     }
     return(null);
 }
コード例 #28
0
ファイル: MgMenuHandler.cs プロジェクト: rinavin/RCJS
        /// <summary> This method is activated when a menu was selected. It performs the needed operations in order to
        /// translate the selected menu into the matching operation
        ///
        /// </summary>
        /// <param name="widget">-
        /// the selected menu entry widget
        /// </param>
        private void onSelection(Object sender)
        {
            //Object object_Renamed = widget.getData();
            GuiMenuEntry  guiMenuEntry = null;
            ToolStripItem menuItem     = null;
            ToolStrip     ts;

            menuItem = (ToolStripItem)sender;
            ts       = menuItem.GetCurrentParent();

            guiMenuEntry = ((TagData)menuItem.Tag).guiMenuEntry;

            // when a menu with check style is selected, it is automatically checked.
            // we want to check it only if it should be checked - according to the state.
            if (sender is ToolStripButton)
            {
                ((ToolStripButton)sender).Checked = guiMenuEntry.getChecked();
            }
            else
            {
                ((ToolStripMenuItem)sender).Checked = guiMenuEntry.getChecked();
            }

            Form      form                  = menuObjToForm(sender);
            GuiMgForm activeForm            = null;
            bool      activatedFromMDIFrame = false;

            if (form.IsMdiContainer)
            {
                activatedFromMDIFrame = true;

                Form activeMDIChild = GuiUtils.GetActiveMDIChild(form);
                if (activeMDIChild != null)
                {
                    form = activeMDIChild;
                }
            }

            ControlsMap controlsMap = ControlsMap.getInstance();
            Control     c           = ((TagData)(form.Tag)).ClientPanel;

            activeForm = controlsMap.getControlMapData(c).getForm();

            Events.OnMenuSelection(guiMenuEntry, activeForm, activatedFromMDIFrame);
        }
コード例 #29
0
ファイル: Helper.cs プロジェクト: vaginessa/MagiWOL
        internal static void ScaleToolstripItem(ToolStripItem item, string name)
        {
            var sizeAndSet = GetSizeAndSet(item.GetCurrentParent());
            var size       = sizeAndSet.Key;
            var set        = sizeAndSet.Value;

            var    resources = MagiWol.Properties.Resources.ResourceManager;
            Bitmap bitmap    = resources.GetObject(name + set) as Bitmap;

            item.ImageScaling = ToolStripItemImageScaling.None;
#if DEBUG
            item.Image = (bitmap != null) ? new Bitmap(bitmap, size, size) : new Bitmap(size, size, PixelFormat.Format8bppIndexed);
#else
            if (bitmap != null)
            {
                item.Image = new Bitmap(bitmap, size, size);
            }
#endif
        }
コード例 #30
0
        private Control GetAssociatedControl(Component c)
        {
            if (c is Control)
            {
                return(c as Control);
            }
            if (!(c is ToolStripItem))
            {
                return(null);
            }
            ToolStripItem item          = c as ToolStripItem;
            Control       currentParent = item.GetCurrentParent();

            if (currentParent == null)
            {
                currentParent = item.Owner;
            }
            return(currentParent);
        }
コード例 #31
0
        private bool LooksPressed(ToolStripItem item)
        {
            var parent = item.GetCurrentParent();

            if (parent is MenuStrip)
            {
                return(false);
            }
            if (parent is ContextMenuStrip)
            {
                return(false);
            }
            if (parent is ToolStripDropDown)
            {
                return(false);
            }

            if (item.Pressed)
            {
                return(true);
            }

            {
                var a = item as ToolStripDropDownButton;
                if (a != null && a.IsOnDropDown)
                {
                    return(true);
                }
            }

            {
                var a = item as ToolStripSplitButton;
                if (a != null && a.IsOnDropDown)
                {
                    return(true);
                }
            }

            return(false);
        }