convert tabs to space

This commit is contained in:
Hylke Bons 2012-10-20 23:25:36 +01:00
parent c274e87019
commit c0996c6569
16 changed files with 325 additions and 324 deletions

View file

@ -184,14 +184,15 @@ namespace SparkleLib {
if (File.Exists (identifier_path)) { if (File.Exists (identifier_path)) {
Identifier = File.ReadAllText (identifier_path).Trim (); Identifier = File.ReadAllText (identifier_path).Trim ();
File.SetAttributes (identifier_path, FileAttributes.Hidden);
} else { } else {
Identifier = CreateIdentifier (); Identifier = CreateIdentifier ();
File.WriteAllText (identifier_path, Identifier); File.WriteAllText (identifier_path, Identifier);
CreateInitialChangeSet (); CreateInitialChangeSet ();
} }
File.SetAttributes (identifier_path, FileAttributes.Hidden);
} }

View file

@ -46,9 +46,9 @@ namespace SparkleLib {
public class SparkleChange { public class SparkleChange {
public SparkleChangeType Type; public SparkleChangeType Type;
public DateTime Timestamp; public DateTime Timestamp;
public bool IsFolder = false; public bool IsFolder = false;
public string Path; public string Path;
public string MovedToPath; public string MovedToPath;
} }

View file

@ -169,7 +169,7 @@
} }
.table-wrapper { .table-wrapper {
padding: 64px 32px; padding: 64px 32px;
} }
td { td {

View file

@ -54,15 +54,15 @@ namespace SparkleShare {
"under certain conditions. Please read the GNU GPLv3 for details." + n + "under certain conditions. Please read the GNU GPLv3 for details." + n +
n + n +
"Usage: sparkleshare [start|stop|restart]"); "Usage: sparkleshare [start|stop|restart]");
Console.WriteLine ("SparkleShare is already running."); Console.WriteLine ("SparkleShare is already running.");
Environment.Exit (-1); Environment.Exit (-1);
} }
// Only allow one instance of SparkleShare (on Windows) // Only allow one instance of SparkleShare (on Windows)
if (!program_mutex.WaitOne (0, false)) { if (!program_mutex.WaitOne (0, false)) {
Console.WriteLine ("SparkleShare is already running."); Console.WriteLine ("SparkleShare is already running.");
Environment.Exit (-1); Environment.Exit (-1);
} }
try { try {
Controller = new SparkleController (); Controller = new SparkleController ();

View file

@ -65,7 +65,7 @@ namespace SparkleShare {
return message = string.Format (message, change_set.Changes [0].Path); return message = string.Format (message, change_set.Changes [0].Path);
} else if (change_set.Changes.Count > 1) { } else if (change_set.Changes.Count > 1) {
message = string.Format (message, change_set.Changes [0].Path); message = string.Format (message, change_set.Changes [0].Path);
return string.Format (message + " and {0} more", change_set.Changes.Count - 1); return string.Format (message + " and {0} more", change_set.Changes.Count - 1);
} else { } else {

View file

@ -504,7 +504,7 @@ namespace SparkleShare {
string tmp_path = this.config.TmpPath; string tmp_path = this.config.TmpPath;
if (!Directory.Exists (tmp_path)) { if (!Directory.Exists (tmp_path)) {
Directory.CreateDirectory (tmp_path); Directory.CreateDirectory (tmp_path);
File.SetAttributes (tmp_path, File.GetAttributes (tmp_path) | FileAttributes.Hidden); File.SetAttributes (tmp_path, File.GetAttributes (tmp_path) | FileAttributes.Hidden);
} }
@ -590,7 +590,7 @@ namespace SparkleShare {
this.fetcher.Complete (); this.fetcher.Complete ();
string canonical_name = Path.GetFileNameWithoutExtension (this.fetcher.RemoteUrl.AbsolutePath); string canonical_name = Path.GetFileNameWithoutExtension (this.fetcher.RemoteUrl.AbsolutePath);
canonical_name = canonical_name.Replace ("-crypto", ""); canonical_name = canonical_name.Replace ("-crypto", "");
bool target_folder_exists = Directory.Exists ( bool target_folder_exists = Directory.Exists (
Path.Combine (this.config.FoldersPath, canonical_name)); Path.Combine (this.config.FoldersPath, canonical_name));

View file

@ -50,7 +50,7 @@ namespace SparkleShare {
return IO.Path.Combine (PluginsPath, image_file_name); return IO.Path.Combine (PluginsPath, image_file_name);
} }
} }
public bool PathUsesLowerCase { public bool PathUsesLowerCase {
get { get {
string uses_lower_case = GetValue ("path", "uses_lower_case"); string uses_lower_case = GetValue ("path", "uses_lower_case");

View file

@ -342,7 +342,7 @@ namespace SparkleShare {
public void AddPageCompleted (string address, string remote_path) public void AddPageCompleted (string address, string remote_path)
{ {
SyncingFolder = Path.GetFileNameWithoutExtension (remote_path); SyncingFolder = Path.GetFileNameWithoutExtension (remote_path);
SyncingFolder = SyncingFolder.Replace ("-crypto", ""); SyncingFolder = SyncingFolder.Replace ("-crypto", "");
ProgressBarPercentage = 1.0; ProgressBarPercentage = 1.0;
ChangePageEvent (PageType.Syncing, null); ChangePageEvent (PageType.Syncing, null);

View file

@ -117,8 +117,8 @@ namespace SparkleShare {
Width = 318 Width = 318
}; };
SparkleLink website_link = new SparkleLink ("Website", Controller.WebsiteLinkAddress); SparkleLink website_link = new SparkleLink ("Website", Controller.WebsiteLinkAddress);
SparkleLink credits_link = new SparkleLink ("Credits", Controller.CreditsLinkAddress); SparkleLink credits_link = new SparkleLink ("Credits", Controller.CreditsLinkAddress);
SparkleLink report_problem_link = new SparkleLink ("Report a problem", Controller.ReportProblemLinkAddress); SparkleLink report_problem_link = new SparkleLink ("Report a problem", Controller.ReportProblemLinkAddress);
SparkleLink debug_log_link = new SparkleLink ("Debug log", Controller.DebugLogLinkAddress); SparkleLink debug_log_link = new SparkleLink ("Debug log", Controller.DebugLogLinkAddress);
@ -140,11 +140,11 @@ namespace SparkleShare {
Canvas.SetLeft (credits, 294); Canvas.SetLeft (credits, 294);
Canvas.SetTop (credits, 142); Canvas.SetTop (credits, 142);
canvas.Children.Add (website_link); canvas.Children.Add (website_link);
Canvas.SetLeft (website_link, 289); Canvas.SetLeft (website_link, 289);
Canvas.SetTop (website_link, 222); Canvas.SetTop (website_link, 222);
canvas.Children.Add (credits_link); canvas.Children.Add (credits_link);
Canvas.SetLeft (credits_link, 289 + website_link.ActualWidth + 60); Canvas.SetLeft (credits_link, 289 + website_link.ActualWidth + 60);
Canvas.SetTop (credits_link, 222); Canvas.SetTop (credits_link, 222);
@ -169,32 +169,32 @@ namespace SparkleShare {
} }
public class SparkleLink : Label { public class SparkleLink : Label {
public SparkleLink (string title, string url) public SparkleLink (string title, string url)
{ {
FontSize = 11; FontSize = 11;
Cursor = Cursors.Hand; Cursor = Cursors.Hand;
Foreground = new SolidColorBrush (Color.FromRgb (135, 178, 227)); Foreground = new SolidColorBrush (Color.FromRgb (135, 178, 227));
TextDecoration underline = new TextDecoration () { TextDecoration underline = new TextDecoration () {
Pen = new Pen (new SolidColorBrush (Color.FromRgb (135, 178, 227)), 1), Pen = new Pen (new SolidColorBrush (Color.FromRgb (135, 178, 227)), 1),
PenThicknessUnit = TextDecorationUnit.FontRecommended PenThicknessUnit = TextDecorationUnit.FontRecommended
}; };
TextDecorationCollection collection = new TextDecorationCollection (); TextDecorationCollection collection = new TextDecorationCollection ();
collection.Add (underline); collection.Add (underline);
TextBlock text_block = new TextBlock () { TextBlock text_block = new TextBlock () {
Text = title, Text = title,
TextDecorations = collection TextDecorations = collection
}; };
Content = text_block; Content = text_block;
MouseUp += delegate { MouseUp += delegate {
Program.Controller.OpenWebsite (url); Program.Controller.OpenWebsite (url);
}; };
} }
} }
} }

View file

@ -129,17 +129,17 @@ namespace SparkleShare {
public override bool CreateSparkleShareFolder () public override bool CreateSparkleShareFolder ()
{ {
if (Directory.Exists (FoldersPath)) if (Directory.Exists (FoldersPath))
return false; return false;
Directory.CreateDirectory (FoldersPath); Directory.CreateDirectory (FoldersPath);
File.SetAttributes (FoldersPath, File.GetAttributes (FoldersPath) | FileAttributes.System); File.SetAttributes (FoldersPath, File.GetAttributes (FoldersPath) | FileAttributes.System);
SparkleLogger.LogInfo ("Config", "Created '" + FoldersPath + "'"); SparkleLogger.LogInfo ("Config", "Created '" + FoldersPath + "'");
string app_path = Path.GetDirectoryName (Forms.Application.ExecutablePath); string app_path = Path.GetDirectoryName (Forms.Application.ExecutablePath);
string icon_file_path = Path.Combine (app_path, "Pixmaps", "sparkleshare-folder.ico"); string icon_file_path = Path.Combine (app_path, "Pixmaps", "sparkleshare-folder.ico");
if (!File.Exists (icon_file_path)) { if (!File.Exists (icon_file_path)) {
string ini_file_path = Path.Combine (FoldersPath, "desktop.ini"); string ini_file_path = Path.Combine (FoldersPath, "desktop.ini");
string ini_file = "[.ShellClassInfo]" + string ini_file = "[.ShellClassInfo]" +
@ -147,20 +147,20 @@ namespace SparkleShare {
"IconIndex=0" + "IconIndex=0" +
"InfoTip=SparkleShare"; "InfoTip=SparkleShare";
try { try {
File.Create (ini_file_path).Close (); File.Create (ini_file_path).Close ();
File.WriteAllText (ini_file_path, ini_file); File.WriteAllText (ini_file_path, ini_file);
File.SetAttributes (ini_file_path, File.SetAttributes (ini_file_path,
File.GetAttributes (ini_file_path) | FileAttributes.Hidden | FileAttributes.System); File.GetAttributes (ini_file_path) | FileAttributes.Hidden | FileAttributes.System);
} catch (IOException e) { } catch (IOException e) {
SparkleLogger.LogInfo ("Config", SparkleLogger.LogInfo ("Config",
"Failed setting icon for '" + FoldersPath + "': " + e.Message); "Failed setting icon for '" + FoldersPath + "': " + e.Message);
} }
return true; return true;
} }
return false; return false;
} }
@ -172,20 +172,20 @@ namespace SparkleShare {
} }
public override void OpenFolder (string path) public override void OpenFolder (string path)
{ {
Process process = new Process (); Process process = new Process ();
process.StartInfo.FileName = "explorer"; process.StartInfo.FileName = "explorer";
process.StartInfo.Arguments = path; process.StartInfo.Arguments = path;
process.Start (); process.Start ();
} }
public override void OpenWebsite (string url) public override void OpenWebsite (string url)
{ {
Process.Start (new ProcessStartInfo (url)); Process.Start (new ProcessStartInfo (url));
} }
public override void Quit () public override void Quit ()

View file

@ -117,10 +117,10 @@ namespace SparkleShare {
"MouseClick", RoutingStrategy.Bubble, typeof (MouseButtonEventHandler), typeof (SparkleNotifyIcon)); "MouseClick", RoutingStrategy.Bubble, typeof (MouseButtonEventHandler), typeof (SparkleNotifyIcon));
public readonly RoutedEvent MouseDoubleClickEvent = EventManager.RegisterRoutedEvent( public readonly RoutedEvent MouseDoubleClickEvent = EventManager.RegisterRoutedEvent(
"MouseDoubleClick", RoutingStrategy.Bubble, typeof (MouseButtonEventHandler), typeof (SparkleNotifyIcon)); "MouseDoubleClick", RoutingStrategy.Bubble, typeof (MouseButtonEventHandler), typeof (SparkleNotifyIcon));
public readonly DependencyProperty TextProperty = DependencyProperty.Register( public readonly DependencyProperty TextProperty = DependencyProperty.Register(
"Text", typeof(string), typeof (SparkleNotifyIcon), new PropertyMetadata (OnTextChanged)); "Text", typeof(string), typeof (SparkleNotifyIcon), new PropertyMetadata (OnTextChanged));
private string header_text; private string header_text;
@ -154,7 +154,7 @@ namespace SparkleShare {
// TODO: // TODO:
// - Use the image pointed to by image_path // - Use the image pointed to by image_path
// - Find a way to use the prettier (Win7?) balloons // - Find a way to use the prettier (Win7?) balloons
this.notify_icon.ShowBalloonTip (5 * 1000, title, subtext, Forms.ToolTipIcon.Info); this.notify_icon.ShowBalloonTip (5 * 1000, title, subtext, Forms.ToolTipIcon.Info);
} }
@ -241,7 +241,7 @@ namespace SparkleShare {
struct_pointer, typeof (MouseLLHook)); struct_pointer, typeof (MouseLLHook));
return new Point (mouse_hook.X, mouse_hook.Y); return new Point (mouse_hook.X, mouse_hook.Y);
} }
private int OnMouseEventProc (int code, int button, IntPtr data_pointer) private int OnMouseEventProc (int code, int button, IntPtr data_pointer)
@ -277,7 +277,7 @@ namespace SparkleShare {
GetModuleHandle (module.ModuleName), 0); GetModuleHandle (module.ModuleName), 0);
} }
if (this.mouse_hook_handle == 0) if (this.mouse_hook_handle == 0)
throw new Win32Exception (Marshal.GetLastWin32Error ()); throw new Win32Exception (Marshal.GetLastWin32Error ());
} }

View file

@ -25,172 +25,172 @@ using System.Windows.Forms;
namespace SparkleShare { namespace SparkleShare {
public class Shortcut : IDisposable { public class Shortcut : IDisposable {
private IShellLinkW link; private IShellLinkW link;
public Shortcut () public Shortcut ()
{ {
} }
public void Create (string file_path, string target_path) public void Create (string file_path, string target_path)
{ {
link = (IShellLinkW) new CShellLink (); link = (IShellLinkW) new CShellLink ();
this.link.SetShowCmd (1); this.link.SetShowCmd (1);
this.link.SetPath (target_path); this.link.SetPath (target_path);
(this.link as IPersistFile).Save (file_path, true); (this.link as IPersistFile).Save (file_path, true);
} }
public void Dispose () { public void Dispose () {
if (this.link == null ) if (this.link == null )
return; return;
Marshal.ReleaseComObject (this.link); Marshal.ReleaseComObject (this.link);
this.link = null; this.link = null;
} }
~Shortcut () ~Shortcut ()
{ {
Dispose (); Dispose ();
} }
private class UnManagedMethods { private class UnManagedMethods {
[DllImport ("Shell32", CharSet = CharSet.Auto)] [DllImport ("Shell32", CharSet = CharSet.Auto)]
internal extern static int ExtractIconEx ( internal extern static int ExtractIconEx (
[MarshalAs(UnmanagedType.LPTStr)] string lpszFile, int nIconIndex, [MarshalAs(UnmanagedType.LPTStr)] string lpszFile, int nIconIndex,
IntPtr[] phIconLarge, IntPtr[] phIconSmall, int nIcons); IntPtr[] phIconLarge, IntPtr[] phIconSmall, int nIcons);
[DllImport ("user32")] [DllImport ("user32")]
internal static extern int DestroyIcon (IntPtr hIcon); internal static extern int DestroyIcon (IntPtr hIcon);
} }
[StructLayoutAttribute (LayoutKind.Sequential, Pack = 4, Size = 0)] [StructLayoutAttribute (LayoutKind.Sequential, Pack = 4, Size = 0)]
private struct _FILETIME { private struct _FILETIME {
public uint dwLowDateTime; public uint dwLowDateTime;
public uint dwHighDateTime; public uint dwHighDateTime;
} }
[StructLayoutAttribute(LayoutKind.Sequential, Pack = 4, Size = 0, CharSet = CharSet.Unicode)] [StructLayoutAttribute(LayoutKind.Sequential, Pack = 4, Size = 0, CharSet = CharSet.Unicode)]
private struct _WIN32_FIND_DATAW { private struct _WIN32_FIND_DATAW {
public uint dwFileAttributes; public uint dwFileAttributes;
public _FILETIME ftCreationTime; public _FILETIME ftCreationTime;
public _FILETIME ftLastAccessTime; public _FILETIME ftLastAccessTime;
public _FILETIME ftLastWriteTime; public _FILETIME ftLastWriteTime;
public uint nFileSizeHigh; public uint nFileSizeHigh;
public uint nFileSizeLow; public uint nFileSizeLow;
public uint dwReserved0; public uint dwReserved0;
public uint dwReserved1; public uint dwReserved1;
[MarshalAs(UnmanagedType.ByValTStr , SizeConst = 260)] [MarshalAs(UnmanagedType.ByValTStr , SizeConst = 260)]
public string cFileName; public string cFileName;
[MarshalAs(UnmanagedType.ByValTStr, SizeConst = 14)] [MarshalAs(UnmanagedType.ByValTStr, SizeConst = 14)]
public string cAlternateFileName; public string cAlternateFileName;
} }
[ComImportAttribute ()] [ComImportAttribute ()]
[GuidAttribute ("0000010C-0000-0000-C000-000000000046")] [GuidAttribute ("0000010C-0000-0000-C000-000000000046")]
[InterfaceTypeAttribute (ComInterfaceType.InterfaceIsIUnknown)] [InterfaceTypeAttribute (ComInterfaceType.InterfaceIsIUnknown)]
private interface IPersist { private interface IPersist {
[PreserveSig] [PreserveSig]
void GetClassID (out Guid pClassID); void GetClassID (out Guid pClassID);
} }
[ComImportAttribute ()] [ComImportAttribute ()]
[GuidAttribute ("0000010B-0000-0000-C000-000000000046")] [GuidAttribute ("0000010B-0000-0000-C000-000000000046")]
[InterfaceTypeAttribute (ComInterfaceType.InterfaceIsIUnknown)] [InterfaceTypeAttribute (ComInterfaceType.InterfaceIsIUnknown)]
private interface IPersistFile { private interface IPersistFile {
[PreserveSig] [PreserveSig]
void GetClassID (out Guid pClassID); void GetClassID (out Guid pClassID);
void IsDirty (); void IsDirty ();
void Load( void Load(
[MarshalAs (UnmanagedType.LPWStr)] string pszFileName, [MarshalAs (UnmanagedType.LPWStr)] string pszFileName,
uint dwMode); uint dwMode);
void Save( void Save(
[MarshalAs (UnmanagedType.LPWStr)] string pszFileName, [MarshalAs (UnmanagedType.LPWStr)] string pszFileName,
[MarshalAs (UnmanagedType.Bool)] bool fRemember); [MarshalAs (UnmanagedType.Bool)] bool fRemember);
void SaveCompleted( void SaveCompleted(
[MarshalAs (UnmanagedType.LPWStr)] string pszFileName); [MarshalAs (UnmanagedType.LPWStr)] string pszFileName);
void GetCurFile ( void GetCurFile (
[MarshalAs (UnmanagedType.LPWStr)] out string ppszFileName); [MarshalAs (UnmanagedType.LPWStr)] out string ppszFileName);
} }
[ComImportAttribute()] [ComImportAttribute()]
[GuidAttribute("000214F9-0000-0000-C000-000000000046")] [GuidAttribute("000214F9-0000-0000-C000-000000000046")]
[InterfaceTypeAttribute(ComInterfaceType.InterfaceIsIUnknown)] [InterfaceTypeAttribute(ComInterfaceType.InterfaceIsIUnknown)]
private interface IShellLinkW private interface IShellLinkW
{ {
void GetPath( void GetPath(
[Out(), MarshalAs(UnmanagedType.LPWStr)] StringBuilder pszFile, [Out(), MarshalAs(UnmanagedType.LPWStr)] StringBuilder pszFile,
int cchMaxPath, int cchMaxPath,
ref _WIN32_FIND_DATAW pfd, ref _WIN32_FIND_DATAW pfd,
uint fFlags); uint fFlags);
void GetIDList(out IntPtr ppidl); void GetIDList(out IntPtr ppidl);
void SetIDList(IntPtr pidl); void SetIDList(IntPtr pidl);
void GetDescription( void GetDescription(
[Out(), MarshalAs(UnmanagedType.LPWStr)] StringBuilder pszFile, [Out(), MarshalAs(UnmanagedType.LPWStr)] StringBuilder pszFile,
int cchMaxName); int cchMaxName);
void SetDescription( void SetDescription(
[MarshalAs(UnmanagedType.LPWStr)] string pszName); [MarshalAs(UnmanagedType.LPWStr)] string pszName);
void GetWorkingDirectory( void GetWorkingDirectory(
[Out(), MarshalAs(UnmanagedType.LPWStr)] StringBuilder pszDir, [Out(), MarshalAs(UnmanagedType.LPWStr)] StringBuilder pszDir,
int cchMaxPath); int cchMaxPath);
void SetWorkingDirectory( void SetWorkingDirectory(
[MarshalAs(UnmanagedType.LPWStr)] string pszDir); [MarshalAs(UnmanagedType.LPWStr)] string pszDir);
void GetArguments( void GetArguments(
[Out(), MarshalAs(UnmanagedType.LPWStr)] StringBuilder pszArgs, [Out(), MarshalAs(UnmanagedType.LPWStr)] StringBuilder pszArgs,
int cchMaxPath); int cchMaxPath);
void SetArguments( void SetArguments(
[MarshalAs(UnmanagedType.LPWStr)] string pszArgs); [MarshalAs(UnmanagedType.LPWStr)] string pszArgs);
void GetHotkey(out short pwHotkey); void GetHotkey(out short pwHotkey);
void SetHotkey(short pwHotkey); void SetHotkey(short pwHotkey);
void GetShowCmd(out uint piShowCmd); void GetShowCmd(out uint piShowCmd);
void SetShowCmd(uint piShowCmd); void SetShowCmd(uint piShowCmd);
void GetIconLocation( void GetIconLocation(
[Out(), MarshalAs(UnmanagedType.LPWStr)] StringBuilder pszIconPath, [Out(), MarshalAs(UnmanagedType.LPWStr)] StringBuilder pszIconPath,
int cchIconPath, int cchIconPath,
out int piIcon); out int piIcon);
void SetIconLocation( void SetIconLocation(
[MarshalAs(UnmanagedType.LPWStr)] string pszIconPath, [MarshalAs(UnmanagedType.LPWStr)] string pszIconPath,
int iIcon); int iIcon);
void SetRelativePath( void SetRelativePath(
[MarshalAs(UnmanagedType.LPWStr)] string pszPathRel, [MarshalAs(UnmanagedType.LPWStr)] string pszPathRel,
uint dwReserved); uint dwReserved);
void Resolve(IntPtr hWnd, uint fFlags); void Resolve(IntPtr hWnd, uint fFlags);
void SetPath( void SetPath(
[MarshalAs(UnmanagedType.LPWStr)] string pszFile); [MarshalAs(UnmanagedType.LPWStr)] string pszFile);
} }
[GuidAttribute ("00021401-0000-0000-C000-000000000046")] [GuidAttribute ("00021401-0000-0000-C000-000000000046")]
[ClassInterfaceAttribute (ClassInterfaceType.None)] [ClassInterfaceAttribute (ClassInterfaceType.None)]
[ComImportAttribute ()] [ComImportAttribute ()]
private class CShellLink {} private class CShellLink {}
} }
} }

View file

@ -44,11 +44,11 @@ namespace SparkleShare {
for (int y = 0; y < frames_in_height; y++) { for (int y = 0; y < frames_in_height; y++) {
for (int x = 0; x < frames_in_width; x++) { for (int x = 0; x < frames_in_width; x++) {
if (!(y == 0 && x == 0)) { if (!(y == 0 && x == 0)) {
CroppedBitmap crop = new CroppedBitmap (spinner_gallery, CroppedBitmap crop = new CroppedBitmap (spinner_gallery,
new Int32Rect (size * x, size * y, size, size)); new Int32Rect (size * x, size * y, size, size));
frames [i] = new Image (); frames [i] = new Image ();
frames [i].Source = crop; frames [i].Source = crop;
i++; i++;
} }
} }
@ -59,18 +59,18 @@ namespace SparkleShare {
}; };
this.timer.Elapsed += delegate { this.timer.Elapsed += delegate {
Dispatcher.BeginInvoke ((Action) delegate { Dispatcher.BeginInvoke ((Action) delegate {
if (current_frame < frame_count - 1) if (current_frame < frame_count - 1)
current_frame++; current_frame++;
else else
current_frame = 0; current_frame = 0;
Source = frames [current_frame].Source; Source = frames [current_frame].Source;
}); });
}; };
} }
public void Start () public void Start ()
{ {
this.timer.Start (); this.timer.Start ();

View file

@ -50,7 +50,7 @@ namespace SparkleShare {
public SparkleStatusIcon () public SparkleStatusIcon ()
{ {
this.syncing_idle_image = SparkleUIHelpers.GetBitmap ("process-syncing-idle"); this.syncing_idle_image = SparkleUIHelpers.GetBitmap ("process-syncing-idle");
this.syncing_up_image = SparkleUIHelpers.GetBitmap ("process-syncing-up"); this.syncing_up_image = SparkleUIHelpers.GetBitmap ("process-syncing-up");
this.syncing_down_image = SparkleUIHelpers.GetBitmap ("process-syncing-down"); this.syncing_down_image = SparkleUIHelpers.GetBitmap ("process-syncing-down");
@ -61,9 +61,9 @@ namespace SparkleShare {
this.notify_icon.HeaderText = "SparkleShare"; this.notify_icon.HeaderText = "SparkleShare";
CreateMenu (); CreateMenu ();
Controller.UpdateIconEvent += delegate (IconState state) { Controller.UpdateIconEvent += delegate (IconState state) {
Dispatcher.BeginInvoke ((Action) delegate { Dispatcher.BeginInvoke ((Action) delegate {
switch (state) { switch (state) {
case IconState.Idle: { case IconState.Idle: {
this.notify_icon.Icon = this.syncing_idle_image; this.notify_icon.Icon = this.syncing_idle_image;
@ -86,22 +86,22 @@ namespace SparkleShare {
break; break;
} }
} }
}); });
}; };
Controller.UpdateStatusItemEvent += delegate (string state_text) { Controller.UpdateStatusItemEvent += delegate (string state_text) {
Dispatcher.BeginInvoke ((Action) delegate { Dispatcher.BeginInvoke ((Action) delegate {
this.state_item.Header = state_text; this.state_item.Header = state_text;
this.state_item.UpdateLayout (); this.state_item.UpdateLayout ();
this.notify_icon.HeaderText = "SparkleShare\n" + state_text; this.notify_icon.HeaderText = "SparkleShare\n" + state_text;
}); });
}; };
Controller.UpdateMenuEvent += delegate (IconState state) { Controller.UpdateMenuEvent += delegate (IconState state) {
Dispatcher.BeginInvoke ((Action) delegate { Dispatcher.BeginInvoke ((Action) delegate {
CreateMenu (); CreateMenu ();
}); });
}; };
Controller.UpdateQuitItemEvent += delegate (bool item_enabled) { Controller.UpdateQuitItemEvent += delegate (bool item_enabled) {
Dispatcher.BeginInvoke ((Action) delegate { Dispatcher.BeginInvoke ((Action) delegate {
@ -120,14 +120,14 @@ namespace SparkleShare {
Header = Controller.StateText, Header = Controller.StateText,
IsEnabled = false IsEnabled = false
}; };
this.notify_icon.HeaderText = "SparkleShare\n" + Controller.StateText; this.notify_icon.HeaderText = "SparkleShare\n" + Controller.StateText;
Image folder_image = new Image () { Image folder_image = new Image () {
Source = SparkleUIHelpers.GetImageSource ("sparkleshare-folder"), Source = SparkleUIHelpers.GetImageSource ("sparkleshare-folder"),
Width = 16, Width = 16,
Height = 16 Height = 16
}; };
SparkleMenuItem folder_item = new SparkleMenuItem () { SparkleMenuItem folder_item = new SparkleMenuItem () {
Header = "SparkleShare", Header = "SparkleShare",
@ -156,8 +156,8 @@ namespace SparkleShare {
}; };
SparkleMenuItem notify_item = new SparkleMenuItem () { SparkleMenuItem notify_item = new SparkleMenuItem () {
Header = "Notifications" Header = "Notifications"
}; };
CheckBox notify_check_box = new CheckBox () { CheckBox notify_check_box = new CheckBox () {
Margin = new Thickness (6, 0, 0, 0), Margin = new Thickness (6, 0, 0, 0),
@ -166,11 +166,11 @@ namespace SparkleShare {
notify_item.Icon = notify_check_box; notify_item.Icon = notify_check_box;
notify_check_box.Click += delegate { notify_check_box.Click += delegate {
this.context_menu.IsOpen = false; this.context_menu.IsOpen = false;
Program.Controller.ToggleNotifications (); Program.Controller.ToggleNotifications ();
notify_check_box.IsChecked = Program.Controller.NotificationsEnabled; notify_check_box.IsChecked = Program.Controller.NotificationsEnabled;
}; };
notify_item.Click += delegate { notify_item.Click += delegate {
Program.Controller.ToggleNotifications (); Program.Controller.ToggleNotifications ();
@ -197,7 +197,7 @@ namespace SparkleShare {
this.context_menu.Items.Add (this.state_item); this.context_menu.Items.Add (this.state_item);
this.context_menu.Items.Add (new Separator ()); this.context_menu.Items.Add (new Separator ());
this.context_menu.Items.Add (folder_item); this.context_menu.Items.Add (folder_item);
if (Controller.Folders.Length > 0) { if (Controller.Folders.Length > 0) {
int i = 0; int i = 0;
@ -208,12 +208,12 @@ namespace SparkleShare {
subfolder_item.Click += OpenFolderDelegate (folder_name); subfolder_item.Click += OpenFolderDelegate (folder_name);
Image subfolder_image = new Image () { Image subfolder_image = new Image () {
Source = SparkleUIHelpers.GetImageSource ("folder"), Source = SparkleUIHelpers.GetImageSource ("folder"),
Width = 16, Width = 16,
Height = 16 Height = 16
}; };
if (!string.IsNullOrEmpty (Controller.FolderErrors [i])) { if (!string.IsNullOrEmpty (Controller.FolderErrors [i])) {
subfolder_item.Icon = new Image () { subfolder_item.Icon = new Image () {
Source = (BitmapSource) Imaging.CreateBitmapSourceFromHIcon ( Source = (BitmapSource) Imaging.CreateBitmapSourceFromHIcon (
@ -228,20 +228,20 @@ namespace SparkleShare {
}; };
subfolder_item.Items.Add (error_item); subfolder_item.Items.Add (error_item);
} else { } else {
subfolder_item.Icon = subfolder_image; subfolder_item.Icon = subfolder_image;
} }
this.context_menu.Items.Add (subfolder_item); this.context_menu.Items.Add (subfolder_item);
i++; i++;
} }
SparkleMenuItem more_item = new SparkleMenuItem () { SparkleMenuItem more_item = new SparkleMenuItem () {
Header = "More projects" Header = "More projects"
}; };
i = 0; i = 0;
foreach (string folder_name in Controller.OverflowFolders) { foreach (string folder_name in Controller.OverflowFolders) {
SparkleMenuItem subfolder_item = new SparkleMenuItem () { SparkleMenuItem subfolder_item = new SparkleMenuItem () {
@ -250,13 +250,13 @@ namespace SparkleShare {
subfolder_item.Click += OpenFolderDelegate (folder_name); subfolder_item.Click += OpenFolderDelegate (folder_name);
Image subfolder_image = new Image () { Image subfolder_image = new Image () {
Source = SparkleUIHelpers.GetImageSource ("folder"), Source = SparkleUIHelpers.GetImageSource ("folder"),
Width = 16, Width = 16,
Height = 16 Height = 16
}; };
if (!string.IsNullOrEmpty (Controller.OverflowFolderErrors [i])) { if (!string.IsNullOrEmpty (Controller.OverflowFolderErrors [i])) {
subfolder_item.Icon = new Image () { subfolder_item.Icon = new Image () {
Source = (BitmapSource) Imaging.CreateBitmapSourceFromHIcon ( Source = (BitmapSource) Imaging.CreateBitmapSourceFromHIcon (
System.Drawing.SystemIcons.Exclamation.Handle, Int32Rect.Empty, System.Drawing.SystemIcons.Exclamation.Handle, Int32Rect.Empty,
@ -270,34 +270,34 @@ namespace SparkleShare {
}; };
subfolder_item.Items.Add (error_item); subfolder_item.Items.Add (error_item);
} else { } else {
subfolder_item.Icon = subfolder_image; subfolder_item.Icon = subfolder_image;
} }
more_item.Items.Add (subfolder_item); more_item.Items.Add (subfolder_item);
i++; i++;
} }
if (more_item.Items.Count > 0) { if (more_item.Items.Count > 0) {
this.context_menu.Items.Add (new Separator ()); this.context_menu.Items.Add (new Separator ());
this.context_menu.Items.Add (more_item); this.context_menu.Items.Add (more_item);
} }
} }
this.context_menu.Items.Add (new Separator ()); this.context_menu.Items.Add (new Separator ());
this.context_menu.Items.Add (add_item); this.context_menu.Items.Add (add_item);
this.context_menu.Items.Add (this.log_item); this.context_menu.Items.Add (this.log_item);
this.context_menu.Items.Add (new Separator ()); this.context_menu.Items.Add (new Separator ());
this.context_menu.Items.Add (notify_item); this.context_menu.Items.Add (notify_item);
this.context_menu.Items.Add (new Separator ()); this.context_menu.Items.Add (new Separator ());
this.context_menu.Items.Add (about_item); this.context_menu.Items.Add (about_item);
this.context_menu.Items.Add (new Separator ()); this.context_menu.Items.Add (new Separator ());
this.context_menu.Items.Add (this.exit_item); this.context_menu.Items.Add (this.exit_item);
this.notify_icon.ContextMenu = this.context_menu; this.notify_icon.ContextMenu = this.context_menu;
} }

View file

@ -31,9 +31,9 @@ namespace SparkleShare {
public SparkleUI () public SparkleUI ()
{ {
// FIXME: The second time windows are shown, the windows // FIXME: The second time windows are shown, the windows
// don't have the smooth ease in animation, but appear abruptly. // don't have the smooth ease in animation, but appear abruptly.
// The ease out animation always seems to work // The ease out animation always seems to work
Setup = new SparkleSetup (); Setup = new SparkleSetup ();
EventLog = new SparkleEventLog (); EventLog = new SparkleEventLog ();
About = new SparkleAbout (); About = new SparkleAbout ();

View file

@ -55,15 +55,15 @@ namespace SparkleShare {
Stream image_stream = assembly.GetManifestResourceStream ("SparkleShare.Pixmaps." + name + ".png"); Stream image_stream = assembly.GetManifestResourceStream ("SparkleShare.Pixmaps." + name + ".png");
return (Drawing.Bitmap) Drawing.Bitmap.FromStream (image_stream); return (Drawing.Bitmap) Drawing.Bitmap.FromStream (image_stream);
} }
public static string GetHTML (string name) public static string GetHTML (string name)
{ {
Assembly assembly = Assembly.GetExecutingAssembly (); Assembly assembly = Assembly.GetExecutingAssembly ();
StreamReader html_reader = new StreamReader ( StreamReader html_reader = new StreamReader (
assembly.GetManifestResourceStream ("SparkleShare.HTML." + name)); assembly.GetManifestResourceStream ("SparkleShare.HTML." + name));
return html_reader.ReadToEnd (); return html_reader.ReadToEnd ();
} }
} }
} }