示例#1
0
        private List <string> GetCheckedItem_COM(TabPage tp_IndexName)
        {
            List <string> IndexName = new List <string>();

            for (int i = 0; i < tp_IndexName.Controls.Count; i++)
            {
                // 识别GroupBox控件;
                Type     type1    = tp_IndexName.Controls[i].GetType();
                GroupBox groupBox = new GroupBox();
                if (type1 == groupBox.GetType())
                {
                    groupBox = (GroupBox)tp_IndexName.Controls[i];
                    for (int j = 0; j < groupBox.Controls.Count; j++)
                    {
                        // 识别CheckBox控件;
                        CheckBox checkbox = new CheckBox();
                        string   str      = "";
                        Type     type2    = groupBox.Controls[j].GetType();
                        if (type2 == checkbox.GetType())
                        {
                            checkbox = (CheckBox)groupBox.Controls[j];
                            if (checkbox.Checked)
                            {
                                str = checkbox.Text;
                                str = str.Substring(0, str.IndexOf("("));
                                IndexName.Add(str);
                            }
                        }
                    }
                }
            }
            return(IndexName);
        }
示例#2
0
        private GroupBox CloneGroupBox(GroupBox source)
        {
            GroupBox target = (GroupBox)Activator.CreateInstance(source.GetType());

            CopyProperties(target, source);
            target.Name = source.Name;
            return(target);
        }
示例#3
0
        private List <string> GetCheckedItem_SPE(TabPage tabPage)
        {
            List <string> IndexName = new List <string>();
            string        str1      = "";

            for (int i = 0; i < tabPage.Controls.Count; i++)
            {
                Type        typ1        = tabPage.Controls[i].GetType();
                RadioButton radioButton = new RadioButton();
                if (typ1 == radioButton.GetType())
                {
                    radioButton = (RadioButton)tabPage.Controls[i];
                    if (radioButton.Checked)
                    {
                        str1 = radioButton.Text;
                        str1 = str1.Substring(0, str1.IndexOf("("));
                    }
                }
            }

            #region 识别选中的CheckBox
            for (int i = 0; i < tabPage.Controls.Count; i++)
            {
                Type     typ1     = tabPage.Controls[i].GetType();
                GroupBox groupBox = new GroupBox();
                if (typ1 == groupBox.GetType())
                {
                    groupBox = (GroupBox)tabPage.Controls[i];
                    for (int j = 0; j < groupBox.Controls.Count; j++)
                    {
                        // 识别CheckBox控件;
                        CheckBox checkBox = new CheckBox();
                        Type     type2    = groupBox.Controls[j].GetType();
                        if (type2 == checkBox.GetType())
                        {
                            string str2 = "";
                            checkBox = (CheckBox)groupBox.Controls[j];
                            if (checkBox.Checked)
                            {
                                str2 = checkBox.Text;
                                str2 = str2.Substring(0, str2.IndexOf("("));
                                IndexName.Add(str1 + "_" + str2);
                            }
                        }
                    }
                }
            }
            #endregion
            return(IndexName);
        }
            private GroupBox CreateGroupBox(string text, Size size, Font font, Point point)
            {
                GroupBox groupbox = new GroupBox();

                //groupbox.AutoSize = true;
                groupbox.Font      = font;
                groupbox.ForeColor = SystemColors.HighlightText;
                groupbox.Name      = text + groupbox.GetType().Name;
                groupbox.Text      = text;
                groupbox.Location  = point;
                groupbox.Size      = size;

                return(groupbox);
            }
示例#5
0
        private static void Drag_Drop(object sender, System.Windows.Forms.DragEventArgs e)
        {
            try
            {
                GroupBox self = sender as GroupBox;

                GroupBox ct = e.Data.GetData(self.GetType()) as GroupBox;

                if (self == ct)
                {
                    return;
                }

                Control parent = self.Parent;

                int ord = parent.Controls.GetChildIndex(self);

                int ordself = self.Top > ct.Top?ord + 1:ord - 1;

                DockStyle dss = self.Dock;
                self.Dock = ct.Dock;;
                ct.Dock   = dss;
                //				System.Drawing.Point dps=self.Location;
                //				self.Location=ct.Location;
                //				ct.Location=dps;

                if (ordself > ord)
                {
                    setPosition(self, ordself);
                    setPosition(ct, ord);
                }
                else
                {
                    setPosition(ct, ord);
                    setPosition(self, ordself);
                }
            }
            catch (Exception ee)
            {
                System.Windows.Forms.MessageBox.Show(ee.Message, "Error");
            }
        }
示例#6
0
        /// <summary>
        /// This is the method that actually does the work.
        /// </summary>
        /// <param name="DA">The DA object is used to retrieve from inputs and store in outputs.</param>
        protected override void SolveInstance(IGH_DataAccess DA)
        {
            List <string>           props = new List <string>();
            List <GH_ObjectWrapper> vals  = new List <GH_ObjectWrapper>();
            List <GH_ObjectWrapper> ctrls = new List <GH_ObjectWrapper>();

            DA.GetDataList(0, props);
            DA.GetDataList(1, vals);
            DA.GetDataList(2, ctrls);

            GroupBox gb = new GroupBox(); // container doesn't need id initialized

            for (int i = 0; i < props.Count; i++)
            {
                string n = props[i];
                object val;
                try { val = vals[i].Value; }
                catch (ArgumentOutOfRangeException)
                {
                    AddRuntimeMessage(GH_RuntimeMessageLevel.Error, "P, V should correspond each other");
                    return;
                }

                if (n.ToLower() == "size")
                {
                    if (val is GH_Point pt)
                    {
                        Size winsize = new Size((int)pt.Value.X, (int)pt.Value.Y);
                        gb.Size = winsize;
                    }
                    else if (val is GH_Vector vec)
                    {
                        Size winsize = new Size((int)vec.Value.X, (int)vec.Value.Y);
                        gb.Size = winsize;
                    }
                    else if (val is GH_String sstr)
                    {
                        string[] xy = sstr.Value.Split(',');
                        bool     xp = int.TryParse(xy[0], out int x);
                        bool     yp = int.TryParse(xy[1], out int y);
                        if (xp && yp)
                        {
                            gb.Size = new Size(x, y);
                        }
                        else
                        {
                            AddRuntimeMessage(GH_RuntimeMessageLevel.Warning, " text cannot be parsed as Size object");
                        }
                    }
                    else if (val is GH_Rectangle grec)
                    {
                        int x = (int)grec.Value.X.Length;
                        int y = (int)grec.Value.Y.Length;
                        gb.Size = new Size(x, y);
                    }
                    else if (val is GH_ComplexNumber gcomp)
                    {
                        int x = (int)gcomp.Value.Real;
                        int y = (int)gcomp.Value.Imaginary;
                        gb.Size = new Size(x, y);
                    }
                    else
                    {
                        try { Util.SetProp(gb, "Size", Util.GetGooVal(val)); }
                        catch (Exception ex) { AddRuntimeMessage(GH_RuntimeMessageLevel.Warning, ex.Message); }
                    }
                }
                else if (n.ToLower() == "padding")
                {
                    if (val is GH_Integer ghi)
                    {
                        gb.Padding = ghi.Value;
                    }
                    else if (val is GH_String gstr)
                    {
                        if (int.TryParse(gstr.Value, out int v))
                        {
                            gb.Padding = v;
                        }
                        else if (gstr.Value.Split(',') is string[] xy)
                        {
                            if (xy.Length == 2)
                            {
                                bool i0 = int.TryParse(xy[0], out int n0);
                                bool i1 = int.TryParse(xy[1], out int n1);
                                if (i0 && i1)
                                {
                                    gb.Padding = new Padding(n0, n1);
                                }
                                else
                                {
                                    AddRuntimeMessage(GH_RuntimeMessageLevel.Warning, " text cannot be parsed as Padding object");
                                }
                            }
                            else if (xy.Length == 4)
                            {
                                bool i0 = int.TryParse(xy[0], out int n0);
                                bool i1 = int.TryParse(xy[1], out int n1);
                                bool i2 = int.TryParse(xy[2], out int n2);
                                bool i3 = int.TryParse(xy[3], out int n3);
                                if (i0 && i1 && i2 && i3)
                                {
                                    gb.Padding = new Padding(n0, n1, n2, n3);
                                }
                                else
                                {
                                    AddRuntimeMessage(GH_RuntimeMessageLevel.Warning, " text cannot be parsed as Padding object");
                                }
                            }
                        }
                    }
                    else if (val is GH_Number gnum)
                    {
                        gb.Padding = (int)gnum.Value;
                    }
                    else if (val is GH_Point pt)
                    {
                        gb.Padding = new Padding((int)pt.Value.X, (int)pt.Value.Y);
                    }
                    else if (val is GH_Vector vec)
                    {
                        gb.Padding = new Padding((int)vec.Value.X, (int)vec.Value.Y);
                    }
                    else if (val is GH_Rectangle grec)
                    {
                        int x = (int)grec.Value.X.Length;
                        int y = (int)grec.Value.Y.Length;
                        gb.Padding = new Padding(x, y);
                    }
                    else if (val is GH_ComplexNumber gcomp)
                    {
                        int x = (int)gcomp.Value.Real;
                        int y = (int)gcomp.Value.Imaginary;
                        gb.Padding = new Padding(x, y);
                    }
                    else
                    {
                        try { Util.SetProp(gb, "Padding", Util.GetGooVal(val)); }
                        catch (Exception ex) { AddRuntimeMessage(GH_RuntimeMessageLevel.Warning, ex.Message); }
                    }
                }
                else if (n.ToLower() == "text" || n.ToLower() == "title")
                {
                    if (val is GH_String gstr)
                    {
                        gb.Text = gstr.Value;
                    }
                    else
                    {
                        gb.Text = val.ToString();
                    }
                }
                else
                {
                    try { Util.SetProp(gb, n, Util.GetGooVal(val)); }
                    catch (Exception ex) { AddRuntimeMessage(GH_RuntimeMessageLevel.Warning, ex.Message); }
                }
            }

            DynamicLayout content = new DynamicLayout()
            {
                DefaultPadding = 1,
            };

            foreach (GH_ObjectWrapper ghobj in ctrls)
            {
                if (ghobj.Value is Control ctrl)
                {
                    content.AddAutoSized(ctrl);
                }
                else
                {
                    AddRuntimeMessage(GH_RuntimeMessageLevel.Warning, " one or more object cannot be added\n are they non-Synapse components?");
                }
            }
            gb.Content = content;

            DA.SetData(1, new GH_ObjectWrapper(gb));

            PropertyInfo[] allprops  = gb.GetType().GetProperties();
            List <string>  printouts = new List <string>();

            foreach (PropertyInfo prop in allprops)
            {
                if (prop.CanWrite)
                {
                    printouts.Add(prop.Name + ": " + prop.PropertyType.ToString());
                }
            }
            DA.SetDataList(0, printouts);
        }