コード例 #1
0
        public void DrawLoad()
        {
            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();
            Color current = (circle.Fill as SolidColorBrush).Color;
            Color color   = new Color();

            if (num <= 50)
            {
                //interpolate (0,50) between green (0,255,0) and yellow (255,255,0)
                double red = num / (50d / 255);
                color = Color.FromArgb(255, (byte)red, 255, 0);
            }
            else
            {
                //interpolate (50,100) between yellow (255,255,0) and red (255,0,0)
                double green = (100d - num) / (50d / 255);
                color = Color.FromArgb(255, 255, (byte)green, 0);
            }

            colorAnim.From = current;
            colorAnim.To   = color;
            colorSb.Begin();
        }
コード例 #2
0
ファイル: cpumonitor.cs プロジェクト: dfr0/moon
		public void DrawLoad ()
		{
			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 ();
			Color current = (circle.Fill as SolidColorBrush).Color;
			Color color = new Color ();

			if (num <= 50) {
				//interpolate (0,50) between green (0,255,0) and yellow (255,255,0)
				double red = num / (50d / 255);
				color = Color.FromArgb (255, (byte)red, 255, 0);
			} else {
				//interpolate (50,100) between yellow (255,255,0) and red (255,0,0)
				double green = (100d - num) / (50d / 255);
				color = Color.FromArgb (255, 255, (byte)green, 0);
			}

			colorAnim.From = current;
			colorAnim.To = color;
			colorSb.Begin ();
		}
コード例 #3
0
ファイル: cpumonitor.cs プロジェクト: dfr0/moon
		public CpuCounter Sub (ref CpuCounter other) {
			CpuCounter res = this;
			res.user -= other.user;
			res.nice -= other.nice;
			res.system -= other.system;
			res.idle -= other.idle;
			res.iowait -= other.iowait;
			res.irq -= other.irq;
			res.softirq -= other.softirq;
			res.steal -= other.steal;
			res.total -= other.total;
			return res;
		}
コード例 #4
0
        public CpuCounter Sub(ref CpuCounter other)
        {
            CpuCounter res = this;

            res.user    -= other.user;
            res.nice    -= other.nice;
            res.system  -= other.system;
            res.idle    -= other.idle;
            res.iowait  -= other.iowait;
            res.irq     -= other.irq;
            res.softirq -= other.softirq;
            res.steal   -= other.steal;
            res.total   -= other.total;
            return(res);
        }
コード例 #5
0
        public void PageLoaded(object o, EventArgs e)
        {
            Moonlight.Gtk.Desklet.SetupToolbox(this);

            closeButton = FindName("desklet-close") as Polygon;

            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));

            sb.Completed += delegate {
                DrawLoad();
                sb.Begin();
            };
            sb.Begin();
            DrawLoad();
        }
コード例 #6
0
ファイル: cpumonitor.cs プロジェクト: dfr0/moon
		public void PageLoaded (object o, EventArgs e) 
		{
			Moonlight.Gtk.Desklet.SetupToolbox (this);

			closeButton = FindName ("desklet-close") as Polygon;

			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));

			sb.Completed += delegate {
				DrawLoad ();
				sb.Begin ();
			};
			sb.Begin ();
			DrawLoad ();
		}