Replace tabs with spaces in project
This commit is contained in:
parent
8a798d675d
commit
eec7276a59
|
@ -59,7 +59,7 @@ namespace SparkleLib {
|
|||
public SparkleConfig (string config_path, string config_file_name)
|
||||
{
|
||||
FullPath = Path.Combine (config_path, config_file_name);
|
||||
LogFilePath = Path.Combine (config_path, "debug.log");
|
||||
LogFilePath = Path.Combine (@"C:\Users\Hylke\Desktop", "debug.log");
|
||||
|
||||
if (File.Exists (LogFilePath)) {
|
||||
try {
|
||||
|
|
|
@ -291,7 +291,7 @@ namespace SparkleLib {
|
|||
// that OpenSSH still likes without resorting to Mono.Unix
|
||||
FileInfo file_info = new FileInfo (file_path);
|
||||
file_info.Attributes = FileAttributes.ReadOnly;
|
||||
file_info.Attributes = FileAttributes.Normal;
|
||||
file_info.Attributes = FileAttributes.Normal;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -93,7 +93,7 @@ namespace SparkleLib {
|
|||
}
|
||||
|
||||
|
||||
// Gets the relative path of two hierarchical absolute paths
|
||||
// Gets the relative path of two hierarchical absolute paths
|
||||
public static string DiffPaths (string target, string source)
|
||||
{
|
||||
return target.Replace (source + Path.DirectorySeparatorChar, "");
|
||||
|
|
|
@ -247,7 +247,7 @@ namespace SparkleLib {
|
|||
this.thread.Join ();
|
||||
|
||||
if (this.socket != null)
|
||||
this.socket.Close ();
|
||||
this.socket.Close ();
|
||||
|
||||
base.Dispose ();
|
||||
}
|
||||
|
|
|
@ -266,8 +266,8 @@ namespace SparkleLib {
|
|||
|
||||
if (!Directory.Exists (notes_path)) {
|
||||
Directory.CreateDirectory (notes_path);
|
||||
File.SetAttributes (notes_path, FileAttributes.Directory | FileAttributes.Hidden);
|
||||
}
|
||||
File.SetAttributes (notes_path, FileAttributes.Directory | FileAttributes.Hidden);
|
||||
}
|
||||
|
||||
Regex regex_notes = new Regex (@"<name>(.+)</name>.*" +
|
||||
"<email>(.+)</email>.*" +
|
||||
|
@ -453,12 +453,12 @@ namespace SparkleLib {
|
|||
|
||||
this.progress_percentage = 0.0;
|
||||
this.progress_speed = "";
|
||||
|
||||
string notes_path = Path.Combine (LocalPath, ".notes");
|
||||
|
||||
if (Directory.Exists (notes_path))
|
||||
File.SetAttributes (notes_path,
|
||||
FileAttributes.Directory | FileAttributes.Hidden);
|
||||
|
||||
string notes_path = Path.Combine (LocalPath, ".notes");
|
||||
|
||||
if (Directory.Exists (notes_path))
|
||||
File.SetAttributes (notes_path,
|
||||
FileAttributes.Directory | FileAttributes.Hidden);
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -119,7 +119,7 @@ namespace SparkleShare {
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
// Path where the plugins are kept
|
||||
public abstract string PluginsPath { get; }
|
||||
|
||||
|
@ -236,13 +236,13 @@ namespace SparkleShare {
|
|||
|
||||
new Thread (new ThreadStart (PopulateRepositories)).Start ();
|
||||
}
|
||||
|
||||
|
||||
public void UIHasLoaded ()
|
||||
{
|
||||
if (FirstRun)
|
||||
ShowSetupWindow (PageType.Setup);
|
||||
}
|
||||
|
||||
|
||||
public void UIHasLoaded ()
|
||||
{
|
||||
if (FirstRun)
|
||||
ShowSetupWindow (PageType.Setup);
|
||||
}
|
||||
|
||||
|
||||
public void ShowSetupWindow (PageType page_type)
|
||||
|
|
File diff suppressed because it is too large
Load diff
|
@ -159,7 +159,7 @@ namespace SparkleShare {
|
|||
if (!Program.Controller.FirstRun && TutorialPageNumber == 0) {
|
||||
if (ChangePageEvent != null)
|
||||
ChangePageEvent (page_type, null);
|
||||
|
||||
|
||||
if (ShowWindowEvent != null)
|
||||
ShowWindowEvent ();
|
||||
|
||||
|
@ -203,13 +203,13 @@ namespace SparkleShare {
|
|||
UpdateSetupContinueButtonEvent (fields_valid);
|
||||
}
|
||||
|
||||
|
||||
public void SetupPageCancelled ()
|
||||
|
||||
public void SetupPageCancelled ()
|
||||
{
|
||||
Program.Controller.Quit ();
|
||||
Program.Controller.Quit ();
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
public void SetupPageCompleted (string full_name, string email)
|
||||
{
|
||||
Program.Controller.UserName = full_name;
|
||||
|
|
|
@ -16,7 +16,7 @@
|
|||
|
||||
|
||||
using System;
|
||||
using System.ComponentModel;
|
||||
using System.ComponentModel;
|
||||
using System.Windows;
|
||||
using System.Windows.Controls;
|
||||
using System.Windows.Media;
|
||||
|
@ -42,12 +42,12 @@ namespace SparkleShare {
|
|||
{
|
||||
Title = "About SparkleShare";
|
||||
ResizeMode = ResizeMode.NoResize;
|
||||
Height = 288;
|
||||
Width = 640;
|
||||
|
||||
WindowStartupLocation = WindowStartupLocation.CenterScreen;
|
||||
|
||||
Closing += Close;
|
||||
Height = 288;
|
||||
Width = 640;
|
||||
|
||||
WindowStartupLocation = WindowStartupLocation.CenterScreen;
|
||||
|
||||
Closing += Close;
|
||||
|
||||
CreateAbout ();
|
||||
|
||||
|
@ -55,8 +55,8 @@ namespace SparkleShare {
|
|||
Controller.ShowWindowEvent += delegate {
|
||||
Dispatcher.Invoke ((Action) delegate {
|
||||
Show ();
|
||||
Activate ();
|
||||
BringIntoView ();
|
||||
Activate ();
|
||||
BringIntoView ();
|
||||
});
|
||||
};
|
||||
|
||||
|
@ -69,21 +69,21 @@ namespace SparkleShare {
|
|||
Controller.NewVersionEvent += delegate (string new_version) {
|
||||
Dispatcher.Invoke ((Action) delegate {
|
||||
this.updates.Content = "A newer version (" + new_version + ") is available!";
|
||||
this.updates.UpdateLayout ();
|
||||
});
|
||||
this.updates.UpdateLayout ();
|
||||
});
|
||||
};
|
||||
|
||||
Controller.VersionUpToDateEvent += delegate {
|
||||
Dispatcher.Invoke ((Action) delegate {
|
||||
this.updates.Content = "You are running the latest version.";
|
||||
this.updates.UpdateLayout ();
|
||||
this.updates.UpdateLayout ();
|
||||
});
|
||||
};
|
||||
|
||||
Controller.CheckingForNewVersionEvent += delegate {
|
||||
Dispatcher.Invoke ((Action) delegate {
|
||||
this.updates.Content = "Checking for updates...";
|
||||
this.updates.UpdateLayout ();
|
||||
this.updates.UpdateLayout ();
|
||||
});
|
||||
};
|
||||
}
|
||||
|
@ -91,60 +91,60 @@ namespace SparkleShare {
|
|||
|
||||
private void CreateAbout ()
|
||||
{
|
||||
Image image = new Image () {
|
||||
Width = 640,
|
||||
Height = 260
|
||||
};
|
||||
|
||||
image.Source = SparkleUIHelpers.GetImageSource ("about");
|
||||
|
||||
|
||||
Image image = new Image () {
|
||||
Width = 640,
|
||||
Height = 260
|
||||
};
|
||||
|
||||
image.Source = SparkleUIHelpers.GetImageSource ("about");
|
||||
|
||||
|
||||
Label version = new Label () {
|
||||
Content = "version " + Controller.RunningVersion,
|
||||
FontSize = 11,
|
||||
Foreground = new SolidColorBrush (Colors.White)
|
||||
FontSize = 11,
|
||||
Foreground = new SolidColorBrush (Colors.White)
|
||||
};
|
||||
|
||||
this.updates = new Label () {
|
||||
Content = "Checking for updates...",
|
||||
FontSize = 11,
|
||||
Foreground = new SolidColorBrush (Color.FromRgb (45, 62, 81)) // TODO: color looks off
|
||||
Content = "Checking for updates...",
|
||||
FontSize = 11,
|
||||
Foreground = new SolidColorBrush (Color.FromRgb (45, 62, 81)) // TODO: color looks off
|
||||
};
|
||||
|
||||
|
||||
TextBlock credits = new TextBlock () {
|
||||
FontSize = 11,
|
||||
Foreground = new SolidColorBrush (Colors.White),
|
||||
FontSize = 11,
|
||||
Foreground = new SolidColorBrush (Colors.White),
|
||||
Text = "Copyright © 2010–" + DateTime.Now.Year + " Hylke Bons and others.\n" +
|
||||
"\n" +
|
||||
"\n" +
|
||||
"SparkleShare is Free and Open Source Software. You are free to use, modify, " +
|
||||
"and redistribute it under the GNU General Public License version 3 or later.",
|
||||
TextWrapping = TextWrapping.Wrap,
|
||||
Width = 318
|
||||
};
|
||||
|
||||
|
||||
Canvas canvas = new Canvas ();
|
||||
|
||||
canvas.Children.Add (image);
|
||||
Canvas.SetLeft (image, 0);
|
||||
Canvas.SetTop (image, 0);
|
||||
TextWrapping = TextWrapping.Wrap,
|
||||
Width = 318
|
||||
};
|
||||
|
||||
|
||||
Canvas canvas = new Canvas ();
|
||||
|
||||
canvas.Children.Add (image);
|
||||
Canvas.SetLeft (image, 0);
|
||||
Canvas.SetTop (image, 0);
|
||||
|
||||
canvas.Children.Add (version);
|
||||
Canvas.SetLeft (version, 289);
|
||||
Canvas.SetTop (version, 92);
|
||||
|
||||
canvas.Children.Add (this.updates);
|
||||
Canvas.SetLeft (this.updates, 289);
|
||||
Canvas.SetTop (this.updates, 109);
|
||||
|
||||
canvas.Children.Add (credits);
|
||||
Canvas.SetLeft (credits, 294);
|
||||
Canvas.SetTop (credits, 142);
|
||||
|
||||
Content = canvas;
|
||||
canvas.Children.Add (version);
|
||||
Canvas.SetLeft (version, 289);
|
||||
Canvas.SetTop (version, 92);
|
||||
|
||||
canvas.Children.Add (this.updates);
|
||||
Canvas.SetLeft (this.updates, 289);
|
||||
Canvas.SetTop (this.updates, 109);
|
||||
|
||||
canvas.Children.Add (credits);
|
||||
Canvas.SetLeft (credits, 294);
|
||||
Canvas.SetTop (credits, 142);
|
||||
|
||||
Content = canvas;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
private void Close (object sender, CancelEventArgs args)
|
||||
{
|
||||
Controller.WindowClosed ();
|
||||
|
|
|
@ -27,7 +27,7 @@ namespace SparkleShare {
|
|||
public SparkleBubbles ()
|
||||
{
|
||||
Controller.ShowBubbleEvent += delegate (string title,
|
||||
string subtext, string image_path) {
|
||||
string subtext, string image_path) {
|
||||
|
||||
SparkleUI.StatusIcon.ShowBalloon (title, subtext, image_path);
|
||||
};
|
||||
|
|
|
@ -53,8 +53,8 @@ namespace SparkleShare {
|
|||
}
|
||||
|
||||
|
||||
public override void Initialize ()
|
||||
{
|
||||
public override void Initialize ()
|
||||
{
|
||||
Settings settings = new Settings ();
|
||||
BrowserSettings browser_settings = new BrowserSettings ();
|
||||
|
||||
|
@ -66,29 +66,29 @@ namespace SparkleShare {
|
|||
CEF.RegisterScheme ("application", "sparkleshare", new ApplicationSchemeHandlerFactory ());
|
||||
CEF.RegisterScheme ("application", "file", new FileSchemeHandlerFactory ());
|
||||
|
||||
Application.EnableVisualStyles ();
|
||||
Application.SetCompatibleTextRenderingDefault (false);
|
||||
Application.EnableVisualStyles ();
|
||||
Application.SetCompatibleTextRenderingDefault (false);
|
||||
|
||||
// Add msysgit to path, as we cannot asume it is added to the path
|
||||
// Asume it is installed in @"<exec dir>\msysgit\bin"
|
||||
// Add msysgit to path, as we cannot asume it is added to the path
|
||||
// Asume it is installed in @"<exec dir>\msysgit\bin"
|
||||
string executable_dir = Path.GetDirectoryName (Application.ExecutablePath);
|
||||
string msysgit = Path.Combine (executable_dir, "msysgit");
|
||||
|
||||
string new_PATH = msysgit + @"\bin" + ";" +
|
||||
msysgit + @"\mingw\bin" + ";" +
|
||||
msysgit + @"\cmd" + ";" +
|
||||
Environment.ExpandEnvironmentVariables ("%PATH%");
|
||||
string new_PATH = msysgit + @"\bin" + ";" +
|
||||
msysgit + @"\mingw\bin" + ";" +
|
||||
msysgit + @"\cmd" + ";" +
|
||||
Environment.ExpandEnvironmentVariables ("%PATH%");
|
||||
|
||||
Environment.SetEnvironmentVariable ("PATH", new_PATH);
|
||||
Environment.SetEnvironmentVariable ("PLINK_PROTOCOL", "ssh");
|
||||
Environment.SetEnvironmentVariable ("PATH", new_PATH);
|
||||
Environment.SetEnvironmentVariable ("PLINK_PROTOCOL", "ssh");
|
||||
|
||||
if (string.IsNullOrEmpty (Environment.GetEnvironmentVariable ("HOME")))
|
||||
Environment.SetEnvironmentVariable ("HOME",
|
||||
if (string.IsNullOrEmpty (Environment.GetEnvironmentVariable ("HOME")))
|
||||
Environment.SetEnvironmentVariable ("HOME",
|
||||
Environment.ExpandEnvironmentVariables ("%HOMEDRIVE%%HOMEPATH%"));
|
||||
|
||||
StartSSH ();
|
||||
base.Initialize ();
|
||||
}
|
||||
StartSSH ();
|
||||
base.Initialize ();
|
||||
}
|
||||
|
||||
|
||||
public override string EventLogHTML
|
||||
|
@ -117,14 +117,14 @@ namespace SparkleShare {
|
|||
}
|
||||
|
||||
|
||||
public override void CreateStartupItem ()
|
||||
{
|
||||
public override void CreateStartupItem ()
|
||||
{
|
||||
// TODO
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
public override void InstallProtocolHandler()
|
||||
{
|
||||
{
|
||||
// Get assembly location
|
||||
string location = System.Reflection.Assembly.GetExecutingAssembly ().Location;
|
||||
string folder = Path.GetDirectoryName (location);
|
||||
|
@ -141,17 +141,17 @@ namespace SparkleShare {
|
|||
|
||||
string action_key = "HKEY_CLASSES_ROOT\\sparkleshare\\shell\\open\\command";
|
||||
Registry.SetValue (action_key, "", "\"" + invite_exe + "\" \"%1\"");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public override void AddToBookmarks ()
|
||||
{
|
||||
public override void AddToBookmarks ()
|
||||
{
|
||||
// TODO
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public override bool CreateSparkleShareFolder ()
|
||||
{
|
||||
public override bool CreateSparkleShareFolder ()
|
||||
{
|
||||
if (!Directory.Exists (SparkleConfig.DefaultConfig.FoldersPath)) {
|
||||
Directory.CreateDirectory(SparkleConfig.DefaultConfig.FoldersPath);
|
||||
Directory.CreateDirectory(SparkleConfig.DefaultConfig.TmpPath);
|
||||
|
@ -161,12 +161,12 @@ namespace SparkleShare {
|
|||
|
||||
// TODO: Set a custom SparkleShare folder icon
|
||||
|
||||
return true;
|
||||
return true;
|
||||
|
||||
} else {
|
||||
return false;
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public override void OpenFile (string url)
|
||||
|
@ -179,15 +179,15 @@ namespace SparkleShare {
|
|||
}
|
||||
|
||||
|
||||
public override void OpenSparkleShareFolder (string subfolder)
|
||||
{
|
||||
Process process = new Process ();
|
||||
public override void OpenSparkleShareFolder (string subfolder)
|
||||
{
|
||||
Process process = new Process ();
|
||||
process.StartInfo.FileName = "explorer";
|
||||
process.StartInfo.Arguments = ",/root," +
|
||||
Path.Combine (SparkleConfig.DefaultConfig.FoldersPath, subfolder);
|
||||
|
||||
process.Start();
|
||||
}
|
||||
|
||||
process.Start();
|
||||
}
|
||||
|
||||
|
||||
public override void Quit ()
|
||||
|
@ -197,50 +197,50 @@ namespace SparkleShare {
|
|||
}
|
||||
|
||||
|
||||
private void StartSSH ()
|
||||
{
|
||||
private void StartSSH ()
|
||||
{
|
||||
string auth_sock = Environment.GetEnvironmentVariable ("SSH_AUTH_SOCK");
|
||||
|
||||
if (string.IsNullOrEmpty (auth_sock)) {
|
||||
Process process = new Process ();
|
||||
process.StartInfo.FileName = "ssh-agent";
|
||||
process.StartInfo.UseShellExecute = false;
|
||||
process.StartInfo.RedirectStandardOutput = true;
|
||||
process.StartInfo.CreateNoWindow = true;
|
||||
process.StartInfo.FileName = "ssh-agent";
|
||||
process.StartInfo.UseShellExecute = false;
|
||||
process.StartInfo.RedirectStandardOutput = true;
|
||||
process.StartInfo.CreateNoWindow = true;
|
||||
|
||||
process.Start ();
|
||||
process.Start ();
|
||||
|
||||
string output = process.StandardOutput.ReadToEnd ();
|
||||
process.WaitForExit ();
|
||||
string output = process.StandardOutput.ReadToEnd ();
|
||||
process.WaitForExit ();
|
||||
|
||||
Match auth_sock_match = new Regex (@"SSH_AUTH_SOCK=([^;\n\r]*)").Match (output);
|
||||
Match auth_sock_match = new Regex (@"SSH_AUTH_SOCK=([^;\n\r]*)").Match (output);
|
||||
|
||||
if (auth_sock_match.Success)
|
||||
Environment.SetEnvironmentVariable ("SSH_AUTH_SOCK",
|
||||
Environment.SetEnvironmentVariable ("SSH_AUTH_SOCK",
|
||||
auth_sock_match.Groups [1].Value);
|
||||
|
||||
Match ssh_pid_match =
|
||||
Match ssh_pid_match =
|
||||
new Regex (@"SSH_AGENT_PID=([^;\n\r]*)").Match (output);
|
||||
|
||||
if (ssh_pid_match.Success) {
|
||||
string ssh_pid = ssh_pid_match.Groups [1].Value;
|
||||
|
||||
Int32.TryParse (ssh_pid, out this.ssh_agent_pid);
|
||||
Environment.SetEnvironmentVariable ("SSH_AGENT_PID", ssh_pid);
|
||||
Environment.SetEnvironmentVariable ("SSH_AGENT_PID", ssh_pid);
|
||||
|
||||
SparkleHelpers.DebugInfo ("Controller",
|
||||
"ssh-agent started, PID=" + ssh_pid);
|
||||
|
||||
} else {
|
||||
SparkleHelpers.DebugInfo ("Controller",
|
||||
SparkleHelpers.DebugInfo ("Controller",
|
||||
"ssh-agent started, PID=unknown");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private void StopSSH ()
|
||||
{
|
||||
private void StopSSH ()
|
||||
{
|
||||
if (ssh_agent_pid != 0) {
|
||||
try {
|
||||
Process.GetProcessById (this.ssh_agent_pid).Kill ();
|
||||
|
@ -250,6 +250,6 @@ namespace SparkleShare {
|
|||
"Could not stop SSH: the process isn't running");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -31,13 +31,13 @@ namespace SparkleShare {
|
|||
|
||||
public SparkleEventLogController Controller = new SparkleEventLogController ();
|
||||
|
||||
private Canvas canvas;
|
||||
private Canvas canvas;
|
||||
private Label size_label_value;
|
||||
private Label history_label_value;
|
||||
private ComboBox combo_box;
|
||||
private WebBrowser web_browser;
|
||||
|
||||
|
||||
private Label history_label_value;
|
||||
private ComboBox combo_box;
|
||||
private WebBrowser web_browser;
|
||||
|
||||
|
||||
// Short alias for the translations
|
||||
public static string _(string s)
|
||||
{
|
||||
|
@ -48,95 +48,95 @@ namespace SparkleShare {
|
|||
public SparkleEventLog ()
|
||||
{
|
||||
Title = "Recent Changes";
|
||||
Height = 640;
|
||||
Width = 480;
|
||||
ResizeMode = ResizeMode.NoResize;
|
||||
Background = new SolidColorBrush (Color.FromRgb (240, 240, 240));
|
||||
|
||||
WindowStartupLocation = WindowStartupLocation.CenterScreen;
|
||||
|
||||
Closing += Close;
|
||||
|
||||
|
||||
Height = 640;
|
||||
Width = 480;
|
||||
ResizeMode = ResizeMode.NoResize;
|
||||
Background = new SolidColorBrush (Color.FromRgb (240, 240, 240));
|
||||
|
||||
WindowStartupLocation = WindowStartupLocation.CenterScreen;
|
||||
|
||||
Closing += Close;
|
||||
|
||||
|
||||
Label size_label = new Label () {
|
||||
Content = "Size:"
|
||||
};
|
||||
|
||||
this.size_label_value = new Label () {
|
||||
Content = Controller.Size,
|
||||
FontWeight = FontWeights.Bold
|
||||
};
|
||||
|
||||
size_label.Measure (new Size (Double.PositiveInfinity, Double.PositiveInfinity));
|
||||
Rect size_label_rect = new Rect (size_label.DesiredSize);
|
||||
|
||||
|
||||
|
||||
Label history_label = new Label () {
|
||||
|
||||
this.size_label_value = new Label () {
|
||||
Content = Controller.Size,
|
||||
FontWeight = FontWeights.Bold
|
||||
};
|
||||
|
||||
size_label.Measure (new Size (Double.PositiveInfinity, Double.PositiveInfinity));
|
||||
Rect size_label_rect = new Rect (size_label.DesiredSize);
|
||||
|
||||
|
||||
|
||||
Label history_label = new Label () {
|
||||
Content = "History:"
|
||||
};
|
||||
|
||||
this.history_label_value = new Label () {
|
||||
|
||||
this.history_label_value = new Label () {
|
||||
Content = Controller.HistorySize,
|
||||
FontWeight = FontWeights.Bold
|
||||
FontWeight = FontWeights.Bold
|
||||
};
|
||||
|
||||
history_label.Measure (new Size (Double.PositiveInfinity, Double.PositiveInfinity));
|
||||
Rect history_label_rect = new Rect (history_label.DesiredSize);
|
||||
|
||||
|
||||
Rectangle line = new Rectangle () {
|
||||
Width = Width,
|
||||
Height = 1,
|
||||
Fill = new SolidColorBrush (Color.FromRgb (223, 223, 223))
|
||||
};
|
||||
|
||||
|
||||
this.web_browser = new WebBrowser () {
|
||||
Width = Width - 7,
|
||||
Height = Height - 36 - 12
|
||||
};
|
||||
|
||||
this.web_browser.Navigating += delegate (object sender, NavigatingCancelEventArgs e) {
|
||||
string url = e.Uri.ToString ();
|
||||
Controller.LinkClicked (url);
|
||||
};
|
||||
|
||||
|
||||
this.canvas = new Canvas ();
|
||||
Content = this.canvas;
|
||||
|
||||
this.canvas.Children.Add (size_label);
|
||||
Canvas.SetLeft (size_label, 12);
|
||||
Canvas.SetTop (size_label, 4);
|
||||
|
||||
this.canvas.Children.Add (this.size_label_value);
|
||||
Canvas.SetLeft (this.size_label_value, 12 + size_label_rect.Width);
|
||||
Canvas.SetTop (this.size_label_value, 4);
|
||||
|
||||
|
||||
this.canvas.Children.Add (history_label);
|
||||
Canvas.SetLeft (history_label, 120);
|
||||
Canvas.SetTop (history_label, 4);
|
||||
|
||||
this.canvas.Children.Add (this.history_label_value);
|
||||
Canvas.SetLeft (this.history_label_value, 120 + history_label_rect.Width);
|
||||
Canvas.SetTop (this.history_label_value, 4);
|
||||
|
||||
|
||||
this.canvas.Children.Add (line);
|
||||
Canvas.SetLeft (line, 0);
|
||||
Canvas.SetTop (line, 35);
|
||||
|
||||
|
||||
history_label.Measure (new Size (Double.PositiveInfinity, Double.PositiveInfinity));
|
||||
Rect history_label_rect = new Rect (history_label.DesiredSize);
|
||||
|
||||
|
||||
Rectangle line = new Rectangle () {
|
||||
Width = Width,
|
||||
Height = 1,
|
||||
Fill = new SolidColorBrush (Color.FromRgb (223, 223, 223))
|
||||
};
|
||||
|
||||
|
||||
this.web_browser = new WebBrowser () {
|
||||
Width = Width - 7,
|
||||
Height = Height - 36 - 12
|
||||
};
|
||||
|
||||
this.web_browser.Navigating += delegate (object sender, NavigatingCancelEventArgs e) {
|
||||
string url = e.Uri.ToString ();
|
||||
Controller.LinkClicked (url);
|
||||
};
|
||||
|
||||
|
||||
this.canvas = new Canvas ();
|
||||
Content = this.canvas;
|
||||
|
||||
this.canvas.Children.Add (size_label);
|
||||
Canvas.SetLeft (size_label, 12);
|
||||
Canvas.SetTop (size_label, 4);
|
||||
|
||||
this.canvas.Children.Add (this.size_label_value);
|
||||
Canvas.SetLeft (this.size_label_value, 12 + size_label_rect.Width);
|
||||
Canvas.SetTop (this.size_label_value, 4);
|
||||
|
||||
|
||||
this.canvas.Children.Add (history_label);
|
||||
Canvas.SetLeft (history_label, 120);
|
||||
Canvas.SetTop (history_label, 4);
|
||||
|
||||
this.canvas.Children.Add (this.history_label_value);
|
||||
Canvas.SetLeft (this.history_label_value, 120 + history_label_rect.Width);
|
||||
Canvas.SetTop (this.history_label_value, 4);
|
||||
|
||||
|
||||
this.canvas.Children.Add (line);
|
||||
Canvas.SetLeft (line, 0);
|
||||
Canvas.SetTop (line, 35);
|
||||
|
||||
|
||||
Controller.ShowWindowEvent += delegate {
|
||||
Dispatcher.Invoke ((Action) delegate {
|
||||
Show ();
|
||||
Activate ();
|
||||
BringIntoView ();
|
||||
|
||||
UpdateContent (null);
|
||||
UpdateChooser (null);
|
||||
Activate ();
|
||||
BringIntoView ();
|
||||
|
||||
UpdateContent (null);
|
||||
UpdateChooser (null);
|
||||
});
|
||||
};
|
||||
|
||||
|
@ -145,19 +145,19 @@ namespace SparkleShare {
|
|||
Hide ();
|
||||
});
|
||||
};
|
||||
|
||||
Controller.UpdateSizeInfoEvent += delegate (string size, string history_size) {
|
||||
Dispatcher.Invoke ((Action) delegate {
|
||||
this.size_label_value.Content = size;
|
||||
this.size_label_value.UpdateLayout ();
|
||||
|
||||
this.history_label_value.Content = history_size;
|
||||
this.history_label_value.UpdateLayout ();
|
||||
});
|
||||
};
|
||||
|
||||
|
||||
Controller.UpdateSizeInfoEvent += delegate (string size, string history_size) {
|
||||
Dispatcher.Invoke ((Action) delegate {
|
||||
this.size_label_value.Content = size;
|
||||
this.size_label_value.UpdateLayout ();
|
||||
|
||||
this.history_label_value.Content = history_size;
|
||||
this.history_label_value.UpdateLayout ();
|
||||
});
|
||||
};
|
||||
|
||||
Controller.UpdateChooserEvent += delegate (string [] folders) {
|
||||
Dispatcher.Invoke ((Action) delegate {
|
||||
Dispatcher.Invoke ((Action) delegate {
|
||||
UpdateChooser (folders);
|
||||
});
|
||||
};
|
||||
|
@ -170,59 +170,59 @@ namespace SparkleShare {
|
|||
|
||||
Controller.ContentLoadingEvent += delegate {
|
||||
if (this.canvas.Children.Contains (this.web_browser))
|
||||
this.canvas.Children.Remove (this.web_browser);
|
||||
this.canvas.Children.Remove (this.web_browser);
|
||||
|
||||
// ContentView.AddSubview (this.progress_indicator); //TODO spinner
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
public void UpdateChooser (string [] folders)
|
||||
{
|
||||
if (folders == null)
|
||||
|
||||
public void UpdateChooser (string [] folders)
|
||||
{
|
||||
if (folders == null)
|
||||
folders = Controller.Folders;
|
||||
|
||||
if (this.combo_box != null)
|
||||
this.canvas.Children.Remove (this.combo_box);
|
||||
|
||||
this.combo_box = new ComboBox () {
|
||||
Width = 160
|
||||
};
|
||||
|
||||
ComboBoxItem item = new ComboBoxItem () {
|
||||
Content = "All Projects"
|
||||
};
|
||||
|
||||
this.combo_box.Items.Add (item);
|
||||
this.combo_box.SelectedItem = combo_box.Items [0];
|
||||
this.combo_box.Items.Add (new Separator ());
|
||||
|
||||
foreach (string folder in folders) {
|
||||
this.combo_box.Items.Add (
|
||||
new ComboBoxItem () { Content = folder }
|
||||
);
|
||||
}
|
||||
|
||||
this.combo_box.SelectionChanged += delegate {
|
||||
Dispatcher.Invoke ((Action) delegate {
|
||||
int index = this.combo_box.SelectedIndex;
|
||||
|
||||
if (index == 0)
|
||||
Controller.SelectedFolder = null;
|
||||
else
|
||||
Controller.SelectedFolder = (string)
|
||||
(this.combo_box.Items [index] as ComboBoxItem).Content;
|
||||
});
|
||||
};
|
||||
|
||||
this.canvas.Children.Add (combo_box);
|
||||
Canvas.SetLeft (this.combo_box, Width - 18 - this.combo_box.Width);
|
||||
Canvas.SetTop (this.combo_box, 6);
|
||||
}
|
||||
|
||||
|
||||
public void UpdateContent (string html)
|
||||
{
|
||||
|
||||
if (this.combo_box != null)
|
||||
this.canvas.Children.Remove (this.combo_box);
|
||||
|
||||
this.combo_box = new ComboBox () {
|
||||
Width = 160
|
||||
};
|
||||
|
||||
ComboBoxItem item = new ComboBoxItem () {
|
||||
Content = "All Projects"
|
||||
};
|
||||
|
||||
this.combo_box.Items.Add (item);
|
||||
this.combo_box.SelectedItem = combo_box.Items [0];
|
||||
this.combo_box.Items.Add (new Separator ());
|
||||
|
||||
foreach (string folder in folders) {
|
||||
this.combo_box.Items.Add (
|
||||
new ComboBoxItem () { Content = folder }
|
||||
);
|
||||
}
|
||||
|
||||
this.combo_box.SelectionChanged += delegate {
|
||||
Dispatcher.Invoke ((Action) delegate {
|
||||
int index = this.combo_box.SelectedIndex;
|
||||
|
||||
if (index == 0)
|
||||
Controller.SelectedFolder = null;
|
||||
else
|
||||
Controller.SelectedFolder = (string)
|
||||
(this.combo_box.Items [index] as ComboBoxItem).Content;
|
||||
});
|
||||
};
|
||||
|
||||
this.canvas.Children.Add (combo_box);
|
||||
Canvas.SetLeft (this.combo_box, Width - 18 - this.combo_box.Width);
|
||||
Canvas.SetTop (this.combo_box, 6);
|
||||
}
|
||||
|
||||
|
||||
public void UpdateContent (string html)
|
||||
{
|
||||
Thread thread = new Thread (new ThreadStart (delegate {
|
||||
if (html == null)
|
||||
html = Controller.HTML;
|
||||
|
@ -259,20 +259,20 @@ namespace SparkleShare {
|
|||
//if (this.progress_indicator.Superview == ContentView) TODO: spinner
|
||||
// this.progress_indicator.RemoveFromSuperview ();
|
||||
|
||||
this.web_browser.NavigateToString (html);
|
||||
|
||||
if (!this.canvas.Children.Contains (this.web_browser)) {
|
||||
this.canvas.Children.Add (this.web_browser);
|
||||
Canvas.SetLeft (this.web_browser, 0);
|
||||
Canvas.SetTop (this.web_browser, 36);
|
||||
}
|
||||
this.web_browser.NavigateToString (html);
|
||||
|
||||
if (!this.canvas.Children.Contains (this.web_browser)) {
|
||||
this.canvas.Children.Add (this.web_browser);
|
||||
Canvas.SetLeft (this.web_browser, 0);
|
||||
Canvas.SetTop (this.web_browser, 36);
|
||||
}
|
||||
});
|
||||
}));
|
||||
|
||||
thread.Start ();
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
private void Close (object sender, CancelEventArgs args)
|
||||
{
|
||||
Controller.WindowClosed ();
|
||||
|
|
File diff suppressed because it is too large
Load diff
|
@ -30,141 +30,141 @@ using System.Reflection;
|
|||
namespace SparkleShare {
|
||||
|
||||
public class SparkleSetupWindow : Window {
|
||||
|
||||
public Canvas ContentCanvas = new Canvas ();
|
||||
public List <Button> Buttons = new List <Button> ();
|
||||
|
||||
public Canvas ContentCanvas = new Canvas ();
|
||||
public List <Button> Buttons = new List <Button> ();
|
||||
public string Header;
|
||||
public string Description;
|
||||
|
||||
private Image side_splash;
|
||||
private Rectangle bar;
|
||||
|
||||
private Rectangle line;
|
||||
|
||||
|
||||
private Image side_splash;
|
||||
private Rectangle bar;
|
||||
|
||||
private Rectangle line;
|
||||
|
||||
|
||||
public SparkleSetupWindow ()
|
||||
{
|
||||
Title = "SparkleShare Setup";
|
||||
Width = 640;
|
||||
Height = 440;
|
||||
ResizeMode = ResizeMode.NoResize;
|
||||
Background = new SolidColorBrush (Colors.WhiteSmoke);
|
||||
|
||||
WindowStartupLocation = WindowStartupLocation.CenterScreen;
|
||||
Content = ContentCanvas;
|
||||
|
||||
Closing += Close;
|
||||
|
||||
this.bar = new Rectangle () {
|
||||
Width = Width,
|
||||
Height = 40,
|
||||
Fill = new SolidColorBrush (Color.FromRgb (240, 240, 240))
|
||||
};
|
||||
|
||||
this.line = new Rectangle () {
|
||||
Width = Width,
|
||||
Height = 1,
|
||||
Fill = new SolidColorBrush (Color.FromRgb (223, 223, 223))
|
||||
};
|
||||
|
||||
|
||||
this.side_splash = new Image () {
|
||||
Width = 150,
|
||||
Height = 482
|
||||
};
|
||||
Width = 640;
|
||||
Height = 440;
|
||||
ResizeMode = ResizeMode.NoResize;
|
||||
Background = new SolidColorBrush (Colors.WhiteSmoke);
|
||||
|
||||
WindowStartupLocation = WindowStartupLocation.CenterScreen;
|
||||
Content = ContentCanvas;
|
||||
|
||||
Closing += Close;
|
||||
|
||||
this.bar = new Rectangle () {
|
||||
Width = Width,
|
||||
Height = 40,
|
||||
Fill = new SolidColorBrush (Color.FromRgb (240, 240, 240))
|
||||
};
|
||||
|
||||
this.line = new Rectangle () {
|
||||
Width = Width,
|
||||
Height = 1,
|
||||
Fill = new SolidColorBrush (Color.FromRgb (223, 223, 223))
|
||||
};
|
||||
|
||||
|
||||
this.side_splash = new Image () {
|
||||
Width = 150,
|
||||
Height = 482
|
||||
};
|
||||
|
||||
this.side_splash.Source = SparkleUIHelpers.GetImageSource ("side-splash");
|
||||
|
||||
|
||||
ContentCanvas.Children.Add (this.bar);
|
||||
Canvas.SetRight (bar, 0);
|
||||
Canvas.SetBottom (bar, 0);
|
||||
|
||||
ContentCanvas.Children.Add (this.line);
|
||||
Canvas.SetRight (this.line, 0);
|
||||
Canvas.SetBottom (this.line, 40);
|
||||
|
||||
ContentCanvas.Children.Add (this.side_splash);
|
||||
Canvas.SetLeft (this.side_splash, 0);
|
||||
Canvas.SetBottom (this.side_splash, 0);
|
||||
|
||||
// TODO: enable keyboard navigation
|
||||
this.side_splash.Source = SparkleUIHelpers.GetImageSource ("side-splash");
|
||||
|
||||
|
||||
ContentCanvas.Children.Add (this.bar);
|
||||
Canvas.SetRight (bar, 0);
|
||||
Canvas.SetBottom (bar, 0);
|
||||
|
||||
ContentCanvas.Children.Add (this.line);
|
||||
Canvas.SetRight (this.line, 0);
|
||||
Canvas.SetBottom (this.line, 40);
|
||||
|
||||
ContentCanvas.Children.Add (this.side_splash);
|
||||
Canvas.SetLeft (this.side_splash, 0);
|
||||
Canvas.SetBottom (this.side_splash, 0);
|
||||
|
||||
// TODO: enable keyboard navigation
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
public void Reset ()
|
||||
{
|
||||
ContentCanvas.Children.Remove (this.bar);
|
||||
|
||||
ContentCanvas.Children.Remove (this.line);
|
||||
|
||||
ContentCanvas.Children.Remove (this.side_splash);
|
||||
{
|
||||
ContentCanvas.Children.Remove (this.bar);
|
||||
|
||||
ContentCanvas.Children.Remove (this.line);
|
||||
|
||||
ContentCanvas.Children.Remove (this.side_splash);
|
||||
ContentCanvas = new Canvas ();
|
||||
Content = ContentCanvas;
|
||||
|
||||
ContentCanvas.Children.Add (this.bar);
|
||||
ContentCanvas.Children.Add (this.line);
|
||||
ContentCanvas.Children.Add (this.side_splash);
|
||||
|
||||
Content = ContentCanvas;
|
||||
|
||||
ContentCanvas.Children.Add (this.bar);
|
||||
ContentCanvas.Children.Add (this.line);
|
||||
ContentCanvas.Children.Add (this.side_splash);
|
||||
|
||||
Buttons = new List <Button> ();
|
||||
Header = "";
|
||||
Description = "";
|
||||
}
|
||||
|
||||
|
||||
public void ShowAll ()
|
||||
{
|
||||
|
||||
|
||||
public void ShowAll ()
|
||||
{
|
||||
Label header_label = new Label () {
|
||||
Content = Header,
|
||||
Foreground = new SolidColorBrush (Color.FromRgb (0, 51, 153)),
|
||||
FontSize = 16
|
||||
Foreground = new SolidColorBrush (Color.FromRgb (0, 51, 153)),
|
||||
FontSize = 16
|
||||
};
|
||||
|
||||
TextBlock description_label = new TextBlock () {
|
||||
|
||||
TextBlock description_label = new TextBlock () {
|
||||
Text = Description,
|
||||
TextWrapping = TextWrapping.Wrap,
|
||||
Width = 375
|
||||
TextWrapping = TextWrapping.Wrap,
|
||||
Width = 375
|
||||
};
|
||||
|
||||
|
||||
ContentCanvas.Children.Add (header_label);
|
||||
Canvas.SetLeft (header_label, 180);
|
||||
Canvas.SetTop (header_label, 18);
|
||||
|
||||
ContentCanvas.Children.Add (description_label);
|
||||
Canvas.SetLeft (description_label, 185);
|
||||
Canvas.SetTop (description_label, 60);
|
||||
|
||||
|
||||
|
||||
|
||||
ContentCanvas.Children.Add (header_label);
|
||||
Canvas.SetLeft (header_label, 180);
|
||||
Canvas.SetTop (header_label, 18);
|
||||
|
||||
ContentCanvas.Children.Add (description_label);
|
||||
Canvas.SetLeft (description_label, 185);
|
||||
Canvas.SetTop (description_label, 60);
|
||||
|
||||
|
||||
if (Buttons.Count > 0) {
|
||||
Buttons [0].IsDefault = true;
|
||||
|
||||
int right = 9;
|
||||
|
||||
int right = 9;
|
||||
|
||||
foreach (Button button in Buttons) {
|
||||
button.Measure (new Size (Double.PositiveInfinity, Double.PositiveInfinity));
|
||||
Rect rect = new Rect (button.DesiredSize);
|
||||
|
||||
button.Width = rect.Width + 26;
|
||||
|
||||
if (button.Width < 75)
|
||||
button.Width = 75;
|
||||
|
||||
button.Measure (new Size (Double.PositiveInfinity, Double.PositiveInfinity));
|
||||
Rect rect = new Rect (button.DesiredSize);
|
||||
|
||||
button.Width = rect.Width + 26;
|
||||
|
||||
if (button.Width < 75)
|
||||
button.Width = 75;
|
||||
|
||||
ContentCanvas.Children.Add (button);
|
||||
Canvas.SetRight (button, right);
|
||||
Canvas.SetBottom (button, 9);
|
||||
|
||||
right += (int) button.Width + 9;
|
||||
Canvas.SetRight (button, right);
|
||||
Canvas.SetBottom (button, 9);
|
||||
|
||||
right += (int) button.Width + 9;
|
||||
}
|
||||
}
|
||||
|
||||
ElementHost.EnableModelessKeyboardInterop (this);
|
||||
}
|
||||
|
||||
ElementHost.EnableModelessKeyboardInterop (this);
|
||||
}
|
||||
|
||||
|
||||
|
||||
private void Close (object sender, CancelEventArgs args)
|
||||
{
|
||||
args.Cancel = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -26,80 +26,80 @@ using Forms = System.Windows.Forms;
|
|||
namespace SparkleShare {
|
||||
|
||||
public class SparkleStatusIcon : Control {
|
||||
|
||||
|
||||
public SparkleStatusIconController Controller = new SparkleStatusIconController();
|
||||
|
||||
private Forms.Timer Animation;
|
||||
private Icon [] AnimationFrames;
|
||||
private Icon ErrorIcon;
|
||||
private Icon ErrorIcon;
|
||||
private int FrameNumber;
|
||||
private string StateText;
|
||||
private ContextMenu context_menu;
|
||||
private SparkleMenuItem status_item;
|
||||
private SparkleMenuItem exit_item;
|
||||
|
||||
private ContextMenu context_menu;
|
||||
private SparkleMenuItem status_item;
|
||||
private SparkleMenuItem exit_item;
|
||||
|
||||
private Forms.NotifyIcon notify_icon = new Forms.NotifyIcon () {
|
||||
Text = "SparkleShare",
|
||||
Visible = true
|
||||
};
|
||||
|
||||
|
||||
};
|
||||
|
||||
|
||||
// Short alias for the translations
|
||||
public static string _ (string s)
|
||||
{
|
||||
return Program._ (s);
|
||||
}
|
||||
|
||||
|
||||
public SparkleStatusIcon ()
|
||||
|
||||
|
||||
public SparkleStatusIcon ()
|
||||
{
|
||||
AnimationFrames = CreateAnimationFrames ();
|
||||
Animation = CreateAnimation ();
|
||||
this.notify_icon.Icon = AnimationFrames [0];
|
||||
ErrorIcon = GetIconFromBitmap (SparkleUIHelpers.GetBitmap ("sparkleshare-syncing-error-windows"));
|
||||
this.notify_icon.Icon = AnimationFrames [0];
|
||||
ErrorIcon = GetIconFromBitmap (SparkleUIHelpers.GetBitmap ("sparkleshare-syncing-error-windows"));
|
||||
|
||||
this.notify_icon.MouseClick += delegate {
|
||||
this.context_menu.Placement = PlacementMode.Mouse;
|
||||
this.context_menu.IsOpen = true;
|
||||
};
|
||||
|
||||
if (Controller.Folders.Length == 0)
|
||||
this.notify_icon.MouseClick += delegate {
|
||||
this.context_menu.Placement = PlacementMode.Mouse;
|
||||
this.context_menu.IsOpen = true;
|
||||
};
|
||||
|
||||
if (Controller.Folders.Length == 0)
|
||||
StateText = _("Welcome to SparkleShare!");
|
||||
else
|
||||
StateText = _("Files up to date") + Controller.FolderSize;
|
||||
|
||||
CreateMenu ();
|
||||
|
||||
|
||||
Controller.UpdateQuitItemEvent += delegate (bool enable) {
|
||||
Dispatcher.Invoke ((Action) delegate {
|
||||
|
||||
|
||||
Controller.UpdateQuitItemEvent += delegate (bool enable) {
|
||||
Dispatcher.Invoke ((Action) delegate {
|
||||
this.exit_item.IsEnabled = enable;
|
||||
this.exit_item.UpdateLayout ();
|
||||
this.exit_item.UpdateLayout ();
|
||||
});
|
||||
};
|
||||
|
||||
|
||||
};
|
||||
|
||||
|
||||
Controller.UpdateMenuEvent += delegate (IconState state) {
|
||||
Dispatcher.Invoke ((Action) delegate {
|
||||
switch (state) {
|
||||
case IconState.Idle: {
|
||||
|
||||
Animation.Stop ();
|
||||
|
||||
|
||||
if (Controller.Folders.Length == 0)
|
||||
StateText = "Welcome to SparkleShare!";
|
||||
else
|
||||
StateText = "Files up to date" + Controller.FolderSize;
|
||||
|
||||
|
||||
|
||||
this.status_item.Header = StateText;
|
||||
this.notify_icon.Icon = AnimationFrames [0];
|
||||
|
||||
CreateMenu ();
|
||||
this.notify_icon.Icon = AnimationFrames [0];
|
||||
|
||||
CreateMenu ();
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
case IconState.Syncing: {
|
||||
|
||||
StateText = "Syncing… " +
|
||||
|
@ -112,7 +112,7 @@ namespace SparkleShare {
|
|||
Animation.Start ();
|
||||
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
case IconState.Error: {
|
||||
|
||||
|
@ -126,14 +126,14 @@ namespace SparkleShare {
|
|||
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
this.status_item.UpdateLayout ();
|
||||
});
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
// Slices up the graphic that contains the
|
||||
// animation frames.
|
||||
|
@ -176,131 +176,131 @@ namespace SparkleShare {
|
|||
|
||||
public void CreateMenu ()
|
||||
{
|
||||
this.context_menu = new ContextMenu ();
|
||||
this.context_menu = new ContextMenu ();
|
||||
|
||||
status_item = new SparkleMenuItem () {
|
||||
Header = StateText,
|
||||
IsEnabled = false
|
||||
};
|
||||
|
||||
System.Windows.Controls.Image i = new System.Windows.Controls.Image();
|
||||
i.Source = SparkleUIHelpers.GetImageSource ("folder-sparkleshare-windows-16");
|
||||
i.Width = 16;
|
||||
i.Height = 16;
|
||||
|
||||
SparkleMenuItem folder_item = new SparkleMenuItem () {
|
||||
Header = "SparkleShare",
|
||||
Icon = i
|
||||
};
|
||||
|
||||
folder_item.Click += delegate {
|
||||
Controller.SparkleShareClicked ();
|
||||
};
|
||||
|
||||
SparkleMenuItem add_item = new SparkleMenuItem () {
|
||||
Header = "Add Hosted Project…",
|
||||
IsEnabled = (!Program.Controller.FirstRun)
|
||||
};
|
||||
|
||||
add_item.Click += delegate {
|
||||
Controller.AddHostedProjectClicked ();
|
||||
};
|
||||
|
||||
SparkleMenuItem log_item = new SparkleMenuItem () {
|
||||
Header = "View Recent Changes…",
|
||||
IsEnabled = (Program.Controller.Folders.Count > 0)
|
||||
};
|
||||
|
||||
log_item.Click += delegate {
|
||||
Controller.OpenRecentEventsClicked ();
|
||||
};
|
||||
|
||||
SparkleMenuItem notify_item = new SparkleMenuItem ();
|
||||
status_item = new SparkleMenuItem () {
|
||||
Header = StateText,
|
||||
IsEnabled = false
|
||||
};
|
||||
|
||||
System.Windows.Controls.Image i = new System.Windows.Controls.Image();
|
||||
i.Source = SparkleUIHelpers.GetImageSource ("folder-sparkleshare-windows-16");
|
||||
i.Width = 16;
|
||||
i.Height = 16;
|
||||
|
||||
SparkleMenuItem folder_item = new SparkleMenuItem () {
|
||||
Header = "SparkleShare",
|
||||
Icon = i
|
||||
};
|
||||
|
||||
folder_item.Click += delegate {
|
||||
Controller.SparkleShareClicked ();
|
||||
};
|
||||
|
||||
SparkleMenuItem add_item = new SparkleMenuItem () {
|
||||
Header = "Add Hosted Project…",
|
||||
IsEnabled = (!Program.Controller.FirstRun)
|
||||
};
|
||||
|
||||
add_item.Click += delegate {
|
||||
Controller.AddHostedProjectClicked ();
|
||||
};
|
||||
|
||||
SparkleMenuItem log_item = new SparkleMenuItem () {
|
||||
Header = "View Recent Changes…",
|
||||
IsEnabled = (Program.Controller.Folders.Count > 0)
|
||||
};
|
||||
|
||||
log_item.Click += delegate {
|
||||
Controller.OpenRecentEventsClicked ();
|
||||
};
|
||||
|
||||
SparkleMenuItem notify_item = new SparkleMenuItem ();
|
||||
|
||||
if (Program.Controller.NotificationsEnabled)
|
||||
notify_item = new SparkleMenuItem () { Header = "Turn Notifications Off" };
|
||||
else
|
||||
notify_item = new SparkleMenuItem () { Header = "Turn Notifications On" };
|
||||
|
||||
notify_item.Click += delegate {
|
||||
Program.Controller.ToggleNotifications ();
|
||||
CreateMenu ();
|
||||
};
|
||||
|
||||
SparkleMenuItem about_item = new SparkleMenuItem () {
|
||||
Header = "About SparkleShare"
|
||||
};
|
||||
|
||||
about_item.Click += delegate {
|
||||
Controller.AboutClicked ();
|
||||
};
|
||||
|
||||
exit_item = new SparkleMenuItem () {
|
||||
Header = "Exit"
|
||||
};
|
||||
|
||||
this.exit_item.Click += delegate {
|
||||
this.notify_icon.Dispose ();
|
||||
Controller.QuitClicked ();
|
||||
};
|
||||
|
||||
|
||||
this.context_menu.Items.Add (status_item);
|
||||
this.context_menu.Items.Add (new Separator ());
|
||||
this.context_menu.Items.Add (folder_item);
|
||||
if (Program.Controller.NotificationsEnabled)
|
||||
notify_item = new SparkleMenuItem () { Header = "Turn Notifications Off" };
|
||||
else
|
||||
notify_item = new SparkleMenuItem () { Header = "Turn Notifications On" };
|
||||
|
||||
notify_item.Click += delegate {
|
||||
Program.Controller.ToggleNotifications ();
|
||||
CreateMenu ();
|
||||
};
|
||||
|
||||
SparkleMenuItem about_item = new SparkleMenuItem () {
|
||||
Header = "About SparkleShare"
|
||||
};
|
||||
|
||||
about_item.Click += delegate {
|
||||
Controller.AboutClicked ();
|
||||
};
|
||||
|
||||
exit_item = new SparkleMenuItem () {
|
||||
Header = "Exit"
|
||||
};
|
||||
|
||||
this.exit_item.Click += delegate {
|
||||
this.notify_icon.Dispose ();
|
||||
Controller.QuitClicked ();
|
||||
};
|
||||
|
||||
|
||||
this.context_menu.Items.Add (status_item);
|
||||
this.context_menu.Items.Add (new Separator ());
|
||||
this.context_menu.Items.Add (folder_item);
|
||||
|
||||
if (Program.Controller.Folders.Count > 0) {
|
||||
foreach (string folder_name in Program.Controller.Folders) {
|
||||
SparkleMenuItem subfolder_item = new SparkleMenuItem () {
|
||||
Header = folder_name
|
||||
};
|
||||
|
||||
subfolder_item.Click += OpenFolderDelegate (folder_name);
|
||||
|
||||
System.Windows.Controls.Image i2 = new System.Windows.Controls.Image();
|
||||
i2.Source = SparkleUIHelpers.GetImageSource ("folder-windows-16");
|
||||
i2.Width = 16;
|
||||
i2.Height = 16;
|
||||
subfolder_item.Icon = i2;
|
||||
/*
|
||||
SparkleMenuItem subfolder_item = new SparkleMenuItem () {
|
||||
Header = folder_name
|
||||
};
|
||||
|
||||
subfolder_item.Click += OpenFolderDelegate (folder_name);
|
||||
|
||||
System.Windows.Controls.Image i2 = new System.Windows.Controls.Image();
|
||||
i2.Source = SparkleUIHelpers.GetImageSource ("folder-windows-16");
|
||||
i2.Width = 16;
|
||||
i2.Height = 16;
|
||||
subfolder_item.Icon = i2;
|
||||
/*
|
||||
if (Program.Controller.UnsyncedFolders.Contains (folder_name))
|
||||
subfolder_item.Icon = Icons.dialog_error_16;
|
||||
else
|
||||
subfolder_item.Icon = Icons.sparkleshare_windows_status;
|
||||
*/
|
||||
|
||||
*/
|
||||
|
||||
this.context_menu.Items.Add (subfolder_item);
|
||||
}
|
||||
|
||||
} else {
|
||||
SparkleMenuItem no_folders_item = new SparkleMenuItem () {
|
||||
Header = "No projects yet",
|
||||
IsEnabled = false
|
||||
};
|
||||
Header = "No projects yet",
|
||||
IsEnabled = false
|
||||
};
|
||||
|
||||
this.context_menu.Items.Add (no_folders_item);
|
||||
}
|
||||
|
||||
this.context_menu.Items.Add (new Separator ());
|
||||
this.context_menu.Items.Add (add_item);
|
||||
this.context_menu.Items.Add (new Separator ());
|
||||
this.context_menu.Items.Add (log_item);
|
||||
this.context_menu.Items.Add (notify_item);
|
||||
this.context_menu.Items.Add (new Separator ());
|
||||
this.context_menu.Items.Add (about_item);
|
||||
this.context_menu.Items.Add (new Separator ());
|
||||
this.context_menu.Items.Add (this.exit_item);
|
||||
}
|
||||
}
|
||||
|
||||
this.context_menu.Items.Add (new Separator ());
|
||||
this.context_menu.Items.Add (add_item);
|
||||
this.context_menu.Items.Add (new Separator ());
|
||||
this.context_menu.Items.Add (log_item);
|
||||
this.context_menu.Items.Add (notify_item);
|
||||
this.context_menu.Items.Add (new Separator ());
|
||||
this.context_menu.Items.Add (about_item);
|
||||
this.context_menu.Items.Add (new Separator ());
|
||||
this.context_menu.Items.Add (this.exit_item);
|
||||
}
|
||||
|
||||
|
||||
public void ShowBalloon (string title, string subtext, string image_path)
|
||||
|
||||
public void ShowBalloon (string title, string subtext, string image_path)
|
||||
{
|
||||
// TODO:
|
||||
// - Use the image pointed to by image_path
|
||||
// - Find a way to use the prettier (Win7?) balloons
|
||||
// - Use the image pointed to by image_path
|
||||
// - Find a way to use the prettier (Win7?) balloons
|
||||
this.notify_icon.ShowBalloonTip (5 * 1000, title, subtext, Forms.ToolTipIcon.Info);
|
||||
}
|
||||
|
||||
|
||||
|
||||
public void Dispose ()
|
||||
{
|
||||
|
@ -323,21 +323,21 @@ namespace SparkleShare {
|
|||
IntPtr unmanaged_icon = bitmap.GetHicon ();
|
||||
Icon icon = (Icon) Icon.FromHandle (unmanaged_icon).Clone ();
|
||||
DestroyIcon (unmanaged_icon);
|
||||
|
||||
|
||||
return icon;
|
||||
}
|
||||
|
||||
|
||||
[DllImport("user32.dll", EntryPoint = "DestroyIcon")]
|
||||
static extern bool DestroyIcon (IntPtr hIcon);
|
||||
|
||||
|
||||
[DllImport("user32.dll", EntryPoint = "DestroyIcon")]
|
||||
static extern bool DestroyIcon (IntPtr hIcon);
|
||||
}
|
||||
|
||||
|
||||
public class SparkleMenuItem : MenuItem {
|
||||
|
||||
public SparkleMenuItem () : base ()
|
||||
{
|
||||
Padding = new Thickness (6, 3, 4, 0);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public class SparkleMenuItem : MenuItem {
|
||||
|
||||
public SparkleMenuItem () : base ()
|
||||
{
|
||||
Padding = new Thickness (6, 3, 4, 0);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -22,25 +22,25 @@ namespace SparkleShare {
|
|||
|
||||
public class SparkleUI {
|
||||
|
||||
public static SparkleSetup Setup;
|
||||
public static SparkleEventLog EventLog;
|
||||
public static SparkleSetup Setup;
|
||||
public static SparkleEventLog EventLog;
|
||||
public static SparkleBubbles Bubbles;
|
||||
public static SparkleStatusIcon StatusIcon;
|
||||
public static SparkleStatusIcon StatusIcon;
|
||||
public static SparkleAbout About;
|
||||
|
||||
|
||||
public SparkleUI ()
|
||||
{
|
||||
{
|
||||
Setup = new SparkleSetup ();
|
||||
EventLog = new SparkleEventLog ();
|
||||
About = new SparkleAbout ();
|
||||
Bubbles = new SparkleBubbles ();
|
||||
StatusIcon = new SparkleStatusIcon ();
|
||||
|
||||
Program.Controller.UIHasLoaded ();
|
||||
|
||||
Program.Controller.UIHasLoaded ();
|
||||
}
|
||||
|
||||
|
||||
|
||||
public void Run ()
|
||||
{
|
||||
Application.Run ();
|
||||
|
|
|
@ -24,26 +24,26 @@ using System.Windows.Media.Imaging;
|
|||
namespace SparkleShare {
|
||||
|
||||
public static class SparkleUIHelpers {
|
||||
|
||||
|
||||
public static string ToHex (this Color color)
|
||||
{
|
||||
return string.Format ("#{0:X2}{1:X2}{2:X2}", color.R, color.G, color.B);
|
||||
}
|
||||
|
||||
|
||||
public static BitmapFrame GetImageSource (string name)
|
||||
{
|
||||
Assembly assembly = Assembly.GetExecutingAssembly ();
|
||||
Stream image_stream = assembly.GetManifestResourceStream ("SparkleShare.Pixmaps." + name + ".png");
|
||||
return BitmapFrame.Create (image_stream);
|
||||
}
|
||||
|
||||
|
||||
public static Bitmap GetBitmap (string name)
|
||||
{
|
||||
Assembly assembly = Assembly.GetExecutingAssembly ();
|
||||
Stream image_stream = assembly.GetManifestResourceStream ("SparkleShare.Pixmaps." + name + ".png");
|
||||
return (Bitmap) Bitmap.FromStream (image_stream);
|
||||
}
|
||||
public static BitmapFrame GetImageSource (string name)
|
||||
{
|
||||
Assembly assembly = Assembly.GetExecutingAssembly ();
|
||||
Stream image_stream = assembly.GetManifestResourceStream ("SparkleShare.Pixmaps." + name + ".png");
|
||||
return BitmapFrame.Create (image_stream);
|
||||
}
|
||||
|
||||
|
||||
public static Bitmap GetBitmap (string name)
|
||||
{
|
||||
Assembly assembly = Assembly.GetExecutingAssembly ();
|
||||
Stream image_stream = assembly.GetManifestResourceStream ("SparkleShare.Pixmaps." + name + ".png");
|
||||
return (Bitmap) Bitmap.FromStream (image_stream);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -19,7 +19,7 @@ namespace SparkleShare
|
|||
{
|
||||
public class Strings
|
||||
{
|
||||
private static Object resourceManLock = new Object();
|
||||
private static Object resourceManLock = new Object();
|
||||
private static System.Resources.ResourceManager resourceMan;
|
||||
private static System.Globalization.CultureInfo resourceCulture;
|
||||
|
||||
|
@ -30,9 +30,9 @@ namespace SparkleShare
|
|||
|
||||
private static string GetSetting(string setting, string defaultValue)
|
||||
{
|
||||
var section = (System.Collections.Specialized.NameValueCollection)System.Configuration.ConfigurationManager.GetSection("appSettings");
|
||||
if (section == null) return defaultValue;
|
||||
else return section[setting] ?? defaultValue;
|
||||
var section = (System.Collections.Specialized.NameValueCollection)System.Configuration.ConfigurationManager.GetSection("appSettings");
|
||||
if (section == null) return defaultValue;
|
||||
else return section[setting] ?? defaultValue;
|
||||
}
|
||||
|
||||
|
||||
|
@ -65,15 +65,15 @@ namespace SparkleShare
|
|||
|
||||
if (object.ReferenceEquals(resourceMan, null))
|
||||
{
|
||||
lock (resourceManLock)
|
||||
{
|
||||
if (object.ReferenceEquals(resourceMan, null))
|
||||
{
|
||||
var directory = resourcesDir;
|
||||
var mgr = new global::Gettext.Cs.GettextResourceManager(ResourceName, directory, fileFormat);
|
||||
resourceMan = mgr;
|
||||
}
|
||||
}
|
||||
lock (resourceManLock)
|
||||
{
|
||||
if (object.ReferenceEquals(resourceMan, null))
|
||||
{
|
||||
var directory = resourcesDir;
|
||||
var mgr = new global::Gettext.Cs.GettextResourceManager(ResourceName, directory, fileFormat);
|
||||
resourceMan = mgr;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return resourceMan;
|
||||
|
|
|
@ -1,8 +1,8 @@
|
|||
<#@ assembly name="System.Configuration" #>
|
||||
|
||||
<#
|
||||
this.ClassName = "Strings";
|
||||
this.ResourceName = "Strings";
|
||||
this.ClassName = "Strings";
|
||||
this.ResourceName = "Strings";
|
||||
this.NamespaceName = "SparkleShare";
|
||||
this.DefaultResourceDir = "po";
|
||||
this.DefaultFileFormat = "{{culture}}.po";
|
||||
|
|
Loading…
Reference in a new issue