Ejemplo n.º 1
0
        public void RegisterItem(ToolStripPath path, IToolStripItemCodon toolStripItem)
        {
            ToolStripItem view = (ToolStripItem)toolStripItem.View;

            if (path.PathPoints.Count == 1)
            {
                if (path.PathPoints[0].Index.HasValue)
                {
                    int index = path.PathPoints[0].Index.Value;
                    if (index >= this.Items.Count)
                    {
                        index = this.Items.Count;
                    }
                    this.Items.Insert(index, view);
                }
                else
                {
                    this.Items.Add(view);
                }
            }
            else
            {
                ToolStripMenuItemView   targetItem           = null;
                ToolStripItemCollection targetItemCollection = this.Items;
                for (int i = 1; i < path.PathPoints.Count; i++)
                {
                    foreach (ToolStripMenuItemView targetItemDoozer in targetItemCollection)
                    {
                        IToolStripItemView doozer = targetItemDoozer as IToolStripItemView;
                        if (doozer == null)
                        {
                            continue;
                        }
                        if (doozer.Codon.PathPoint == path.PathPoints[i].Name)
                        {
                            targetItem           = targetItemDoozer;
                            targetItemCollection = targetItemDoozer.DropDownItems;
                            break;
                        }
                    }
                }
                if (targetItem != null)
                {
                    if (path.PathPoints[path.PathPoints.Count - 1].Index.HasValue)
                    {
                        int index = path.PathPoints[path.PathPoints.Count - 1].Index.Value;
                        if (index >= targetItem.DropDownItems.Count)
                        {
                            index = targetItem.DropDownItems.Count;
                        }
                        targetItem.DropDownItems.Insert(index, view);
                    }
                    else
                    {
                        targetItem.DropDownItems.Add(view);
                    }
                }
            }
        }
        public void RegisterItem(ToolStripPath path, IToolStripItemCodon toolStripItem)
        {
            ToolStripView toolStrip = this.GetToolStrip(path.PathPoints[0].Name);

            if (toolStrip == null && path.PathPoints.Count == 1)
            {
                toolStrip = this.CreateToolStrip(path.PathPoints[0].Name);
            }
            toolStrip.RegisterItem(path.Cut(0), toolStripItem);
        }
        public void RegisterItem(string path, IToolStripItemCodon item)
        {
            if (String.IsNullOrEmpty(path) || item == null)
            {
                Debug.Assert(false, "RegisterToolStripItem,没有指定path或toolStripItem");
                return;
            }
            ToolStripPath toolStripPath = new ToolStripPath(path);

            if (toolStripPath.IsEmpty)
            {
                Debug.Assert(false, "RegisterToolStripItem,toolStripPath.IsEmpty");
                return;
            }
            IToolStripDropDownItemCodon  targetItem           = null;
            ToolStripItemCodonCollection targetItemCollection = this;

            for (int i = 0; i < toolStripPath.PathPoints.Count; i++)
            {
                foreach (IToolStripItemCodon targetItemCodon in targetItemCollection)
                {
                    if (targetItemCodon.PathPoint == toolStripPath.PathPoints[i].Name &&
                        targetItemCodon is IToolStripDropDownItemCodon)
                    {
                        targetItem           = targetItemCodon as IToolStripDropDownItemCodon;
                        targetItemCollection = targetItem.Items;
                        break;
                    }
                }
            }
            if (targetItem != null)
            {
                if (toolStripPath.PathPoints[toolStripPath.PathPoints.Count - 1].Index.HasValue)
                {
                    int index = toolStripPath.PathPoints[toolStripPath.PathPoints.Count - 1].Index.Value;
                    if (index >= targetItem.Items.Count)
                    {
                        index = targetItem.Items.Count;
                    }
                    targetItem.Items.Insert(index, item);
                }
                else
                {
                    targetItem.Items.Add(item);
                }
            }
        }
Ejemplo n.º 4
0
        public void RegisterItem(ToolStripPath path, IToolStripItemCodon toolStripItem)
        {
            if (path.PathPoints.Count > 1)
            {
                throw new NotImplementedException("工具栏暂不支持多级注册项");
            }
            toolStripItem.Owner = this.Codon;
            ToolStripMenuItemView item = toolStripItem.View as ToolStripMenuItemView;

            if (path.PathPoints[0].Index.HasValue)
            {
                this.Items.Insert(path.PathPoints[0].Index.Value, item);
            }
            else
            {
                this.Items.Add(item);
            }
        }
 public static void Update(System.Windows.Forms.ToolStripItem toolStripItem, IToolStripItemCodon codon)
 {
     if (toolStripItem == null || codon == null)
     {
         Debug.Assert(false, "ToolStripItemDoozerHelper.Update , toolStripItem或codon为null");
         return;
     }
     toolStripItem.Text         = codon.Text;
     toolStripItem.Image        = codon.Image;
     toolStripItem.Alignment    = codon.Alignment;
     toolStripItem.AutoSize     = codon.AutoSize;
     toolStripItem.AutoToolTip  = codon.AutoToolTip;
     toolStripItem.Available    = codon.Available;
     toolStripItem.DisplayStyle = codon.DisplayStyle;
     if (codon.Width.HasValue)
     {
         toolStripItem.Width = codon.Width.Value;
     }
 }
 public int IndexOf(IToolStripItemCodon value)
 {
     return(List.IndexOf(value));
 }
Ejemplo n.º 7
0
 public ItemRegisterEventArgs(ToolStripPath path, IToolStripItemCodon codon, ToolStripItem item)
 {
     Path  = path;
     Codon = codon;
     Item  = item;
 }
 public void RegisterItem(string path, IToolStripItemCodon toolStripItem)
 {
     RegisterItem(new ToolStripPath(path), toolStripItem);
 }
Ejemplo n.º 9
0
 public void RegisterToolStrip(string path, IToolStripItemCodon toolStripItem)
 {
     this._toolStripPanel.RegisterItem(path, toolStripItem);
 }
Ejemplo n.º 10
0
 public void RegisterToolStrip(string path, IToolStripItemCodon toolStripItem)
 {
     _shellView.RegisterToolStrip(path, toolStripItem);
 }
 public virtual void Remove(IToolStripItemCodon value)
 {
     List.Remove(value);
 }
Ejemplo n.º 12
0
 public void RegisterMenu(string path, IToolStripItemCodon toolStripItem)
 {
     this._menuStrip.RegisterItem(path, toolStripItem);
 }
 public void Insert(int index, IToolStripItemCodon value)
 {
     value.Owner = Owner;
     List.Insert(index, value);
 }
 public ToolStripComboBoxCodonSelectedItemChangedEventArgs(IToolStripItemCodon codon) :
     base(codon)
 {
 }
 public bool Contains(IToolStripItemCodon value)
 {
     return(List.Contains(value));
 }
 public virtual int Add(IToolStripItemCodon value)
 {
     value.Owner = this.Owner;
     return(List.Add(value));
 }
Ejemplo n.º 17
0
 public ToolStripItemCodonEventArgs(IToolStripItemCodon codon)
 {
     Codon = codon;
 }