Esempio n. 1
0
        // Static constructor.
        static NamedBrush()
        {
            BrushNameProperty = DependencyProperty.Register("BrushName", typeof(string), typeof(NamedBrush), new PropertyMetadata(BrushNameChangedCallback));
            BrushProperty     = DependencyProperty.Register("Brush", typeof(Brush), typeof(NamedBrush), new PropertyMetadata(BrushChangedCallback));

                        #if UseArray
            PropertyInfo[] props = typeof(Brushes).GetProperties();
            nbrushes = new NamedBrush[props.Length];
            for (int i = 0; i < props.Length; i++)
            {
                nbrushes[i] = new NamedBrush(props[i].Name, (Brush)props[i].GetValue(null, null));
            }
                        #endif
        }
Esempio n. 2
0
        private BrushList()
        {
            foreach (PropertyInfo pi in typeof(Colors).GetProperties())
            {
                if (pi.PropertyType != typeof(Color)) continue;

                MethodInfo mi = pi.GetGetMethod();
                const MethodAttributes inclusiveAttributes = MethodAttributes.Static | MethodAttributes.Public;
                if (mi == null || (mi.Attributes & inclusiveAttributes) != inclusiveAttributes) continue;

                NamedBrush namedBrush = new NamedBrush(pi.Name, (Color)pi.GetValue(null, null));
                brushes.Add(namedBrush);
            }
        }
Esempio n. 3
0
 void CopyToClipboard(NamedBrush nb)
 {
     if (nb != null)
     {
         SolidColorBrush scb       = nb.Brush as SolidColorBrush;
         string          colorName = nb.ClipboardName;
         string          text      = String.Format("{0}=#{4:x02}{1:x02}{2:x02}{3:x02}",
                                                   colorName,
                                                   scb.Color.R, scb.Color.G, scb.Color.B, scb.Color.A
                                                   );
         Report("{0}", text);
         try {
             Clipboard.SetText(text);
         } catch { }
     }
 }
Esempio n. 4
0
 public Window1()
 {
     InitializeComponent();
     for (int i = 0; i < frameBackground.Items.Count; ++i)
     {
         NamedBrush item  = frameBackground.Items[i] as NamedBrush;
         string[]   names = item.BrushName.Split(' ');
         if (names.Length == 2 && names[names.Length - 1] == "White")
         {
             frameBackground.SelectedIndex = i;
             break;
         }
     }
     clipper          = new DispatcherTimer();
     clipper.Tick    += new EventHandler(clipper_Tick);
     clipper.Interval = TimeSpan.FromSeconds(1);
     clipper.Start();
 }
Esempio n. 5
0
 private static void BrushChangedCallback(DependencyObject dob, DependencyPropertyChangedEventArgs e)
 {
     NamedBrush nb = dob as NamedBrush;
 }
Esempio n. 6
0
 public static void Add(NamedBrush namedBrush)
 {
     if (brushes.Count(nb => nb.Name == namedBrush.Name) <= 0)
         brushes.Insert(0, namedBrush);
 }