public void FirePropertyKeyEnter(PropertyGrid.Section section, PropertyGrid.Item item)
 {
     if (this.OnPropertyKeyEnter != null)
     {
         this.OnPropertyKeyEnter(this, new PropertyKeyEnterArgs(section, item));
     }
 }
 public void FirePropertyChanged(PropertyGrid.Section section, PropertyGrid.Item item, object oldValue)
 {
     if (this.OnPropertyChanged != null)
     {
         this.OnPropertyChanged(this, new PropertyChangedArgs(section, item, oldValue));
     }
 }
Пример #3
0
        private void bRemoveSection_Click(object sender, EventArgs e)
        {
            if (this.referenceList.SelectedSection == null)
            {
                return;
            }
            string        name = this.referenceList.SelectedSection.Name;
            List <string> strs = new List <string>();

            foreach (KeyValuePair <string, GameData.TripleInt> keyValuePair in this.Item.referenceData(name, false))
            {
                if (this.Item.getState(name, keyValuePair.Key) == GameData.State.LOCKED)
                {
                    continue;
                }
                strs.Add(keyValuePair.Key);
            }
            if (strs.Count == 0)
            {
                return;
            }
            foreach (string str in strs)
            {
                this.Item.removeReference(name, str);
                PropertyGrid.PropertyGrid.Item item = this.referenceList.getSection(name).Items.Find((PropertyGrid.PropertyGrid.Item x) => x.Data.ToString() == str);
                this.referenceList.removeItem(name, item);
            }
            if (this.referenceList.getSection(name).Items.Count == 0)
            {
                this.referenceList.removeSection(name);
            }
            this.nav.refreshState(this.Item);
            this.nav.HasChanges = true;
        }
        public PropertyGrid.Item getItem(string name)
        {
            PropertyGrid.Item             item;
            Predicate <PropertyGrid.Item> predicate = null;

            foreach (PropertyGrid.Section section in this.Sections)
            {
                List <PropertyGrid.Item>      items      = section.Items;
                Predicate <PropertyGrid.Item> predicate1 = predicate;
                if (predicate1 == null)
                {
                    Predicate <PropertyGrid.Item> predicate2 = (PropertyGrid.Item o) => o.Name == name;
                    Predicate <PropertyGrid.Item> predicate3 = predicate2;
                    predicate  = predicate2;
                    predicate1 = predicate3;
                }
                PropertyGrid.Item item1 = items.Find(predicate1);
                if (item1 != null)
                {
                    item = item1;
                    return(item);
                }
            }
            item = null;
            return(item);
        }
 protected void FirePropertySelected(PropertyGrid.Section section, PropertyGrid.Item item)
 {
     if (this.OnPropertySelected != null)
     {
         this.OnPropertySelected(this, new PropertySelectedArgs(section, item));
     }
 }
 public void refreshGrid()
 {
     this.grid.clear();
     if (this.Item == null)
     {
         return;
     }
     foreach (string str in this.Item.referenceLists())
     {
         GameData.Desc     desc = GameData.getDesc(this.Item.type, str);
         TripleIntProperty tripleIntProperty = new TripleIntProperty(desc.flags);
         foreach (KeyValuePair <string, GameData.TripleInt> keyValuePair in this.Item.referenceData(str, false))
         {
             if (this.Exclusions.Contains(str))
             {
                 continue;
             }
             GameData.Item  item                = this.nav.ou.gameData.getItem(keyValuePair.Key);
             GameData.State state               = this.Item.getState(str, keyValuePair.Key);
             string         str1                = (item != null ? item.Name : keyValuePair.Key);
             Color          stateColor          = StateColours.GetStateColor(state);
             PropertyGrid.PropertyGrid.Item key = this.grid.addItem(str, str1, keyValuePair.Value, desc.description, new Color?(stateColor), desc.flags > 0);
             key.Property = tripleIntProperty;
             key.Data     = keyValuePair.Key;
             key.Editable = state != GameData.State.LOCKED;
         }
     }
     foreach (KeyValuePair <string, GameData.Instance> keyValuePair1 in this.Item.instanceData())
     {
         bool  flag  = (keyValuePair1.Value.getState() == GameData.State.LOCKED ? false : !this.readOnly);
         Color color = StateColours.GetStateColor(keyValuePair1.Value.getState());
         this.grid.addItem("Instances", keyValuePair1.Key, keyValuePair1.Value, "Object instances", new Color?(color), flag);
     }
     this.grid.AutosizeDivider();
 }
Пример #7
0
 public override void Paint(PropertyGrid grid, PropertyGrid.Item item, Graphics g, Rectangle rect)
 {
     base.Paint(grid, item, g, rect);
     if (base.Editing == item)
     {
         g.DrawString("...", grid.Font, Brushes.Black, new PointF((float)(this.mButton.X + 3), (float)rect.Y));
     }
 }
 public void removeItem(string section, string name)
 {
     PropertyGrid.Item item = this.getItem(section, name);
     if (item != null)
     {
         this.removeItem(section, item);
     }
 }
        private void PropertyGrid_MouseDown(object sender, MouseEventArgs e)
        {
            Point autoScrollPosition;

            base.Focus();
            if ((this.mEditor == null ? false : this.mEditor.Editing != null))
            {
                if (e.X <= this.DividerPosition + 2)
                {
                    this.closeEditor(true);
                }
                else
                {
                    CustomProperty customProperty            = this.mEditor;
                    System.Windows.Forms.MouseButtons button = e.Button;
                    int clicks = e.Clicks;
                    int x      = e.X;
                    int y      = e.Y;
                    autoScrollPosition = base.AutoScrollPosition;
                    customProperty.MouseDown(new MouseEventArgs(button, clicks, x, y - autoScrollPosition.Y, e.Delta));
                }
            }
            if ((this.DividerFixed ? true : Math.Abs(e.X - this.DividerPosition) >= 3))
            {
                int num = e.Y;
                autoScrollPosition = base.AutoScrollPosition;
                KeyValuePair <PropertyGrid.Section, PropertyGrid.Item> itemAt = this.getItemAt(num - autoScrollPosition.Y);
                if (itemAt.Value != null)
                {
                    this.mFocusedItem    = itemAt.Value;
                    this.mFocusedSection = itemAt.Key;
                    this.FirePropertySelected(this.mFocusedSection, this.mFocusedItem);
                    if (e.X > this.DividerPosition)
                    {
                        this.createEditor(itemAt.Key, itemAt.Value);
                    }
                }
                else if (itemAt.Key != null)
                {
                    this.mFocusedItem    = null;
                    this.mFocusedSection = itemAt.Key;
                    if (e.X < this.MarginSize)
                    {
                        this.mFocusedSection.Collapsed = !this.mFocusedSection.Collapsed;
                        this.recalculateSize();
                    }
                }
                base.Invalidate();
            }
            else
            {
                this.Cursor         = Cursors.VSplit;
                this.mMovingDivider = true;
                base.Capture        = true;
            }
        }
Пример #10
0
 public virtual void CreateEditor(PropertyGrid grid, PropertyGrid.Section section, PropertyGrid.Item item, Rectangle rect)
 {
     this.mGrid    = grid;
     this.mItem    = item;
     this.mSection = section;
     if (this.mTextBox == null)
     {
         this.CreateTextbox(this.getAsString(item.Value), rect, 2, 0);
     }
 }
Пример #11
0
 public void DestroyEditor()
 {
     if (this.mItem != null)
     {
         this.mItem = null;
         this.mGrid.Controls.Clear();
         this.mGrid.Invalidate();
         this.mTextBox = null;
         this.mGrid    = null;
     }
 }
Пример #12
0
        public void refresh(GameData.Item item, string instanceID, itemType mask)
        {
            this.Item         = item;
            this.InstanceName = instanceID;
            this.Instance     = item.getInstance(instanceID);
            GameData gameDatum = this.nav.ou.gameData;
            string   str       = this.Instance.sdata["ref"];
            object   obj       = gameDatum.getItem(str);

            if (obj == null)
            {
                obj = str;
            }
            bool   state      = this.Instance.getState() == GameData.State.LOCKED;
            Color  stateColor = StateColours.GetStateColor((state ? GameData.State.LOCKED : GameData.State.ORIGINAL));
            string str1       = "";

            if (mask == itemType.NULL_ITEM)
            {
                str1 = "is node=true";
            }
            this.grid.addItem("Base", "Parent Item", this.Item, "The item this instance belongs to", new Color?(SystemColors.GrayText), false);
            this.grid.addItem("Base", "Instance ID", this.InstanceName, "Unique identifier for this instance. Works the same as StringID but for instances", new Color?(stateColor), !state);
            this.grid.addItem("Base", "Target", obj, "Game object that is instanced", new Color?(stateColor), !state).Property = new GameDataItemProperty(gameDatum, mask, str1);
            GameData.State state1 = this.Instance.getState("ref");
            if (state && state1 != GameData.State.INVALID)
            {
                state1 = GameData.State.LOCKED;
            }
            this.grid.getItem("Target").TextColour = StateColours.GetStateColor(state1);
            this.setItem("Position", "X", "x", "Instance position");
            this.setItem("Position", "Y", "y", "Instance position");
            this.setItem("Position", "Z", "z", "Instance position");
            this.setItem("Orientation", "W", "qw", "Instance oriantetion (quaternion)");
            this.setItem("Orientation", "X", "qx", "Instance oriantetion (quaternion)");
            this.setItem("Orientation", "Y", "qy", "Instance oriantetion (quaternion)");
            this.setItem("Orientation", "Z", "qz", "Instance oriantetion (quaternion)");
            foreach (KeyValuePair <string, GameData.TripleInt> keyValuePair in this.Instance.referenceData("states", false))
            {
                GameData.Item item1 = this.nav.ou.gameData.getItem(keyValuePair.Key);
                if (item1 == null)
                {
                    continue;
                }
                PropertyGrid.PropertyGrid propertyGrid = this.grid;
                itemType _itemType = item1.type;
                Color?   nullable  = null;
                PropertyGrid.PropertyGrid.Item gameDataItemProperty = propertyGrid.addItem("State Data", _itemType.ToString(), item1, "Instance state data", nullable, true);
                gameDataItemProperty.Property = new GameDataItemProperty(gameDatum, item1.type, "");
                gameDataItemProperty.Editable = false;
            }
            this.grid.AutosizeDivider();
        }
Пример #13
0
 public override void Paint(PropertyGrid grid, PropertyGrid.Item item, Graphics g, Rectangle rect)
 {
     if (base.Editing != item)
     {
         base.Paint(grid, item, g, rect);
     }
     else if (this.mButton.Width > 0)
     {
         rect.X     = this.mButton.X;
         rect.Width = this.mButton.Width;
         ButtonRenderer.DrawButton(g, rect, this.mState);
     }
 }
Пример #14
0
        private PropertyGrid.PropertyGrid.Item setItem(string section, string name, string key, string desc)
        {
            Color?nullable = null;

            PropertyGrid.PropertyGrid.Item stateColor = this.grid.addItem(section, name, this.Instance[key], desc, nullable, true);
            stateColor.Data       = key;
            stateColor.TextColour = StateColours.GetStateColor(this.Instance.getState(key));
            if (this.Instance.getState() == GameData.State.LOCKED)
            {
                stateColor.TextColour = StateColours.GetStateColor(GameData.State.LOCKED);
                stateColor.Editable   = false;
            }
            return(stateColor);
        }
 public void addItem(string section, PropertyGrid.Item item)
 {
     PropertyGrid.Section list = this.getSection(section, true);
     list.Items.Add(item);
     if (this.SortItems)
     {
         list.Items = (
             from o in list.Items
             orderby o.Name
             select o).ToList <PropertyGrid.Item>();
     }
     this.recalculateSize();
     base.Invalidate();
 }
 public void removeItem(string section, PropertyGrid.Item item)
 {
     this.closeEditor(true);
     PropertyGrid.Section section1 = this.getSection(section, false);
     if (section1 != null)
     {
         if (this.mFocusedItem == item)
         {
             this.mFocusedItem = null;
         }
         section1.Items.Remove(item);
         base.Invalidate();
     }
 }
 public PropertyGrid.Item getItem(string section, string name)
 {
     PropertyGrid.Item    item;
     PropertyGrid.Section section1 = this.getSection(section, false);
     if (section1 != null)
     {
         PropertyGrid.Item item1 = section1.Items.Find((PropertyGrid.Item o) => o.Name == name);
         item = item1;
     }
     else
     {
         item = null;
     }
     return(item);
 }
Пример #18
0
        public override void Paint(PropertyGrid grid, PropertyGrid.Item item, Graphics g, Rectangle rect)
        {
            Color value      = (Color)item.Value;
            Brush solidBrush = new SolidBrush(value);

            g.FillRectangle(solidBrush, rect.X + 2, rect.Y + 3, rect.Height, rect.Height - 5);
            g.DrawRectangle(Pens.Black, rect.X + 1, rect.Y + 2, rect.Height, rect.Height - 4);
            if (base.Editing == item)
            {
                base.Paint(grid, item, g, rect);
            }
            else
            {
                base.DrawText(this.ColourString(value), grid.Font, g, rect, rect.Height + 5, 0, new Color?(item.TextColour));
            }
        }
Пример #19
0
 private void mTextBox_KeyDown(object sender, KeyEventArgs e)
 {
     if (e.KeyCode == Keys.Return)
     {
         PropertyGrid         propertyGrid = this.mGrid;
         PropertyGrid.Section section      = this.mSection;
         PropertyGrid.Item    item         = this.mItem;
         this.Apply();
         propertyGrid.FirePropertyKeyEnter(section, item);
         e.SuppressKeyPress = true;
     }
     else if (e.KeyCode == Keys.Escape)
     {
         this.DestroyEditor();
         e.SuppressKeyPress = true;
     }
 }
 private void createEditor(PropertyGrid.Section s, PropertyGrid.Item item)
 {
     if ((this.mEditor == null ? true : this.mEditor.Editing != item))
     {
         this.closeEditor(true);
         if (item.Editable)
         {
             int verticalPosition = this.getVerticalPosition(s, item);
             this.mEditor = item.Property ?? this.DefaultType;
             CustomProperty      customProperty  = this.mEditor;
             int                 dividerPosition = this.DividerPosition;
             int                 y          = verticalPosition + 1 + base.AutoScrollPosition.Y;
             System.Drawing.Size clientSize = base.ClientSize;
             customProperty.CreateEditor(this, s, item, new Rectangle(dividerPosition, y, clientSize.Width - this.DividerPosition, this.LineHeight));
         }
     }
 }
        protected override void ButtonPressed()
        {
            PropertyGrid.PropertyGrid.Item item                  = this.mItem;
            PropertyGrid.PropertyGrid      propertyGrid          = this.mGrid;
            TranslationManager.TranslationDialogueLine.Line data = this.mItem.Data as TranslationManager.TranslationDialogueLine.Line;
            TextDialog textDialog = new TextDialog(this.mItem.Name, data.Translation, data.Original);

            if (textDialog.ShowDialog() == DialogResult.OK)
            {
                this.mItem = item;
                this.mGrid = propertyGrid;
                char[] chrArray = new char[] { ' ', '\n', '\r' };
                base.setValue(textDialog.Value.TrimEnd(chrArray));
                this.mItem = null;
                this.mGrid = null;
            }
        }
        public PropertyGrid.Item addItem(string section, string name, object value, string description = "", Color?color = null, bool editable = true)
        {
            PropertyGrid.Item item = new PropertyGrid.Item()
            {
                Name     = name,
                Value    = value,
                Editable = editable,
                Visible  = true
            };
            //TODO 这里以后可以汉化字段
            //  item.Name = item.Name;

            //string tansedStr = null;
            //if ((bool)NativeTranslte.enumDict.TryGetValue(name, out tansedStr))
            //{
            //    item.TransName = tansedStr;
            //}
            //tansedStr = null;
            //if ((value is string || value is EnumValue) && (bool)NativeTranslte.enumDict.TryGetValue((string)value, out tansedStr))
            //{
            //    item.TransValue = tansedStr;
            //}
            //try
            //{
            //    fCSEnums.addValue(tansedStr, max);
            //}
            //catch (Exception exception)
            //{
            //    fCSEnums.addValue(item1, max);
            //}
            PropertyGrid.Item item1    = item;
            Color?            nullable = color;

            item1.TextColour = (nullable.HasValue ? nullable.GetValueOrDefault() : this.ForeColor);
            item.Description = description;
            if (value != null)
            {
                item.Property = this.getCustomProperty(value.GetType());
            }
            this.addItem(section, item);
            return(item);
        }
Пример #23
0
        public override void Paint(PropertyGrid grid, PropertyGrid.Item item, Graphics g, Rectangle rect)
        {
            if (base.Editing == item)
            {
                ComboBoxState comboBoxState = ComboBoxState.Normal;
                switch (this.mState)
                {
                case PushButtonState.Hot:
                {
                    comboBoxState = ComboBoxState.Hot;
                    break;
                }

                case PushButtonState.Pressed:
                {
                    comboBoxState = ComboBoxState.Pressed;
                    break;
                }

                case PushButtonState.Disabled:
                {
                    comboBoxState = ComboBoxState.Disabled;
                    break;
                }
                }
                rect.X     = this.mButton.X;
                rect.Width = this.mButton.Width;
                if (!Application.RenderWithVisualStyles)
                {
                    ControlPaint.DrawScrollButton(g, rect, ScrollButton.Down, (comboBoxState == ComboBoxState.Pressed ? ButtonState.Pushed : ButtonState.Normal));
                }
                else
                {
                    ComboBoxRenderer.DrawDropDownButton(g, rect, comboBoxState);
                }
            }
            else
            {
                base.Paint(grid, item, g, rect);
            }
        }
        private int getVerticalPosition(PropertyGrid.Section section, PropertyGrid.Item item)
        {
            int num;
            int lineHeight = 0;

            if (!section.Collapsed)
            {
                foreach (PropertyGrid.Section section1 in this.Sections)
                {
                    if ((section1 != section ? true : item != null))
                    {
                        lineHeight += this.LineHeight;
                        if (section1 == section)
                        {
                            num = lineHeight + section1.Items.IndexOf(item) * this.LineHeight;
                            return(num);
                        }
                        else if (!section1.Collapsed)
                        {
                            lineHeight = lineHeight + section1.Items.Count * this.LineHeight;
                        }
                    }
                    else
                    {
                        num = lineHeight;
                        return(num);
                    }
                }
                num = -1;
            }
            else
            {
                num = -1;
            }
            return(num);
        }
 private void PropertyGrid_PreviewKeyDown(object sender, PreviewKeyDownEventArgs e)
 {
     PropertyGrid.Item item;
     if ((this.Sections.Count == 0 ? false : this.mFocusedSection != null))
     {
         int num  = this.Sections.IndexOf(this.mFocusedSection);
         int num1 = (this.mFocusedItem == null ? -1 : this.mFocusedSection.Items.IndexOf(this.mFocusedItem));
         PropertyGrid.Item item1 = this.mFocusedItem;
         if (e.KeyCode == Keys.Up)
         {
             if (num1 > 0)
             {
                 item1 = this.mFocusedSection.Items[num1 - 1];
             }
             else if (num1 == 0)
             {
                 item1 = null;
             }
             else if (num > 0)
             {
                 this.mFocusedSection = this.Sections[num - 1];
                 if (this.mFocusedSection.Items.Count == 0)
                 {
                     item = null;
                 }
                 else
                 {
                     item = this.mFocusedSection.Items[this.mFocusedSection.Items.Count - 1];
                 }
                 item1 = item;
             }
         }
         else if (e.KeyCode == Keys.Down)
         {
             if (num1 < this.mFocusedSection.Items.Count - 1)
             {
                 item1 = this.mFocusedSection.Items[num1 + 1];
             }
             else if (num < this.Sections.Count - 1)
             {
                 this.mFocusedSection = this.Sections[num + 1];
                 item1 = null;
             }
         }
         else if ((e.KeyCode != Keys.Left ? false : num1 < 0))
         {
             this.mFocusedSection.Collapsed = true;
             base.Invalidate();
         }
         else if ((e.KeyCode != Keys.Right ? false : num1 < 0))
         {
             this.mFocusedSection.Collapsed = false;
             base.Invalidate();
         }
         else if (this.mFocusedItem != null)
         {
             this.createEditor(this.mFocusedSection, this.mFocusedItem);
         }
         if (item1 != this.mFocusedItem)
         {
             this.mFocusedItem = item1;
             if (item1 != null)
             {
                 this.FirePropertySelected(this.mFocusedSection, this.mFocusedItem);
             }
             int   verticalPosition   = this.getVerticalPosition(this.mFocusedSection, this.mFocusedItem);
             Point autoScrollPosition = base.AutoScrollPosition;
             int   num2       = Math.Min(verticalPosition, -autoScrollPosition.Y);
             int   lineHeight = verticalPosition + this.LineHeight;
             System.Drawing.Size clientSize = base.ClientSize;
             num2 = Math.Max(num2, lineHeight - clientSize.Height);
             base.AutoScrollPosition = new Point(0, num2);
             base.Invalidate();
         }
     }
 }
Пример #26
0
 public override void CreateEditor(PropertyGrid grid, PropertyGrid.Section section, PropertyGrid.Item item, Rectangle rect)
 {
     base.CreateEditor(grid, section, item, rect);
     this.mPopupX = rect.X;
 }
Пример #27
0
 public PropertySelectedArgs(PropertyGrid.Section section, PropertyGrid.Item item)
 {
     this.Section = section;
     this.Item    = item;
 }
Пример #28
0
 public override void CreateEditor(PropertyGrid grid, PropertyGrid.Section section, PropertyGrid.Item item, Rectangle rect)
 {
     base.CreateEditor(grid, section, item, rect);
     this.mTextBox.KeyPress += new KeyPressEventHandler(this.mTextBox_KeyPress);
 }
Пример #29
0
 public override void CreateEditor(PropertyGrid grid, PropertyGrid.Section section, PropertyGrid.Item item, Rectangle rect)
 {
     base.CreateEditor(grid, section, item, rect);
     this.mList.Items.Add(false);
     this.mList.Items.Add(true);
     this.mList.SelectedItem = item.Value;
 }
Пример #30
0
 public override void CreateEditor(PropertyGrid grid, PropertyGrid.Section section, PropertyGrid.Item item, Rectangle rect)
 {
     base.CreateEditor(grid, section, item, rect);
     foreach (object value in Enum.GetValues(item.Value.GetType()))
     {
         this.mList.Items.Add(value);
     }
     this.mList.SelectedItem = item.Value;
 }