コード例 #1
0
        // on menu button..

        public void ShowMenu()
        {
            map.displaycontrol.ApplyToControlOfName("InfoBoxForm*", (c) => { ((GLForm)c).Close(); }); // close any info box forms
            map.displaycontrol.ApplyToControlOfName("MS*", (c) => { c.Visible = false; });            // hide the visiblity of the on screen controls

            int leftmargin = 4;
            int vpos       = 10;
            int ypad       = 10;

            GLForm pform = new GLForm("Galmenu", "Configure Map", new Rectangle(10, 10, 600, 600));

            pform.BackColor  = Color.FromArgb(220, 60, 60, 70);
            pform.ForeColor  = Color.Orange;
            pform.FormClosed = (frm) => { map.displaycontrol.ApplyToControlOfName("MS*", (c) => { c.Visible = true; }); };
            pform.Resizeable = pform.Moveable = false;

            // provide opening animation
            pform.ScaleWindow = new SizeF(0.0f, 0.0f);
            pform.Animators.Add(new AnimateScale(10, 400, true, new SizeF(1, 1)));

            // and closing animation
            pform.FormClosing += (f, e) => {
                e.Handled = true;                                           // stop close
                var ani = new AnimateScale(10, 400, true, new SizeF(0, 0)); // add a close animation
                ani.FinishAction += (a, c, t) => { pform.ForceClose(); };   // when its complete, force close
                pform.Animators.Add(ani);
            };

            {   // top buttons
                GLPanel p3d2d = new GLPanel("3d2d", new Rectangle(leftmargin, vpos, 80, iconsize), Color.Transparent);

                GLCheckBox but3d = new GLCheckBox("3d", new Rectangle(0, 0, iconsize, iconsize), Properties.Resources._3d, null);
                but3d.Checked          = map.gl3dcontroller.MatrixCalc.InPerspectiveMode;
                but3d.ToolTipText      = "3D View";
                but3d.GroupRadioButton = true;
                but3d.MouseClick      += (e1, e2) => { map.gl3dcontroller.ChangePerspectiveMode(true); };
                p3d2d.Add(but3d);

                GLCheckBox but2d = new GLCheckBox("2d", new Rectangle(50, 0, iconsize, iconsize), Properties.Resources._2d, null);
                but2d.Checked          = !map.gl3dcontroller.MatrixCalc.InPerspectiveMode;
                but2d.ToolTipText      = "2D View";
                but2d.GroupRadioButton = true;
                but2d.MouseClick      += (e1, e2) => { map.gl3dcontroller.ChangePerspectiveMode(false); };
                p3d2d.Add(but2d);

                pform.Add(p3d2d);

                GLCheckBox butelite = new GLCheckBox("Elite", new Rectangle(100, vpos, iconsize, iconsize), Properties.Resources.EliteMovement, null);
                butelite.ToolTipText   = "Select elite movement (on Y plain)";
                butelite.Checked       = map.gl3dcontroller.YHoldMovement;
                butelite.CheckChanged += (e1) => { map.gl3dcontroller.YHoldMovement = butelite.Checked; };
                pform.Add(butelite);

                GLCheckBox butgal = new GLCheckBox("Galaxy", new Rectangle(150, vpos, iconsize, iconsize), Properties.Resources.ShowGalaxy, null);
                butgal.ToolTipText   = "Show galaxy image";
                butgal.Checked       = map.GalaxyDisplay;
                butgal.CheckChanged += (e1) => { map.GalaxyDisplay = butgal.Checked; };
                pform.Add(butgal);

                GLCheckBox butsd = new GLCheckBox("StarDots", new Rectangle(200, vpos, iconsize, iconsize), Properties.Resources.StarDots, null);
                butsd.ToolTipText   = "Show star field";
                butsd.Checked       = map.StarDotsDisplay;
                butsd.CheckChanged += (e1) => { map.StarDotsDisplay = butsd.Checked; };
                pform.Add(butsd);

                vpos += butgal.Height + ypad;
            }

            {
                GLGroupBox tpgb = new GLGroupBox("TravelPathGB", "Travel Path", new Rectangle(leftmargin, vpos, pform.ClientWidth - leftmargin * 2, iconsize * 2));
                tpgb.BackColor = pform.BackColor;
                tpgb.ForeColor = Color.Orange;
                pform.Add(tpgb);

                GLCheckBox buttp = new GLCheckBox("TravelPath", new Rectangle(leftmargin, 0, iconsize, iconsize), Properties.Resources.StarDots, null);
                buttp.ToolTipText   = "Show travel path";
                buttp.Checked       = map.TravelPathDisplay;
                buttp.CheckChanged += (e1) => { map.TravelPathDisplay = buttp.Checked; };
                tpgb.Add(buttp);

                GLDateTimePicker dtps = new GLDateTimePicker("TPStart", new Rectangle(50, 0, 250, 30), DateTime.Now);
                dtps.Font          = new Font("Ms Sans Serif", 8.25f);
                dtps.ShowCheckBox  = dtps.ShowCalendar = true;
                dtps.Value         = map.TravelPathStartDate;
                dtps.Checked       = map.TravelPathStartDateEnable;
                dtps.ValueChanged += (e1) => { map.TravelPathStartDate = dtps.Value; map.TravelPathRefresh(); };
                dtps.CheckChanged += (e1) => { map.TravelPathStartDateEnable = dtps.Checked; map.TravelPathRefresh(); };
                dtps.ShowUpDown    = true;
                tpgb.Add(dtps);

                GLDateTimePicker dtpe = new GLDateTimePicker("TPEnd", new Rectangle(320, 0, 250, 30), DateTime.Now);
                dtpe.Font          = new Font("Ms Sans Serif", 8.25f);
                dtpe.ShowCheckBox  = dtps.ShowCalendar = true;
                dtpe.Value         = map.TravelPathEndDate;
                dtpe.Checked       = map.TravelPathEndDateEnable;
                dtpe.ValueChanged += (e1) => { map.TravelPathEndDate = dtpe.Value; map.TravelPathRefresh(); };
                dtpe.CheckChanged += (e1) => { map.TravelPathEndDateEnable = dtpe.Checked; map.TravelPathRefresh(); };
                dtpe.ShowUpDown    = true;
                tpgb.Add(dtpe);


                vpos += tpgb.Height + ypad;
            }

            { // Galaxy objects
                GLGroupBox galgb = new GLGroupBox("GalGB", "Galaxy Objects", new Rectangle(leftmargin, vpos, pform.ClientWidth - leftmargin * 2, 50));
                galgb.ClientHeight = (iconsize + 4) * 2;
                galgb.BackColor    = pform.BackColor;
                galgb.ForeColor    = Color.Orange;
                pform.Add(galgb);
                GLFlowLayoutPanel galfp = new GLFlowLayoutPanel("GALFP", DockingType.Fill, 0);
                galfp.FlowPadding = new PaddingType(2, 2, 2, 2);
                galfp.BackColor   = pform.BackColor;
                galgb.Add(galfp);

                for (int i = map.edsmmapping.RenderableMapTypes.Length - 1; i >= 0; i--)
                {
                    var        gt   = map.edsmmapping.RenderableMapTypes[i];
                    bool       en   = map.GetGalObjectTypeEnable(gt.Typeid);
                    GLCheckBox butg = new GLCheckBox("GMSEL" + i, new Rectangle(0, 0, iconsize, iconsize), gt.Image, null);
                    butg.ToolTipText   = "Enable/Disable " + gt.Description;
                    butg.Checked       = en;
                    butg.CheckChanged += (e1) =>
                    {
                        map.SetGalObjectTypeEnable(gt.Typeid, butg.Checked);
                    };
                    galfp.Add(butg);
                }

                GLCheckBox butgonoff = new GLCheckBox("GMONOFF", new Rectangle(0, 0, iconsize, iconsize), Properties.Resources.dotted, null);
                butgonoff.ToolTipText   = "Enable/Disable Display";
                butgonoff.Checked       = map.GalObjectDisplay;
                butgonoff.CheckChanged += (e1) => { map.GalObjectDisplay = !map.GalObjectDisplay; };
                galfp.Add(butgonoff);

                vpos += galgb.Height + ypad;
            }

            { // EDSM regions
                GLGroupBox edsmregionsgb = new GLGroupBox("EDSMR", "EDSM Regions", new Rectangle(leftmargin, vpos, pform.ClientWidth - leftmargin * 2, 50));
                edsmregionsgb.ClientHeight = iconsize + 8;
                edsmregionsgb.BackColor    = pform.BackColor;
                edsmregionsgb.ForeColor    = Color.Orange;
                pform.Add(edsmregionsgb);
                vpos += edsmregionsgb.Height + ypad;

                GLCheckBox butedre = new GLCheckBox("EDSMRE", new Rectangle(leftmargin, 0, iconsize, iconsize), Properties.Resources.ShowGalaxy, null);
                butedre.ToolTipText      = "Enable EDSM Regions";
                butedre.Checked          = map.EDSMRegionsEnable;
                butedre.UserCanOnlyCheck = true;
                edsmregionsgb.Add(butedre);

                GLCheckBox buted2 = new GLCheckBox("EDSMR2", new Rectangle(50, 0, iconsize, iconsize), Properties.Resources.ShowGalaxy, null);
                buted2.Checked       = map.EDSMRegionsOutlineEnable;
                buted2.Enabled       = map.EDSMRegionsEnable;
                buted2.ToolTipText   = "Enable Region Outlines";
                buted2.CheckChanged += (e1) => { map.EDSMRegionsOutlineEnable = !map.EDSMRegionsOutlineEnable; };
                edsmregionsgb.Add(buted2);

                GLCheckBox buted3 = new GLCheckBox("EDSMR3", new Rectangle(100, 0, iconsize, iconsize), Properties.Resources.ShowGalaxy, null);
                buted3.Checked       = map.EDSMRegionsShadingEnable;
                buted3.Enabled       = map.EDSMRegionsEnable;
                buted3.ToolTipText   = "Enable Region Shading";
                buted3.CheckChanged += (e1) => { map.EDSMRegionsShadingEnable = !map.EDSMRegionsShadingEnable; };
                edsmregionsgb.Add(buted3);

                GLCheckBox buted4 = new GLCheckBox("EDSMR4", new Rectangle(150, 0, iconsize, iconsize), Properties.Resources.ShowGalaxy, null);
                buted4.Checked       = map.EDSMRegionsTextEnable;
                buted4.Enabled       = map.EDSMRegionsEnable;
                buted4.ToolTipText   = "Enable Region Naming";
                buted4.CheckChanged += (e1) => { map.EDSMRegionsTextEnable = !map.EDSMRegionsTextEnable; };
                edsmregionsgb.Add(buted4);

                // elite regions

                GLGroupBox eliteregionsgb = new GLGroupBox("ELITER", "Elite Regions", new Rectangle(leftmargin, vpos, pform.ClientWidth - leftmargin * 2, 50));
                eliteregionsgb.ClientHeight = iconsize + 8;
                eliteregionsgb.BackColor    = pform.BackColor;
                eliteregionsgb.ForeColor    = Color.Orange;
                pform.Add(eliteregionsgb);
                vpos += eliteregionsgb.Height + ypad;

                GLCheckBox butelre = new GLCheckBox("ELITERE", new Rectangle(leftmargin, 0, iconsize, iconsize), Properties.Resources.ShowGalaxy, null);
                butelre.ToolTipText      = "Enable Elite Regions";
                butelre.Checked          = map.EliteRegionsEnable;
                butelre.UserCanOnlyCheck = true;
                eliteregionsgb.Add(butelre);

                GLCheckBox butel2 = new GLCheckBox("ELITER2", new Rectangle(50, 0, iconsize, iconsize), Properties.Resources.ShowGalaxy, null);
                butel2.Checked       = map.EliteRegionsOutlineEnable;
                butel2.Enabled       = map.EliteRegionsEnable;
                butel2.ToolTipText   = "Enable Region Outlines";
                butel2.CheckChanged += (e1) => { map.EliteRegionsOutlineEnable = !map.EliteRegionsOutlineEnable; };
                eliteregionsgb.Add(butel2);

                GLCheckBox butel3 = new GLCheckBox("ELITER3", new Rectangle(100, 0, iconsize, iconsize), Properties.Resources.ShowGalaxy, null);
                butel3.Checked       = map.EliteRegionsShadingEnable;
                butel3.Enabled       = map.EliteRegionsEnable;
                butel3.ToolTipText   = "Enable Region Shading";
                butel3.CheckChanged += (e1) => { map.EliteRegionsShadingEnable = !map.EliteRegionsShadingEnable; };
                eliteregionsgb.Add(butel3);

                GLCheckBox butel4 = new GLCheckBox("ELITER4", new Rectangle(150, 0, iconsize, iconsize), Properties.Resources.ShowGalaxy, null);
                butel4.Checked       = map.EliteRegionsTextEnable;
                butel4.Enabled       = map.EliteRegionsEnable;
                butel4.ToolTipText   = "Enable Region Naming";
                butel4.CheckChanged += (e1) => { map.EliteRegionsTextEnable = !map.EliteRegionsTextEnable; };
                eliteregionsgb.Add(butel4);

                butedre.CheckChanged += (e) =>
                {
                    if (e.Name == "EDSMRE")
                    {
                        butelre.CheckedNoChangeEvent = !butedre.Checked;
                    }
                    else
                    {
                        butedre.CheckedNoChangeEvent = !butelre.Checked;
                    }

                    map.EDSMRegionsEnable  = butedre.Checked;
                    map.EliteRegionsEnable = butelre.Checked;

                    buted2.Enabled = buted3.Enabled = buted4.Enabled = butedre.Checked;
                    butel2.Enabled = butel3.Enabled = butel4.Enabled = butelre.Checked;
                };

                butelre.CheckChanged += butedre.CheckChanged;
            }

            map.displaycontrol.Add(pform);
        }
コード例 #2
0
        private void InitInt(string caption, Object callertag)
        {
            this.callertag   = callertag;    // passed back to caller via trigger
            this.Text        = caption;
            this.FormClosed += (a) => {
                Trigger?.Invoke(this, null, "Close", this.callertag);       // pass back the logical name of dialog, the name of the control, the caller tag
            };

            SuspendLayout();

            for (int i = 0; i < entries.Count; i++)
            {
                Entry ent = entries[i];

                bool oursmade = ent.Control == null;

                if (oursmade)
                {
                    ent.Control      = (GLBaseControl)Activator.CreateInstance(ent.ControlType);
                    ent.Control.Name = ent.Name;
                    ent.Control.SetNI(ent.Location, ent.Size);
                    ent.Control.Anchor   = ent.Anchor;
                    ent.Control.AutoSize = ent.AutoSize;
                }

                GLBaseControl control = ent.Control;
                control.Tag      = ent; // point control tag at ent structure
                control.TabOrder = ent.TabOrder;

                if (control is GLLabel)
                {
                    var l = control as GLLabel;
                    if (oursmade)
                    {
                        l.Text = ent.Text;
                    }

                    if (ent.TextAlign.HasValue)
                    {
                        l.TextAlign = ent.TextAlign.Value;
                    }
                }
                else if (control is GLNumberBoxFloat)      // must be before MLTB
                {
                    GLNumberBoxFloat cb = control as GLNumberBoxFloat;

                    if (oursmade)
                    {
                        cb.Minimum = (float)ent.NumberBoxDoubleMinimum;
                        cb.Maximum = (float)ent.NumberBoxDoubleMaximum;
                        float?v = ent.Text.InvariantParseFloatNull();
                        cb.Value = v.HasValue ? v.Value : cb.Minimum;
                        if (ent.NumberBoxFormat != null)
                        {
                            cb.Format = ent.NumberBoxFormat;
                        }
                    }

                    cb.ReturnPressed += (box) =>
                    {
                        Entry en = (Entry)(box.Tag);
                        Trigger?.Invoke(this, en, ":Return", this.callertag);       // pass back the logical name of dialog, the name of the control, the caller tag
                    };
                    cb.ValidityChanged += (box, b) =>
                    {
                        Entry en = (Entry)(box.Tag);
                        Trigger?.Invoke(this, en, "Validity:" + b.ToString(), this.callertag);       // pass back the logical name of dialog, the name of the control, the caller tag
                    };
                }
                else if (control is GLNumberBoxDouble)      // must be before MLTB
                {
                    GLNumberBoxDouble cb = control as GLNumberBoxDouble;

                    if (oursmade)
                    {
                        cb.Minimum = ent.NumberBoxDoubleMinimum;
                        cb.Maximum = ent.NumberBoxDoubleMaximum;
                        double?v = ent.Text.InvariantParseDoubleNull();
                        cb.Value = v.HasValue ? v.Value : cb.Minimum;
                        if (ent.NumberBoxFormat != null)
                        {
                            cb.Format = ent.NumberBoxFormat;
                        }
                    }

                    cb.ReturnPressed += (box) =>
                    {
                        Entry en = (Entry)(box.Tag);
                        Trigger?.Invoke(this, en, ":Return", this.callertag);       // pass back the logical name of dialog, the name of the control, the caller tag
                    };
                    cb.ValidityChanged += (box, b) =>
                    {
                        Entry en = (Entry)(box.Tag);
                        Trigger?.Invoke(this, en, "Validity:" + b.ToString(), this.callertag);       // pass back the logical name of dialog, the name of the control, the caller tag
                    };
                }
                else if (control is GLNumberBoxLong)        // must be before MLTB
                {
                    GLNumberBoxLong cb = control as GLNumberBoxLong;
                    if (oursmade)
                    {
                        cb.Minimum = ent.NumberBoxLongMinimum;
                        cb.Maximum = ent.NumberBoxLongMaximum;
                        long?v = ent.Text.InvariantParseLongNull();
                        cb.Value = v.HasValue ? v.Value : cb.Minimum;
                        if (ent.NumberBoxFormat != null)
                        {
                            cb.Format = ent.NumberBoxFormat;
                        }
                    }

                    cb.ReturnPressed += (box) =>
                    {
                        Entry en = (Entry)(box.Tag);
                        Trigger?.Invoke(this, en, "Return", this.callertag);       // pass back the logical name of dialog, the name of the control, the caller tag
                    };
                    cb.ValidityChanged += (box, s) =>
                    {
                        Entry en = (Entry)(box.Tag);
                        Trigger?.Invoke(this, en, "Validity:" + s.ToString(), this.callertag);       // pass back the logical name of dialog, the name of the control, the caller tag
                    };
                }

                else if (control is GLMultiLineTextBox)   // also TextBox as its inherited
                {
                    GLMultiLineTextBox tb = control as GLMultiLineTextBox;

                    if (oursmade)
                    {
                        tb.Text             = ent.Text;
                        tb.ClearOnFirstChar = ent.ClearOnFirstChar;
                        tb.ReadOnly         = ent.ReadOnly;
                    }

                    tb.ReturnPressed += (box) =>        // only works for text box
                    {
                        Entry en = (Entry)(box.Tag);
                        Trigger?.Invoke(this, en, "Return", this.callertag);       // pass back the logical name of dialog, the name of the control, the caller tag
                    };
                }
                else if (control is GLButton)
                {
                    GLButton b = control as GLButton;
                    if (oursmade)
                    {
                        b.Text = ent.Text;
                    }

                    if (ent.TextAlign.HasValue)
                    {
                        b.TextAlign = ent.TextAlign.Value;
                    }

                    b.Click += (sender, ev) =>
                    {
                        Entry en = (Entry)(((GLBaseControl)sender).Tag);
                        Trigger?.Invoke(this, en, en.Name, this.callertag);       // pass back the logical name of dialog, the name of the control, the caller tag
                    };

                    b.Return += (sender) =>
                    {
                        Entry en = (Entry)(((GLBaseControl)sender).Tag);
                        Trigger?.Invoke(this, en, en.Name, this.callertag);       // pass back the logical name of dialog, the name of the control, the caller tag
                    };
                }
                else if (control is GLCheckBox)
                {
                    GLCheckBox cb = control as GLCheckBox;
                    if (oursmade)
                    {
                        cb.Checked = ent.Checked;
                    }
                    cb.CheckChanged = (sender) =>
                    {
                        Entry en = (Entry)(((GLBaseControl)sender).Tag);
                        Trigger?.Invoke(this, en, en.Name, this.callertag);       // pass back the logical name of dialog, the name of the control, the caller tag
                    };
                }
                else if (control is GLDateTimePicker)
                {
                    GLDateTimePicker dt = control as GLDateTimePicker;
                    if (oursmade)
                    {
                        DateTime t;
                        if (DateTime.TryParse(ent.Text, System.Globalization.CultureInfo.InvariantCulture, System.Globalization.DateTimeStyles.AssumeLocal, out t))     // assume local, so no conversion
                        {
                            dt.Value = t;
                        }
                    }

                    switch (ent.CustomDateFormat.ToLowerInvariant())
                    {
                    case "short":
                        dt.Format = GLDateTimePicker.DateTimePickerFormat.Short;
                        break;

                    case "long":
                        dt.Format = GLDateTimePicker.DateTimePickerFormat.Long;
                        break;

                    case "time":
                        dt.Format = GLDateTimePicker.DateTimePickerFormat.Time;
                        break;

                    default:
                        dt.CustomFormat = ent.CustomDateFormat;
                        break;
                    }
                }
                else if (control is GLComboBox)
                {
                    GLComboBox cb = control as GLComboBox;

                    if (oursmade)
                    {
                        cb.Items.AddRange(ent.ComboBoxItems);
                        if (cb.Items.Contains(ent.Text))
                        {
                            cb.SelectedItem = ent.Text;
                        }
                    }

                    cb.SelectedIndexChanged += (sender) =>
                    {
                        GLBaseControl ctr = (GLBaseControl)sender;
                        if (ctr.Enabled)
                        {
                            Entry en = (Entry)(ctr.Tag);
                            Trigger?.Invoke(this, en, en.Name, this.callertag);       // pass back the logical name of dialog, the name of the control, the caller tag
                        }
                    };
                }


                Add(control);
            }

            ResumeLayout();
        }
コード例 #3
0
        protected override void OnLoad(EventArgs e)
        {
            base.OnLoad(e);
            Closed += ShaderTest_Closed;

            items.Add(new GLMatrixCalcUniformBlock(), "MCUB");     // create a matrix uniform block

            int front = -20000, back = front + 90000, left = -45000, right = left + 90000, vsize = 2000;

            Vector4[] displaylines = new Vector4[]
            {
                new Vector4(left, -vsize, front, 1), new Vector4(left, +vsize, front, 1),
                new Vector4(left, +vsize, front, 1), new Vector4(right, +vsize, front, 1),
                new Vector4(right, +vsize, front, 1), new Vector4(right, -vsize, front, 1),
                new Vector4(right, -vsize, front, 1), new Vector4(left, -vsize, front, 1),

                new Vector4(left, -vsize, back, 1), new Vector4(left, +vsize, back, 1),
                new Vector4(left, +vsize, back, 1), new Vector4(right, +vsize, back, 1),
                new Vector4(right, +vsize, back, 1), new Vector4(right, -vsize, back, 1),
                new Vector4(right, -vsize, back, 1), new Vector4(left, -vsize, back, 1),

                new Vector4(left, -vsize, front, 1), new Vector4(left, -vsize, back, 1),
                new Vector4(left, +vsize, front, 1), new Vector4(left, +vsize, back, 1),
                new Vector4(right, -vsize, front, 1), new Vector4(right, -vsize, back, 1),
                new Vector4(right, +vsize, front, 1), new Vector4(right, +vsize, back, 1),
            };

            GLRenderState rl       = GLRenderState.Lines(1);

            {
                items.Add(new GLFixedShader(System.Drawing.Color.Yellow), "LINEYELLOW");
                rObjects.Add(items.Shader("LINEYELLOW"),
                             GLRenderableItem.CreateVector4(items, PrimitiveType.Lines, rl, displaylines));
            }

            float h = 0;

            if (h != -1)
            {
                items.Add(new GLColorShaderWorld(), "COS-1L");

                int   dist = 1000;
                Color cr   = Color.FromArgb(100, Color.White);
                rObjects.Add(items.Shader("COS-1L"),    // horizontal
                             GLRenderableItem.CreateVector4Color4(items, PrimitiveType.Lines, rl,
                                                                  GLShapeObjectFactory.CreateLines(new Vector3(left, h, front), new Vector3(left, h, back), new Vector3(dist, 0, 0), (back - front) / dist + 1),
                                                                  new Color4[] { cr })
                             );

                rObjects.Add(items.Shader("COS-1L"),
                             GLRenderableItem.CreateVector4Color4(items, PrimitiveType.Lines, rl,
                                                                  GLShapeObjectFactory.CreateLines(new Vector3(left, h, front), new Vector3(right, h, front), new Vector3(0, 0, dist), (right - left) / dist + 1),
                                                                  new Color4[] { cr })
                             );
            }

            GLMatrixCalc mc = new GLMatrixCalc();

            mc.PerspectiveNearZDistance = 1f;
            mc.PerspectiveFarZDistance  = 500000f;

            mc.ResizeViewPort(this, glwfc.Size);                               // must establish size before starting

            displaycontrol           = new GLControlDisplay(items, glwfc, mc); // hook form to the window - its the master, it takes its size fro mc.ScreenCoordMax
            displaycontrol.Focusable = true;                                   // we want to be able to focus and receive key presses.
            displaycontrol.Name      = "displaycontrol";
            displaycontrol.Font      = new Font("Times", 8);

            GLForm pform;

            if (true)
            {
                pform = new GLForm("Form1", "GL Form demonstration", new Rectangle(0, 0, 1000, 800));
                //pform.BackColor = Color.FromArgb(200, Color.Red);
                //pform.Opacity = 0.7f;
                // pform.BackColorGradientDir = 90;
                //  pform.BackColorGradientAlt = Color.FromArgb(200, Color.Yellow);
                //pform.ScaleWindow = new SizeF(0.75f, 0.75f);
                //pform.AlternatePos = new RectangleF(100, 100, 500, 400);
                //pform.AlternatePos = new RectangleF(100, 100, 1200, 1000);
                //  pform.ScaleWindow = new SizeF(0.0f, 0.0f);
                //   pform.Animators.Add(new AnimateScale(100, 1000, true, new SizeF(1, 1),removeafterend:true));
                //  pform.Animators.Add(new AnimateTranslate(glwfc.ElapsedTimems + 100, glwfc.ElapsedTimems + 1000, false, new Point(100, 100), removeafterend: true));
                //  pform.Animators.Add(new AnimateOpacity(glwfc.ElapsedTimems + 100, glwfc.ElapsedTimems + 2000, false, 1.0f,0.0f, removeafterend: true));

                int taborder = 0;

                if (true)
                {
                    GLLabel lab1 = new GLLabel("Lab1", new Rectangle(400, 0, 0, 0), "From Check");
                    pform.Add(lab1);

                    GLButton b1 = new GLButton("B1", new Rectangle(5, 10, 80, 30), "Configuration Dialog");
                    b1.Margin      = new MarginType(2);
                    b1.AutoSize    = true;
                    b1.TabOrder    = taborder++;
                    b1.Padding     = new PaddingType(5);
                    b1.Click      += (c, ev) => { ConfDialog(); };
                    b1.ToolTipText = "Button 1 tip\r\nLine 2 of it";
                    pform.Add(b1);

                    GLButton b2 = new GLButton("B2", new Rectangle(5, 50, 0, 0), "Msg1");
                    b2.Image       = Properties.Resources.ImportSphere;
                    b2.TabOrder    = taborder++;
                    b2.ImageAlign  = ContentAlignment.MiddleLeft;
                    b2.TextAlign   = ContentAlignment.MiddleRight;
                    b2.Click      += (c, ev) => { MsgDialog1(); };
                    b2.ToolTipText = "Button 2 tip\r\nLine 2 of it";
                    pform.Add(b2);

                    GLButton b3 = new GLButton("B3", new Rectangle(100, 10, 80, 30), "Font");
                    b3.Margin      = new MarginType(2);
                    b3.TabOrder    = taborder++;
                    b3.Padding     = new PaddingType(5);
                    b3.ToolTipText = "Button 3 tip\r\nLine 2 of it";
                    b3.Click      += (c, ev) => {
                        displaycontrol.Font = new Font("Times", 12);
                    };
                    pform.Add(b3);

                    GLButton b4 = new GLButton("B4", new Rectangle(100, 50, 80, 30), "Msg2");
                    b4.TabOrder    = taborder++;
                    b4.Padding     = new PaddingType(2);
                    b4.ToolTipText = "Button 4 tip\r\nLine 2 of it";
                    b4.Click      += (c, ev) => { MsgDialog2(); };
                    pform.Add(b4);

                    GLButton b5 = new GLButton("B5", new Rectangle(200, 10, 80, 30), "Conf2");
                    b5.TabOrder    = taborder++;
                    b5.Padding     = new PaddingType(2);
                    b5.ToolTipText = "Button 5 tip\r\nLine 2 of it";
                    b5.Click      += (c, ev) => { ConfDialog2(); };
                    pform.Add(b5);

                    GLButton b6 = new GLButton("B3", new Rectangle(200, 50, 80, 30), "Disabled");
                    b6.TabOrder    = taborder++;
                    b6.ToolTipText = "Button 6 tip\r\nLine 2 of it";
                    b6.Enabled     = false;
                    pform.Add(b6);
                }

                if (true)
                {
                    GLComboBox cb1 = new GLComboBox("CB", new Rectangle(0, 100, 0, 0), new List <string>()
                    {
                        "one", "two", "three"
                    });
                    cb1.Margin      = new MarginType(16, 8, 16, 8);
                    cb1.TabOrder    = taborder++;
                    cb1.ToolTipText = "Combo Box";
                    pform.Add(cb1);

                    GLComboBox cbstars = new GLComboBox("GalaxyStarsNumber", new Rectangle(100, 100, 100, 32));
                    cbstars.ToolTipText = "Control how many stars are shown when zoomes in";
                    cbstars.Items       = new List <string>()
                    {
                        "Ultra", "High", "Medium", "Low"
                    };
                    cbstars.TabOrder = taborder++;
                    var list = new List <int>()
                    {
                        1000000, 500000, 250000, 100000
                    };
                    int itemno = 1;
                    cbstars.SelectedIndex = itemno >= 0 ? itemno : 1;       // high default
                    pform.Add(cbstars);
                }

                if (true)
                {
                    GLCheckBox chk1 = new GLCheckBox("Checkbox1", new Rectangle(0, 150, 0, 0), "Normal");
                    chk1.Margin   = new MarginType(16, 0, 0, 0);
                    chk1.TabOrder = taborder++;
                    pform.Add(chk1);
                    GLCheckBox chk2 = new GLCheckBox("Checkbox2", new Rectangle(100, 150, 0, 0), "Radio");
                    chk2.Appearance = GLCheckBox.CheckBoxAppearance.Radio;
                    chk2.TabOrder   = taborder++;
                    chk2.Checked    = true;
                    pform.Add(chk2);
                    GLCheckBox chk3 = new GLCheckBox("Checkbox3", new Rectangle(200, 150, 0, 0), "Button");
                    chk3.Appearance = GLCheckBox.CheckBoxAppearance.Button;
                    chk3.TabOrder   = taborder++;
                    chk3.BackColor  = Color.FromArgb(200, 200, 200);
                    pform.Add(chk3);
                    GLCheckBox chk4 = new GLCheckBox("Checkbox4", new Rectangle(300, 150, 0, 0), "");
                    chk4.TabOrder = taborder++;
                    pform.Add(chk4);
                    GLCheckBox chk5 = new GLCheckBox("Checkbox5", new Rectangle(350, 150, 0, 0), "R1");
                    chk5.Appearance       = GLCheckBox.CheckBoxAppearance.Radio;
                    chk5.GroupRadioButton = true;
                    chk5.TabOrder         = taborder++;
                    pform.Add(chk5);
                    GLCheckBox chk6 = new GLCheckBox("Checkbox6", new Rectangle(400, 150, 0, 0), "R2");
                    chk6.Appearance       = GLCheckBox.CheckBoxAppearance.Radio;
                    chk6.GroupRadioButton = true;
                    chk6.TabOrder         = taborder++;
                    pform.Add(chk6);
                    GLCheckBox chk7 = new GLCheckBox("Checkbox7", new Rectangle(0, 175, 0, 0), "Disabled");
                    chk7.TabOrder = taborder++;
                    chk7.Enabled  = false;
                    pform.Add(chk7);
                    GLCheckBox chk8 = new GLCheckBox("Checkbox8", new Rectangle(100, 175, 0, 0), "Disabled");
                    chk8.Appearance = GLCheckBox.CheckBoxAppearance.Radio;
                    chk8.TabOrder   = taborder++;
                    chk8.Enabled    = false;
                    pform.Add(chk8);
                    GLCheckBox chk9 = new GLCheckBox("Checkbox9", new Rectangle(200, 175, 0, 0), "CDisabled");
                    chk9.TabOrder = taborder++;
                    chk9.Enabled  = false;
                    chk9.Checked  = true;
                    pform.Add(chk9);
                    GLCheckBox chk10 = new GLCheckBox("Checkbox10", new Rectangle(300, 175, 0, 0), "CDisabled");
                    chk10.Appearance = GLCheckBox.CheckBoxAppearance.Radio;
                    chk10.TabOrder   = taborder++;
                    chk10.Enabled    = false;
                    chk10.Checked    = true;
                    pform.Add(chk10);
                }

                if (true)
                {
                    GLDateTimePicker dtp = new GLDateTimePicker("DTP", new Rectangle(0, 210, 500, 30), DateTime.Now);
                    dtp.Culture = System.Globalization.CultureInfo.GetCultureInfo("de-AT");
                    dtp.Format  = GLDateTimePicker.DateTimePickerFormat.Long;
                    //dtp.CustomFormat = "'start' dddd 'hello there' MMMM' and here 'yyyy";
                    dtp.Font         = new Font("Ms Sans Serif", 11);
                    dtp.ShowCheckBox = true;
                    dtp.ShowCalendar = true;
                    dtp.ShowUpDown   = true;
                    dtp.AutoSize     = true;
                    //dtp.Culture = CultureInfo.GetCultureInfo("es");
                    dtp.TabOrder = taborder++;
                    pform.Add(dtp);
                }

                if (true)
                {
                    List <string> i1 = new List <string>()
                    {
                        "one two three four five six seven eight", "two", "three", "four", "five", "six", "seven is very long too to check", "eight", "nine", "ten", "eleven", "twelve"
                    };
                    GLListBox lb1 = new GLListBox("LB1", new Rectangle(0, 260, 260, 100), i1);
                    lb1.Font         = new Font("Microsoft Sans Serif", 12f);
                    lb1.TabOrder     = taborder++;
                    lb1.ShowFocusBox = true;
                    lb1.ScrollBarTheme.SliderColor      = Color.AliceBlue;
                    lb1.ScrollBarTheme.ThumbButtonColor = Color.Blue;
                    //lb1.FitToItemsHeight = false;
                    pform.Add(lb1);
                    lb1.SelectedIndexChanged += (s, si) => { System.Diagnostics.Debug.WriteLine("Selected index " + si); };
                }

                if (true)
                {
                    GLUpDownControl upc1 = new GLUpDownControl("UPC1", new Rectangle(0, 600, 26, 46));
                    upc1.TabOrder = taborder++;
                    pform.Add(upc1);
                    upc1.Clicked += (s, upe) => System.Diagnostics.Debug.WriteLine("Up down control {0} {1}", s.Name, upe);
                }

                if (true)
                {
                    GLCalendar cal = new GLCalendar("Cal", new Rectangle(500, 10, 300, 200));
                    cal.TabOrder = taborder++;
                    //cal.Culture = CultureInfo.GetCultureInfo("es");
                    cal.AutoSize = true;
                    cal.Font     = new Font("Arial", 10);
                    pform.Add(cal);
                }

                if (true)
                {
                    GLNumberBoxFloat glf = new GLNumberBoxFloat("FLOAT", new Rectangle(500, 250, 100, 25), 23.4f);
                    glf.BackColor        = Color.AliceBlue;
                    glf.TabOrder         = taborder++;
                    glf.Font             = new Font("Ms Sans Serif", 12);
                    glf.Minimum          = -1000;
                    glf.Maximum          = 1000;
                    glf.ValueChanged    += (a) => { System.Diagnostics.Debug.WriteLine("GLF value changed"); };
                    glf.ValidityChanged += (a, b) => { System.Diagnostics.Debug.WriteLine($"GLF validity changed {b}"); };
                    pform.Add(glf);

                    GLButton glfbut = new GLButton("FLOATBUT", new Rectangle(610, 250, 40, 15), "Value");
                    glfbut.Click += (e1, b1) => { glf.Value = 20.22f; };
                    pform.Add(glfbut);

                    GLTextBoxAutoComplete gla = new GLTextBoxAutoComplete("ACTB", new Rectangle(500, 300, 100, 25));
                    gla.TabOrder = taborder++;
                    gla.Font     = new Font("Ms Sans Serif", 12);
                    gla.PerformAutoCompleteInThread += (s, a, set) =>
                    {
                        var r = new List <string>()
                        {
                            "one", "two", "three"
                        };
                        foreach (var x in r)
                        {
                            if (x.StartsWith(s) || s.IsEmpty())
                            {
                                set.Add(x);
                            }
                        }
                    };
                    gla.SelectedEntry += (s) => { System.Diagnostics.Debug.WriteLine($"Autocomplete selected {s.Text}"); };
                    pform.Add(gla);
                }

                if (true)
                {
                    GLButton b1 = new GLButton("BD1", new Rectangle(5, 10, 80, 30), "Bottom 1");
                    b1.TabOrder = taborder++;
                    b1.Dock     = DockingType.Bottom;
                    displaycontrol.Add(b1);
                    GLButton b2 = new GLButton("BD2", new Rectangle(5, 10, 80, 30), "Bottom 2");
                    b2.TabOrder = taborder++;
                    b2.Dock     = DockingType.Bottom;
                    displaycontrol.Add(b2);
                }

                displaycontrol.Add(pform);
            }

            if (true)
            {
                GLForm pform2 = new GLForm("Form2", "Form 2 GL Control demonstration", new Rectangle(1100, 0, 400, 400));
                pform2.BackColor            = Color.FromArgb(200, Color.Red);
                pform2.Font                 = new Font("Ms sans serif", 10);
                pform2.BackColorGradientDir = 90;
                pform2.BackColorGradientAlt = Color.FromArgb(200, Color.Blue);
                displaycontrol.Add(pform2);

                GLButton b1 = new GLButton("*********** F2B1", new Rectangle(5, 10, 80, 30), "F2B1");
                pform2.Add(b1);
            }

            if (true)
            {
                GLToolTip tip = new GLToolTip("ToolTip");
                displaycontrol.Add(tip);
            }

            displaycontrol.GlobalMouseDown += (ctrl, ex) =>
            {
                if (ctrl == null || !pform.IsThisOrChildOf(ctrl))
                {
                    //  System.Diagnostics.Debug.WriteLine("Not on form");
                }
                else
                {
                    //  System.Diagnostics.Debug.WriteLine("Click on form");
                }
            };



            gl3dcontroller = new Controller3D();
            gl3dcontroller.ZoomDistance  = 5000F;
            gl3dcontroller.YHoldMovement = true;
            gl3dcontroller.PaintObjects  = Controller3dDraw;

            gl3dcontroller.KeyboardTravelSpeed = (ms, eyedist) =>
            {
                return((float)ms * 10.0f);
            };

            gl3dcontroller.MatrixCalc.InPerspectiveMode = true;

            if (displaycontrol != null)
            {
                gl3dcontroller.Start(mc, displaycontrol, new Vector3(0, 0, 10000), new Vector3(140.75f, 0, 0), 0.5F); // HOOK the 3dcontroller to the form so it gets Form events

                displaycontrol.Paint += (o, ts) =>                                                                    // subscribing after start means we paint over the scene, letting transparency work
                {
                    displaycontrol.Render(glwfc.RenderState, ts);                                                     // we use the same matrix calc as done in controller 3d draw
                };
            }
            else
            {
                gl3dcontroller.Start(glwfc, new Vector3(0, 0, 10000), new Vector3(140.75f, 0, 0), 0.5F);     // HOOK the 3dcontroller to the form so it gets Form events
            }
            systemtimer.Start();
        }
コード例 #4
0
ファイル: MapMenu.cs プロジェクト: EDDiscovery/EDDiscovery
        // on menu button..
        public void ShowMenu(Map.Parts parts)
        {
            //map.displaycontrol.ApplyToControlOfName("InfoBoxForm*", (c) => { ((GLForm)c).Close(); });      // close any info box forms (don't want to I think)

            map.displaycontrol.ApplyToControlOfName("MS*", (c) => { c.Visible = false; });      // hide the visiblity of the on screen controls

            int leftmargin = 4;
            int vpos       = 10;
            int hpad       = 8;
            int ypad       = 10;

            GLForm pform = new GLForm("Galmenu", "Configure Map", new Rectangle(10, 10, 500, 600));

            pform.FormClosed = (frm) => { map.displaycontrol.ApplyToControlOfName("MS*", (c) => { c.Visible = true; }); };
            pform.Resizeable = pform.Moveable = false;

            // provide opening animation
            pform.ScaleWindow = new SizeF(0.0f, 0.0f);
            pform.Animators.Add(new GLControlAnimateScale(10, 400, true, new SizeF(1, 1)));
            pform.Font = new Font("Arial", 10f);

            // and closing animation
            pform.FormClosing += (f, e) => {
                var nb = ((GLNumberBoxLong)pform["GalaxyStarsGB"]?["LYDist"]);;
                if (nb != null)
                {
                    map.LocalAreaSize = (int)nb.Value;
                }
                e.Handled = true;                                                    // stop close
                var ani = new GLControlAnimateScale(10, 400, true, new SizeF(0, 0)); // add a close animation
                ani.FinishAction += (a, c, t) => { pform.ForceClose(); };            // when its complete, force close
                pform.Animators.Add(ani);
            };

            {   // top buttons
                int hpos = 0;

                if ((parts & Map.Parts.PerspectiveChange) != 0)
                {
                    GLPanel p3d2d = new GLPanel("3d2d", new Rectangle(leftmargin, vpos, 80, iconsize), Color.Transparent);

                    GLCheckBox but3d = new GLCheckBox("3d", new Rectangle(hpos, 0, iconsize, iconsize), BaseUtils.Icons.IconSet.GetBitmap("GalMap.3d"), null);
                    but3d.Checked          = map.gl3dcontroller.MatrixCalc.InPerspectiveMode;
                    but3d.ToolTipText      = "3D View";
                    but3d.GroupRadioButton = true;
                    but3d.MouseClick      += (e1, e2) => { map.gl3dcontroller.ChangePerspectiveMode(true); };
                    p3d2d.Add(but3d);
                    hpos += but3d.Width + hpad;

                    GLCheckBox but2d = new GLCheckBox("2d", new Rectangle(hpos, 0, iconsize, iconsize), BaseUtils.Icons.IconSet.GetBitmap("GalMap.2d"), null);
                    but2d.Checked          = !map.gl3dcontroller.MatrixCalc.InPerspectiveMode;
                    but2d.ToolTipText      = "2D View";
                    but2d.GroupRadioButton = true;
                    but2d.MouseClick      += (e1, e2) => { map.gl3dcontroller.ChangePerspectiveMode(false); };
                    p3d2d.Add(but2d);
                    hpos += but2d.Width + hpad;

                    pform.Add(p3d2d);
                }

                if ((parts & Map.Parts.YHoldButton) != 0)
                {
                    GLCheckBox butelite = new GLCheckBox("Elite", new Rectangle(hpos, vpos, iconsize, iconsize), BaseUtils.Icons.IconSet.GetBitmap("GalMap.EliteMovement"), null);
                    butelite.ToolTipText   = "Select elite movement (on Y plain)";
                    butelite.Checked       = map.gl3dcontroller.YHoldMovement;
                    butelite.CheckChanged += (e1) => { map.gl3dcontroller.YHoldMovement = butelite.Checked; };
                    pform.Add(butelite);
                    hpos += butelite.Width + hpad;
                }

                if ((parts & Map.Parts.Galaxy) != 0)
                {
                    GLCheckBox butgal = new GLCheckBox("Galaxy", new Rectangle(hpos, vpos, iconsize, iconsize), BaseUtils.Icons.IconSet.GetBitmap("GalMap.ShowGalaxy"), null);
                    butgal.ToolTipText   = "Show galaxy image";
                    butgal.Checked       = map.GalaxyDisplay;
                    butgal.CheckChanged += (e1) => { map.GalaxyDisplay = butgal.Checked; };
                    pform.Add(butgal);
                    hpos += butgal.Width + hpad;
                }

                if ((parts & Map.Parts.Grid) != 0)
                {
                    GLCheckBox butgrid = new GLCheckBox("GridLines", new Rectangle(hpos, vpos, iconsize, iconsize), BaseUtils.Icons.IconSet.GetBitmap("GalMap.Grid"), null);
                    butgrid.ToolTipText   = "Show grid";
                    butgrid.Checked       = map.Grid;
                    butgrid.CheckChanged += (e1) => { map.Grid = butgrid.Checked; };
                    pform.Add(butgrid);
                    hpos += butgrid.Width + hpad;
                }

                if ((parts & Map.Parts.StarDots) != 0)
                {
                    GLCheckBox butsd = new GLCheckBox("StarDots", new Rectangle(hpos, vpos, iconsize, iconsize), BaseUtils.Icons.IconSet.GetBitmap("GalMap.StarDots"), null);
                    butsd.ToolTipText   = "Show star field";
                    butsd.Checked       = map.StarDotsSpritesDisplay;
                    butsd.CheckChanged += (e1) => { map.StarDotsSpritesDisplay = butsd.Checked; };
                    pform.Add(butsd);
                    hpos += butsd.Width + hpad;
                }

                if ((parts & Map.Parts.NavRoute) != 0)
                {
                    GLCheckBox butnr = new GLCheckBox("NavRoute", new Rectangle(hpos, vpos, iconsize, iconsize), BaseUtils.Icons.IconSet.GetBitmap("GalMap.NavRoute"), null);
                    butnr.ToolTipText   = "Show nav route";
                    butnr.Checked       = map.NavRouteDisplay;
                    butnr.CheckChanged += (e1) => { map.NavRouteDisplay = butnr.Checked; };
                    pform.Add(butnr);
                    hpos += butnr.Width + hpad;
                }

                if ((parts & Map.Parts.Bookmarks) != 0)
                {
                    GLCheckBox butbkmks = new GLCheckBox("Bookmarks", new Rectangle(hpos, vpos, iconsize, iconsize), BaseUtils.Icons.IconSet.GetBitmap("GalMap.ShowBookmarks"), null);
                    butbkmks.ToolTipText   = "Show bookmarks";
                    butbkmks.Checked       = map.ShowBookmarks;
                    butbkmks.CheckChanged += (e1) => { map.ShowBookmarks = butbkmks.Checked; };
                    pform.Add(butbkmks);
                    hpos += butbkmks.Width + hpad;
                }

                vpos += iconsize + ypad;
            }


            if ((parts & Map.Parts.EDSMStars) != 0)
            {
                GLGroupBox tpgb = new GLGroupBox("GalaxyStarsGB", "Galaxy Stars", new Rectangle(leftmargin, vpos, pform.ClientWidth - leftmargin * 2, iconsize * 2));
                tpgb.BackColor = Color.Transparent;
                tpgb.ForeColor = Color.Orange;
                pform.Add(tpgb);

                int hpos = leftmargin;

                GLCheckBox butgalstars = new GLCheckBox("GalaxyStars", new Rectangle(hpos, 0, iconsize, iconsize), BaseUtils.Icons.IconSet.GetBitmap("GalMap.GalaxyStars"), null);
                butgalstars.ToolTipText   = "Show stars when zoomed in";
                butgalstars.Checked       = (map.GalaxyStars & 1) != 0;
                butgalstars.CheckChanged += (e1) => { map.GalaxyStars ^= 1; };
                tpgb.Add(butgalstars);
                hpos += butgalstars.Width + hpad;

                GLCheckBox butgalstarstext = new GLCheckBox("GalaxyStarsText", new Rectangle(hpos, 0, iconsize, iconsize), BaseUtils.Icons.IconSet.GetBitmap("GalMap.GalaxyStarsText"), null);
                butgalstarstext.ToolTipText   = "Show names of stars when zoomed in";
                butgalstarstext.Checked       = (map.GalaxyStars & 2) != 0;
                butgalstarstext.CheckChanged += (e1) => { map.GalaxyStars ^= 2; };
                tpgb.Add(butgalstarstext);
                hpos += butgalstarstext.Width + hpad;

                if ((parts & Map.Parts.PrepopulateEDSMLocalArea) != 0)
                {
                    GLNumberBoxLong nblong = new GLNumberBoxLong("LYDist", new Rectangle(hpos, 0, 50, iconsize), map.LocalAreaSize);
                    nblong.Minimum     = 1;
                    nblong.Maximum     = 500;
                    nblong.ToolTipText = "Set distance in ly of the box around the current star to show";
                    tpgb.Add(nblong);
                    hpos += nblong.Width + hpad;

                    GLLabel lylab = new GLLabel("LYLab", new Rectangle(hpos, 0, 30, iconsize), "Ly");
                    lylab.ForeColor = Color.DarkOrange;
                    tpgb.Add(lylab);
                    hpos += lylab.Width + hpad;
                }

                if ((parts & Map.Parts.LimitSelector) != 0)
                {
                    GLComboBox cbstars = new GLComboBox("GalaxyStarsNumber", new Rectangle(hpos, 0, 150, iconsize));
                    cbstars.ToolTipText = "Control how many stars are shown when zoomes in";
                    cbstars.Items       = new List <string>()
                    {
                        "Stars-Ultra", "Stars-High", "Stars-Medium", "Stars-Low"
                    };
                    var list = new List <int>()
                    {
                        750000, 500000, 250000, 100000
                    };
                    int itemno = list.IndexOf(map.GalaxyStarsMaxObjects); // may be -1
                    if (itemno < 0)
                    {
                        itemno = 2;
                        map.GalaxyStarsMaxObjects = list[itemno];
                    }

                    cbstars.SelectedIndex         = itemno; // high default
                    cbstars.SelectedIndexChanged += (e1) => { map.GalaxyStarsMaxObjects = list[cbstars.SelectedIndex]; };
                    tpgb.Add(cbstars);
                }

                vpos += tpgb.Height + ypad;
            }

            if ((parts & Map.Parts.TravelPath) != 0)
            {
                GLGroupBox tpgb = new GLGroupBox("TravelPathGB", "Travel Path", new Rectangle(leftmargin, vpos, pform.ClientWidth - leftmargin * 2, iconsize * 3));
                tpgb.BackColor = Color.Transparent;
                tpgb.ForeColor = Color.Orange;
                pform.Add(tpgb);

                GLCheckBox buttp = new GLCheckBox("TravelPathTape", new Rectangle(leftmargin, 0, iconsize, iconsize), BaseUtils.Icons.IconSet.GetBitmap("GalMap.TravelPath"), null);
                buttp.ToolTipText   = "Show travel path";
                buttp.Checked       = map.TravelPathTapeDisplay;
                buttp.CheckChanged += (e1) => { map.TravelPathTapeDisplay = buttp.Checked; };
                tpgb.Add(buttp);

                GLDateTimePicker dtps = new GLDateTimePicker("TPStart", new Rectangle(50, 0, 350, 30), System.DateTime.Now);
                dtps.SuspendLayout();
                dtps.AutoSize      = true;
                dtps.ShowCheckBox  = dtps.ShowCalendar = true;
                dtps.Value         = map.TravelPathStartDate;
                dtps.Checked       = map.TravelPathStartDateEnable;
                dtps.ValueChanged += (e1) => { map.TravelPathStartDate = dtps.Value; map.TravelPathRefresh(); };
                dtps.CheckChanged += (e1) => { map.TravelPathStartDateEnable = dtps.Checked; map.TravelPathRefresh(); };
                dtps.ShowUpDown    = true;
                dtps.ResumeLayout();
                tpgb.Add(dtps);

                GLCheckBox buttptext = new GLCheckBox("TravelPathText", new Rectangle(leftmargin, 34, iconsize, iconsize), BaseUtils.Icons.IconSet.GetBitmap("GalMap.GalaxyStarsText"), null);
                buttptext.ToolTipText   = "Show names of stars when zoomed in";
                buttptext.Checked       = map.TravelPathTextDisplay;
                buttptext.CheckChanged += (e1) => { map.TravelPathTextDisplay = !map.TravelPathTextDisplay; };
                tpgb.Add(buttptext);

                GLDateTimePicker dtpe = new GLDateTimePicker("TPEnd", new Rectangle(50, 34, 350, 30), System.DateTime.Now);
                dtpe.SuspendLayout();
                dtpe.AutoSize      = true;
                dtpe.ShowCheckBox  = dtps.ShowCalendar = true;
                dtpe.Value         = map.TravelPathEndDate;
                dtpe.Checked       = map.TravelPathEndDateEnable;
                dtpe.ValueChanged += (e1) => { map.TravelPathEndDate = dtpe.Value; map.TravelPathRefresh(); };
                dtpe.CheckChanged += (e1) => { map.TravelPathEndDateEnable = dtpe.Checked; map.TravelPathRefresh(); };
                dtpe.ShowUpDown    = true;
                dtpe.ResumeLayout();
                tpgb.Add(dtpe);

                vpos += tpgb.Height + ypad;
            }

            if ((parts & Map.Parts.GalObjects) != 0)
            {
                GLGroupBox galgb = new GLGroupBox("GalGB", "Galaxy Objects", new Rectangle(leftmargin, vpos, pform.ClientWidth - leftmargin * 2, 50));
                galgb.ClientHeight = (iconsize + 4) * 2;
                galgb.BackColor    = Color.Transparent;
                galgb.ForeColor    = Color.Orange;
                pform.Add(galgb);
                GLFlowLayoutPanel galfp = new GLFlowLayoutPanel("GALFP", DockingType.Fill, 0);
                galfp.FlowPadding = new PaddingType(2, 2, 2, 2);
                galfp.BackColor   = Color.Transparent;
                galgb.Add(galfp);
                vpos += galgb.Height + ypad;

                IReadOnlyDictionary <GalMapType.VisibleObjectsType, Image> icons = new BaseUtils.Icons.IconGroup <GalMapType.VisibleObjectsType>("GalMap");

                for (int i = GalMapType.VisibleTypes.Length - 1; i >= 0; i--)
                {
                    var        gt   = GalMapType.VisibleTypes[i];
                    bool       en   = map.GetGalObjectTypeEnable(gt.TypeName);
                    GLCheckBox butg = new GLCheckBox("GMSEL" + i, new Rectangle(0, 0, iconsize, iconsize), icons[gt.VisibleType.Value], null);
                    butg.ToolTipText   = "Enable/Disable " + gt.Description;
                    butg.Checked       = en;
                    butg.CheckChanged += (e1) =>
                    {
                        map.SetGalObjectTypeEnable(gt.TypeName, butg.Checked);
                    };
                    galfp.Add(butg);
                }

                GLCheckBox butgonoff = new GLCheckBox("GMONOFF", new Rectangle(0, 0, iconsize, iconsize), BaseUtils.Icons.IconSet.GetBitmap("GalMap.ShowGalaxy"), null);
                butgonoff.ToolTipText   = "Enable/Disable Display";
                butgonoff.Checked       = map.GalObjectDisplay;
                butgonoff.CheckChanged += (e1) => { map.GalObjectDisplay = !map.GalObjectDisplay; };
                galfp.Add(butgonoff);
            }


            if ((parts & Map.Parts.Regions) != 0)
            {
                // EDSM regions

                GLGroupBox edsmregionsgb = new GLGroupBox("EDSMR", "EDSM Regions", new Rectangle(leftmargin, vpos, pform.ClientWidth - leftmargin * 2, 50));
                edsmregionsgb.ClientHeight = iconsize + 8;
                edsmregionsgb.BackColor    = Color.Transparent;
                edsmregionsgb.ForeColor    = Color.Orange;
                pform.Add(edsmregionsgb);
                vpos += edsmregionsgb.Height + ypad;

                GLCheckBox butedre = new GLCheckBox("EDSMRE", new Rectangle(leftmargin, 0, iconsize, iconsize), BaseUtils.Icons.IconSet.GetBitmap("GalMap.ShowGalaxy"), null);
                butedre.ToolTipText      = "Enable EDSM Regions";
                butedre.Checked          = map.EDSMRegionsEnable;
                butedre.UserCanOnlyCheck = true;
                edsmregionsgb.Add(butedre);

                GLCheckBox buted2 = new GLCheckBox("EDSMR2", new Rectangle(50, 0, iconsize, iconsize), BaseUtils.Icons.IconSet.GetBitmap("GalMap.RegionOutlines"), null);
                buted2.Checked       = map.EDSMRegionsOutlineEnable;
                buted2.Enabled       = map.EDSMRegionsEnable;
                buted2.ToolTipText   = "Enable Region Outlines";
                buted2.CheckChanged += (e1) => { map.EDSMRegionsOutlineEnable = !map.EDSMRegionsOutlineEnable; };
                edsmregionsgb.Add(buted2);

                GLCheckBox buted3 = new GLCheckBox("EDSMR3", new Rectangle(100, 0, iconsize, iconsize), BaseUtils.Icons.IconSet.GetBitmap("GalMap.RegionShading"), null);
                buted3.Checked       = map.EDSMRegionsShadingEnable;
                buted3.Enabled       = map.EDSMRegionsEnable;
                buted3.ToolTipText   = "Enable Region Shading";
                buted3.CheckChanged += (e1) => { map.EDSMRegionsShadingEnable = !map.EDSMRegionsShadingEnable; };
                edsmregionsgb.Add(buted3);

                GLCheckBox buted4 = new GLCheckBox("EDSMR4", new Rectangle(150, 0, iconsize, iconsize), BaseUtils.Icons.IconSet.GetBitmap("GalMap.RegionNames"), null);
                buted4.Checked       = map.EDSMRegionsTextEnable;
                buted4.Enabled       = map.EDSMRegionsEnable;
                buted4.ToolTipText   = "Enable Region Naming";
                buted4.CheckChanged += (e1) => { map.EDSMRegionsTextEnable = !map.EDSMRegionsTextEnable; };
                edsmregionsgb.Add(buted4);

                // elite regions

                GLGroupBox eliteregionsgb = new GLGroupBox("ELITER", "Elite Regions", new Rectangle(leftmargin, vpos, pform.ClientWidth - leftmargin * 2, 50));
                eliteregionsgb.ClientHeight = iconsize + 8;
                eliteregionsgb.BackColor    = Color.Transparent;
                eliteregionsgb.ForeColor    = Color.Orange;
                pform.Add(eliteregionsgb);
                vpos += eliteregionsgb.Height + ypad;

                GLCheckBox butelre = new GLCheckBox("ELITERE", new Rectangle(leftmargin, 0, iconsize, iconsize), BaseUtils.Icons.IconSet.GetBitmap("GalMap.ShowGalaxy"), null);
                butelre.ToolTipText      = "Enable Elite Regions";
                butelre.Checked          = map.EliteRegionsEnable;
                butelre.UserCanOnlyCheck = true;
                eliteregionsgb.Add(butelre);

                GLCheckBox butel2 = new GLCheckBox("ELITER2", new Rectangle(50, 0, iconsize, iconsize), BaseUtils.Icons.IconSet.GetBitmap("GalMap.RegionOutlines"), null);
                butel2.Checked       = map.EliteRegionsOutlineEnable;
                butel2.Enabled       = map.EliteRegionsEnable;
                butel2.ToolTipText   = "Enable Region Outlines";
                butel2.CheckChanged += (e1) => { map.EliteRegionsOutlineEnable = !map.EliteRegionsOutlineEnable; };
                eliteregionsgb.Add(butel2);

                GLCheckBox butel3 = new GLCheckBox("ELITER3", new Rectangle(100, 0, iconsize, iconsize), BaseUtils.Icons.IconSet.GetBitmap("GalMap.RegionShading"), null);
                butel3.Checked       = map.EliteRegionsShadingEnable;
                butel3.Enabled       = map.EliteRegionsEnable;
                butel3.ToolTipText   = "Enable Region Shading";
                butel3.CheckChanged += (e1) => { map.EliteRegionsShadingEnable = !map.EliteRegionsShadingEnable; };
                eliteregionsgb.Add(butel3);

                GLCheckBox butel4 = new GLCheckBox("ELITER4", new Rectangle(150, 0, iconsize, iconsize), BaseUtils.Icons.IconSet.GetBitmap("GalMap.RegionNames"), null);
                butel4.Checked       = map.EliteRegionsTextEnable;
                butel4.Enabled       = map.EliteRegionsEnable;
                butel4.ToolTipText   = "Enable Region Naming";
                butel4.CheckChanged += (e1) => { map.EliteRegionsTextEnable = !map.EliteRegionsTextEnable; };
                eliteregionsgb.Add(butel4);

                butedre.CheckChanged += (e) =>
                {
                    if (e.Name == "EDSMRE")
                    {
                        butelre.CheckedNoChangeEvent = !butedre.Checked;
                    }
                    else
                    {
                        butedre.CheckedNoChangeEvent = !butelre.Checked;
                    }

                    map.EDSMRegionsEnable  = butedre.Checked;
                    map.EliteRegionsEnable = butelre.Checked;

                    buted2.Enabled = buted3.Enabled = buted4.Enabled = butedre.Checked;
                    butel2.Enabled = butel3.Enabled = butel4.Enabled = butelre.Checked;
                };

                butelre.CheckChanged += butedre.CheckChanged;
            }

            pform.ClientHeight = vpos;

            map.displaycontrol.Add(pform);
        }