private void UnwindGroupBoxes(GroupBox delete, ControlCollection controls) { List <Control> controls_ = new List <Control>(); controls_.AddRange(controls.OfType <Control>()); foreach (Control c in controls_) { if (delete != null) { //delete.Controls.Remove(c); Controls.Add(c); } if (typeof(GroupBox).IsAssignableFrom(c.GetType())) { UnwindGroupBoxes((GroupBox)c, c.Controls); } } if (delete != null) { delete.Controls.Clear(); Controls.Remove(delete); delete.Dispose(); } }
private void NewForm_MouseDoubleClick(object sender, MouseEventArgs e) { GroupBox temp = (GroupBox)sender; if (e.Button == MouseButtons.Left) { temp.Dispose(); } if (e.Button == MouseButtons.Right) { string nameControl = ""; for (int i = 0; i < Controls.Count; i++) { if (temp.Location.X + e.Location.X >= Controls[i].Location.X && temp.Location.Y + e.Location.Y >= Controls[i].Location.Y && temp.Location.X + e.Location.X <= Controls[i].Location.X + Controls[i].Size.Width && temp.Location.Y + e.Location.Y <= Controls[i].Location.Y + Controls[i].Size.Height) { if (Controls[i].Text.CompareTo(nameControl) > 0) { temp = (GroupBox)Controls[i]; } } } Text = "Площадь - " + (temp.Size.Height * temp.Size.Width) + " Координаты - " + temp.Location; } }
protected override void Dispose(bool disposing) { if (!_disposed) { try { _buttonAdd.Dispose(); _buttonEdit.Dispose(); _buttonDelete.Dispose(); _buttonOK.Dispose(); _buttonCancel.Dispose(); _labelComment.Dispose(); _textBoxComment.Dispose(); _labelTags.Dispose(); _listView.Dispose(); _groupMetaData.Dispose(); _buttonPanel.Dispose(); _radioButtonNone.Dispose(); _radioButtonMetadata.Dispose(); _buttonCancel.Click -= new EventHandler(DoButtonCancelClick); _buttonOK.Click -= new EventHandler(DoButtonOKClick); _buttonAdd.Click -= new EventHandler(DoButtonAddClick); _buttonEdit.Click -= new EventHandler(DoButtonEditClick); _buttonDelete.Click -= new EventHandler(DoButtonDeleteClick); _radioButtonMetadata.Click -= new EventHandler(DoRadioButtonMetadataClick); _radioButtonNone.Click -= new EventHandler(DoRadioButtonNoneClick); } finally { _disposed = true; } } }
private void ClearSubPanel() { GroupBox subGroupBox = ( GroupBox )this.SubPanel.Controls[0]; ControlInitializer.RemoveAllEvents(subGroupBox); subGroupBox.Parent = null; subGroupBox.Dispose(); }
private void InitializeMainPanel() { if (this.MainPanel.HasChildren) { GroupBox existGroupBox = ( GroupBox )this.MainPanel.Controls[0]; ControlInitializer.RemoveAllEvents(existGroupBox); existGroupBox.Parent = null; existGroupBox.Dispose(); } GroupBox mainGroupBox = new GroupBox(); mainGroupBox.Text = "GroupBox"; mainGroupBox.Dock = DockStyle.Fill; mainGroupBox.SizeChanged += (s, e) => { this.AppendMessage(s, $"GroupBox size changed."); }; this.MainPanel.Controls.Add(mainGroupBox); TabControl tabControl = new TabControl(); tabControl.Dock = DockStyle.Fill; tabControl.SelectedIndexChanged += (s, e) => { this.AppendMessage(s, "Selected tab page changed."); }; mainGroupBox.Controls.Add(tabControl); Button button = new Button(); button.Text = "Button"; button.Click += (s, e) => { this.AppendMessage(s, "Button clicked."); }; TextBox textBox = new TextBox(); textBox.TextChanged += (s, e) => { this.AppendMessage(s, "Text changed."); }; CheckBox checkBox = new CheckBox(); checkBox.Text = "CheckBox"; checkBox.CheckStateChanged += (s, e) => { this.AppendMessage(s, $"CheckBox state changed. Current : { ( ( CheckBox )s ).CheckState}"); }; RadioButton radioButton1 = new RadioButton(); radioButton1.Text = "RadioButton 1"; radioButton1.Checked = true; radioButton1.CheckedChanged += (s, e) => { this.AppendMessage(s, $"RadioButton 1 state changed. Current : { ( ( RadioButton )s ).Checked}"); }; RadioButton radioButton2 = new RadioButton(); radioButton2.Text = "RadioButton 2"; radioButton2.Checked = false; radioButton2.CheckedChanged += (s, e) => { this.AppendMessage(s, $"RadioButton 2 state changed. Current : {( ( RadioButton )s ).Checked}"); }; this.AddTabPage(tabControl, "Controls 1", button, textBox); this.AddTabPage(tabControl, "Controls 2", checkBox, radioButton1, radioButton2); }
private void rbNewProcess_CheckedChanged(object sender, EventArgs e) { if (groupBox != null) { groupBox.Dispose(); } if (rbNewProcess.Checked) { mode = ActionMode.NewProcess; groupBox = new GroupBox(); groupBox.Text = "Nowy proces"; groupBox.Location = new Point(this.groupBox1.Right + 3, this.groupBox1.Top); groupBox.Size = new Size(300, 300); groupBox.Parent = this; GenerateNewProcessControls(groupBox); } else if (rbNewError.Checked) { mode = ActionMode.NewError; groupBox = new GroupBox(); groupBox.Text = "Nowy błąd"; groupBox.Location = new Point(this.groupBox1.Right + 3, this.groupBox1.Top); groupBox.Size = new Size(300, 300); groupBox.Parent = this; GenerateNewErrorControls(groupBox); } else if (rbNewSolution.Checked) { mode = ActionMode.NewSolution; groupBox = new GroupBox(); groupBox.Text = "Nowe rozwiązanie"; groupBox.Location = new Point(this.groupBox1.Right + 3, this.groupBox1.Top); groupBox.Size = new Size(300, 300); groupBox.Parent = this; GenerateNewSolutionControls(groupBox); } else if (rbBounds.Checked) { mode = ActionMode.Bound; groupBox = new GroupBox(); groupBox.Text = "Powiązanie"; groupBox.Location = new Point(this.groupBox1.Right + 3, this.groupBox1.Top); groupBox.Size = new Size(300, 300); groupBox.Parent = this; GenerateBoundErrorControls(groupBox); } }
public void DrawField(ref GroupBox Field, Field field, int x, int y, int sideLength, Panel[][] panels) { if (Field != null) { Field.Dispose(); } Field = new GroupBox { Location = new Point(x, y), Size = new Size(field.width * sideLength, field.height * sideLength), BackColor = Color.LimeGreen }; Controls.Add(Field); AddPanelsToGroupBox(Field, panels, sideLength); }
public void BoxsClean(Form form) { player1.removeallcard(); player2.removeallcard(); for (int t = 0; t <= form.Controls.Count - 1; t++) { if (form.Controls[t].Name.Contains("gBox_Board")) { GroupBox boxlar = (GroupBox)form.Controls[t]; boxlar.Dispose(); continue; } if (form.Controls[t].Name.Contains("gBox_Yer")) { GroupBox boxlar = (GroupBox)form.Controls[t]; boxlar.Dispose(); continue; } if (form.Controls[t].Name.Contains("gBox_P1")) { GroupBox boxlar = (GroupBox)form.Controls[t]; boxlar.Dispose(); continue; } if (form.Controls[t].Name.Contains("gBox_P2")) { GroupBox boxlar = (GroupBox)form.Controls[t]; boxlar.Dispose(); continue; } if (form.Controls[t].Name.Contains("gBox_oynanan1")) { GroupBox boxoynanan = (GroupBox)form.Controls[t]; boxoynanan.Dispose(); continue; } if (form.Controls[t].Name.Contains("oynanan")) { GroupBox boxoynanan2 = (GroupBox)form.Controls[t]; boxoynanan2.Dispose(); continue; } } }
public void DeleteSlots() { if (gb != null) { var all = GetAll(gb, typeof(NoteButton)); foreach (NoteButton nb in all) { Console.WriteLine(nb.Name); nb.Dispose(); } all = GetAll(gb, typeof(Button)); foreach (Button nb in all) { Console.WriteLine(nb.Name); nb.Dispose(); } gb.Dispose(); } }
/// <summary> /// Cleans up either unmanaged resources or managed and unmanaged resources. /// </summary> /// <remarks> /// <para> /// If disposing equals true, the method has been called directly or indirectly by a user's /// code. Managed and unmanaged resources can be disposed. /// </para> /// <para> /// If disposing equals false, the method has been called by the runtime from inside the /// finalizer and you should not reference other objects. Only unmanaged resources can /// be disposed. /// </para> /// </remarks> /// <param name="disposing">Was Dispose called manually?</param> protected override void Dispose(bool disposing) { if (!isDisposed) // Check To See If Dispose Has Already Been Called { if (disposing) // If disposing Equals true, Dispose All Managed And Unmanaged Resources { pictureBox.Dispose(); rad640.Dispose(); rad800.Dispose(); rad1024.Dispose(); rad1600.Dispose(); rad16bpp.Dispose(); rad24bpp.Dispose(); rad32bpp.Dispose(); grpResolution.Dispose(); grpColorDepth.Dispose(); chkFullscreen.Dispose(); chkStatusBar.Dispose(); btnOk.Dispose(); GC.SuppressFinalize(this); // Suppress Finalization } // Release Any Unmanaged Resources Here, If disposing Was false, Only The Following Code Is Executed pictureBox = null; rad640 = null; rad800 = null; rad1024 = null; rad1600 = null; rad16bpp = null; rad24bpp = null; rad32bpp = null; grpResolution = null; grpColorDepth = null; chkFullscreen = null; chkStatusBar = null; btnOk = null; base.Dispose(disposing); } isDisposed = true; // Mark As disposed }
// 把userInfo映射成表以textBox的方式显示出来 private void GetTextBox(appleAcount user) { Task.Factory.StartNew(() => { #region Invoke //新建的工作线程是非创建Form窗体的窗口线程,所以不能直接调用窗口线程。 //开启一个一部委托捆绑要执行的方法。 this.Invoke(new Action(() => { gb.Dispose(); gb = new GroupBox(); int x = 40; int y = 80; gb.Width = 900; gb.Height = 800; this.Controls.Add(gb); for (int i = 0; i < propertyInfo.Length; i++) { TextBox tb = new TextBox(); tb.Tag = "name"; tb.Text = propertyInfo[i].Name; tb.Location = new Point(x, y); tb.Width = 130; tb.Height = 20; gb.Controls.Add(tb); TextBox tbValue = new TextBox(); tbValue.Tag = "value"; try { tbValue.Text = propertyInfo[i].GetValue(user).ToString(); } catch { } tbValue.Location = new Point(x + 130, y); tbValue.Width = 200; tbValue.Height = 20; gb.Controls.Add(tbValue); y += 20; } })); #endregion }); }
private void removeTimerButton_Click(object sender, EventArgs e) { Button removeButton = sender as Button; GroupBox grp = removeButton.Parent as GroupBox; int key = groupBoxDict.FirstOrDefault(x => x.Value.Equals(grp)).Key; // Abort thread of that timer //if (threadDict.ContainsKey(key)) //{ // threadDict[key].Abort(); //} // Remove groupBox & release memory grp.Parent.Controls.Remove(grp); grp.Dispose(); for (int i = key; i < groupBoxDict.Count; i++) { var item = groupBoxDict.ElementAt(i); var groupBox = item.Value; groupBox.Location = new Point(groupBox.Location.X, groupBox.Location.Y - 80); } yLocation -= 80; }
private void radTron_CheckedChanged(object sender, EventArgs e) { GroupBox grpTron = new GroupBox(); Label lblSoDoi = new Label(); NumericUpDown numSoDoi = new NumericUpDown(); Label lblSoThanhVien = new Label(); ComboBox cboSoThanhVien = new ComboBox(); Label lblThang = new Label(); TextBox txtThang = new TextBox(); Label lblHoa = new Label(); TextBox txtHoa = new TextBox(); Label lblThua = new Label(); TextBox txtThua = new TextBox(); Label lblSoLuot = new Label(); Button btn1 = new Button(); Button btn2 = new Button(); if (radTron.Checked == true) { //add more space this.Height += 184; panGiaiDau.Height += 184; btnCreate.Location = new Point(63, 329 + 184); btnExit.Location = new Point(162, 329 + 184); //add property //grpTron grpTron.Location = new Point(7, 315); grpTron.Name = "grpTron"; grpTron.Size = new Size(281, 183); grpTron.Text = "Đấu vòng tròn"; grpTron.ForeColor = Color.MidnightBlue; panGiaiDau.Controls.Add(grpTron); grpTron.Controls.Add(lblSoDoi); grpTron.Controls.Add(cboSoThanhVien); grpTron.Controls.Add(lblThang); grpTron.Controls.Add(btn2); grpTron.Controls.Add(lblSoLuot); grpTron.Controls.Add(btn1); grpTron.Controls.Add(lblSoThanhVien); grpTron.Controls.Add(numSoDoi); grpTron.Controls.Add(lblHoa); grpTron.Controls.Add(txtThua); grpTron.Controls.Add(lblThua); grpTron.Controls.Add(txtHoa); grpTron.Controls.Add(txtThang); //lblSodoi lblSoDoi.AutoSize = true; lblSoDoi.Location = new Point(3, 16); lblSoDoi.Name = "lblSoDoi"; lblSoDoi.Text = "Số đội tham gia [2-30]:"; lblSoDoi.ForeColor = Color.MidnightBlue; //numSodoi numSoDoi.Location = new Point(3, 32); numSoDoi.Name = "numSoDoi"; numSoDoi.Size = new Size(120, 20); numSoDoi.Value = new decimal(new int[] { 2, 0, 0, 0 }); numSoDoi.ForeColor = Color.MidnightBlue; //lblThang lblThang.AutoSize = true; lblThang.Location = new Point(3, 55); lblThang.Name = "lblThang"; lblThang.Text = "Điểm thắng:"; lblThang.ForeColor = Color.MidnightBlue; //lblHoa lblHoa.AutoSize = true; lblHoa.Location = new Point(117, 55); lblHoa.Name = "lblHoa"; lblHoa.Text = "Điểm hòa:"; lblHoa.ForeColor = Color.MidnightBlue; // lblThua lblThua.AutoSize = true; lblThua.Location = new Point(217, 55); lblThua.Name = "lblThua"; lblThua.Text = "Điểm thua:"; lblThua.ForeColor = Color.MidnightBlue; // txtThang txtThang.Location = new Point(6, 71); txtThang.Name = "txtThang"; txtThang.Size = new Size(57, 20); txtThang.ForeColor = Color.MidnightBlue; // txtHoa txtHoa.Location = new Point(120, 71); txtHoa.Name = "txtHoa"; txtHoa.Size = new Size(52, 20); txtHoa.ForeColor = Color.MidnightBlue; // txtThua txtThua.Location = new Point(220, 71); txtThua.Name = "txtThua"; txtThua.Size = new Size(55, 20); txtThua.ForeColor = Color.MidnightBlue; // lblSoLuot lblSoLuot.AutoSize = true; lblSoLuot.Location = new Point(3, 104); lblSoLuot.Name = "lblSoLuot"; lblSoLuot.Text = "Số lượt đá vòng tròn:"; lblSoLuot.ForeColor = Color.MidnightBlue; // btn1 btn1.Location = new Point(129, 97); btn1.Name = "btn1"; btn1.Size = new Size(52, 26); btn1.Text = "1"; btn1.UseVisualStyleBackColor = true; btn1.ForeColor = Color.MidnightBlue; btn1.Click += new System.EventHandler(this.btn1_Click); // btn2 btn2.Location = new Point(187, 97); btn2.Name = "btn2"; btn2.Size = new Size(52, 26); btn2.Text = "2"; btn2.UseVisualStyleBackColor = true; btn2.ForeColor = Color.MidnightBlue; btn2.Click += new System.EventHandler(this.btn2_Click); // lblSoThanhVien lblSoThanhVien.AutoSize = true; lblSoThanhVien.Location = new Point(3, 135); lblSoThanhVien.Name = "lblSoThanhVien"; lblSoThanhVien.Text = "Số người mỗi đội:"; lblSoThanhVien.ForeColor = Color.MidnightBlue; // cboSoThanhVien cboSoThanhVien.FormattingEnabled = true; cboSoThanhVien.Location = new Point(6, 151); cboSoThanhVien.Name = "cboSoThanhVien"; cboSoThanhVien.ForeColor = Color.MidnightBlue; cboSoThanhVien.DropDownStyle = ComboBoxStyle.DropDownList; cboSoThanhVien.Size = new Size(121, 21); //add element int[] stv = new int[4]; stv[0] = 5; stv[1] = 7; stv[2] = 9; stv[3] = 11; cboSoThanhVien.DataSource = stv; this.numSoDoi = numSoDoi; this.cboSoThanhVien = cboSoThanhVien; this.txtThang = txtThang; this.txtHoa = txtHoa; this.txtThua = txtThua; this.btn1 = btn1; this.btn2 = btn2; } else { this.Height -= 184; panGiaiDau.Height -= 184; btnCreate.Location = new Point(63, 329); btnExit.Location = new Point(162, 329); panGiaiDau.Controls.Remove(panGiaiDau.Controls.Find("grpTron", true)[0]); grpTron.Dispose(); } }
private void radLoai_CheckedChanged(object sender, EventArgs e) { //init controls GroupBox grpLoai = new GroupBox(); Label lblSoDoi = new Label(); NumericUpDown numSoDoi = new NumericUpDown(); Label lblSoThanhVien = new Label(); ComboBox cboSoThanhVien = new ComboBox(); if (radLoai.Checked == true) { //add more space this.Height += 98; panGiaiDau.Height += 98; btnCreate.Location = new Point(63, 329 + 98); btnExit.Location = new Point(162, 329 + 98); //add property //grpLoai grpLoai.Location = new Point(7, 315); grpLoai.Name = "grpLoai"; grpLoai.Size = new Size(281, 100); grpLoai.Text = "Loại trực tiếp"; grpLoai.ForeColor = Color.MidnightBlue; panGiaiDau.Controls.Add(grpLoai); grpLoai.Controls.Add(lblSoDoi); grpLoai.Controls.Add(numSoDoi); grpLoai.Controls.Add(lblSoThanhVien); grpLoai.Controls.Add(cboSoThanhVien); //lblSodoi lblSoDoi.Name = "lblSoDoi"; lblSoDoi.AutoSize = true; lblSoDoi.Text = "Số đội tham gia [2-64]:"; lblSoDoi.Location = new Point(3, 16); lblSoDoi.ForeColor = Color.MidnightBlue; //numSodoi numSoDoi.Name = "numSoDoi"; numSoDoi.Location = new Point(3, 32); numSoDoi.Size = new Size(120, 20); numSoDoi.TabIndex = 10; numSoDoi.Value = new decimal(new int[] { 2, 0, 0, 0 }); numSoDoi.ForeColor = Color.MidnightBlue; //lblSothanhvien lblSoThanhVien.Name = "lblSoThanhVien"; lblSoThanhVien.AutoSize = true; lblSoThanhVien.Text = "Số người mỗi đội:"; lblSoThanhVien.Location = new Point(3, 55); lblSoThanhVien.ForeColor = Color.MidnightBlue; //cboSothanhvien cboSoThanhVien.Name = "cboSoThanhVien"; cboSoThanhVien.FormattingEnabled = true; cboSoThanhVien.Location = new Point(3, 71); cboSoThanhVien.Size = new Size(121, 21); cboSoThanhVien.TabIndex = 11; cboSoThanhVien.ForeColor = Color.MidnightBlue; cboSoThanhVien.DropDownStyle = ComboBoxStyle.DropDownList; //add element int[] stv = new int[4]; stv[0] = 5; stv[1] = 7; stv[2] = 9; stv[3] = 11; cboSoThanhVien.DataSource = stv; this.cboSoThanhVien = cboSoThanhVien; this.numSoDoi = numSoDoi; } else { //less space this.Height -= 98; panGiaiDau.Height -= 98; btnCreate.Location = new Point(63, 329); btnExit.Location = new Point(162, 329); panGiaiDau.Controls.Remove(panGiaiDau.Controls.Find("grpLoai", true)[0]); grpLoai.Dispose(); } }
private void settingsToolStripMenuItem_Click(object sender, EventArgs e) { ////remove controls int x = 0; try { foreach (Label control in CurrentConfig.Controls) { CurrentConfig.Controls.Remove(control); control.Dispose(); x++; } CurrentConfig.Dispose(); } catch { ///first run, ignore } ////show current configuration CurrentConfig = new GroupBox(); CurrentConfig.Text = "Current Configuration"; CurrentConfig.Location = new System.Drawing.Point(31, 27); CurrentConfig.Size = new System.Drawing.Size(452, 114); CurrentConfig.Name = "CurrentConfig"; settings.Controls.Add(CurrentConfig); Label[] currentconfig = null; ContextMenu[] ConfigMenu = null; Array.Resize(ref ConfigMenu, Configuration.Length); Array.Resize(ref currentconfig, Configuration.Length); MenuItem Edit = new MenuItem(); MenuItem Remove = new MenuItem(); MenuItem Current = new MenuItem(); Edit.Text = "Edit Item"; Edit.Click += new EventHandler(Edit_Click); Remove.Text = "Remove"; Remove.Click += new EventHandler(Remove_Click); x = 0; int ylocation = 0; try { foreach (Button config in Menu) { ///// create grid /// currentconfig[x] = new Label(); if (ylocation < CurrentConfig.Size.Height) { if (x > 0) { currentconfig[x].Location = new System.Drawing.Point(currentconfig[x - 1].Location.X, currentconfig[x - 1].Location.Y + 33); ylocation = currentconfig[x].Location.Y + 30 + currentconfig[x].Size.Height; } else { currentconfig[x].Location = new System.Drawing.Point(15, 15); } } else { currentconfig[x].Location = new System.Drawing.Point(currentconfig[x - 1].Location.X + 50, 15); ylocation = currentconfig[x].Location.Y + 30; } ///// make new menu for each config ConfigMenu[x] = new ContextMenu(); Current.Text = Menu[x].Name; ConfigMenu[x].MenuItems.Add(0, Current.CloneMenu()); ConfigMenu[x].MenuItems.Add("-"); ConfigMenu[x].MenuItems.Add(2, Edit.CloneMenu()); ConfigMenu[x].MenuItems.Add(3, Remove.CloneMenu()); ConfigMenu[x].MenuItems[2].Name = "Edit" + x; ConfigMenu[x].MenuItems[3].Name = "Remove" + x; ///add images to menus AddImageToMenuItem(ConfigMenu[x].MenuItems[3], SystemIcons.Error.Handle, true); AddImageToMenuItem(ConfigMenu[x].MenuItems[2], SystemIcons.Asterisk.Handle, true); AddImageToMenuItem(ConfigMenu[x].MenuItems[0], Icon.ExtractAssociatedIcon(Configuration[x]).Handle, false); //// add images to configs currentconfig[x].Image = new Bitmap(Icon.ExtractAssociatedIcon(Configuration[x]).ToBitmap()); currentconfig[x].BorderStyle = BorderStyle.Fixed3D; currentconfig[x].Size = currentconfig[x].Image.Size; currentconfig[x].Name = x.ToString(); currentconfig[x].ContextMenu = ConfigMenu[x]; currentconfig[x].MouseHover += new EventHandler(currentconfig_MouseHover); CurrentConfig.Controls.Add(currentconfig[x]); x = x + 1; } settings.Visible = true; settings.BringToFront(); } catch { } //// reload configuration _main.Visible = false; }
private void CreateMain() { int x = 0; ////remove controls try { foreach (Button control in Configured.Controls) { Configured.Controls.Remove(control); control.Dispose(); } _main.Controls.Remove(Configured); Configured.Dispose(); Array.Clear(Menu, 0, Menu.Length); } catch { ///first run, ignore } Configured = new GroupBox(); Configured.Name = "Configured"; Configured.Location = new System.Drawing.Point(12, 27); Configured.Size = new System.Drawing.Size(483, 194); Configured.Text = "Found " + Configuration.Length + " Configurations"; _main.Controls.Add(Configured); Array.Resize(ref Menu, Configuration.Length); x = 0; int ylocation = 0; foreach (string mnu in Configuration) { try { string[] temp = mnu.Split(new char[] { '\\' }); string[] tmp = temp[temp.Length - 1].Split(new char[] { '.' }); string id = tmp[tmp.Length - 2]; Menu[x] = new Button(); Menu[x].Name = id; Menu[x].Size = new System.Drawing.Size(50, 50); Menu[x].BackgroundImageLayout = ImageLayout.Stretch; Menu[x].BackgroundImage = new Bitmap(Icon.ExtractAssociatedIcon(Configuration[x]).ToBitmap()); Menu[x].Click += new EventHandler(Menu_Click); Menu[x].MouseHover += new EventHandler(Menu_MouseHover); Menu[x].MouseEnter += new EventHandler(Menu_MouseEnter); Menu[x].MouseLeave += new EventHandler(Menu_MouseLeave); if (ylocation < Configured.Size.Height) { if (x > 0) { Menu[x].Location = new System.Drawing.Point(Menu[x - 1].Location.X, Menu[x - 1].Location.Y + 50); ylocation = Menu[x].Location.Y + 50 + Menu[x].Size.Height; } else { Menu[x].Location = new System.Drawing.Point(25, 25); } } else { Menu[x].Location = new System.Drawing.Point(Menu[x - 1].Location.X + 50, 25); ylocation = Menu[x].Location.Y + 50 + Menu[x].Size.Height; } Configured.Controls.Add(Menu[x]); } catch { } x = x + 1; } this.Update(); _main.Visible = true; _main.BringToFront(); }
private void CheckUpdate() { GroupBox groupBoxupdate = new GroupBox { Location = new Point(12, button10.Location.Y + 35), Size = new Size(Size.Width - 30, 90), BackColor = Color.Aqua }; Label versionLabel = new Label { AutoSize = false, TextAlign = ContentAlignment.BottomCenter, Dock = DockStyle.None, Location = new Point(2, 30), Size = new Size(groupBoxupdate.Size.Width - 10, 25), }; versionLabel.Font = new Font(versionLabel.Font.Name, 10F, FontStyle.Bold); Label infoLabel = new Label { AutoSize = false, TextAlign = ContentAlignment.BottomCenter, Dock = DockStyle.None, Location = new Point(2, 10), Size = new Size(groupBoxupdate.Size.Width - 10, 20), Text = "Eine neue Version ist verfügbar" }; infoLabel.Font = new Font(infoLabel.Font.Name, 8.75F); Label downLabel = new Label { Location = new Point(groupBoxupdate.Size.Width - 245, 60), TextAlign = ContentAlignment.MiddleRight, AutoSize = false, Size = new Size(100, 23), Text = "Jetzt Updaten" }; Button laterButton = new Button { Location = new Point(groupBoxupdate.Size.Width - 125, 60), Text = "Nein", Size = new Size(50, 23), BackColor = Color.FromArgb(224, 224, 224) }; Button updateButton = new Button { Location = new Point(groupBoxupdate.Size.Width - 70, 60), Text = "Ja", Size = new Size(50, 23), BackColor = Color.FromArgb(224, 224, 224) }; groupBoxupdate.Controls.Add(updateButton); groupBoxupdate.Controls.Add(laterButton); groupBoxupdate.Controls.Add(downLabel); groupBoxupdate.Controls.Add(infoLabel); groupBoxupdate.Controls.Add(versionLabel); updateButton.Click += new EventHandler(UpdateButton_Click); laterButton.Click += new EventHandler(LaterButton_Click); if (culture1.Name != "de-DE") { infoLabel.Text = "A new version is available"; laterButton.Text = "No"; updateButton.Text = "Yes"; downLabel.Text = "Update now"; } void LaterButton_Click(object sender, EventArgs e) { groupBoxupdate.Dispose(); Controls.Remove(groupBoxupdate); groupBox3.Enabled = true; } ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls12; try { var request = (WebRequest)HttpWebRequest.Create("https://github.com/UndertakerBen/PorEdgeUpd/raw/master/Version.txt"); var response = request.GetResponse(); using (StreamReader reader = new StreamReader(response.GetResponseStream())) { var version = reader.ReadToEnd(); versionLabel.Text = version; FileVersionInfo testm = FileVersionInfo.GetVersionInfo(applicationPath + "\\Portable Edge (Chromium) Updater.exe"); if (Convert.ToDecimal(version) > Convert.ToDecimal(testm.FileVersion)) { Controls.Add(groupBoxupdate); groupBox3.Enabled = false; } reader.Close(); } } catch (Exception) { } void UpdateButton_Click(object sender, EventArgs e) { ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls12; var request2 = (WebRequest)HttpWebRequest.Create("https://github.com/UndertakerBen/PorEdgeUpd/raw/master/Version.txt"); var response2 = request2.GetResponse(); using (StreamReader reader = new StreamReader(response2.GetResponseStream())) { var version = reader.ReadToEnd(); reader.Close(); ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls12; using (WebClient myWebClient2 = new WebClient()) { myWebClient2.DownloadFile($"https://github.com/UndertakerBen/PorEdgeUpd/releases/download/v{version}/Portable.Edge.Chromium.Updater.v{version}.7z", @"Portable.Edge.Chromium.Updater.v" + version + ".7z"); } File.AppendAllText(@"Update.cmd", "@echo off" + "\n" + "timeout /t 2 /nobreak" + "\n" + "\"" + applicationPath + "\\Bin\\7zr.exe\" e \"" + applicationPath + "\\Portable.Edge.Chromium.Updater.v" + version + ".7z\" -o\"" + applicationPath + "\" \"Portable Edge (Chromium) Updater.exe\"" + " -y\n" + "call cmd /c Start /b \"\" " + "\"" + applicationPath + "\\Portable Edge (Chromium) Updater.exe\"\n" + "del /f /q \"" + applicationPath + "\\Portable.Edge.Chromium.Updater.v" + version + ".7z\"\n" + "del /f /q \"" + applicationPath + "\\Update.cmd\" && exit\n" + "exit\n"); string arguments = " /c call Update.cmd"; Process process = new Process(); process.StartInfo.FileName = "cmd.exe"; process.StartInfo.Arguments = arguments; process.Start(); Close(); } } }
private void CheckUpdate() { GroupBox groupBoxupdate = new GroupBox { Location = new Point(groupBox1.Location.X, button10.Location.Y + button10.Size.Height + 5), Size = new Size(groupBox1.Width, 90), BackColor = Color.Aqua }; Label versionLabel = new Label { AutoSize = false, TextAlign = ContentAlignment.BottomCenter, Dock = DockStyle.None, Location = new Point(2, 30), Size = new Size(groupBoxupdate.Width - 4, 25), }; versionLabel.Font = new Font(versionLabel.Font.Name, 10F, FontStyle.Bold); Label infoLabel = new Label { AutoSize = false, TextAlign = ContentAlignment.BottomCenter, Dock = DockStyle.None, Location = new Point(2, 10), Size = new Size(groupBoxupdate.Width - 4, 20), }; infoLabel.Font = new Font(infoLabel.Font.Name, 8.75F); Label downLabel = new Label { TextAlign = ContentAlignment.MiddleRight, AutoSize = false, Size = new Size(100, 23), }; Button laterButton = new Button { Size = new Size(40, 23), BackColor = Color.FromArgb(224, 224, 224) }; Button updateButton = new Button { Location = new Point(groupBoxupdate.Width - Width - 10, 60), Size = new Size(40, 23), BackColor = Color.FromArgb(224, 224, 224) }; updateButton.Location = new Point(groupBoxupdate.Width - updateButton.Width - 10, 60); laterButton.Location = new Point(updateButton.Location.X - laterButton.Width - 5, 60); downLabel.Location = new Point(laterButton.Location.X - downLabel.Width - 20, 60); groupBoxupdate.Controls.Add(updateButton); groupBoxupdate.Controls.Add(laterButton); groupBoxupdate.Controls.Add(downLabel); groupBoxupdate.Controls.Add(infoLabel); groupBoxupdate.Controls.Add(versionLabel); updateButton.Click += new EventHandler(UpdateButton_Click); laterButton.Click += new EventHandler(LaterButton_Click); switch (culture1.TwoLetterISOLanguageName) { case "ru": infoLabel.Text = "Доступна новая версия"; laterButton.Text = "нет"; updateButton.Text = "Да"; downLabel.Text = "ОБНОВИТЬ"; break; case "de": infoLabel.Text = "Eine neue Version ist verfügbar"; laterButton.Text = "Nein"; updateButton.Text = "Ja"; downLabel.Text = "Jetzt Updaten"; break; default: infoLabel.Text = "A new version is available"; laterButton.Text = "No"; updateButton.Text = "Yes"; downLabel.Text = "Update now"; break; } void LaterButton_Click(object sender, EventArgs e) { groupBoxupdate.Dispose(); Controls.Remove(groupBoxupdate); groupBox1.Enabled = true; } ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls12; try { var request = (WebRequest)HttpWebRequest.Create("https://github.com/UndertakerBen/PorBraveUpd/raw/master/Version.txt"); var response = request.GetResponse(); using (StreamReader reader = new StreamReader(response.GetResponseStream())) { var version = reader.ReadToEnd(); FileVersionInfo testm = FileVersionInfo.GetVersionInfo(applicationPath + "\\Portable Brave Updater.exe"); versionLabel.Text = testm.FileVersion + " >>> " + version; if (Convert.ToInt32(version.Replace(".", "")) > Convert.ToInt32(testm.FileVersion.Replace(".", ""))) { Controls.Add(groupBoxupdate); groupBox1.Enabled = false; } reader.Close(); } } catch (Exception) { } void UpdateButton_Click(object sender, EventArgs e) { ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls12; var request2 = (WebRequest)HttpWebRequest.Create("https://github.com/UndertakerBen/PorBraveUpd/raw/master/Version.txt"); var response2 = request2.GetResponse(); using (StreamReader reader = new StreamReader(response2.GetResponseStream())) { var version = reader.ReadToEnd(); reader.Close(); ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls12; using (WebClient myWebClient2 = new WebClient()) { myWebClient2.DownloadFile($"https://github.com/UndertakerBen/PorBraveUpd/releases/download/v{version}/Portable.Brave.Updater.v{version}.7z", @"Portable.Brave.Updater.v" + version + ".7z"); } File.AppendAllText(@"Update.cmd", "@echo off" + "\n" + "timeout /t 1 /nobreak" + "\n" + "\"" + applicationPath + "\\Bin\\7zr.exe\" e \"" + applicationPath + "\\Portable.Brave.Updater.v" + version + ".7z\" -o\"" + applicationPath + "\" \"Portable Brave Updater.exe\"" + " -y\n" + "call cmd /c Start /b \"\" " + "\"" + applicationPath + "\\Portable Brave Updater.exe\"\n" + "del /f /q \"" + applicationPath + "\\Portable.Brave.Updater.v" + version + ".7z\"\n" + "del /f /q \"" + applicationPath + "\\Update.cmd\" && exit\n" + "exit\n"); string arguments = " /c call Update.cmd"; Process process = new Process(); process.StartInfo.FileName = "cmd.exe"; process.StartInfo.Arguments = arguments; process.Start(); Close(); } } }
private void radioButtons_CheckedChanged(object sender, EventArgs e) { var human = new Human(); var construct = new Construct(); var p = new BackgroundPanels(); RadioButton radioButton = sender as RadioButton; if (Details.buttonGroups.Count != 0 && radioButton.Checked == true) { var C1 = Details.CharacterList[0]; C1.STR = 1; C1.DEX = 1; C1.WILL = 1; C1.RES = 1; C1.INT = 1; C1.PER = 1; C1.Skills.Clear(); if (radioButton.Parent.Text.ToString() == "Nation") { GroupBox rb = Details.buttonGroups[0]; rb.Dispose(); Details.buttonGroups[0] = null; } else if (radioButton.Parent.Text.ToString() == "Planet") { GroupBox rb1 = Details.buttonGroups[1]; rb1.Dispose(); Details.buttonGroups[1] = null; } } if (radioButton.Parent.Text.ToString() == "Nation" && radioButton.Checked == true) { if (radioButton.TabIndex == 0) { p.planetsPanel(Details.panel); foreach (Control ctl in Details.characterPanel.Controls) { if (ctl.Name == "nation") { Details.planet = Human.freeColonies; Details.CharacterList[0].Nationality = radioButton.Text; ctl.Text = "Nationality: " + Details.CharacterList[0].Nationality; } } } if (radioButton.TabIndex == 1) { p.planetsPanel(Details.panel); foreach (Control ctl in Details.characterPanel.Controls) { if (ctl.Name == "nation") { Details.planet = Human.secondColonies; Details.CharacterList[0].Nationality = radioButton.Text; ctl.Text = "Nationality: " + Details.CharacterList[0].Nationality; } } } } else if (radioButton.Parent.Text.ToString() == "Planet" && radioButton.Checked == true) { Details.CharacterList[0].Planet = radioButton.Text; if (Details.CharacterList[0].Nationality == "Democratic Alliance of Free Colonies") { switch (radioButton.TabIndex) { case 0: Details.life = Human.Earthborn; break; case 1: Details.life = Human.FirstExpansion; break; case 2: Details.life = Human.FrontierWorld; break; case 3: Details.life = Human.OrbitalString; break; } } if (Details.CharacterList[0].Nationality == "Second Wave Colonies") { switch (radioButton.TabIndex) { case 0: Details.life = Human.JungleWorld; break; case 1: Details.life = Human.IceWorld; break; case 2: Details.life = Human.DesertWorld; break; case 3: Details.life = Human.MegaCity; break; } } p.LifePanel(Details.panel); } else if (radioButton.Parent.Name.ToString() == "Life" && radioButton.Checked == true) { Details.CharacterList[0].Life = radioButton.Text; } if (Details.CharacterList[0].Race == "Human") { human.Update("update", Details.panel); } else if (Details.CharacterList[0].Race == "Construct") { construct.Update("update", Details.panel); } foreach (Control ctl in Details.characterPanel.Controls) { switch (ctl.Name) { case "Planet": ctl.Text = "Planet: " + Details.CharacterList[0].Planet; break; case "Willpower": ctl.Text = "Willpower: " + Details.CharacterList[0].WILL; break; case "Strength": ctl.Text = "Strength: " + Details.CharacterList[0].STR; break; case "Resiliance": ctl.Text = "Resiliance: " + Details.CharacterList[0].RES; break; case "Dexterity": ctl.Text = "Dexterity: " + Details.CharacterList[0].DEX; break; case "Intelligence": ctl.Text = "Intelligence: " + Details.CharacterList[0].INT; break; case "Perception": ctl.Text = "Perception: " + Details.CharacterList[0].PER; break; case "Abilities": ctl.Text = "Abilities: "; foreach (string x in Details.CharacterList[0].Skills) { ctl.Text += x + "\n"; } break; } } }