예제 #1
0
        public override void Detach(DriverWidget child)
        {
            WinFormsMenuItem mi = child as WinFormsMenuItem;

            if (mi == null)
            {
                throw new Exception("Trying to detach invalid object to popup menu:" + child.ToString());
            }

            var item = child.NativeObject as System.Windows.Forms.ToolStripItem;

            strip.Items.Remove(item);
        }
예제 #2
0
        /*public override MenuItem Add(string caption, Image image, MenuFlags flags)
         * {
         *  System.Windows.Forms.ToolStripItem item=null;
         *  if ((flags & MenuFlags.Separator) != 0)
         *      item = new System.Windows.Forms.ToolStripSeparator();
         *  else
         *  {
         *      System.Windows.Forms.ToolStripMenuItem mi = new System.Windows.Forms.ToolStripMenuItem();
         *      item = mi;
         *      mi.Image = WinFormsDriver.ImageToWinFormsImage(image);
         *      mi.ImageScaling = System.Windows.Forms.ToolStripItemImageScaling.None;
         *
         *      //parse shortkey text
         *      if (caption == null) caption = "";
         *      string[] capts=caption.Split('\t');
         *      if(capts.Length>0)
         *          mi.Text = capts[0];
         *      if (capts.Length > 1)
         *          mi.ShortcutKeyDisplayString = capts[1];
         *
         *      if ((flags & MenuFlags.Checkable) != 0)
         *      {
         *          mi.CheckOnClick = true;
         *          mi.CheckState = (((flags & MenuFlags.Checked) != 0) ? System.Windows.Forms.CheckState.Checked : System.Windows.Forms.CheckState.Unchecked);
         *      }
         *
         *      strip.Items.Add(mi);
         *  }
         *
         *  return new MenuItem(item, caption, image, flags);
         * }*/



        public override void Append(DriverWidget dw)
        {
            WinFormsMenuItem mi = dw as WinFormsMenuItem;

            if (mi == null)
            {
                throw new Exception("Trying to append invalid object to popup menu:" + dw.ToString());
            }

            var item = dw.NativeObject as System.Windows.Forms.ToolStripItem;



            strip.Items.Add(item);
        }
예제 #3
0
        public override void Append(DriverWidget dw)
        {
            WinFormsMenuItem mi = dw as WinFormsMenuItem;

            if (mi == null)
            {
                throw new Exception("Trying to append invalid object to popup menu:" + dw.ToString());
            }

            var child = dw.NativeObject as System.Windows.Forms.ToolStripItem;
            var par   = item as System.Windows.Forms.ToolStripMenuItem;

            if (item != null && par != null)
            {
                par.DropDownItems.Add(child);
            }
        }