コード例 #1
0
        public void create_list_control(UIAttribute attribute, Data_Member item)
        {
            List_Control control = new List_Control(attribute, (List <string>)item.get_value(receiver));

            add_below(control);

            connections.Add(item, control);
        }
コード例 #2
0
        public virtual MetaNode clone()
        {
            MetaNode new_node = (MetaNode)Activator.CreateInstance(GetType());

            foreach (Data_Member member in Data_Member.get_data_members(GetType()))
            {
                if (member.can_write)
                {
                    member.set_value(new_node, member.get_value(this));
                }
            }

            return(new_node);
        }
コード例 #3
0
        public Generic_Form(object new_receiver, string new_title)
        {
            InitializeComponent();
            initial_control_count = Controls.Count;

            receiver = new_receiver;
            Text     = new_title;

            Data_Member[] members = Data_Member.get_data_members(receiver.GetType());

            Dictionary <UIAttribute, Data_Member> dictionary = new Dictionary <UIAttribute, Data_Member>();
            List <UIAttribute> items = new List <UIAttribute>();

            foreach (Data_Member item in members)
            {
                UIAttribute attribute = item.get_custom_attribute(typeof(UIAttribute)) as UIAttribute;

                if (attribute != null)
                {
                    dictionary.Add(attribute, item);
                    items.Add(attribute);
                }
            }

            items.Sort(delegate(UIAttribute first, UIAttribute second)
                       { return(first.order.CompareTo(second.order)); });

            foreach (UIAttribute attribute in items)
            {
                Data_Member item = dictionary[attribute];

                if (item.member_type.IsGenericType)
                {
                    create_list_control(attribute, item);
                }
                else
                {
                    Label label = new Label();
                    label.Left  = border;
                    label.Text  = attribute.text;
                    label.Width = 60;
                    add_below(label);

                    TextBox box = new TextBox();
                    //add_below(label).Top = box.Top = 20 + (control_height * count);
                    //box.Left = 140;
                    box.ReadOnly = false;
                    box.Width    = 120;
                    box.Font     = new System.Drawing.Font("Courier New", 9.75F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
                    box.Text     = (string)item.get_value(receiver);
                    add_beside(box);
                    connections.Add(item, box);
                }
            }
            Button button = new Button();

            button.Text   = "&Accept";
            button.Click += new EventHandler(button_Add_Click);
            AcceptButton  = button;
            add_below(button);

            button        = new Button();
            button.Text   = "&Cancel";
            button.Click += new EventHandler(button_Cancel_Click);
            CancelButton  = button;
            add_beside(button);

            //            button_Accept.Top = button_Cancel.Top = count * control_height;
            this.Height = Controls[Controls.Count - 1].Bottom + 30;

            foreach (Control control in Controls)
            {
                if (control.Right + 5 > Width)
                {
                    Width = control.Right + border;
                }
            }
            Activate();
            Windows.bring_window_to_front(this.Handle);
            Windows.set_foreground_window(this.Handle);
        }