public void CloseForm() { //if (MessageBox.Show("Voulez vous quittez ?","confirmation",MessageBoxButtons.YesNo) == DialogResult.Yes) //{ // Environment.Exit(0); //} string[] _ = _Configs.GetJsonValueByKey("exit_confirmation").Split('|'); int ch = SAAD_NATIVE.MessageBox(main_form.Handle, _[0], _[1], 4); // 6 == yes // 7 == no if (ch == 6) { Environment.Exit(1); } }
public void builder() { if (main_form != null && !main_form.IsDisposed) { // tracking stacked controls fel main form : Vector2 _Tracking = new Vector2(); _Tracking.x = 0; _Tracking.y = 0; //// Form main_form.Name = FormName; main_form.Text = FormTitle; main_form.Location = new Point(0, 0); main_form.FormBorderStyle = FormBorderStyle.None; //// Top_TitleBAR TitlePanel = new Panel() { Bounds = new Rectangle(_Tracking.x, _Tracking.y, screen.w, 70), BackColor = settings.TitleBarColor, Parent = main_form, }; TitlePanel.MouseDown += md; TitlePanel.MouseUp += mu; TitlePanel.MouseMove += mm; TitlePanel.DoubleClick += (o, a) => main_form.Location = new Point(0, 0); //TitlePanel.MouseDoubleClick += (o, a) => main_form.Location = new Point(0, 0); _Tracking.y += 70; // Title bar sub COntrols region #region Controls_TitlePanel MenuIcon = new PictureBox { Parent = TitlePanel, Width = 20, Height = 20, Location = new Point(leftPanelMiniWidth / 2 - 10, TitlePanel.Height / 2 - (25 / 2)), Image = Properties.Resources.Menu2, SizeMode = PictureBoxSizeMode.StretchImage, Cursor = Cursors.Hand, }; // _working // MenuIcon Click Event __x MenuIcon.Click += (o, a) => { try { if (!settings.PinnedTop && !settings.isStretched) { LeftSidePanel.Width = leftPanelFullWidth; settings.isStretched = true; foreach (Control ctrl in LeftSidePanel.Controls) { if (ctrl is _MenuItem) { _MenuItem menu = ctrl as _MenuItem; menu.Height = 50; menu.icon.Bounds = new Rectangle(new Point(10, 50 / 2 - 10), new Size(20, 20)); menu.menuItem_title.Bounds = new Rectangle(new Point(15, 50 / 2 - 12 / 2), new Size(menu.Width, 12)); } } } else if (settings.isStretched) { LeftSidePanel.Width = leftPanelMiniWidth; settings.isStretched = false; foreach (Control ctrl in LeftSidePanel.Controls) { if (ctrl is _MenuItem) { _MenuItem menu = ctrl as _MenuItem; menu.Height = 100; menu.icon.Bounds = new Rectangle(new Point(menu.Width / 2 - 13, menu.Height / 2 - 26), new Size(26, 26)); menu.menuItem_title.Bounds = new Rectangle(new Point(0, menu.Height / 2 + 5), new Size(menu.Width, 12)); } } } } catch (Exception) { } }; icon = new PictureBox() { Image = Properties.Resources.icon, SizeMode = PictureBoxSizeMode.StretchImage, Width = 25, Height = 25, Parent = TitlePanel, Location = new Point(100 + MenuIcon.Width, TitlePanel.Height / 2 - (25 / 2)) }; title = new Label() { Width = 200, Text = settings.app_title, ForeColor = Color.FromArgb(255, 157, 157, 157), BackColor = settings.TitleBarColor, Location = new Point(110 + MenuIcon.Width + icon.Width, TitlePanel.Height / 2 - (12 / 2)), Parent = TitlePanel }; closeBtn = new PictureBox() { Cursor = Cursors.Hand, BackColor = Color.Red, Width = 20, Height = 20, Parent = TitlePanel, Location = new Point(main_form.Width - 50, TitlePanel.Height / 2 - 10), }; closeBtn.Click += (o, ev) => CloseForm(); pinTopBtn = new PictureBox() { Cursor = Cursors.Hand, BackColor = Color.YellowGreen, Width = 20, Height = 20, Parent = TitlePanel, Location = new Point(main_form.Width - 80, TitlePanel.Height / 2 - 10), }; pinTopBtn.Click += (e, o) => PinToTop(); minBtn = new PictureBox() { Cursor = Cursors.Hand, BackColor = Color.Green, Width = 20, Height = 20, Parent = TitlePanel, Location = new Point(main_form.Width - 110, TitlePanel.Height / 2 - 10), }; minBtn.Click += (e, o) => main_form.WindowState = FormWindowState.Minimized; #endregion // Search TextBox SearchInputContainer = new Panel { Parent = TitlePanel, Bounds = new Rectangle(new Point(400, TitlePanel.Height / 2 - 15), new Size(500, 30)), BackColor = settings.ContainerBgColor, }; SearchInput = new TextBox { Parent = SearchInputContainer, BorderStyle = BorderStyle.None, Font = new Font("tahoma", 25f, FontStyle.Regular, GraphicsUnit.Pixel), BackColor = settings.ContainerBgColor, ForeColor = Color.FromArgb(255, 80, 80, 80), Dock = DockStyle.Fill }; //// LEFT PANEL ! LeftSidePanel = new Panel() { Bounds = new Rectangle(_Tracking.x, _Tracking.y, leftPanelMiniWidth, screen.h), BackColor = settings.TitleBarColor, Parent = main_form, Name = "LeftPanel" }; _Tracking.x += 200; _Tracking.y += 0; // adding LEFT panel sub controls : #region LeftPanel_menuItems TestItem = new _MenuItem(100, leftPanelMiniWidth, /* Color.FromArgb(255, 60, 60, 60)*/ Color.Transparent, _Configs.GetJsonValueByKey("menu4").ToString(), Properties.Resources.settings) { Parent = LeftSidePanel, Dock = DockStyle.Top, }; TestItem2 = new _MenuItem(100, leftPanelMiniWidth, /* Color.FromArgb(255, 60, 60, 60)*/ Color.Transparent, _Configs.GetJsonValueByKey("menu3").ToString(), Properties.Resources.cameras) { Parent = LeftSidePanel, Dock = DockStyle.Top, }; TestItem3 = new _MenuItem(100, leftPanelMiniWidth, /* Color.FromArgb(255, 60, 60, 60)*/ Color.Transparent, _Configs.GetJsonValueByKey("menu2").ToString(), Properties.Resources.users) { Parent = LeftSidePanel, Dock = DockStyle.Top, }; TestItem4 = new _MenuItem(100, leftPanelMiniWidth, /* Color.FromArgb(255, 60, 60, 60)*/ Color.Transparent, _Configs.GetJsonValueByKey("menu1").ToString(), Properties.Resources.comps) { Parent = LeftSidePanel, Dock = DockStyle.Top, }; //MenuIconPanel = new Panel //{ // Parent = TitlePanel, // Dock = DockStyle.Left, // Height = 30, // BackColor = Color.Red, //}; #endregion //// Container_panel ContainerPanel = new Panel() { Bounds = new Rectangle(_Tracking.x, _Tracking.y, screen.w - _Tracking.y, screen.h), BackColor = settings.ContainerBgColor, Parent = main_form, }; _Tracking.x += screen.w - _Tracking.y; _Tracking.y += 0; } else { string[] _ = _Configs.GetJsonValueByKey("unknown_err1").Split('|'); SAAD_NATIVE.MessageBox(main_form.Handle, _[0], _[1], 0); Environment.Exit(-1); } }