Beispiel #1
0
 private void btnChange_Click(object sender, EventArgs e)
 {
     if (CanChange)
     {
         NamedColor origColor = SelectedNamedColor;
         string     name      = tbColorName.Text.Trim();
         Color      color     = ucColor.BackColor;
         origColor.Name  = name;
         origColor.Color = color;
         foreach (ListViewItem lvi in listView.Items)
         {
             if (lvi.Tag == origColor)
             {
                 lvi.Text = origColor.Name;
                 lvi.SubItems[1].BackColor = origColor.Color;
                 break;
             }
         }
         listView.Sort();
         UpdateControls();
         if (app.GetControlsAttr(ControlsAttr.AutoSave))
         {
             using (Context context = lib.GetContext()) origColor.Save(context);
         }
         if (OnNamedColorChanged != null)
         {
             OnNamedColorChanged(this, new NamedColorEventArgs(origColor));
         }
     }
 }
Beispiel #2
0
 private void btnAdd_Click(object sender, EventArgs e)
 {
     if (CanAdd)
     {
         string     name  = tbColorName.Text.Trim();
         Color      color = ucColor.BackColor;
         NamedColor nc    = new NamedColor(lib, name, color);
         colors.Add(nc);
         AddColor(nc);
         listView.Sort();
         UpdateControls();
         if (app.GetControlsAttr(ControlsAttr.AutoSave))
         {
             using (Context context = lib.GetContext()) nc.Save(context);
         }
         if (OnNamedColorAdded != null)
         {
             OnNamedColorAdded(this, new NamedColorEventArgs(nc));
         }
     }
 }