public MaterialListView AddEmbeddedButton(EventHandler handler, string columnName = "chAction_Default") { if (!this.Columns.ContainsKey(columnName)) { // Add Column header. ColumnHeader header = new ColumnHeader(); header.Name = columnName; header.Text = "操作"; header.Width = 105; header.TextAlign = HorizontalAlignment.Center; this.Columns.Add(header); } MaterialFlatButton button = new MaterialFlatButton(); button.CustomFont = new Font("微软雅黑", 9f); button.Text = "点击删除"; button.Primary = true; button.Click += handler; SubItem subItem = new SubItem() { Column = 4, Row = this.Items.Count == 0 ? 0 : this.Items.Count - 1 }; _embeddedControls[subItem] = button; this.Controls.Add(button); return(this); }
public void RemoveActiveItem(MaterialFlatButton button) { var activeSubItem = _embeddedControls.Where(kvp => kvp.Value == button).FirstOrDefault().Key; var subItems = _embeddedControls.Select(kvp => kvp.Key).ToList(); this.Controls.Remove(this._embeddedControls[activeSubItem]); this._embeddedControls.Remove(activeSubItem); for (int i = 0; i < subItems.Count; i++) { if (subItems[i].Row > activeSubItem.Row) { subItems[i].Row--; } } this.Items.Remove(this.Items[activeSubItem.Row]); }
void InitializeComponent() { this.materialLabel1 = new MaterialSkin.Controls.MaterialLabel(); this.materialFlatButton1 = new MaterialSkin.Controls.MaterialFlatButton(); this.SuspendLayout(); // // materialLabel1 // this.materialLabel1.AutoSize = false; this.materialLabel1.Depth = 0; this.materialLabel1.Font = new System.Drawing.Font("Roboto", 11F); this.materialLabel1.ForeColor = System.Drawing.Color.FromArgb(((int)(((byte)(222)))), ((int)(((byte)(0)))), ((int)(((byte)(0)))), ((int)(((byte)(0))))); this.materialLabel1.Location = new System.Drawing.Point(63, 21); this.materialLabel1.MouseState = MaterialSkin.MouseState.HOVER; this.materialLabel1.Name = "materialLabel1"; this.materialLabel1.Size = new System.Drawing.Size(116, 19); this.materialLabel1.TabIndex = 1; this.materialLabel1.Text = "John Appleseed"; // // materialFlatButton1 // this.materialFlatButton1.AutoSizeMode = System.Windows.Forms.AutoSizeMode.GrowAndShrink; this.materialFlatButton1.Depth = 0; this.materialFlatButton1.Location = new System.Drawing.Point(547, 0); this.materialFlatButton1.Margin = new System.Windows.Forms.Padding(4, 6, 4, 6); this.materialFlatButton1.MouseState = MaterialSkin.MouseState.HOVER; this.materialFlatButton1.Name = "materialFlatButton1"; this.materialFlatButton1.Primary = false; this.materialFlatButton1.Size = new System.Drawing.Size(63, 63); this.materialFlatButton1.TabIndex = 0; this.materialFlatButton1.Text = "Talk"; this.materialFlatButton1.UseVisualStyleBackColor = true; this.ResumeLayout(); Controls.AddRange(new Control[] { materialFlatButton1, materialLabel1 }); }
private void materialFlatButton_Click(object sender, EventArgs e) { if (lastActive == ((MaterialFlatButton)sender)) return; lastActive.UseCustomBackColor = true; lastActive.Refresh(); ((MaterialFlatButton)sender).UseCustomBackColor = false; ((MaterialFlatButton)sender).Refresh(); animateProgress = 10; animateStep = (((MaterialFlatButton)sender).Location.Y - lastActive.Location.Y) / 54; timer1.Start(); if ((MaterialFlatButton)sender != materialFlatButton1) lastActive = (MaterialFlatButton)sender; }
private void Main_Shown(object sender, EventArgs e) { if (Program.silentStart) { Hide(); Notification welcome = new Notification(Mode.Message); welcome.Text = "Welcome back Sait. Have a nice day!"; welcome.NotifyIcon = Resources.message_blue; welcome.Done += (o) => { this.Show(); this.Activate(); }; welcome.Show(); welcome.Activate(); if (File.Exists(@"C:\Windows\Media\Windows Logon.wav")) { SoundPlayer welcomeSound = new SoundPlayer(@"C:\Windows\Media\Windows Logon.wav"); welcomeSound.Play(); welcomeSound.Dispose(); } //PlaySound("Notification", UIntPtr.Zero, (uint)sndFlags.SND_SYNC); } materialFlatButton3.Focus(); lastActive = materialFlatButton3; materialSingleLineTextField1.Enabled = true; materialLabel1.Font = SkinManager.ROBOTO_MEDIUM_12; timePickerPanel1.timePicker.ClockMenu.SnapWindow(this.Handle, this.Handle, new SnapPoint { OffsetConstantX = this.Location.X + 180, OffsetConstantY = materialListView1.Location.Y + 104 }); timePickerPanel1.timePicker.ClockMenu.ClockButtonOK.Click += TimePicker_Choosed; timePickerPanel1.timePicker.ClockMenu.Closed += delegate (object o, ToolStripDropDownClosedEventArgs evnt) { materialSingleLineTextField1.Enabled = true; }; HandCursor = new Cursor(LoadCursor(IntPtr.Zero, idCursor.HAND)); finishLoad = true; }