Xpoint
   [напомнить пароль]

Property grid: Многоуровневые "ветки"

Метки: [без меток]
2009-04-20 14:38:39 [обр] Top manager(0/2)[досье]

есть настройки, собственно их не мало :)

Я сделал некоторый параметр, который является экземпляром класса. В нем есть еще под классы и т.д.

Ни как не могу понять, что не так, почему выходит то, что видно на картинке.

код в студию:

using System;
using System.Data;
using System.IO;
using System.IO.Ports;
using System.Text;
using System.ComponentModel;
using System.Xml;
using System.Xml.Serialization;

namespace _DES
{
/// <summary>
/// Setting for thales
/// </summary>
///   
    [DefaultPropertyAttribute("Mode")]
    public class ThalesSettings
   {
        public enum HsmConnectionMode { Ethernet, RS232 }
        private HsmConnectionMode mode = HsmConnectionMode.Ethernet;
        private string hsmRS232PortName = "";
        private string hsmEthernetAddress = "";
        private int hsmEthernetPortNo = 2030;
        private int hsmAnswerTimeout = 5000;
        private ComponentStyle component1Style = new ComponentStyle();
        private ComponentStyle component2Style = new ComponentStyle();
        private TMKStyle tmkStyle = new TMKStyle();

      private BU.IniFile ini = new BU.IniFile();

      public ThalesSettings()
      {
      }

        [CategoryAttribute("Connection"), DescriptionAttribute("HSM connection mode")]
        public HsmConnectionMode Mode
        {
            get
            {
                return this.mode;
            }
            set
            {
                this.mode = value;
            }
        }
        [CategoryAttribute("Connection"), DescriptionAttribute("RS-232 port name")]
        public string HsmRS232PortName
        {
            get
            {
                return this.hsmRS232PortName;
            }
            set
            {
                this.hsmRS232PortName = value;
            }
        }
        [CategoryAttribute("Connection"), DescriptionAttribute("Ethernet host address")]
        public string HsmEthernetAddress
        {
            get
            {
                return this.hsmEthernetAddress;
            }
            set
            {
                this.hsmEthernetAddress = value;
            }
        }
        [CategoryAttribute("Connection"), DescriptionAttribute("Ethernet host port")]
        public int HsmEthernetPortNo
        {
            get
            {
                return this.hsmEthernetPortNo;
            }
            set
            {
                this.hsmEthernetPortNo = value;
            }
        }
        [CategoryAttribute("Connection"), DescriptionAttribute("HSM answer wating timeout")]
        public int HsmAnswerTimeout
        {
            get
            {
                return this.hsmAnswerTimeout;
            }
            set
            {
                this.hsmAnswerTimeout = value;
            }
        }

        [CategoryAttribute("First Component style"), DescriptionAttribute("Style of the first component")]
        public ComponentStyle Component1Style
        {
            get
            {
                return this.component1Style;
            }
            set
            {
                this.component1Style = value;
            }
        }
        [CategoryAttribute("Second component style"), DescriptionAttribute("Style of the second component")]
        public ComponentStyle Component2Style
        {
            get
            {
                return this.component2Style;
            }
            set
            {
                this.component2Style = value;
            }
        }
        [CategoryAttribute("TMK style"), DescriptionAttribute("Style of the TMK")]
        public TMKStyle TmkStyle
        {
            get
            {
                return this.tmkStyle;
            }
            set
            {
                this.tmkStyle = value;
            }
        }

        public void save()
        {
            this.ini.write("Settings", "Thales", this.serialize());
        }

        public void read()
        {
            string xml = this.ini.read("Settings", "Thales");
            if (xml == "")
            {
                Program.thalesSettings.save();
                return;
            }
            Program.thalesSettings = ThalesSettings.deserialize(xml);
        }

        public String serialize()
        {
            try
            {
                String xmlizedString = null;
                MemoryStream memoryStream = new MemoryStream();
                Type type = typeof(ThalesSettings);
                XmlSerializer xs = new XmlSerializer(type);
                XmlTextWriter xmlTextWriter = new XmlTextWriter(memoryStream, Encoding.UTF8);
                xs.Serialize(xmlTextWriter, this);
                memoryStream = (MemoryStream)xmlTextWriter.BaseStream;
                xmlizedString = BU.Util.utf8ByteArrayToString(memoryStream.ToArray());
                xmlizedString = xmlizedString.Remove(0, xmlizedString.IndexOf("<"));
                return xmlizedString;
            }
            catch (Exception e)
            {
                System.Console.WriteLine(e);
                return null;
            }
        }

        public static ThalesSettings deserialize(String xml)
        {
            XmlSerializer xs = new XmlSerializer(typeof(ThalesSettings));
            MemoryStream memoryStream = new MemoryStream(BU.Util.stringToUTF8ByteArray(xml));
            XmlTextWriter xmlTextWriter = new XmlTextWriter(memoryStream, Encoding.UTF8);
            return (ThalesSettings)xs.Deserialize(memoryStream);
        }

        [DefaultPropertyAttribute("NoLocation")]
        public class ComponentStyle
        {
            private XY noLocation = new XY(1, 1);
            private Element id = new Element();
            private Element checkValue = new Element();
            private Element createdAt = new Element();

            public ComponentStyle()
            { 
            }

            [CategoryAttribute("Elements"), DescriptionAttribute("\"No\" location")]
            public XY NoLocation
            {
                get { return this.noLocation; }
                set { this.noLocation = value; }
            }
            [CategoryAttribute("Elements"), DescriptionAttribute("\"ID\" element")]
            public Element ID
            {
                get { return this.id; }
                set { this.id = value; }
            }
            [CategoryAttribute("Elements"), DescriptionAttribute("\"Check value\" element ")]
            public Element CheckValue
            {
                get { return this.checkValue; }
                set { this.checkValue = value; }
            }
            [CategoryAttribute("Elements"), DescriptionAttribute("\"Created at\" element")]
            public Element CreatedAt
            {
                get { return this.createdAt; }
                set { this.createdAt = value; }
            }

            public class Element
            {
                private string title = "";
                private XY titleXY = new XY(1, 1);
                private XY valueXY = new XY(1, 1);

                public Element()
                {
                }
                [CategoryAttribute("Element data"), DescriptionAttribute("Element title")]
                public string Title
                {
                    get { return this.title; }
                    set { this.title = value.Trim(); }
                }
                [CategoryAttribute("Element data"), DescriptionAttribute("Location of element title")]
                public XY TitleLocation
                {
                    get { return this.titleXY; }
                    set { this.titleXY = value; }
                }
                [CategoryAttribute("Element data"), DescriptionAttribute("Location of element value")]
                public XY ValueLocation
                {
                    get { return this.valueXY; }
                    set { this.valueXY = value; }
                }
            }
            public class XY
            {
                private int x = 1;
                private int y = 1;

                public XY()
                { 
                }
                public XY(int x, int y)
                {
                    this.x = x;
                    this.y = y;
                }
                [CategoryAttribute("Object location"), DescriptionAttribute("Number of spaces placed before")]
                public int X
                {
                    get { return this.x; }
                    set { this.x = value; }
                }
                [CategoryAttribute("Object location"), DescriptionAttribute("Number of lines placed before")]
                public int Y
                {
                    get { return this.y; }
                    set { this.y = value; }
                }
            }
        }
        [DefaultPropertyAttribute("NoLocation")]
        public class TMKStyle
        {
            private string title = "";
            private int titleX1 = 0;
            private int titleX2 = 0;
            private int titleY = 0;

            private int valueX1 = 0;
            private int valueX2 = 0;
            private int valueY = 0;

            [CategoryAttribute("TMK"), DescriptionAttribute("TMK title lable")]
            public string Title
            {
                get { return this.title; }
                set { this.title = value; }
            }
            [CategoryAttribute("TMK"), DescriptionAttribute("TMK title location in first component")]
            public int TitleX1
            {
                get { return this.titleX1; }
                set { this.titleX1 = value; }
            }
            [CategoryAttribute("TMK"), DescriptionAttribute("TMK title location in second component")]
            public int TitleX2
            {
                get { return this.titleX2; }
                set { this.titleX2 = value; }
            }
            [CategoryAttribute("TMK"), DescriptionAttribute("TMK title location in both component")]
            public int TitleY
            {
                get { return this.titleY; }
                set { this.titleY = value; }
            }

            [CategoryAttribute("TMK"), DescriptionAttribute("TMK value location in first component")]
            public int ValueX1
            {
                get { return this.valueX1; }
                set { this.valueX1 = value; }
            }
            [CategoryAttribute("TMK"), DescriptionAttribute("TMK value location in second component")]
            public int ValueX2
            {
                get { return this.valueX2; }
                set { this.valueX2 = value; }
            }
            [CategoryAttribute("TMK"), DescriptionAttribute("TMK value location in both component")]
            public int ValueY
            {
                get { return this.valueY; }
                set { this.valueY = value; }
            }
        }
    }
}
спустя 5 часов [обр] Василий Свиридов(47/175)[досье]
А что выходит в вашем случае?
спустя 10 часов [обр] Top manager(0/2)[досье]
Василий Свиридов[досье] то что видно на картинке...
спустя 16 часов [обр] Василий Свиридов(47/175)[досье]
Т.е. вы хотите чтобы те вещи, которые показываются как Thales_Settings.ComponentStyle были развёрнуты в отдельные панели, так?
спустя 18 часов [обр] Top manager(0/2)[досье]
Василий Свиридов[досье] верно, что бы были развернуты как и другие ветки данного объекта
Powered by POEM™ Engine Copyright © 2002-2005