예제 #1
0
        // Puts all of the stuff where it belongs.
        public void createUI()
        {
            layout.DefaultSpacing = new Size(5, 5);
            layout.Padding        = new Padding(10, 10, 10, 10);

            layout.BeginHorizontal();

            layout.BeginVertical();
            layout.BeginGroup("Set Current User", new Padding(10, 10, 10, 10));
            layout.BeginHorizontal();
            layout.BeginVertical(padding: new Padding(0, 0, 0, 10));
            layout.AddAutoSized(new Label {
                Text = "Search User Name"
            });
            layout.BeginHorizontal();
            layout.AddAutoSized(nameBox);
            layout.AddAutoSized(search);
            layout.EndHorizontal();
            layout.EndVertical();
            layout.EndHorizontal();
            layout.BeginHorizontal();
            layout.BeginVertical(padding: new Padding(0, 0, 0, 10));
            layout.AddAutoSized(new Label {
                Text = "User IDs"
            });
            layout.AddAutoSized(nameList);
            layout.EndVertical();
            layout.EndHorizontal();
            layout.EndGroup();
            layout.EndVertical();

            layout.EndHorizontal();
        }
예제 #2
0
        public void OtherSidebarLayout(ref DynamicLayout layout)
        {
            // Other Sidebar
            layout.BeginVertical(null, null, false, true);

            // Sagittal
            layout.BeginVertical(null, null, false, true);
            layout.Add(new Label {
                Text = "Slice Thickness: " + RetrieveTag <decimal>(DicomTag.PixelSpacing, 0)
            });
            layout.Add(new Label {
                Text = "Slice Position: " + RetrieveTag <decimal>(DicomTag.PixelSpacing, 0) * nS
            });

            // Buttons
            layout.AddRow(new Label {
                Text = ""
            });
            layout.BeginHorizontal();
            layout.AddAutoSized(new Button {
                Text = "<", Command = prevS
            });
            layout.AddAutoSized(new Button {
                Text = ">", Command = nextS
            });
            layout.EndHorizontal();
            layout.AddRow(null);

            layout.EndVertical();

            // Coronal
            layout.BeginVertical(null, null, false, true);
            layout.Add(new Label {
                Text = "Slice Thickness: " + RetrieveTag <decimal>(DicomTag.PixelSpacing, 0)
            });
            layout.Add(new Label {
                Text = "Slice Position: " + RetrieveTag <decimal>(DicomTag.PixelSpacing, 0) * nC
            });

            // Buttons
            layout.AddRow(new Label {
                Text = ""
            });
            layout.BeginHorizontal();
            layout.AddAutoSized(new Button {
                Text = "<", Command = prevC
            });
            layout.AddAutoSized(new Button {
                Text = ">", Command = nextC
            });
            layout.EndHorizontal();
            layout.AddRow(null);

            layout.EndVertical();

            // End Other Sidebar
            layout.EndVertical();
        }
예제 #3
0
        public LinkButtonSection()
        {
            var layout = new DynamicLayout();

            layout.AddAutoSized(NormalButton(), centered: true);
            layout.AddAutoSized(LongerButton(), centered: true);
            layout.AddAutoSized(ColourButton(), centered: true);
            layout.AddAutoSized(DisabledButton(), centered: true);
            layout.AddAutoSized(DisabledButtonWithColor(), centered: true);
            layout.Add(StretchedButton());
            layout.Add(null);

            Content = layout;
        }
예제 #4
0
        ContextMenuSection(bool inDialog)
        {
            Styles.Add <Label>(null, l => l.VerticalAlignment = VerticalAlignment.Center);

            var relativeToLabelCheckBox = new CheckBox {
                Text = "Relative to label"
            };

            relativeToLabelCheckBox.CheckedBinding.Bind(this, c => c.RelativeToLabel);

            var useLocationCheckBox = new CheckBox {
                Text = "Use Location"
            };

            useLocationCheckBox.CheckedBinding.Bind(this, c => c.UseLocation);

            var locationInput = PointControl(() => location, p => location = p);

            var contextMenuLabel = CreateContextMenuLabel();

            var showInDialog = new Button {
                Text = "Show in Dialog"
            };

            showInDialog.Click += (sender, e) =>
            {
                var dlg = new Dialog {
                    Content = new ContextMenuSection(true)
                };
                dlg.ShowModal(this);
            };

            // layout

            var layout = new DynamicLayout();

            layout.BeginCentered();
            layout.AddAutoSized(relativeToLabelCheckBox);
            layout.AddSeparateRow(useLocationCheckBox, locationInput);
            if (!inDialog)
            {
                layout.AddAutoSized(showInDialog);
            }
            layout.EndCentered();

            layout.AddCentered(contextMenuLabel, yscale: true);

            Content = layout;
        }
예제 #5
0
        private void InitializeComponent()
        {
            Title  = "About";
            Width  = 300;
            Height = 300;

            DefaultButton.Visible = false;
            AbortButton.Visible  &= !Global.UseHeaderBar;
            AbortButton.Text      = "Close";

            dynamic1 = new DynamicLayout();
            dynamic1.DefaultSpacing = new Size(6, 6);
            dynamic1.Padding        = 6;
            dynamic1.BeginVertical();

            image1       = new ImageView();
            image1.Image = Bitmap.FromResource("Icons.monogame.png");
            if (Global.Unix)
            {
                image1.Height = 128;
            }
            dynamic1.Add(image1, true, true);

            labelTitle      = new Label();
            labelTitle.Font = new Font(labelTitle.Font.Family, labelTitle.Font.Size, FontStyle.Bold);
            labelTitle.Text = GetAttribute(typeof(AssemblyTitleAttribute));
            dynamic1.AddAutoSized(labelTitle, centered: true);

            labelVersion      = new Label();
            labelVersion.Text = Assembly.GetExecutingAssembly().GetName().Version.ToString();
            dynamic1.AddAutoSized(labelVersion, centered: true);

            labelDescription      = new Label();
            labelDescription.Text = GetAttribute(typeof(AssemblyDescriptionAttribute));
            dynamic1.AddAutoSized(labelDescription, centered: true);

            linkWebsite      = new LinkButton();
            linkWebsite.Text = "MonoGame Website";
            dynamic1.AddAutoSized(linkWebsite, centered: true);

            labelCopyright      = new Label();
            labelCopyright.Text = GetAttribute(typeof(AssemblyCopyrightAttribute));
            dynamic1.AddAutoSized(labelCopyright, centered: true);

            dynamic1.EndVertical();
            CreateContent(dynamic1);

            linkWebsite.Click += LinkWebsite_Click;
        }
예제 #6
0
        Control TestProperties()
        {
            var layout = new DynamicLayout {
                DefaultSpacing = new Size(5, 5)
            };
            DateTimePicker min, max, current, setValue;
            Button         setButton;

            layout.AddRow("Min Value", min = new DateTimePicker());
            layout.AddRow("Max Value", max = new DateTimePicker());
            layout.BeginHorizontal();
            layout.Add("Set to value");
            layout.BeginVertical(Padding.Empty);
            layout.BeginHorizontal();
            layout.AddAutoSized(setValue = new DateTimePicker());
            layout.Add(setButton         = new Button {
                Text = "Set"
            });
            layout.EndHorizontal();
            layout.EndVertical();
            layout.EndHorizontal();
            layout.AddRow("Value", current = new DateTimePicker());

            min.ValueChanged += (sender, e) => current.MinDate = min.Value ?? DateTime.MinValue;
            max.ValueChanged += (sender, e) => current.MaxDate = max.Value ?? DateTime.MaxValue;
            setButton.Click  += (sender, e) => current.Value = setValue.Value;
            LogEvents(current);

            return(layout);
        }
예제 #7
0
        public LinkButtonSection()
        {
            var layout = new DynamicLayout {
                DefaultSpacing = new Size(5, 5), Padding = new Padding(10)
            };

            layout.AddAutoSized(NormalButton(), centered: true);
            layout.AddAutoSized(LongerButton(), centered: true);
            layout.AddAutoSized(ColourButton(), centered: true);
            layout.AddAutoSized(DisabledButton(), centered: true);
            layout.AddAutoSized(DisabledButtonWithColor(), centered: true);
            layout.Add(StretchedButton());
            layout.Add(null);

            Content = layout;
        }
예제 #8
0
파일: EtoForm.cs 프로젝트: KaivnD/npkg
        public EtoForm()
        {
            ClientSize  = new Size(360, 60);
            Padding     = new Padding(8, 8);
            WindowStyle = WindowStyle.None;
            //Resizable = false;
            Opacity         = 0.5;
            ShowInTaskbar   = false;
            BackgroundColor = Color.FromArgb(20, 20, 20, 50);

            TextBox cmd = new TextBox()
            {
                TextAlignment   = TextAlignment.Center,
                BackgroundColor = Color.FromArgb(20, 20, 20, 50),
                ShowBorder      = false,
                TextColor       = Color.FromGrayscale(100),
                Font            = new Font("Microsoft YaHei UI", 26.25F),
                Size            = new Size(344, 45)
            };

            cmd.LostFocus += Cmd_LostFocus;

            DynamicLayout layout = new DynamicLayout();

            layout.AddAutoSized(cmd);

            Content = layout;
        }
예제 #9
0
        void Init()
        {
            _tbxShellData = new TextArea {
                Size = new Size(-1, 200)
            };
            _tbxMsg             = new TextBox();
            _btnShowMsgInStatus = new Button {
                Text = "Show Msg In Status", Width = 150
            };
            _btnShowMsgInStatus.Click += btn_showMsgInStatus_Click;
            _btnShowMessageBox         = new Button {
                Text = "Show Msg In Message", Width = 150
            };
            _btnShowMessageBox.Click += btn_showMessageBox_Click;
            _btnCreateNewTabPage      = new Button {
                Text = "Create New TabPage", Width = 150
            };
            _btnCreateNewTabPage.Click += btn_createNewTabPage_Click;

            // Test
            var btnTest = new Button {
                Text = "Test", Width = 150
            };

            btnTest.Click += btnTest_Click;

            var layout = new DynamicLayout {
                Padding = new Padding(10, 10), Size = new Size(10, 10)
            };

            layout.AddRow(new Label()
            {
                Text = "ShellData"
            });
            layout.AddRow(_tbxShellData);
            layout.AddSeparateRow(new Label()
            {
                Text = "Msg", VerticalAlign = VerticalAlign.Middle
            }, _tbxMsg, null);
            layout.AddAutoSized(_btnShowMsgInStatus);
            layout.AddAutoSized(_btnShowMessageBox);
            layout.AddAutoSized(_btnCreateNewTabPage);
            layout.AddAutoSized(btnTest);
            layout.Add(null);

            this.Content = layout;
        }
예제 #10
0
        public ButtonSection()
        {
            var layout = new DynamicLayout();

            layout.AddAutoSized(NormalButton(), centered: true);
            layout.AddAutoSized(LongerButton(), centered: true);
            layout.AddAutoSized(DefaultSizeButton(), centered: true);
            layout.AddAutoSized(ColourButton(), centered: true);
            layout.AddAutoSized(DisabledButton(), centered: true);
            layout.Add(StretchedButton());
            layout.AddSeparateRow(null, new Label {
                Text = "Image Position:", VerticalAlign = VerticalAlign.Middle
            }, ImagePositionControl(), null);
            layout.AddSeparateRow(null, TableLayout.AutoSized(ImageButton(smallImage)), TableLayout.AutoSized(ImageTextButton(smallImage)), null);
            layout.AddSeparateRow(null, TableLayout.AutoSized(ImageButton(largeImage)), TableLayout.AutoSized(ImageTextButton(largeImage)), null);

            layout.Add(null);

            Content = layout;
        }
예제 #11
0
        // Puts all of the stuff where it belongs.
        public void createUI()
        {
            layout.DefaultSpacing = new Size(5, 5);
            layout.Padding        = new Padding(10, 10, 10, 10);
            friendsGrid.Size      = new Size(450, 650);
            latestTips.Size       = new Size(1200, 650);

            layout.BeginHorizontal();

            layout.BeginHorizontal();
            layout.BeginGroup("Friends", new Padding(10, 10, 10, 10));
            layout.AddAutoSized(friendsGrid);
            layout.EndGroup();
            layout.BeginGroup("Latest Tips", new Padding(10, 10, 10, 10));
            layout.AddAutoSized(latestTips);
            layout.EndGroup();
            layout.EndHorizontal();

            layout.EndHorizontal();
        }
예제 #12
0
        public ButtonSection()
        {
            var layout = new DynamicLayout {
                DefaultSpacing = new Size(5, 5), Padding = new Padding(10)
            };

            layout.AddAutoSized(NormalButton(), centered: true);
            layout.AddAutoSized(LongerButton(), centered: true);
            layout.AddAutoSized(DefaultSizeButton(), centered: true);
            layout.AddAutoSized(ColourButton(), centered: true);
            layout.AddAutoSized(DisabledButton(), centered: true);
            layout.Add(StretchedButton());
            layout.AddSeparateRow(null, new Label {
                Text = "Image Position:", VerticalAlignment = VerticalAlignment.Center
            }, ImagePositionControl(), ClearMinimumSizeControl(), null);
            layout.AddSeparateRow(null, TableLayout.AutoSized(ImageButton(smallImage)), TableLayout.AutoSized(ImageTextButton(smallImage)), null);
            layout.AddSeparateRow(null, TableLayout.AutoSized(ImageButton(largeImage)), TableLayout.AutoSized(ImageTextButton(largeImage)), null);

            layout.Add(null);

            Content = layout;
        }
예제 #13
0
        Control CreateViews(Image image)
        {
            var layout = new DynamicLayout();

            layout.BeginHorizontal();
            layout.Add("ImageView");
            layout.AddAutoSized(new ImageView {
                Image = image
            });
            layout.AddAutoSized(new ImageView {
                Image = image, Size = new Size(64, 64)
            });
            layout.AddAutoSized(new ImageView {
                Image = image, Size = new Size(32, 32)
            });
            layout.EndBeginHorizontal();
            layout.Add("Drawable");
            layout.AddAutoSized(new DrawableImageView {
                Image = image
            });
            layout.AddAutoSized(new DrawableImageView {
                Image = image, MinimumSize = new Size(64, 64), ScaleImage = true
            });
            layout.AddAutoSized(new DrawableImageView {
                Image = image, MinimumSize = new Size(32, 32), ScaleImage = true
            });
            layout.EndBeginHorizontal();
            layout.Add("Button");
            layout.AddAutoSized(new Button {
                Image = image, Text = "Auto Size"
            });
            layout.AddAutoSized(new Button {
                Image = image, Text = "64px Height", Height = 64
            });
            layout.AddAutoSized(new Button {
                Image = image, Text = "32px Height", Height = 32
            });
            layout.EndBeginHorizontal();
            layout.EndHorizontal();
            return(layout);
        }
예제 #14
0
 protected virtual void CreateControls()
 {
     Layout = new DynamicLayout();
     if (DataType.HasFileType && fileTypes.Count > 1)
     {
         Layout.BeginHorizontal();
         Layout.Add(new Label {
             Text = "File Type", VerticalAlign = VerticalAlign.Middle
         });
         Layout.AddAutoSized(FileTypeComboBox());
         Layout.EndHorizontal();
     }
     foreach (var flag in DataType.Flags)
     {
         Layout.BeginHorizontal();
         Layout.Add(null, xscale: false);
         Layout.Add(flag.CreateControl());
         Layout.EndHorizontal();
     }
 }
예제 #15
0
        Control TestProperties()
        {
            var            layout = new DynamicLayout();
            DateTimePicker min, max, current, setValue;
            Button         setButton;

            layout.AddRow(new Label {
                Text = "Min Value"
            }, min = new DateTimePicker());
            layout.AddRow(new Label {
                Text = "Max Value"
            }, max = new DateTimePicker());
            layout.BeginHorizontal();
            layout.Add(new Label {
                Text = "Set to value"
            });
            layout.BeginVertical();
            layout.BeginHorizontal();
            layout.AddAutoSized(setValue = new DateTimePicker());
            layout.Add(setButton         = new Button {
                Text = "Set"
            });
            layout.EndHorizontal();
            layout.EndVertical();
            layout.EndHorizontal();
            layout.AddRow(new Label {
                Text = "Value"
            }, current = new DateTimePicker());

            min.ValueChanged += (sender, e) => current.MinDate = min.Value ?? DateTime.MinValue;
            max.ValueChanged += (sender, e) => current.MaxDate = max.Value ?? DateTime.MaxValue;
            setButton.Click  += (sender, e) => current.Value = setValue.Value;
            LogEvents(current);

            return(layout);
        }
예제 #16
0
        Control LeftPane()
        {
            var layout = new DynamicLayout();

            layout.DefaultPadding = Padding.Empty;
            layout.BeginVertical();
            layout.BeginHorizontal();
            layout.Add(new Label {
                Text = "Label", VerticalAlignment = VerticalAlignment.Center
            });
            layout.AddAutoSized(new Button {
                Text = "Button Control"
            }, centered: true);
            layout.Add(new ImageView {
                Image = icon1, Size = new Size(64, 64)
            });
            layout.Add(null);
            layout.EndHorizontal();
            layout.EndBeginVertical();
            layout.AddRow(new CheckBox {
                Text = "Check Box (/w three state)", ThreeState = true, Checked = null
            }, RadioButtons(), null);
            layout.EndBeginVertical();
            layout.AddRow(new TextBox {
                Text = "Text Box", Size = new Size(150, -1)
            }, new PasswordBox {
                Text = "Password Box", Size = new Size(150, -1)
            }, null);
            layout.EndBeginVertical();
            layout.AddRow(ComboBox(), new DateTimePicker {
                Value = DateTime.Now
            }, null);
            layout.EndBeginVertical();
            layout.AddRow(new NumericUpDown {
                Value = 50
            }, null);
            layout.EndBeginVertical();
            layout.AddRow(ListBox(), new TextArea {
                Text = "Text Area", Size = new Size(150, 50)
            }, null);
            layout.EndBeginVertical();
            layout.AddRow(new Slider {
                Value = 50, TickFrequency = 10
            });
            layout.EndBeginVertical();
            layout.AddRow(new ProgressBar {
                Value = 25
            });
            layout.EndBeginVertical();
            layout.AddRow(new GroupBox {
                Text = "Group Box", Content = new Label {
                    Text = "I'm in a group box"
                }
            });

            layout.EndBeginVertical();


            layout.EndVertical();
            layout.Add(null);

            return(layout);
        }
예제 #17
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);
        }
예제 #18
0
        /// <summary>
        /// This is the method that actually does the work.
        /// </summary>
        /// <param name="DA">The DA object can be used to retrieve data from input parameters and
        /// to store data in output parameters.</param>
        protected override void SolveInstance(IGH_DataAccess DA)
        {
            bool run = false;

            DA.GetData(0, ref run);
            List <string>           props    = new List <string>();
            bool                    param1   = DA.GetDataList(1, props);
            List <GH_ObjectWrapper> vals     = new List <GH_ObjectWrapper>();
            bool                    param2   = DA.GetDataList(2, vals);
            List <GH_ObjectWrapper> contents = new List <GH_ObjectWrapper>();

            DA.GetDataList(3, contents);

            if (EWindow == null)
            {
                EWindow = new Form()
                {
                    Height = 200,
                    Width  = 400,
                    Title  = "an Eto window",
                };
                EWindow.Closing  += EWClosing;
                EWindow.GotFocus += GhDocCheck;
            }
            else if (EWindow.Visible && !run)
            {
                EWindow.Close();
                OutputProps(DA);
                return;
            }
            else if (EWindow.Visible && run)
            {
                if (!ctrlredo)
                {
                    AddRuntimeMessage(GH_RuntimeMessageLevel.Warning, " open window will not be modified unless \"Repaint\" is unchecked");
                    return;
                }
                else
                {
                    EWindow.Content = null;
                }
            }

            //EWindow.Owner = Instances.EtoDocumentEditor;

            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);
                        EWindow.Size = winsize;
                    }
                    else if (val is GH_Vector vec)
                    {
                        Size winsize = new Size((int)vec.Value.X, (int)vec.Value.Y);
                        EWindow.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)
                        {
                            EWindow.Size = new Size(x, y);
                        }
                    }
                    else if (val is GH_Rectangle grec)
                    {
                        int x = (int)grec.Value.X.Length;
                        int y = (int)grec.Value.Y.Length;
                        EWindow.Size = new Size(x, y);
                    }
                    else if (val is GH_ComplexNumber gcomp)
                    {
                        int x = (int)gcomp.Value.Real;
                        int y = (int)gcomp.Value.Imaginary;
                        EWindow.Size = new Size(x, y);
                    }
                    else
                    {
                        try { Util.SetProp(EWindow, "Size", Util.GetGooVal(val)); }
                        catch (Exception ex) { AddRuntimeMessage(GH_RuntimeMessageLevel.Warning, ex.Message); }
                    }
                }
                else if (n.ToLower() == "title")
                {
                    Util.SetProp(EWindow, "Title", Util.GetGooVal(val).ToString());
                }
                else if (n.ToLower() == "opacity" || n.ToLower() == "transparency")
                {
                    if (val is GH_Number perct)
                    {
                        Util.SetProp(EWindow, "Opacity", perct.Value);
                    }
                    else if (val is GH_String pstr)
                    {
                        if (double.TryParse(pstr.Value, out double pc))
                        {
                            Util.SetProp(EWindow, "Opacity", pc);
                        }
                    }
                    else
                    {
                        try { Util.SetProp(EWindow, "Opacity", Util.GetGooVal(val)); }
                        catch (Exception ex) { AddRuntimeMessage(GH_RuntimeMessageLevel.Warning, ex.Message); }
                    }
                }
                else if (n.ToLower() == "backgroundcolor" || n.ToLower() == "color" || n.ToLower() == "background color")
                {
                    if (val is GH_Colour gclr)
                    {
                        EWindow.BackgroundColor = Color.FromArgb(gclr.Value.ToArgb());
                    }
                    else if (val is GH_String cstr)
                    {
                        if (Color.TryParse(cstr.Value, out Color clr))
                        {
                            EWindow.BackgroundColor = clr;
                        }
                    }
                    else if (val is GH_Point pt)
                    {
                        Color clr = Color.FromArgb((int)pt.Value.X, (int)pt.Value.Y, (int)pt.Value.Z);
                        EWindow.BackgroundColor = clr;
                    }
                    else if (val is GH_Vector vec)
                    {
                        Color clr = Color.FromArgb((int)vec.Value.X, (int)vec.Value.Y, (int)vec.Value.Z);
                        EWindow.BackgroundColor = clr;
                    }
                    else if (val is IEnumerable <int> nums)
                    {
                        int[] c = nums.ToArray();
                        if (c.Length == 3)
                        {
                            Color clr = Color.FromArgb(c[0], c[1], c[2]);
                            EWindow.BackgroundColor = clr;
                        }
                        else if (c.Length == 4)
                        {
                            Color clr = Color.FromArgb(c[0], c[1], c[2], c[3]);
                            EWindow.BackgroundColor = clr;
                        }
                    }
                    else if (val is Color etoclr)
                    {
                        EWindow.BackgroundColor = etoclr;
                    }
                    else
                    {
                        try { Util.SetProp(EWindow, "BackgroundColor", Util.GetGooVal(val)); }
                        catch (Exception ex) { AddRuntimeMessage(GH_RuntimeMessageLevel.Warning, ex.Message); }
                    }
                }
                else if (n.ToLower() == "location" || n.ToLower() == "position")
                {
                    if (val is GH_Point pt)
                    {
                        Util.SetProp(EWindow, "Location", new Eto.Drawing.Point((int)pt.Value.X, (int)pt.Value.Y));
                    }
                    else if (val is GH_Vector vec)
                    {
                        Util.SetProp(EWindow, "Location", new Eto.Drawing.Point((int)vec.Value.X, (int)vec.Value.Y));
                    }
                    else if (val is GH_String locstr)
                    {
                        if (Point3d.TryParse(locstr.Value, out Point3d rhpt))
                        {
                            Util.SetProp(EWindow, "Location", new Eto.Drawing.Point((int)rhpt.X, (int)rhpt.Y));
                        }
                    }
                    else if (val is GH_Rectangle grec)
                    {
                        int x = (int)grec.Value.X.Length;
                        int y = (int)grec.Value.Y.Length;
                        EWindow.Location = new Eto.Drawing.Point(x, y);
                    }
                    else if (val is GH_ComplexNumber gcomp)
                    {
                        int x = (int)gcomp.Value.Real;
                        int y = (int)gcomp.Value.Imaginary;
                        EWindow.Location = new Eto.Drawing.Point(x, y);
                    }
                    else
                    {
                        try { Util.SetProp(EWindow, "Location", Util.GetGooVal(val)); }
                        catch (Exception ex) { AddRuntimeMessage(GH_RuntimeMessageLevel.Warning, ex.Message); }
                    }
                }
                else if (n.ToLower() == "padding")
                {
                    if (val is GH_Point pt)
                    {
                        Util.SetProp(EWindow, "Padding", new Eto.Drawing.Padding((int)pt.Value.X, (int)pt.Value.Y));
                    }
                    else if (val is GH_Vector vec)
                    {
                        Util.SetProp(EWindow, "Padding", new Eto.Drawing.Padding((int)vec.Value.X, (int)vec.Value.Y));
                    }
                    else if (val is GH_String pstr)
                    {
                        string[] subs = pstr.Value.Split(',');
                        if (subs.Length == 2)
                        {
                            bool i0 = int.TryParse(subs[0], out int n0);
                            bool i1 = int.TryParse(subs[1], out int n1);
                            if (i0 && i1)
                            {
                                Util.SetProp(EWindow, "Padding", new Eto.Drawing.Padding(n0, n1));
                            }
                        }
                        else if (subs.Length == 4)
                        {
                            bool i0 = int.TryParse(subs[0], out int n0);
                            bool i1 = int.TryParse(subs[1], out int n1);
                            bool i2 = int.TryParse(subs[2], out int n2);
                            bool i3 = int.TryParse(subs[3], out int n3);
                            if (i0 && i1 && i2 && i3)
                            {
                                Util.SetProp(EWindow, "Padding", new Eto.Drawing.Padding(n0, n1, n2, n3));
                            }
                        }
                    }
                    else if (val is GH_Integer pad)
                    {
                        Util.SetProp(EWindow, "Padding", new Eto.Drawing.Padding(pad.Value));
                    }
                    else if (val is GH_Rectangle grec)
                    {
                        int x = (int)grec.Value.X.Length;
                        int y = (int)grec.Value.Y.Length;
                        EWindow.Padding = new Padding(x, y);
                    }
                    else if (val is GH_ComplexNumber gcomp)
                    {
                        int x = (int)gcomp.Value.Real;
                        int y = (int)gcomp.Value.Imaginary;
                        EWindow.Padding = new Padding(x, y);
                    }
                    else
                    {
                        try { Util.SetProp(EWindow, "Padding", Util.GetGooVal(val)); }
                        catch (Exception ex) { AddRuntimeMessage(GH_RuntimeMessageLevel.Warning, ex.Message); }
                    }
                }
                else if (n == "WindowStyle" || n == "window style")
                {
                    if (val is GH_Boolean b)
                    {
                        WindowStyle style;
                        if (b.Value)
                        {
                            style = WindowStyle.Default;
                        }
                        else
                        {
                            style = WindowStyle.None;
                        }
                        Util.SetProp(EWindow, "WindowStyle", style);
                    }
                    else if (val is GH_String bstr)
                    {
                        if (int.TryParse(bstr.Value, out int ws))
                        {
                            switch (ws)
                            {
                            case 0:
                                Util.SetProp(EWindow, "WindowStyle", WindowStyle.Default);
                                break;

                            case 1:
                                Util.SetProp(EWindow, "WindowStyle", WindowStyle.None);
                                break;

                            case 2:
                                Util.SetProp(EWindow, "WindowStyle", WindowStyle.Utility);
                                break;

                            default:
                                break;
                            }
                        }
                    }
                    else if (val is GH_Integer inum)
                    {
                        Util.SetProp(EWindow, "WindowStyle", inum.Value);
                    }
                    else if (val is GH_Number num)
                    {
                        Util.SetProp(EWindow, "WindowStyle", (int)num.Value);
                    }
                    else
                    {
                        try { Util.SetProp(EWindow, "WindowStyle", Util.GetGooVal(val)); }
                        catch (Exception ex) { AddRuntimeMessage(GH_RuntimeMessageLevel.Warning, ex.Message); }
                    }
                }
                else
                {
                    try { Util.SetProp(EWindow, n, Util.GetGooVal(val)); }
                    catch (Exception ex) { AddRuntimeMessage(GH_RuntimeMessageLevel.Warning, ex.Message); }
                }
            }

            DynamicLayout bucket = new DynamicLayout();

            try
            {
                foreach (GH_ObjectWrapper ghobj in contents)
                {
                    if (ghobj.Value is Control ctrl)
                    {
                        if (ctrlfill)
                        {
                            bucket.Add(ctrl);
                        }
                        else
                        {
                            bucket.AddAutoSized(ctrl);
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                if (ex is NullReferenceException || ex is ArgumentNullException)
                {
                    AddRuntimeMessage(GH_RuntimeMessageLevel.Warning, " invalid controls detected");
                }
                else
                {
                    throw ex;
                }
            }
            Scrollable content = new Scrollable {
                Content = bucket, Border = BorderType.None
            };

            EWindow.Content = content;

            if (run)
            {
                EWindow.Show();
            }
            OutputProps(DA);
        }
예제 #19
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);

            Scrollable    scroll = new Scrollable();
            DynamicLayout layout = new DynamicLayout();

            foreach (GH_ObjectWrapper gho in ctrls)
            {
                if (gho.Value is Control c)
                {
                    layout.AddAutoSized(c);
                }
            }
            scroll.Content = layout;

            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() == "border" || n.ToLower() == "bordertype")
                {
                    if (val is GH_String gstr)
                    {
                        switch (gstr.Value.ToLower())
                        {
                        case "bezel":
                            scroll.Border = BorderType.Bezel;
                            break;

                        case "line":
                            scroll.Border = BorderType.Line;
                            break;

                        case "none":
                            scroll.Border = BorderType.None;
                            break;

                        default:
                            scroll.Border = BorderType.None;
                            break;
                        }
                    }
                    else if (val is GH_Integer gint)
                    {
                        switch (gint.Value)
                        {
                        case 0:
                            scroll.Border = BorderType.Bezel;
                            break;

                        case 1:
                            scroll.Border = BorderType.Line;
                            break;

                        case 2:
                            scroll.Border = BorderType.None;
                            break;

                        default:
                            scroll.Border = BorderType.None;
                            break;
                        }
                    }
                    else
                    {
                        try { Util.SetProp(scroll, "Border", Util.GetGooVal(val)); }
                        catch (Exception ex) { AddRuntimeMessage(GH_RuntimeMessageLevel.Warning, ex.Message); }
                    }
                }
                else if (n.ToLower() == "padding")
                {
                    if (val is GH_Point pt)
                    {
                        scroll.Padding = new Padding((int)pt.Value.X, (int)pt.Value.Y);
                    }
                    else if (val is GH_Vector vec)
                    {
                        scroll.Padding = new Padding((int)vec.Value.X, (int)vec.Value.Y);
                    }
                    else if (val is GH_String pstr)
                    {
                        string[] subs = pstr.Value.Split(',');
                        if (subs.Length == 2)
                        {
                            bool i0 = int.TryParse(subs[0], out int n0);
                            bool i1 = int.TryParse(subs[1], out int n1);
                            if (i0 && i1)
                            {
                                scroll.Padding = new Padding(n0, n1);
                            }
                        }
                        else if (subs.Length == 4)
                        {
                            bool i0 = int.TryParse(subs[0], out int n0);
                            bool i1 = int.TryParse(subs[1], out int n1);
                            bool i2 = int.TryParse(subs[2], out int n2);
                            bool i3 = int.TryParse(subs[3], out int n3);
                            if (i0 && i1 && i2 && i3)
                            {
                                scroll.Padding = new Padding(n0, n1, n2, n3);
                            }
                        }
                    }
                    else if (val is GH_Integer pad)
                    {
                        scroll.Padding = new Padding(pad.Value);
                    }
                    else if (val is GH_Rectangle grec)
                    {
                        int x = (int)grec.Value.X.Length;
                        int y = (int)grec.Value.Y.Length;
                        scroll.Padding = new Padding(x, y);
                    }
                    else if (val is GH_ComplexNumber gcomp)
                    {
                        int x = (int)gcomp.Value.Real;
                        int y = (int)gcomp.Value.Imaginary;
                        scroll.Padding = new Padding(x, y);
                    }
                    else
                    {
                        try { Util.SetProp(scroll, "Padding", Util.GetGooVal(val)); }
                        catch (Exception ex) { AddRuntimeMessage(GH_RuntimeMessageLevel.Warning, ex.Message); }
                    }
                }
                else
                {
                    try { Util.SetProp(scroll, n, Util.GetGooVal(val)); }
                    catch (Exception ex) { AddRuntimeMessage(GH_RuntimeMessageLevel.Warning, ex.Message); }
                }
            }

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

            PropertyInfo[] allprops  = scroll.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);
        }
예제 #20
0
        // Creates and places all of the UI elements. This is particularly
        // nasty looking. There is probably a better way to do this, but idk.
        // https://github.com/picoe/Eto/wiki/DynamicLayout
        public void createUI()
        {
            layout.Padding        = new Padding(10, 0, 10, 10);
            grid.Size             = new Size(1000, 1000);
            layout.DefaultSpacing = new Size(5, 5);

            SelectSort.DataStore = SortStore;

            layout.BeginHorizontal();

            layout.BeginVertical();

            layout.BeginHorizontal();
            layout.BeginGroup("User Info", new Padding(10, 10, 10, 10));

            layout.BeginHorizontal();
            layout.BeginVertical(padding: new Padding(0, 0, 0, 10));
            layout.AddAutoSized(user);
            layout.EndVertical();
            layout.AddAutoSized(userlogin);
            layout.EndHorizontal();

            layout.BeginVertical();
            layout.BeginHorizontal();
            layout.AddAutoSized(new Label {
                Text = "User Name:"
            });
            layout.AddAutoSized(usernameBox);
            layout.EndHorizontal();
            layout.BeginHorizontal();
            layout.AddAutoSized(new Label {
                Text = "Yelping Since:"
            });
            layout.AddAutoSized(dateBox);
            layout.EndHorizontal();
            layout.BeginHorizontal();
            layout.AddAutoSized(new Label {
                Text = "Stars:"
            });
            layout.AddAutoSized(starsBox);
            layout.EndHorizontal();
            layout.BeginHorizontal();
            layout.AddAutoSized(new Label {
                Text = "Number of Fans:"
            });
            layout.AddAutoSized(fansBox);
            layout.EndHorizontal();
            layout.BeginHorizontal();
            layout.AddAutoSized(new Label {
                Text = "Funny:"
            });
            layout.AddAutoSized(funnyBox);
            layout.EndHorizontal();
            layout.BeginHorizontal();
            layout.AddAutoSized(new Label {
                Text = "Cool:"
            });
            layout.AddAutoSized(coolBox);
            layout.EndHorizontal();
            layout.BeginHorizontal();
            layout.AddAutoSized(new Label {
                Text = "Useful:"
            });
            layout.AddAutoSized(usefulBox);
            layout.EndHorizontal();
            layout.BeginHorizontal();
            layout.AddAutoSized(new Label {
                Text = "Number of Tips:"
            });
            layout.AddAutoSized(tipcountBox);
            layout.EndHorizontal();
            layout.BeginHorizontal();
            layout.AddAutoSized(new Label {
                Text = "Number of Likes:"
            });
            layout.AddAutoSized(totallikesBox);
            layout.EndHorizontal();
            layout.BeginHorizontal();
            layout.AddAutoSized(new Label {
                Text = "Latitude:"
            });
            layout.AddAutoSized(latitudeBox);
            layout.EndHorizontal();
            layout.BeginHorizontal();
            layout.AddAutoSized(new Label {
                Text = "Longitude:"
            });
            layout.AddAutoSized(longitudeBox);
            layout.EndHorizontal();
            layout.AddAutoSized(updateLocation);
            layout.EndVertical();

            layout.EndGroup();
            layout.EndHorizontal();

            layout.BeginGroup("Location", new Padding(10, 10, 10, 10));

            layout.BeginHorizontal();
            //layout.BeginVertical(padding: new Padding(0, 10, 0, 10));
            layout.AddAutoSized(new Label {
                Text = "State"
            });
            layout.AddAutoSized(stateList);
            //layout.EndVertical();
            layout.EndHorizontal();

            layout.BeginHorizontal();
            layout.BeginVertical(padding: new Padding(0, 0, 0, 10));
            layout.AddAutoSized(new Label {
                Text = "City"
            });
            layout.AddAutoSized(cityList);
            layout.EndVertical();
            layout.EndHorizontal();

            layout.BeginHorizontal();
            layout.BeginVertical(padding: new Padding(0, 0, 0, 10));
            layout.AddAutoSized(new Label {
                Text = "Zip Code"
            });
            layout.AddAutoSized(zipList);
            layout.AddAutoSized(new Label {
                Text = "Businesses in State:"
            });
            layout.AddAutoSized(stnum);
            layout.AddAutoSized(new Label {
                Text = "Businesses in City:"
            });
            layout.AddAutoSized(ctnum);
            layout.EndVertical();
            layout.EndHorizontal();

            layout.EndGroup();

            layout.BeginGroup("Sort By", new Padding(10, 10, 10, 10));
            layout.AddAutoSized(SelectSort);
            layout.EndGroup();

            layout.EndVertical();

            layout.BeginVertical(new Padding(10, 0, 0, 0));
            layout.BeginGroup("Search Results");
            layout.BeginCentered();
            layout.AddAutoSized(grid);
            layout.EndCentered();
            layout.EndGroup();
            layout.EndVertical();

            layout.BeginVertical();

            layout.BeginGroup("Categories", new Padding(10, 10, 10, 10));

            layout.BeginHorizontal();
            layout.BeginVertical(padding: new Padding(0, 0, 0, 10));
            layout.AddAutoSized(new Label {
                Text = "Category"
            });
            layout.AddAutoSized(catList);
            layout.EndVertical();
            layout.EndHorizontal();

            layout.BeginHorizontal();
            layout.BeginVertical(padding: new Padding(0, 0, 0, 10));
            layout.AddAutoSized(new Label {
                Text = "Selected Categories"
            });
            layout.AddAutoSized(selectedCats);
            layout.BeginHorizontal();
            layout.AddAutoSized(add_cat);
            layout.AddAutoSized(remove_cat);
            layout.EndHorizontal();
            layout.EndVertical();
            layout.EndHorizontal();

            layout.EndGroup();

            layout.BeginGroup("Filters", new Padding(10, 10, 10, 10));

            layout.BeginHorizontal();
            layout.BeginVertical(padding: new Padding(0, 0, 0, 10));
            layout.AddAutoSized(new Label {
                Text = "Price"
            });
            layout.AddAutoSized(priceFilters);
            layout.EndVertical();
            layout.EndHorizontal();

            layout.BeginHorizontal();
            layout.BeginVertical(padding: new Padding(0, 0, 0, 10));
            layout.AddAutoSized(new Label {
                Text = "Attributes"
            });
            layout.AddAutoSized(attributeFilters);
            layout.EndVertical();
            layout.EndHorizontal();

            layout.BeginHorizontal();
            layout.BeginVertical(padding: new Padding(0, 0, 0, 10));
            layout.AddAutoSized(new Label {
                Text = "Meal"
            });
            layout.AddAutoSized(mealFilters);
            layout.BeginHorizontal();
            layout.AddAutoSized(add_att);
            layout.AddAutoSized(remove_att);
            layout.EndHorizontal();
            layout.EndVertical();
            layout.EndHorizontal();

            layout.BeginHorizontal();
            layout.BeginVertical(padding: new Padding(0, 0, 0, 10));
            layout.AddAutoSized(new Label {
                Text = "Selected Attributes"
            });
            layout.AddAutoSized(selectedAtts);
            layout.EndVertical();
            layout.EndHorizontal();

            layout.EndGroup();

            layout.BeginCentered();
            layout.AddAutoSized(search);
            layout.EndCentered();

            layout.EndVertical();

            layout.EndHorizontal();
        }
예제 #21
0
        /// <summary>
        /// Layout for the Form
        /// TODO: Store images in Panel and use mouse data!!!
        /// </summary>
        /// <param name="layout">Layout Variable (reference)</param>
        ///

        public void SidebarLayout(ref DynamicLayout layout)
        {
            // General Info
            layout.BeginVertical(null, null, false, false);
            layout.Add(new Label {
                Text = "Patient Name: " + RetrieveTag <string>(DicomTag.PatientName, 0), TextColor = Colors.Green
            });

            // Patient Info
            layout.AddRow(new Label {
                Text = ""
            });
            layout.AddRow(new Label {
                Text = "Patient Information", TextColor = Colors.Red
            });
            layout.Add(new Label {
                Text = "Gender: " + RetrieveTag <string>(DicomTag.PatientSex, 0)
            });
            layout.Add(new Label {
                Text = "Age: " + RetrieveTag <string>(DicomTag.PatientAge, 0)
            });
            layout.Add(new Label {
                Text = "Weight: " + RetrieveTag <string>(DicomTag.PatientWeight, 0)
            });

            // Image Info
            layout.AddRow(new Label {
                Text = ""
            });
            layout.AddRow(new Label {
                Text = "Image Information", TextColor = Colors.Red
            });
            layout.Add(new Label {
                Text = "Modality: " + RetrieveTag <string>(nT, DicomTag.Modality, 0)
            });
            //layout.Add(new Label { Text = "Description: " + RetrieveTag<string>(nT, DicomTag.SeriesDescription, 0) });
            layout.Add(new Label {
                Text = "Date: " + Date(RetrieveTag <string>(nT, DicomTag.AcquisitionDate, 0))
            });
            layout.Add(new Label {
                Text = "Time: " + Time(RetrieveTag <string>(nT, DicomTag.AcquisitionTime, 0))
            });
            layout.Add(new Label {
                Text = "Slice Thickness: " + slices[nT].sliceThickness
            });
            layout.Add(new Label {
                Text = "Slice Position: " + slices[nT].sliceLocation + "mm"
            });

            // Buttons
            layout.AddRow(new Label {
                Text = ""
            });
            layout.BeginHorizontal();
            layout.AddAutoSized(new Button {
                Text = "<", Command = prevT
            });
            layout.AddAutoSized(new Button {
                Text = ">", Command = nextT
            });

            // End of UI
            layout.EndHorizontal();
            layout.AddRow(null);
            layout.EndVertical();
            layout.EndVertical();
        }
예제 #22
0
        private void InitializeComponent()
        {
            var layout_left = new DynamicLayout {
                Padding = new Padding(10, 5, 5, 5), Spacing = new Size(5, 5), ClientSize = new Size(345, 426), MinimumSize = new Size(345, 426)
            };
            var layout_right = new DynamicLayout {
                Padding = new Padding(5, 5, 5, 5), Spacing = new Size(5, 5), ClientSize = new Size(180, 426), MinimumSize = new Size(180, 426)
            };

            var layout_serialPort = new DynamicLayout {
                Padding = new Padding(5, 15, 5, 5), Spacing = new Size(5, 5)
            };


            _textAreaIn = new TextArea()
            {
                BackgroundColor = Colors.Black, TextColor = Colors.SpringGreen,
            };
            _textAreaOut = new TextArea()
            {
                BackgroundColor = Colors.Black, TextColor = Colors.SpringGreen,
            };
            layout_left.AddAutoSized(new Label()
            {
                Text = "接收区"
            });
            layout_left.AddSeparateRow(new Panel()
            {
                Content = _textAreaIn, MinimumSize = new Size(345, 240), ClientSize = new Size(345, 240)
            });
            layout_left.AddAutoSized(new Label()
            {
                Text = "发送区"
            });
            layout_left.AddSeparateRow(new Panel()
            {
                Content = _textAreaOut, MinimumSize = new Size(345, 165), ClientSize = new Size(345, 165)
            });

            _comboBoxSerialPortName = new ComboBox();
            _comboBoxSerialBaudRate = new ComboBox();
            _comboBoxSerialDataBits = new ComboBox();
            _comboBoxSerialParity   = new ComboBox();
            _comboBoxSerialStopBits = new ComboBox();

            _btnClear = new Button {
                Text = "清空收区"
            };
            _btnOpen = new Button {
                Text = "打开串口"
            };
            _btnSend = new Button {
                Text = "串口发送"
            };
            _checkBoxHex = new CheckBox {
                Text = "是否Hex"
            };
            label7 = new Label();

            layout_serialPort.BeginVertical();
            layout_serialPort.BeginHorizontal();
            layout_serialPort.AddAutoSized(new Label()
            {
                Text = "端口号:"
            }, new Padding(0, 3));
            layout_serialPort.AddAutoSized(_comboBoxSerialPortName);
            layout_serialPort.EndBeginHorizontal();
            layout_serialPort.BeginHorizontal();
            layout_serialPort.AddAutoSized(new Label()
            {
                Text = "波特率:"
            }, new Padding(0, 3));
            layout_serialPort.AddAutoSized(_comboBoxSerialBaudRate);
            layout_serialPort.EndBeginHorizontal();
            layout_serialPort.BeginHorizontal();
            layout_serialPort.AddAutoSized(new Label()
            {
                Text = "数据位:"
            }, new Padding(0, 3));
            layout_serialPort.AddAutoSized(_comboBoxSerialDataBits);
            layout_serialPort.EndBeginHorizontal();
            layout_serialPort.BeginHorizontal();
            layout_serialPort.AddAutoSized(new Label()
            {
                Text = "效验位:"
            }, new Padding(0, 3));
            layout_serialPort.AddAutoSized(_comboBoxSerialParity);
            layout_serialPort.EndBeginHorizontal();
            layout_serialPort.BeginHorizontal();
            layout_serialPort.AddAutoSized(new Label()
            {
                Text = "停止位:"
            }, new Padding(0, 3));
            layout_serialPort.AddAutoSized(_comboBoxSerialStopBits);
            layout_serialPort.EndBeginHorizontal();
            //layout_serialPort.AddColumn();
            //layout_serialPort.AddColumn();

            layout_serialPort.EndBeginVertical();

            layout_right.AddAutoSized(layout_serialPort);
            layout_right.AddCentered(new Panel()
            {
                Content = _btnClear, ClientSize = new Size(164, 37), MinimumSize = new Size(164, 37)
            }, null, null, true);
            layout_right.AddCentered(new Panel()
            {
                Content = _btnOpen, ClientSize = new Size(164, 37), MinimumSize = new Size(164, 37)
            }, new Padding(0, 80, 0, 0), null, true);
            layout_right.AddCentered(new Panel()
            {
                Content = _btnSend, ClientSize = new Size(164, 37), MinimumSize = new Size(164, 37)
            }, new Padding(0, 10), null, true);
            layout_right.AddCentered(_checkBoxHex);
            layout_right.AddAutoSized(label7);

            var layout = new Splitter()
            {
                Panel1      = layout_left,
                Panel2      = layout_right,
                Orientation = SplitterOrientation.Horizontal
            };
        }
예제 #23
0
        // Puts all of the stuff where it belongs.
        public void createUI(string bid)
        {
            layout.DefaultSpacing = new Size(15, 5);
            layout.Padding        = new Padding(10, 10, 10, 10);
            general_grid.Size     = new Size(800, 400);
            friend_grid.Size      = new Size(800, 100);

            layout.BeginVertical();

            layout.BeginGroup("Buisness Info", new Padding(10, 10, 200, 10));
            layout.BeginHorizontal();

            layout.BeginVertical();
            layout.BeginHorizontal();
            layout.AddAutoSized(new Label {
                Text = "Business Name:"
            });
            layout.AddAutoSized(businessname);
            layout.EndHorizontal();
            layout.BeginHorizontal();
            layout.AddAutoSized(new Label {
                Text = "Street Address:"
            });
            layout.AddAutoSized(streetaddress);
            layout.EndHorizontal();
            layout.BeginHorizontal();
            layout.AddAutoSized(new Label {
                Text = "Today's Hours:"
            });
            layout.AddAutoSized(openHours);
            layout.EndHorizontal();
            layout.EndBeginVertical();

            layout.BeginHorizontal();
            layout.BeginGroup("Business Attributes", new Padding(10, 10, 10, 10));
            layout.AddAutoSized(attributes);
            layout.EndGroup();
            layout.BeginGroup("Business Categories", new Padding(10, 10, 10, 10));
            layout.AddAutoSized(categories);
            layout.EndGroup();
            layout.EndHorizontal();

            layout.EndHorizontal();
            layout.EndGroup();



            layout.BeginGroup("Friend Tips", new Padding(10, 10, 10, 10));
            layout.BeginHorizontal();
            layout.AddAutoSized(friend_grid);
            layout.EndHorizontal();
            layout.EndGroup();

            layout.BeginGroup("Tips", new Padding(10, 10, 10, 10));
            layout.BeginHorizontal();
            layout.AddAutoSized(general_grid);

            layout.BeginVertical();
            layout.AddAutoSized(addLike);
            layout.AddAutoSized(checkIn);
            layout.AddAutoSized(checkinGraph);
            layout.EndVertical();

            layout.EndHorizontal();
            layout.BeginHorizontal();
            layout.AddAutoSized(newTip);
            layout.AddAutoSized(addTip);
            layout.EndHorizontal();
            layout.EndGroup();


            layout.EndVertical();
        }
예제 #24
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);

            DynamicLayout dyna = new DynamicLayout();

            List <GH_ObjectWrapper> valids = ctrls.FindAll(c => c.Value is Control ctrl);

            Control[] added = valids.Select(c => c.Value as Control).ToArray();

            //set props
            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);
                        dyna.Size = winsize;
                    }
                    else if (val is GH_Vector vec)
                    {
                        Size winsize = new Size((int)vec.Value.X, (int)vec.Value.Y);
                        dyna.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)
                        {
                            dyna.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;
                        dyna.Size = new Size(x, y);
                    }
                    else if (val is GH_ComplexNumber gcomp)
                    {
                        int x = (int)gcomp.Value.Real;
                        int y = (int)gcomp.Value.Imaginary;
                        dyna.Size = new Size(x, y);
                    }
                    else
                    {
                        try { Util.SetProp(dyna, "Size", Util.GetGooVal(val)); }
                        catch (Exception ex) { AddRuntimeMessage(GH_RuntimeMessageLevel.Warning, ex.Message); }
                    }
                }
                else if (n.ToLower() == "padding")
                {
                    if (val is GH_Integer ghi)
                    {
                        dyna.Padding = ghi.Value;
                    }
                    else if (val is GH_String gstr)
                    {
                        if (int.TryParse(gstr.Value, out int v))
                        {
                            dyna.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)
                                {
                                    dyna.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)
                                {
                                    dyna.Padding = new Padding(n0, n1, n2, n3);
                                }
                                else
                                {
                                    AddRuntimeMessage(GH_RuntimeMessageLevel.Warning, " text cannot be parsed as Padding object");
                                }
                            }
                        }
                    }
                    else if (val is GH_Point pt)
                    {
                        dyna.Padding = new Padding((int)pt.Value.X, (int)pt.Value.Y);
                    }
                    else if (val is GH_Vector vec)
                    {
                        dyna.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;
                        dyna.Padding = new Padding(x, y);
                    }
                    else if (val is GH_ComplexNumber gcomp)
                    {
                        int x = (int)gcomp.Value.Real;
                        int y = (int)gcomp.Value.Imaginary;
                        dyna.Padding = new Padding(x, y);
                    }
                    else
                    {
                        try { Util.SetProp(dyna, "Padding", Util.GetGooVal(val)); }
                        catch (Exception ex) { AddRuntimeMessage(GH_RuntimeMessageLevel.Warning, ex.Message); }
                    }
                }
                else if (n.ToLower() == "spacing")
                {
                    if (val is GH_Integer ghi)
                    {
                        dyna.Spacing = new Size(ghi.Value, ghi.Value);
                    }
                    else if (val is GH_String ghstr)
                    {
                        if (int.TryParse(ghstr.Value, out int v))
                        {
                            dyna.Spacing = new Size(v, v);
                        }
                        else if (ghstr.Value.Split(',') is string[] xy)
                        {
                            if (int.TryParse(xy[0], out int x) && int.TryParse(xy[1], out int y))
                            {
                                dyna.Spacing = new Size(x, y);
                            }
                            else
                            {
                                AddRuntimeMessage(GH_RuntimeMessageLevel.Warning, " cannot parse text string into Size object");
                            }
                        }
                        else
                        {
                            AddRuntimeMessage(GH_RuntimeMessageLevel.Warning, " cannot parse text string into Size object");
                        }
                    }
                    else if (val is GH_Number gnum)
                    {
                        dyna.Spacing = new Size((int)gnum.Value, (int)gnum.Value);
                    }
                    else if (val is GH_Rectangle grec)
                    {
                        int x = (int)grec.Value.X.Length;
                        int y = (int)grec.Value.Y.Length;
                        dyna.Spacing = new Size(x, y);
                    }
                    else if (val is GH_ComplexNumber gcomp)
                    {
                        int x = (int)gcomp.Value.Real;
                        int y = (int)gcomp.Value.Imaginary;
                        dyna.Spacing = new Size(x, y);
                    }
                    else
                    {
                        try { Util.SetProp(dyna, "Spacing", Util.GetGooVal(val)); }
                        catch (Exception ex) { AddRuntimeMessage(GH_RuntimeMessageLevel.Warning, ex.Message); }
                    }
                }
                else if (n.ToLower() == "direction" || n.ToLower() == "flow")
                {
                    if (val is GH_Boolean gb)
                    {
                        hz = gb.Value;
                    }
                    else if (val is GH_Integer gint)
                    {
                        if (gint.Value == 0)
                        {
                            hz = false;
                        }
                        else if (gint.Value == 1)
                        {
                            hz = true;
                        }
                        else
                        {
                            AddRuntimeMessage(GH_RuntimeMessageLevel.Warning, " flow direction cannot be set\n check input parameter");
                        }
                    }
                    else if (val is GH_String gstr)
                    {
                        if (gstr.Value.ToLower() == "horizontal" || gstr.Value.ToLower() == "true")
                        {
                            hz = true;
                        }
                        else if (gstr.Value.ToLower() == "vertical" || gstr.Value.ToLower() == "false")
                        {
                            hz = false;
                        }
                        else
                        {
                            AddRuntimeMessage(GH_RuntimeMessageLevel.Warning, " flow direction cannot be set\n check input parameter");
                        }
                    }
                    else
                    {
                        AddRuntimeMessage(GH_RuntimeMessageLevel.Warning, " flow direction cannot be set\n check input parameter");
                    }
                }
                else
                {
                    try { Util.SetProp(dyna, n, Util.GetGooVal(val)); }
                    catch (Exception ex) { AddRuntimeMessage(GH_RuntimeMessageLevel.Warning, ex.Message); }
                }
            }

            //dyna.AddRange(added);
            if (!hz)
            {
                foreach (Control c in added)
                {
                    dyna.AddAutoSized(c);
                }
            }
            else
            {
                dyna.BeginHorizontal();
                foreach (Control c in added)
                {
                    dyna.BeginVertical();
                    dyna.AddAutoSized(c);
                    dyna.EndVertical();
                }
                dyna.EndHorizontal();
            }


            //TODO: currently not able to add separate columns i.e. flow horizontally

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

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

            foreach (PropertyInfo prop in allprops)
            {
                if (prop.CanWrite)
                {
                    printouts.Add(prop.Name + ": " + prop.PropertyType.ToString());
                }
            }
            printouts.Add("Flow: set boolean to true to flow horizontally, false vertically");
            DA.SetDataList(0, printouts);
        }
예제 #25
0
        void InitUi()
        {
            // input
            _textBoxName = new TextBox {
                PlaceholderText = "*Name", Width = 200
            };
            _comboBoxLevel = new ComboBox {
                Width = 100
            };
            _dropDownScritpType = new DropDown {
                Width = 120
            };
            _textBoxShellPath = new TextBox {
                PlaceholderText = "*Shell Url", Width = 300
            };
            _textBoxShellPass = new TextBox {
                PlaceholderText = "*Pass"
            };
            _textBoxRemark = new TextBox {
                PlaceholderText = "Remark"
            };

            // _buttonAdd
            _buttonAdd = new Button {
                Text = StrRes.GetString("StrAdd", "Add")
            };
            _buttonAdd.Click += buttonAdd_Click;

            // _buttonAlter
            _buttonAlter = new Button {
                Text = StrRes.GetString("StrAlter", "Alter")
            };
            _buttonAlter.Click += _buttonAlter_Click;

            // _buttonAdvanced
            _buttonAdvanced = new Button {
                Text = StrRes.GetString("StrAdvanced", "Advanced")
            };
            _buttonAdvanced.Click += _buttonAdvanced_Click;

            var codeList1 = new List <IListItem>
            {
                new ListItem {
                    Text = "UTF-8"
                },
                new ListItem {
                    Text = "GB2312"
                }
            };
            var codeList2 = new List <IListItem>
            {
                new ListItem {
                    Text = "UTF-8"
                },
                new ListItem {
                    Text = "GB2312"
                },
                new ListItem {
                    Text = "Big5"
                },
                new ListItem {
                    Text = "Shift-JIS"
                },
                new ListItem {
                    Text = "EUC-JP"
                },
                new ListItem {
                    Text = "EUC-KR"
                },
                new ListItem {
                    Text = "ISO-8859-1"
                }
            };

            _dropDownServerCoding = new DropDown();
            _dropDownServerCoding.Items.AddRange(codeList1);
            _dropDownServerCoding.SelectedIndex = 0;
            _dropDownWebCoding = new DropDown();
            _dropDownWebCoding.Items.AddRange(codeList2);
            _dropDownWebCoding.SelectedIndex = 0;

            // _buttonDefault
            _buttonDefault = new Button {
                Text = "Default"
            };
            _buttonDefault.Click += _buttonDefault_Click;

            // _richTextBoxSetting
            _richTextBoxSetting = new TextArea {
                Wrap = false
            };

            // _panelAdvanced
            _panelAdvanced = new DynamicLayout {
                Padding = new Padding(5, 5), Spacing = new Size(5, 5)
            };
            _panelAdvanced.BeginVertical();
            _panelAdvanced.BeginHorizontal();
            _panelAdvanced.AddAutoSized(new Label
            {
                Text          = StrRes.GetString("StrServerCoding", "ServerCoding"),
                VerticalAlign = VerticalAlign.Middle
            }, centered: true);
            _panelAdvanced.AddAutoSized(_dropDownServerCoding, centered: true);
            _panelAdvanced.AddAutoSized(new Label
            {
                Text          = StrRes.GetString("StrWebCoding", "WebCoding"),
                VerticalAlign = VerticalAlign.Middle
            }, centered: true);
            _panelAdvanced.AddAutoSized(_dropDownWebCoding, centered: true);
            _panelAdvanced.Add(null);
            _panelAdvanced.AddAutoSized(_buttonDefault, centered: true);
            _panelAdvanced.EndHorizontal();
            _panelAdvanced.EndVertical();
            //_panelAdvanced.AddSeparateRow(new Label { Text = StrRes.GetString("StrServerCoding", "ServerCoding"), VerticalAlign = VerticalAlign.Middle }, _dropDownServerCoding);
            //_panelAdvanced.AddSeparateRow(new Label { Text = StrRes.GetString("StrWebCoding", "WebCoding"), VerticalAlign = VerticalAlign.Middle }, _dropDownWebCoding);
            _panelAdvanced.AddSeparateRow(_richTextBoxSetting);

            var panel1 = new DynamicLayout {
                Padding = new Padding(5, 5), Spacing = new Size(5, 5)
            };

            //line 1
            panel1.BeginVertical();
            panel1.BeginHorizontal();
            panel1.Add(_textBoxName, xscale: true);
            panel1.Add(_comboBoxLevel);
            panel1.Add(_dropDownScritpType);
            panel1.EndHorizontal();
            panel1.EndVertical();
            //line 2
            panel1.BeginVertical();
            panel1.BeginHorizontal();
            panel1.Add(_textBoxShellPath, true);
            panel1.Add(_textBoxShellPass);
            panel1.EndHorizontal();
            panel1.EndVertical();
            //line 3
            panel1.AddRow(_textBoxRemark);
            //line 4
            panel1.BeginVertical();
            panel1.BeginHorizontal();
            panel1.Add(_buttonAdvanced);
            panel1.Add(null, true);
            panel1.Add(_buttonAdd);
            panel1.Add(_buttonAlter);
            panel1.EndHorizontal();
            panel1.EndVertical();
            //line 5
            panel1.Add(_panelAdvanced, false, true);
            _panelAdvanced.Visible = false;

            //_p12 = new Splitter
            //{
            //	Panel1 = panel1,
            //	Panel2 = _panelAdvanced,
            //	Orientation = SplitterOrientation.Vertical,
            //	Position = 130,
            //};
            //_p12.FixedPanel = SplitterFixedPanel.Panel1;
            //_p12.Panel2.Visible = false;

            Content    = panel1;
            ClientSize = new Size(500, 130);
            Title      = "Edit Shell";
            Icon       = Application.Instance.MainForm.Icon;
        }