Author: mhabersack
Date: 2007-06-29 16:11:03 -0400 (Fri, 29 Jun 2007)
New Revision: 81070

Modified:
   trunk/moon/desklet/cpumonitor/Makefile
   trunk/moon/desklet/cpumonitor/default.xaml
   trunk/moon/desklet/cpumonitor/monitor.cs
Log:
added close button


Modified: trunk/moon/desklet/cpumonitor/Makefile
===================================================================
--- trunk/moon/desklet/cpumonitor/Makefile      2007-06-29 20:04:24 UTC (rev 
81069)
+++ trunk/moon/desklet/cpumonitor/Makefile      2007-06-29 20:11:03 UTC (rev 
81070)
@@ -11,7 +11,8 @@
 all: $(ASSEMBLY)
 
 $(ASSEMBLY): $(DSOURCES)
-       gmcs -debug -target:library -pkg:silver $(DSOURCES)
+       gmcs -debug -target:library -pkg:silver -r:../desklets.dll $(DSOURCES)
+       cp -a ../desklets.dll .
 
 run: $(ASSEMBLY)
        MONO_OPTIONS=$(LOPTIONS) $(LAUNCHER) default.xaml

Modified: trunk/moon/desklet/cpumonitor/default.xaml
===================================================================
--- trunk/moon/desklet/cpumonitor/default.xaml  2007-06-29 20:04:24 UTC (rev 
81069)
+++ trunk/moon/desklet/cpumonitor/default.xaml  2007-06-29 20:11:03 UTC (rev 
81070)
@@ -14,6 +14,11 @@
            </Storyboard>
     </Canvas.Resources>
        
+    <!-- close/drag elements -->
+    <Polygon x:Name="desklet-close" Canvas.Left="0" Canvas.Top="0"
+            Points="4 4 8 8 4 12 6 14 10 10 14 14 16 12 12 8 16 4 14 2 10 6 6 
2 4 4"
+            Stroke="#66FFFFFF" StrokeThickness="3" Fill="#66FFFFFF" />
+
        <Ellipse
                x:Name="Circle"
                Stroke="Black"

Modified: trunk/moon/desklet/cpumonitor/monitor.cs
===================================================================
--- trunk/moon/desklet/cpumonitor/monitor.cs    2007-06-29 20:04:24 UTC (rev 
81069)
+++ trunk/moon/desklet/cpumonitor/monitor.cs    2007-06-29 20:11:03 UTC (rev 
81070)
@@ -49,7 +49,7 @@
                }
 
                public void FetchGlobalCounters() {
-               using ( StreamReader sr = new StreamReader ("/proc/stat")) {
+                       using ( StreamReader sr = new StreamReader 
("/proc/stat")) {
                                String line = sr.ReadLine ();
                                Read (line);
                        }
@@ -68,19 +68,24 @@
                ColorAnimation colorAnim;
                Storyboard colorSb;
 
+               Polygon closeButton;
+               
+               Brush buttonHilite = new SolidColorBrush (Color.FromArgb (0xAA, 
0xFF, 0xFF, 0xFF));
+               Brush buttonNormal = new SolidColorBrush (Color.FromArgb (0x66, 
0xFF, 0xFF, 0xFF));
+               
                public void DrawLoad ()
                {
-               CpuCounter cur = new CpuCounter ();
-               cur.FetchGlobalCounters ();
-               CpuCounter delta = cur.Sub (ref last);
-               last = cur;
+                       CpuCounter cur = new CpuCounter ();
+                       cur.FetchGlobalCounters ();
+                       CpuCounter delta = cur.Sub (ref last);
+                       last = cur;
                
-               double num = Math.Round (delta.CpuLoad ());
-               load.Text = ((int)num).ToString ();
+                       double num = Math.Round (delta.CpuLoad ());
+                       load.Text = ((int)num).ToString ();
                        Color current = (circle.Fill as SolidColorBrush).Color;
-               Color color = new Color ();
+                       Color color = new Color ();
 
-               if (num <= 50) {
+                       if (num <= 50) {
                                //interpolate (0,50) between green (0,255,0) 
and yellow (255,255,0)
                                double red = num / (50d / 255);
                                color = Color.FromRgb ((byte)red, 255, 0);
@@ -95,18 +100,39 @@
                        colorSb.Begin ();
                }
 
+               void HighlightButton (Polygon button)
+               {
+                       button.Stroke = buttonHilite;
+               }
+
+               void UnhighlightButton (Polygon button)
+               {
+                       button.Stroke = buttonNormal;
+               }
+               
                public void PageLoaded (object o, EventArgs e) 
-           {
-               circle = FindName ("Circle") as Shape;
-               load = FindName ("Load") as TextBlock;
-               colorSb = FindName ("color_sb") as Storyboard;
-               colorAnim = FindName ("color_anim") as  ColorAnimation;
-               last = new CpuCounter ();
+               {
+                       Mono.Desklets.Desklet.SetupToolbox (this);
 
-               if (circle == null)
-                       Console.WriteLine ("no circle ="+(FindName ("Circle") 
!= null));
+                       closeButton = FindName ("desklet-close") as Polygon;
 
-               Storyboard sb = FindName ("run") as Storyboard;
+                       closeButton.MouseEnter += delegate {
+                               HighlightButton (closeButton);
+                       };
+
+                       closeButton.MouseLeave += delegate {
+                               UnhighlightButton (closeButton);
+                       };
+                       circle = FindName ("Circle") as Shape;
+                       load = FindName ("Load") as TextBlock;
+                       colorSb = FindName ("color_sb") as Storyboard;
+                       colorAnim = FindName ("color_anim") as  ColorAnimation;
+                       last = new CpuCounter ();
+
+                       if (circle == null)
+                               Console.WriteLine ("no circle ="+(FindName 
("Circle") != null));
+
+                       Storyboard sb = FindName ("run") as Storyboard;
                        DoubleAnimation timer = new DoubleAnimation ();
                        sb.Children.Add (timer);
                        timer.Duration = new Duration 
(TimeSpan.FromMilliseconds (100));
@@ -115,8 +141,8 @@
                                DrawLoad ();
                                sb.Begin ();
                        };
-               sb.Begin ();
-               DrawLoad ();
+                       sb.Begin ();
+                       DrawLoad ();
                }
        }
 }

_______________________________________________
Mono-patches maillist  -  [email protected]
http://lists.ximian.com/mailman/listinfo/mono-patches

Reply via email to