Author: mhabersack
Date: 2007-06-25 12:47:09 -0400 (Mon, 25 Jun 2007)
New Revision: 80694
Added:
trunk/moon/desklet/novell.clock/
trunk/moon/desklet/novell.clock/clock.cs
trunk/moon/desklet/novell.clock/clock.desklet
trunk/moon/desklet/novell.clock/default.xaml
trunk/moon/desklet/novell.clock/images/
trunk/moon/desklet/novell.clock/images/moon1.jpg
trunk/moon/desklet/novell.clock/images/moon2.jpg
Log:
a desklet ported from the plugin clock example
Added: trunk/moon/desklet/novell.clock/clock.cs
===================================================================
--- trunk/moon/desklet/novell.clock/clock.cs 2007-06-25 16:33:39 UTC (rev
80693)
+++ trunk/moon/desklet/novell.clock/clock.cs 2007-06-25 16:47:09 UTC (rev
80694)
@@ -0,0 +1,61 @@
+using System;
+using System.Threading;
+using IO=System.IO;
+
+using System.Windows;
+using System.Windows.Controls;
+using System.Windows.Media;
+using System.Windows.Media.Animation;
+using System.Windows.Shapes;
+
+namespace Golem.Desklet
+{
+ public class Clock : Canvas
+ {
+ RotateTransform secondsHand;
+ RotateTransform minuteHand;
+ RotateTransform hourHand;
+ Image background;
+ Timer t;
+ Uri moon1;
+ Uri moon2;
+
+ void UpdateTime (object status)
+ {
+ Console.WriteLine ("UpdateTime");
+ DateTime now = DateTime.Now;
+
+ if (now.Second < 30)
+ background.Source = moon1;
+ else
+ background.Source = moon2;
+
+ secondsHand.Angle = now.Second * 6;
+ minuteHand.Angle = now.Minute * 6;
+ hourHand.Angle = now.Hour * 30;
+ }
+
+ public void PageLoaded (object o, EventArgs e)
+ {
+ Console.WriteLine ("page loaded");
+ secondsHand = FindName ("secondsHand") as RotateTransform;
+ minuteHand = FindName ("minuteHand") as RotateTransform;
+ hourHand = FindName ("hourHand") as RotateTransform;
+ background = FindName ("backImage") as Image;
+
+ string imagesDir = IO.Path.Combine (Environment.CurrentDirectory,
"images");
+ moon1 = new Uri (IO.Path.Combine (imagesDir, "moon1.jpg"));
+ moon2 = new Uri (IO.Path.Combine (imagesDir, "moon2.jpg"));
+
+ if (secondsHand == null || minuteHand == null || hourHand == null ||
background == null) {
+ // TODO: Should communicate the error to the desklet host
+ Console.WriteLine ("Missing elements in the desklet xaml file");
+ return;
+ }
+
+ Console.WriteLine ("Starting timer");
+ AutoResetEvent autoEvent = new AutoResetEvent(false);
+ t = new Timer (new TimerCallback (UpdateTime), autoEvent, 5, 1000);
+ }
+ }
+}
Property changes on: trunk/moon/desklet/novell.clock/clock.cs
___________________________________________________________________
Name: svn:eol-style
+ native
Added: trunk/moon/desklet/novell.clock/clock.desklet
===================================================================
--- trunk/moon/desklet/novell.clock/clock.desklet 2007-06-25 16:33:39 UTC
(rev 80693)
+++ trunk/moon/desklet/novell.clock/clock.desklet 2007-06-25 16:47:09 UTC
(rev 80694)
@@ -0,0 +1,8 @@
+<?xml version="1.0" encoding="utf-8" ?><!-- -*- nxml -*- -->
+<golemDesklet>
+ <name>Clock</name>
+ <version>0.0.1</version>
+ <author>Mono Team</author>
+ <description>A sample clock applet</description>
+ <desklet path="default.xaml"/>
+</golemDesklet>
Added: trunk/moon/desklet/novell.clock/default.xaml
===================================================================
--- trunk/moon/desklet/novell.clock/default.xaml 2007-06-25 16:33:39 UTC
(rev 80693)
+++ trunk/moon/desklet/novell.clock/default.xaml 2007-06-25 16:47:09 UTC
(rev 80694)
@@ -0,0 +1,85 @@
+<Canvas xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
+ xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
+ x:Class="Golem.Desklet.Clock;assembly=bin/clock.dll"
+ Loaded="PageLoaded">
+
+ <Image Source="images/moon1.jpg" x:Name="backImage" Canvas.Left="0"
Canvas.Top="0" />
+
+ <!-- border 1 -->
+ <Path Fill="#ffc6c8da" Stroke="#ff605773" StrokeThickness="3">
+ <Path.Data>
+ <EllipseGeometry Center="100,100" RadiusX="50"
RadiusY="50" />
+ </Path.Data>
+ </Path>
+
+ <!-- border 2 -->
+ <Path Fill="#fff3f3f3" Stroke="#ff8585a0" StrokeThickness="5">
+ <Path.Data>
+ <EllipseGeometry Center="100,100" RadiusX="44"
RadiusY="44" />
+ </Path.Data>
+ </Path>
+
+ <!-- border 2 -->
+ <Path Fill="#fff3f3f3" Stroke="Silver" StrokeThickness="1">
+ <Path.Data>
+ <EllipseGeometry Center="100,100" RadiusX="40"
RadiusY="40" />
+ </Path.Data>
+ </Path>
+
+ <!-- dots -->
+ <Path Fill="Silver">
+ <Path.Data>
+ <EllipseGeometry Center="100,68" RadiusX="4"
RadiusY="4" />
+ </Path.Data>
+ </Path>
+ <Path Fill="Silver">
+ <Path.Data>
+ <EllipseGeometry Center="132,100" RadiusX="4"
RadiusY="4" />
+ </Path.Data>
+ </Path>
+ <Path Fill="Silver">
+ <Path.Data>
+ <EllipseGeometry Center="100,132" RadiusX="4"
RadiusY="4" />
+ </Path.Data>
+ </Path>
+ <Path Fill="Silver">
+ <Path.Data>
+ <EllipseGeometry Center="68,100" RadiusX="4"
RadiusY="4" />
+ </Path.Data>
+ </Path>
+
+
+ <!-- hour hand -->
+ <Line Stroke="Black" X1="100" Y1="75" X2="100" Y2="100"
StrokeThickness="6" StrokeStartLineCap="Round">
+ <Line.RenderTransform>
+ <RotateTransform x:Name="hourHand" Angle="30"
CenterX="100" CenterY="100" />
+ </Line.RenderTransform>
+ </Line>
+
+ <!-- minute hand -->
+ <Line Stroke="Black" X1="100" Y1="64" X2="100" Y2="100"
StrokeThickness="4" StrokeStartLineCap="Round">
+ <Line.RenderTransform>
+ <RotateTransform x:Name="minuteHand" Angle="100"
CenterX="100" CenterY="100" />
+ </Line.RenderTransform>
+ </Line>
+
+ <!-- middle -->
+ <Path Fill="#fff3f3f3" Stroke="#ff000000" StrokeThickness="4">
+ <Path.Data>
+ <EllipseGeometry Center="100,100" RadiusX="6"
RadiusY="6" />
+ </Path.Data>
+ </Path>
+
+ <!-- seconds hand -->
+ <Path Fill="Red" Stroke="Red">
+ <Path.Data>
+ <EllipseGeometry Center="100,100" RadiusX="3"
RadiusY="3" />
+ </Path.Data>
+ </Path>
+ <Line Stroke="Red" X1="100" Y1="62" X2="100" Y2="100"
StrokeThickness="2" StrokeStartLineCap="Round">
+ <Line.RenderTransform>
+ <RotateTransform x:Name="secondsHand" Angle="10"
CenterX="100" CenterY="100" />
+ </Line.RenderTransform>
+ </Line>
+
+</Canvas>
Added: trunk/moon/desklet/novell.clock/images/moon1.jpg
===================================================================
(Binary files differ)
Property changes on: trunk/moon/desklet/novell.clock/images/moon1.jpg
___________________________________________________________________
Name: svn:mime-type
+ image/jpeg
Added: trunk/moon/desklet/novell.clock/images/moon2.jpg
===================================================================
(Binary files differ)
Property changes on: trunk/moon/desklet/novell.clock/images/moon2.jpg
___________________________________________________________________
Name: svn:mime-type
+ image/jpeg
_______________________________________________
Mono-patches maillist - [email protected]
http://lists.ximian.com/mailman/listinfo/mono-patches