public override void Show(SummerGUIWindow parent) { //ParentWindow = parent; base.Show(parent); InitAnimation(); Invalidate(); }
public AboutScreen(string name, string caption, int width, int height, SummerGUIWindow parent) : base(name, caption, width, height, parent, true, GameWindowFlags.FixedWindow) { ShowInTaskBar = false; InitButtons(); InitTable(); }
public FontManager(SummerGUIWindow owner) { Owner = owner; FontManager.DPI = 96; Fonts = new Dictionary <string, IGUIFont> (); FontConfigs = new Dictionary <string, GUIFontConfiguration> (); InitFontConfigs(); }
public virtual void Show(SummerGUIWindow parent) { if (parent != null) { parent.Controls.AddChild(this); } this.Focus(); }
public static DialogResults ShowWarning(string msg, SummerGUIWindow parent) { string caption = DefaultCaption; if (String.IsNullOrEmpty(caption)) { caption = "Warning"; } return(Show(caption, msg, MessageBoxTypes.Warning, MessageBoxButtons.OK, parent)); }
public static DialogResults ShowContinueRepeat(string msg, SummerGUIWindow parent) { string caption = DefaultCaption; if (String.IsNullOrEmpty(caption)) { caption = "Question"; } return(Show(caption, msg, MessageBoxTypes.Question, MessageBoxButtons.ContinueRepeatCancel, parent)); }
/*** * protected override void OnKeyDown (KeyboardKeyEventArgs e) * { * switch (e.Key) { * case Key.Escape: * OnCancel (); * break; * case Key.Enter: * OnOK (); * break; * default: * base.OnKeyDown (e); * break; * } * } ****/ public void Show(SummerGUIWindow parent) { if (ParentWindow != parent) { this.LogWarning("Parent should equal ParentWindow"); } if (ParentWindow != null) { ParentWindow.AddChildWindow(this); } this.Run(); }
public ContactForm(SummerGUIWindow parent, Contact contact) : base("ContactForm", contact == null ? "New Contact" : "Edit Contact", (520 * parent.ScaleFactor).Ceil(), (364 * parent.ScaleFactor).Ceil(), parent, true) { Notifications = AddChild(new NotificationPanel("notifications")); Contact = contact; BackColor = Theme.Colors.Base2; InitButtons(); InitTable(); GetData(); Table.Children ["FirstName"].TabInto(); RemoveBorders(); }
protected virtual RectangleF GetSubMenuBounds(SubMenuOverlay sub) { SummerGUIWindow aw = ParentWindow; if (aw == null || aw.Width < 5 || aw.Height < 5) { return(RectangleF.Empty); } RectangleF bounds = Bounds; SizeF sz = sub.PreferredSize(aw); float w = Math.Min(sz.Width, aw.Width); float h = Math.Min(sz.Height, aw.Height); float y = 0; try { y = itemStartPositions[Menu.IndexOf(m_ActiveItem)] - Padding.Top; } catch (Exception ex) { ex.LogError(); } RectangleF rsub = new RectangleF( bounds.Right, y, w, h); try { float ofs = 5 * ParentWindow.ScaleFactor; rsub.Offset(-ofs, -ofs); } catch (Exception ex) { ex.LogError(); } if (rsub.Right > aw.Width) { rsub.Offset(aw.Width - rsub.Right, 0); } if (rsub.Bottom > aw.Height) { rsub.Offset(0, aw.Height - rsub.Bottom); } return(rsub); }
protected virtual RectangleF GetDropDownBounds() { SummerGUIWindow aw = ParentWindow; if (aw == null) { return(RectangleF.Empty); } //Rectangle bounds = ClientRectangle; RectangleF bounds = MarginBounds; float spaceAbove = bounds.Top; float spaceBelow = aw.Height - bounds.Bottom; float desiredHeight = DropDownHeight; float desiredWidth = DropDownWidth; float maxspace = Math.Max(spaceAbove, spaceBelow); if (desiredHeight > maxspace) { desiredHeight = (maxspace / ItemHeight) * ItemHeight; } if (desiredHeight < 1 || desiredWidth < 1) { return(RectangleF.Empty); } if (spaceBelow >= desiredHeight) { return(new RectangleF(bounds.Left, bounds.Bottom, desiredWidth, desiredHeight)); } if (spaceAbove >= desiredHeight) { return(new RectangleF(bounds.Left, bounds.Top - desiredHeight, desiredWidth, desiredHeight)); } return(RectangleF.Empty); }
//[STAThread] static void Main(string[] args) { // Setup logging Logging.SetupLogging(LogLevels.Verbose, LogTargets.Console); // Setup global exception handlers AppDomain.CurrentDomain.UnhandledException += ExceptionUnhandled; AppDomain.CurrentDomain.FirstChanceException += AppDomain_CurrentDomain_FirstChanceException; // This step is required. // Since we can't make this static class inheritable, // you have to do it here, until we find a smarter solution int pf = (int)Environment.OSVersion.Platform; if (pf != 4 && pf != 6 && pf != 128) { string path = Path.GetDirectoryName(Assembly.GetEntryAssembly().Location); path = Path.Combine(path, IntPtr.Size == 8 ? "x64" : "x86"); if (!SetDllDirectory(path)) { throw new System.ComponentModel.Win32Exception(); } } InitApplication(); // >>> Bug in OpenTK: Program hangs on Exit, when using this option.. // don't use SDL2 //OpenTK.ToolkitOptions.Default.Backend = OpenTK.PlatformBackend.PreferNative; //OpenTK.Toolkit.Init (); // testing the ThemeLoader class //ThemeLoader loader = new ThemeLoader (Strings.ApplicationPath (true) + "ColorTheme.config"); using (MainForm wnd = new MainForm()) { MainWindow = wnd; // The frame rate is throttled to a value between 30 and 60 Hz // depending on the monitor device refresh rate. // You can call another overload to set these explicitly wnd.Run(); } }
public ChildFormWindow(string name, string caption, int width, int height, SummerGUIWindow parent, bool modal = false, GameWindowFlags flags = GameWindowFlags.Default, WindowPositions position = WindowPositions.CenterParent) : base(caption, width, height, parent, flags) { if (String.IsNullOrEmpty(name)) { name = "ChildWindow"; } Name = name; IsModal = modal; if (!IsModal) { ShowInTaskBar = true; AllowMinimize = flags == GameWindowFlags.Default; AllowMaximize = flags == GameWindowFlags.Default; } else { // ToDo: FixMe: this.HideFromTaskbar(); } // ToDo: Set Window Modal State on Platform /** ToDo: * m_pDisplay->Create( NULL, //CWnd default * NULL, //has no name * WS_CHILD|WS_CLIPSIBLINGS|WS_CLIPCHILDREN|WS_VISIBLE, * rect, * this, //this is the parent * 0); //this should really be a different * // number... check resource.h * * return TRUE; // return TRUE unless you set * // the focus to a control **/ }
// ToDo: Let user specify the cursor size. // ToDo: scale to 32x32 rather than 24x24 // ToDo: how to scale cursors for HiRes? // ToDo: add more standard cursors to enum above (and to assets) public void LoadCursorFromFile(SummerGUIWindow wnd, string pngPath, string name) { try { if (String.IsNullOrEmpty(name)) { this.LogWarning("LoadCursorFromFile: invalid/empty name specified."); } if (DictCursors.ContainsKey(name)) { this.LogWarning("Cursor '{0}' was already loaded", name); return; } if (String.IsNullOrEmpty(pngPath)) { this.LogWarning("LoadCursorFromFile: empty path specified."); return; } pngPath = pngPath.FixedExpandedPath(); if (System.IO.File.Exists(pngPath)) { using (Bitmap bmp = new Bitmap(pngPath)) using (Bitmap bmpScaled = new Bitmap(bmp, new Size(24, 24))) { int w = bmpScaled.Width; int h = bmpScaled.Height; int len = w * h; //System.Drawing.Imaging.BitmapData data = bmp.LockBits(new Rectangle(0, 0, w, h), System.Drawing.Imaging.ImageLockMode.ReadOnly, System.Drawing.Imaging.PixelFormat.Format32bppArgb); byte[] bytes = new byte[len * 4]; int bp = 0; for (int k = 0; k < len; k++) { int x = k % w; int y = k / w; /** * Debug.Write(x, "X"); * Debug.Write(y, "\tY"); * Debug.WriteLine(k, "\tk"); **/ Color c = bmpScaled.GetPixel(x, y); bytes[bp++] = (byte)c.B; bytes[bp++] = (byte)c.G; bytes[bp++] = (byte)c.R; bytes[bp++] = (byte)c.A; } //bmp.UnlockBits(data); DictCursors.Add(name, new MouseCursor(w / 2, h / 2, w, h, bytes)); } } else { this.LogWarning("LoadCursorFromFile: path not found."); } } catch (Exception ex) { ex.LogError(); } }
public void LoadCursorFromFile(SummerGUIWindow wnd, string pngPath, Cursors cursor) { LoadCursorFromFile(wnd, pngPath, cursor.ToString()); }
public static DialogResults ShowContinueRepeat(string msg, SummerGUIWindow parent) { return(Show(msg, MessageBoxTypes.Question, MessageBoxButtons.ContinueRepeatCancel, parent)); }
public static DialogResults ShowQuestion(string msg, SummerGUIWindow parent) { return(Show(msg, MessageBoxTypes.Question, MessageBoxButtons.YesNoCancel, parent)); }
public static DialogResults ShowWarning(string msg, SummerGUIWindow parent) { return(Show(msg, MessageBoxTypes.Warning, MessageBoxButtons.OK, parent)); }
public static DialogResults Show(string message, MessageBoxTypes msgType = MessageBoxTypes.Info, MessageBoxButtons buttons = MessageBoxButtons.OkCancel, SummerGUIWindow parent = null) { // *** Icon FontAwesomeIcons icon = FontAwesomeIcons.fa_anchor; ColorContexts colorContext = ColorContexts.Default; // init icon switch (msgType) { case MessageBoxTypes.Info: icon = FontAwesomeIcons.fa_info_circle; colorContext = ColorContexts.Information; break; case MessageBoxTypes.Success: icon = FontAwesomeIcons.fa_exclamation_circle; colorContext = ColorContexts.Success; break; case MessageBoxTypes.Warning: icon = FontAwesomeIcons.fa_warning; colorContext = ColorContexts.Warning; break; case MessageBoxTypes.Error: icon = FontAwesomeIcons.fa_times_circle; colorContext = ColorContexts.Danger; break; case MessageBoxTypes.Question: icon = FontAwesomeIcons.fa_question_circle; colorContext = ColorContexts.Question; break; case MessageBoxTypes.Help: icon = FontAwesomeIcons.fa_life_ring; colorContext = ColorContexts.Success; break; } MessageBoxOverlay box = new MessageBoxOverlay(parent, colorContext); box.InitIconImage((char)icon, colorContext); // *** Buttons box.InitButtons(buttons, colorContext); box.InitText(message.TrimRightLinebreaks() + "\n", colorContext); if (msgType == MessageBoxTypes.Error) { //box.InitCopyButton (); } box.Style.BackColorBrush.Color = Color.FromArgb(30, Color.DarkSlateGray); /*** ***/ box.Show(parent); box.Focus(); return(DialogResults.OK); /*** * if (box != null) * box.Dispose (); * return box.Result; ***/ }
public static DialogResults Show(string caption, string message, MessageBoxTypes msgType = MessageBoxTypes.Info, MessageBoxButtons buttons = MessageBoxButtons.OkCancel, SummerGUIWindow parent = null) { float scaling = 1; if (parent != null) { scaling = parent.ScaleFactor; } MessageBoxWindow box = new MessageBoxWindow("MsgBox", caption, (DefaultWidth * scaling).Ceil(), (DefaultHeight * scaling).Ceil(), parent); // *** Icon FontAwesomeIcons icon = FontAwesomeIcons.fa_anchor; ColorContexts colorContext = ColorContexts.Default; // init icon switch (msgType) { case MessageBoxTypes.Info: icon = FontAwesomeIcons.fa_info_circle; colorContext = ColorContexts.Information; break; case MessageBoxTypes.Success: icon = FontAwesomeIcons.fa_exclamation_circle; colorContext = ColorContexts.Success; break; case MessageBoxTypes.Warning: icon = FontAwesomeIcons.fa_warning; colorContext = ColorContexts.Warning; break; case MessageBoxTypes.Error: icon = FontAwesomeIcons.fa_times_circle; colorContext = ColorContexts.Danger; break; case MessageBoxTypes.Question: icon = FontAwesomeIcons.fa_question_circle; colorContext = ColorContexts.Question; break; case MessageBoxTypes.Help: icon = FontAwesomeIcons.fa_life_ring; colorContext = ColorContexts.Success; break; } box.InitIconImage((char)icon, colorContext); // *** Buttons box.InitButtons(buttons); box.InitText(message); if (msgType == MessageBoxTypes.Error) { box.InitCopyButton(); } box.ShowInTaskBar = false; box.Show(parent); if (box != null) { box.Dispose(); } return(box.Result); }
protected virtual RectangleF GetSubMenuBounds(SubMenuOverlay sub) { SummerGUIWindow aw = ParentWindow; if (aw == null) { return(RectangleF.Empty); } RectangleF bounds = MarginBounds; try { bounds.Offset(itemStartPositions[Menu.IndexOf(ActiveItem)], 0); } catch (Exception ex) { ex.LogError(); } float spaceAbove = bounds.Top; float spaceBelow = aw.Height - bounds.Bottom; SizeF sz = sub.PreferredSize(aw); float desiredHeight = sz.Height; float desiredWidth = sz.Width; float itemHeight = sub.LineHeight; float maxspace = Math.Max(spaceAbove, spaceBelow); if (desiredHeight > maxspace) { desiredHeight = (int)(maxspace / itemHeight) * itemHeight; } RectangleF result = RectangleF.Empty; if (desiredHeight > 0 && desiredWidth > 0) { if (spaceBelow >= desiredHeight) { result = new RectangleF(bounds.Left, bounds.Bottom, desiredWidth, desiredHeight); } else if (spaceAbove >= desiredHeight) { result = new RectangleF(bounds.Left, bounds.Top - desiredHeight, desiredWidth, desiredHeight); } } if (!result.IsEmpty) { if (result.Left < 1) { result.Offset(Math.Abs(result.Left) + 3, -2); } else { result.Offset(-2, -2); } } return(result); }
protected MessageBoxWindow(string name, string caption, int width, int height, SummerGUIWindow parent) : base(name, caption, width, height, parent, true, GameWindowFlags.FixedWindow) { ButtonContainer = Controls.AddChild(new ButtonContainer("buttoncontainer")); }
public AboutScreen(string caption, SummerGUIWindow parent) : this("AboutScreen", caption, (520 * parent.ScaleFactor).Ceil(), (460 * parent.ScaleFactor).Ceil(), parent) { }
public AppointmentDialog(string name, SummerGUIWindow parent) : base(name, "Edit Appointment", 360, 480, parent, true) { Form = new AppointmentForm("apppointment"); this.AddChild(Form); }