diff --git a/SparkleShare/Common/BaseController.cs b/SparkleShare/Common/BaseController.cs index 4a370041..a31b9b5b 100644 --- a/SparkleShare/Common/BaseController.cs +++ b/SparkleShare/Common/BaseController.cs @@ -167,7 +167,7 @@ namespace SparkleShare { public abstract void SetFolderIcon (); // Creates the SparkleShare folder in the user's home folder - public abstract bool CreateSparkleShareFolder (); + public abstract void CreateSparkleShareFolder (); // Opens the SparkleShare folder or an (optional) subfolder public abstract void OpenFolder (string path); @@ -206,9 +206,6 @@ namespace SparkleShare { Config = new Configuration (config_path, "projects.xml"); Configuration.DefaultConfiguration = Config; - UserAuthenticationInfo = new SSHAuthenticationInfo (); - SSHAuthenticationInfo.DefaultAuthenticationInfo = UserAuthenticationInfo; - FoldersPath = Config.FoldersPath; } @@ -227,6 +224,9 @@ namespace SparkleShare { // TODO: ToString() with nice os version names (Mac OS X Yosemite, Fedora 24, Ubuntu 16.04, etc.) Logger.LogInfo ("Environment", InstallationInfo.OperatingSystem + " (" + Environment.OSVersion + ")"); + UserAuthenticationInfo = new SSHAuthenticationInfo (); + SSHAuthenticationInfo.DefaultAuthenticationInfo = UserAuthenticationInfo; + Preset.PresetsPath = PresetsPath; InstallProtocolHandler (); diff --git a/SparkleShare/Linux/Controller.cs b/SparkleShare/Linux/Controller.cs index 4f6333fa..2cc1f47c 100644 --- a/SparkleShare/Linux/Controller.cs +++ b/SparkleShare/Linux/Controller.cs @@ -33,15 +33,12 @@ namespace SparkleShare { } - public override bool CreateSparkleShareFolder () + public override void CreateSparkleShareFolder () { - if (Directory.Exists (Configuration.DefaultConfiguration.FoldersPath)) - return false; - - Directory.CreateDirectory (Configuration.DefaultConfiguration.FoldersPath); - Syscall.chmod (Configuration.DefaultConfiguration.FoldersPath, (FilePermissions) 448); // 448 -> 700 - - return false; + if (!Directory.Exists (Configuration.DefaultConfiguration.FoldersPath)) { + Directory.CreateDirectory (Configuration.DefaultConfiguration.FoldersPath); + Syscall.chmod (Configuration.DefaultConfiguration.FoldersPath, (FilePermissions) 448); // 448 -> 700 + } } diff --git a/SparkleShare/Mac/Controller.cs b/SparkleShare/Mac/Controller.cs index b97c05b4..b53c7012 100644 --- a/SparkleShare/Mac/Controller.cs +++ b/SparkleShare/Mac/Controller.cs @@ -61,16 +61,12 @@ namespace SparkleShare { } - public override bool CreateSparkleShareFolder () + public override void CreateSparkleShareFolder () { if (!Directory.Exists (SparkleShare.Controller.FoldersPath)) { Directory.CreateDirectory (SparkleShare.Controller.FoldersPath); Syscall.chmod (SparkleShare.Controller.FoldersPath, (FilePermissions) 448); // 448 -> 700 - - return true; } - - return false; } diff --git a/SparkleShare/SparkleShare.exe.config b/SparkleShare/SparkleShare.exe.config new file mode 100644 index 00000000..51278a45 --- /dev/null +++ b/SparkleShare/SparkleShare.exe.config @@ -0,0 +1,3 @@ + + + diff --git a/SparkleShare/SparkleShare.vshost.exe.config b/SparkleShare/SparkleShare.vshost.exe.config new file mode 100644 index 00000000..51278a45 --- /dev/null +++ b/SparkleShare/SparkleShare.vshost.exe.config @@ -0,0 +1,3 @@ + + + diff --git a/SparkleShare/Windows/SparkleEventLog.cs b/SparkleShare/Windows/SparkleEventLog.cs deleted file mode 100644 index 24aa73ec..00000000 --- a/SparkleShare/Windows/SparkleEventLog.cs +++ /dev/null @@ -1,372 +0,0 @@ -// 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.ComponentModel; -using System.IO; -using System.Runtime.InteropServices; -using System.Security.Permissions; -using System.Threading; -using System.Windows; -using System.Windows.Controls; -using System.Windows.Media; -using System.Windows.Media.Imaging; - -using Microsoft.Win32; -using Shapes = System.Windows.Shapes; - -using SparkleLib; - -namespace SparkleShare { - - public class SparkleEventLog : Window { - - public SparkleEventLogController Controller = new SparkleEventLogController (); - - private Canvas canvas; - private Label size_label_value; - private Label history_label_value; - private ComboBox combo_box; - private WebBrowser web_browser; - private SparkleSpinner spinner; - - - public SparkleEventLog () - { - Title = "Recent Changes"; - Height = 640; - Width = 480; - ResizeMode = ResizeMode.NoResize; // TODO - Background = new SolidColorBrush (Color.FromRgb (240, 240, 240)); - AllowsTransparency = false; - Icon = SparkleUIHelpers.GetImageSource ("sparkleshare-app", "ico"); - - int x = (int) (SystemParameters.PrimaryScreenWidth * 0.61); - int y = (int) (SystemParameters.PrimaryScreenHeight * 0.5 - (Height * 0.5)); - - WindowStartupLocation = WindowStartupLocation.Manual; - Left = x; - Top = y; - - WriteOutImages (); - - Label size_label = new Label () { - Content = "Size:", - FontWeight = FontWeights.Bold - }; - - this.size_label_value = new Label () { - Content = Controller.Size - }; - - 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:", - FontWeight = FontWeights.Bold - }; - - this.history_label_value = new Label () { - Content = Controller.HistorySize, - }; - - history_label.Measure (new Size (Double.PositiveInfinity, Double.PositiveInfinity)); - Rect history_label_rect = new Rect (history_label.DesiredSize); - - Shapes.Rectangle line = new Shapes.Rectangle () { - Width = Width, - Height = 1, - Fill = new SolidColorBrush (Color.FromRgb (223, 223, 223)) - }; - - Shapes.Rectangle background = new Shapes.Rectangle () { - Width = Width, - Height = Height, - Fill = new SolidColorBrush (Color.FromRgb (250, 250, 250)) - }; - - this.web_browser = new WebBrowser () { - Width = Width - 6, - Height = Height - 64 - }; - - this.web_browser.ObjectForScripting = new SparkleScriptingObject (); - - - spinner = new SparkleSpinner (22); - - // Disable annoying IE clicking sound - CoInternetSetFeatureEnabled (21, 0x00000002, true); - - - this.canvas = new Canvas (); - Content = this.canvas; - - this.canvas.Children.Add (size_label); - Canvas.SetLeft (size_label, 24); - Canvas.SetTop (size_label, 4); - - this.canvas.Children.Add (this.size_label_value); - Canvas.SetLeft (this.size_label_value, 22 + size_label_rect.Width); - Canvas.SetTop (this.size_label_value, 4); - - this.canvas.Children.Add (history_label); - Canvas.SetLeft (history_label, 130); - Canvas.SetTop (history_label, 4); - - this.canvas.Children.Add (this.history_label_value); - Canvas.SetLeft (this.history_label_value, 130 + history_label_rect.Width); - Canvas.SetTop (this.history_label_value, 4); - - this.canvas.Children.Add (background); - Canvas.SetLeft (background, 0); - 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); - Canvas.SetLeft (line, 0); - Canvas.SetTop (line, 35); - - - Closing += Close; - - Controller.ShowWindowEvent += delegate { - Dispatcher.BeginInvoke ((Action) delegate { - Show (); - Activate (); - BringIntoView (); - }); - }; - - Controller.HideWindowEvent += delegate { - Dispatcher.BeginInvoke ((Action) delegate { - Hide (); - - if (this.canvas.Children.Contains (this.web_browser)) - this.canvas.Children.Remove (this.web_browser); - }); - }; - - Controller.UpdateSizeInfoEvent += delegate (string size, string history_size) { - Dispatcher.BeginInvoke ((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.BeginInvoke ((Action) delegate { - UpdateChooser (folders); - }); - }; - - Controller.UpdateChooserEnablementEvent += delegate (bool enabled) { - Dispatcher.BeginInvoke ((Action) delegate { - this.combo_box.IsEnabled = enabled; - }); - }; - - Controller.UpdateContentEvent += delegate (string html) { - Dispatcher.BeginInvoke ((Action) delegate { - UpdateContent (html); - }); - }; - - Controller.ContentLoadingEvent += delegate { - Dispatcher.BeginInvoke ((Action) delegate { - this.spinner.Start (); - - if (this.canvas.Children.Contains (this.web_browser)) - this.canvas.Children.Remove (this.web_browser); - }); - }; - - Controller.ShowSaveDialogEvent += delegate (string file_name, string target_folder_path) { - Dispatcher.BeginInvoke ((Action) delegate { - SaveFileDialog dialog = new SaveFileDialog () { - FileName = file_name, - InitialDirectory = target_folder_path, - Title = "Restore from History", - DefaultExt = "." + Path.GetExtension (file_name), - Filter = "All Files|*.*" - }; - - Nullable result = dialog.ShowDialog (this); - - if (result == true) - Controller.SaveDialogCompleted (dialog.FileName); - else - Controller.SaveDialogCancelled (); - }); - }; - } - - - 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 = "Summary" - }; - - this.combo_box.Items.Add (item); - this.combo_box.Items.Add (new Separator ()); - - this.combo_box.SelectedItem = combo_box.Items [0]; - - int row = 2; - foreach (string folder in folders) { - this.combo_box.Items.Add ( - new ComboBoxItem () { Content = folder } - ); - - if (folder.Equals (Controller.SelectedFolder)) - this.combo_box.SelectedItem = combo_box.Items [row]; - - row++; - } - - this.combo_box.SelectionChanged += delegate { - Dispatcher.BeginInvoke ((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 - 24 - this.combo_box.Width); - Canvas.SetTop (this.combo_box, 6); - } - - - public void UpdateContent (string html) - { - string pixmaps_path = Path.Combine (SparkleLib.SparkleConfig.DefaultConfig.TmpPath, "Images".SHA1 ()); - pixmaps_path = pixmaps_path.Replace ("\\", "/"); - - html = html.Replace ("", "'Segoe UI', sans-serif"); - html = html.Replace ("", "13px"); - html = html.Replace ("", "12px"); - html = html.Replace ("", "#bbb"); - html = html.Replace ("", "#ddd"); - html = html.Replace ("", "90%"); - html = html.Replace ("", "#f5f5f5"); - html = html.Replace ("", "#0085cf"); - html = html.Replace ("", "#009ff8"); - html = html.Replace ("", pixmaps_path); - html = html.Replace ("", pixmaps_path + "/document-added-12.png"); - html = html.Replace ("", pixmaps_path + "/document-edited-12.png"); - html = html.Replace ("", pixmaps_path + "/document-deleted-12.png"); - html = html.Replace ("", pixmaps_path + "/document-moved-12.png"); - - this.spinner.Stop (); - - this.web_browser.ObjectForScripting = new SparkleScriptingObject (); - 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); - } - } - - - private void WriteOutImages () - { - string tmp_path = SparkleLib.SparkleConfig.DefaultConfig.TmpPath; - string pixmaps_path = Path.Combine (tmp_path, "Images".SHA1 ()); - - if (!Directory.Exists (pixmaps_path)) { - Directory.CreateDirectory (pixmaps_path); - - File.SetAttributes (tmp_path, - File.GetAttributes (tmp_path) | FileAttributes.Hidden); - } - - BitmapSource image = SparkleUIHelpers.GetImageSource ("user-icon-default"); - string file_path = Path.Combine (pixmaps_path, "user-icon-default.png"); - - using (FileStream stream = new FileStream (file_path, FileMode.Create)) - { - BitmapEncoder encoder = new PngBitmapEncoder (); - encoder.Frames.Add (BitmapFrame.Create (image)); - encoder.Save (stream); - } - - string [] actions = new string [] {"added", "deleted", "edited", "moved"}; - - foreach (string action in actions) { - image = SparkleUIHelpers.GetImageSource ("document-" + action + "-12"); - file_path = Path.Combine (pixmaps_path, "document-" + action + "-12.png"); - - using (FileStream stream = new FileStream (file_path, FileMode.Create)) - { - BitmapEncoder encoder = new PngBitmapEncoder (); - encoder.Frames.Add (BitmapFrame.Create (image)); - encoder.Save (stream); - } - } - } - - - private void Close (object sender, CancelEventArgs args) - { - Controller.WindowClosed (); - args.Cancel = true; - } - - - [DllImport ("urlmon.dll")] - [PreserveSig] - [return:MarshalAs (UnmanagedType.Error)] - static extern int CoInternetSetFeatureEnabled (int feature, - [MarshalAs (UnmanagedType.U4)] int flags, bool enable); - } - - - [PermissionSet(SecurityAction.Demand, Name = "FullTrust")] - [ComVisible(true)] - public class SparkleScriptingObject { - - public void LinkClicked (string url) - { - SparkleShare.UI.EventLog.Controller.LinkClicked (url); - } - } -} diff --git a/SparkleShare/Windows/SparkleEventLogWindow.xaml b/SparkleShare/Windows/SparkleEventLogWindow.xaml deleted file mode 100644 index a43d38f3..00000000 --- a/SparkleShare/Windows/SparkleEventLogWindow.xaml +++ /dev/null @@ -1,38 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/SparkleShare/Windows/SparkleEventLogWindow.xaml.cs b/SparkleShare/Windows/SparkleEventLogWindow.xaml.cs deleted file mode 100644 index b686da9d..00000000 --- a/SparkleShare/Windows/SparkleEventLogWindow.xaml.cs +++ /dev/null @@ -1,262 +0,0 @@ -// SparkleShare, a collaboration and sharing tool. -// Copyright (C) 2010 Hylke Bons -// -// 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 . - - -using System; -using System.Collections.Generic; -using System.ComponentModel; -using System.IO; -using System.Linq; -using System.Security.Permissions; -using System.Text; -using System.Runtime.InteropServices; -using System.Windows; -using System.Windows.Controls; -using System.Windows.Media; -using System.Windows.Media.Imaging; - -using Microsoft.Win32; - -namespace SparkleShare -{ - public partial class SparkleEventLogWindow : Window - { - public SparkleEventLogController Controller = new SparkleEventLogController (); - - [DllImport("urlmon.dll")] - [PreserveSig] - [return: MarshalAs(UnmanagedType.Error)] - static extern int CoInternetSetFeatureEnabled (int feature, [MarshalAs(UnmanagedType.U4)] int flags, bool enable); - - - public SparkleEventLogWindow () - { - InitializeComponent (); - - - Background = new SolidColorBrush (Color.FromRgb(240, 240, 240)); - AllowsTransparency = false; - Icon = SparkleUIHelpers.GetImageSource ("sparkleshare-app", "ico"); - WindowStartupLocation = WindowStartupLocation.CenterScreen; - - WriteOutImages (); - - this.label_Size.Content = "Size: " + Controller.Size; - this.label_History.Content = "History: " + Controller.HistorySize; - - this.webbrowser.ObjectForScripting = new SparkleScriptingObject (); - - // Disable annoying IE clicking sound - CoInternetSetFeatureEnabled (21, 0x00000002, true); - - Closing += this.OnClosing; - - Controller.ShowWindowEvent += delegate { - Dispatcher.BeginInvoke ((Action) (() => { - Show (); - Activate (); - BringIntoView (); - })); - }; - - Controller.HideWindowEvent += delegate { - Dispatcher.BeginInvoke ((Action) (() => { - Hide (); - this.spinner.Visibility = Visibility.Visible; - this.webbrowser.Visibility = Visibility.Collapsed; - })); - }; - - Controller.UpdateSizeInfoEvent += delegate (string size, string history_size) { - Dispatcher.BeginInvoke ((Action) (() => { - this.label_Size.Content = "Size: " + size; - this.label_History.Content = "History: " + history_size; - })); - }; - - Controller.UpdateChooserEvent += delegate (string [] folders) { - Dispatcher.BeginInvoke ((Action) (() => - UpdateChooser (folders)) - ); - }; - - Controller.UpdateChooserEnablementEvent += delegate (bool enabled) { - Dispatcher.BeginInvoke ((Action) (() => - this.combobox.IsEnabled = enabled - )); - }; - - Controller.UpdateContentEvent += delegate (string html) { - Dispatcher.BeginInvoke ((Action) (() => { - UpdateContent (html); - - this.spinner.Visibility = Visibility.Collapsed; - this.webbrowser.Visibility = Visibility.Visible; - })); - }; - - Controller.ContentLoadingEvent += () => this.Dispatcher.BeginInvoke ( - (Action)(() => { - this.spinner.Visibility = Visibility.Visible; - this.spinner.Start (); - this.webbrowser.Visibility = Visibility.Collapsed; - })); - - Controller.ShowSaveDialogEvent += delegate (string file_name, string target_folder_path) { - Dispatcher.BeginInvoke ((Action) (() => { - SaveFileDialog dialog = new SaveFileDialog () { - FileName = file_name, - InitialDirectory = target_folder_path, - Title = "Restore from History", - DefaultExt = "." + Path.GetExtension (file_name), - Filter = "All Files|*.*" - }; - - bool? result = dialog.ShowDialog (this); - - if (result == true) - Controller.SaveDialogCompleted (dialog.FileName); - else - Controller.SaveDialogCancelled (); - })); - }; - } - - - private void OnClosing (object sender, CancelEventArgs cancel_event_args) - { - Controller.WindowClosed (); - cancel_event_args.Cancel = true; - } - - - private void UpdateContent (string html) - { - string pixmaps_path = Path.Combine (Sparkles.SparkleConfig.DefaultConfig.TmpPath, "Images"); - pixmaps_path = pixmaps_path.Replace ("\\", "/"); - - html = html.Replace ("", "Segoe UI"); - html = html.Replace ("", "13px"); - html = html.Replace ("", "12px"); - html = html.Replace ("", "#bbb"); - html = html.Replace ("", "#ddd"); - html = html.Replace ("", "90%"); - html = html.Replace ("", "#f5f5f5"); - html = html.Replace ("", "#0085cf"); - html = html.Replace ("", "#009ff8"); - html = html.Replace ("", pixmaps_path); - html = html.Replace ("", pixmaps_path + "/document-added-12.png"); - html = html.Replace ("", pixmaps_path + "/document-edited-12.png"); - html = html.Replace ("", pixmaps_path + "/document-deleted-12.png"); - html = html.Replace ("", pixmaps_path + "/document-moved-12.png"); - - this.spinner.Stop (); - - this.webbrowser.ObjectForScripting = new SparkleScriptingObject (); - this.webbrowser.NavigateToString (html); - } - - - public void UpdateChooser (string [] folders) - { - if (folders == null) { - folders = Controller.Folders; - } - - this.combobox.Items.Clear (); - this.combobox.Items.Add (new ComboBoxItem () { Content = "Summary" }); - this.combobox.Items.Add (new Separator ()); - this.combobox.SelectedItem = combobox.Items [0]; - - int row = 2; - foreach (string folder in folders) { - this.combobox.Items.Add (new ComboBoxItem () { Content = folder } ); - - if (folder.Equals (Controller.SelectedFolder)) - this.combobox.SelectedItem = this.combobox.Items [row]; - - row++; - } - - this.combobox.SelectionChanged += delegate { - Dispatcher.BeginInvoke ((Action) delegate { - int index = this.combobox.SelectedIndex; - - if (index == 0) - Controller.SelectedFolder = null; - else - Controller.SelectedFolder = (string) ((ComboBoxItem) this.combobox.Items [index]).Content; - }); - }; - } - - - private void WriteOutImages () - { - string tmp_path = Sparkles.SparkleConfig.DefaultConfig.TmpPath; - string pixmaps_path = Path.Combine (tmp_path, "Images"); - - if (!Directory.Exists (pixmaps_path)) - { - Directory.CreateDirectory (pixmaps_path); - - File.SetAttributes (tmp_path, File.GetAttributes (tmp_path) | FileAttributes.Hidden); - } - - BitmapSource image = SparkleUIHelpers.GetImageSource ("user-icon-default"); - string file_path = Path.Combine (pixmaps_path, "user-icon-default.png"); - - using (FileStream stream = new FileStream (file_path, FileMode.Create)) - { - BitmapEncoder encoder = new PngBitmapEncoder (); - encoder.Frames.Add (BitmapFrame.Create (image)); - encoder.Save (stream); - } - - string[] actions = new string [] { "added", "deleted", "edited", "moved" }; - - foreach (string action in actions) - { - image = SparkleUIHelpers.GetImageSource ("document-" + action + "-12"); - file_path = Path.Combine (pixmaps_path, "document-" + action + "-12.png"); - - using (FileStream stream = new FileStream (file_path, FileMode.Create)) - { - BitmapEncoder encoder = new PngBitmapEncoder (); - encoder.Frames.Add (BitmapFrame.Create(image)); - encoder.Save (stream); - } - } - } - } - - - - - - [PermissionSet(SecurityAction.Demand, Name = "FullTrust")] - [ComVisible(true)] - public class SparkleScriptingObject - { - public void LinkClicked(string url) - { - SparkleShare.UI.EventLog.Controller.LinkClicked(url); - } - } - - -} diff --git a/SparkleShare/Windows/SparkleLib/Git/SparkleLib.Git.csproj b/SparkleShare/Windows/SparkleLib/Git/SparkleLib.Git.csproj deleted file mode 100644 index 473b4dce..00000000 --- a/SparkleShare/Windows/SparkleLib/Git/SparkleLib.Git.csproj +++ /dev/null @@ -1,71 +0,0 @@ - - - - - Debug - AnyCPU - {7F0DB8D0-E278-4955-8204-FC391B99F7C1} - Library - Properties - SparkleLib.Git - SparkleLib.Git - v4.0 - 512 - - - - true - full - false - ..\..\..\..\bin\ - DEBUG;TRACE - prompt - 4 - - - pdbonly - true - ..\..\..\..\bin\ - TRACE - prompt - 4 - - - - - - - - - - - - - SparkleFetcherGit.cs - - - SparkleGit.cs - Component - - - SparkleRepoGit.cs - - - - - - - - {748f6316-37b4-46fd-a011-af073bc7c02d} - SparkleLib - - - - - \ No newline at end of file diff --git a/SparkleShare/Windows/SparkleLib/SparkleLib.csproj b/SparkleShare/Windows/SparkleLib/SparkleLib.csproj deleted file mode 100644 index 4c5eaff9..00000000 --- a/SparkleShare/Windows/SparkleLib/SparkleLib.csproj +++ /dev/null @@ -1,97 +0,0 @@ - - - - - Debug - AnyCPU - {748F6316-37B4-46FD-A011-AF073BC7C02D} - Library - Properties - SparkleLib - SparkleLib - v4.0 - 512 - - - - true - full - false - ..\..\..\bin\ - DEBUG;TRACE - prompt - 4 - - - pdbonly - true - ..\..\..\bin\ - TRACE - prompt - 4 - - - - - - - - - - - - - - - - Defines.cs - - - SparkleBackend.cs - - - SparkleConfig.cs - - - SparkleExtensions.cs - - - SparkleFetcherBase.cs - - - SparkleFetcherSSH.cs - - - SparkleListenerBase.cs - - - SparkleListenerFactory.cs - - - SparkleListenerTcp.cs - - - SparkleLogger.cs - - - SparkleRepoBase.cs - - - SparkleUser.cs - - - SparkleWatcher.cs - - - SparkleWrappers.cs - - - - - \ No newline at end of file diff --git a/SparkleShare/Windows/SparkleShare.Windows.csproj b/SparkleShare/Windows/SparkleShare.Windows.csproj index 89d9d7c0..7e557d3e 100644 --- a/SparkleShare/Windows/SparkleShare.Windows.csproj +++ b/SparkleShare/Windows/SparkleShare.Windows.csproj @@ -1,4 +1,4 @@ - + Debug @@ -6,9 +6,9 @@ 8.0.30703 {728483AA-E34B-4441-BF2C-C8BC2901E4E0} WinExe - SparkleShare + SparkleShare.Windows 2.0 - SparkleShare + SparkleShare.Windows 3.5 @@ -44,6 +44,7 @@ x86 TRACE true + false ..\..\bin\ @@ -53,6 +54,26 @@ true 4 false + false + + + true + ..\..\bin\ + TRACE;DEBUG + full + AnyCPU + prompt + MinimumRecommendedRules.ruleset + + + true + ..\..\bin\ + TRACE + true + pdbonly + x86 + prompt + AllRules.ruleset ..\..\bin\ @@ -80,53 +101,30 @@ - - SparkleBubblesController.cs + + + + + + + + + + + + + + + Note.xaml - - SparkleControllerBase.cs - - - SparkleExtensions.cs - - - SparkleInvite.cs - - - SparkleNoteController.cs - - - SparklePlugin.cs - - - SparkleStatusIconController.cs - - - - SparkleEventLogWindow.xaml - - - SparkleNote.xaml - - - - - - - - - - - - - SparkleEventLogController.cs - - - - Program.cs - - - + + + + + + + + @@ -155,9 +153,11 @@ Images\about.png + Always Images\side-splash.png + Always HTML\day-entry.html @@ -174,31 +174,47 @@ Images\user-icon-default.png + Always - + Images\document-added-12.png + Always - + Images\document-deleted-12.png + Always - + Images\document-edited-12.png + Always - + Images\document-moved-12.png + Always - + Images\process-working-22.png + Always + + + Always + + + Always + + + Always + + + Always - - - - Images\tutorial-slide-1.png + Always Images\tutorial-slide-2.png + Always @@ -206,10 +222,6 @@ Presets\github.png Always - - Presets\gitorious.png - Always - Presets\own-server.png Always @@ -218,20 +230,13 @@ Presets\bitbucket.png Always - - Presets\ssnet.png - Always - Presets\planio.png Always + - - Presets\ssnet.xml - Always - Presets\bitbucket.xml Always @@ -240,10 +245,6 @@ Presets\github.xml Always - - Presets\gitorious.xml - Always - Presets\own-server.xml Always @@ -254,26 +255,35 @@ - - - - + + Always + + + Always + + + Always + + + Always + - + + Always + Images\text-balloon.png + Always - + + Always + - - Designer - MSBuild:Compile - - + Designer MSBuild:Compile @@ -288,4 +298,4 @@ Sparkles.Git - + \ No newline at end of file diff --git a/SparkleShare/Windows/SparkleAbout.cs b/SparkleShare/Windows/UserInterface/About.cs similarity index 94% rename from SparkleShare/Windows/SparkleAbout.cs rename to SparkleShare/Windows/UserInterface/About.cs index 6d34ed73..a8cf7328 100644 --- a/SparkleShare/Windows/SparkleAbout.cs +++ b/SparkleShare/Windows/UserInterface/About.cs @@ -17,30 +17,27 @@ using System; using System.ComponentModel; -using System.Diagnostics; using System.Windows; using System.Windows.Input; using System.Windows.Controls; using System.Windows.Media; -using System.Windows.Media.Imaging; -using System.Xaml; namespace SparkleShare { - public class SparkleAbout : Window { + public class About : Window { - public SparkleAboutController Controller = new SparkleAboutController (); + public AboutController Controller = new AboutController (); private Label updates; - public SparkleAbout () + public About () { Title = "About SparkleShare"; ResizeMode = ResizeMode.NoResize; Height = 288; Width = 720; - Icon = SparkleUIHelpers.GetImageSource("sparkleshare-app", "ico"); + Icon = UserInterfaceHelpers.GetImageSource("sparkleshare-app", "ico"); WindowStartupLocation = WindowStartupLocation.CenterScreen; Closing += Close; @@ -77,7 +74,7 @@ namespace SparkleShare { Height = 260 }; - image.Source = SparkleUIHelpers.GetImageSource ("about"); + image.Source = UserInterfaceHelpers.GetImageSource ("about"); Label version = new Label () { diff --git a/SparkleShare/Windows/SparkleBubbles.cs b/SparkleShare/Windows/UserInterface/Bubbles.cs similarity index 87% rename from SparkleShare/Windows/SparkleBubbles.cs rename to SparkleShare/Windows/UserInterface/Bubbles.cs index e9b07136..3e692768 100644 --- a/SparkleShare/Windows/SparkleBubbles.cs +++ b/SparkleShare/Windows/UserInterface/Bubbles.cs @@ -15,16 +15,14 @@ // along with this program. If not, see . -using System; - namespace SparkleShare { - public class SparkleBubbles { + public class Bubbles { - public SparkleBubblesController Controller = new SparkleBubblesController (); + public BubblesController Controller = new BubblesController (); - public SparkleBubbles () + public Bubbles () { Controller.ShowBubbleEvent += delegate (string title, string subtext, string image_path) { if (!SparkleShare.Controller.NotificationsEnabled) diff --git a/SparkleShare/Windows/SparkleController.cs b/SparkleShare/Windows/UserInterface/Controller.cs similarity index 69% rename from SparkleShare/Windows/SparkleController.cs rename to SparkleShare/Windows/UserInterface/Controller.cs index 9c030b4c..6e979908 100644 --- a/SparkleShare/Windows/SparkleController.cs +++ b/SparkleShare/Windows/UserInterface/Controller.cs @@ -16,26 +16,22 @@ using System; -using System.Collections.Generic; using System.Diagnostics; using System.IO; using System.Reflection; using System.Runtime.InteropServices; -using System.Text; -using System.Text.RegularExpressions; -using System.Threading; using System.Windows; using Forms = System.Windows.Forms; -using Microsoft.Win32; using Sparkles; +using Sparkles.Git; namespace SparkleShare { - public class SparkleController : SparkleControllerBase { + public class Controller : BaseController { - public SparkleController () + public Controller () { } @@ -43,7 +39,7 @@ namespace SparkleShare { public override string PresetsPath { get { - return Path.Combine (Path.GetDirectoryName (Assembly.GetExecutingAssembly ().Location), "plugins"); + return Path.Combine (Path.GetDirectoryName (Assembly.GetExecutingAssembly ().Location), "Presets"); } } @@ -55,15 +51,11 @@ namespace SparkleShare { string executable_path = Path.GetDirectoryName (Forms.Application.ExecutablePath); string msysgit_path = Path.Combine (executable_path, "msysgit"); - string new_PATH = msysgit_path + @"\bin" + ";" + - msysgit_path + @"\mingw\bin" + ";" + - msysgit_path + @"\cmd" + ";" + - Environment.ExpandEnvironmentVariables ("%PATH%"); - - Environment.SetEnvironmentVariable ("PATH", new_PATH); Environment.SetEnvironmentVariable ("HOME", Environment.GetFolderPath (Environment.SpecialFolder.UserProfile)); - Sparkles.Git.SparkleGit.SSHPath = Path.Combine (msysgit_path, "bin", "ssh.exe"); + SSHCommand.SSHPath = Path.Combine (msysgit_path, "usr", "bin"); + SSHFetcher.SSHKeyScan = Path.Combine (msysgit_path, "usr", "bin", "ssh-keyscan.exe"); + GitCommand.GitPath = Path.Combine (msysgit_path, "bin", "git.exe"); base.Initialize (); } @@ -71,22 +63,54 @@ namespace SparkleShare { public override string EventLogHTML { get { - string html = SparkleUIHelpers.GetHTML ("event-log.html"); - return html.Replace ("", SparkleUIHelpers.GetHTML ("jquery.js")); + string html = UserInterfaceHelpers.GetHTML ("event-log.html"); + return html.Replace ("", UserInterfaceHelpers.GetHTML ("jquery.js")); } } public override string DayEntryHTML { get { - return SparkleUIHelpers.GetHTML ("day-entry.html"); + return UserInterfaceHelpers.GetHTML ("day-entry.html"); } } public override string EventEntryHTML { get { - return SparkleUIHelpers.GetHTML ("event-entry.html"); + return UserInterfaceHelpers.GetHTML ("event-entry.html"); + } + } + + + public override void SetFolderIcon () + { + string app_path = Path.GetDirectoryName (Forms.Application.ExecutablePath); + string icon_file_path = Path.Combine (app_path, "Images", "sparkleshare-folder.ico"); + + if (!File.Exists (icon_file_path)) + { + string ini_file_path = Path.Combine (FoldersPath, "desktop.ini"); + string n = Environment.NewLine; + + string ini_file = "[.ShellClassInfo]" + n + + "IconFile=" + icon_file_path + n + + "IconIndex=0" + n + + "InfoTip=SparkleShare"; + + try + { + File.Create (ini_file_path).Close (); + File.WriteAllText (ini_file_path, ini_file); + + File.SetAttributes (ini_file_path, + File.GetAttributes (ini_file_path) | FileAttributes.Hidden | FileAttributes.System); + + } + catch (IOException e) + { + Logger.LogInfo ("Config", "Failed setting icon for '" + FoldersPath + "': " + e.Message); + } } } @@ -112,7 +136,7 @@ namespace SparkleShare { } - public override void AddToBookmarks () + public void AddToBookmarks () { string user_profile_path = Environment.GetFolderPath (Environment.SpecialFolder.UserProfile); string shortcut_path = Path.Combine (user_profile_path, "Links", "SparkleShare.lnk"); @@ -125,43 +149,15 @@ namespace SparkleShare { } - public override bool CreateSparkleShareFolder () + public override void CreateSparkleShareFolder () { - if (Directory.Exists (FoldersPath)) - return false; + if (!Directory.Exists (FoldersPath)) + { + Directory.CreateDirectory (FoldersPath); - Directory.CreateDirectory (FoldersPath); - - File.SetAttributes (FoldersPath, File.GetAttributes (FoldersPath) | FileAttributes.System); - SparkleLogger.LogInfo ("Config", "Created '" + FoldersPath + "'"); - - string app_path = Path.GetDirectoryName (Forms.Application.ExecutablePath); - string icon_file_path = Path.Combine (app_path, "Images", "sparkleshare-folder.ico"); - - if (!File.Exists (icon_file_path)) { - string ini_file_path = Path.Combine (FoldersPath, "desktop.ini"); - string n = Environment.NewLine; - - string ini_file = "[.ShellClassInfo]" + n + - "IconFile=" + icon_file_path + n + - "IconIndex=0" + n + - "InfoTip=SparkleShare"; - - try { - File.Create (ini_file_path).Close (); - File.WriteAllText (ini_file_path, ini_file); - - File.SetAttributes (ini_file_path, - File.GetAttributes (ini_file_path) | FileAttributes.Hidden | FileAttributes.System); - - } catch (IOException e) { - SparkleLogger.LogInfo ("Config", "Failed setting icon for '" + FoldersPath + "': " + e.Message); - } - - return true; + File.SetAttributes (FoldersPath, File.GetAttributes(FoldersPath) | FileAttributes.System); + Logger.LogInfo ("Config", "Created '" + FoldersPath + "'"); } - - return false; } @@ -189,7 +185,7 @@ namespace SparkleShare { Clipboard.SetData (DataFormats.Text, text); } catch (COMException e) { - SparkleLogger.LogInfo ("Controller", "Copy to clipboard failed", e); + Logger.LogInfo ("Controller", "Copy to clipboard failed", e); } } diff --git a/SparkleShare/Windows/UserInterface/EventLog.cs b/SparkleShare/Windows/UserInterface/EventLog.cs new file mode 100644 index 00000000..00037124 --- /dev/null +++ b/SparkleShare/Windows/UserInterface/EventLog.cs @@ -0,0 +1,347 @@ +// SparkleShare, a collaboration and sharing tool. +// Copyright (C) 2010 Hylke Bons +// +// 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 . + + +using System; +using System.ComponentModel; +using System.IO; +using System.Security.Permissions; +using System.Runtime.InteropServices; +using System.Windows; +using System.Windows.Controls; +using System.Windows.Media; +using System.Windows.Media.Imaging; +using System.Windows.Shapes; + +using Microsoft.Win32; +using System.Windows.Data; + +namespace SparkleShare +{ + public class EventLog : Window { + + public EventLogController Controller = new EventLogController (); + + private Label label_Size; + private Label label_History; + + private WebBrowser webbrowser; + + private Spinner spinner; + + private ComboBox combobox; + + private Grid grid_Base; + + [DllImport("urlmon.dll")] + [PreserveSig] + [return: MarshalAs(UnmanagedType.Error)] + static extern int CoInternetSetFeatureEnabled(int feature, [MarshalAs(UnmanagedType.U4)] int flags, bool enable); + + public EventLog() + { + CreateEventLog(); + + Background = new SolidColorBrush(Color.FromRgb(240, 240, 240)); + AllowsTransparency = false; + Icon = UserInterfaceHelpers.GetImageSource("sparkleshare-app", "ico"); + WindowStartupLocation = WindowStartupLocation.CenterScreen; + + WriteOutImages(); + + this.label_Size.Content = "Size: " + Controller.Size; + this.label_History.Content = "History: " + Controller.HistorySize; + + this.webbrowser.ObjectForScripting = new SparkleScriptingObject(); + + // Disable annoying IE clicking sound + CoInternetSetFeatureEnabled(21, 0x00000002, true); + + Closing += this.OnClosing; + + Controller.ShowWindowEvent += delegate { + Dispatcher.BeginInvoke((Action)(() => { + Show(); + Activate(); + BringIntoView(); + })); + }; + + Controller.HideWindowEvent += delegate { + Dispatcher.BeginInvoke((Action)(() => { + Hide(); + this.spinner.Visibility = Visibility.Visible; + this.webbrowser.Visibility = Visibility.Collapsed; + })); + }; + + Controller.UpdateSizeInfoEvent += delegate (string size, string history_size) { + Dispatcher.BeginInvoke((Action)(() => { + this.label_Size.Content = "Size: " + size; + this.label_History.Content = "History: " + history_size; + })); + }; + + Controller.UpdateChooserEvent += delegate (string[] folders) { + Dispatcher.BeginInvoke((Action)(() => + UpdateChooser(folders)) + ); + }; + + Controller.UpdateChooserEnablementEvent += delegate (bool enabled) { + Dispatcher.BeginInvoke((Action)(() => + this.combobox.IsEnabled = enabled + )); + }; + + Controller.UpdateContentEvent += delegate (string html) { + Dispatcher.BeginInvoke((Action)(() => { + UpdateContent(html); + + this.spinner.Visibility = Visibility.Collapsed; + this.webbrowser.Visibility = Visibility.Visible; + })); + }; + + Controller.ContentLoadingEvent += () => this.Dispatcher.BeginInvoke( + (Action)(() => { + this.spinner.Visibility = Visibility.Visible; + this.spinner.Start(); + this.webbrowser.Visibility = Visibility.Collapsed; + })); + + Controller.ShowSaveDialogEvent += delegate (string file_name, string target_folder_path) { + Dispatcher.BeginInvoke((Action)(() => { + SaveFileDialog dialog = new SaveFileDialog() + { + FileName = file_name, + InitialDirectory = target_folder_path, + Title = "Restore from History", + DefaultExt = "." + System.IO.Path.GetExtension(file_name), + Filter = "All Files|*.*" + }; + + bool? result = dialog.ShowDialog(this); + + if (result == true) + Controller.SaveDialogCompleted(dialog.FileName); + else + Controller.SaveDialogCancelled(); + })); + }; + } + + + private void CreateEventLog () { + grid_Base = new Grid { Background = Brushes.White }; + + label_Size = new Label { + Content = "Size: ?", + Height = 28, + HorizontalAlignment = HorizontalAlignment.Left, + Margin = new Thickness(20, 0, 0, 0), + FontWeight = FontWeights.Bold + }; + + label_History = new Label { + Content = "History: ?", + Height = 28, + HorizontalAlignment = HorizontalAlignment.Left, + Margin = new Thickness(100, 0, 0, 0), + FontWeight = FontWeights.Bold + }; + + combobox = new ComboBox { + HorizontalAlignment = HorizontalAlignment.Right, + VerticalAlignment = VerticalAlignment.Center, + Margin = new Thickness(0, 0, 6, 0), + MinWidth = 120 + }; + + spinner = new Spinner { Name = "spinner" }; + webbrowser = new WebBrowser { Name = "webbrowser" }; + + Border border = new Border { + VerticalAlignment = VerticalAlignment.Top, + Height = 35, + Background = new SolidColorBrush(Color.FromArgb(255, 240, 240, 240)), + BorderBrush = new SolidColorBrush(Color.FromArgb(255, 223, 223, 223)), + BorderThickness = new Thickness(0, 0, 0, 1) + }; + + Grid borderGrid = new Grid(); + + borderGrid.Children.Add(this.label_Size); + borderGrid.Children.Add(this.label_History); + borderGrid.Children.Add(this.combobox); + + border.Child = borderGrid; + + Grid browserGrid = new Grid { Margin = new Thickness(0, 35, 0, 0) }; + + browserGrid.RowDefinitions.Add(new RowDefinition { Height = new GridLength(1, GridUnitType.Star) }); + browserGrid.RowDefinitions.Add(new RowDefinition { Height = GridLength.Auto }); + + browserGrid.ColumnDefinitions.Add(new ColumnDefinition { Width = new GridLength(1, GridUnitType.Star) }); + browserGrid.ColumnDefinitions.Add(new ColumnDefinition { Width = GridLength.Auto }); + + browserGrid.Children.Add(this.spinner); + browserGrid.Children.Add(this.webbrowser); + + Rectangle sizingControlHeight = new Rectangle { + Name = "sizingControlHeight", + Visibility = Visibility.Hidden + }; + + Grid.SetColumn(sizingControlHeight, 1); + + Rectangle sizingControlWidth = new Rectangle { + Name = "sizingControlHeight", + Visibility = Visibility.Hidden + }; + + Grid.SetColumn(sizingControlWidth, 0); + Grid.SetRow(sizingControlWidth, 0); + + browserGrid.Children.Add(sizingControlHeight); + browserGrid.Children.Add(sizingControlWidth); + + webbrowser.SetBinding(HeightProperty, new Binding("ActualHeightProperty") { ElementName = sizingControlHeight.Name }); + webbrowser.SetBinding(WidthProperty, new Binding("ActualWidthProperty") { ElementName = sizingControlWidth.Name }); + + grid_Base.Children.Add(border); + } + + private void OnClosing(object sender, CancelEventArgs cancel_event_args) + { + Controller.WindowClosed(); + cancel_event_args.Cancel = true; + } + + + private void UpdateContent(string html) + { + string pixmaps_path = System.IO.Path.Combine(Sparkles.Configuration.DefaultConfiguration.TmpPath, "Images"); + pixmaps_path = pixmaps_path.Replace("\\", "/"); + + html = html.Replace("", "Segoe UI"); + html = html.Replace("", "13px"); + html = html.Replace("", "12px"); + html = html.Replace("", "#bbb"); + html = html.Replace("", "#ddd"); + html = html.Replace("", "90%"); + html = html.Replace("", "#f5f5f5"); + html = html.Replace("", "#0085cf"); + html = html.Replace("", "#009ff8"); + html = html.Replace("", pixmaps_path); + html = html.Replace("", pixmaps_path + "/document-added-12.png"); + html = html.Replace("", pixmaps_path + "/document-edited-12.png"); + html = html.Replace("", pixmaps_path + "/document-deleted-12.png"); + html = html.Replace("", pixmaps_path + "/document-moved-12.png"); + + this.spinner.Stop(); + + this.webbrowser.ObjectForScripting = new SparkleScriptingObject(); + this.webbrowser.NavigateToString(html); + } + + + public void UpdateChooser(string[] folders) + { + if (folders == null) + { + folders = Controller.Folders; + } + + this.combobox.Items.Clear(); + this.combobox.Items.Add(new ComboBoxItem() { Content = "Summary" }); + this.combobox.Items.Add(new Separator()); + this.combobox.SelectedItem = combobox.Items[0]; + + int row = 2; + foreach (string folder in folders) + { + this.combobox.Items.Add(new ComboBoxItem() { Content = folder }); + + if (folder.Equals(Controller.SelectedFolder)) + this.combobox.SelectedItem = this.combobox.Items[row]; + + row++; + } + + this.combobox.SelectionChanged += delegate { + Dispatcher.BeginInvoke((Action)delegate { + int index = this.combobox.SelectedIndex; + + if (index == 0) + Controller.SelectedFolder = null; + else + Controller.SelectedFolder = (string)((ComboBoxItem)this.combobox.Items[index]).Content; + }); + }; + } + + + private void WriteOutImages() + { + string tmp_path = Sparkles.Configuration.DefaultConfiguration.TmpPath; + string pixmaps_path = System.IO.Path.Combine(tmp_path, "Images"); + + if (!Directory.Exists(pixmaps_path)) + { + Directory.CreateDirectory(pixmaps_path); + + File.SetAttributes(tmp_path, File.GetAttributes(tmp_path) | FileAttributes.Hidden); + } + + BitmapSource image = UserInterfaceHelpers.GetImageSource("user-icon-default"); + string file_path = System.IO.Path.Combine(pixmaps_path, "user-icon-default.png"); + + using (FileStream stream = new FileStream(file_path, FileMode.Create)) + { + BitmapEncoder encoder = new PngBitmapEncoder(); + encoder.Frames.Add(BitmapFrame.Create(image)); + encoder.Save(stream); + } + + string[] actions = new string[] { "added", "deleted", "edited", "moved" }; + + foreach (string action in actions) + { + image = UserInterfaceHelpers.GetImageSource("document-" + action + "-12"); + file_path = System.IO.Path.Combine(pixmaps_path, "document-" + action + "-12.png"); + + using (FileStream stream = new FileStream(file_path, FileMode.Create)) + { + BitmapEncoder encoder = new PngBitmapEncoder(); + encoder.Frames.Add(BitmapFrame.Create(image)); + encoder.Save(stream); + } + } + } + } + + [PermissionSet(SecurityAction.Demand, Name = "FullTrust")] + [ComVisible(true)] + public class SparkleScriptingObject + { + public void LinkClicked(string url) + { + SparkleShare.UI.EventLog.Controller.LinkClicked(url); + } + } +} \ No newline at end of file diff --git a/SparkleShare/Windows/SparkleNote.xaml b/SparkleShare/Windows/UserInterface/Note.xaml similarity index 94% rename from SparkleShare/Windows/SparkleNote.xaml rename to SparkleShare/Windows/UserInterface/Note.xaml index 355b2cd2..2d39a248 100644 --- a/SparkleShare/Windows/SparkleNote.xaml +++ b/SparkleShare/Windows/UserInterface/Note.xaml @@ -1,4 +1,4 @@ - - + diff --git a/SparkleShare/Windows/SparkleNote.xaml.cs b/SparkleShare/Windows/UserInterface/Note.xaml.cs similarity index 90% rename from SparkleShare/Windows/SparkleNote.xaml.cs rename to SparkleShare/Windows/UserInterface/Note.xaml.cs index f5631905..d90caa0f 100644 --- a/SparkleShare/Windows/SparkleNote.xaml.cs +++ b/SparkleShare/Windows/UserInterface/Note.xaml.cs @@ -26,19 +26,19 @@ using Sparkles; namespace SparkleShare { - public partial class SparkleNote : Window { + public partial class Note : Window { - public SparkleNoteController Controller = new SparkleNoteController (); + public NoteController Controller = new NoteController (); private readonly string default_text = "Anything to add?"; - public SparkleNote() + public Note () { InitializeComponent(); Background = new SolidColorBrush(Color.FromRgb(240, 240, 240)); AllowsTransparency = false; - Icon = SparkleUIHelpers.GetImageSource("sparkleshare-app", "ico"); + Icon = UserInterfaceHelpers.GetImageSource("sparkleshare-app", "ico"); WindowStartupLocation = WindowStartupLocation.CenterScreen; Closing += this.OnClosing; @@ -85,10 +85,10 @@ namespace SparkleShare { private void CreateNote() { - ImageSource avatar = SparkleUIHelpers.GetImageSource("user-icon-default"); + ImageSource avatar = UserInterfaceHelpers.GetImageSource("user-icon-default"); if (File.Exists (Controller.AvatarFilePath)) { - avatar = SparkleUIHelpers.GetImage (Controller.AvatarFilePath); + avatar = UserInterfaceHelpers.GetImage (Controller.AvatarFilePath); } this.user_image.ImageSource = avatar; diff --git a/SparkleShare/Windows/SparkleNotifyIcon.cs b/SparkleShare/Windows/UserInterface/NotifyIcon.cs similarity index 79% rename from SparkleShare/Windows/SparkleNotifyIcon.cs rename to SparkleShare/Windows/UserInterface/NotifyIcon.cs index d8730179..e7397f60 100644 --- a/SparkleShare/Windows/SparkleNotifyIcon.cs +++ b/SparkleShare/Windows/UserInterface/NotifyIcon.cs @@ -1,188 +1,188 @@ -// SparkleShare, a collaboration and sharing tool. -// Copyright (C) 2010 Hylke Bons -// -// 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 . - - -using System; -using System.ComponentModel; -using System.Runtime.InteropServices; -using System.Windows; -using System.Windows.Controls; -using System.Windows.Input; -using System.Windows.Markup; - -using Drawing = System.Drawing; -using Forms = System.Windows.Forms; - -namespace SparkleShare { - - [ContentProperty("Text")] - [DefaultEvent("MouseDoubleClick")] - public class SparkleNotifyIcon : UIElement, IAddChild { - - [DllImport("user32.dll", EntryPoint = "DestroyIcon")] - static extern bool DestroyIcon(IntPtr h_icon); - - public Drawing.Bitmap Icon { - set { - NotifyIcon.Icon = GetIconFromBitmap(value); - } - } - - public string Text { - get { - return (string) GetValue(TextProperty); - } - set { - var text = value; - - if(!string.IsNullOrEmpty(HeaderText)) - text = HeaderText + "\n" + text; - - SetValue(TextProperty, text); - } - } - - public ContextMenu ContextMenu { - get; - set; - } - - public string HeaderText { - get; - set; - } - - private Forms.NotifyIcon NotifyIcon { - get; - set; - } - - public readonly RoutedEvent MouseClickEvent = EventManager.RegisterRoutedEvent( - "MouseClick", RoutingStrategy.Bubble, typeof(MouseButtonEventHandler), typeof(SparkleNotifyIcon)); - - public readonly RoutedEvent MouseDoubleClickEvent = EventManager.RegisterRoutedEvent( - "MouseDoubleClick", RoutingStrategy.Bubble, typeof(MouseButtonEventHandler), typeof(SparkleNotifyIcon)); - - public readonly DependencyProperty TextProperty = DependencyProperty.Register( - "Text", typeof(string), typeof(SparkleNotifyIcon), new PropertyMetadata(OnTextChanged)); - - public SparkleNotifyIcon() { - VisibilityProperty.OverrideMetadata(typeof(SparkleNotifyIcon), new PropertyMetadata(OnVisibilityChanged)); - - NotifyIcon = new Forms.NotifyIcon { - Text = Text, - Visible = true, - ContextMenu = new Forms.ContextMenu() - }; - NotifyIcon.MouseDown += OnMouseDown; - NotifyIcon.MouseUp += OnMouseUp; - NotifyIcon.MouseClick += OnMouseClick; - NotifyIcon.MouseDoubleClick += OnMouseDoubleClick; - } - - public void ShowBalloonTip(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 - NotifyIcon.ShowBalloonTip(5 * 1000, title, subtext, Forms.ToolTipIcon.Info); - } - - public void Dispose() { - NotifyIcon.Dispose(); - } - - - void IAddChild.AddChild(object value) { - throw new InvalidOperationException(); - } - - void IAddChild.AddText(string text) { - if(text == null) - throw new ArgumentNullException(); - - Text = text; - } - - private static MouseButtonEventArgs CreateMouseButtonEventArgs(RoutedEvent handler, Forms.MouseButtons button) { - MouseButton mouse_button; - - if(button == Forms.MouseButtons.Left) { - mouse_button = MouseButton.Left; - - } else if(button == Forms.MouseButtons.Right) { - mouse_button = MouseButton.Right; - - } else if(button == Forms.MouseButtons.Middle) { - mouse_button = MouseButton.Middle; - - } else if(button == Forms.MouseButtons.XButton1) { - mouse_button = MouseButton.XButton1; - - } else if(button == Forms.MouseButtons.XButton2) { - mouse_button = MouseButton.XButton2; - - } else { - throw new InvalidOperationException(); - } - - return new MouseButtonEventArgs(InputManager.Current.PrimaryMouseDevice, 0, mouse_button) { - RoutedEvent = handler - }; - } - - private void OnVisibilityChanged(DependencyObject target, DependencyPropertyChangedEventArgs args) { - SparkleNotifyIcon control = (SparkleNotifyIcon) target; - control.NotifyIcon.Visible = (control.Visibility == Visibility.Visible); - } - - private void OnMouseDown(object sender, Forms.MouseEventArgs args) { - RaiseEvent(CreateMouseButtonEventArgs(MouseDownEvent, args.Button)); - } - - private void OnMouseClick(object sender, Forms.MouseEventArgs args) { - RaiseEvent(CreateMouseButtonEventArgs(MouseClickEvent, args.Button)); - } - - private void OnMouseDoubleClick(object sender, Forms.MouseEventArgs args) { - RaiseEvent(CreateMouseButtonEventArgs(MouseDoubleClickEvent, args.Button)); - } - - private void OnMouseUp(object sender, Forms.MouseEventArgs args) { - - if(args.Button == Forms.MouseButtons.Right) { - - ContextMenu.IsOpen = true; - ContextMenu.StaysOpen = false; - } - - RaiseEvent(CreateMouseButtonEventArgs(MouseUpEvent, args.Button)); - } - - private static void OnTextChanged(DependencyObject target, DependencyPropertyChangedEventArgs args) { - SparkleNotifyIcon control = (SparkleNotifyIcon) target; - control.NotifyIcon.Text = control.Text; - } - - - private static Drawing.Icon GetIconFromBitmap(Drawing.Bitmap bitmap) { - IntPtr unmanaged_icon = bitmap.GetHicon(); - Drawing.Icon icon = (Drawing.Icon) Drawing.Icon.FromHandle(unmanaged_icon).Clone(); - DestroyIcon(unmanaged_icon); - - return icon; - } - } -} +// SparkleShare, a collaboration and sharing tool. +// Copyright (C) 2010 Hylke Bons +// +// 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 . + + +using System; +using System.ComponentModel; +using System.Runtime.InteropServices; +using System.Windows; +using System.Windows.Controls; +using System.Windows.Input; +using System.Windows.Markup; + +using Drawing = System.Drawing; +using Forms = System.Windows.Forms; + +namespace SparkleShare { + + [ContentProperty("Text")] + [DefaultEvent("MouseDoubleClick")] + public class NotifyIcon : UIElement, IAddChild { + + [DllImport("user32.dll", EntryPoint = "DestroyIcon")] + static extern bool DestroyIcon(IntPtr h_icon); + + public Drawing.Bitmap Icon { + set { + Notification.Icon = GetIconFromBitmap(value); + } + } + + public string Text { + get { + return (string) GetValue(TextProperty); + } + set { + var text = value; + + if(!string.IsNullOrEmpty(HeaderText)) + text = HeaderText + "\n" + text; + + SetValue(TextProperty, text); + } + } + + public ContextMenu ContextMenu { + get; + set; + } + + public string HeaderText { + get; + set; + } + + private Forms.NotifyIcon Notification { + get; + set; + } + + public readonly RoutedEvent MouseClickEvent = EventManager.RegisterRoutedEvent( + "MouseClick", RoutingStrategy.Bubble, typeof(MouseButtonEventHandler), typeof(NotifyIcon)); + + public readonly RoutedEvent MouseDoubleClickEvent = EventManager.RegisterRoutedEvent( + "MouseDoubleClick", RoutingStrategy.Bubble, typeof(MouseButtonEventHandler), typeof(NotifyIcon)); + + public readonly DependencyProperty TextProperty = DependencyProperty.Register( + "Text", typeof(string), typeof(NotifyIcon), new PropertyMetadata(OnTextChanged)); + + public NotifyIcon() { + VisibilityProperty.OverrideMetadata(typeof(NotifyIcon), new PropertyMetadata(OnVisibilityChanged)); + + Notification = new Forms.NotifyIcon { + Text = Text, + Visible = true, + ContextMenu = new Forms.ContextMenu() + }; + Notification.MouseDown += OnMouseDown; + Notification.MouseUp += OnMouseUp; + Notification.MouseClick += OnMouseClick; + Notification.MouseDoubleClick += OnMouseDoubleClick; + } + + public void ShowBalloonTip(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 + Notification.ShowBalloonTip(5 * 1000, title, subtext, Forms.ToolTipIcon.Info); + } + + public void Dispose() { + Notification.Dispose(); + } + + + void IAddChild.AddChild(object value) { + throw new InvalidOperationException(); + } + + void IAddChild.AddText(string text) { + if(text == null) + throw new ArgumentNullException(); + + Text = text; + } + + private static MouseButtonEventArgs CreateMouseButtonEventArgs(RoutedEvent handler, Forms.MouseButtons button) { + MouseButton mouse_button; + + if(button == Forms.MouseButtons.Left) { + mouse_button = MouseButton.Left; + + } else if(button == Forms.MouseButtons.Right) { + mouse_button = MouseButton.Right; + + } else if(button == Forms.MouseButtons.Middle) { + mouse_button = MouseButton.Middle; + + } else if(button == Forms.MouseButtons.XButton1) { + mouse_button = MouseButton.XButton1; + + } else if(button == Forms.MouseButtons.XButton2) { + mouse_button = MouseButton.XButton2; + + } else { + throw new InvalidOperationException(); + } + + return new MouseButtonEventArgs(InputManager.Current.PrimaryMouseDevice, 0, mouse_button) { + RoutedEvent = handler + }; + } + + private void OnVisibilityChanged(DependencyObject target, DependencyPropertyChangedEventArgs args) { + NotifyIcon control = (NotifyIcon) target; + control.Notification.Visible = (control.Visibility == Visibility.Visible); + } + + private void OnMouseDown(object sender, Forms.MouseEventArgs args) { + RaiseEvent(CreateMouseButtonEventArgs(MouseDownEvent, args.Button)); + } + + private void OnMouseClick(object sender, Forms.MouseEventArgs args) { + RaiseEvent(CreateMouseButtonEventArgs(MouseClickEvent, args.Button)); + } + + private void OnMouseDoubleClick(object sender, Forms.MouseEventArgs args) { + RaiseEvent(CreateMouseButtonEventArgs(MouseDoubleClickEvent, args.Button)); + } + + private void OnMouseUp(object sender, Forms.MouseEventArgs args) { + + if(args.Button == Forms.MouseButtons.Right) { + + ContextMenu.IsOpen = true; + ContextMenu.StaysOpen = false; + } + + RaiseEvent(CreateMouseButtonEventArgs(MouseUpEvent, args.Button)); + } + + private static void OnTextChanged(DependencyObject target, DependencyPropertyChangedEventArgs args) { + NotifyIcon control = (NotifyIcon) target; + control.Notification.Text = control.Text; + } + + + private static Drawing.Icon GetIconFromBitmap(Drawing.Bitmap bitmap) { + IntPtr unmanaged_icon = bitmap.GetHicon(); + Drawing.Icon icon = (Drawing.Icon) Drawing.Icon.FromHandle(unmanaged_icon).Clone(); + DestroyIcon(unmanaged_icon); + + return icon; + } + } +} diff --git a/SparkleShare/Windows/SparkleSetup.cs b/SparkleShare/Windows/UserInterface/Setup.cs similarity index 81% rename from SparkleShare/Windows/SparkleSetup.cs rename to SparkleShare/Windows/UserInterface/Setup.cs index 1cd7b6cf..33eef79a 100644 --- a/SparkleShare/Windows/SparkleSetup.cs +++ b/SparkleShare/Windows/UserInterface/Setup.cs @@ -15,33 +15,27 @@ // along with this program. If not, see . +using Sparkles; using System; -using System.Collections.Generic; -using System.ComponentModel; -using System.IO; -using System.Media; using System.Windows; using System.Windows.Controls; -using System.Windows.Data; using System.Windows.Documents; using System.Windows.Markup; using System.Windows.Media; using System.Windows.Media.Imaging; -using System.Windows.Navigation; using System.Windows.Shell; using Drawing = System.Drawing; using Imaging = System.Windows.Interop.Imaging; -using WPF = System.Windows.Controls; namespace SparkleShare { - public class SparkleSetup : SparkleSetupWindow { + public class Setup : SetupWindow { - public SparkleSetupController Controller = new SparkleSetupController (); + public SetupController Controller = new SetupController (); - public SparkleSetup () + public Setup () { Controller.ShowWindowEvent += delegate { Dispatcher.BeginInvoke ((Action) delegate { @@ -268,7 +262,7 @@ namespace SparkleShare { header_style.Setters.Add (new Setter (GridViewColumnHeader.VisibilityProperty, Visibility.Collapsed)); grid_view.ColumnHeaderContainerStyle = header_style; - foreach (SparklePreset plugin in Controller.Presets) { + foreach (Preset plugin in Controller.Presets) { // FIXME: images are blurry BitmapFrame image = BitmapFrame.Create ( new Uri (plugin.ImagePath) @@ -814,167 +808,6 @@ namespace SparkleShare { break; } - - case PageType.Tutorial: { - switch (Controller.TutorialPageNumber) { - case 1: { - Header = "What’s happening next?"; - Description = "SparkleShare creates a special folder on your computer " + - "that will keep track of your projects."; - - - WPF.Image slide_image = new WPF.Image () { - Width = 324, - Height = 200 - }; - - slide_image.Source = SparkleUIHelpers.GetImageSource ("tutorial-slide-1"); - - Button skip_tutorial_button = new Button () { - Content = "Skip tutorial" - }; - - Button continue_button = new Button () { - Content = "Continue" - }; - - - ContentCanvas.Children.Add (slide_image); - Canvas.SetLeft (slide_image, 228); - Canvas.SetTop (slide_image, 130); - - Buttons.Add (skip_tutorial_button); - Buttons.Add (continue_button); - - - skip_tutorial_button.Click += delegate { - Controller.TutorialSkipped (); - }; - - continue_button.Click += delegate { - Controller.TutorialPageCompleted (); - }; - - break; - } - - case 2: { - Header = "Sharing files with others"; - Description = "All files added to your project folders are synced automatically with " + - "the host and your team members."; - - - Button continue_button = new Button () { - Content = "Continue" - }; - - WPF.Image slide_image = new WPF.Image () { - Width = 324, - Height = 200 - }; - - slide_image.Source = SparkleUIHelpers.GetImageSource ("tutorial-slide-2"); - - - ContentCanvas.Children.Add (slide_image); - Canvas.SetLeft (slide_image, 228); - Canvas.SetTop (slide_image, 130); - - Buttons.Add (continue_button); - - - continue_button.Click += delegate { - Controller.TutorialPageCompleted (); - }; - - break; - } - - case 3: { - Header = "The status icon helps you"; - Description = "It shows the syncing progress, provides easy access to " + - "your projects, and lets you view recent changes."; - - Button continue_button = new Button () { - Content = "Continue" - }; - - WPF.Image slide_image = new WPF.Image () { - Width = 324, - Height = 200 - }; - - slide_image.Source = SparkleUIHelpers.GetImageSource ("tutorial-slide-3"); - - - ContentCanvas.Children.Add (slide_image); - Canvas.SetLeft (slide_image, 228); - Canvas.SetTop (slide_image, 130); - - Buttons.Add (continue_button); - - - continue_button.Click += delegate { - Controller.TutorialPageCompleted (); - }; - - break; - } - - case 4: { - Header = "Here’s your unique Client ID"; - Description = "You’ll need it whenever you want to link this computer to a host. " + - "You can also find it in the status icon menu."; - - - TextBox link_code_text_box = new TextBox () { - Text = SparkleShare.Controller.CurrentUser.PublicKey, - Width = 250, - MaxLines = 1, - TextWrapping = TextWrapping.NoWrap, - IsEnabled = false - }; - - Button copy_button = new Button () { - Content = "Copy", - Width = 60 - }; - - Button finish_button = new Button () { - Content = "Finish" - }; - - CheckBox check_box = new CheckBox () { - Content = "Add SparkleShare to startup items", - IsChecked = true - }; - - - ContentCanvas.Children.Add (link_code_text_box); - Canvas.SetLeft (link_code_text_box, 235); - Canvas.SetTop (link_code_text_box, 190); - - ContentCanvas.Children.Add (copy_button); - Canvas.SetLeft (copy_button, 490); - Canvas.SetTop (copy_button, 190); - - ContentCanvas.Children.Add (check_box); - Canvas.SetLeft (check_box, 185); - Canvas.SetBottom (check_box, 12); - - Buttons.Add (finish_button); - - - check_box.Click += delegate { Controller.StartupItemChanged (check_box.IsChecked.Value); }; - finish_button.Click += delegate { Controller.TutorialPageCompleted (); }; - copy_button.Click += delegate { Controller.CopyToClipboardClicked(); }; - - break; - } - } - - break; - } } ShowAll (); diff --git a/SparkleShare/Windows/SparkleSetupWindow.cs b/SparkleShare/Windows/UserInterface/SetupWindow.cs similarity index 93% rename from SparkleShare/Windows/SparkleSetupWindow.cs rename to SparkleShare/Windows/UserInterface/SetupWindow.cs index 87607e24..2e756052 100644 --- a/SparkleShare/Windows/SparkleSetupWindow.cs +++ b/SparkleShare/Windows/UserInterface/SetupWindow.cs @@ -1,193 +1,193 @@ -// 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.Collections.Generic; -using System.ComponentModel; -using System.Windows; -using System.Windows.Controls; -using System.Windows.Forms.Integration; -using System.Windows.Media; -using System.Windows.Shapes; -using System.Windows.Shell; -using System.Runtime.InteropServices; -using System.Windows.Interop; - -namespace SparkleShare { - - public class SparkleSetupWindow : Window { - - public Canvas ContentCanvas = new Canvas (); - public List