private void cbOperatorDynamic_SelectedIndexChanged(int rCount) { Control[] op = pnlConditions.Controls.Find("cbOperator" + rCount, true); Control[] tb = pnlConditions.Controls.Find("tbValue" + rCount, true); if (op.Length <= 0) { throw new ArgumentException("No control with name cbOperator" + rCount + " was found!"); } if (tb.Length <= 0) { throw new ArgumentException("No control with name tbValue" + rCount + " was found!"); } MaterialComboBox cbOperatorDynamic = (MaterialComboBox)op[0]; MaterialTextBox tbValueDynamic = (MaterialTextBox)tb[0]; if (cbOperatorDynamic.SelectedItem.ToString() == "true" || cbOperatorDynamic.SelectedItem.ToString() == "false") { tbValueDynamic.Text = "N/A"; tbValueDynamic.Enabled = false; } else { tbValueDynamic.Text = ""; tbValueDynamic.Enabled = true; } }
private void SubtractSecond(MaterialTextBox tb) { if (pnlRunningTimers.Controls.Count > 1 && tb.Text != "0") { int value = Convert.ToInt32(tb.Text); value--; tb.Text = "" + value; } }
private void EBox_Enter(object sender, EventArgs e) { MaterialTextBox TB = (MaterialTextBox)sender; { int VisibleTime = 1000; ToolTip tt = new ToolTip(); tt.Show("Spodná hranica hodnotenia, vrátane.", TB, 25, -20, VisibleTime); } }
private MaterialTextBox CloneTextBox(MaterialTextBox original) { MaterialTextBox copy = new MaterialTextBox(); copy.BorderStyle = original.BorderStyle; copy.Font = original.Font; copy.Hint = original.Hint; copy.Size = original.Size; copy.MaxLength = original.MaxLength; copy.Multiline = original.Multiline; return(copy); }
private bool pflichtfeldvalidierung(Control Controlcard) { foreach (var control in Controlcard.Controls) { MaterialTextBox t = control as MaterialTextBox; if (t?.Text == String.Empty) { MessageBox.Show("Bitte füllen sie alle Felder aus! :)"); return(false); } } return(true); }
public static bool IsEmpty(MaterialTextBox textBox, bool msg = true) { if (string.IsNullOrWhiteSpace(textBox.Text)) { if (!msg) { return(true); } MyMessage.MsgShowWarning($@"{textBox.Name} is Empty, Please Check it again!!!"); return(true); } return(false); }
private void btnAddRow_Click(object sender, EventArgs e) { pnlConditions.AutoScrollPosition = new Point(0, 0); MaterialComboBox condition = CloneComboBox(cbCondition); MaterialComboBox dataType = CloneComboBox(cbDataType); MaterialComboBox op = CloneComboBox(cbOperator); MaterialTextBox property = CloneTextBox(tbProperty); MaterialTextBox value = CloneTextBox(tbValue); condition.Name = cbCondition.Name + rowCount; dataType.Name = cbDataType.Name + rowCount; op.Name = cbOperator.Name + rowCount; property.Name = tbProperty.Name + rowCount; value.Name = tbValue.Name + rowCount; //Names fixed, location is next condition.Location = new Point(cbCondition.Location.X, (cbCondition.Location.Y + cbCondition.Height) * rowCount); dataType.Location = new Point(cbDataType.Location.X, (cbDataType.Location.Y + cbDataType.Height) * rowCount); op.Location = new Point(cbOperator.Location.X, (cbOperator.Location.Y + cbOperator.Height) * rowCount); property.Location = new Point(tbProperty.Location.X, (tbProperty.Location.Y + cbCondition.Height) * rowCount); value.Location = new Point(tbValue.Location.X, (tbValue.Location.Y + cbCondition.Height) * rowCount); //location fixed, add em to the panel int currRowCount = 0 + rowCount; dataType.SelectedIndexChanged += (s, ee) => cbDataTypeDynamic_SelectedIndexChanged(currRowCount); op.SelectedIndexChanged += (s, ee) => cbOperatorDynamic_SelectedIndexChanged(currRowCount); pnlConditions.Controls.Add(condition); pnlConditions.Controls.Add(dataType); pnlConditions.Controls.Add(op); pnlConditions.Controls.Add(property); pnlConditions.Controls.Add(value); rowCount++; }
void Add(int _index, Subject _subject) { MaterialTextBox textField = new MaterialTextBox(); textField.ReadOnly = true; textField.Location = new Point(15, 30 + _index * 80); textField.Width = 395; textField.Tag = _subject.ID; textField.Hint = _subject.Name; textField.Click += new EventHandler(txtRunnerTeacher_Click); textField.TextChanged += TextField_TextChanged; MaterialTextBox textField2 = new MaterialTextBox(); textField2.ReadOnly = true; textField2.Location = new Point(15, 30 + _index * 80); textField2.Width = 395; textField2.Tag = _subject.ID; textField2.Hint = _subject.Name; textField2.Click += new EventHandler(txtRunnerTeacher_Click); textField2.TextChanged += TextField_TextChanged; MaterialCheckBox checkBox = new MaterialCheckBox(); checkBox.Location = new Point(425, 45 + _index * 80); checkBox.Text = "Khóa bảng điểm"; checkBox.Tag = _subject.ID; checkBox.CheckedColor = Color.FromArgb(47, 144, 176); checkBox.CheckedChanged += CheckBox_CheckedChanged; MaterialCheckBox checkBox2 = new MaterialCheckBox(); checkBox2.Location = new Point(425, 45 + _index * 80); checkBox2.Text = "Khóa bảng điểm"; checkBox2.Tag = _subject.ID; checkBox2.CheckedColor = Color.FromArgb(47, 144, 176); tbpgSem1.Controls.Add(textField); tbpgSem1.Controls.Add(checkBox); tbpgSem2.Controls.Add(textField2); tbpgSem2.Controls.Add(checkBox2); }
private void InitializeComponent() { this.materialTextBox1 = new MaterialTextBox(); this.SuspendLayout(); // // materialTextBox1 // this.materialTextBox1.FocusedColor = "#508ef5"; this.materialTextBox1.FontColor = "#999999"; this.materialTextBox1.IsEnabled = true; this.materialTextBox1.Location = new System.Drawing.Point(0, 0); this.materialTextBox1.MaxLength = 32767; this.materialTextBox1.Multiline = false; this.materialTextBox1.Name = "materialTextBox1"; this.materialTextBox1.ReadOnly = false; this.materialTextBox1.Size = new System.Drawing.Size(300, 24); this.materialTextBox1.TabIndex = 0; this.materialTextBox1.Text = "materialTextBox1"; this.materialTextBox1.TextAlignment = System.Windows.Forms.HorizontalAlignment.Left; this.materialTextBox1.UseSystemPasswordChar = false; this.materialTextBox1.PreviewKeyDown += new System.Windows.Forms.PreviewKeyDownEventHandler(this.materialTextBox1_PreviewKeyDown); this.ResumeLayout(false); }
private void TB_TextChanged(object sender, EventArgs e) { try { MaterialTextBox CTB = sender as MaterialTextBox; if (Regex.IsMatch(CTB.Text, "[^0-9]")) { CTB.Text = CTB.Text.Remove(CTB.Text.Length - 1); TB_TextChanged(sender, e); } else if (Convert.ToInt32(CTB.Text) > 255) { CTB.Text = "255"; } else if (Convert.ToInt32(CTB.Text) < 0) { CTB.Text = "0"; } } catch { // } }
/// <summary> /// Btn an Zobrazenie vybranej aktivity z datagridview /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void EditActTempBtn_Click(object sender, EventArgs e) { try { if (AllActTempGrid.Rows.Count <= 0) { return; } countAdd = 0; countBtnAdd = 1; this.AddTaskBtn.Visible = false; this.DeleteTaskBtn.Visible = false; ///Try if after click on Edit it will keep coount of everything and nothing else is differernt var labelCounts = Labels.Count - 1; //Odstranenie controls aby sa neopakovali pri editovani ClearTasks(); using (StudentDBDataContext con = new StudentDBDataContext(conn_str)) { var selectedTaskTemp = con.TaskTemplates.Where(a => a.IdActivityTemplate == (int)AllActTempGrid.CurrentRow.Cells[2].Value); var selectedAct = con.ActivityTemplates.Where(a => a.Id == (int)AllActTempGrid.CurrentRow.Cells[2].Value); var emailTemps = con.GetTable <EmailTemplate>().Where(x => x.IdUser == currUser.Id); comboBox1.Text = (from email in emailTemps where email.Id == selectedAct.FirstOrDefault().FirstRem select email.EmailTemplateName).FirstOrDefault(); comboBox2.Text = (from email in emailTemps where email.Id == selectedAct.FirstOrDefault().SecondRem select email.EmailTemplateName).FirstOrDefault(); foreach (var x in selectedAct) { ActNameTxtBox.Text = x.ActivityName; MaxPtsLabel.Text = x.MaxPoints.ToString(); } foreach (var x in selectedTaskTemp) { if (count >= 20) { MessageBox.Show("Nie je možné vytvoriť viac ako 20 úloh", "Upozornenie", MessageBoxButtons.OK, MessageBoxIcon.Warning); return; } this.AddTaskBtn.Location = new Point(25, 40 + (30 * countBtn)); this.DeleteTaskBtn.Location = new Point(500, 40 + (30 * countBtn++)); countBtnAdd++; MaterialLabel label = new MaterialLabel { Name = "DynamicLabel" + count, Location = new Point(21, 24 + (30 * count)), Text = "Názov úlohy: ", AutoSize = true, }; countAdd++; Labels.Add(label); this.panel1.Controls.Add(label); MaterialLabel labelPoints = new MaterialLabel { Name = "DynamicLabelPoints" + count, Location = new Point(420, 24 + (30 * count)), AutoSize = true, Text = "Max bodov: ", }; Labels.Add(labelPoints); this.panel1.Controls.Add(labelPoints); MaterialTextBox taskName = new MaterialTextBox() { Name = "DynName" + count, Location = new Point(124, 17 + (30 * count)), Size = new Size(245, 23), Text = x.TaskName, MaxLength = 45, }; this.panel1.Controls.Add(taskName); MaterialTextBox taskPoints = new MaterialTextBox() { Name = "DynPoints" + count, Location = new Point(520, 17 + (30 * count)), Size = new Size(70, 23), Text = x.MaxPts.ToString(), MaxLength = 5 }; count++; controlNamesForEdit.Add(taskName); controlPointsForEdit.Add(taskPoints); /// Pridavanie max bodov za task do max bodov za aktivitu taskPoints.TextChanged += TextBox_TextChanged; this.panel1.Controls.Add(taskPoints); } this.AddTaskBtn.Visible = true; this.DeleteTaskBtn.Visible = true; count = 0; countBtn = 1; } } catch (Exception ex) { Logger newLog = new Logger(); newLog.LogError(ex); MessageBox.Show(ex.ToString()); } }
/// <summary> /// Vytvaranie novych taskov dynamicky /// </summary> private void AddTaskBtn_Click(object sender, EventArgs e) { try { if (countAdd >= 20) { MessageBox.Show("Nie je možné vytvoriť viac ako 20 úloh", "Upozornenie", MessageBoxButtons.OK, MessageBoxIcon.Warning); return; } this.AddTaskBtn.Location = new Point(25, 40 + (30 * countBtnAdd)); this.DeleteTaskBtn.Location = new Point(500, 40 + (30 * countBtnAdd++)); MaterialLabel label = new MaterialLabel { Name = "DynamicLabel" + countAdd, Location = new Point(21, 24 + (30 * countAdd)), Text = "Názov úlohy:" }; Labels.Add(label); this.panel1.Controls.Add(label); MaterialLabel labelPoints = new MaterialLabel { Name = "DynamicLabelPoints" + countAdd, Location = new Point(420, 24 + (30 * countAdd)), Text = "Max bodov:" }; this.panel1.Controls.Add(labelPoints); Labels.Add(labelPoints); MaterialTextBox taskName = new MaterialTextBox() { Name = "DynName" + countAdd, Location = new Point(124, 17 + (30 * countAdd)), MaxLength = 45, SelectionBullet = false, Size = new Size(245, 18) }; this.panel1.Controls.Add(taskName); MaterialTextBox taskPoints = new MaterialTextBox() { Name = "DynPoints" + countAdd, Location = new Point(520, 17 + (30 * countAdd++)), MaxLength = 5, Size = new Size(70, 18) }; controlNamesForEdit.Add(taskName); controlPointsForEdit.Add(taskPoints); controlsNames.Add(taskName); controlsPoints.Add(taskPoints); /// Pridavanie max bodov za task do max bodov za aktivitu taskPoints.TextChanged += TextBox_TextChanged; this.panel1.Controls.Add(taskPoints); } catch (Exception ex) { Logger logger = new Logger(); logger.LogError(ex); } }
private void NewTaskTab(Activity activity, Student stud) { try { using (StudentDBDataContext con = new StudentDBDataContext(conn_str)) { var tasks = con.GetTable <Task>().Where(x => x.IdActivity == activity.Id && x.IdStudent == stud.Id); foreach (var task in tasks) { TabPage page1 = new TabPage { Name = task.TaskName, Text = task.TaskName + Graded(task), BackColor = Color.White, UseVisualStyleBackColor = true, }; RichTextBox comment = new RichTextBox { Name = "comment", Size = new Size(300, 190), Location = new Point(30, 125), Text = task.Comment }; Label label0 = new Label { Name = "NameOfTaskLabel" + count, Location = new Point(24, 15), AutoSize = true, Font = new Font("Roboto", 12), Text = "Názov: " + task.TaskName.ToString() }; tasksDictionary.Add(task.TaskName.ToString(), task.Id); MaterialLabel label = new MaterialLabel { Name = "TotalPtsLabel" + count, Location = new Point(26, 40), AutoSize = true, Text = "Maximum bodov: " + task.Points.ToString() }; MaterialLabel label2 = new MaterialLabel { Name = "StudentPtsLabel" + count, Location = new Point(26, 70), AutoSize = true, Text = "Získané: ", }; MaterialTextBox textField = new MaterialTextBox() { Name = "GradeTextBox", Location = new Point(100, 65), Size = new Size(70, 23), MaxLength = 4, Text = task.Hodnotenie.ToString(), }; MaterialLabel label3 = new MaterialLabel { Name = "CommentLabel" + count, Location = new Point(26, 105), AutoSize = true, Text = "Komentár ku úlohe: " }; MaterialButton button = new MaterialButton() { Name = "GradeBtn", Location = new Point(250, 330), Text = "Hodnotiť úlohu", }; button.Click += GradeTaskBtnClick; textField.Click += (s, e) => { textField.SelectAll(); }; MaterialTabCOntrol.Controls.Add(page1); page1.Controls.Add(label0); page1.Controls.Add(comment); page1.Controls.Add(label); page1.Controls.Add(label2); page1.Controls.Add(textField); page1.Controls.Add(label3); page1.Controls.Add(button); page1.ImageIndex = 0; } } } catch (Exception ex) { Logger newLog = new Logger(); newLog.LogError(ex); MessageBox.Show(ex.ToString()); } }