Esempio n. 1
0
		internal bool validation_failed; //track whether validation was cancelled by a validating control

		#region Public Constructors
		public ContainerControl() {
			active_control = null;
			unvalidated_control = null;
			ControlRemoved += new ControlEventHandler(OnControlRemoved);
			auto_scale_dimensions = SizeF.Empty;
			auto_scale_mode = AutoScaleMode.Inherit;
		}
Esempio n. 2
0
 private static SizeF GetCurrentAutoScaleSize(AutoScaleMode autoScaleMode)
 {
     using (Form form = new Form())
     {
         form.AutoScaleMode = autoScaleMode;
         return form.CurrentAutoScaleDimensions;
     }
 }
Esempio n. 3
0
 private static SizeF GetCurrentAutoScaleSize(AutoScaleMode autoScaleMode)
 {
     using (Form form = new Form())
     {
         form.AutoScaleMode = autoScaleMode;
         return(form.CurrentAutoScaleDimensions);
     }
 }
Esempio n. 4
0
        protected override void OnLoad(EventArgs e)
        {
            base.OnLoad(e);

            // Do this even in design mode to have valid UI.
            AutoScaleMode   = AutoScaleMode.None;
            Appearance.Font = SkinHelper.StandardFont;
        }
Esempio n. 5
0
        public void Form_AutoScaleModeGetSet(AutoScaleMode expected)
        {
            var form = new Form();

            form.AutoScaleMode = expected;

            Assert.Equal(expected, form.AutoScaleMode);
        }
Esempio n. 6
0
        public void PerformAutoScale_InvokeWithoutChildren_Success(AutoScaleMode autoScaleMode)
        {
            var control = new SubContainerControl
            {
                AutoScaleMode = autoScaleMode
            };

            control.PerformAutoScale();
        }
Esempio n. 7
0
 private static SizeF GetCurrentAutoScaleSize(AutoScaleMode autoScaleMode)
 {
     using (var form = new Form {
         AutoScaleMode = autoScaleMode
     })
     {
         return(form.CurrentAutoScaleDimensions);
     }
 }
Esempio n. 8
0
        public void SetAutoScale(AutoScaleMode mode, SizeF drawingSize)
        {
            AutoScaleMode       = mode;
            AutoScaleDimensions = drawingSize;
            //AutoSize = true;
            //AutoSizeMode = AutoSizeMode.GrowAndShrink;
            float scaleFactor = DESIGN_TIME_DPI / _currentDpi;

            ScaleFontForControl(this, scaleFactor);
            SetControlScaleModes(Controls, mode, Font, drawingSize);
        }
Esempio n. 9
0
        public void PerformAutoScale_InvokeWithChildren_Success(AutoScaleMode autoScaleMode)
        {
            var child   = new Control();
            var control = new SubContainerControl
            {
                AutoScaleMode = autoScaleMode
            };

            control.Controls.Add(child);
            control.PerformAutoScale();
        }
Esempio n. 10
0
        public void setAutoScaleMode(AutoScaleMode mode)
        {
            if (this.InvokeRequired)
            {
                this.BeginInvoke(new AutoScaleModeDelegate(setAutoScaleMode), new object[] { mode });
                return;
            }



            this.AutoScaleMode = mode;
        }
 /// <summary>
 /// Sets the automatic scale mode.
 /// </summary>
 /// <param name="control">The control.</param>
 /// <param name="value">The value.</param>
 public static void SetAutoScaleMode(this ContainerControl control, AutoScaleMode value)
 {
     if (control.InvokeRequired)
     {
         control.BeginInvoke(new MethodInvoker(() => control.SetAutoScaleMode(value)));
     }
     else
     {
         control.AutoScaleMode = value;
         control.Refresh();
     }
 }
Esempio n. 12
0
        public void Form_AutoScaleMode_Set_GetReturnsExpected(AutoScaleMode value)
        {
            var form = new Form
            {
                AutoScaleMode = value
            };

            Assert.Equal(value, form.AutoScaleMode);

            // Set same.
            form.AutoScaleMode = value;
            Assert.Equal(value, form.AutoScaleMode);
        }
Esempio n. 13
0
        public void AutoScaleMode_Set_GetReturnsExpected(AutoScaleMode value)
        {
            var control = new ContainerControl
            {
                AutoScaleMode = value
            };

            Assert.Equal(value, control.AutoScaleMode);

            // Set same.
            control.AutoScaleMode = value;
            Assert.Equal(value, control.AutoScaleMode);
        }
Esempio n. 14
0
        public void AutoScaleMode_SetDifferent_ResetsAutoScaleDimensions(AutoScaleMode value, SizeF expectedAutoScaleDimensions)
        {
            var control = new ContainerControl
            {
                AutoScaleDimensions = new SizeF(1, 2),
                AutoScaleMode       = AutoScaleMode.Font
            };

            control.AutoScaleMode = value;
            Assert.Equal(value, control.AutoScaleMode);
            Assert.Equal(expectedAutoScaleDimensions, control.AutoScaleDimensions);
            Assert.Equal(expectedAutoScaleDimensions, control.CurrentAutoScaleDimensions);
        }
Esempio n. 15
0
    protected override void clearFieldsDialog()
    {
        defaultModeWallpaper    = currentDesktopManager.ModeWallpaper;
        listWallpaperMode.value = defaultModeWallpaper == AutoScaleMode.FULL ? 0 : 1;

        sliderIconSize.value    = defaultIconSize = currentDesktopManager.IconScalePercentage;
        inputWallpaperPath.text = defaultWallpaperPath = currentDesktopManager.WallpaperImagePath;

        defaultIndexMinutesToChangeWallpaper = fromSecondsToDropdownIndex(currentDesktopManager.SecondsToChangeWallpaper);
        listMinutesToChangeWallpaper.value   = defaultIndexMinutesToChangeWallpaper;

        textNColumnsDesktop.text = DesktopRootReferenceManager.getInstance().desktopListManager.NumberOfColumns.ToString();
        textNDesktop.text        = DesktopRootReferenceManager.getInstance().desktopListManager.NumberOfDesktop.ToString();
    }
Esempio n. 16
0
        public static void SetAutoScaleMode(this Control control, AutoScaleMode autoScaleMode)
        {
            if (control == null)
            {
                return;
            }

            foreach (Control c in control.Controls)
            {
                SetAutoScaleMode(c, autoScaleMode);
            }

            if (control is ContainerControl)
            {
                ((ContainerControl)control).AutoScaleMode = autoScaleMode;
            }
        }
Esempio n. 17
0
 private void SetControlScaleModes(Control.ControlCollection controls, AutoScaleMode mode, Font font,
                                   SizeF drawingSize)
 {
     lblDenoteRequiredField.Text = "DPI:" + _currentDpi;
     foreach (Control control in controls)
     {
         //control.Font = font;
         SetControlScaleModes(control.Controls, mode, font, drawingSize);
         var container = control as ContainerControl;
         if (container != null)
         {
             container.AutoScaleMode       = mode;
             container.AutoScaleDimensions = drawingSize;
         }
         else
         {
             control.AutoSize = true;
         }
     }
 }
Esempio n. 18
0
 public void Init(Point pos, Icon icon, string caption, string lname = null, Object callertag = null, AutoScaleMode asm = AutoScaleMode.Font)
 {
     Init(icon, pos, caption, lname, callertag, false, asm);
 }
Esempio n. 19
0
        public void AutoScaleMode_SetInvalid_ThrowsInvalidEnumArgumentException(AutoScaleMode value)
        {
            var control = new ContainerControl();

            Assert.Throws <InvalidEnumArgumentException>("value", () => control.AutoScaleMode = value);
        }
Esempio n. 20
0
        private void Init(Icon icon, System.Drawing.Point pos, string caption, string lname, Object callertag, bool posiscentrecoords = false, AutoScaleMode asm = AutoScaleMode.Font)
        {
            this.logicalname = lname;     // passed back to caller via trigger
            this.callertag   = callertag; // passed back to caller via trigger

            ITheme theme = ThemeableFormsInstance.Instance;

            FormBorderStyle = FormBorderStyle.FixedDialog;

            ExtPanelScroll outer = new ExtPanelScroll()
            {
                Dock = DockStyle.Fill, BorderStyle = BorderStyle.FixedSingle
            };

            outer.MouseDown += FormMouseDown;
            outer.MouseUp   += FormMouseUp;
            Controls.Add(outer);

            ExtScrollBar scr = new ExtScrollBar();

            scr.HideScrollBar = true;
            outer.Controls.Add(scr);

            this.Text = caption;

            Label textLabel = new Label()
            {
                Left = 4, Top = 8, Width = Width - 50, Text = caption
            };

            textLabel.MouseDown += FormMouseDown;
            textLabel.MouseUp   += FormMouseUp;

            if (!theme.WindowsFrame)
            {
                outer.Controls.Add(textLabel);
            }

            ToolTip tt = new ToolTip(components);

            tt.ShowAlways = true;
            for (int i = 0; i < entries.Count; i++)
            {
                Entry   ent = entries[i];
                Control c   = ent.controltype != null ? (Control)Activator.CreateInstance(ent.controltype) : ent.control;
                ent.control = c;
                c.Size      = ent.size;
                c.Location  = ent.pos;
                //System.Diagnostics.Debug.WriteLine("Control " + c.GetType().ToString() + " at " + c.Location + " " + c.Size);
                if (!(ent.controltype == null || c is ExtendedControls.ExtComboBox || c is ExtendedControls.ExtDateTimePicker || c is ExtendedControls.NumberBoxDouble || c is ExtendedControls.NumberBoxLong))         // everything but get text
                {
                    c.Text = ent.text;
                }
                c.Tag = ent;     // point control tag at ent structure
                outer.Controls.Add(c);
                if (ent.tooltip != null)
                {
                    tt.SetToolTip(c, ent.tooltip);
                }

                if (c is ExtendedControls.ExtButton)
                {
                    ExtendedControls.ExtButton b = c as ExtendedControls.ExtButton;
                    b.Click += (sender, ev) =>
                    {
                        if (!ProgClose)
                        {
                            Entry en = (Entry)(((Control)sender).Tag);
                            Trigger?.Invoke(logicalname, en.controlname, this.callertag);       // pass back the logical name of dialog, the name of the control, the caller tag
                        }
                    };
                }
                else if (c is ExtendedControls.NumberBoxDouble)
                {
                    ExtendedControls.NumberBoxDouble cb = c as ExtendedControls.NumberBoxDouble;
                    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) =>
                    {
                        SwallowReturn = false;
                        if (!ProgClose)
                        {
                            Entry en = (Entry)(box.Tag);
                            Trigger?.Invoke(logicalname, en.controlname + ":Return", this.callertag);       // pass back the logical name of dialog, the name of the control, the caller tag
                        }

                        return(SwallowReturn);
                    };
                    cb.ValidityChanged += (box, s) =>
                    {
                        if (!ProgClose)
                        {
                            Entry en = (Entry)(box.Tag);
                            Trigger?.Invoke(logicalname, en.controlname + ":Validity:" + s.ToString(), this.callertag);       // pass back the logical name of dialog, the name of the control, the caller tag
                        }
                    };
                }
                else if (c is ExtendedControls.NumberBoxLong)
                {
                    ExtendedControls.NumberBoxLong cb = c as ExtendedControls.NumberBoxLong;
                    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) =>
                    {
                        SwallowReturn = false;
                        if (!ProgClose)
                        {
                            Entry en = (Entry)(box.Tag);
                            Trigger?.Invoke(logicalname, en.controlname + ":Return", this.callertag);       // pass back the logical name of dialog, the name of the control, the caller tag
                        }
                        return(SwallowReturn);
                    };
                    cb.ValidityChanged += (box, s) =>
                    {
                        if (!ProgClose)
                        {
                            Entry en = (Entry)(box.Tag);
                            Trigger?.Invoke(logicalname, en.controlname + ":Validity:" + s.ToString(), this.callertag);       // pass back the logical name of dialog, the name of the control, the caller tag
                        }
                    };
                }
                else if (c is ExtendedControls.ExtTextBox)
                {
                    ExtendedControls.ExtTextBox tb = c as ExtendedControls.ExtTextBox;
                    tb.Multiline        = tb.WordWrap = ent.textboxmultiline;
                    tb.Size             = ent.size; // restate size in case multiline is on
                    tb.ClearOnFirstChar = ent.clearonfirstchar;
                    tb.ReturnPressed   += (box) =>
                    {
                        SwallowReturn = false;
                        if (!ProgClose)
                        {
                            Entry en = (Entry)(box.Tag);
                            Trigger?.Invoke(logicalname, en.controlname + ":Return", this.callertag);       // pass back the logical name of dialog, the name of the control, the caller tag
                        }
                        return(SwallowReturn);
                    };
                }
                else if (c is ExtendedControls.ExtCheckBox)
                {
                    ExtendedControls.ExtCheckBox cb = c as ExtendedControls.ExtCheckBox;
                    cb.Checked = ent.checkboxchecked;
                    cb.Click  += (sender, ev) =>
                    {
                        if (!ProgClose)
                        {
                            Entry en = (Entry)(((Control)sender).Tag);
                            Trigger?.Invoke(logicalname, en.controlname, this.callertag);       // pass back the logical name of dialog, the name of the control, the caller tag
                        }
                    };
                }


                if (c is ExtendedControls.ExtDateTimePicker)
                {
                    ExtendedControls.ExtDateTimePicker dt = c as ExtendedControls.ExtDateTimePicker;
                    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 = DateTimePickerFormat.Short;
                        break;

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

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

                    default:
                        dt.CustomFormat = ent.customdateformat;
                        break;
                    }
                }

                if (c is ExtendedControls.ExtComboBox)
                {
                    ExtendedControls.ExtComboBox cb = c as ExtendedControls.ExtComboBox;

                    cb.Items.AddRange(ent.comboboxitems.Split(','));
                    if (cb.Items.Contains(ent.text))
                    {
                        cb.SelectedItem = ent.text;
                    }
                    cb.SelectedIndexChanged += (sender, ev) =>
                    {
                        Control ctr = (Control)sender;
                        if (ctr.Enabled && !ProgClose)
                        {
                            Entry en = (Entry)(ctr.Tag);
                            Trigger?.Invoke(logicalname, en.controlname, this.callertag);       // pass back the logical name of dialog, the name of the control, the caller tag
                        }
                    };
                }
            }

            ShowInTaskbar = false;

            this.Icon = icon;

            this.AutoScaleMode = asm;

            //this.DumpTree(0);
            theme.ApplyStd(this);
            //this.DumpTree(0);

            int fh = (int)this.Font.GetHeight();        // use the FH to nerf the extra area so it scales with FH.. this helps keep the controls within a framed window

            // measure the items after scaling. Exclude the scroll bar
            Size measureitemsinwindow = outer.FindMaxSubControlArea(fh + 8, (theme.WindowsFrame ? 50 : 16) + fh, new Type[] { typeof(ExtScrollBar) });

            StartPosition = FormStartPosition.Manual;

            Location = pos;

            this.PositionSizeWithinScreen(measureitemsinwindow.Width, measureitemsinwindow.Height, false, 64, centrecoords: posiscentrecoords);
        }
Esempio n. 21
0
 public void Init(Point pos, Icon icon, string caption, string lname = null, Object callertag = null, AutoScaleMode asm = AutoScaleMode.Font, bool closeicon = false)
 {
     Init(icon, pos, caption, lname, callertag, closeicon, null, null, asm);
 }
 public JSONMapperAutoScaleBackgroundToCamera(AutoScaleBackgroundToCamera autoscaler)
 {
     mode = autoscaler.mode;
     backgroundPathList           = autoscaler.backgroundPathList;
     secondsToAutoChangeWallpaper = autoscaler.SecondsToAutoChangeWallpaper;
 }
 public void InitCentred(Form p, Icon icon, string caption, string lname = null, Object callertag = null,
                         AutoScaleMode asm = AutoScaleMode.Font, bool closeicon = false)
 {
     Init(icon, new Size(1, 1), new Size(50000, 50000), new Point((p.Left + p.Right) / 2, (p.Top + p.Bottom) / 2), caption, lname, callertag, closeicon,
          HorizontalAlignment.Center, ControlHelpersStaticFunc.VerticalAlignment.Middle, asm);
 }
Esempio n. 24
0
 public void Init(Size minsize, Size maxsize, Point pos, Icon icon, string caption, string lname = null, Object callertag = null,
                  AutoScaleMode asm = AutoScaleMode.Font, bool closeicon = false, bool transparent = false)
 {
     Init(icon, minsize, maxsize, pos, caption, lname, callertag, closeicon, null, null, asm, transparent);
 }
Esempio n. 25
0
 public void InitCentred(Form p, Size minsize, Size maxsize, Icon icon, string caption, string lname = null, Object callertag = null,
                         AutoScaleMode asm = AutoScaleMode.Font, bool closeicon = false, bool transparent = false)
 {
     Init(icon, minsize, maxsize, new Point((p.Left + p.Right) / 2, (p.Top + p.Bottom) / 2), caption, lname, callertag, closeicon,
          HorizontalAlignment.Center, ControlHelpersStaticFunc.VerticalAlignment.Middle, asm, transparent);
 }
Esempio n. 26
0
        public void setAutoScaleMode(AutoScaleMode mode)
        {
            if (this.InvokeRequired)
            {
                this.BeginInvoke(new AutoScaleModeDelegate(setAutoScaleMode), new object[] { mode });
                return;
            }

            this.AutoScaleMode = mode;
        }
Esempio n. 27
0
 public static void ApplyInternalProperties()
 {
     if (ComicSans)
     {
         FontName = ComicSansFontType;
     }
     else
     {
         FontName = DefaultFontType;
     }
     switch (FontSizeforum)
     {
         default:
             //set the autoscale mode
             AppScalingMode = AutoScaleMode.Font;
             //set the scale amount
             ScaleSize = Scale100;
             //set the font
             AppFont = new Font(DefaultFontType, FontSize100);
             break;
         case FontSize.Font100:
             ScaleSize = Scale100;
             AppScalingMode = AutoScaleMode.Font;
             AppFont = new Font(FontName, FontSize100);
             break;
         case FontSize.Font125:
             ScaleSize = Scale125;
             AppScalingMode = AutoScaleMode.Font;
             AppFont = new Font(FontName, FontSize125);
             break;
         case FontSize.Font175:
             ScaleSize = Scale175;
             AppScalingMode = AutoScaleMode.Font;
             AppFont = new Font(FontName, FontSize175);
             break;
         case FontSize.Font225:
             ScaleSize = Scale225;
             AppScalingMode = AutoScaleMode.Font;
             AppFont = new Font(FontName, FontSize225);
             break;
         case FontSize.Font275:
             ScaleSize = Scale275;
             AppScalingMode = AutoScaleMode.Font;
             AppFont = new Font(FontName, FontSize275);
             break;
         case FontSize.DPI100:
             ScaleSize = Scale100;
             AppScalingMode = AutoScaleMode.Dpi;
             AppFont = new Font(FontName, FontSize100);
             break;
         case FontSize.DPI125:
             ScaleSize = Scale125;
             AppScalingMode = AutoScaleMode.Dpi;
             AppFont = new Font(FontName, FontSize125);
             break;
         case FontSize.DPI175:
             ScaleSize = Scale175;
             AppScalingMode = AutoScaleMode.Dpi;
             AppFont = new Font(FontName, FontSize175);
             break;
         case FontSize.DPI225:
             ScaleSize = Scale225;
             AppScalingMode = AutoScaleMode.Dpi;
             AppFont = new Font(FontName, FontSize225);
             break;
         case FontSize.DPI275:
             ScaleSize = Scale275;
             AppScalingMode = AutoScaleMode.Dpi;
             AppFont = new Font(FontName, FontSize275);
             break;
         case FontSize.DPIAUTO:
             ScaleSize = Utils.GetScalingFactor();
             AppScalingMode = AutoScaleMode.Dpi;
             float nweFontSize = FontSize100 * ScaleSize;
             float roundedanswer = (float)Math.Round(nweFontSize * 4, MidpointRounding.ToEven) / 4;
             AppFont = new Font(FontName, roundedanswer);
             break;
     }
 }
Esempio n. 28
0
        public static void ShowScanOrMarketForm(Form parent, Object tag, bool checkedsm, HistoryList hl)     // tag can be a Isystem or an He.. output depends on it.
        {
            Type ty = typeof(ScanDisplayForm);

            if (tag == null)
            {
                return;
            }

            ExtendedControls.ConfigurableForm f = new ExtendedControls.ConfigurableForm();

            Size infosize  = parent.SizeWithinScreen(new Size(parent.Width * 2 / 4, parent.Height * 2 / 4), 128, 128 + 100);    // go for this, but allow this around window
            int  topmargin = 40;

            HistoryEntry           he  = tag as HistoryEntry;                     // is tag HE?
            ISystem                sys = he != null ? he.System : tag as ISystem; // if so, sys is he.system, else its a direct sys
            ScanDisplayUserControl sd  = null;
            string title = "System".Tx(ty, "Sys") + ": " + sys.Name;

            AutoScaleMode asm = AutoScaleMode.Font;

            if (he != null && (he.EntryType == JournalTypeEnum.Market || he.EntryType == JournalTypeEnum.EDDCommodityPrices))  // station data..
            {
                JournalCommodityPricesBase jm = he.journalEntry as JournalCommodityPricesBase;
                jm.FillInformation(out string info, out string detailed, 1);

                f.Add(new ExtendedControls.ConfigurableForm.Entry("RTB", typeof(ExtendedControls.ExtRichTextBox), detailed, new Point(0, topmargin), infosize, null));

                title += ", " + "Station".Tx(ty) + ": " + jm.Station;
            }
            else
            {
                sd           = new ScanDisplayUserControl();
                sd.CheckEDSM = checkedsm;
                sd.ShowMoons = sd.ShowMaterials = sd.ShowOverlays = true;
                int selsize = (int)(EDDTheme.Instance.GetFont.Height / 16.0f * 48.0f);
                sd.SetSize(selsize);
                sd.Size = infosize;

                StarScan.SystemNode data = sd.FindSystem(sys, hl);
                if (data != null)
                {
                    long value = data.ScanValue(sd.CheckEDSM);
                    title += " ~ " + value.ToString("N0") + " cr";
                }

                sd.BackColor = EDDTheme.Instance.Form;
                sd.DrawSystem(data, null, hl);

                infosize = new Size(Math.Max(400, sd.DisplayAreaUsed.X), Math.Max(200, sd.DisplayAreaUsed.Y));

                asm = AutoScaleMode.None;   // because we are using a picture box, it does not autoscale, so we can't use that logic on it.

                f.Add(new ExtendedControls.ConfigurableForm.Entry("Sys", null, null, new Point(0, topmargin), infosize, null)
                {
                    control = sd
                });
            }

            f.Add(new ExtendedControls.ConfigurableForm.Entry("OK", typeof(ExtendedControls.ExtButton), "OK".Tx(), new Point(infosize.Width - 120, topmargin + infosize.Height + 10), new Size(100, 24), ""));

            f.Trigger += (dialogname, controlname, ttag) =>
            {
                if (controlname == "OK" || controlname == "Cancel")
                {
                    f.Close();
                }
            };

            f.InitCentred(parent, parent.Icon, title, null, null, asm);

            f.Show(parent);
        }
Esempio n. 29
0
 /// <summary>
 /// Required method for Designer support - do not modify
 /// the contents of this method with the code editor.
 /// </summary>
 private void InitializeComponent()
 {
     components         = new System.ComponentModel.Container();
     this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
 }
 /// <summary>
 /// Required method for Designer support - do not modify
 /// the contents of this method with the code editor.
 /// </summary>
 private void InitializeComponent()
 {
     this.components    = new System.ComponentModel.Container();
     this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
     this.Text          = "OvalPictureBox";
 }
Esempio n. 31
0
        private void Init(Icon icon, System.Drawing.Size minsize, System.Drawing.Size maxsize, System.Drawing.Point pos,
                          string caption, string lname, Object callertag, bool closeicon,
                          HorizontalAlignment?halign, ControlHelpersStaticFunc.VerticalAlignment?valign,
                          AutoScaleMode asm, bool transparent)
        {
            this.logicalname = lname;     // passed back to caller via trigger
            this.callertag   = callertag; // passed back to caller via trigger

            this.halign = halign;
            this.valign = valign;

            this.minsize = minsize;       // set min size window
            this.maxsize = maxsize;

            ITheme theme = ThemeableFormsInstance.Instance;

            FormBorderStyle = FormBorderStyle.FixedDialog;

            //outer = new ExtPanelScroll() { Dock = DockStyle.Fill, BorderStyle = BorderStyle.FixedSingle, Margin = new Padding(0), Padding = new Padding(0) };
            outer = new ExtPanelScroll()
            {
                Name = "Outer", BorderStyle = BorderStyle.FixedSingle, Margin = new Padding(0), Padding = new Padding(0)
            };
            outer.MouseDown += FormMouseDown;
            outer.MouseUp   += FormMouseUp;
            Controls.Add(outer);

            ExtScrollBar scr = new ExtScrollBar();

            scr.HideScrollBar = true;
            outer.Controls.Add(scr);

            this.Text = caption;

            int yoffset = 0;                            // adjustment to move controls up if windows frame present.

            if (theme.WindowsFrame && !ForceNoBorder)
            {
                yoffset = int.MaxValue;
                for (int i = 0; i < entries.Count; i++)             // find minimum control Y
                {
                    yoffset = Math.Min(yoffset, entries[i].pos.Y);
                }

                yoffset -= 8;           // place X spaces below top
            }
            else
            {
                titlelabel = new Label()
                {
                    Name = "title", Left = 4, Top = 8, Width = 10, Text = caption, AutoSize = true
                };                                                                                                         // autosize it, and set width small so it does not mess up the computation below
                titlelabel.MouseDown += FormMouseDown;
                titlelabel.MouseUp   += FormMouseUp;
                titlelabel.Name       = "title";
                outer.Controls.Add(titlelabel);

                if (closeicon)
                {
                    closebutton = new ExtButtonDrawn()
                    {
                        Name = "closebut", Size = new Size(18, 18), Location = new Point(0, 0)
                    };                                                                                                                 // purposely at top left to make it not contribute to overall size
                    closebutton.ImageSelected = ExtButtonDrawn.ImageType.Close;
                    closebutton.Click        += (sender, f) =>
                    {
                        if (!ProgClose)
                        {
                            Trigger?.Invoke(logicalname, "Close", callertag);
                        }
                    };

                    outer.Controls.Add(closebutton);            // add now so it gets themed
                }
            }

            ToolTip tt = new ToolTip(components);

            tt.ShowAlways = true;

            for (int i = 0; i < entries.Count; i++)
            {
                Entry   ent = entries[i];
                Control c   = ent.controltype != null ? (Control)Activator.CreateInstance(ent.controltype) : ent.control;
                ent.control = c;
                c.Size      = ent.size;
                c.Location  = new Point(ent.pos.X, ent.pos.Y - yoffset);
                c.Name      = ent.controlname;
                if (!(ent.text == null || c is ExtendedControls.ExtComboBox || c is ExtendedControls.ExtDateTimePicker || c is ExtendedControls.NumberBoxDouble || c is ExtendedControls.NumberBoxLong))        // everything but get text
                {
                    c.Text = ent.text;
                }
                c.Tag = ent;     // point control tag at ent structure
                System.Diagnostics.Debug.WriteLine("Control " + c.GetType().ToString() + " at " + c.Location + " " + c.Size + " " + c.Text);
                outer.Controls.Add(c);
                if (ent.tooltip != null)
                {
                    tt.SetToolTip(c, ent.tooltip);
                }

                if (c is Label)
                {
                    Label l = c as Label;
                    if (ent.textalign.HasValue)
                    {
                        l.TextAlign = ent.textalign.Value;
                    }
                }
                else if (c is ExtendedControls.ExtButton)
                {
                    ExtendedControls.ExtButton b = c as ExtendedControls.ExtButton;
                    if (ent.textalign.HasValue)
                    {
                        b.TextAlign = ent.textalign.Value;
                    }
                    b.Click += (sender, ev) =>
                    {
                        if (!ProgClose)
                        {
                            Entry en = (Entry)(((Control)sender).Tag);
                            Trigger?.Invoke(logicalname, en.controlname, this.callertag);       // pass back the logical name of dialog, the name of the control, the caller tag
                        }
                    };
                }
                else if (c is ExtendedControls.NumberBoxDouble)
                {
                    ExtendedControls.NumberBoxDouble cb = c as ExtendedControls.NumberBoxDouble;
                    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) =>
                    {
                        SwallowReturn = false;
                        if (!ProgClose)
                        {
                            Entry en = (Entry)(box.Tag);
                            Trigger?.Invoke(logicalname, en.controlname + ":Return", this.callertag);       // pass back the logical name of dialog, the name of the control, the caller tag
                        }

                        return(SwallowReturn);
                    };
                    cb.ValidityChanged += (box, s) =>
                    {
                        if (!ProgClose)
                        {
                            Entry en = (Entry)(box.Tag);
                            Trigger?.Invoke(logicalname, en.controlname + ":Validity:" + s.ToString(), this.callertag);       // pass back the logical name of dialog, the name of the control, the caller tag
                        }
                    };
                }
                else if (c is ExtendedControls.NumberBoxLong)
                {
                    ExtendedControls.NumberBoxLong cb = c as ExtendedControls.NumberBoxLong;
                    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) =>
                    {
                        SwallowReturn = false;
                        if (!ProgClose)
                        {
                            Entry en = (Entry)(box.Tag);
                            Trigger?.Invoke(logicalname, en.controlname + ":Return", this.callertag);       // pass back the logical name of dialog, the name of the control, the caller tag
                        }
                        return(SwallowReturn);
                    };
                    cb.ValidityChanged += (box, s) =>
                    {
                        if (!ProgClose)
                        {
                            Entry en = (Entry)(box.Tag);
                            Trigger?.Invoke(logicalname, en.controlname + ":Validity:" + s.ToString(), this.callertag);       // pass back the logical name of dialog, the name of the control, the caller tag
                        }
                    };
                }
                else if (c is ExtendedControls.ExtTextBox)
                {
                    ExtendedControls.ExtTextBox tb = c as ExtendedControls.ExtTextBox;
                    tb.Multiline        = tb.WordWrap = ent.textboxmultiline;
                    tb.Size             = ent.size; // restate size in case multiline is on
                    tb.ClearOnFirstChar = ent.clearonfirstchar;
                    tb.ReturnPressed   += (box) =>
                    {
                        SwallowReturn = false;
                        if (!ProgClose)
                        {
                            Entry en = (Entry)(box.Tag);
                            Trigger?.Invoke(logicalname, en.controlname + ":Return", this.callertag);       // pass back the logical name of dialog, the name of the control, the caller tag
                        }
                        return(SwallowReturn);
                    };

                    if (tb.ClearOnFirstChar)
                    {
                        tb.SelectEnd();
                    }
                }
                else if (c is ExtendedControls.ExtCheckBox)
                {
                    ExtendedControls.ExtCheckBox cb = c as ExtendedControls.ExtCheckBox;
                    cb.Checked = ent.checkboxchecked;
                    cb.Click  += (sender, ev) =>
                    {
                        if (!ProgClose)
                        {
                            Entry en = (Entry)(((Control)sender).Tag);
                            Trigger?.Invoke(logicalname, en.controlname, this.callertag);       // pass back the logical name of dialog, the name of the control, the caller tag
                        }
                    };
                }


                if (c is ExtendedControls.ExtDateTimePicker)
                {
                    ExtendedControls.ExtDateTimePicker dt = c as ExtendedControls.ExtDateTimePicker;
                    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 = DateTimePickerFormat.Short;
                        break;

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

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

                    default:
                        dt.CustomFormat = ent.customdateformat;
                        break;
                    }
                }

                if (c is ExtendedControls.ExtComboBox)
                {
                    ExtendedControls.ExtComboBox cb = c as ExtendedControls.ExtComboBox;

                    cb.Items.AddRange(ent.comboboxitems.Split(','));
                    if (cb.Items.Contains(ent.text))
                    {
                        cb.SelectedItem = ent.text;
                    }
                    cb.SelectedIndexChanged += (sender, ev) =>
                    {
                        Control ctr = (Control)sender;
                        if (ctr.Enabled && !ProgClose)
                        {
                            Entry en = (Entry)(ctr.Tag);
                            Trigger?.Invoke(logicalname, en.controlname, this.callertag);       // pass back the logical name of dialog, the name of the control, the caller tag
                        }
                    };
                }
            }

            ShowInTaskbar = false;

            this.Icon = icon;

            this.AutoScaleMode = asm;

            // outer.FindMaxSubControlArea(0, 0,null,true); // debug

            //this.DumpTree(0);
            theme.ApplyStd(this, ForceNoBorder);
            //theme.Apply(this, new Font("ms Sans Serif", 16f));
            //this.DumpTree(0);

            if (transparent)
            {
                TransparencyKey = BackColor;
            }

            for (int i = 0; i < entries.Count; i++)     // post scale any controls which ask for different font ratio sizes
            {
                if (entries[i].PostThemeFontScale != 1.0f)
                {
                    entries[i].control.Font = new Font(entries[i].control.Font.Name, entries[i].control.Font.SizeInPoints * entries[i].PostThemeFontScale);
                }
            }

            // position
            StartPosition = FormStartPosition.Manual;
            this.Location = pos;

            //System.Diagnostics.Debug.WriteLine("Bounds " + Bounds + " ClientRect " + ClientRectangle);
            //System.Diagnostics.Debug.WriteLine("Outer Bounds " + outer.Bounds + " ClientRect " + outer.ClientRectangle);
        }
        public static async void ShowScanOrMarketForm(Form parent, Object tag, bool checkedsm, HistoryList hl)     // tag can be a Isystem or an He.. output depends on it.
        {
            if (tag == null)
            {
                return;
            }

            ExtendedControls.ConfigurableForm f = new ExtendedControls.ConfigurableForm();

            Size infosize  = parent.SizeWithinScreen(new Size(parent.Width * 6 / 8, parent.Height * 6 / 8), 128, 128 + 100);       // go for this, but allow this around window
            int  topmargin = 40;

            HistoryEntry           he  = tag as HistoryEntry;                     // is tag HE?
            ISystem                sys = he != null ? he.System : tag as ISystem; // if so, sys is he.system, else its a direct sys
            ScanDisplayUserControl sd  = null;
            string title = "System".T(EDTx.ScanDisplayForm_Sys) + ": " + sys.Name;

            AutoScaleMode asm = AutoScaleMode.Font;

            if (he != null && (he.EntryType == JournalTypeEnum.Market || he.EntryType == JournalTypeEnum.EDDCommodityPrices))  // station data..
            {
                he.FillInformation(out string info, out string detailed);

                f.Add(new ExtendedControls.ConfigurableForm.Entry("RTB", typeof(ExtendedControls.ExtRichTextBox), detailed, new Point(0, topmargin), infosize, null));

                JournalCommodityPricesBase jm = he.journalEntry as JournalCommodityPricesBase;
                title += ", " + "Station".T(EDTx.ScanDisplayForm_Station) + ": " + jm.Station;
            }
            else
            {
                sd           = new ScanDisplayUserControl();
                sd.CheckEDSM = checkedsm;
                int selsize = (int)(EDDTheme.Instance.GetFont.Height / 16.0f * 48.0f);
                sd.SetSize(selsize);
                sd.Size = infosize;

                StarScan.SystemNode data = await hl.StarScan.FindSystemAsync(sys, sd.CheckEDSM);    // look up system async

                if (data != null)
                {
                    long value = data.ScanValue(sd.CheckEDSM);
                    title += " ~ " + value.ToString("N0") + " cr";
                }

                sd.BackColor = EDDTheme.Instance.Form;
                sd.DrawSystem(data, null, hl);

                int wastedh = infosize.Height - sd.DisplayAreaUsed.Y - 10 - 40;
                if (wastedh > 0)
                {
                    infosize.Height -= wastedh;
                }

                asm = AutoScaleMode.None;   // because we are using a picture box, it does not autoscale, so we can't use that logic on it.

                f.Add(new ExtendedControls.ConfigurableForm.Entry("Sys", null, null, new Point(0, topmargin), infosize, null)
                {
                    control = sd
                });
            }

            f.AddOK(new Point(infosize.Width - 120, topmargin + infosize.Height + 10));

            f.Trigger += (dialogname, controlname, ttag) =>
            {
                if (controlname == "OK")
                {
                    f.ReturnResult(DialogResult.OK);
                }
                else if (controlname == "Close")
                {
                    f.ReturnResult(DialogResult.Cancel);
                }
            };

            f.InitCentred(parent, parent.Icon, title, null, null, asm, closeicon: true);

            f.Show(parent);
        }
Esempio n. 33
0
    public void onChangeWallpaperMode()
    {
        AutoScaleMode modeWallpaper = (listWallpaperMode.value == 0) ? AutoScaleMode.FULL : AutoScaleMode.MAXIMIZE;

        currentDesktopManager.changeModeWallpaper(modeWallpaper);
    }