private void genWord_Click(object sender, EventArgs e) { if (tableLayoutPanel != null) { tableLayoutPanel.Dispose(); } CreateTableLayoutPanel(gameWordsLogic.DoMixedWord()); TrueAndFalse.Text = ""; }
// Реакция на изменение состояния модели при выборе какой-либо карточки(карточка открывается и затем либо переварачивается либо исчезает) private void stateModelChanged(GameModel.EnumState State) { ScoreRefresh(); if (State == GameModel.EnumState.Start) { CreateTableForCards(Controller.Model.CurrentMatrixSize); //Рисуем сетку с кнопками(карточки) } else { TableLayoutPanel tableForCards = getCurentTableForCards(); Button clickButton = (Button)tableForCards.GetControlFromPosition(Controller.Model.CurrentPosition.Y, Controller.Model.CurrentPosition.X); clickButton.BackgroundImage = new Bitmap(new Bitmap(Controller.Model.ImageAdressMatrix[Controller.Model.CurrentPosition.X, Controller.Model.CurrentPosition.Y]), clickButton.Width, clickButton.Height); clickButton.Refresh(); switch (State) { case GameModel.EnumState.SecondClickGood: { Thread.Sleep(300); Button prevClickButton = (Button)tableForCards.GetControlFromPosition(Controller.Model.PreviousPosition.Y, Controller.Model.PreviousPosition.X); prevClickButton.Visible = false; clickButton.Visible = false; break; } case GameModel.EnumState.SecondClickBad: { Thread.Sleep(500); Button prevClickButton = (Button)tableForCards.GetControlFromPosition(Controller.Model.PreviousPosition.Y, Controller.Model.PreviousPosition.X); prevClickButton.BackgroundImage = null; clickButton.BackgroundImage = null; break; } case GameModel.EnumState.FinalWin: { tableForCards.Dispose(); restartButton.Text = "♕\nRestart"; restartButton.Visible = true; congaratLabel.Visible = true; break; } case GameModel.EnumState.FinalLose: { tableForCards.Dispose(); restartButton.Text = "☹\nRestart"; restartButton.Visible = true; break; } } } ScoreRefresh(); }
/// <summary> /// /// </summary> private void CreateStreamDeckControls() { SuspendLayout(); // Trash existing control first if (iTableLayoutPanelStreamDeck != null) { Controls.Remove(iTableLayoutPanelStreamDeck); iTableLayoutPanelStreamDeck.Dispose(); iTableLayoutPanelStreamDeck = null; } // CreateStreamDeckTableLayoutPanel(); //For each row for (int j = 0; j < iTableLayoutPanelStreamDeck.RowCount; j++) { //For each column for (int i = 0; i < iTableLayoutPanelStreamDeck.ColumnCount; i++) { CreateStreamDeckKeyControls(i, j); } } ResumeLayout(false); }
/// <summary> /// 销毁控件 /// </summary> private void disposePanel() { //治具界面 if (panelUUT != null) { foreach (Control item in panelUUT.Controls) { panelUUT.Controls.Remove(item); item.Dispose(); } labUUTNo.Clear(); labUUT.Clear(); panelUUT.Dispose(); panelUUT = null; } //条码界面 if (panelSn != null) { foreach (Control item in panelSn.Controls) { panelSn.Controls.Remove(item); item.Dispose(); } labNo.Clear(); labSn.Clear(); labResult.Clear(); panelSn.Dispose(); panelSn = null; } }
protected virtual void Dispose(bool disposing) { if (disposing) { xLabel.Dispose(); yLabel.Dispose(); panel.Dispose(); } }
private void XoaCauTraLoiGayNhieu(object sender, EventArgs e) { if (UICommon.ShowMsgQuestionString("Bạn có chắc muốn xóa câu trả lời gây nhiễu này không ?", MessageBoxButtons.YesNo) != DialogResult.Yes) { return; } DevExpress.XtraEditors.SimpleButton button = sender as DevExpress.XtraEditors.SimpleButton; TableLayoutPanel tblPanelDapAn = button.Parent as TableLayoutPanel; int rowIndex = tblPanelMain2.GetRow(tblPanelDapAn); //get id cau hoi bi xoa int idCauTraLoiBiXoa = Convert.ToInt32(button.Tag); //IDEx xác định id ex de xoa trong list cau tra loi int idEx = Convert.ToInt32(tblPanelDapAn.Tag); var cauTraLoiBiXoa = CauHoiCurent.ListCauTraLoi.FirstOrDefault(m => m.IdEx == idEx); CauHoiCurent.ListCauTraLoi.Remove(cauTraLoiBiXoa); //neu khac 0 la cau hoi da ton tai, can xoa if (idCauTraLoiBiXoa != 0) { ListIdCauTraLoiBiXoa.Add(idCauTraLoiBiXoa); } //remove old controls foreach (Control ctrl in tblPanelDapAn.Controls) { ctrl.Dispose(); } tblPanelDapAn.Controls.Clear(); tblPanelDapAn.Dispose(); tblPanelMain2.Controls.Remove(tblPanelDapAn); _lstTablePanelGayNhieu.Remove(tblPanelDapAn); //decrease row index of panels down 2 //rename panel for (int i = rowIndex + 2; i < tblPanelMain2.RowStyles.Count; i = i + 2) { tblPanelDapAn = tblPanelMain2.Controls[_nameTablePanelDapAn + i] as TableLayoutPanel; if (tblPanelDapAn != null) { tblPanelMain2.SetRow(tblPanelDapAn, i - 2); tblPanelDapAn.Name = _nameTablePanelDapAn + (i - 2); } } //remove 2 last rows tblPanelMain2.RowStyles.RemoveAt(tblPanelMain2.RowStyles.Count - 2); tblPanelMain2.RowCount--; tblPanelMain2.RowStyles.RemoveAt(tblPanelMain2.RowStyles.Count - 2); tblPanelMain2.RowCount--; IsChanged = true; }
public void Render() { boardLayoutPanel?.Dispose(); boardLayoutPanel = CreateBoardLayoutPanel(); AddCellsToBoardLayout(boardLayoutPanel); outputControl.Controls.Add(boardLayoutPanel); outputControl.Invalidate(); }
private void XoaCauTraLoi(object sender, EventArgs e) { if (UICommon.ShowMsgQuestionString("Bạn có chắc muốn xóa câu trả lời này không ?", MessageBoxButtons.YesNo) != DialogResult.Yes) { return; } SimpleButton button = sender as SimpleButton; TableLayoutPanel tblPanelDapAn = button.Parent as TableLayoutPanel; int rowIndex = tblPanelMain.GetRow(tblPanelDapAn); //get id cau hoi bi xoa int idCauHoiBiXoa = Convert.ToInt32(button.Tag); //neu khac 0 la cau hoi da ton tai, can xoa if (idCauHoiBiXoa != 0) { ListIdCauHoiBiXoa.Add(idCauHoiBiXoa); IsChanged = true; } //remove old controls foreach (Control ctrl in tblPanelDapAn.Controls) { ctrl.Dispose(); } tblPanelDapAn.Controls.Clear(); tblPanelDapAn.Dispose(); tblPanelMain.Controls.Remove(tblPanelDapAn); _lstTablePanelDapAn.Remove(tblPanelDapAn); //decrease row index of panels down 2 //rename panel for (int i = rowIndex + 2; i < tblPanelMain.RowStyles.Count; i = i + 2) { tblPanelDapAn = tblPanelMain.Controls[_nameTablePanelDapAn + i] as TableLayoutPanel; if (tblPanelDapAn != null) { tblPanelMain.SetRow(tblPanelDapAn, i - 2); tblPanelDapAn.Name = _nameTablePanelDapAn + (i - 2); } } //remove 2 last rows tblPanelMain.RowStyles.RemoveAt(tblPanelMain.RowStyles.Count - 2); tblPanelMain.RowCount--; tblPanelMain.RowStyles.RemoveAt(tblPanelMain.RowStyles.Count - 2); tblPanelMain.RowCount--; // Reset text this.ResetTextCauTraLoi(); ResizeLayoutCauTraLoi(false); }
// The bulk of the clean-up code is implemented in Dispose(bool) protected virtual void Dispose(bool disposing) { if (disposing) { // free managed resources m_printBtn.Dispose(); m_panel.Dispose(); m_dataPanel.Dispose(); m_searchPanel.Dispose(); m_report.Dispose(); } // free native resources if there are any. }
// The bulk of the clean-up code is implemented in Dispose(bool) protected virtual void Dispose(bool disposing) { if (disposing) { // free managed resources foreach (var ctrl in m_searchCtrls) { ctrl.Dispose(); } } // free native resources if there are any. m_tblPanel.Dispose(); m_searchBtn.Dispose(); m_searchCtrls.Clear(); }
public void Dispose() { CoinIndexLabel.Dispose(); CoinLabel.Dispose(); PriceLabel.Dispose(); BoughtTextBox.Dispose(); BoughtPriceLabel.Dispose(); TotalLabel.Dispose(); PaidTextBox.Dispose(); ProfitLabel.Dispose(); RatioLabel.Dispose(); ChangeDollarLabel.Dispose(); ChangePercentLabel.Dispose(); Change1HrPercentLabel.Dispose(); Change24HrPercentLabel.Dispose(); Change7DayPercentLabel.Dispose(); Table.Dispose(); }
/// <summary> /// 销毁控件 /// </summary> private void disposePanel() { if (panelYield != null) { foreach (Control item in panelYield.Controls) { panelYield.Controls.Remove(item); item.Dispose(); } labTitle.Clear(); labName.Clear(); labTTNum.Clear(); labFailNum.Clear(); labPassRate.Clear(); panelYield.Dispose(); panelYield = null; } }
public void CreateField(int rowsCount, int columnsCount, int bombsCount) { if (_gameField != null) { _gameField.Dispose(); } int fieldLength = 30; _gameField = new TableLayoutPanel(); _gameField.ColumnCount = columnsCount; _gameField.RowCount = rowsCount; _gameField.CellBorderStyle = TableLayoutPanelCellBorderStyle.Single; _gameField.Margin = new Padding(0); _gameField.Padding = new Padding(0); _gameField.Width = columnsCount * fieldLength; _gameField.Height = rowsCount * fieldLength; _gameField.AutoSize = true; _gameField.TabIndex = 0; _gameField.BackColor = Color.White; for (int y = 0; y < rowsCount; y++) { _gameField.RowStyles.Add(new RowStyle(SizeType.Absolute, fieldLength)); for (int x = 0; x < columnsCount; x++) { _gameField.ColumnStyles.Add(new ColumnStyle(SizeType.Absolute, fieldLength)); CellButton button = new CellButton(x, y, fieldLength); button.MouseDown += new MouseEventHandler(_presenter.FieldButtonLeftClick); button.MouseDown += new MouseEventHandler(_presenter.FieldButtonRightClick); button.CellFlagged += new EventHandler(DecreaseBombsCounter); button.CellCleared += new EventHandler(IncreaseBombsCounter); _gameField.Controls.Add(button, x, y); } } gameFieldPanel.Controls.Add(_gameField); BombsCounter = bombsCount; }
private void CreatePanel() { panel.Dispose(); panel = new TableLayoutPanel { BackColor = SystemColors.ButtonHighlight, BackgroundImageLayout = ImageLayout.Center, CellBorderStyle = TableLayoutPanelCellBorderStyle.Single, ColumnCount = 3 }; panel.ColumnStyles.Add(new ColumnStyle(SizeType.Percent, 100F)); panel.Font = new Font("Microsoft Sans Serif", 11.25F, FontStyle.Bold, GraphicsUnit.Point, (0)); panel.Location = new Point(290, 228); panel.Name = "tableLayoutPanel1"; panel.Size = new Size(100, 40); panel.AutoSize = true; Controls.Add(panel); }
private void XoaCauTraLoiPhai(int IndexEx) { TableLayoutPanel tblPanelDapAn = _lstTablePanelCauTraLoi.FirstOrDefault(m => (int)m.Tag == IndexEx); int rowIndex = tblPanelMain2.GetRow(tblPanelDapAn); //remove old controls foreach (Control ctrl in tblPanelDapAn.Controls) { ctrl.Dispose(); } tblPanelDapAn.Controls.Clear(); tblPanelDapAn.Dispose(); tblPanelMain2.Controls.Remove(tblPanelDapAn); _lstTablePanelCauTraLoi.Remove(tblPanelDapAn); //decrease row index of panels down 2 //rename panel for (int i = rowIndex + 2; i < tblPanelMain2.RowStyles.Count; i = i + 2) { tblPanelDapAn = tblPanelMain2.Controls[_nameTablePanelDapAn + i] as TableLayoutPanel; if (tblPanelDapAn != null) { tblPanelMain2.SetRow(tblPanelDapAn, i - 2); tblPanelDapAn.Name = _nameTablePanelDapAn + (i - 2); } } //remove 2 last rows tblPanelMain2.RowStyles.RemoveAt(tblPanelMain2.RowStyles.Count - 2); tblPanelMain2.RowCount--; tblPanelMain2.RowStyles.RemoveAt(tblPanelMain2.RowStyles.Count - 2); tblPanelMain2.RowCount--; //xoa lai cau tra loi dien khuyet ResetTextCauTraLoiPhai(); ResizeLayoutCauTraLoiPhai(false); SetTextSoLuongCauHoi(); }
private void button8_ClickAsync(object sender, EventArgs e) { this.Cursor = Cursors.WaitCursor; string s1 = keyValuePairs[((sender as Button).Parent as TableLayoutPanel).Controls[1] as Label].ToString(); keyValuePairs.Remove(((sender as Button).Parent as TableLayoutPanel).Controls[1] as Label); TableLayoutPanel ss = ((sender as Button).Parent as TableLayoutPanel); MethodInvoker methodInvokerDelegate = async delegate() { await API.DeletePresets(Token, s1, ""); ss.Dispose(); this.Cursor = Cursors.Default; }; if (this.InvokeRequired) { this.Invoke(methodInvokerDelegate); } else { methodInvokerDelegate(); } }
/// 刷新电压输出规格 /// </summary> private void refreshOutPutPara() { try { if (vOutPanel != null) { vOutPanel.Dispose(); vOutPanel = null; } int rowNum = _chanNum; vOutPanel = new TableLayoutPanel(); vOutPanel.Dock = DockStyle.Fill; vOutPanel.CellBorderStyle = TableLayoutPanelCellBorderStyle.Single; vOutPanel.RowCount = rowNum + 2; vOutPanel.ColumnCount = 10; vOutPanel.RowStyles.Add(new RowStyle(SizeType.Absolute, 28)); for (int i = 0; i < rowNum + 1; i++) { vOutPanel.RowStyles.Add(new RowStyle(SizeType.Absolute, 24)); } vOutPanel.RowStyles.Add(new RowStyle(SizeType.Percent, 100)); vOutPanel.ColumnStyles.Add(new ColumnStyle(SizeType.Percent, 100)); vOutPanel.ColumnStyles.Add(new ColumnStyle(SizeType.Percent, 100)); vOutPanel.ColumnStyles.Add(new ColumnStyle(SizeType.Percent, 100)); vOutPanel.ColumnStyles.Add(new ColumnStyle(SizeType.Percent, 100)); vOutPanel.ColumnStyles.Add(new ColumnStyle(SizeType.Percent, 100)); vOutPanel.ColumnStyles.Add(new ColumnStyle(SizeType.Percent, 100)); vOutPanel.ColumnStyles.Add(new ColumnStyle(SizeType.Percent, 100)); vOutPanel.ColumnStyles.Add(new ColumnStyle(SizeType.Percent, 100)); vOutPanel.ColumnStyles.Add(new ColumnStyle(SizeType.Percent, 100)); vOutPanel.ColumnStyles.Add(new ColumnStyle(SizeType.Percent, 100)); Label lab1 = new Label(); lab1.Dock = DockStyle.Fill; lab1.TextAlign = ContentAlignment.MiddleCenter; lab1.Text = CLanguage.Lan("输出通道"); vOutPanel.Controls.Add(lab1, 0, 0); Label lab2 = new Label(); lab2.Dock = DockStyle.Fill; lab2.TextAlign = ContentAlignment.MiddleCenter; lab2.Text = CLanguage.Lan("输出名称"); vOutPanel.Controls.Add(lab2, 1, 0); Label lab3 = new Label(); lab3.Dock = DockStyle.Fill; lab3.TextAlign = ContentAlignment.MiddleCenter; lab3.Text = CLanguage.Lan("电压下限") + "(V)"; vOutPanel.Controls.Add(lab3, 2, 0); Label lab4 = new Label(); lab4.Dock = DockStyle.Fill; lab4.TextAlign = ContentAlignment.MiddleCenter; lab4.Text = CLanguage.Lan("电压上限") + "(V)"; vOutPanel.Controls.Add(lab4, 3, 0); Label lab5 = new Label(); lab5.Dock = DockStyle.Fill; lab5.TextAlign = ContentAlignment.MiddleCenter; lab5.Text = CLanguage.Lan("负载模式"); vOutPanel.Controls.Add(lab5, 4, 0); Label lab6 = new Label(); lab6.Dock = DockStyle.Fill; lab6.TextAlign = ContentAlignment.MiddleCenter; lab6.Text = CLanguage.Lan("负载设置") + "(A)"; vOutPanel.Controls.Add(lab6, 5, 0); Label lab7 = new Label(); lab7.Dock = DockStyle.Fill; lab7.TextAlign = ContentAlignment.MiddleCenter; lab7.Text = CLanguage.Lan("电流下限") + "(A)"; vOutPanel.Controls.Add(lab7, 6, 0); Label lab8 = new Label(); lab8.Dock = DockStyle.Fill; lab8.TextAlign = ContentAlignment.MiddleCenter; lab8.Text = CLanguage.Lan("电流上限") + "(A)"; vOutPanel.Controls.Add(lab8, 7, 0); Label lab9 = new Label(); lab9.Dock = DockStyle.Fill; lab9.TextAlign = ContentAlignment.MiddleCenter; lab9.Text = CLanguage.Lan("快充模式"); vOutPanel.Controls.Add(lab9, 8, 0); Label lab10 = new Label(); lab10.Dock = DockStyle.Fill; lab10.TextAlign = ContentAlignment.MiddleCenter; lab10.Text = CLanguage.Lan("快充电压") + "(V)"; vOutPanel.Controls.Add(lab10, 9, 0); vControl.Clear(); for (int i = 0; i < rowNum; i++) { vControl.Add(new CV_CTR()); vControl[i].chkIsUsed.Dock = DockStyle.Fill; vControl[i].chkIsUsed.Checked = true; vControl[i].chkIsUsed.Margin = new Padding(20, 0, 0, 0); vControl[i].chkIsUsed.Name = "CH" + i.ToString(); vControl[i].chkIsUsed.Text = "CH" + (i + 1).ToString(); vControl[i].chkIsUsed.CheckedChanged += new EventHandler(OnCheckChanged); vControl[i].txtName.Dock = DockStyle.Fill; vControl[i].txtName.TextAlign = HorizontalAlignment.Center; vControl[i].txtName.Margin = new Padding(1); vControl[i].txtName.Text = _outPut.Chan[i].Vname; vControl[i].txtVmin.Dock = DockStyle.Fill; vControl[i].txtVmin.TextAlign = HorizontalAlignment.Center; vControl[i].txtVmin.Margin = new Padding(1); vControl[i].txtVmin.KeyPress += new KeyPressEventHandler(OnTextKeyPressIsNumber); vControl[i].txtVmin.Text = _outPut.Chan[i].Vmin.ToString(); vControl[i].txtVmax.Dock = DockStyle.Fill; vControl[i].txtVmax.TextAlign = HorizontalAlignment.Center; vControl[i].txtVmax.Margin = new Padding(1); vControl[i].txtVmax.KeyPress += new KeyPressEventHandler(OnTextKeyPressIsNumber); vControl[i].txtVmax.Text = _outPut.Chan[i].Vmax.ToString(); vControl[i].cmbIMode.Dock = DockStyle.Fill; vControl[i].cmbIMode.Margin = new Padding(1); vControl[i].cmbIMode.DropDownStyle = ComboBoxStyle.DropDownList; vControl[i].cmbIMode.Items.Clear(); vControl[i].cmbIMode.Items.Add("0:CC_Slow"); vControl[i].cmbIMode.Items.Add("1:CV"); vControl[i].cmbIMode.Items.Add("2:CP"); vControl[i].cmbIMode.Items.Add("3:CR"); vControl[i].cmbIMode.Items.Add("4:CC_Fast"); vControl[i].cmbIMode.Items.Add("5:LED"); vControl[i].cmbIMode.SelectedIndex = 0; vControl[i].txtISet.Dock = DockStyle.Fill; vControl[i].txtISet.TextAlign = HorizontalAlignment.Center; vControl[i].txtISet.Margin = new Padding(1); vControl[i].txtISet.KeyPress += new KeyPressEventHandler(OnTextKeyPressIsNumber); vControl[i].txtISet.Text = _outPut.Chan[i].ISet.ToString(); vControl[i].txtImin.Dock = DockStyle.Fill; vControl[i].txtImin.TextAlign = HorizontalAlignment.Center; vControl[i].txtImin.Margin = new Padding(1); vControl[i].txtImin.KeyPress += new KeyPressEventHandler(OnTextKeyPressIsNumber); vControl[i].txtImin.Text = _outPut.Chan[i].Imin.ToString(); vControl[i].txtImax.Dock = DockStyle.Fill; vControl[i].txtImax.TextAlign = HorizontalAlignment.Center; vControl[i].txtImax.Margin = new Padding(1); vControl[i].txtImax.KeyPress += new KeyPressEventHandler(OnTextKeyPressIsNumber); vControl[i].txtImax.Text = _outPut.Chan[i].Imax.ToString(); vControl[i].cmbQCM.Dock = DockStyle.Fill; vControl[i].cmbQCM.Margin = new Padding(1); vControl[i].cmbQCM.DropDownStyle = ComboBoxStyle.DropDownList; vControl[i].cmbQCM.Items.Clear(); List <string> qcvList = new List <string>(); string[] strQcv = CKunXApp.QCM_Type.Split(','); for (int z = 0; z < strQcv.Length; z++) { if (!qcvList.Contains(strQcv[z]) && Enum.IsDefined(typeof(EQCM), strQcv[z])) { qcvList.Add(strQcv[i]); vControl[i].cmbQCM.Items.Add(strQcv[z]); } } vControl[i].cmbQCM.Text = ((EQCM)_outPut.Chan[i].QCType).ToString(); vControl[i].txtQCV.Dock = DockStyle.Fill; vControl[i].txtQCV.TextAlign = HorizontalAlignment.Center; vControl[i].txtQCV.Margin = new Padding(1); vControl[i].txtQCV.KeyPress += new KeyPressEventHandler(OnTextKeyPressIsNumber); vControl[i].txtQCV.Text = _outPut.Chan[i].QCV.ToString(); vOutPanel.Controls.Add(vControl[i].chkIsUsed, 0, i + 1); vOutPanel.Controls.Add(vControl[i].txtName, 1, i + 1); vOutPanel.Controls.Add(vControl[i].txtVmin, 2, i + 1); vOutPanel.Controls.Add(vControl[i].txtVmax, 3, i + 1); vOutPanel.Controls.Add(vControl[i].cmbIMode, 4, i + 1); vOutPanel.Controls.Add(vControl[i].txtISet, 5, i + 1); vOutPanel.Controls.Add(vControl[i].txtImin, 6, i + 1); vOutPanel.Controls.Add(vControl[i].txtImax, 7, i + 1); vOutPanel.Controls.Add(vControl[i].cmbQCM, 8, i + 1); vOutPanel.Controls.Add(vControl[i].txtQCV, 9, i + 1); } panel1.Controls.Add(vOutPanel, 0, 0); labDescribe.Text = _outPut.Describe; } catch (Exception) { throw; } }
public void TransitionTo(Screen screen) { gameModel.IsRunning = false; foreach (var p in AllGrids) { p.Visible = false; } DropSelection(); if (FightGrid != null) { foreach (var weapon in gameModel.PlayerShip.Weapons) { weapon.Target = null; weapon.TimeLeftToCoolDown = weapon.CoolDownTime; } AllGrids.Remove(FightGrid); this.Controls.Remove(FightGrid); FightGrid.Dispose(); FightGrid = null; GameTick.OnWin = null; GC.Collect(); } switch (screen) { case Screen.Menu: Sp.Stop(); Sp = new SoundPlayer("music/mainTheme.wav"); Sp.Play(); MainMenuGrid.Visible = true; break; case Screen.Options: OptionsGrid.Visible = true; break; case Screen.Start: StartGrid.Visible = true; break; case Screen.Help: HelpGrid.Visible = true; break; case Screen.Map: Sp.Stop(); Sp = new SoundPlayer("music/peaceTheme.wav"); Sp.Play(); MapGrid.Visible = true; break; case Screen.Fight: Sp.Stop(); Sp = new SoundPlayer("music/battleTheme.wav"); Sp.Play(); FightGrid = GenerateFightScreen(); //gameModel.OtherShip = new Titan(Alignment.Enemy); FightGrid.Visible = true; AllGrids.Add(FightGrid); this.Controls.Add(FightGrid); gameModel.IsRunning = true; break; case Screen.Peace: Sp.Stop(); Sp = new SoundPlayer("music/peaceTheme.wav"); Sp.Play(); PeaceGrid = GeneratePeaceScreen(); PeaceGrid.Visible = true; AllGrids.Add(PeaceGrid); this.Controls.Add(PeaceGrid); gameModel.IsRunning = true; break; default: throw new Exception("Unknown screen type"); } }
private void XoaCauHoiCon(object sender, EventArgs e) { //Nếu trái it nhất phải = 1 if (_lstTablePanelCauHoi.Count == 2) { UICommon.ShowMsgWarningString("Số câu hỏi con không được nhỏ hơn 2 \nBạn không thể xóa!"); return; } if (UICommon.ShowMsgQuestionString("Bạn có chắc muốn xóa câu hỏi này không ?") != DialogResult.Yes) { return; } SimpleButton button = sender as SimpleButton; TableLayoutPanel tblPanelDapAn = button.Parent as TableLayoutPanel; int rowIndex = tblPanelMain.GetRow(tblPanelDapAn); //get id cau hoi bi xoa int idEx = Convert.ToInt32(button.Tag); //neu khac 0 la cau hoi da ton tai, can xoa var cauHoi = CauHoiCurent.ListCauHoi.FirstOrDefault(m => m.IDEx == idEx); if (cauHoi != null && cauHoi.Id > 0) { ListIdCauHoiBiXoa.Add((int)cauHoi.Id); ListIdCauTraLoiBiXoa.Add((int)cauHoi.ListCauTraLoi.FirstOrDefault()?.Id); IsChanged = true; } //remove old controls foreach (Control ctrl in tblPanelDapAn.Controls) { ctrl.Dispose(); } tblPanelDapAn.Controls.Clear(); tblPanelDapAn.Dispose(); tblPanelMain.Controls.Remove(tblPanelDapAn); _lstTablePanelCauHoi.Remove(tblPanelDapAn); //decrease row index of panels down 2 //rename panel for (int i = rowIndex + 2; i < tblPanelMain.RowStyles.Count; i = i + 2) { tblPanelDapAn = tblPanelMain.Controls[_nameTablePanelCauHoi + i] as TableLayoutPanel; if (tblPanelDapAn != null) { tblPanelMain.SetRow(tblPanelDapAn, i - 2); tblPanelDapAn.Name = _nameTablePanelCauHoi + (i - 2); } } //remove 2 last rows tblPanelMain.RowStyles.RemoveAt(tblPanelMain.RowStyles.Count - 2); tblPanelMain.RowCount--; tblPanelMain.RowStyles.RemoveAt(tblPanelMain.RowStyles.Count - 2); tblPanelMain.RowCount--; // Reset text this.ResetTextCauTraLoi(); ResizeLayoutCauTraLoi(false); }
private void GameSummaryPopup_FormClosed(object sender, FormClosedEventArgs e) { _statsPanel.Dispose(); }
private void RebuildLayout() { TableLayoutPanel table = null; if (this.Controls.Count > 0) { table = this.Controls[0] as TableLayoutPanel; } if (table != null) { table.SuspendLayout(); foreach (Control c in table.Controls) { c.SizeChanged -= Control_SizeChanged; c.Dispose(); } table.Dispose(); } this.Controls.Clear(); toolTip.RemoveAll(); _heights = new Dictionary <Control, int>(); table = new TableLayoutPanel(); table.ColumnCount = 2; table.ColumnStyles.Add(new ColumnStyle(SizeType.AutoSize)); table.ColumnStyles.Add(new ColumnStyle(SizeType.AutoSize)); table.Dock = DockStyle.Fill; table.AutoSizeMode = System.Windows.Forms.AutoSizeMode.GrowAndShrink; table.AutoSize = true; table.AutoScroll = true; this.Controls.Add(table); table.SuspendLayout(); table.RowCount = _adapter.Parts.Count + 1; for (int i = 0; i < _adapter.Parts.Count; i++) { var part = _adapter.Parts[i]; table.RowStyles.Add(new RowStyle(SizeType.AutoSize)); var label = new Label(); label.AutoSize = true; label.Anchor = AnchorStyles.Left; label.Text = part.SelectedPath.Description.Replace("&", "&&"); table.Controls.Add(label, 0, i); var control = part.UIElement.Element; control.Dock = DockStyle.Fill; table.Controls.Add(control, 1, i); toolTip.SetToolTip(control, part.SelectedPath.ToString()); _heights.Add(control, 0); control.SizeChanged += Control_SizeChanged; } // add one more autosize row at the bottom to fill the remaining space table.RowStyles.Add(new RowStyle(SizeType.Percent, 100f)); // HACK: table layout autoscroll causes a horizontal scrollbar to appear - offset by vertical scrollbar width fixes this (but pads out the UI and looks less than ideal) table.Padding = new Padding(table.Padding.Left, table.Padding.Top, SystemInformation.VerticalScrollBarWidth + table.Padding.Right, table.Padding.Bottom); table.ResumeLayout(); }
public void Dispose() { _table?.Dispose(); }
/// <summary> /// Reset viewer. Clear all controls on container and reset row and column style. /// </summary> private void ResetViewer() { this.Controls.Clear(); // Dispose old workflow. if (WorkFlow != null) { WorkFlow.Dispose(); WorkFlow = null; } // Dispose Panel Container. if (PanelContainer != null) { // Unbind event handler. PanelContainer.Resize -= m_container_Resize; PanelContainer.Scroll -= m_container_Scroll; // Dispose object. PanelContainer.Dispose(); PanelContainer = null; } //Dispose Table Layout if (m_tableLayout != null) { m_tableLayout.Dispose(); m_tableLayout = null; } // ReCreate TableLayout. m_tableLayout = new TableLayoutPanel(); m_tableLayout.Dock = DockStyle.Fill; // ReCreate Container. PanelContainer = new WorkflowPanel(); PanelContainer.Dock = DockStyle.Fill; PanelContainer.AutoScroll = true; PanelContainer.Resize += m_container_Resize; PanelContainer.Scroll += m_container_Scroll; m_tableLayout.RowCount = 1; m_tableLayout.ColumnCount = 1; m_tableLayout.RowStyles.Clear(); m_tableLayout.ColumnStyles.Clear(); m_tableLayout.RowStyles.Add(new RowStyle(SizeType.Percent, 100)); m_tableLayout.ColumnStyles.Add(new ColumnStyle(SizeType.Percent, 100)); m_tableLayout.Controls.Add(PanelContainer, 0, 0); this.Controls.Add(m_tableLayout); // Create new workflow. WorkFlow = new Workflow(this, LineImage); WorkFlow.Anchor = AnchorStyles.Left | AnchorStyles.Top; WorkFlow.AutoSize = true; WorkFlow.AutoSizeMode = AutoSizeMode.GrowAndShrink; // Add workflow into container. PanelContainer.Controls.Add(WorkFlow); PanelContainer.Width = WorkFlow.Width; SubscribeWorkflow(); }
/// <summary> /// 初始化设置 /// </summary> /// <param name="statNum"></param> private void InitialFlowPanel(int statNum) { if (FlowPanel != null) { foreach (Control item in FlowPanel.Controls) { item.Dispose(); } FlowPanel.Dispose(); FlowPanel = null; } labStatId.Clear(); txtStatName.Clear(); cmbFlowId.Clear(); txtFlowName.Clear(); cmbDisable.Clear(); FlowPanel = new TableLayoutPanel(); FlowPanel.Dock = DockStyle.Fill; FlowPanel.CellBorderStyle = TableLayoutPanelCellBorderStyle.Single; FlowPanel.GetType().GetProperty("DoubleBuffered", System.Reflection.BindingFlags.Instance | System.Reflection.BindingFlags.NonPublic) .SetValue(FlowPanel, true, null); FlowPanel.RowCount = statNum + 2; for (int i = 0; i < statNum + 1; i++) { FlowPanel.RowStyles.Add(new RowStyle(SizeType.Absolute, 28)); } FlowPanel.RowStyles.Add(new RowStyle(SizeType.Percent, 100)); FlowPanel.ColumnCount = 6; FlowPanel.ColumnStyles.Add(new ColumnStyle(SizeType.Absolute, 80)); FlowPanel.ColumnStyles.Add(new ColumnStyle(SizeType.Absolute, 100)); FlowPanel.ColumnStyles.Add(new ColumnStyle(SizeType.Absolute, 80)); FlowPanel.ColumnStyles.Add(new ColumnStyle(SizeType.Absolute, 100)); FlowPanel.ColumnStyles.Add(new ColumnStyle(SizeType.Absolute, 80)); FlowPanel.ColumnStyles.Add(new ColumnStyle(SizeType.Percent, 100)); Label labT1 = new Label(); labT1.Dock = DockStyle.Fill; labT1.Margin = new Padding(1); labT1.TextAlign = ContentAlignment.MiddleCenter; labT1.Text = "编号"; FlowPanel.Controls.Add(labT1, 0, 0); Label labT2 = new Label(); labT2.Dock = DockStyle.Fill; labT2.Margin = new Padding(1); labT2.TextAlign = ContentAlignment.MiddleCenter; labT2.Text = "站别名称"; FlowPanel.Controls.Add(labT2, 1, 0); Label labT3 = new Label(); labT3.Dock = DockStyle.Fill; labT3.Margin = new Padding(1); labT3.TextAlign = ContentAlignment.MiddleCenter; labT3.Text = "流程编号"; FlowPanel.Controls.Add(labT3, 2, 0); Label labT4 = new Label(); labT4.Dock = DockStyle.Fill; labT4.Margin = new Padding(1); labT4.TextAlign = ContentAlignment.MiddleCenter; labT4.Text = "流程名称"; FlowPanel.Controls.Add(labT4, 3, 0); Label labT5 = new Label(); labT5.Dock = DockStyle.Fill; labT5.Margin = new Padding(1); labT5.TextAlign = ContentAlignment.MiddleCenter; labT5.Text = "使用状态"; FlowPanel.Controls.Add(labT5, 4, 0); for (int i = 0; i < statNum; i++) { Label lab1 = new Label(); lab1.Dock = DockStyle.Fill; lab1.Margin = new Padding(1); lab1.Text = (i + 1).ToString(); lab1.TextAlign = ContentAlignment.MiddleCenter; labStatId.Add(lab1); TextBox txt1 = new TextBox(); txt1.Dock = DockStyle.Fill; txt1.Margin = new Padding(1); txt1.TextAlign = HorizontalAlignment.Center; txt1.Text = ""; txtStatName.Add(txt1); ComboBox cmb1 = new ComboBox(); cmb1.Dock = DockStyle.Fill; cmb1.Margin = new Padding(1); cmb1.DropDownStyle = ComboBoxStyle.DropDownList; for (int z = 0; z < 12; z++) { cmb1.Items.Add(z + 1); } cmb1.SelectedIndex = i; cmbFlowId.Add(cmb1); TextBox txt2 = new TextBox(); txt2.Dock = DockStyle.Fill; txt2.Margin = new Padding(1); txt2.TextAlign = HorizontalAlignment.Center; txt2.Text = ""; txtFlowName.Add(txt2); ComboBox cmb2 = new ComboBox(); cmb2.Dock = DockStyle.Fill; cmb2.Margin = new Padding(1); cmb2.DropDownStyle = ComboBoxStyle.DropDownList; cmb2.Items.Add("启用"); cmb2.Items.Add("禁用"); cmb2.SelectedIndex = 0; cmbDisable.Add(cmb2); FlowPanel.Controls.Add(labStatId[i], 0, i + 1); FlowPanel.Controls.Add(txtStatName[i], 1, i + 1); FlowPanel.Controls.Add(cmbFlowId[i], 2, i + 1); FlowPanel.Controls.Add(txtFlowName[i], 3, i + 1); FlowPanel.Controls.Add(cmbDisable[i], 4, i + 1); } panel6.Controls.Add(FlowPanel, 0, 1); }
public override object EditValue(ITypeDescriptorContext context, IServiceProvider provider, object value) { var editorService = (IWindowsFormsEditorService)provider.GetService(typeof(IWindowsFormsEditorService)); if (editorService != null) { var subscription = default(IDisposable); var propertyDescriptor = context.PropertyDescriptor; var source = GetDataSource(context, provider); var chart = new ChartPanel(source, provider); chart.Dock = DockStyle.Fill; var autoSetButton = new Button { Text = AutoStart }; autoSetButton.Dock = DockStyle.Fill; var autoSetButtonClicked = Observable.FromEventPattern <EventHandler, EventArgs>( handler => autoSetButton.Click += handler, handler => autoSetButton.Click -= handler); var autoSetDeviationLabel = new Label(); autoSetDeviationLabel.Dock = DockStyle.Fill; autoSetDeviationLabel.Text = DeviationLabel; autoSetDeviationLabel.TextAlign = ContentAlignment.MiddleCenter; var autoSetDeviationUpDown = new NumericUpDown(); var upDownMargin = autoSetDeviationUpDown.Margin; autoSetDeviationUpDown.Margin = new Padding(upDownMargin.Left, upDownMargin.Top + 1, upDownMargin.Right, upDownMargin.Bottom); autoSetDeviationUpDown.Anchor = AnchorStyles.None; var autoSetPanel = new TableLayoutPanel(); autoSetPanel.Dock = DockStyle.Top; autoSetPanel.Height = autoSetButton.Height + autoSetPanel.Margin.Top; autoSetPanel.GrowStyle = TableLayoutPanelGrowStyle.AddColumns; autoSetPanel.Controls.Add(autoSetDeviationLabel, 0, 0); autoSetPanel.Controls.Add(autoSetDeviationUpDown, 1, 0); autoSetPanel.Controls.Add(autoSetButton, 2, 0); autoSetPanel.ColumnStyles.Add(new ColumnStyle(SizeType.Absolute, autoSetDeviationLabel.PreferredWidth + autoSetPanel.Margin.Left + autoSetPanel.Margin.Right)); autoSetPanel.ColumnStyles.Add(new ColumnStyle(SizeType.Absolute, autoSetDeviationUpDown.PreferredSize.Width)); autoSetPanel.ColumnStyles.Add(new ColumnStyle(SizeType.AutoSize)); autoSetDeviationUpDown.Maximum = 99; autoSetDeviationUpDown.Minimum = -99; var editorPanel = new TableLayoutPanel(); editorPanel.ClientSize = new System.Drawing.Size(320, 320); editorPanel.RowCount = 2; editorPanel.ColumnCount = 1; editorPanel.RowStyles.Add(new RowStyle(SizeType.Percent, 99)); editorPanel.RowStyles.Add(new RowStyle(SizeType.AutoSize)); editorPanel.Controls.Add(chart); editorPanel.Controls.Add(autoSetPanel); var activeVisualizer = provider.GetService(typeof(DialogTypeVisualizer)) as SpikeWaveformCollectionVisualizer; var spikeVisualizer = new MatVisualizer <WaveformThresholdPicker>(); if (activeVisualizer != null) { spikeVisualizer.AutoScaleX = activeVisualizer.AutoScaleX; spikeVisualizer.AutoScaleY = activeVisualizer.AutoScaleY; spikeVisualizer.ChannelOffset = activeVisualizer.ChannelOffset; spikeVisualizer.ChannelsPerPage = activeVisualizer.ChannelsPerPage; spikeVisualizer.HistoryLength = activeVisualizer.HistoryLength; spikeVisualizer.OverlayChannels = activeVisualizer.OverlayChannels; spikeVisualizer.SelectedChannels = activeVisualizer.SelectedChannels; spikeVisualizer.SelectedPage = activeVisualizer.SelectedPage; spikeVisualizer.WaveformBufferLength = activeVisualizer.WaveformBufferLength; spikeVisualizer.XMax = activeVisualizer.XMax; spikeVisualizer.XMin = activeVisualizer.XMin; spikeVisualizer.YMax = activeVisualizer.YMax; spikeVisualizer.YMin = activeVisualizer.YMin; } else { spikeVisualizer.OverlayChannels = false; spikeVisualizer.WaveformBufferLength = 10; } spikeVisualizer.Load(chart); var thresholdPicker = spikeVisualizer.Graph; thresholdPicker.Threshold = (double[])value; thresholdPicker.ThresholdChanged += (sender, e) => propertyDescriptor.SetValue(context.Instance, value = thresholdPicker.Threshold); var visualizerObservable = spikeVisualizer.Visualize(source.Output, chart); var autoSetObservable = AutoThreshold(source.Output, autoSetButtonClicked, () => (double)autoSetDeviationUpDown.Value) .Do(ts => propertyDescriptor.SetValue(context.Instance, value = thresholdPicker.Threshold = ts)); chart.HandleCreated += delegate { subscription = new CompositeDisposable(visualizerObservable.Subscribe(), autoSetObservable.Subscribe()); }; editorPanel.Leave += delegate { editorService.CloseDropDown(); subscription.Dispose(); }; autoSetButton.Click += delegate { autoSetButton.Text = autoSetButton.Text == AutoStart ? AutoStop : AutoStart; }; try { editorService.DropDownControl(editorPanel); } finally { chart.Dispose(); autoSetButton.Dispose(); editorPanel.Dispose(); spikeVisualizer.Unload(); } return(value); } return(base.EditValue(context, provider, value)); }
private void InitialSnPanel(int slotMax) { if (SnPanel != null) { foreach (Control item in SnPanel.Controls) { item.Dispose(); } SnPanel.Dispose(); SnPanel = null; } txtSn.Clear(); txtSnFlow.Clear(); cmbSnResult.Clear(); SnPanel = new TableLayoutPanel(); SnPanel.Dock = DockStyle.Fill; SnPanel.CellBorderStyle = TableLayoutPanelCellBorderStyle.Single; SnPanel.GetType().GetProperty("DoubleBuffered", System.Reflection.BindingFlags.Instance | System.Reflection.BindingFlags.NonPublic) .SetValue(SnPanel, true, null); SnPanel.RowCount = slotMax + 1; SnPanel.RowStyles.Add(new RowStyle(SizeType.Percent, 100)); for (int i = 0; i < slotMax; i++) { SnPanel.RowStyles.Add(new RowStyle(SizeType.Percent, 100)); } SnPanel.ColumnCount = 4; SnPanel.ColumnStyles.Add(new ColumnStyle(SizeType.Absolute, 60)); SnPanel.ColumnStyles.Add(new ColumnStyle(SizeType.Percent, 100)); SnPanel.ColumnStyles.Add(new ColumnStyle(SizeType.Absolute, 80)); SnPanel.ColumnStyles.Add(new ColumnStyle(SizeType.Absolute, 60)); Label labT1 = new Label(); labT1.Dock = DockStyle.Fill; labT1.Margin = new Padding(1); labT1.TextAlign = ContentAlignment.MiddleCenter; labT1.Text = "编号"; SnPanel.Controls.Add(labT1, 0, 0); Label labT2 = new Label(); labT2.Dock = DockStyle.Fill; labT2.Margin = new Padding(1); labT2.TextAlign = ContentAlignment.MiddleCenter; labT2.Text = "产品条码"; SnPanel.Controls.Add(labT2, 1, 0); Label labT3 = new Label(); labT3.Dock = DockStyle.Fill; labT3.Margin = new Padding(1); labT3.TextAlign = ContentAlignment.MiddleCenter; labT3.Text = "流程名称"; SnPanel.Controls.Add(labT3, 2, 0); Label labT4 = new Label(); labT4.Dock = DockStyle.Fill; labT4.Margin = new Padding(1); labT4.TextAlign = ContentAlignment.MiddleCenter; labT4.Text = "结果"; SnPanel.Controls.Add(labT4, 3, 0); for (int i = 0; i < slotMax; i++) { Label lab1 = new Label(); lab1.Dock = DockStyle.Fill; lab1.Margin = new Padding(1); lab1.Text = (i + 1).ToString("D2"); lab1.TextAlign = ContentAlignment.MiddleCenter; SnPanel.Controls.Add(lab1, 0, i + 1); TextBox txt1 = new TextBox(); txt1.Dock = DockStyle.Fill; txt1.Margin = new Padding(1); txt1.TextAlign = HorizontalAlignment.Center; txt1.Text = "A000000" + (i + 1).ToString("D2"); txtSn.Add(txt1); SnPanel.Controls.Add(txtSn[i], 1, i + 1); TextBox txt2 = new TextBox(); txt2.Dock = DockStyle.Fill; txt2.Margin = new Padding(1); txt2.TextAlign = HorizontalAlignment.Center; txt2.Text = ""; txtSnFlow.Add(txt2); SnPanel.Controls.Add(txtSnFlow[i], 2, i + 1); ComboBox cmb1 = new ComboBox(); cmb1.Dock = DockStyle.Fill; cmb1.Margin = new Padding(1); cmb1.DropDownStyle = ComboBoxStyle.DropDownList; cmb1.Items.Add("良品"); cmb1.Items.Add("不良"); cmb1.SelectedIndex = 0; cmbSnResult.Add(cmb1); SnPanel.Controls.Add(cmbSnResult[i], 3, i + 1); } panel11.Controls.Add(SnPanel, 1, 0); }
public void SetItem(CHPPara.CStep stepItem) { step = stepItem; if (panelStep != null) { foreach (Control item in panelStep.Controls) { item.Dispose(); } labStepName = null; txtStepVal = null; labStepDes = null; panelStep.Dispose(); } int itemNum = step.para.Count; labItemName.Text = CLanguage.Lan(step.des); panelStep = new TableLayoutPanel(); panelStep.GetType().GetProperty("DoubleBuffered", System.Reflection.BindingFlags.Instance | System.Reflection.BindingFlags.NonPublic) .SetValue(panelStep, true, null); panelStep.Dock = DockStyle.Fill; panelStep.CellBorderStyle = TableLayoutPanelCellBorderStyle.Single; panelStep.RowCount = itemNum + 1; panelStep.ColumnCount = 3; for (int i = 0; i < itemNum; i++) { panelStep.RowStyles.Add(new RowStyle(SizeType.Absolute, 28)); } panelStep.RowStyles.Add(new RowStyle(SizeType.Percent, 100)); panelStep.ColumnStyles.Add(new ColumnStyle(SizeType.Absolute, 120)); panelStep.ColumnStyles.Add(new ColumnStyle(SizeType.Absolute, 120)); panelStep.ColumnStyles.Add(new ColumnStyle(SizeType.Percent, 120)); labStepName = new Label[itemNum]; txtStepVal = new TextBox[itemNum]; labStepDes = new Label[itemNum]; for (int i = 0; i < itemNum; i++) { labStepName[i] = new Label(); labStepName[i].Name = "stepName" + i.ToString(); labStepName[i].Dock = DockStyle.Fill; labStepName[i].TextAlign = ContentAlignment.MiddleLeft; labStepName[i].Text = CLanguage.Lan(step.para[i].name) + ":"; panelStep.Controls.Add(labStepName[i], 0, i); txtStepVal[i] = new TextBox(); txtStepVal[i].Name = "stepVal" + i.ToString(); txtStepVal[i].Dock = DockStyle.Fill; txtStepVal[i].TextAlign = HorizontalAlignment.Center; txtStepVal[i].Text = step.para[i].setVal.ToString(); txtStepVal[i].KeyPress += new KeyPressEventHandler(OnStepValKeyPress); txtStepVal[i].TextChanged += new EventHandler(OnStepValChange); panelStep.Controls.Add(txtStepVal[i], 1, i); labStepDes[i] = new Label(); labStepDes[i].Name = "stepDes" + i.ToString(); labStepDes[i].Dock = DockStyle.Fill; labStepDes[i].TextAlign = ContentAlignment.MiddleLeft; labStepDes[i].Text = CLanguage.Lan(step.para[i].unitDes); panelStep.Controls.Add(labStepDes[i], 2, i); } splitContainer1.Panel2.Controls.Add(panelStep); }
public override void Unload() { base.Unload(); panel.Dispose(); panel = null; }
void DeleteShot(TableLayoutPanel shot) //выгрузка выстрела { shot.Dispose(); m_shots.Remove(shot); }
private void XoaCauTraLoi(object sender, EventArgs e) { if (ListCauHoi.Count == 1) { UICommon.ShowMsgWarningString("Số lượng câu hỏi không thể nhỏ hơn 1 \nBạn không thể xóa câu hỏi này"); return; } if (UICommon.ShowMsgQuestionString("Bạn có chắc muốn xóa câu trả lời này không ?", MessageBoxButtons.YesNo) != DialogResult.Yes) { return; } SimpleButton button = sender as SimpleButton; TableLayoutPanel tblPanelDapAn = button.Parent as TableLayoutPanel; int rowIndex = tblPanelMain.GetRow(tblPanelDapAn); ListIdCauHoiBiXoa.Add(CauHoiCurent.Id); //remove old controls foreach (Control ctrl in tblPanelDapAn.Controls) { ctrl.Dispose(); } tblPanelDapAn.Controls.Clear(); tblPanelDapAn.Dispose(); tblPanelMain.Controls.Remove(tblPanelDapAn); _lstTablePanelCauHoi.Remove(tblPanelDapAn); //decrease row index of panels down 2 //rename panel for (int i = rowIndex + 2; i < tblPanelMain.RowStyles.Count; i = i + 2) { tblPanelDapAn = tblPanelMain.Controls[_nameTablePanelDapAn + i] as TableLayoutPanel; if (tblPanelDapAn != null) { tblPanelMain.SetRow(tblPanelDapAn, i - 2); tblPanelDapAn.Name = _nameTablePanelDapAn + (i - 2); } } //remove 2 last rows tblPanelMain.RowStyles.RemoveAt(tblPanelMain.RowStyles.Count - 2); tblPanelMain.RowCount--; tblPanelMain.RowStyles.RemoveAt(tblPanelMain.RowStyles.Count - 2); tblPanelMain.RowCount--; //Tìm vị trí điền khuyết var noiDungReply = CauHoiCurent.ListCauTraLoi.FirstOrDefault(); var textReply = (string.Format("({0})_____", CauHoiCurent.IDEx)); txtCtrlNoiDungCauHoi.Focus(); txtCtrlNoiDungCauHoi.Find(textReply, RichTextBoxFinds.MatchCase); txtCtrlNoiDungCauHoi.Cut(); Clipboard.Clear(); //Tra lai noi dung cho text box cau hoi if (noiDungReply == null) { return; } var noiDungText = UICommon.ConvertRftToText(noiDungReply.NoiDung).Trim(); Clipboard.SetText(noiDungText); txtCtrlNoiDungCauHoi.Paste(); txtCtrlNoiDungCauHoi.Refresh(); Clipboard.Clear(); ListCauHoi.Remove(CauHoiCurent); int idEx = 1; foreach (var viTri in ListCauHoi) { var textFind = (string.Format("({0})_____", viTri.IDEx)); var textRepalce = (string.Format("({0})_____", idEx)); txtCtrlNoiDungCauHoi.Find(textFind, RichTextBoxFinds.MatchCase); txtCtrlNoiDungCauHoi.Focus(); txtCtrlNoiDungCauHoi.Cut(); Clipboard.Clear(); Clipboard.SetText(textRepalce); txtCtrlNoiDungCauHoi.Paste(); txtCtrlNoiDungCauHoi.Refresh(); viTri.IDEx = idEx++; } SetDataToCboCauHoi(); var cauHoiKeTiep = ListCauHoi.LastOrDefault(); //Xoa het du lieu cau hoi ClearAllCauTraLoi(); ClearAllCauTraLoiGayNhieu(); cboCauHoi.EditValueChanged -= CboCauHoi_EditValueChanged;; if (cauHoiKeTiep != null) { CauHoiCurent = cauHoiKeTiep; IdCauHoiCurent = cauHoiKeTiep.IDEx; LoadCauHoiNew(IdCauHoiCurent); cboCauHoi.CategoryID = cauHoiKeTiep.IDEx; } else { cboCauHoi.CategoryID = null; } cboCauHoi.EditValueChanged += CboCauHoi_EditValueChanged; _mathCollection = _parsing.ParseDienKhuyet2(txtCtrlNoiDungCauHoi.Text); IsChanged = true; }