// COPYRIGHT (C) Tom. ALL RIGHTS RESERVED. // THE AntdUI PROJECT IS AN WINFORM LIBRARY LICENSED UNDER THE Apache-2.0 License. // LICENSED UNDER THE Apache License, VERSION 2.0 (THE "License") // YOU MAY NOT USE THIS FILE EXCEPT IN COMPLIANCE WITH THE License. // YOU MAY OBTAIN A COPY OF THE LICENSE AT // // http://www.apache.org/licenses/LICENSE-2.0 // // UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING, SOFTWARE // DISTRIBUTED UNDER THE LICENSE IS DISTRIBUTED ON AN "AS IS" BASIS, // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. // SEE THE LICENSE FOR THE SPECIFIC LANGUAGE GOVERNING PERMISSIONS AND // LIMITATIONS UNDER THE License. // GITEE: https://gitee.com/antdui/AntdUI // GITHUB: https://github.com/AntdUI/AntdUI // CSDN: https://blog.csdn.net/v_132 // QQ: 17379620 using System; using System.Collections.Generic; using System.Drawing; using System.Windows.Forms; namespace AntdUI { internal class LayeredFormModal : Window, IEventListener { Modal.Config config; Panel? panel_main; public LayeredFormModal(Modal.Config _config) { SetStyle( ControlStyles.UserPaint | ControlStyles.AllPaintingInWmPaint | ControlStyles.OptimizedDoubleBuffer | ControlStyles.ResizeRedraw | ControlStyles.DoubleBuffer, true); UpdateStyles(); Resizable = false; FormBorderStyle = FormBorderStyle.FixedSingle; config = _config; if (config.Form != null) TopMost = config.Form.TopMost; close_button = new ITaskOpacity(this); #region InitializeComponent SuspendLayout(); int butt_h = (int)Math.Round(config.BtnHeight * Config.Dpi); BackColor = Style.Db.BgElevated; Size = new Size(416, 122 + butt_h); if (config.Form == null) { if (config.Font != null) Font = config.Font; } else Font = config.Font ?? config.Form.Font; ForeColor = Style.Db.TextBase; ShowInTaskbar = false; if (config.Form == null) StartPosition = FormStartPosition.CenterScreen; else StartPosition = FormStartPosition.CenterParent; if (butt_h > 0) { btn_ok = new Button { AutoSizeMode = TAutoSize.Width, Dock = DockStyle.Right, Location = new Point(304, 0), Name = "btn_ok", Size = new Size(64, butt_h), TabIndex = 0, Type = config.OkType, Text = config.OkText }; config.OnButtonStyle?.Invoke("OK", btn_ok); btn_ok.Click += btn_ok_Click; if (config.OkFont != null) btn_ok.Font = config.OkFont; if (config.CancelText != null) { btn_no = new Button { AutoSizeMode = TAutoSize.Width, BorderWidth = 1F, Dock = DockStyle.Right, Location = new Point(240, 0), Name = "btn_no", Size = new Size(64, butt_h), TabIndex = 1, Text = config.CancelText }; config.OnButtonStyle?.Invoke("Cancel", btn_no); btn_no.Click += btn_no_Click; if (config.CancelFont != null) btn_no.Font = config.CancelFont; } panel_main = new Panel { Dock = DockStyle.Bottom, Back = Style.Db.BgElevated, Size = new Size(368, butt_h) }; if (btn_no != null) panel_main.Controls.Add(btn_no); panel_main.Controls.Add(btn_ok); if (config.Btns != null) { var btns = new List