windows eventlog: Add a spinner
This commit is contained in:
parent
8fd3d8ee7b
commit
fdc3195bbf
|
@ -39,6 +39,7 @@ namespace SparkleShare {
|
||||||
private Label history_label_value;
|
private Label history_label_value;
|
||||||
private ComboBox combo_box;
|
private ComboBox combo_box;
|
||||||
private WebBrowser web_browser;
|
private WebBrowser web_browser;
|
||||||
|
private SparkleSpinner spinner;
|
||||||
|
|
||||||
|
|
||||||
// Short alias for the translations
|
// Short alias for the translations
|
||||||
|
@ -103,13 +104,15 @@ namespace SparkleShare {
|
||||||
|
|
||||||
this.web_browser.ObjectForScripting = new SparkleScriptingObject ();;
|
this.web_browser.ObjectForScripting = new SparkleScriptingObject ();;
|
||||||
|
|
||||||
|
spinner = new SparkleSpinner (22);
|
||||||
|
|
||||||
// Disable annoying IE clicking sound
|
// Disable annoying IE clicking sound
|
||||||
CoInternetSetFeatureEnabled (21, 0x00000002, true);
|
CoInternetSetFeatureEnabled (21, 0x00000002, true);
|
||||||
|
|
||||||
|
|
||||||
this.canvas = new Canvas ();
|
this.canvas = new Canvas ();
|
||||||
Content = this.canvas;
|
Content = this.canvas;
|
||||||
|
|
||||||
this.canvas.Children.Add (size_label);
|
this.canvas.Children.Add (size_label);
|
||||||
Canvas.SetLeft (size_label, 24);
|
Canvas.SetLeft (size_label, 24);
|
||||||
Canvas.SetTop (size_label, 4);
|
Canvas.SetTop (size_label, 4);
|
||||||
|
@ -131,6 +134,10 @@ namespace SparkleShare {
|
||||||
Canvas.SetLeft (background, 0);
|
Canvas.SetLeft (background, 0);
|
||||||
Canvas.SetTop (background, 36);
|
Canvas.SetTop (background, 36);
|
||||||
|
|
||||||
|
this.canvas.Children.Add (spinner);
|
||||||
|
Canvas.SetLeft (spinner, (Width / 2) - 15);
|
||||||
|
Canvas.SetTop (spinner, (Height / 2) - 22);
|
||||||
|
|
||||||
this.canvas.Children.Add (line);
|
this.canvas.Children.Add (line);
|
||||||
Canvas.SetLeft (line, 0);
|
Canvas.SetLeft (line, 0);
|
||||||
Canvas.SetTop (line, 35);
|
Canvas.SetTop (line, 35);
|
||||||
|
@ -181,10 +188,10 @@ namespace SparkleShare {
|
||||||
};
|
};
|
||||||
|
|
||||||
Controller.ContentLoadingEvent += delegate {
|
Controller.ContentLoadingEvent += delegate {
|
||||||
if (this.canvas.Children.Contains (this.web_browser))
|
this.spinner.Start ();
|
||||||
this.canvas.Children.Remove (this.web_browser);
|
|
||||||
|
if (this.canvas.Children.Contains (this.web_browser))
|
||||||
// ContentView.AddSubview (this.progress_indicator); //TODO spinner
|
this.canvas.Children.Remove (this.web_browser);
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -277,8 +284,7 @@ namespace SparkleShare {
|
||||||
|
|
||||||
|
|
||||||
Dispatcher.Invoke ((Action) delegate {
|
Dispatcher.Invoke ((Action) delegate {
|
||||||
//if (this.progress_indicator.Superview == ContentView) TODO: spinner
|
this.spinner.Stop ();
|
||||||
// this.progress_indicator.RemoveFromSuperview ();
|
|
||||||
|
|
||||||
this.web_browser.NavigateToString (html);
|
this.web_browser.NavigateToString (html);
|
||||||
|
|
||||||
|
|
|
@ -123,6 +123,7 @@
|
||||||
<Link>Program.cs</Link>
|
<Link>Program.cs</Link>
|
||||||
</Compile>
|
</Compile>
|
||||||
<Compile Include="SparkleNotifyIcon.cs" />
|
<Compile Include="SparkleNotifyIcon.cs" />
|
||||||
|
<Compile Include="SparkleSpinner.cs" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<ProjectReference Include="..\..\SparkleLib\windows\SparkleLib.csproj">
|
<ProjectReference Include="..\..\SparkleLib\windows\SparkleLib.csproj">
|
||||||
|
@ -281,6 +282,9 @@
|
||||||
<EmbeddedResource Include="..\..\data\icons\document-moved-12.png">
|
<EmbeddedResource Include="..\..\data\icons\document-moved-12.png">
|
||||||
<Link>Pixmaps\document-moved-12.png</Link>
|
<Link>Pixmaps\document-moved-12.png</Link>
|
||||||
</EmbeddedResource>
|
</EmbeddedResource>
|
||||||
|
<EmbeddedResource Include="..\..\data\icons\process-working-22.png">
|
||||||
|
<Link>Pixmaps\process-working-22.png</Link>
|
||||||
|
</EmbeddedResource>
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<None Include="..\..\data\plugins\github.png">
|
<None Include="..\..\data\plugins\github.png">
|
||||||
|
|
122
SparkleShare/Windows/SparkleSpinner.cs
Normal file
122
SparkleShare/Windows/SparkleSpinner.cs
Normal file
|
@ -0,0 +1,122 @@
|
||||||
|
// SparkleShare, a collaboration and sharing tool.
|
||||||
|
// Copyright (C) 2010 Hylke Bons <hylkebons@gmail.com>
|
||||||
|
//
|
||||||
|
// This program is free software: you can redistribute it and/or modify
|
||||||
|
// it under the terms of the GNU General Public License as published by
|
||||||
|
// the Free Software Foundation, either version 3 of the License, or
|
||||||
|
// (at your option) any later version.
|
||||||
|
//
|
||||||
|
// This program is distributed in the hope that it will be useful,
|
||||||
|
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
// GNU General Public License for more details.
|
||||||
|
//
|
||||||
|
// You should have received a copy of the GNU General Public License
|
||||||
|
// along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
|
using System;
|
||||||
|
using System.Timers;
|
||||||
|
using System.Windows;
|
||||||
|
using System.Windows.Controls;
|
||||||
|
using System.Windows.Media.Imaging;
|
||||||
|
|
||||||
|
namespace SparkleShare {
|
||||||
|
|
||||||
|
// TODO: cleanup
|
||||||
|
// This is a close implementation of GtkSpinner
|
||||||
|
public class SparkleSpinner : Image {
|
||||||
|
|
||||||
|
public bool Active;
|
||||||
|
|
||||||
|
private Image [] Images;
|
||||||
|
private Timer Timer;
|
||||||
|
private int CycleDuration;
|
||||||
|
private int CurrentStep;
|
||||||
|
private int NumSteps;
|
||||||
|
private int Size;
|
||||||
|
|
||||||
|
|
||||||
|
public SparkleSpinner (int size) : base ()
|
||||||
|
{
|
||||||
|
|
||||||
|
Width = size;
|
||||||
|
Height = size;
|
||||||
|
Size = size;
|
||||||
|
|
||||||
|
CycleDuration = 400;
|
||||||
|
CurrentStep = 0;
|
||||||
|
|
||||||
|
BitmapSource spinner_gallery = SparkleUIHelpers.GetImageSource ("process-working-22");
|
||||||
|
|
||||||
|
|
||||||
|
int frames_in_width = spinner_gallery.PixelWidth / Size;
|
||||||
|
int frames_in_height = spinner_gallery.PixelHeight / Size;
|
||||||
|
|
||||||
|
NumSteps = frames_in_width * frames_in_height;
|
||||||
|
Images = new Image [NumSteps - 1];
|
||||||
|
|
||||||
|
int i = 0;
|
||||||
|
|
||||||
|
for (int y = 0; y < frames_in_height; y++) {
|
||||||
|
for (int x = 0; x < frames_in_width; x++) {
|
||||||
|
if (!(y == 0 && x == 0)) {
|
||||||
|
CroppedBitmap crop = new CroppedBitmap (
|
||||||
|
spinner_gallery,
|
||||||
|
new Int32Rect (x*Size, y*Size, Size, Size));
|
||||||
|
Images [i] = new Image ();
|
||||||
|
Images [i].Source = crop;
|
||||||
|
i++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
Timer = new Timer () {
|
||||||
|
Interval = CycleDuration / NumSteps
|
||||||
|
};
|
||||||
|
|
||||||
|
Timer.Elapsed += delegate {
|
||||||
|
NextImage ();
|
||||||
|
};
|
||||||
|
|
||||||
|
Start ();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
private void NextImage ()
|
||||||
|
{
|
||||||
|
if (CurrentStep < NumSteps - 2)
|
||||||
|
CurrentStep++;
|
||||||
|
else
|
||||||
|
CurrentStep = 0;
|
||||||
|
|
||||||
|
Dispatcher.Invoke ((Action)delegate { SetImage (); });
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
private void SetImage ()
|
||||||
|
{
|
||||||
|
Source = Images [CurrentStep].Source;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public bool IsActive ()
|
||||||
|
{
|
||||||
|
return Active;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public void Start ()
|
||||||
|
{
|
||||||
|
CurrentStep = 0;
|
||||||
|
Active = true;
|
||||||
|
Timer.Start ();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public void Stop ()
|
||||||
|
{
|
||||||
|
Active = false;
|
||||||
|
Timer.Stop ();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in a new issue