Ejemplo n.º 1
0
        public string SaveState()
        {
            System.Text.StringBuilder          state      = new System.Text.StringBuilder(this.m_userItems.Count);
            List <GuanacoListItem> .Enumerator enumerator = new List <GuanacoListItem> .Enumerator();

            try
            {
                enumerator = this.m_userItems.GetEnumerator();
                while (enumerator.MoveNext())
                {
                    GuanacoListItem item = enumerator.Current;
                    if (item.Selected)
                    {
                        state.Append('Y');
                    }
                    else
                    {
                        state.Append('N');
                    }
                }
            }
            finally
            {
                enumerator.Dispose();
            }
            return(state.ToString());
        }
Ejemplo n.º 2
0
        private void RenderCheckList(GH_Canvas canvas, Graphics graphics, Color color)
        {
            List <GuanacoListItem> .Enumerator enumerator;
            if (this.Owner.ListItems.Count == 0)
            {
                return;
            }
            int y0 = Convert.ToInt32(this.Bounds.Y);
            int y  = Convert.ToInt32(this.Bounds.Bottom);
            int x  = Convert.ToInt32(this.Owner.ListItems[0].BoxLeft.Right);

            enumerator = this.Owner.ListItems.GetEnumerator();
            try
            {
                enumerator = this.Owner.ListItems.GetEnumerator();
                while (enumerator.MoveNext())
                {
                    GuanacoListItem item = enumerator.Current;
                    graphics.DrawString(item.Name, GH_FontServer.Standard, Brushes.Black, item.BoxName, GH_TextRenderingConstants.CenterCenter);
                    if (item.Selected)
                    {
                        GuanacoListAttributes.RenderCheckMark(canvas, graphics, item.BoxLeft, color);
                    }
                }
            }
            finally
            {
                enumerator.Dispose();
            }
        }
Ejemplo n.º 3
0
        private void LayoutDropDown()
        {
            List <GuanacoListItem> .Enumerator enumerator;
            int num2 = this.ItemMaximumWidth() + 0x16;
            int num  = 0x16;

            this.Pivot = (PointF)GH_Convert.ToPoint(this.Pivot);
            RectangleF ef2 = new RectangleF(this.Pivot.X, this.Pivot.Y, (float)num2, (float)num);

            this.Bounds = ef2;
            GuanacoListItem firstSelectedItem = this.Owner.FirstSelectedItem;

            enumerator = this.Owner.ListItems.GetEnumerator();

            try
            {
                while (enumerator.MoveNext())
                {
                    GuanacoListItem current = enumerator.Current;

                    if (current == firstSelectedItem)
                    {
                        SetDropdownBounds(current, this.Bounds);
                    }
                    else
                    {
                        SetEmptyBounds(current, this.Bounds);
                    }
                }
            }
            finally
            {
                enumerator.Dispose();
            }
        }
Ejemplo n.º 4
0
        private void RenderDropDown(GH_Canvas canvas, Graphics graphics, Color color)
        {
            GuanacoListItem firstSelectedItem = this.Owner.FirstSelectedItem;

            if (firstSelectedItem != null)
            {
                graphics.DrawString(this.Owner.SelectedItems[0].Name, GH_FontServer.Standard, Brushes.Black, firstSelectedItem.BoxName, GH_TextRenderingConstants.CenterCenter);
                RenderDownArrow(canvas, graphics, firstSelectedItem.BoxRight, color);
            }
        }
Ejemplo n.º 5
0
        private void SetEmptyBounds(GuanacoListItem item, RectangleF bounds)
        {
            RectangleF rectangleF = new RectangleF(bounds.X, bounds.Y, 0f, 0f);

            item.BoxLeft  = rectangleF;
            rectangleF    = new RectangleF(bounds.X, bounds.Y, 0f, 0f);
            item.BoxName  = rectangleF;
            rectangleF    = new RectangleF(bounds.X, bounds.Y, 0f, 0f);
            item.BoxRight = rectangleF;
        }
Ejemplo n.º 6
0
        private void SetDropdownBounds(GuanacoListItem item, RectangleF bounds)
        {
            RectangleF rectangleF = new RectangleF(bounds.X, bounds.Y, 0f, bounds.Height);

            item.BoxLeft  = rectangleF;
            rectangleF    = new RectangleF(bounds.X, bounds.Y, bounds.Width - 22f, bounds.Height);
            item.BoxName  = rectangleF;
            rectangleF    = new RectangleF(bounds.Right - 22f, bounds.Y, 22f, bounds.Height);
            item.BoxRight = rectangleF;
        }
Ejemplo n.º 7
0
        private void ValueMenuItem_Click(object sender, EventArgs e)
        {
            ToolStripMenuItem menuItem = (ToolStripMenuItem)sender;

            if (menuItem.Checked)
            {
                return;
            }
            GuanacoListItem item = menuItem.Tag as GuanacoListItem;

            if (item == null)
            {
                return;
            }
            this.Owner.SelectItem(this.Owner.ListItems.IndexOf(item));
        }
Ejemplo n.º 8
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);
                    Type            t = JsonConvert.DeserializeObject <Type>(chunk.GetString("Type"));
                    object          deserializedExpression = JsonConvert.DeserializeObject(itemExpression, t);
                    GuanacoListItem item = new GuanacoListItem(itemName, deserializedExpression);
                    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));
        }
Ejemplo n.º 9
0
        protected override void CollectVolatileData_Custom()
        {
            List <GuanacoListItem> .Enumerator enumerator = new List <GuanacoListItem> .Enumerator();

            this.m_data.Clear();
            try
            {
                enumerator = this.SelectedItems.GetEnumerator();
                while (enumerator.MoveNext())
                {
                    GuanacoListItem item = enumerator.Current;
                    this.m_data.Append(item.Value, new GH_Path(0));
                }
            }
            finally
            {
                enumerator.Dispose();
            }
        }
Ejemplo n.º 10
0
        public void LoadState(string state)
        {
            System.Collections.IEnumerator enumerator = new List <GuanacoListItem> .Enumerator();

            try
            {
                enumerator = this.m_userItems.GetEnumerator();
                while (enumerator.MoveNext())
                {
                    GuanacoListItem item = enumerator.Current as GuanacoListItem;
                    item.Selected = false;
                }
            }
            finally
            {
                ((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');
                }
            }
        }
Ejemplo n.º 11
0
        public override GH_ObjectResponse RespondToMouseDown(GH_Canvas sender, GH_CanvasMouseEvent e)
        {
            if (e.Button == MouseButtons.Left)
            {
                switch (this.Owner.ListMode)
                {
                case GH_ValueListMode.CheckList:
                {
                    int arg_4A_0 = 0;
                    int num      = this.Owner.ListItems.Count - 1;
                    for (int i = arg_4A_0; i <= num; i++)
                    {
                        GuanacoListItem item = this.Owner.ListItems[i];
                        if (item.BoxLeft.Contains(e.CanvasLocation))
                        {
                            this.Owner.ToggleItem(i);
                            return(GH_ObjectResponse.Handled);
                        }
                    }
                    break;
                }

                case GH_ValueListMode.DropDown:
                {
                    GuanacoListItem item2 = this.Owner.FirstSelectedItem;
                    if (item2 != null)
                    {
                        if (item2.BoxRight.Contains(e.CanvasLocation))
                        {
                            List <GuanacoListItem> .Enumerator enumerator;
                            ToolStripDropDownMenu menu       = new ToolStripDropDownMenu();
                            GuanacoListItem       activeItem = this.Owner.FirstSelectedItem;
                            enumerator = this.Owner.ListItems.GetEnumerator();
                            try
                            {
                                enumerator = this.Owner.ListItems.GetEnumerator();
                                while (enumerator.MoveNext())
                                {
                                    GuanacoListItem   existingItem = enumerator.Current;
                                    ToolStripMenuItem menuItem     = new ToolStripMenuItem(existingItem.Name);
                                    menuItem.Click += new EventHandler(this.ValueMenuItem_Click);
                                    if (existingItem == activeItem)
                                    {
                                        menuItem.Checked = true;
                                    }
                                    menuItem.Tag = existingItem;
                                    menu.Items.Add(menuItem);
                                }
                            }
                            finally
                            {
                                enumerator.Dispose();
                            }
                            menu.Show(sender, e.ControlLocation);
                            return(GH_ObjectResponse.Handled);
                        }
                    }
                    break;
                }
                }
            }
            return(base.RespondToMouseDown(sender, e));
        }