Exemple #1
0
        public string SaveState()
        {
            System.Text.StringBuilder state = new System.Text.StringBuilder(this.m_userItems.Count);
            try
            {
                System.Collections.Generic.List <GH_ValueListItem> .Enumerator enumerator = this.m_userItems.GetEnumerator();
                while (enumerator.MoveNext())
                {
                    GH_ValueListItem item = enumerator.Current;
                    if (item.Selected)
                    {
                        state.Append('Y');
                    }
                    else
                    {
                        state.Append('N');
                    }
                }
            }
            finally
            {
                System.Collections.Generic.List <GH_ValueListItem> .Enumerator enumerator = new List <GH_ValueListItem> .Enumerator();

                ((System.IDisposable)enumerator).Dispose();
            }
            return(state.ToString());
        }
Exemple #2
0
        private void LayoutDropDown()
        {
            int width  = this.ItemMaximumWidth() + 22;
            int height = 22;

            this.Pivot = GH_Convert.ToPoint(this.Pivot);
            System.Drawing.RectangleF bounds = new System.Drawing.RectangleF(this.Pivot.X, this.Pivot.Y, (float)width, (float)height);
            this.Bounds = bounds;
            GH_ValueListItem activeItem = this.Owner.FirstSelectedItem;

            try
            {
                System.Collections.Generic.List <GH_ValueListItem> .Enumerator enumerator = this.Owner.ListItems.GetEnumerator();
                while (enumerator.MoveNext())
                {
                    GH_ValueListItem item = enumerator.Current;
                    if (item == activeItem)
                    {
                        item.SetDropdownBounds(this.Bounds);
                    }
                    else
                    {
                        item.SetEmptyBounds(this.Bounds);
                    }
                }
            }
            finally
            {
                System.Collections.Generic.List <GH_ValueListItem> .Enumerator enumerator = new List <GH_ValueListItem> .Enumerator();

                ((System.IDisposable)enumerator).Dispose();
            }
        }
Exemple #3
0
        private void RenderDropDown(GH_Canvas canvas, System.Drawing.Graphics graphics, System.Drawing.Color color)
        {
            GH_ValueListItem item = this.Owner.FirstSelectedItem;

            if (item == null)
            {
                return;
            }
            graphics.DrawString(item.Name, GH_FontServer.Standard, System.Drawing.Brushes.Black, item.BoxName, GH_TextRenderingConstants.CenterCenter);
            Mandrill_FontStyleAttributes.RenderDownArrow(canvas, graphics, item.BoxRight, color);
        }
Exemple #4
0
        private void ValueMenuItem_Click(object sender, System.EventArgs e)
        {
            System.Windows.Forms.ToolStripMenuItem menuItem = (System.Windows.Forms.ToolStripMenuItem)sender;
            if (menuItem.Checked)
            {
                return;
            }
            GH_ValueListItem item = menuItem.Tag as GH_ValueListItem;

            if (item == null)
            {
                return;
            }
            this.Owner.SelectItem(this.Owner.ListItems.IndexOf(item));
        }
Exemple #5
0
        public override bool Read(GH_IReader reader)
        {
            int mode = 1;

            reader.TryGetInt32("UIMode", ref mode);
            reader.TryGetInt32("ListMode", ref mode);
            this.ListMode = (GH_ValueListMode)mode;
            int count = reader.GetInt32("ListCount");
            int cache = 0;

            reader.TryGetInt32("CacheCount", ref cache);
            this.m_userItems.Clear();
            int arg_52_0 = 0;
            int num      = count - 1;

            for (int i = arg_52_0; i <= num; i++)
            {
                GH_IReader chunk = reader.FindChunk("ListItem", i);
                if (chunk == null)
                {
                    reader.AddMessage("Missing chunk for List Value: " + i.ToString(), GH_Message_Type.error);
                }
                else
                {
                    string itemName       = chunk.GetString("Name");
                    string itemExpression = chunk.GetString("Expression");
                    bool   itemSelected   = false;
                    chunk.TryGetBoolean("Selected", ref itemSelected);
                    GH_ValueListItem item = new GH_ValueListItem(itemName, itemExpression);
                    item.Selected = itemSelected;
                    this.m_userItems.Add(item);
                }
            }
            if (reader.ItemExists("ListIndex"))
            {
                int idx = reader.GetInt32("ListIndex");
                if (idx >= 0 && idx < this.m_userItems.Count)
                {
                    this.m_userItems[idx].Selected = true;
                }
            }
            return(base.Read(reader));
        }
Exemple #6
0
        protected override void CollectVolatileData_Custom()
        {
            this.m_data.Clear();
            try
            {
                System.Collections.Generic.List <GH_ValueListItem> .Enumerator enumerator = this.SelectedItems.GetEnumerator();
                while (enumerator.MoveNext())
                {
                    GH_ValueListItem item = enumerator.Current;
                    this.m_data.Append(item.Value, new GH_Path(0));
                }
            }
            finally
            {
                System.Collections.Generic.List <GH_ValueListItem> .Enumerator enumerator = new List <GH_ValueListItem> .Enumerator();

                ((System.IDisposable)enumerator).Dispose();
            }
        }
Exemple #7
0
        public override GH_ObjectResponse RespondToMouseDown(GH_Canvas sender, GH_CanvasMouseEvent e)
        {
            if (e.Button == System.Windows.Forms.MouseButtons.Left)
            {
                GH_ValueListItem item2 = this.Owner.FirstSelectedItem;
                if (item2 != null)
                {
                    if (item2.BoxRight.Contains(e.CanvasLocation))
                    {
                        System.Windows.Forms.ToolStripDropDownMenu menu = new System.Windows.Forms.ToolStripDropDownMenu();
                        GH_ValueListItem activeItem = this.Owner.FirstSelectedItem;
                        try
                        {
                            System.Collections.Generic.List <GH_ValueListItem> .Enumerator enumerator = this.Owner.ListItems.GetEnumerator();
                            while (enumerator.MoveNext())
                            {
                                GH_ValueListItem existingItem = enumerator.Current;
                                System.Windows.Forms.ToolStripMenuItem menuItem = new System.Windows.Forms.ToolStripMenuItem(existingItem.Name);
                                menuItem.Click += new System.EventHandler(this.ValueMenuItem_Click);
                                if (existingItem == activeItem)
                                {
                                    menuItem.Checked = true;
                                }
                                menuItem.Tag = existingItem;
                                menu.Items.Add(menuItem);
                            }
                        }
                        finally
                        {
                            System.Collections.Generic.List <GH_ValueListItem> .Enumerator enumerator = new List <GH_ValueListItem> .Enumerator();

                            ((System.IDisposable)enumerator).Dispose();
                        }
                        menu.Show(sender, e.ControlLocation);
                        return(GH_ObjectResponse.Handled);
                    }
                }
            }
            return(base.RespondToMouseDown(sender, e));
        }
Exemple #8
0
        private int ItemMaximumWidth()
        {
            int max = 20;

            try
            {
                System.Collections.Generic.List <GH_ValueListItem> .Enumerator enumerator = this.Owner.ListItems.GetEnumerator();
                while (enumerator.MoveNext())
                {
                    GH_ValueListItem item = enumerator.Current;
                    int width             = GH_FontServer.StringWidth(item.Name, GH_FontServer.Standard);
                    max = System.Math.Max(max, width);
                }
            }
            finally
            {
                System.Collections.Generic.List <GH_ValueListItem> .Enumerator enumerator = new List <GH_ValueListItem> .Enumerator();

                ((System.IDisposable)enumerator).Dispose();
            }
            return(max + 10);
        }
Exemple #9
0
        public void LoadState(string state)
        {
            try
            {
                System.Collections.Generic.List <GH_ValueListItem> .Enumerator enumerator = this.m_userItems.GetEnumerator();
                while (enumerator.MoveNext())
                {
                    GH_ValueListItem item = enumerator.Current;
                    item.Selected = false;
                }
            }
            finally
            {
                System.Collections.Generic.List <GH_ValueListItem> .Enumerator enumerator = new List <GH_ValueListItem> .Enumerator();

                ((System.IDisposable)enumerator).Dispose();
            }
            int index;

            if (int.TryParse(state, out index))
            {
                if (index >= 0 && index < this.m_userItems.Count)
                {
                    this.m_userItems[index].Selected = true;
                }
            }
            else
            {
                int arg_81_0 = 0;
                int num      = System.Math.Min(state.Length, this.m_userItems.Count) - 1;
                for (int i = arg_81_0; i <= num; i++)
                {
                    this.m_userItems[i].Selected = state[i].Equals('Y');
                }
            }
        }