diff --git a/SparkleLib/SparkleConfig.cs b/SparkleLib/SparkleConfig.cs index 8e02e978..7d901f11 100755 --- a/SparkleLib/SparkleConfig.cs +++ b/SparkleLib/SparkleConfig.cs @@ -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 { diff --git a/SparkleLib/SparkleFetcherBase.cs b/SparkleLib/SparkleFetcherBase.cs index 1c6d3cdb..12865fdd 100755 --- a/SparkleLib/SparkleFetcherBase.cs +++ b/SparkleLib/SparkleFetcherBase.cs @@ -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; } } } diff --git a/SparkleLib/SparkleHelpers.cs b/SparkleLib/SparkleHelpers.cs index e86424ab..3012a4f4 100755 --- a/SparkleLib/SparkleHelpers.cs +++ b/SparkleLib/SparkleHelpers.cs @@ -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, ""); diff --git a/SparkleLib/SparkleListenerTcp.cs b/SparkleLib/SparkleListenerTcp.cs index 1810a065..762c67eb 100755 --- a/SparkleLib/SparkleListenerTcp.cs +++ b/SparkleLib/SparkleListenerTcp.cs @@ -247,7 +247,7 @@ namespace SparkleLib { this.thread.Join (); if (this.socket != null) - this.socket.Close (); + this.socket.Close (); base.Dispose (); } diff --git a/SparkleLib/SparkleRepoBase.cs b/SparkleLib/SparkleRepoBase.cs index ec4b515b..5c862d54 100755 --- a/SparkleLib/SparkleRepoBase.cs +++ b/SparkleLib/SparkleRepoBase.cs @@ -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 (@"(.+).*" + "(.+).*" + @@ -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); } diff --git a/SparkleShare/SparkleControllerBase.cs b/SparkleShare/SparkleControllerBase.cs index 58f4aa26..1fb314c9 100644 --- a/SparkleShare/SparkleControllerBase.cs +++ b/SparkleShare/SparkleControllerBase.cs @@ -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) diff --git a/SparkleShare/SparkleOptions.cs b/SparkleShare/SparkleOptions.cs index ea321f0e..4e835073 100644 --- a/SparkleShare/SparkleOptions.cs +++ b/SparkleShare/SparkleOptions.cs @@ -149,953 +149,953 @@ namespace NDesk.Options namespace SparkleShare #endif { - public class OptionValueCollection : IList, IList { - - List values = new List (); - OptionContext c; - - internal OptionValueCollection (OptionContext c) - { - this.c = c; - } - - #region ICollection - void ICollection.CopyTo (Array array, int index) {(values as ICollection).CopyTo (array, index);} - bool ICollection.IsSynchronized {get {return (values as ICollection).IsSynchronized;}} - object ICollection.SyncRoot {get {return (values as ICollection).SyncRoot;}} - #endregion - - #region ICollection - public void Add (string item) {values.Add (item);} - public void Clear () {values.Clear ();} - public bool Contains (string item) {return values.Contains (item);} - public void CopyTo (string[] array, int arrayIndex) {values.CopyTo (array, arrayIndex);} - public bool Remove (string item) {return values.Remove (item);} - public int Count {get {return values.Count;}} - public bool IsReadOnly {get {return false;}} - #endregion - - #region IEnumerable - IEnumerator IEnumerable.GetEnumerator () {return values.GetEnumerator ();} - #endregion - - #region IEnumerable - public IEnumerator GetEnumerator () {return values.GetEnumerator ();} - #endregion - - #region IList - int IList.Add (object value) {return (values as IList).Add (value);} - bool IList.Contains (object value) {return (values as IList).Contains (value);} - int IList.IndexOf (object value) {return (values as IList).IndexOf (value);} - void IList.Insert (int index, object value) {(values as IList).Insert (index, value);} - void IList.Remove (object value) {(values as IList).Remove (value);} - void IList.RemoveAt (int index) {(values as IList).RemoveAt (index);} - bool IList.IsFixedSize {get {return false;}} - object IList.this [int index] {get {return this [index];} set {(values as IList)[index] = value;}} - #endregion - - #region IList - public int IndexOf (string item) {return values.IndexOf (item);} - public void Insert (int index, string item) {values.Insert (index, item);} - public void RemoveAt (int index) {values.RemoveAt (index);} - - private void AssertValid (int index) - { - if (c.Option == null) - throw new InvalidOperationException ("OptionContext.Option is null."); - if (index >= c.Option.MaxValueCount) - throw new ArgumentOutOfRangeException ("index"); - if (c.Option.OptionValueType == OptionValueType.Required && - index >= values.Count) - throw new OptionException (string.Format ( - c.OptionSet.MessageLocalizer ("Missing required value for option '{0}'."), c.OptionName), - c.OptionName); - } - - public string this [int index] { - get { - AssertValid (index); - return index >= values.Count ? null : values [index]; - } - set { - values [index] = value; - } - } - #endregion - - public List ToList () - { - return new List (values); - } - - public string[] ToArray () - { - return values.ToArray (); - } - - public override string ToString () - { - return string.Join (", ", values.ToArray ()); - } - } - - public class OptionContext { - private Option option; - private string name; - private int index; - private OptionSet set; - private OptionValueCollection c; - - public OptionContext (OptionSet set) - { - this.set = set; - this.c = new OptionValueCollection (this); - } - - public Option Option { - get {return option;} - set {option = value;} - } - - public string OptionName { - get {return name;} - set {name = value;} - } - - public int OptionIndex { - get {return index;} - set {index = value;} - } - - public OptionSet OptionSet { - get {return set;} - } - - public OptionValueCollection OptionValues { - get {return c;} - } - } - - public enum OptionValueType { - None, - Optional, - Required, - } - - public abstract class Option { - string prototype, description; - string[] names; - OptionValueType type; - int count; - string[] separators; - - protected Option (string prototype, string description) - : this (prototype, description, 1) - { - } - - protected Option (string prototype, string description, int maxValueCount) - { - if (prototype == null) - throw new ArgumentNullException ("prototype"); - if (prototype.Length == 0) - throw new ArgumentException ("Cannot be the empty string.", "prototype"); - if (maxValueCount < 0) - throw new ArgumentOutOfRangeException ("maxValueCount"); - - this.prototype = prototype; - this.names = prototype.Split ('|'); - this.description = description; - this.count = maxValueCount; - this.type = ParsePrototype (); - - if (this.count == 0 && type != OptionValueType.None) - throw new ArgumentException ( - "Cannot provide maxValueCount of 0 for OptionValueType.Required or " + - "OptionValueType.Optional.", - "maxValueCount"); - if (this.type == OptionValueType.None && maxValueCount > 1) - throw new ArgumentException ( - string.Format ("Cannot provide maxValueCount of {0} for OptionValueType.None.", maxValueCount), - "maxValueCount"); - if (Array.IndexOf (names, "<>") >= 0 && - ((names.Length == 1 && this.type != OptionValueType.None) || - (names.Length > 1 && this.MaxValueCount > 1))) - throw new ArgumentException ( - "The default option handler '<>' cannot require values.", - "prototype"); - } - - public string Prototype {get {return prototype;}} - public string Description {get {return description;}} - public OptionValueType OptionValueType {get {return type;}} - public int MaxValueCount {get {return count;}} - - public string[] GetNames () - { - return (string[]) names.Clone (); - } - - public string[] GetValueSeparators () - { - if (separators == null) - return new string [0]; - return (string[]) separators.Clone (); - } - - protected static T Parse (string value, OptionContext c) - { - Type tt = typeof (T); - bool nullable = tt.IsValueType && tt.IsGenericType && - !tt.IsGenericTypeDefinition && - tt.GetGenericTypeDefinition () == typeof (Nullable<>); - Type targetType = nullable ? tt.GetGenericArguments () [0] : typeof (T); - TypeConverter conv = TypeDescriptor.GetConverter (targetType); - T t = default (T); - try { - if (value != null) - t = (T) conv.ConvertFromString (value); - } - catch (Exception e) { - throw new OptionException ( - string.Format ( - c.OptionSet.MessageLocalizer ("Could not convert string `{0}' to type {1} for option `{2}'."), - value, targetType.Name, c.OptionName), - c.OptionName, e); - } - return t; - } - - internal string[] Names {get {return names;}} - internal string[] ValueSeparators {get {return separators;}} - - static readonly char[] NameTerminator = new char[]{'=', ':'}; - - private OptionValueType ParsePrototype () - { - char type = '\0'; - List seps = new List (); - for (int i = 0; i < names.Length; ++i) { - string name = names [i]; - if (name.Length == 0) - throw new ArgumentException ("Empty option names are not supported.", "prototype"); - - int end = name.IndexOfAny (NameTerminator); - if (end == -1) - continue; - names [i] = name.Substring (0, end); - if (type == '\0' || type == name [end]) - type = name [end]; - else - throw new ArgumentException ( - string.Format ("Conflicting option types: '{0}' vs. '{1}'.", type, name [end]), - "prototype"); - AddSeparators (name, end, seps); - } - - if (type == '\0') - return OptionValueType.None; - - if (count <= 1 && seps.Count != 0) - throw new ArgumentException ( - string.Format ("Cannot provide key/value separators for Options taking {0} value(s).", count), - "prototype"); - if (count > 1) { - if (seps.Count == 0) - this.separators = new string[]{":", "="}; - else if (seps.Count == 1 && seps [0].Length == 0) - this.separators = null; - else - this.separators = seps.ToArray (); - } - - return type == '=' ? OptionValueType.Required : OptionValueType.Optional; - } - - private static void AddSeparators (string name, int end, ICollection seps) - { - int start = -1; - for (int i = end+1; i < name.Length; ++i) { - switch (name [i]) { - case '{': - if (start != -1) - throw new ArgumentException ( - string.Format ("Ill-formed name/value separator found in \"{0}\".", name), - "prototype"); - start = i+1; - break; - case '}': - if (start == -1) - throw new ArgumentException ( - string.Format ("Ill-formed name/value separator found in \"{0}\".", name), - "prototype"); - seps.Add (name.Substring (start, i-start)); - start = -1; - break; - default: - if (start == -1) - seps.Add (name [i].ToString ()); - break; - } - } - if (start != -1) - throw new ArgumentException ( - string.Format ("Ill-formed name/value separator found in \"{0}\".", name), - "prototype"); - } - - public void Invoke (OptionContext c) - { - OnParseComplete (c); - c.OptionName = null; - c.Option = null; - c.OptionValues.Clear (); - } - - protected abstract void OnParseComplete (OptionContext c); - - public override string ToString () - { - return Prototype; - } - } - - [Serializable] - public class OptionException : Exception { - private string option; - - public OptionException () - { - } - - public OptionException (string message, string optionName) - : base (message) - { - this.option = optionName; - } - - public OptionException (string message, string optionName, Exception innerException) - : base (message, innerException) - { - this.option = optionName; - } - - protected OptionException (SerializationInfo info, StreamingContext context) - : base (info, context) - { - this.option = info.GetString ("OptionName"); - } - - public string OptionName { - get {return this.option;} - } - - [SecurityPermission (SecurityAction.LinkDemand, SerializationFormatter = true)] - public override void GetObjectData (SerializationInfo info, StreamingContext context) - { - base.GetObjectData (info, context); - info.AddValue ("OptionName", option); - } - } - - public delegate void OptionAction (TKey key, TValue value); - - public class OptionSet : KeyedCollection - { - public OptionSet () - : this (delegate (string f) {return f;}) - { - } - - public OptionSet (Converter localizer) - { - this.localizer = localizer; - } - - Converter localizer; - - public Converter MessageLocalizer { - get {return localizer;} - } - - protected override string GetKeyForItem (Option item) - { - if (item == null) - throw new ArgumentNullException ("option"); - if (item.Names != null && item.Names.Length > 0) - return item.Names [0]; - // This should never happen, as it's invalid for Option to be - // constructed w/o any names. - throw new InvalidOperationException ("Option has no names!"); - } - - [Obsolete ("Use KeyedCollection.this[string]")] - protected Option GetOptionForName (string option) - { - if (option == null) - throw new ArgumentNullException ("option"); - try { - return base [option]; - } - catch (KeyNotFoundException) { - return null; - } - } - - protected override void InsertItem (int index, Option item) - { - base.InsertItem (index, item); - AddImpl (item); - } - - protected override void RemoveItem (int index) - { - base.RemoveItem (index); - Option p = Items [index]; - // KeyedCollection.RemoveItem() handles the 0th item - for (int i = 1; i < p.Names.Length; ++i) { - Dictionary.Remove (p.Names [i]); - } - } - - protected override void SetItem (int index, Option item) - { - base.SetItem (index, item); - RemoveItem (index); - AddImpl (item); - } - - private void AddImpl (Option option) - { - if (option == null) - throw new ArgumentNullException ("option"); - List added = new List (option.Names.Length); - try { - // KeyedCollection.InsertItem/SetItem handle the 0th name. - for (int i = 1; i < option.Names.Length; ++i) { - Dictionary.Add (option.Names [i], option); - added.Add (option.Names [i]); - } - } - catch (Exception) { - foreach (string name in added) - Dictionary.Remove (name); - throw; - } - } - - public new OptionSet Add (Option option) - { - base.Add (option); - return this; - } - - sealed class ActionOption : Option { - Action action; - - public ActionOption (string prototype, string description, int count, Action action) - : base (prototype, description, count) - { - if (action == null) - throw new ArgumentNullException ("action"); - this.action = action; - } - - protected override void OnParseComplete (OptionContext c) - { - action (c.OptionValues); - } - } - - public OptionSet Add (string prototype, Action action) - { - return Add (prototype, null, action); - } - - public OptionSet Add (string prototype, string description, Action action) - { - if (action == null) - throw new ArgumentNullException ("action"); - Option p = new ActionOption (prototype, description, 1, - delegate (OptionValueCollection v) { action (v [0]); }); - base.Add (p); - return this; - } - - public OptionSet Add (string prototype, OptionAction action) - { - return Add (prototype, null, action); - } - - public OptionSet Add (string prototype, string description, OptionAction action) - { - if (action == null) - throw new ArgumentNullException ("action"); - Option p = new ActionOption (prototype, description, 2, - delegate (OptionValueCollection v) {action (v [0], v [1]);}); - base.Add (p); - return this; - } - - sealed class ActionOption : Option { - Action action; - - public ActionOption (string prototype, string description, Action action) - : base (prototype, description, 1) - { - if (action == null) - throw new ArgumentNullException ("action"); - this.action = action; - } - - protected override void OnParseComplete (OptionContext c) - { - action (Parse (c.OptionValues [0], c)); - } - } - - sealed class ActionOption : Option { - OptionAction action; - - public ActionOption (string prototype, string description, OptionAction action) - : base (prototype, description, 2) - { - if (action == null) - throw new ArgumentNullException ("action"); - this.action = action; - } - - protected override void OnParseComplete (OptionContext c) - { - action ( - Parse (c.OptionValues [0], c), - Parse (c.OptionValues [1], c)); - } - } - - public OptionSet Add (string prototype, Action action) - { - return Add (prototype, null, action); - } - - public OptionSet Add (string prototype, string description, Action action) - { - return Add (new ActionOption (prototype, description, action)); - } - - public OptionSet Add (string prototype, OptionAction action) - { - return Add (prototype, null, action); - } - - public OptionSet Add (string prototype, string description, OptionAction action) - { - return Add (new ActionOption (prototype, description, action)); - } - - protected virtual OptionContext CreateOptionContext () - { - return new OptionContext (this); - } + public class OptionValueCollection : IList, IList { + + List values = new List (); + OptionContext c; + + internal OptionValueCollection (OptionContext c) + { + this.c = c; + } + + #region ICollection + void ICollection.CopyTo (Array array, int index) {(values as ICollection).CopyTo (array, index);} + bool ICollection.IsSynchronized {get {return (values as ICollection).IsSynchronized;}} + object ICollection.SyncRoot {get {return (values as ICollection).SyncRoot;}} + #endregion + + #region ICollection + public void Add (string item) {values.Add (item);} + public void Clear () {values.Clear ();} + public bool Contains (string item) {return values.Contains (item);} + public void CopyTo (string[] array, int arrayIndex) {values.CopyTo (array, arrayIndex);} + public bool Remove (string item) {return values.Remove (item);} + public int Count {get {return values.Count;}} + public bool IsReadOnly {get {return false;}} + #endregion + + #region IEnumerable + IEnumerator IEnumerable.GetEnumerator () {return values.GetEnumerator ();} + #endregion + + #region IEnumerable + public IEnumerator GetEnumerator () {return values.GetEnumerator ();} + #endregion + + #region IList + int IList.Add (object value) {return (values as IList).Add (value);} + bool IList.Contains (object value) {return (values as IList).Contains (value);} + int IList.IndexOf (object value) {return (values as IList).IndexOf (value);} + void IList.Insert (int index, object value) {(values as IList).Insert (index, value);} + void IList.Remove (object value) {(values as IList).Remove (value);} + void IList.RemoveAt (int index) {(values as IList).RemoveAt (index);} + bool IList.IsFixedSize {get {return false;}} + object IList.this [int index] {get {return this [index];} set {(values as IList)[index] = value;}} + #endregion + + #region IList + public int IndexOf (string item) {return values.IndexOf (item);} + public void Insert (int index, string item) {values.Insert (index, item);} + public void RemoveAt (int index) {values.RemoveAt (index);} + + private void AssertValid (int index) + { + if (c.Option == null) + throw new InvalidOperationException ("OptionContext.Option is null."); + if (index >= c.Option.MaxValueCount) + throw new ArgumentOutOfRangeException ("index"); + if (c.Option.OptionValueType == OptionValueType.Required && + index >= values.Count) + throw new OptionException (string.Format ( + c.OptionSet.MessageLocalizer ("Missing required value for option '{0}'."), c.OptionName), + c.OptionName); + } + + public string this [int index] { + get { + AssertValid (index); + return index >= values.Count ? null : values [index]; + } + set { + values [index] = value; + } + } + #endregion + + public List ToList () + { + return new List (values); + } + + public string[] ToArray () + { + return values.ToArray (); + } + + public override string ToString () + { + return string.Join (", ", values.ToArray ()); + } + } + + public class OptionContext { + private Option option; + private string name; + private int index; + private OptionSet set; + private OptionValueCollection c; + + public OptionContext (OptionSet set) + { + this.set = set; + this.c = new OptionValueCollection (this); + } + + public Option Option { + get {return option;} + set {option = value;} + } + + public string OptionName { + get {return name;} + set {name = value;} + } + + public int OptionIndex { + get {return index;} + set {index = value;} + } + + public OptionSet OptionSet { + get {return set;} + } + + public OptionValueCollection OptionValues { + get {return c;} + } + } + + public enum OptionValueType { + None, + Optional, + Required, + } + + public abstract class Option { + string prototype, description; + string[] names; + OptionValueType type; + int count; + string[] separators; + + protected Option (string prototype, string description) + : this (prototype, description, 1) + { + } + + protected Option (string prototype, string description, int maxValueCount) + { + if (prototype == null) + throw new ArgumentNullException ("prototype"); + if (prototype.Length == 0) + throw new ArgumentException ("Cannot be the empty string.", "prototype"); + if (maxValueCount < 0) + throw new ArgumentOutOfRangeException ("maxValueCount"); + + this.prototype = prototype; + this.names = prototype.Split ('|'); + this.description = description; + this.count = maxValueCount; + this.type = ParsePrototype (); + + if (this.count == 0 && type != OptionValueType.None) + throw new ArgumentException ( + "Cannot provide maxValueCount of 0 for OptionValueType.Required or " + + "OptionValueType.Optional.", + "maxValueCount"); + if (this.type == OptionValueType.None && maxValueCount > 1) + throw new ArgumentException ( + string.Format ("Cannot provide maxValueCount of {0} for OptionValueType.None.", maxValueCount), + "maxValueCount"); + if (Array.IndexOf (names, "<>") >= 0 && + ((names.Length == 1 && this.type != OptionValueType.None) || + (names.Length > 1 && this.MaxValueCount > 1))) + throw new ArgumentException ( + "The default option handler '<>' cannot require values.", + "prototype"); + } + + public string Prototype {get {return prototype;}} + public string Description {get {return description;}} + public OptionValueType OptionValueType {get {return type;}} + public int MaxValueCount {get {return count;}} + + public string[] GetNames () + { + return (string[]) names.Clone (); + } + + public string[] GetValueSeparators () + { + if (separators == null) + return new string [0]; + return (string[]) separators.Clone (); + } + + protected static T Parse (string value, OptionContext c) + { + Type tt = typeof (T); + bool nullable = tt.IsValueType && tt.IsGenericType && + !tt.IsGenericTypeDefinition && + tt.GetGenericTypeDefinition () == typeof (Nullable<>); + Type targetType = nullable ? tt.GetGenericArguments () [0] : typeof (T); + TypeConverter conv = TypeDescriptor.GetConverter (targetType); + T t = default (T); + try { + if (value != null) + t = (T) conv.ConvertFromString (value); + } + catch (Exception e) { + throw new OptionException ( + string.Format ( + c.OptionSet.MessageLocalizer ("Could not convert string `{0}' to type {1} for option `{2}'."), + value, targetType.Name, c.OptionName), + c.OptionName, e); + } + return t; + } + + internal string[] Names {get {return names;}} + internal string[] ValueSeparators {get {return separators;}} + + static readonly char[] NameTerminator = new char[]{'=', ':'}; + + private OptionValueType ParsePrototype () + { + char type = '\0'; + List seps = new List (); + for (int i = 0; i < names.Length; ++i) { + string name = names [i]; + if (name.Length == 0) + throw new ArgumentException ("Empty option names are not supported.", "prototype"); + + int end = name.IndexOfAny (NameTerminator); + if (end == -1) + continue; + names [i] = name.Substring (0, end); + if (type == '\0' || type == name [end]) + type = name [end]; + else + throw new ArgumentException ( + string.Format ("Conflicting option types: '{0}' vs. '{1}'.", type, name [end]), + "prototype"); + AddSeparators (name, end, seps); + } + + if (type == '\0') + return OptionValueType.None; + + if (count <= 1 && seps.Count != 0) + throw new ArgumentException ( + string.Format ("Cannot provide key/value separators for Options taking {0} value(s).", count), + "prototype"); + if (count > 1) { + if (seps.Count == 0) + this.separators = new string[]{":", "="}; + else if (seps.Count == 1 && seps [0].Length == 0) + this.separators = null; + else + this.separators = seps.ToArray (); + } + + return type == '=' ? OptionValueType.Required : OptionValueType.Optional; + } + + private static void AddSeparators (string name, int end, ICollection seps) + { + int start = -1; + for (int i = end+1; i < name.Length; ++i) { + switch (name [i]) { + case '{': + if (start != -1) + throw new ArgumentException ( + string.Format ("Ill-formed name/value separator found in \"{0}\".", name), + "prototype"); + start = i+1; + break; + case '}': + if (start == -1) + throw new ArgumentException ( + string.Format ("Ill-formed name/value separator found in \"{0}\".", name), + "prototype"); + seps.Add (name.Substring (start, i-start)); + start = -1; + break; + default: + if (start == -1) + seps.Add (name [i].ToString ()); + break; + } + } + if (start != -1) + throw new ArgumentException ( + string.Format ("Ill-formed name/value separator found in \"{0}\".", name), + "prototype"); + } + + public void Invoke (OptionContext c) + { + OnParseComplete (c); + c.OptionName = null; + c.Option = null; + c.OptionValues.Clear (); + } + + protected abstract void OnParseComplete (OptionContext c); + + public override string ToString () + { + return Prototype; + } + } + + [Serializable] + public class OptionException : Exception { + private string option; + + public OptionException () + { + } + + public OptionException (string message, string optionName) + : base (message) + { + this.option = optionName; + } + + public OptionException (string message, string optionName, Exception innerException) + : base (message, innerException) + { + this.option = optionName; + } + + protected OptionException (SerializationInfo info, StreamingContext context) + : base (info, context) + { + this.option = info.GetString ("OptionName"); + } + + public string OptionName { + get {return this.option;} + } + + [SecurityPermission (SecurityAction.LinkDemand, SerializationFormatter = true)] + public override void GetObjectData (SerializationInfo info, StreamingContext context) + { + base.GetObjectData (info, context); + info.AddValue ("OptionName", option); + } + } + + public delegate void OptionAction (TKey key, TValue value); + + public class OptionSet : KeyedCollection + { + public OptionSet () + : this (delegate (string f) {return f;}) + { + } + + public OptionSet (Converter localizer) + { + this.localizer = localizer; + } + + Converter localizer; + + public Converter MessageLocalizer { + get {return localizer;} + } + + protected override string GetKeyForItem (Option item) + { + if (item == null) + throw new ArgumentNullException ("option"); + if (item.Names != null && item.Names.Length > 0) + return item.Names [0]; + // This should never happen, as it's invalid for Option to be + // constructed w/o any names. + throw new InvalidOperationException ("Option has no names!"); + } + + [Obsolete ("Use KeyedCollection.this[string]")] + protected Option GetOptionForName (string option) + { + if (option == null) + throw new ArgumentNullException ("option"); + try { + return base [option]; + } + catch (KeyNotFoundException) { + return null; + } + } + + protected override void InsertItem (int index, Option item) + { + base.InsertItem (index, item); + AddImpl (item); + } + + protected override void RemoveItem (int index) + { + base.RemoveItem (index); + Option p = Items [index]; + // KeyedCollection.RemoveItem() handles the 0th item + for (int i = 1; i < p.Names.Length; ++i) { + Dictionary.Remove (p.Names [i]); + } + } + + protected override void SetItem (int index, Option item) + { + base.SetItem (index, item); + RemoveItem (index); + AddImpl (item); + } + + private void AddImpl (Option option) + { + if (option == null) + throw new ArgumentNullException ("option"); + List added = new List (option.Names.Length); + try { + // KeyedCollection.InsertItem/SetItem handle the 0th name. + for (int i = 1; i < option.Names.Length; ++i) { + Dictionary.Add (option.Names [i], option); + added.Add (option.Names [i]); + } + } + catch (Exception) { + foreach (string name in added) + Dictionary.Remove (name); + throw; + } + } + + public new OptionSet Add (Option option) + { + base.Add (option); + return this; + } + + sealed class ActionOption : Option { + Action action; + + public ActionOption (string prototype, string description, int count, Action action) + : base (prototype, description, count) + { + if (action == null) + throw new ArgumentNullException ("action"); + this.action = action; + } + + protected override void OnParseComplete (OptionContext c) + { + action (c.OptionValues); + } + } + + public OptionSet Add (string prototype, Action action) + { + return Add (prototype, null, action); + } + + public OptionSet Add (string prototype, string description, Action action) + { + if (action == null) + throw new ArgumentNullException ("action"); + Option p = new ActionOption (prototype, description, 1, + delegate (OptionValueCollection v) { action (v [0]); }); + base.Add (p); + return this; + } + + public OptionSet Add (string prototype, OptionAction action) + { + return Add (prototype, null, action); + } + + public OptionSet Add (string prototype, string description, OptionAction action) + { + if (action == null) + throw new ArgumentNullException ("action"); + Option p = new ActionOption (prototype, description, 2, + delegate (OptionValueCollection v) {action (v [0], v [1]);}); + base.Add (p); + return this; + } + + sealed class ActionOption : Option { + Action action; + + public ActionOption (string prototype, string description, Action action) + : base (prototype, description, 1) + { + if (action == null) + throw new ArgumentNullException ("action"); + this.action = action; + } + + protected override void OnParseComplete (OptionContext c) + { + action (Parse (c.OptionValues [0], c)); + } + } + + sealed class ActionOption : Option { + OptionAction action; + + public ActionOption (string prototype, string description, OptionAction action) + : base (prototype, description, 2) + { + if (action == null) + throw new ArgumentNullException ("action"); + this.action = action; + } + + protected override void OnParseComplete (OptionContext c) + { + action ( + Parse (c.OptionValues [0], c), + Parse (c.OptionValues [1], c)); + } + } + + public OptionSet Add (string prototype, Action action) + { + return Add (prototype, null, action); + } + + public OptionSet Add (string prototype, string description, Action action) + { + return Add (new ActionOption (prototype, description, action)); + } + + public OptionSet Add (string prototype, OptionAction action) + { + return Add (prototype, null, action); + } + + public OptionSet Add (string prototype, string description, OptionAction action) + { + return Add (new ActionOption (prototype, description, action)); + } + + protected virtual OptionContext CreateOptionContext () + { + return new OptionContext (this); + } #if LINQ - public List Parse (IEnumerable arguments) - { - bool process = true; - OptionContext c = CreateOptionContext (); - c.OptionIndex = -1; - var def = GetOptionForName ("<>"); - var unprocessed = - from argument in arguments - where ++c.OptionIndex >= 0 && (process || def != null) - ? process - ? argument == "--" - ? (process = false) - : !Parse (argument, c) - ? def != null - ? Unprocessed (null, def, c, argument) - : true - : false - : def != null - ? Unprocessed (null, def, c, argument) - : true - : true - select argument; - List r = unprocessed.ToList (); - if (c.Option != null) - c.Option.Invoke (c); - return r; - } + public List Parse (IEnumerable arguments) + { + bool process = true; + OptionContext c = CreateOptionContext (); + c.OptionIndex = -1; + var def = GetOptionForName ("<>"); + var unprocessed = + from argument in arguments + where ++c.OptionIndex >= 0 && (process || def != null) + ? process + ? argument == "--" + ? (process = false) + : !Parse (argument, c) + ? def != null + ? Unprocessed (null, def, c, argument) + : true + : false + : def != null + ? Unprocessed (null, def, c, argument) + : true + : true + select argument; + List r = unprocessed.ToList (); + if (c.Option != null) + c.Option.Invoke (c); + return r; + } #else - public List Parse (IEnumerable arguments) - { - OptionContext c = CreateOptionContext (); - c.OptionIndex = -1; - bool process = true; - List unprocessed = new List (); - Option def = Contains ("<>") ? this ["<>"] : null; - foreach (string argument in arguments) { - ++c.OptionIndex; - if (argument == "--") { - process = false; - continue; - } - if (!process) { - Unprocessed (unprocessed, def, c, argument); - continue; - } - if (!Parse (argument, c)) - Unprocessed (unprocessed, def, c, argument); - } - if (c.Option != null) - c.Option.Invoke (c); - return unprocessed; - } + public List Parse (IEnumerable arguments) + { + OptionContext c = CreateOptionContext (); + c.OptionIndex = -1; + bool process = true; + List unprocessed = new List (); + Option def = Contains ("<>") ? this ["<>"] : null; + foreach (string argument in arguments) { + ++c.OptionIndex; + if (argument == "--") { + process = false; + continue; + } + if (!process) { + Unprocessed (unprocessed, def, c, argument); + continue; + } + if (!Parse (argument, c)) + Unprocessed (unprocessed, def, c, argument); + } + if (c.Option != null) + c.Option.Invoke (c); + return unprocessed; + } #endif - private static bool Unprocessed (ICollection extra, Option def, OptionContext c, string argument) - { - if (def == null) { - extra.Add (argument); - return false; - } - c.OptionValues.Add (argument); - c.Option = def; - c.Option.Invoke (c); - return false; - } + private static bool Unprocessed (ICollection extra, Option def, OptionContext c, string argument) + { + if (def == null) { + extra.Add (argument); + return false; + } + c.OptionValues.Add (argument); + c.Option = def; + c.Option.Invoke (c); + return false; + } - private readonly Regex ValueOption = new Regex ( - @"^(?--|-|/)(?[^:=]+)((?[:=])(?.*))?$"); + private readonly Regex ValueOption = new Regex ( + @"^(?--|-|/)(?[^:=]+)((?[:=])(?.*))?$"); - protected bool GetOptionParts (string argument, out string flag, out string name, out string sep, out string value) - { - if (argument == null) - throw new ArgumentNullException ("argument"); + protected bool GetOptionParts (string argument, out string flag, out string name, out string sep, out string value) + { + if (argument == null) + throw new ArgumentNullException ("argument"); - flag = name = sep = value = null; - Match m = ValueOption.Match (argument); - if (!m.Success) { - return false; - } - flag = m.Groups ["flag"].Value; - name = m.Groups ["name"].Value; - if (m.Groups ["sep"].Success && m.Groups ["value"].Success) { - sep = m.Groups ["sep"].Value; - value = m.Groups ["value"].Value; - } - return true; - } + flag = name = sep = value = null; + Match m = ValueOption.Match (argument); + if (!m.Success) { + return false; + } + flag = m.Groups ["flag"].Value; + name = m.Groups ["name"].Value; + if (m.Groups ["sep"].Success && m.Groups ["value"].Success) { + sep = m.Groups ["sep"].Value; + value = m.Groups ["value"].Value; + } + return true; + } - protected virtual bool Parse (string argument, OptionContext c) - { - if (c.Option != null) { - ParseValue (argument, c); - return true; - } + protected virtual bool Parse (string argument, OptionContext c) + { + if (c.Option != null) { + ParseValue (argument, c); + return true; + } - string f, n, s, v; - if (!GetOptionParts (argument, out f, out n, out s, out v)) - return false; + string f, n, s, v; + if (!GetOptionParts (argument, out f, out n, out s, out v)) + return false; - Option p; - if (Contains (n)) { - p = this [n]; - c.OptionName = f + n; - c.Option = p; - switch (p.OptionValueType) { - case OptionValueType.None: - c.OptionValues.Add (n); - c.Option.Invoke (c); - break; - case OptionValueType.Optional: - case OptionValueType.Required: - ParseValue (v, c); - break; - } - return true; - } - // no match; is it a bool option? - if (ParseBool (argument, n, c)) - return true; - // is it a bundled option? - if (ParseBundledValue (f, string.Concat (n + s + v), c)) - return true; + Option p; + if (Contains (n)) { + p = this [n]; + c.OptionName = f + n; + c.Option = p; + switch (p.OptionValueType) { + case OptionValueType.None: + c.OptionValues.Add (n); + c.Option.Invoke (c); + break; + case OptionValueType.Optional: + case OptionValueType.Required: + ParseValue (v, c); + break; + } + return true; + } + // no match; is it a bool option? + if (ParseBool (argument, n, c)) + return true; + // is it a bundled option? + if (ParseBundledValue (f, string.Concat (n + s + v), c)) + return true; - return false; - } + return false; + } - private void ParseValue (string option, OptionContext c) - { - if (option != null) - foreach (string o in c.Option.ValueSeparators != null - ? option.Split (c.Option.ValueSeparators, StringSplitOptions.None) - : new string[]{option}) { - c.OptionValues.Add (o); - } - if (c.OptionValues.Count == c.Option.MaxValueCount || - c.Option.OptionValueType == OptionValueType.Optional) - c.Option.Invoke (c); - else if (c.OptionValues.Count > c.Option.MaxValueCount) { - throw new OptionException (localizer (string.Format ( - "Error: Found {0} option values when expecting {1}.", - c.OptionValues.Count, c.Option.MaxValueCount)), - c.OptionName); - } - } + private void ParseValue (string option, OptionContext c) + { + if (option != null) + foreach (string o in c.Option.ValueSeparators != null + ? option.Split (c.Option.ValueSeparators, StringSplitOptions.None) + : new string[]{option}) { + c.OptionValues.Add (o); + } + if (c.OptionValues.Count == c.Option.MaxValueCount || + c.Option.OptionValueType == OptionValueType.Optional) + c.Option.Invoke (c); + else if (c.OptionValues.Count > c.Option.MaxValueCount) { + throw new OptionException (localizer (string.Format ( + "Error: Found {0} option values when expecting {1}.", + c.OptionValues.Count, c.Option.MaxValueCount)), + c.OptionName); + } + } - private bool ParseBool (string option, string n, OptionContext c) - { - Option p; - string rn; - if (n.Length >= 1 && (n [n.Length-1] == '+' || n [n.Length-1] == '-') && - Contains ((rn = n.Substring (0, n.Length-1)))) { - p = this [rn]; - string v = n [n.Length-1] == '+' ? option : null; - c.OptionName = option; - c.Option = p; - c.OptionValues.Add (v); - p.Invoke (c); - return true; - } - return false; - } + private bool ParseBool (string option, string n, OptionContext c) + { + Option p; + string rn; + if (n.Length >= 1 && (n [n.Length-1] == '+' || n [n.Length-1] == '-') && + Contains ((rn = n.Substring (0, n.Length-1)))) { + p = this [rn]; + string v = n [n.Length-1] == '+' ? option : null; + c.OptionName = option; + c.Option = p; + c.OptionValues.Add (v); + p.Invoke (c); + return true; + } + return false; + } - private bool ParseBundledValue (string f, string n, OptionContext c) - { - if (f != "-") - return false; - for (int i = 0; i < n.Length; ++i) { - Option p; - string opt = f + n [i].ToString (); - string rn = n [i].ToString (); - if (!Contains (rn)) { - if (i == 0) - return false; - throw new OptionException (string.Format (localizer ( - "Cannot bundle unregistered option '{0}'."), opt), opt); - } - p = this [rn]; - switch (p.OptionValueType) { - case OptionValueType.None: - Invoke (c, opt, n, p); - break; - case OptionValueType.Optional: - case OptionValueType.Required: { - string v = n.Substring (i+1); - c.Option = p; - c.OptionName = opt; - ParseValue (v.Length != 0 ? v : null, c); - return true; - } - default: - throw new InvalidOperationException ("Unknown OptionValueType: " + p.OptionValueType); - } - } - return true; - } + private bool ParseBundledValue (string f, string n, OptionContext c) + { + if (f != "-") + return false; + for (int i = 0; i < n.Length; ++i) { + Option p; + string opt = f + n [i].ToString (); + string rn = n [i].ToString (); + if (!Contains (rn)) { + if (i == 0) + return false; + throw new OptionException (string.Format (localizer ( + "Cannot bundle unregistered option '{0}'."), opt), opt); + } + p = this [rn]; + switch (p.OptionValueType) { + case OptionValueType.None: + Invoke (c, opt, n, p); + break; + case OptionValueType.Optional: + case OptionValueType.Required: { + string v = n.Substring (i+1); + c.Option = p; + c.OptionName = opt; + ParseValue (v.Length != 0 ? v : null, c); + return true; + } + default: + throw new InvalidOperationException ("Unknown OptionValueType: " + p.OptionValueType); + } + } + return true; + } - private static void Invoke (OptionContext c, string name, string value, Option option) - { - c.OptionName = name; - c.Option = option; - c.OptionValues.Add (value); - option.Invoke (c); - } + private static void Invoke (OptionContext c, string name, string value, Option option) + { + c.OptionName = name; + c.Option = option; + c.OptionValues.Add (value); + option.Invoke (c); + } - private const int OptionWidth = 29; + private const int OptionWidth = 29; - public void WriteOptionDescriptions (TextWriter o) - { - foreach (Option p in this) { - int written = 0; - if (!WriteOptionPrototype (o, p, ref written)) - continue; + public void WriteOptionDescriptions (TextWriter o) + { + foreach (Option p in this) { + int written = 0; + if (!WriteOptionPrototype (o, p, ref written)) + continue; - if (written < OptionWidth) - o.Write (new string (' ', OptionWidth - written)); - else { - o.WriteLine (); - o.Write (new string (' ', OptionWidth)); - } + if (written < OptionWidth) + o.Write (new string (' ', OptionWidth - written)); + else { + o.WriteLine (); + o.Write (new string (' ', OptionWidth)); + } - bool indent = false; - string prefix = new string (' ', OptionWidth+2); - foreach (string line in GetLines (localizer (GetDescription (p.Description)))) { - if (indent) - o.Write (prefix); - o.WriteLine (line); - indent = true; - } - } - } + bool indent = false; + string prefix = new string (' ', OptionWidth+2); + foreach (string line in GetLines (localizer (GetDescription (p.Description)))) { + if (indent) + o.Write (prefix); + o.WriteLine (line); + indent = true; + } + } + } - bool WriteOptionPrototype (TextWriter o, Option p, ref int written) - { - string[] names = p.Names; + bool WriteOptionPrototype (TextWriter o, Option p, ref int written) + { + string[] names = p.Names; - int i = GetNextOptionIndex (names, 0); - if (i == names.Length) - return false; + int i = GetNextOptionIndex (names, 0); + if (i == names.Length) + return false; - if (names [i].Length == 1) { - Write (o, ref written, " -"); - Write (o, ref written, names [0]); - } - else { - Write (o, ref written, " --"); - Write (o, ref written, names [0]); - } + if (names [i].Length == 1) { + Write (o, ref written, " -"); + Write (o, ref written, names [0]); + } + else { + Write (o, ref written, " --"); + Write (o, ref written, names [0]); + } - for ( i = GetNextOptionIndex (names, i+1); - i < names.Length; i = GetNextOptionIndex (names, i+1)) { - Write (o, ref written, ", "); - Write (o, ref written, names [i].Length == 1 ? "-" : "--"); - Write (o, ref written, names [i]); - } + for ( i = GetNextOptionIndex (names, i+1); + i < names.Length; i = GetNextOptionIndex (names, i+1)) { + Write (o, ref written, ", "); + Write (o, ref written, names [i].Length == 1 ? "-" : "--"); + Write (o, ref written, names [i]); + } - if (p.OptionValueType == OptionValueType.Optional || - p.OptionValueType == OptionValueType.Required) { - if (p.OptionValueType == OptionValueType.Optional) { - Write (o, ref written, localizer ("[")); - } - Write (o, ref written, localizer ("=" + GetArgumentName (0, p.MaxValueCount, p.Description))); - string sep = p.ValueSeparators != null && p.ValueSeparators.Length > 0 - ? p.ValueSeparators [0] - : " "; - for (int c = 1; c < p.MaxValueCount; ++c) { - Write (o, ref written, localizer (sep + GetArgumentName (c, p.MaxValueCount, p.Description))); - } - if (p.OptionValueType == OptionValueType.Optional) { - Write (o, ref written, localizer ("]")); - } - } - return true; - } + if (p.OptionValueType == OptionValueType.Optional || + p.OptionValueType == OptionValueType.Required) { + if (p.OptionValueType == OptionValueType.Optional) { + Write (o, ref written, localizer ("[")); + } + Write (o, ref written, localizer ("=" + GetArgumentName (0, p.MaxValueCount, p.Description))); + string sep = p.ValueSeparators != null && p.ValueSeparators.Length > 0 + ? p.ValueSeparators [0] + : " "; + for (int c = 1; c < p.MaxValueCount; ++c) { + Write (o, ref written, localizer (sep + GetArgumentName (c, p.MaxValueCount, p.Description))); + } + if (p.OptionValueType == OptionValueType.Optional) { + Write (o, ref written, localizer ("]")); + } + } + return true; + } - static int GetNextOptionIndex (string[] names, int i) - { - while (i < names.Length && names [i] == "<>") { - ++i; - } - return i; - } + static int GetNextOptionIndex (string[] names, int i) + { + while (i < names.Length && names [i] == "<>") { + ++i; + } + return i; + } - static void Write (TextWriter o, ref int n, string s) - { - n += s.Length; - o.Write (s); - } + static void Write (TextWriter o, ref int n, string s) + { + n += s.Length; + o.Write (s); + } - private static string GetArgumentName (int index, int maxIndex, string description) - { - if (description == null) - return maxIndex == 1 ? "VALUE" : "VALUE" + (index + 1); - string[] nameStart; - if (maxIndex == 1) - nameStart = new string[]{"{0:", "{"}; - else - nameStart = new string[]{"{" + index + ":"}; - for (int i = 0; i < nameStart.Length; ++i) { - int start, j = 0; - do { - start = description.IndexOf (nameStart [i], j); - } while (start >= 0 && j != 0 ? description [j++ - 1] == '{' : false); - if (start == -1) - continue; - int end = description.IndexOf ("}", start); - if (end == -1) - continue; - return description.Substring (start + nameStart [i].Length, end - start - nameStart [i].Length); - } - return maxIndex == 1 ? "VALUE" : "VALUE" + (index + 1); - } + private static string GetArgumentName (int index, int maxIndex, string description) + { + if (description == null) + return maxIndex == 1 ? "VALUE" : "VALUE" + (index + 1); + string[] nameStart; + if (maxIndex == 1) + nameStart = new string[]{"{0:", "{"}; + else + nameStart = new string[]{"{" + index + ":"}; + for (int i = 0; i < nameStart.Length; ++i) { + int start, j = 0; + do { + start = description.IndexOf (nameStart [i], j); + } while (start >= 0 && j != 0 ? description [j++ - 1] == '{' : false); + if (start == -1) + continue; + int end = description.IndexOf ("}", start); + if (end == -1) + continue; + return description.Substring (start + nameStart [i].Length, end - start - nameStart [i].Length); + } + return maxIndex == 1 ? "VALUE" : "VALUE" + (index + 1); + } - private static string GetDescription (string description) - { - if (description == null) - return string.Empty; - StringBuilder sb = new StringBuilder (description.Length); - int start = -1; - for (int i = 0; i < description.Length; ++i) { - switch (description [i]) { - case '{': - if (i == start) { - sb.Append ('{'); - start = -1; - } - else if (start < 0) - start = i + 1; - break; - case '}': - if (start < 0) { - if ((i+1) == description.Length || description [i+1] != '}') - throw new InvalidOperationException ("Invalid option description: " + description); - ++i; - sb.Append ("}"); - } - else { - sb.Append (description.Substring (start, i - start)); - start = -1; - } - break; - case ':': - if (start < 0) - goto default; - start = i + 1; - break; - default: - if (start < 0) - sb.Append (description [i]); - break; - } - } - return sb.ToString (); - } + private static string GetDescription (string description) + { + if (description == null) + return string.Empty; + StringBuilder sb = new StringBuilder (description.Length); + int start = -1; + for (int i = 0; i < description.Length; ++i) { + switch (description [i]) { + case '{': + if (i == start) { + sb.Append ('{'); + start = -1; + } + else if (start < 0) + start = i + 1; + break; + case '}': + if (start < 0) { + if ((i+1) == description.Length || description [i+1] != '}') + throw new InvalidOperationException ("Invalid option description: " + description); + ++i; + sb.Append ("}"); + } + else { + sb.Append (description.Substring (start, i - start)); + start = -1; + } + break; + case ':': + if (start < 0) + goto default; + start = i + 1; + break; + default: + if (start < 0) + sb.Append (description [i]); + break; + } + } + return sb.ToString (); + } - private static IEnumerable GetLines (string description) - { - if (string.IsNullOrEmpty (description)) { - yield return string.Empty; - yield break; - } - int length = 80 - OptionWidth - 1; - int start = 0, end; - do { - end = GetLineEnd (start, length, description); - char c = description [end-1]; - if (char.IsWhiteSpace (c)) - --end; - bool writeContinuation = end != description.Length && !IsEolChar (c); - string line = description.Substring (start, end - start) + - (writeContinuation ? "-" : ""); - yield return line; - start = end; - if (char.IsWhiteSpace (c)) - ++start; - length = 80 - OptionWidth - 2 - 1; - } while (end < description.Length); - } + private static IEnumerable GetLines (string description) + { + if (string.IsNullOrEmpty (description)) { + yield return string.Empty; + yield break; + } + int length = 80 - OptionWidth - 1; + int start = 0, end; + do { + end = GetLineEnd (start, length, description); + char c = description [end-1]; + if (char.IsWhiteSpace (c)) + --end; + bool writeContinuation = end != description.Length && !IsEolChar (c); + string line = description.Substring (start, end - start) + + (writeContinuation ? "-" : ""); + yield return line; + start = end; + if (char.IsWhiteSpace (c)) + ++start; + length = 80 - OptionWidth - 2 - 1; + } while (end < description.Length); + } - private static bool IsEolChar (char c) - { - return !char.IsLetterOrDigit (c); - } + private static bool IsEolChar (char c) + { + return !char.IsLetterOrDigit (c); + } - private static int GetLineEnd (int start, int length, string description) - { - int end = System.Math.Min (start + length, description.Length); - int sep = -1; - for (int i = start; i < end; ++i) { - if (description [i] == '\n') - return i+1; - if (IsEolChar (description [i])) - sep = i+1; - } - if (sep == -1 || end == description.Length) - return end; - return sep; - } - } + private static int GetLineEnd (int start, int length, string description) + { + int end = System.Math.Min (start + length, description.Length); + int sep = -1; + for (int i = start; i < end; ++i) { + if (description [i] == '\n') + return i+1; + if (IsEolChar (description [i])) + sep = i+1; + } + if (sep == -1 || end == description.Length) + return end; + return sep; + } + } } diff --git a/SparkleShare/SparkleSetupController.cs b/SparkleShare/SparkleSetupController.cs index 16170042..afdc56bb 100755 --- a/SparkleShare/SparkleSetupController.cs +++ b/SparkleShare/SparkleSetupController.cs @@ -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; diff --git a/SparkleShare/Windows/SparkleAbout.cs b/SparkleShare/Windows/SparkleAbout.cs index 3390a0b0..c9ae38a8 100644 --- a/SparkleShare/Windows/SparkleAbout.cs +++ b/SparkleShare/Windows/SparkleAbout.cs @@ -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 (); diff --git a/SparkleShare/Windows/SparkleBubbles.cs b/SparkleShare/Windows/SparkleBubbles.cs index 7bd87543..22ac35c6 100644 --- a/SparkleShare/Windows/SparkleBubbles.cs +++ b/SparkleShare/Windows/SparkleBubbles.cs @@ -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); }; diff --git a/SparkleShare/Windows/SparkleController.cs b/SparkleShare/Windows/SparkleController.cs index e3088a29..c4cbdb95 100644 --- a/SparkleShare/Windows/SparkleController.cs +++ b/SparkleShare/Windows/SparkleController.cs @@ -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 @"\msysgit\bin" + // Add msysgit to path, as we cannot asume it is added to the path + // Asume it is installed in @"\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"); } } - } + } } } diff --git a/SparkleShare/Windows/SparkleEventLog.cs b/SparkleShare/Windows/SparkleEventLog.cs index ed63b6bd..87626cf2 100644 --- a/SparkleShare/Windows/SparkleEventLog.cs +++ b/SparkleShare/Windows/SparkleEventLog.cs @@ -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 (); diff --git a/SparkleShare/Windows/SparkleSetup.cs b/SparkleShare/Windows/SparkleSetup.cs index 4d5d36b3..9eff6b2b 100644 --- a/SparkleShare/Windows/SparkleSetup.cs +++ b/SparkleShare/Windows/SparkleSetup.cs @@ -32,17 +32,17 @@ using WPF = System.Windows.Controls; namespace SparkleShare { public class SparkleSetup : SparkleSetupWindow { - - public SparkleSetupController Controller = new SparkleSetupController (); - - - public SparkleSetup () - { + + public SparkleSetupController Controller = new SparkleSetupController (); + + + public SparkleSetup () + { Controller.ShowWindowEvent += delegate { Dispatcher.Invoke ((Action) delegate { Show (); - Activate (); - BringIntoView (); + Activate (); + BringIntoView (); }); }; @@ -51,287 +51,287 @@ namespace SparkleShare { Hide (); }); }; - + Controller.ChangePageEvent += delegate (PageType type, string [] warnings) { - Dispatcher.Invoke ((Action) delegate { - Reset (); - - switch (type) { + Dispatcher.Invoke ((Action) delegate { + Reset (); + + switch (type) { case PageType.Setup: { - Header = "Welcome to SparkleShare!"; - Description = "Before we get started, what's your name and email?\n" + - "Don't worry, this information will only visible to any team members."; - - - TextBlock name_label = new TextBlock () { - Text = "Full Name:", - Width = 150, - TextAlignment = TextAlignment.Right, - FontWeight = FontWeights.Bold - }; - - TextBox name_box = new TextBox () { - Text = Controller.GuessedUserName, - Width = 175 - }; - - - TextBlock email_label = new TextBlock () { - Text = "Email:", - Width = 150, - TextAlignment = TextAlignment.Right, - FontWeight = FontWeights.Bold - }; - - TextBox email_box = new TextBox () { - Width = 175, - Text = Controller.GuessedUserEmail - }; - - - - Button cancel_button = new Button () { - Content = "Cancel" - }; - - Button continue_button = new Button () { - Content = "Continue", - IsEnabled = false - }; - - - ContentCanvas.Children.Add (name_label); - Canvas.SetLeft (name_label, 180); - Canvas.SetTop (name_label, 200 + 3); - - ContentCanvas.Children.Add (name_box); - Canvas.SetLeft (name_box, 340); - Canvas.SetTop (name_box, 200); - - ContentCanvas.Children.Add (email_label); - Canvas.SetLeft (email_label, 180); - Canvas.SetTop (email_label, 230 + 3); - - ContentCanvas.Children.Add (email_box); - Canvas.SetLeft (email_box, 340); - Canvas.SetTop (email_box, 230); - - Buttons.Add (continue_button); - Buttons.Add (cancel_button); - - - Controller.UpdateSetupContinueButtonEvent += delegate (bool enabled) { - Dispatcher.Invoke ((Action) delegate { - continue_button.IsEnabled = enabled; - }); - }; - - name_box.TextChanged += delegate { - Controller.CheckSetupPage (name_box.Text, email_box.Text); - }; - - email_box.TextChanged += delegate { - Controller.CheckSetupPage (name_box.Text, email_box.Text); - }; - - cancel_button.Click += delegate { - Dispatcher.Invoke ((Action) delegate { - SparkleUI.StatusIcon.Dispose (); - Controller.SetupPageCancelled (); - }); - }; - - continue_button.Click += delegate { - Controller.SetupPageCompleted (name_box.Text, email_box.Text); - }; - - Controller.CheckSetupPage (name_box.Text, email_box.Text); - - break; - } + Header = "Welcome to SparkleShare!"; + Description = "Before we get started, what's your name and email?\n" + + "Don't worry, this information will only visible to any team members."; + + + TextBlock name_label = new TextBlock () { + Text = "Full Name:", + Width = 150, + TextAlignment = TextAlignment.Right, + FontWeight = FontWeights.Bold + }; + + TextBox name_box = new TextBox () { + Text = Controller.GuessedUserName, + Width = 175 + }; + + + TextBlock email_label = new TextBlock () { + Text = "Email:", + Width = 150, + TextAlignment = TextAlignment.Right, + FontWeight = FontWeights.Bold + }; + + TextBox email_box = new TextBox () { + Width = 175, + Text = Controller.GuessedUserEmail + }; + + + + Button cancel_button = new Button () { + Content = "Cancel" + }; + + Button continue_button = new Button () { + Content = "Continue", + IsEnabled = false + }; + + + ContentCanvas.Children.Add (name_label); + Canvas.SetLeft (name_label, 180); + Canvas.SetTop (name_label, 200 + 3); + + ContentCanvas.Children.Add (name_box); + Canvas.SetLeft (name_box, 340); + Canvas.SetTop (name_box, 200); + + ContentCanvas.Children.Add (email_label); + Canvas.SetLeft (email_label, 180); + Canvas.SetTop (email_label, 230 + 3); + + ContentCanvas.Children.Add (email_box); + Canvas.SetLeft (email_box, 340); + Canvas.SetTop (email_box, 230); + + Buttons.Add (continue_button); + Buttons.Add (cancel_button); + + + Controller.UpdateSetupContinueButtonEvent += delegate (bool enabled) { + Dispatcher.Invoke ((Action) delegate { + continue_button.IsEnabled = enabled; + }); + }; + + name_box.TextChanged += delegate { + Controller.CheckSetupPage (name_box.Text, email_box.Text); + }; + + email_box.TextChanged += delegate { + Controller.CheckSetupPage (name_box.Text, email_box.Text); + }; + + cancel_button.Click += delegate { + Dispatcher.Invoke ((Action) delegate { + SparkleUI.StatusIcon.Dispose (); + Controller.SetupPageCancelled (); + }); + }; + + continue_button.Click += delegate { + Controller.SetupPageCompleted (name_box.Text, email_box.Text); + }; + + Controller.CheckSetupPage (name_box.Text, email_box.Text); + + break; + } case PageType.Invite: { - Header = "You've received an invite!"; - Description = "Do you want to add this project to SparkleShare?"; - - - TextBlock address_label = new TextBlock () { - Text = "Address:", - Width = 150, - TextAlignment = TextAlignment.Right - }; - - TextBlock address_value = new TextBlock () { - Text = Controller.PendingInvite.Address, - Width = 175, - FontWeight = FontWeights.Bold - }; - - - TextBlock path_label = new TextBlock () { - Text = "Remote Path:", - Width = 150, - TextAlignment = TextAlignment.Right - }; - - TextBlock path_value = new TextBlock () { - Width = 175, - Text = Controller.PendingInvite.RemotePath, - FontWeight = FontWeights.Bold - }; - - - - Button cancel_button = new Button () { - Content = "Cancel" - }; - - Button add_button = new Button () { - Content = "Add" - }; - - - ContentCanvas.Children.Add (address_label); - Canvas.SetLeft (address_label, 180); - Canvas.SetTop (address_label, 200); - - ContentCanvas.Children.Add (address_value); - Canvas.SetLeft (address_value, 340); - Canvas.SetTop (address_value, 200); - - ContentCanvas.Children.Add (path_label); - Canvas.SetLeft (path_label, 180); - Canvas.SetTop (path_label, 225); - - ContentCanvas.Children.Add (path_value); - Canvas.SetLeft (path_value, 340); - Canvas.SetTop (path_value, 225); - - Buttons.Add (add_button); - Buttons.Add (cancel_button); - - - cancel_button.Click += delegate { - Controller.PageCancelled (); - }; - - add_button.Click += delegate { - Controller.InvitePageCompleted (); - }; - - break; - } - + Header = "You've received an invite!"; + Description = "Do you want to add this project to SparkleShare?"; + + + TextBlock address_label = new TextBlock () { + Text = "Address:", + Width = 150, + TextAlignment = TextAlignment.Right + }; + + TextBlock address_value = new TextBlock () { + Text = Controller.PendingInvite.Address, + Width = 175, + FontWeight = FontWeights.Bold + }; + + + TextBlock path_label = new TextBlock () { + Text = "Remote Path:", + Width = 150, + TextAlignment = TextAlignment.Right + }; + + TextBlock path_value = new TextBlock () { + Width = 175, + Text = Controller.PendingInvite.RemotePath, + FontWeight = FontWeights.Bold + }; + + + + Button cancel_button = new Button () { + Content = "Cancel" + }; + + Button add_button = new Button () { + Content = "Add" + }; + + + ContentCanvas.Children.Add (address_label); + Canvas.SetLeft (address_label, 180); + Canvas.SetTop (address_label, 200); + + ContentCanvas.Children.Add (address_value); + Canvas.SetLeft (address_value, 340); + Canvas.SetTop (address_value, 200); + + ContentCanvas.Children.Add (path_label); + Canvas.SetLeft (path_label, 180); + Canvas.SetTop (path_label, 225); + + ContentCanvas.Children.Add (path_value); + Canvas.SetLeft (path_value, 340); + Canvas.SetTop (path_value, 225); + + Buttons.Add (add_button); + Buttons.Add (cancel_button); + + + cancel_button.Click += delegate { + Controller.PageCancelled (); + }; + + add_button.Click += delegate { + Controller.InvitePageCompleted (); + }; + + break; + } + case PageType.Add: { - Header = "Where's your project hosted?"; - + Header = "Where's your project hosted?"; + - ListView list_view = new ListView () { - Width = 419, - Height = 195, - SelectionMode = SelectionMode.Single - }; - - GridView grid_view = new GridView (); - - grid_view.Columns.Add ( - new GridViewColumn { - DisplayMemberBinding = new Binding ("Text") - } - ); - - // TODO: - // - Disable column headers - // - Add plugin images - // - Nicer markup: Name\nDescription - foreach (SparklePlugin plugin in Controller.Plugins) { - list_view.Items.Add ( - new { - Text = plugin.Name + "\n" + plugin.Description - }); - } - - list_view.View = grid_view; - list_view.SelectedIndex = Controller.SelectedPluginIndex; - - - TextBlock address_label = new TextBlock () { - Text = "Address:", - FontWeight = FontWeights.Bold - }; - - TextBox address_box = new TextBox () { - Width = 200, - Text = Controller.PreviousAddress - }; - - TextBlock address_help_label = new TextBlock () { - Text = "", - FontSize = 11, - Foreground = new SolidColorBrush (Color.FromRgb (128, 128, 128)) - }; - - TextBlock path_label = new TextBlock () { - Text = "Remote Path:", - FontWeight = FontWeights.Bold, - Width = 200 - }; - - TextBox path_box = new TextBox () { - Width = 200, - Text = Controller.PreviousPath - }; - - TextBlock path_help_label = new TextBlock () { - Text = "", - FontSize = 11, - Width = 200, - Foreground = new SolidColorBrush (Color.FromRgb (128, 128, 128)) - }; - - - Button cancel_button = new Button () { - Content = "Cancel" - }; - - Button add_button = new Button () { - Content = "Add" - }; - - - ContentCanvas.Children.Add (list_view); - Canvas.SetTop (list_view, 70); - Canvas.SetLeft (list_view, 185); - - ContentCanvas.Children.Add (address_label); - Canvas.SetTop (address_label, 285); - Canvas.SetLeft (address_label, 185); - - ContentCanvas.Children.Add (address_box); - Canvas.SetTop (address_box, 305); - Canvas.SetLeft (address_box, 185); - - ContentCanvas.Children.Add (address_help_label); - Canvas.SetTop (address_help_label, 330); - Canvas.SetLeft (address_help_label, 185); - - ContentCanvas.Children.Add (path_label); - Canvas.SetTop (path_label, 285); - Canvas.SetRight (path_label, 30); - - ContentCanvas.Children.Add (path_box); - Canvas.SetTop (path_box, 305); - Canvas.SetRight (path_box, 30); - - ContentCanvas.Children.Add (path_help_label); - Canvas.SetTop (path_help_label, 330); - Canvas.SetRight (path_help_label, 30); - + ListView list_view = new ListView () { + Width = 419, + Height = 195, + SelectionMode = SelectionMode.Single + }; + + GridView grid_view = new GridView (); + + grid_view.Columns.Add ( + new GridViewColumn { + DisplayMemberBinding = new Binding ("Text") + } + ); + + // TODO: + // - Disable column headers + // - Add plugin images + // - Nicer markup: Name\nDescription + foreach (SparklePlugin plugin in Controller.Plugins) { + list_view.Items.Add ( + new { + Text = plugin.Name + "\n" + plugin.Description + }); + } + + list_view.View = grid_view; + list_view.SelectedIndex = Controller.SelectedPluginIndex; + + + TextBlock address_label = new TextBlock () { + Text = "Address:", + FontWeight = FontWeights.Bold + }; + + TextBox address_box = new TextBox () { + Width = 200, + Text = Controller.PreviousAddress + }; + + TextBlock address_help_label = new TextBlock () { + Text = "", + FontSize = 11, + Foreground = new SolidColorBrush (Color.FromRgb (128, 128, 128)) + }; + + TextBlock path_label = new TextBlock () { + Text = "Remote Path:", + FontWeight = FontWeights.Bold, + Width = 200 + }; + + TextBox path_box = new TextBox () { + Width = 200, + Text = Controller.PreviousPath + }; + + TextBlock path_help_label = new TextBlock () { + Text = "", + FontSize = 11, + Width = 200, + Foreground = new SolidColorBrush (Color.FromRgb (128, 128, 128)) + }; + + + Button cancel_button = new Button () { + Content = "Cancel" + }; + + Button add_button = new Button () { + Content = "Add" + }; + + + ContentCanvas.Children.Add (list_view); + Canvas.SetTop (list_view, 70); + Canvas.SetLeft (list_view, 185); + + ContentCanvas.Children.Add (address_label); + Canvas.SetTop (address_label, 285); + Canvas.SetLeft (address_label, 185); + + ContentCanvas.Children.Add (address_box); + Canvas.SetTop (address_box, 305); + Canvas.SetLeft (address_box, 185); + + ContentCanvas.Children.Add (address_help_label); + Canvas.SetTop (address_help_label, 330); + Canvas.SetLeft (address_help_label, 185); + + ContentCanvas.Children.Add (path_label); + Canvas.SetTop (path_label, 285); + Canvas.SetRight (path_label, 30); + + ContentCanvas.Children.Add (path_box); + Canvas.SetTop (path_box, 305); + Canvas.SetRight (path_box, 30); + + ContentCanvas.Children.Add (path_help_label); + Canvas.SetTop (path_help_label, 330); + Canvas.SetRight (path_help_label, 30); + - Buttons.Add (add_button); - Buttons.Add (cancel_button); - - + Buttons.Add (add_button); + Buttons.Add (cancel_button); + + Controller.ChangeAddressFieldEvent += delegate (string text, string example_text, FieldState state) { @@ -352,84 +352,84 @@ namespace SparkleShare { path_help_label.Text = example_text; }); }; - - Controller.UpdateAddProjectButtonEvent += delegate (bool button_enabled) { + + Controller.UpdateAddProjectButtonEvent += delegate (bool button_enabled) { Dispatcher.Invoke ((Action) delegate { add_button.IsEnabled = button_enabled; }); }; - - list_view.SelectionChanged += delegate { - Controller.SelectedPluginChanged (list_view.SelectedIndex); - }; - - list_view.KeyDown += delegate { - Controller.SelectedPluginChanged (list_view.SelectedIndex); - }; - - address_box.TextChanged += delegate { - Controller.CheckAddPage ( - address_box.Text, - path_box.Text, - list_view.SelectedIndex - ); - }; - - path_box.TextChanged += delegate { - Controller.CheckAddPage ( - address_box.Text, - path_box.Text, - list_view.SelectedIndex - ); - }; - - cancel_button.Click += delegate { - Controller.PageCancelled (); - }; + + list_view.SelectionChanged += delegate { + Controller.SelectedPluginChanged (list_view.SelectedIndex); + }; + + list_view.KeyDown += delegate { + Controller.SelectedPluginChanged (list_view.SelectedIndex); + }; + + address_box.TextChanged += delegate { + Controller.CheckAddPage ( + address_box.Text, + path_box.Text, + list_view.SelectedIndex + ); + }; + + path_box.TextChanged += delegate { + Controller.CheckAddPage ( + address_box.Text, + path_box.Text, + list_view.SelectedIndex + ); + }; + + cancel_button.Click += delegate { + Controller.PageCancelled (); + }; add_button.Click += delegate { Controller.AddPageCompleted (address_box.Text, path_box.Text); }; - - Controller.CheckAddPage ( - address_box.Text, - path_box.Text, - list_view.SelectedIndex + + Controller.CheckAddPage ( + address_box.Text, + path_box.Text, + list_view.SelectedIndex ); - - break; - } - - - case PageType.Syncing: { - Header = "Adding project ‘" + Controller.SyncingFolder + "’…"; + + break; + } + + + case PageType.Syncing: { + Header = "Adding project ‘" + Controller.SyncingFolder + "’…"; Description = "This may take a while.\n" + "Are you sure it’s not coffee o'clock?"; - - Button finish_button = new Button () { + + Button finish_button = new Button () { Content = "Finish", - IsEnabled = false + IsEnabled = false }; Button cancel_button = new Button () { Content = "Cancel" }; - - ProgressBar progress_bar = new ProgressBar () { - Width = 414, - Height = 15, - Value = 1 - }; - - - ContentCanvas.Children.Add (progress_bar); - Canvas.SetLeft (progress_bar, 185); - Canvas.SetTop (progress_bar, 150); - - Buttons.Add (finish_button); - Buttons.Add (cancel_button); - + + ProgressBar progress_bar = new ProgressBar () { + Width = 414, + Height = 15, + Value = 1 + }; + + + ContentCanvas.Children.Add (progress_bar); + Canvas.SetLeft (progress_bar, 185); + Canvas.SetTop (progress_bar, 150); + + Buttons.Add (finish_button); + Buttons.Add (cancel_button); + Controller.UpdateProgressBarEvent += delegate (double percentage) { Dispatcher.Invoke ((Action) delegate { @@ -440,100 +440,100 @@ namespace SparkleShare { cancel_button.Click += delegate { Controller.SyncingCancelled (); }; - - break; - } - - - case PageType.Error: { - Header = "Something went wrong…"; + + break; + } + + + case PageType.Error: { + Header = "Something went wrong…"; Description = "Please check the following:"; - // TODO: Bullet points - - - Button cancel_button = new Button () { + // TODO: Bullet points + + + Button cancel_button = new Button () { Content = "Cancel" }; - - Button try_again_button = new Button () { + + Button try_again_button = new Button () { Content = "Try again…" }; - - - Buttons.Add (try_again_button); - Buttons.Add (cancel_button); + + + Buttons.Add (try_again_button); + Buttons.Add (cancel_button); - + cancel_button.Click += delegate { Controller.PageCancelled (); }; - - try_again_button.Click += delegate { + + try_again_button.Click += delegate { Controller.ErrorPageCompleted (); }; - - break; - } - - case PageType.Finished: { - Header = "Project ‘" + Path.GetFileName (Controller.PreviousPath) + - "’ succesfully added!"; + + break; + } + + case PageType.Finished: { + Header = "Project ‘" + Path.GetFileName (Controller.PreviousPath) + + "’ succesfully added!"; - Description = "Access the files from your SparkleShare folder."; - - - // TODO: warnings - - Button finish_button = new Button () { + Description = "Access the files from your SparkleShare folder."; + + + // TODO: warnings + + Button finish_button = new Button () { Content = "Finish" }; Button open_folder_button = new Button () { Content = "Open folder" }; - - - Buttons.Add (finish_button); - Buttons.Add (open_folder_button); - - - finish_button.Click += delegate { - Controller.FinishPageCompleted (); - }; + + + Buttons.Add (finish_button); + Buttons.Add (open_folder_button); + + + finish_button.Click += delegate { + Controller.FinishPageCompleted (); + }; open_folder_button.Click += delegate { Controller.OpenFolderClicked (); }; - - - SystemSounds.Exclamation.Play (); - // TODO: Catch attention without having to raise the window - - break; - } - - case PageType.Tutorial: { - - switch (Controller.TutorialPageNumber) { + + + SystemSounds.Exclamation.Play (); + // TODO: Catch attention without having to raise the window + + 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 = 350, - Height = 200 - }; - - slide_image.Source = SparkleUIHelpers.GetImageSource ("tutorial-slide-1-windows"); - - - ContentCanvas.Children.Add (slide_image); - Canvas.SetLeft (slide_image, 215); - Canvas.SetTop (slide_image, 130); - + + WPF.Image slide_image = new WPF.Image () { + Width = 350, + Height = 200 + }; + + slide_image.Source = SparkleUIHelpers.GetImageSource ("tutorial-slide-1-windows"); + + + ContentCanvas.Children.Add (slide_image); + Canvas.SetLeft (slide_image, 215); + Canvas.SetTop (slide_image, 130); + Button skip_tutorial_button = new Button () { Content = "Skip tutorial" }; @@ -542,140 +542,140 @@ namespace SparkleShare { Button continue_button = new Button () { Content = "Continue" }; - - // TODO: Add slides - + + // TODO: Add slides + Buttons.Add (continue_button); Buttons.Add (skip_tutorial_button); - - - skip_tutorial_button.Click += delegate { - Controller.TutorialSkipped (); - }; - - continue_button.Click += delegate { - Controller.TutorialPageCompleted (); - }; - - break; - } - - case 2: { + + + 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 = 350, - Height = 200 - }; - - slide_image.Source = SparkleUIHelpers.GetImageSource ("tutorial-slide-2-windows"); - - - ContentCanvas.Children.Add (slide_image); - Canvas.SetLeft (slide_image, 215); - Canvas.SetTop (slide_image, 130); - - Buttons.Add (continue_button); - - - continue_button.Click += delegate { + + WPF.Image slide_image = new WPF.Image () { + Width = 350, + Height = 200 + }; + + slide_image.Source = SparkleUIHelpers.GetImageSource ("tutorial-slide-2-windows"); + + + ContentCanvas.Children.Add (slide_image); + Canvas.SetLeft (slide_image, 215); + Canvas.SetTop (slide_image, 130); + + Buttons.Add (continue_button); + + + continue_button.Click += delegate { Controller.TutorialPageCompleted (); }; - + break; - } - - case 3: { - Header = "The status icon is here to help"; + } + + case 3: { + Header = "The status icon is here to help"; Description = "It shows the syncing progress, provides easy access to " + "your projects and let's you view recent changes."; - + Button continue_button = new Button () { Content = "Continue" }; - - WPF.Image slide_image = new WPF.Image () { - Width = 350, - Height = 200 - }; - - slide_image.Source = SparkleUIHelpers.GetImageSource ("tutorial-slide-3-windows"); - - - ContentCanvas.Children.Add (slide_image); - Canvas.SetLeft (slide_image, 215); - Canvas.SetTop (slide_image, 130); - - Buttons.Add (continue_button); - - - continue_button.Click += delegate { + + WPF.Image slide_image = new WPF.Image () { + Width = 350, + Height = 200 + }; + + slide_image.Source = SparkleUIHelpers.GetImageSource ("tutorial-slide-3-windows"); + + + ContentCanvas.Children.Add (slide_image); + Canvas.SetLeft (slide_image, 215); + Canvas.SetTop (slide_image, 130); + + Buttons.Add (continue_button); + + + continue_button.Click += delegate { Controller.TutorialPageCompleted (); }; - + break; - } - - case 4: { + } + + case 4: { Header = "Adding projects to SparkleShare"; Description = "You can do this through the status icon menu, or by clicking " + "magic buttons on webpages that look like this:"; - - - Button finish_button = new Button () { + + + Button finish_button = new Button () { Content = "Finish" - }; - - WPF.Image slide_image = new WPF.Image () { - Width = 350, - Height = 64 - }; - - slide_image.Source = SparkleUIHelpers.GetImageSource ("tutorial-slide-4"); + }; + + WPF.Image slide_image = new WPF.Image () { + Width = 350, + Height = 64 + }; + + slide_image.Source = SparkleUIHelpers.GetImageSource ("tutorial-slide-4"); - CheckBox check_box = new CheckBox () { - Content = "Add SparkleShare to startup items", - IsChecked = true - }; - - - ContentCanvas.Children.Add (slide_image); - Canvas.SetLeft (slide_image, 215); - Canvas.SetTop (slide_image, 130); + CheckBox check_box = new CheckBox () { + Content = "Add SparkleShare to startup items", + IsChecked = true + }; + + + ContentCanvas.Children.Add (slide_image); + Canvas.SetLeft (slide_image, 215); + Canvas.SetTop (slide_image, 130); - ContentCanvas.Children.Add (check_box); - Canvas.SetLeft (check_box, 185); - Canvas.SetBottom (check_box, 12); - + 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 (); - }; + + + check_box.Click += delegate { + Controller.StartupItemChanged (check_box.IsChecked.Value); + }; + + finish_button.Click += delegate { + Controller.TutorialPageCompleted (); + }; break; - } - } - break; - } - } - - ShowAll (); - }); - }; - } - } + } + } + break; + } + } + + ShowAll (); + }); + }; + } + } } diff --git a/SparkleShare/Windows/SparkleSetupWindow.cs b/SparkleShare/Windows/SparkleSetupWindow.cs index 7e1c0060..9a8d9e57 100644 --- a/SparkleShare/Windows/SparkleSetupWindow.cs +++ b/SparkleShare/Windows/SparkleSetupWindow.cs @@ -30,141 +30,141 @@ using System.Reflection; namespace SparkleShare { public class SparkleSetupWindow : Window { - - public Canvas ContentCanvas = new Canvas (); - public List