示例#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 static void UpdateStatus(System.Windows.Forms.ToolStripItem toolStripItem)
        {
            IToolStripItemView view = toolStripItem as IToolStripItemView;

            if (view == null)
            {
                return;
            }
            toolStripItem.Visible = view.Codon.Visible;
            toolStripItem.Enabled = view.Codon.Enabled;
            toolStripItem.Text    = view.Codon.Text;
        }
示例#3
0
 private void CreateView()
 {
     _view       = Activator.CreateInstance <TView>();
     _view.Codon = this;
 }