public void ShowPage(PageType type, string [] warnings) { if (type == PageType.Setup) { Header = "Welcome to SparkleShare!"; Description = "First off, what’s your name and email?\n(visible only to team members)"; FullNameLabel = new SparkleLabel("Full Name:", NSTextAlignment.Right); FullNameLabel.Frame = new RectangleF(165, Frame.Height - 234, 160, 17); FullNameTextField = new NSTextField() { Frame = new RectangleF(330, Frame.Height - 238, 196, 22), StringValue = UnixUserInfo.GetRealUser().RealName, Delegate = new SparkleTextFieldDelegate() }; EmailLabel = new SparkleLabel("Email:", NSTextAlignment.Right); EmailLabel.Frame = new RectangleF(165, Frame.Height - 264, 160, 17); EmailTextField = new NSTextField() { Frame = new RectangleF(330, Frame.Height - 268, 196, 22), Delegate = new SparkleTextFieldDelegate() }; CancelButton = new NSButton() { Title = "Cancel" }; ContinueButton = new NSButton() { Title = "Continue", Enabled = false }; (FullNameTextField.Delegate as SparkleTextFieldDelegate).StringValueChanged += delegate { Controller.CheckSetupPage(FullNameTextField.StringValue, EmailTextField.StringValue); }; (EmailTextField.Delegate as SparkleTextFieldDelegate).StringValueChanged += delegate { Controller.CheckSetupPage(FullNameTextField.StringValue, EmailTextField.StringValue); }; ContinueButton.Activated += delegate { string full_name = FullNameTextField.StringValue.Trim(); string email = EmailTextField.StringValue.Trim(); Controller.SetupPageCompleted(full_name, email); }; CancelButton.Activated += delegate { Controller.SetupPageCancelled(); }; Controller.UpdateSetupContinueButtonEvent += delegate(bool button_enabled) { Program.Controller.Invoke(() => { ContinueButton.Enabled = button_enabled; }); }; ContentView.AddSubview(FullNameLabel); ContentView.AddSubview(FullNameTextField); ContentView.AddSubview(EmailLabel); ContentView.AddSubview(EmailTextField); Buttons.Add(ContinueButton); Buttons.Add(CancelButton); Controller.CheckSetupPage(FullNameTextField.StringValue, EmailTextField.StringValue); if (FullNameTextField.StringValue.Equals("")) { MakeFirstResponder((NSResponder)FullNameTextField); } else { MakeFirstResponder((NSResponder)EmailTextField); } } if (type == PageType.Invite) { Header = "You’ve received an invite!"; Description = "Do you want to add this project to SparkleShare?"; AddressLabel = new SparkleLabel("Address:", NSTextAlignment.Right); AddressLabel.Frame = new RectangleF(165, Frame.Height - 240, 160, 17); AddressTextField = new SparkleLabel(Controller.PendingInvite.Address, NSTextAlignment.Left) { Frame = new RectangleF(330, Frame.Height - 240, 260, 17), Font = SparkleUI.BoldFont }; PathLabel = new SparkleLabel("Remote Path:", NSTextAlignment.Right); PathLabel.Frame = new RectangleF(165, Frame.Height - 264, 160, 17); PathTextField = new SparkleLabel(Controller.PendingInvite.RemotePath, NSTextAlignment.Left) { Frame = new RectangleF(330, Frame.Height - 264, 260, 17), Font = SparkleUI.BoldFont }; CancelButton = new NSButton() { Title = "Cancel" }; AddButton = new NSButton() { Title = "Add" }; CancelButton.Activated += delegate { Controller.PageCancelled(); }; AddButton.Activated += delegate { Controller.InvitePageCompleted(); }; ContentView.AddSubview(AddressLabel); ContentView.AddSubview(PathLabel); ContentView.AddSubview(AddressTextField); ContentView.AddSubview(PathTextField); Buttons.Add(AddButton); Buttons.Add(CancelButton); } if (type == PageType.Add) { Header = "Where’s your project hosted?"; Description = ""; AddressLabel = new SparkleLabel("Address:", NSTextAlignment.Left) { Frame = new RectangleF(190, Frame.Height - 308, 160, 17), Font = SparkleUI.BoldFont }; AddressTextField = new NSTextField() { Frame = new RectangleF(190, Frame.Height - 336, 196, 22), Font = SparkleUI.Font, Enabled = (Controller.SelectedPlugin.Address == null), Delegate = new SparkleTextFieldDelegate(), StringValue = "" + Controller.PreviousAddress }; AddressTextField.Cell.LineBreakMode = NSLineBreakMode.TruncatingTail; PathLabel = new SparkleLabel("Remote Path:", NSTextAlignment.Left) { Frame = new RectangleF(190 + 196 + 16, Frame.Height - 308, 160, 17), Font = SparkleUI.BoldFont }; PathTextField = new NSTextField() { Frame = new RectangleF(190 + 196 + 16, Frame.Height - 336, 196, 22), Enabled = (Controller.SelectedPlugin.Path == null), Delegate = new SparkleTextFieldDelegate(), StringValue = "" + Controller.PreviousPath }; PathTextField.Cell.LineBreakMode = NSLineBreakMode.TruncatingTail; PathHelpLabel = new SparkleLabel(Controller.SelectedPlugin.PathExample, NSTextAlignment.Left) { TextColor = NSColor.DisabledControlText, Frame = new RectangleF(190 + 196 + 16, Frame.Height - 355, 204, 17), Font = NSFontManager.SharedFontManager.FontWithFamily("Lucida Grande", NSFontTraitMask.Condensed, 0, 11), }; AddressHelpLabel = new SparkleLabel(Controller.SelectedPlugin.AddressExample, NSTextAlignment.Left) { TextColor = NSColor.DisabledControlText, Frame = new RectangleF(190, Frame.Height - 355, 204, 17), Font = NSFontManager.SharedFontManager.FontWithFamily("Lucida Grande", NSFontTraitMask.Condensed, 0, 11), }; if (TableView == null || TableView.RowCount != Controller.Plugins.Count) { TableView = new NSTableView() { Frame = new RectangleF(0, 0, 0, 0), RowHeight = 34, IntercellSpacing = new SizeF(8, 12), HeaderView = null, Delegate = new SparkleTableViewDelegate() }; ScrollView = new NSScrollView() { Frame = new RectangleF(190, Frame.Height - 280, 408, 185), DocumentView = TableView, HasVerticalScroller = true, BorderType = NSBorderType.BezelBorder }; IconColumn = new NSTableColumn() { Width = 36, HeaderToolTip = "Icon", DataCell = new NSImageCell() { ImageAlignment = NSImageAlignment.Right } }; DescriptionColumn = new NSTableColumn() { Width = 350, HeaderToolTip = "Description", Editable = false }; DescriptionColumn.DataCell.Font = NSFontManager.SharedFontManager.FontWithFamily("Lucida Grande", NSFontTraitMask.Condensed, 0, 11); TableView.AddColumn(IconColumn); TableView.AddColumn(DescriptionColumn); // Hi-res display support was added after Snow Leopard if (Environment.OSVersion.Version.Major < 11) { DataSource = new SparkleDataSource(1, Controller.Plugins); } else { DataSource = new SparkleDataSource(BackingScaleFactor, Controller.Plugins); } TableView.DataSource = DataSource; TableView.ReloadData(); (TableView.Delegate as SparkleTableViewDelegate).SelectionChanged += delegate { Controller.SelectedPluginChanged(TableView.SelectedRow); Controller.CheckAddPage(AddressTextField.StringValue, PathTextField.StringValue, TableView.SelectedRow); }; } TableView.SelectRow(Controller.SelectedPluginIndex, false); TableView.ScrollRowToVisible(Controller.SelectedPluginIndex); MakeFirstResponder((NSResponder)TableView); HistoryCheckButton = new NSButton() { Frame = new RectangleF(190, Frame.Height - 400, 300, 18), Title = "Fetch prior revisions" }; if (Controller.FetchPriorHistory) { HistoryCheckButton.State = NSCellStateValue.On; } HistoryCheckButton.SetButtonType(NSButtonType.Switch); AddButton = new NSButton() { Title = "Add", Enabled = false }; CancelButton = new NSButton() { Title = "Cancel" }; Controller.ChangeAddressFieldEvent += delegate(string text, string example_text, FieldState state) { Program.Controller.Invoke(() => { AddressTextField.StringValue = text; AddressTextField.Enabled = (state == FieldState.Enabled); AddressHelpLabel.StringValue = example_text; }); }; Controller.ChangePathFieldEvent += delegate(string text, string example_text, FieldState state) { Program.Controller.Invoke(() => { PathTextField.StringValue = text; PathTextField.Enabled = (state == FieldState.Enabled); PathHelpLabel.StringValue = example_text; }); }; (AddressTextField.Delegate as SparkleTextFieldDelegate).StringValueChanged += delegate { Controller.CheckAddPage(AddressTextField.StringValue, PathTextField.StringValue, TableView.SelectedRow); }; (PathTextField.Delegate as SparkleTextFieldDelegate).StringValueChanged += delegate { Controller.CheckAddPage(AddressTextField.StringValue, PathTextField.StringValue, TableView.SelectedRow); }; HistoryCheckButton.Activated += delegate { Controller.HistoryItemChanged(HistoryCheckButton.State == NSCellStateValue.On); }; AddButton.Activated += delegate { Controller.AddPageCompleted(AddressTextField.StringValue, PathTextField.StringValue); }; CancelButton.Activated += delegate { Controller.PageCancelled(); }; Controller.UpdateAddProjectButtonEvent += delegate(bool button_enabled) { Program.Controller.Invoke(() => { AddButton.Enabled = button_enabled; }); }; ContentView.AddSubview(ScrollView); ContentView.AddSubview(AddressLabel); ContentView.AddSubview(AddressTextField); ContentView.AddSubview(AddressHelpLabel); ContentView.AddSubview(PathLabel); ContentView.AddSubview(PathTextField); ContentView.AddSubview(PathHelpLabel); ContentView.AddSubview(HistoryCheckButton); Buttons.Add(AddButton); Buttons.Add(CancelButton); Controller.CheckAddPage(AddressTextField.StringValue, PathTextField.StringValue, TableView.SelectedRow); } if (type == PageType.Syncing) { Header = "Adding project ‘" + Controller.SyncingFolder + "’…"; Description = "This may take a while for large projects.\nIsn’t it coffee-o’clock?"; ProgressIndicator = new NSProgressIndicator() { Frame = new RectangleF(190, Frame.Height - 200, 640 - 150 - 80, 20), Style = NSProgressIndicatorStyle.Bar, MinValue = 0.0, MaxValue = 100.0, Indeterminate = false, DoubleValue = Controller.ProgressBarPercentage }; ProgressIndicator.StartAnimation(this); CancelButton = new NSButton() { Title = "Cancel" }; FinishButton = new NSButton() { Title = "Finish", Enabled = false }; ProgressLabel = new SparkleLabel("Preparing to fetch files…", NSTextAlignment.Right); ProgressLabel.Frame = new RectangleF(Frame.Width - 40 - 250, 185, 250, 25); Controller.UpdateProgressBarEvent += delegate(double percentage, string speed) { Program.Controller.Invoke(() => { ProgressIndicator.DoubleValue = percentage; ProgressLabel.StringValue = speed; }); }; CancelButton.Activated += delegate { Controller.SyncingCancelled(); }; ContentView.AddSubview(ProgressLabel); ContentView.AddSubview(ProgressIndicator); Buttons.Add(FinishButton); Buttons.Add(CancelButton); } if (type == PageType.Error) { Header = "Oops! Something went wrong…"; Description = "Please check the following:"; // Displaying marked up text with Cocoa is // a pain, so we just use a webview instead WebView web_view = new WebView(); web_view.Frame = new RectangleF(190, Frame.Height - 525, 375, 400); string html = "<style>" + "* {" + " font-family: 'Lucida Grande';" + " font-size: 12px; cursor: default;" + "}" + "body {" + " -webkit-user-select: none;" + " margin: 0;" + " padding: 3px;" + "}" + "li {" + " margin-bottom: 16px;" + " margin-left: 0;" + " padding-left: 0;" + " line-height: 20px;" + " word-wrap: break-word;" + "}" + "ul {" + " padding-left: 24px;" + "}" + "</style>" + "<ul>" + " <li><b>" + Controller.PreviousUrl + "</b> is the address we’ve compiled. Does this look alright?</li>" + " <li>Is this computer’s Client ID known by the host?</li>" + "</ul>"; if (warnings.Length > 0) { string warnings_markup = ""; foreach (string warning in warnings) { warnings_markup += "<br><b>" + warning + "</b>"; } html = html.Replace("</ul>", "<li>Here’s the raw error message: " + warnings_markup + "</li></ul>"); } web_view.MainFrame.LoadHtmlString(html, new NSUrl("")); web_view.DrawsBackground = false; CancelButton = new NSButton() { Title = "Cancel" }; TryAgainButton = new NSButton() { Title = "Try Again…" }; CancelButton.Activated += delegate { Controller.PageCancelled(); }; TryAgainButton.Activated += delegate { Controller.ErrorPageCompleted(); }; ContentView.AddSubview(web_view); Buttons.Add(TryAgainButton); Buttons.Add(CancelButton); } if (type == PageType.CryptoSetup || type == PageType.CryptoPassword) { if (type == PageType.CryptoSetup) { Header = "Set up file encryption"; Description = "Please a provide a strong password that you don’t use elsewhere."; } else { Header = "This project contains encrypted files"; Description = "Please enter the password to see their contents."; } int extra_pos_y = 0; if (type == PageType.CryptoPassword) { extra_pos_y = 20; } PasswordLabel = new SparkleLabel("Password:"******"Show password", State = NSCellStateValue.Off }; ShowPasswordCheckButton.SetButtonType(NSButtonType.Switch); WarningImage = NSImage.ImageNamed("NSInfo"); WarningImage.Size = new SizeF(24, 24); WarningImageView = new NSImageView() { Image = WarningImage, Frame = new RectangleF(200, Frame.Height - 320, 24, 24) }; WarningTextField = new SparkleLabel("This password can’t be changed later, and your files can’t be recovered if it’s forgotten.", NSTextAlignment.Left) { Frame = new RectangleF(235, Frame.Height - 390, 325, 100), }; CancelButton = new NSButton() { Title = "Cancel" }; ContinueButton = new NSButton() { Title = "Continue", Enabled = false }; Controller.UpdateCryptoPasswordContinueButtonEvent += delegate(bool button_enabled) { Program.Controller.Invoke(() => { ContinueButton.Enabled = button_enabled; }); }; Controller.UpdateCryptoSetupContinueButtonEvent += delegate(bool button_enabled) { Program.Controller.Invoke(() => { ContinueButton.Enabled = button_enabled; }); }; ShowPasswordCheckButton.Activated += delegate { if (PasswordTextField.Superview == ContentView) { PasswordTextField.RemoveFromSuperview(); ContentView.AddSubview(VisiblePasswordTextField); } else { VisiblePasswordTextField.RemoveFromSuperview(); ContentView.AddSubview(PasswordTextField); } }; (PasswordTextField.Delegate as SparkleTextFieldDelegate).StringValueChanged += delegate { VisiblePasswordTextField.StringValue = PasswordTextField.StringValue; if (type == PageType.CryptoSetup) { Controller.CheckCryptoSetupPage(PasswordTextField.StringValue); } else { Controller.CheckCryptoPasswordPage(PasswordTextField.StringValue); } }; (VisiblePasswordTextField.Delegate as SparkleTextFieldDelegate).StringValueChanged += delegate { PasswordTextField.StringValue = VisiblePasswordTextField.StringValue; if (type == PageType.CryptoSetup) { Controller.CheckCryptoSetupPage(PasswordTextField.StringValue); } else { Controller.CheckCryptoPasswordPage(PasswordTextField.StringValue); } }; ContinueButton.Activated += delegate { if (type == PageType.CryptoSetup) { Controller.CryptoSetupPageCompleted(PasswordTextField.StringValue); } else { Controller.CryptoPasswordPageCompleted(PasswordTextField.StringValue); } }; CancelButton.Activated += delegate { Controller.CryptoPageCancelled(); }; ContentView.AddSubview(PasswordLabel); ContentView.AddSubview(PasswordTextField); ContentView.AddSubview(ShowPasswordCheckButton); if (type == PageType.CryptoSetup) { ContentView.AddSubview(WarningImageView); ContentView.AddSubview(WarningTextField); } Buttons.Add(ContinueButton); Buttons.Add(CancelButton); MakeFirstResponder((NSResponder)PasswordTextField); NSApplication.SharedApplication.RequestUserAttention(NSRequestUserAttentionType.CriticalRequest); } if (type == PageType.Finished) { Header = "Your shared project is ready!"; Description = "You can find the files in your SparkleShare folder."; if (warnings.Length > 0) { WarningImage = NSImage.ImageNamed("NSInfo"); WarningImage.Size = new SizeF(24, 24); WarningImageView = new NSImageView() { Image = WarningImage, Frame = new RectangleF(200, Frame.Height - 175, 24, 24) }; WarningTextField = new SparkleLabel(warnings [0], NSTextAlignment.Left); WarningTextField.Frame = new RectangleF(235, Frame.Height - 245, 325, 100); ContentView.AddSubview(WarningImageView); ContentView.AddSubview(WarningTextField); } ShowFilesButton = new NSButton() { Title = "Show Files…" }; FinishButton = new NSButton() { Title = "Finish" }; ShowFilesButton.Activated += delegate { Controller.ShowFilesClicked(); }; FinishButton.Activated += delegate { Controller.FinishPageCompleted(); }; Buttons.Add(FinishButton); Buttons.Add(ShowFilesButton); NSApplication.SharedApplication.RequestUserAttention(NSRequestUserAttentionType.CriticalRequest); } if (type == PageType.Tutorial) { SlideImage = NSImage.ImageNamed("tutorial-slide-" + Controller.TutorialPageNumber); if (SlideImage != null) { SlideImage.Size = new SizeF(324, 200); SlideImageView = new NSImageView() { Image = SlideImage, Frame = new RectangleF(228, Frame.Height - 350, 324, 200) }; ContentView.AddSubview(SlideImageView); } 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."; SkipTutorialButton = new NSButton() { Title = "Skip Tutorial" }; ContinueButton = new NSButton() { Title = "Continue" }; SkipTutorialButton.Activated += delegate { Controller.TutorialSkipped(); }; ContinueButton.Activated += delegate { Controller.TutorialPageCompleted(); }; ContentView.AddSubview(SlideImageView); Buttons.Add(ContinueButton); Buttons.Add(SkipTutorialButton); 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."; ContinueButton = new NSButton() { Title = "Continue" }; ContinueButton.Activated += delegate { Controller.TutorialPageCompleted(); }; Buttons.Add(ContinueButton); break; } case 3: { Header = "The status icon helps you"; Description = "It shows the syncing progress, provides easy access to " + "your projects, and lets you view recent changes."; ContinueButton = new NSButton() { Title = "Continue" }; ContinueButton.Activated += delegate { Controller.TutorialPageCompleted(); }; Buttons.Add(ContinueButton); break; } case 4: { Header = "Here’s your unique Client ID"; Description = "You’ll need it whenever you want to link this computer to a host. " + "You can also find it in the status icon menu."; LinkCodeTextField = new NSTextField() { StringValue = Program.Controller.CurrentUser.PublicKey, Enabled = false, Selectable = false, Frame = new RectangleF(230, Frame.Height - 238, 246, 22) }; LinkCodeTextField.Cell.UsesSingleLineMode = true; LinkCodeTextField.Cell.LineBreakMode = NSLineBreakMode.TruncatingTail; CopyButton = new NSButton() { Title = "Copy", BezelStyle = NSBezelStyle.RoundRect, Frame = new RectangleF(480, Frame.Height - 238, 60, 22) }; StartupCheckButton = new NSButton() { Frame = new RectangleF(190, Frame.Height - 400, 300, 18), Title = "Add SparkleShare to startup items", State = NSCellStateValue.On }; StartupCheckButton.SetButtonType(NSButtonType.Switch); FinishButton = new NSButton() { Title = "Finish" }; StartupCheckButton.Activated += delegate { Controller.StartupItemChanged(StartupCheckButton.State == NSCellStateValue.On); }; CopyButton.Activated += delegate { Controller.CopyToClipboardClicked(); }; FinishButton.Activated += delegate { Controller.TutorialPageCompleted(); }; ContentView.AddSubview(LinkCodeTextField); ContentView.AddSubview(CopyButton); ContentView.AddSubview(StartupCheckButton); Buttons.Add(FinishButton); break; } } } }
public SparkleSetup() : base() { Controller.HideWindowEvent += delegate { Application.Invoke(delegate { HideAll(); }); }; Controller.ShowWindowEvent += delegate { Application.Invoke(delegate { ShowAll(); Present(); }); }; Controller.ChangePageEvent += delegate(PageType type, string [] warnings) { Application.Invoke(delegate { Reset(); switch (type) { case PageType.Setup: { Header = "Welcome to SparkleShare!"; Description = "First off, what's your name and email?\nThis information is only visible to team members."; Table table = new Table(2, 3, true) { RowSpacing = 6, ColumnSpacing = 6 }; Label name_label = new Label("<b>" + "Full Name:" + "</b>") { UseMarkup = true, Xalign = 1 }; Entry name_entry = new Entry() { Xalign = 0, ActivatesDefault = true }; UnixUserInfo user_info = UnixUserInfo.GetRealUser(); if (user_info != null && user_info.RealName != null) { name_entry.Text = user_info.RealName.TrimEnd(",".ToCharArray()); } Entry email_entry = new Entry() { Xalign = 0, ActivatesDefault = true }; name_entry.Changed += delegate { Controller.CheckSetupPage(name_entry.Text, email_entry.Text); }; email_entry.Changed += delegate { Controller.CheckSetupPage(name_entry.Text, email_entry.Text); }; Label email_label = new Label("<b>" + "Email:" + "</b>") { UseMarkup = true, Xalign = 1 }; table.Attach(name_label, 0, 1, 0, 1); table.Attach(name_entry, 1, 2, 0, 1); table.Attach(email_label, 0, 1, 1, 2); table.Attach(email_entry, 1, 2, 1, 2); VBox wrapper = new VBox(false, 9); wrapper.PackStart(table, true, false, 0); Button cancel_button = new Button("Cancel"); cancel_button.Clicked += delegate { Controller.SetupPageCancelled(); }; Button continue_button = new Button("Continue") { Sensitive = false }; continue_button.Clicked += delegate { Controller.SetupPageCompleted(name_entry.Text, email_entry.Text); }; AddButton(cancel_button); AddButton(continue_button); Add(wrapper); Controller.UpdateSetupContinueButtonEvent += delegate(bool button_enabled) { Application.Invoke(delegate { continue_button.Sensitive = button_enabled; }); }; Controller.CheckSetupPage(name_entry.Text, email_entry.Text); break; } case PageType.Add: { Header = "Where's your project hosted?"; VBox layout_vertical = new VBox(false, 12); HBox layout_fields = new HBox(true, 12); VBox layout_address = new VBox(true, 0); VBox layout_path = new VBox(true, 0); ListStore store = new ListStore(typeof(Gdk.Pixbuf), typeof(string), typeof(SparklePlugin)); SparkleTreeView tree = new SparkleTreeView(store) { HeadersVisible = false }; ScrolledWindow scrolled_window = new ScrolledWindow(); scrolled_window.AddWithViewport(tree); // Icon column tree.AppendColumn("Icon", new Gtk.CellRendererPixbuf(), "pixbuf", 0); tree.Columns [0].Cells [0].Xpad = 6; // Service column TreeViewColumn service_column = new TreeViewColumn() { Title = "Service" }; CellRendererText service_cell = new CellRendererText() { Ypad = 4 }; service_column.PackStart(service_cell, true); service_column.SetCellDataFunc(service_cell, new TreeCellDataFunc(RenderServiceColumn)); foreach (SparklePlugin plugin in Controller.Plugins) { store.AppendValues( new Gdk.Pixbuf(plugin.ImagePath), "<span size=\"small\"><b>" + plugin.Name + "</b>\n" + "<span fgcolor=\"" + SecondaryTextColorSelected + "\">" + plugin.Description + "</span>" + "</span>", plugin); } tree.AppendColumn(service_column); Entry address_entry = new Entry() { Text = Controller.PreviousAddress, Sensitive = (Controller.SelectedPlugin.Address == null), ActivatesDefault = true }; Entry path_entry = new Entry() { Text = Controller.PreviousPath, Sensitive = (Controller.SelectedPlugin.Path == null), ActivatesDefault = true }; Label address_example = new Label() { Xalign = 0, UseMarkup = true, Markup = "<span size=\"small\" fgcolor=\"" + SecondaryTextColor + "\">" + Controller.SelectedPlugin.AddressExample + "</span>" }; Label path_example = new Label() { Xalign = 0, UseMarkup = true, Markup = "<span size=\"small\" fgcolor=\"" + SecondaryTextColor + "\">" + Controller.SelectedPlugin.PathExample + "</span>" }; // Select the first plugin by default TreeSelection default_selection = tree.Selection; TreePath default_path = new TreePath("0"); default_selection.SelectPath(default_path); Controller.SelectedPluginChanged(0); Controller.ChangeAddressFieldEvent += delegate(string text, string example_text, FieldState state) { Application.Invoke(delegate { address_entry.Text = text; address_entry.Sensitive = (state == FieldState.Enabled); address_example.Markup = "<span size=\"small\" fgcolor=\"" + SecondaryTextColor + "\">" + example_text + "</span>"; }); }; Controller.ChangePathFieldEvent += delegate(string text, string example_text, FieldState state) { Application.Invoke(delegate { path_entry.Text = text; path_entry.Sensitive = (state == FieldState.Enabled); path_example.Markup = "<span size=\"small\" fgcolor=\"" + SecondaryTextColor + "\">" + example_text + "</span>"; }); }; Controller.CheckAddPage(address_entry.Text, path_entry.Text, 1); // Update the address field text when the selection changes tree.CursorChanged += delegate(object sender, EventArgs e) { Controller.SelectedPluginChanged(tree.SelectedRow); // TODO: Scroll to selected row when using arrow keys }; tree.Model.Foreach(new TreeModelForeachFunc(delegate(TreeModel model, TreePath path, TreeIter iter) { string address; try { address = (model.GetValue(iter, 2) as SparklePlugin).Address; } catch (NullReferenceException) { address = ""; } if (!string.IsNullOrEmpty(address) && address.Equals(Controller.PreviousAddress)) { tree.SetCursor(path, service_column, false); SparklePlugin plugin = (SparklePlugin)model.GetValue(iter, 2); if (plugin.Address != null) { address_entry.Sensitive = false; } if (plugin.Path != null) { path_entry.Sensitive = false; } // TODO: Scroll to the selection return(true); } else { return(false); } })); address_entry.Changed += delegate { Controller.CheckAddPage(address_entry.Text, path_entry.Text, tree.SelectedRow); }; layout_address.PackStart(new Label() { Markup = "<b>" + "Address:" + "</b>", Xalign = 0 }, true, true, 0); layout_address.PackStart(address_entry, false, false, 0); layout_address.PackStart(address_example, false, false, 0); path_entry.Changed += delegate { Controller.CheckAddPage(address_entry.Text, path_entry.Text, tree.SelectedRow); }; layout_path.PackStart(new Label() { Markup = "<b>" + "Remote Path:" + "</b>", Xalign = 0 }, true, true, 0); layout_path.PackStart(path_entry, false, false, 0); layout_path.PackStart(path_example, false, false, 0); layout_fields.PackStart(layout_address); layout_fields.PackStart(layout_path); layout_vertical.PackStart(new Label(""), false, false, 0); layout_vertical.PackStart(scrolled_window, true, true, 0); layout_vertical.PackStart(layout_fields, false, false, 0); Add(layout_vertical); // Cancel button Button cancel_button = new Button("Cancel"); cancel_button.Clicked += delegate { Controller.PageCancelled(); }; Button add_button = new Button("Add") { Sensitive = false }; add_button.Clicked += delegate { Controller.AddPageCompleted(address_entry.Text, path_entry.Text); }; Controller.UpdateAddProjectButtonEvent += delegate(bool button_enabled) { Application.Invoke(delegate { add_button.Sensitive = button_enabled; }); }; CheckButton check_button = new CheckButton("Fetch prior history") { Active = false }; check_button.Toggled += delegate { Controller.HistoryItemChanged(check_button.Active); }; AddOption(check_button); AddButton(cancel_button); AddButton(add_button); Controller.CheckAddPage(address_entry.Text, path_entry.Text, 1); break; } case PageType.Invite: { Header = "You've received an invite!"; Description = "Do you want to add this project to SparkleShare?"; Table table = new Table(2, 3, true) { RowSpacing = 6, ColumnSpacing = 6 }; Label address_label = new Label("Address:") { Xalign = 1 }; Label path_label = new Label("Remote Path:") { Xalign = 1 }; Label address_value = new Label("<b>" + Controller.PendingInvite.Address + "</b>") { UseMarkup = true, Xalign = 0 }; Label path_value = new Label("<b>" + Controller.PendingInvite.RemotePath + "</b>") { UseMarkup = true, Xalign = 0 }; table.Attach(address_label, 0, 1, 0, 1); table.Attach(address_value, 1, 2, 0, 1); table.Attach(path_label, 0, 1, 1, 2); table.Attach(path_value, 1, 2, 1, 2); VBox wrapper = new VBox(false, 9); wrapper.PackStart(table, true, false, 0); Button cancel_button = new Button("Cancel"); cancel_button.Clicked += delegate { Controller.PageCancelled(); }; Button add_button = new Button("Add"); add_button.Clicked += delegate { Controller.InvitePageCompleted(); }; AddButton(cancel_button); AddButton(add_button); Add(wrapper); break; } case PageType.Syncing: { Header = String.Format("Adding project ‘{0}’…", Controller.SyncingFolder); Description = "This may take a while for large projects.\nIsn't it coffee-o'clock?"; this.progress_bar.Fraction = Controller.ProgressBarPercentage / 100; Button finish_button = new Button() { Sensitive = false, Label = "Finish" }; Button cancel_button = new Button() { Label = "Cancel" }; cancel_button.Clicked += delegate { Controller.SyncingCancelled(); }; AddButton(cancel_button); AddButton(finish_button); Controller.UpdateProgressBarEvent += delegate(double percentage) { Application.Invoke(delegate { this.progress_bar.Fraction = percentage / 100; }); }; if (this.progress_bar.Parent != null) { (this.progress_bar.Parent as Container).Remove(this.progress_bar); } VBox bar_wrapper = new VBox(false, 0); bar_wrapper.PackStart(this.progress_bar, false, false, 15); Add(bar_wrapper); break; } case PageType.Error: { Header = "Oops! Something went wrong" + "…"; VBox points = new VBox(false, 0); Image list_point_one = new Image(SparkleUIHelpers.GetIcon("list-point", 16)); Image list_point_two = new Image(SparkleUIHelpers.GetIcon("list-point", 16)); Image list_point_three = new Image(SparkleUIHelpers.GetIcon("list-point", 16)); Label label_one = new Label() { Markup = "<b>" + Controller.PreviousUrl + "</b> is the address we've compiled. " + "Does this look alright?", Wrap = true, Xalign = 0 }; Label label_two = new Label() { Text = "Do you have access rights to this remote project?", Wrap = true, Xalign = 0 }; points.PackStart(new Label("Please check the following:") { Xalign = 0 }, false, false, 6); HBox point_one = new HBox(false, 0); point_one.PackStart(list_point_one, false, false, 0); point_one.PackStart(label_one, true, true, 12); points.PackStart(point_one, false, false, 12); HBox point_two = new HBox(false, 0); point_two.PackStart(list_point_two, false, false, 0); point_two.PackStart(label_two, true, true, 12); points.PackStart(point_two, false, false, 12); if (warnings.Length > 0) { string warnings_markup = ""; foreach (string warning in warnings) { warnings_markup += "\n<b>" + warning + "</b>"; } Label label_three = new Label() { Markup = "Here's the raw error message:" + warnings_markup, Wrap = true, Xalign = 0 }; HBox point_three = new HBox(false, 0); point_three.PackStart(list_point_three, false, false, 0); point_three.PackStart(label_three, true, true, 12); points.PackStart(point_three, false, false, 12); } points.PackStart(new Label(""), true, true, 0); Button cancel_button = new Button("Cancel"); cancel_button.Clicked += delegate { Controller.PageCancelled(); }; Button try_again_button = new Button("Try Again…") { Sensitive = true }; try_again_button.Clicked += delegate { Controller.ErrorPageCompleted(); }; AddButton(cancel_button); AddButton(try_again_button); Add(points); break; } case PageType.CryptoSetup: { Header = "Set up file encryption"; Description = "Please a provide a strong password that you don't use elsewhere below:"; Label password_label = new Label("<b>" + "Password:"******"</b>") { UseMarkup = true, Xalign = 1 }; Entry password_entry = new Entry() { Xalign = 0, Visibility = false, ActivatesDefault = true }; CheckButton show_password_check_button = new CheckButton("Show password") { Active = false, Xalign = 0, }; show_password_check_button.Toggled += delegate { password_entry.Visibility = !password_entry.Visibility; }; password_entry.Changed += delegate { Controller.CheckCryptoSetupPage(password_entry.Text); }; Button continue_button = new Button("Continue") { Sensitive = false }; continue_button.Clicked += delegate { Controller.CryptoSetupPageCompleted(password_entry.Text); }; Button cancel_button = new Button("Cancel"); cancel_button.Clicked += delegate { Controller.CryptoPageCancelled(); }; Controller.UpdateCryptoSetupContinueButtonEvent += delegate(bool button_enabled) { Application.Invoke(delegate { continue_button.Sensitive = button_enabled; }); }; Table table = new Table(2, 3, true) { RowSpacing = 6, ColumnSpacing = 6 }; table.Attach(password_label, 0, 1, 0, 1); table.Attach(password_entry, 1, 2, 0, 1); table.Attach(show_password_check_button, 1, 2, 1, 2); VBox wrapper = new VBox(false, 9); wrapper.PackStart(table, true, false, 0); Image warning_image = new Image( SparkleUIHelpers.GetIcon("dialog-information", 24) ); Label warning_label = new Label() { Xalign = 0, Wrap = true, Text = "This password can't be changed later, and your files can't be recovered if it's forgotten." }; HBox warning_layout = new HBox(false, 0); warning_layout.PackStart(warning_image, false, false, 15); warning_layout.PackStart(warning_label, true, true, 0); VBox warning_wrapper = new VBox(false, 0); warning_wrapper.PackStart(warning_layout, false, false, 15); wrapper.PackStart(warning_wrapper, false, false, 0); Add(wrapper); AddButton(cancel_button); AddButton(continue_button); break; } case PageType.CryptoPassword: { Header = "This project contains encrypted files"; Description = "Please enter the password to see their contents."; Label password_label = new Label("<b>" + "Password:"******"</b>") { UseMarkup = true, Xalign = 1 }; Entry password_entry = new Entry() { Xalign = 0, Visibility = false, ActivatesDefault = true }; CheckButton show_password_check_button = new CheckButton("Show password") { Active = false, Xalign = 0 }; show_password_check_button.Toggled += delegate { password_entry.Visibility = !password_entry.Visibility; }; password_entry.Changed += delegate { Controller.CheckCryptoPasswordPage(password_entry.Text); }; Button continue_button = new Button("Continue") { Sensitive = false }; continue_button.Clicked += delegate { Controller.CryptoPasswordPageCompleted(password_entry.Text); }; Button cancel_button = new Button("Cancel"); cancel_button.Clicked += delegate { Controller.CryptoPageCancelled(); }; Controller.UpdateCryptoPasswordContinueButtonEvent += delegate(bool button_enabled) { Application.Invoke(delegate { continue_button.Sensitive = button_enabled; }); }; Table table = new Table(2, 3, true) { RowSpacing = 6, ColumnSpacing = 6 }; table.Attach(password_label, 0, 1, 0, 1); table.Attach(password_entry, 1, 2, 0, 1); table.Attach(show_password_check_button, 1, 2, 1, 2); VBox wrapper = new VBox(false, 9); wrapper.PackStart(table, true, false, 0); Add(wrapper); AddButton(cancel_button); AddButton(continue_button); break; } case PageType.Finished: { UrgencyHint = true; if (!HasToplevelFocus) { string title = "Your shared project is ready!"; string subtext = "You can find the files in your SparkleShare folder."; Program.UI.Bubbles.Controller.ShowBubble(title, subtext, null); } Header = "Your shared project is ready!"; Description = "You can find it in your SparkleShare folder"; // A button that opens the synced folder Button show_files_button = new Button("Show Files…"); show_files_button.Clicked += delegate { Controller.ShowFilesClicked(); }; Button finish_button = new Button("Finish"); finish_button.Clicked += delegate { Controller.FinishPageCompleted(); }; if (warnings.Length > 0) { Image warning_image = new Image( SparkleUIHelpers.GetIcon("dialog-information", 24)); Label warning_label = new Label(warnings [0]) { Xalign = 0, Wrap = true }; HBox warning_layout = new HBox(false, 0); warning_layout.PackStart(warning_image, false, false, 15); warning_layout.PackStart(warning_label, true, true, 0); VBox warning_wrapper = new VBox(false, 0); warning_wrapper.PackStart(warning_layout, false, false, 0); Add(warning_wrapper); } else { Add(null); } AddButton(show_files_button); AddButton(finish_button); 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."; Button skip_tutorial_button = new Button("Skip Tutorial"); skip_tutorial_button.Clicked += delegate { Controller.TutorialSkipped(); }; Button continue_button = new Button("Continue"); continue_button.Clicked += delegate { Controller.TutorialPageCompleted(); }; Image slide = SparkleUIHelpers.GetImage("tutorial-slide-1.png"); Add(slide); AddButton(skip_tutorial_button); AddButton(continue_button); 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("Continue"); continue_button.Clicked += delegate { Controller.TutorialPageCompleted(); }; Image slide = SparkleUIHelpers.GetImage("tutorial-slide-2.png"); Add(slide); AddButton(continue_button); break; } case 3: { Header = "The status icon helps you"; Description = "It shows the syncing progress, provides easy access to " + "your projects and let's you view recent changes."; Button continue_button = new Button("Continue"); continue_button.Clicked += delegate { Controller.TutorialPageCompleted(); }; Image slide = SparkleUIHelpers.GetImage("tutorial-slide-3.png"); Add(slide); AddButton(continue_button); break; } case 4: { Header = "Here's your unique link code"; Description = "You'll need it whenever you want to link this computer to a host" + " (we keep a copy in your SparkleShare folder)."; Button finish_button = new Button("Finish"); VBox layout_vertical = new VBox(false, 0) { BorderWidth = 48 }; HBox layout_horizontal = new HBox(false, 6); Entry link_code_entry = new Entry() { Text = Program.Controller.CurrentUser.PublicKey, Sensitive = false }; Button copy_button = new Button(" Copy "); CheckButton check_button = new CheckButton("Add SparkleShare to startup items") { Active = true }; check_button.Toggled += delegate { Controller.StartupItemChanged(check_button.Active); }; copy_button.Clicked += delegate { Clipboard clip_board = Clipboard.Get(Gdk.Atom.Intern("CLIPBOARD", false)); clip_board.Text = link_code_entry.Text; }; finish_button.Clicked += delegate { Controller.TutorialPageCompleted(); }; layout_horizontal.PackStart(link_code_entry, true, true, 0); layout_horizontal.PackStart(copy_button, false, false, 0); layout_vertical.PackStart(new Label(""), true, true, 0); layout_vertical.PackStart(layout_horizontal, false, false, 0); layout_vertical.PackStart(new Label(""), true, true, 18); Add(layout_vertical); AddOption(check_button); AddButton(finish_button); break; } } break; } } ShowAll(); }); }; }
public SparkleSetup() { Controller.ShowWindowEvent += delegate { Dispatcher.BeginInvoke((Action) delegate { Show(); Activate(); BringIntoView(); }); }; Controller.HideWindowEvent += delegate { Dispatcher.BeginInvoke((Action) delegate { Hide(); }); }; Controller.ChangePageEvent += delegate(PageType type, string [] warnings) { Dispatcher.BeginInvoke((Action) delegate { Reset(); switch (type) { case PageType.Setup: { Header = "Welcome to SparkleShare!"; Description = "First off, what's your name and email?\nThis information is only visible to team members."; TextBlock name_label = new TextBlock() { Text = "Full Name:", Width = 150, TextAlignment = TextAlignment.Right, FontWeight = FontWeights.Bold }; string name = System.Security.Principal.WindowsIdentity.GetCurrent().Name; name = name.Split("\\".ToCharArray()) [1]; TextBox name_box = new TextBox() { Text = name, Width = 175 }; TextBlock email_label = new TextBlock() { Text = "Email:", Width = 150, TextAlignment = TextAlignment.Right, FontWeight = FontWeights.Bold }; TextBox email_box = new TextBox() { Width = 175 }; 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(cancel_button); Buttons.Add(continue_button); name_box.Focus(); name_box.Select(name_box.Text.Length, 0); Controller.UpdateSetupContinueButtonEvent += delegate(bool enabled) { Dispatcher.BeginInvoke((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.BeginInvoke((Action) delegate { Program.UI.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; } case PageType.Add: { Header = "Where's your project hosted?"; ListView list_view = new ListView() { Width = 419, Height = 195, SelectionMode = SelectionMode.Single }; GridView grid_view = new GridView() { AllowsColumnReorder = false }; grid_view.Columns.Add(new GridViewColumn()); string xaml = "<DataTemplate xmlns=\"http://schemas.microsoft.com/winfx/2006/xaml/presentation\"" + " xmlns:x=\"http://schemas.microsoft.com/winfx/2006/xaml\">" + " <Grid>" + " <StackPanel Orientation=\"Horizontal\">" + " <Image Margin=\"5,0,0,0\" Source=\"{Binding Image}\" Height=\"24\" Width=\"24\"/>" + " <StackPanel>" + " <TextBlock Padding=\"10,4,0,0\" FontWeight=\"Bold\" Text=\"{Binding Name}\">" + " </TextBlock>" + " <TextBlock Padding=\"10,0,0,4\" Opacity=\"0.5\" Text=\"{Binding Description}\">" + " </TextBlock>" + " </StackPanel>" + " </StackPanel>" + " </Grid>" + "</DataTemplate>"; grid_view.Columns [0].CellTemplate = (DataTemplate)XamlReader.Parse(xaml); Style header_style = new Style(typeof(GridViewColumnHeader)); header_style.Setters.Add(new Setter(GridViewColumnHeader.VisibilityProperty, Visibility.Collapsed)); grid_view.ColumnHeaderContainerStyle = header_style; foreach (SparklePlugin plugin in Controller.Plugins) { // FIXME: images are blurry BitmapFrame image = BitmapFrame.Create( new Uri(plugin.ImagePath) ); list_view.Items.Add( new { Name = plugin.Name, Description = plugin.Description, Image = image } ); } 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, IsEnabled = (Controller.SelectedPlugin.Address == null) }; TextBlock address_help_label = new TextBlock() { Text = Controller.SelectedPlugin.AddressExample, 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, IsEnabled = (Controller.SelectedPlugin.Path == null) }; TextBlock path_help_label = new TextBlock() { Text = Controller.SelectedPlugin.PathExample, 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" }; CheckBox history_check_box = new CheckBox() { Content = "Fetch prior revisions", IsChecked = Controller.FetchPriorHistory }; history_check_box.Click += delegate { Controller.HistoryItemChanged(history_check_box.IsChecked.Value); }; ContentCanvas.Children.Add(history_check_box); Canvas.SetLeft(history_check_box, 185); Canvas.SetBottom(history_check_box, 12); 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); TaskbarItemInfo.ProgressValue = 0.0; TaskbarItemInfo.ProgressState = TaskbarItemProgressState.None; Buttons.Add(add_button); Buttons.Add(cancel_button); address_box.Focus(); address_box.Select(address_box.Text.Length, 0); Controller.ChangeAddressFieldEvent += delegate(string text, string example_text, FieldState state) { Dispatcher.BeginInvoke((Action) delegate { address_box.Text = text; address_box.IsEnabled = (state == FieldState.Enabled); address_help_label.Text = example_text; }); }; Controller.ChangePathFieldEvent += delegate(string text, string example_text, FieldState state) { Dispatcher.BeginInvoke((Action) delegate { path_box.Text = text; path_box.IsEnabled = (state == FieldState.Enabled); path_help_label.Text = example_text; }); }; Controller.UpdateAddProjectButtonEvent += delegate(bool button_enabled) { Dispatcher.BeginInvoke((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); }; Controller.CheckAddPage(address_box.Text, path_box.Text, 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); }; break; } case PageType.Syncing: { Header = "Adding project ‘" + Controller.SyncingFolder + "’…"; Description = "This may take a while for large projects.\nIsn't it coffee-o'clock?"; Button finish_button = new Button() { Content = "Finish", IsEnabled = false }; Button cancel_button = new Button() { Content = "Cancel" }; ProgressBar progress_bar = new ProgressBar() { Width = 414, Height = 15, Value = Controller.ProgressBarPercentage }; ContentCanvas.Children.Add(progress_bar); Canvas.SetLeft(progress_bar, 185); Canvas.SetTop(progress_bar, 150); TaskbarItemInfo.ProgressState = TaskbarItemProgressState.Normal; Buttons.Add(cancel_button); Buttons.Add(finish_button); Controller.UpdateProgressBarEvent += delegate(double percentage) { Dispatcher.BeginInvoke((Action) delegate { progress_bar.Value = percentage; TaskbarItemInfo.ProgressValue = percentage / 100; }); }; cancel_button.Click += delegate { Controller.SyncingCancelled(); }; break; } case PageType.Error: { Header = "Oops! Something went wrong…"; Description = "Please check the following:"; TextBlock help_block = new TextBlock() { TextWrapping = TextWrapping.Wrap, Width = 310 }; TextBlock bullets_block = new TextBlock() { Text = "•\n\n\n•" }; help_block.Inlines.Add(new Bold(new Run(Controller.PreviousUrl))); help_block.Inlines.Add(" is the address we've compiled. Does this look alright?\n\n"); help_block.Inlines.Add("Is this computer's Client ID known by the host??"); if (warnings.Length > 0) { bullets_block.Text += "\n\n•"; help_block.Inlines.Add("\n\nHere's the raw error message:"); foreach (string warning in warnings) { help_block.Inlines.Add("\n"); help_block.Inlines.Add(new Bold(new Run(warning))); } } Button cancel_button = new Button() { Content = "Cancel" }; Button try_again_button = new Button() { Content = "Try again…" }; ContentCanvas.Children.Add(bullets_block); Canvas.SetLeft(bullets_block, 195); Canvas.SetTop(bullets_block, 100); ContentCanvas.Children.Add(help_block); Canvas.SetLeft(help_block, 210); Canvas.SetTop(help_block, 100); TaskbarItemInfo.ProgressValue = 1.0; TaskbarItemInfo.ProgressState = TaskbarItemProgressState.Error; Buttons.Add(try_again_button); Buttons.Add(cancel_button); cancel_button.Click += delegate { Controller.PageCancelled(); }; try_again_button.Click += delegate { Controller.ErrorPageCompleted(); }; break; } case PageType.CryptoSetup: { Header = "Set up file encryption"; Description = "Please a provide a strong password that you don't use elsewhere below:"; TextBlock password_label = new TextBlock() { Text = "Password:"******"Show password", IsChecked = false }; TextBlock info_label = new TextBlock() { Text = "This password can't be changed later, and your files can't be recovered if it's forgotten.", TextWrapping = TextWrapping.Wrap, Width = 315 }; Image warning_image = new Image() { Source = Imaging.CreateBitmapSourceFromHIcon(Drawing.SystemIcons.Information.Handle, Int32Rect.Empty, BitmapSizeOptions.FromEmptyOptions()) }; show_password_checkbox.Checked += delegate { visible_password_box.Text = password_box.Password; visible_password_box.Visibility = Visibility.Visible; password_box.Visibility = Visibility.Hidden; }; show_password_checkbox.Unchecked += delegate { password_box.Password = visible_password_box.Text; password_box.Visibility = Visibility.Visible; visible_password_box.Visibility = Visibility.Hidden; }; password_box.PasswordChanged += delegate { Controller.CheckCryptoSetupPage(password_box.Password); }; visible_password_box.TextChanged += delegate { Controller.CheckCryptoSetupPage(visible_password_box.Text); }; Button continue_button = new Button() { Content = "Continue", IsEnabled = false }; continue_button.Click += delegate { if (show_password_checkbox.IsChecked == true) { Controller.CryptoSetupPageCompleted(visible_password_box.Text); } else { Controller.CryptoSetupPageCompleted(password_box.Password); } }; Button cancel_button = new Button() { Content = "Cancel" }; cancel_button.Click += delegate { Controller.CryptoPageCancelled(); }; Controller.UpdateCryptoSetupContinueButtonEvent += delegate(bool button_enabled) { Dispatcher.BeginInvoke((Action) delegate { continue_button.IsEnabled = button_enabled; }); }; ContentCanvas.Children.Add(password_label); Canvas.SetLeft(password_label, 270); Canvas.SetTop(password_label, 180); ContentCanvas.Children.Add(password_box); Canvas.SetLeft(password_box, 335); Canvas.SetTop(password_box, 180); ContentCanvas.Children.Add(visible_password_box); Canvas.SetLeft(visible_password_box, 335); Canvas.SetTop(visible_password_box, 180); ContentCanvas.Children.Add(show_password_checkbox); Canvas.SetLeft(show_password_checkbox, 338); Canvas.SetTop(show_password_checkbox, 208); ContentCanvas.Children.Add(info_label); Canvas.SetLeft(info_label, 240); Canvas.SetTop(info_label, 300); ContentCanvas.Children.Add(warning_image); Canvas.SetLeft(warning_image, 193); Canvas.SetTop(warning_image, 300); Buttons.Add(continue_button); Buttons.Add(cancel_button); break; } case PageType.CryptoPassword: { Header = "This project contains encrypted files"; Description = "Please enter the password to see their contents."; TextBlock password_label = new TextBlock() { Text = "Password:"******"Show password", IsChecked = false }; show_password_checkbox.Checked += delegate { visible_password_box.Text = password_box.Password; visible_password_box.Visibility = Visibility.Visible; password_box.Visibility = Visibility.Hidden; }; show_password_checkbox.Unchecked += delegate { password_box.Password = visible_password_box.Text; password_box.Visibility = Visibility.Visible; visible_password_box.Visibility = Visibility.Hidden; }; password_box.PasswordChanged += delegate { Controller.CheckCryptoPasswordPage(password_box.Password); }; visible_password_box.TextChanged += delegate { Controller.CheckCryptoPasswordPage(visible_password_box.Text); }; Button continue_button = new Button() { Content = "Continue", IsEnabled = false }; continue_button.Click += delegate { if (show_password_checkbox.IsChecked == true) { Controller.CryptoPasswordPageCompleted(visible_password_box.Text); } else { Controller.CryptoPasswordPageCompleted(password_box.Password); } }; Button cancel_button = new Button() { Content = "Cancel" }; cancel_button.Click += delegate { Controller.CryptoPageCancelled(); }; Controller.UpdateCryptoPasswordContinueButtonEvent += delegate(bool button_enabled) { Dispatcher.BeginInvoke((Action) delegate { continue_button.IsEnabled = button_enabled; }); }; ContentCanvas.Children.Add(password_label); Canvas.SetLeft(password_label, 270); Canvas.SetTop(password_label, 180); ContentCanvas.Children.Add(password_box); Canvas.SetLeft(password_box, 335); Canvas.SetTop(password_box, 180); ContentCanvas.Children.Add(visible_password_box); Canvas.SetLeft(visible_password_box, 335); Canvas.SetTop(visible_password_box, 180); ContentCanvas.Children.Add(show_password_checkbox); Canvas.SetLeft(show_password_checkbox, 338); Canvas.SetTop(show_password_checkbox, 208); Buttons.Add(continue_button); Buttons.Add(cancel_button); break; } case PageType.Finished: { Header = "Your shared project is ready!"; Description = "You can find the files in your SparkleShare folder."; Button finish_button = new Button() { Content = "Finish" }; Button show_files_button = new Button() { Content = "Show files…" }; if (warnings.Length > 0) { Image warning_image = new Image() { Source = Imaging.CreateBitmapSourceFromHIcon(Drawing.SystemIcons.Information.Handle, Int32Rect.Empty, BitmapSizeOptions.FromEmptyOptions()) }; TextBlock warning_block = new TextBlock() { Text = warnings [0], Width = 310, TextWrapping = TextWrapping.Wrap }; ContentCanvas.Children.Add(warning_image); Canvas.SetLeft(warning_image, 193); Canvas.SetTop(warning_image, 100); ContentCanvas.Children.Add(warning_block); Canvas.SetLeft(warning_block, 240); Canvas.SetTop(warning_block, 100); } TaskbarItemInfo.ProgressValue = 0.0; TaskbarItemInfo.ProgressState = TaskbarItemProgressState.None; Buttons.Add(show_files_button); Buttons.Add(finish_button); finish_button.Click += delegate { Controller.FinishPageCompleted(); }; show_files_button.Click += delegate { Controller.ShowFilesClicked(); }; break; } case PageType.Tutorial: { switch (Controller.TutorialPageNumber) { case 1: { Header = "What's happening next?"; Description = "SparkleShare creates a special folder on your computer " + "that will keep track of your projects."; WPF.Image slide_image = new WPF.Image() { Width = 324, Height = 200 }; slide_image.Source = SparkleUIHelpers.GetImageSource("tutorial-slide-1"); Button skip_tutorial_button = new Button() { Content = "Skip tutorial" }; Button continue_button = new Button() { Content = "Continue" }; ContentCanvas.Children.Add(slide_image); Canvas.SetLeft(slide_image, 228); Canvas.SetTop(slide_image, 130); Buttons.Add(skip_tutorial_button); Buttons.Add(continue_button); skip_tutorial_button.Click += delegate { Controller.TutorialSkipped(); }; continue_button.Click += delegate { Controller.TutorialPageCompleted(); }; break; } case 2: { Header = "Sharing files with others"; Description = "All files added to your project folders are synced automatically with " + "the host and your team members."; Button continue_button = new Button() { Content = "Continue" }; WPF.Image slide_image = new WPF.Image() { Width = 324, Height = 200 }; slide_image.Source = SparkleUIHelpers.GetImageSource("tutorial-slide-2"); ContentCanvas.Children.Add(slide_image); Canvas.SetLeft(slide_image, 228); Canvas.SetTop(slide_image, 130); Buttons.Add(continue_button); continue_button.Click += delegate { Controller.TutorialPageCompleted(); }; break; } case 3: { Header = "The status icon helps you"; Description = "It shows the syncing progress, provides easy access to " + "your projects and lets you view recent changes."; Button continue_button = new Button() { Content = "Continue" }; WPF.Image slide_image = new WPF.Image() { Width = 324, Height = 200 }; slide_image.Source = SparkleUIHelpers.GetImageSource("tutorial-slide-3"); ContentCanvas.Children.Add(slide_image); Canvas.SetLeft(slide_image, 228); Canvas.SetTop(slide_image, 130); Buttons.Add(continue_button); continue_button.Click += delegate { Controller.TutorialPageCompleted(); }; break; } case 4: { Header = "Here's your unique client ID"; Description = "You'll need it whenever you want to link this computer to a host. " + "You can also find it in the status icon menu."; TextBox link_code_text_box = new TextBox() { Text = Program.Controller.CurrentUser.PublicKey, Width = 250, MaxLines = 1, TextWrapping = TextWrapping.NoWrap, IsEnabled = false }; Button copy_button = new Button() { Content = "Copy", Width = 60 }; Button finish_button = new Button() { Content = "Finish" }; CheckBox check_box = new CheckBox() { Content = "Add SparkleShare to startup items", IsChecked = true }; ContentCanvas.Children.Add(link_code_text_box); Canvas.SetLeft(link_code_text_box, 235); Canvas.SetTop(link_code_text_box, 190); ContentCanvas.Children.Add(copy_button); Canvas.SetLeft(copy_button, 490); Canvas.SetTop(copy_button, 190); ContentCanvas.Children.Add(check_box); Canvas.SetLeft(check_box, 185); Canvas.SetBottom(check_box, 12); Buttons.Add(finish_button); check_box.Click += delegate { Controller.StartupItemChanged(check_box.IsChecked.Value); }; finish_button.Click += delegate { Controller.TutorialPageCompleted(); }; copy_button.Click += delegate { Controller.CopyToClipboardClicked(); }; break; } } break; } } ShowAll(); }); }; }
public void ShowPage(PageType type, string [] warnings) { if (type == PageType.Setup) { Header = "Welcome to SparkleShare!"; Description = "First off, what's your name and email?\n(visible only to team members)"; FullNameLabel = new NSTextField() { Alignment = NSTextAlignment.Right, BackgroundColor = NSColor.WindowBackground, Bordered = false, Editable = false, Frame = new RectangleF(165, Frame.Height - 234, 160, 17), StringValue = "Full Name:", Font = SparkleUI.Font }; FullNameTextField = new NSTextField() { Frame = new RectangleF(330, Frame.Height - 238, 196, 22), StringValue = UnixUserInfo.GetRealUser().RealName, Delegate = new SparkleTextFieldDelegate() }; EmailLabel = new NSTextField() { Alignment = NSTextAlignment.Right, BackgroundColor = NSColor.WindowBackground, Bordered = false, Editable = false, Frame = new RectangleF(165, Frame.Height - 264, 160, 17), StringValue = "Email:", Font = SparkleUI.Font }; EmailTextField = new NSTextField() { Frame = new RectangleF(330, Frame.Height - 268, 196, 22), Delegate = new SparkleTextFieldDelegate() }; EmailHelpLabel = new NSTextField() { BackgroundColor = NSColor.WindowBackground, Bordered = false, TextColor = NSColor.DisabledControlText, Editable = false, Frame = new RectangleF(330, Frame.Height - 290, 204, 17), Font = NSFontManager.SharedFontManager.FontWithFamily("Lucida Grande", NSFontTraitMask.Condensed, 0, 11), StringValue = "(used to find your Gravatar)" }; CancelButton = new NSButton() { Title = "Cancel" }; ContinueButton = new NSButton() { Title = "Continue", Enabled = false }; (FullNameTextField.Delegate as SparkleTextFieldDelegate).StringValueChanged += delegate { Controller.CheckSetupPage(FullNameTextField.StringValue, EmailTextField.StringValue); }; (EmailTextField.Delegate as SparkleTextFieldDelegate).StringValueChanged += delegate { Controller.CheckSetupPage(FullNameTextField.StringValue, EmailTextField.StringValue); }; ContinueButton.Activated += delegate { string full_name = FullNameTextField.StringValue.Trim(); string email = EmailTextField.StringValue.Trim(); Controller.SetupPageCompleted(full_name, email); }; CancelButton.Activated += delegate { Controller.SetupPageCancelled(); }; Controller.UpdateSetupContinueButtonEvent += delegate(bool button_enabled) { InvokeOnMainThread(delegate { ContinueButton.Enabled = button_enabled; }); }; ContentView.AddSubview(FullNameLabel); ContentView.AddSubview(FullNameTextField); ContentView.AddSubview(EmailLabel); ContentView.AddSubview(EmailTextField); ContentView.AddSubview(EmailHelpLabel); Buttons.Add(ContinueButton); Buttons.Add(CancelButton); Controller.CheckSetupPage(FullNameTextField.StringValue, EmailTextField.StringValue); } if (type == PageType.Invite) { Header = "You've received an invite!"; Description = "Do you want to add this project to SparkleShare?"; AddressLabel = new NSTextField() { Alignment = NSTextAlignment.Right, BackgroundColor = NSColor.WindowBackground, Bordered = false, Editable = false, Frame = new RectangleF(165, Frame.Height - 240, 160, 17), StringValue = "Address:", Font = SparkleUI.Font }; PathLabel = new NSTextField() { Alignment = NSTextAlignment.Right, BackgroundColor = NSColor.WindowBackground, Bordered = false, Editable = false, Frame = new RectangleF(165, Frame.Height - 264, 160, 17), StringValue = "Remote Path:", Font = SparkleUI.Font }; AddressTextField = new NSTextField() { Alignment = NSTextAlignment.Left, BackgroundColor = NSColor.WindowBackground, Bordered = false, Editable = false, Frame = new RectangleF(330, Frame.Height - 240, 260, 17), StringValue = Controller.PendingInvite.Address, Font = SparkleUI.BoldFont }; PathTextField = new NSTextField() { Alignment = NSTextAlignment.Left, BackgroundColor = NSColor.WindowBackground, Bordered = false, Editable = false, Frame = new RectangleF(330, Frame.Height - 264, 260, 17), StringValue = Controller.PendingInvite.RemotePath, Font = SparkleUI.BoldFont }; CancelButton = new NSButton() { Title = "Cancel" }; AddButton = new NSButton() { Title = "Add" }; CancelButton.Activated += delegate { Controller.PageCancelled(); }; AddButton.Activated += delegate { Controller.InvitePageCompleted(); }; ContentView.AddSubview(AddressLabel); ContentView.AddSubview(PathLabel); ContentView.AddSubview(AddressTextField); ContentView.AddSubview(PathTextField); Buttons.Add(AddButton); Buttons.Add(CancelButton); } if (type == PageType.Add) { Header = "Where's your project hosted?"; Description = ""; AddressLabel = new NSTextField() { Alignment = NSTextAlignment.Left, BackgroundColor = NSColor.WindowBackground, Bordered = false, Editable = false, Frame = new RectangleF(190, Frame.Height - 308, 160, 17), StringValue = "Address:", Font = SparkleUI.BoldFont }; AddressTextField = new NSTextField() { Frame = new RectangleF(190, Frame.Height - 336, 196, 22), Font = SparkleUI.Font, Enabled = (Controller.SelectedPlugin.Address == null), Delegate = new SparkleTextFieldDelegate(), StringValue = "" + Controller.PreviousAddress }; AddressTextField.Cell.LineBreakMode = NSLineBreakMode.TruncatingTail; PathLabel = new NSTextField() { Alignment = NSTextAlignment.Left, BackgroundColor = NSColor.WindowBackground, Bordered = false, Editable = false, Frame = new RectangleF(190 + 196 + 16, Frame.Height - 308, 160, 17), StringValue = "Remote Path:", Font = SparkleUI.BoldFont }; PathTextField = new NSTextField() { Frame = new RectangleF(190 + 196 + 16, Frame.Height - 336, 196, 22), Enabled = (Controller.SelectedPlugin.Path == null), Delegate = new SparkleTextFieldDelegate(), StringValue = "" + Controller.PreviousPath }; PathTextField.Cell.LineBreakMode = NSLineBreakMode.TruncatingTail; PathHelpLabel = new NSTextField() { BackgroundColor = NSColor.WindowBackground, Bordered = false, TextColor = NSColor.DisabledControlText, Editable = false, Frame = new RectangleF(190 + 196 + 16, Frame.Height - 355, 204, 17), Font = NSFontManager.SharedFontManager.FontWithFamily("Lucida Grande", NSFontTraitMask.Condensed, 0, 11), StringValue = "" + Controller.SelectedPlugin.PathExample }; AddressHelpLabel = new NSTextField() { BackgroundColor = NSColor.WindowBackground, Bordered = false, TextColor = NSColor.DisabledControlText, Editable = false, Frame = new RectangleF(190, Frame.Height - 355, 204, 17), Font = NSFontManager.SharedFontManager.FontWithFamily("Lucida Grande", NSFontTraitMask.Condensed, 0, 11), StringValue = "" + Controller.SelectedPlugin.AddressExample }; TableView = new NSTableView() { Frame = new RectangleF(0, 0, 0, 0), RowHeight = 34, IntercellSpacing = new SizeF(8, 12), HeaderView = null, Delegate = new SparkleTableViewDelegate() }; ScrollView = new NSScrollView() { Frame = new RectangleF(190, Frame.Height - 280, 408, 185), DocumentView = TableView, HasVerticalScroller = true, BorderType = NSBorderType.BezelBorder }; IconColumn = new NSTableColumn(new NSImage()) { Width = 36, HeaderToolTip = "Icon", DataCell = new NSImageCell() { ImageAlignment = NSImageAlignment.Right } }; DescriptionColumn = new NSTableColumn() { Width = 350, HeaderToolTip = "Description", Editable = false }; DescriptionColumn.DataCell.Font = NSFontManager.SharedFontManager.FontWithFamily("Lucida Grande", NSFontTraitMask.Condensed, 0, 11); TableView.AddColumn(IconColumn); TableView.AddColumn(DescriptionColumn); DataSource = new SparkleDataSource(Controller.Plugins); TableView.DataSource = DataSource; TableView.ReloadData(); HistoryCheckButton = new NSButton() { Frame = new RectangleF(190, Frame.Height - 400, 300, 18), Title = "Fetch prior revisions" }; if (Controller.FetchPriorHistory) { HistoryCheckButton.State = NSCellStateValue.On; } HistoryCheckButton.SetButtonType(NSButtonType.Switch); AddButton = new NSButton() { Title = "Add", Enabled = false }; CancelButton = new NSButton() { Title = "Cancel" }; Controller.ChangeAddressFieldEvent += delegate(string text, string example_text, FieldState state) { InvokeOnMainThread(delegate { AddressTextField.StringValue = text; AddressTextField.Enabled = (state == FieldState.Enabled); AddressHelpLabel.StringValue = example_text; }); }; Controller.ChangePathFieldEvent += delegate(string text, string example_text, FieldState state) { InvokeOnMainThread(delegate { PathTextField.StringValue = text; PathTextField.Enabled = (state == FieldState.Enabled); PathHelpLabel.StringValue = example_text; }); }; TableView.SelectRow(Controller.SelectedPluginIndex, false); TableView.ScrollRowToVisible(Controller.SelectedPluginIndex); (AddressTextField.Delegate as SparkleTextFieldDelegate).StringValueChanged += delegate { Controller.CheckAddPage(AddressTextField.StringValue, PathTextField.StringValue, TableView.SelectedRow); }; (PathTextField.Delegate as SparkleTextFieldDelegate).StringValueChanged += delegate { Controller.CheckAddPage(AddressTextField.StringValue, PathTextField.StringValue, TableView.SelectedRow); }; (TableView.Delegate as SparkleTableViewDelegate).SelectionChanged += delegate { Controller.SelectedPluginChanged(TableView.SelectedRow); Controller.CheckAddPage(AddressTextField.StringValue, PathTextField.StringValue, TableView.SelectedRow); }; HistoryCheckButton.Activated += delegate { Controller.HistoryItemChanged(HistoryCheckButton.State == NSCellStateValue.On); }; AddButton.Activated += delegate { Controller.AddPageCompleted(AddressTextField.StringValue, PathTextField.StringValue); }; CancelButton.Activated += delegate { Controller.PageCancelled(); }; Controller.UpdateAddProjectButtonEvent += delegate(bool button_enabled) { InvokeOnMainThread(delegate { AddButton.Enabled = button_enabled; }); }; ContentView.AddSubview(ScrollView); ContentView.AddSubview(AddressLabel); ContentView.AddSubview(AddressTextField); ContentView.AddSubview(AddressHelpLabel); ContentView.AddSubview(PathLabel); ContentView.AddSubview(PathTextField); ContentView.AddSubview(PathHelpLabel); ContentView.AddSubview(HistoryCheckButton); Buttons.Add(AddButton); Buttons.Add(CancelButton); Controller.CheckAddPage(AddressTextField.StringValue, PathTextField.StringValue, TableView.SelectedRow); } if (type == PageType.Syncing) { Header = "Adding project ‘" + Controller.SyncingFolder + "’…"; Description = "This may take a while for large projects.\nIsn't it coffee-o'clock?"; ProgressIndicator = new NSProgressIndicator() { Frame = new RectangleF(190, Frame.Height - 200, 640 - 150 - 80, 20), Style = NSProgressIndicatorStyle.Bar, MinValue = 0.0, MaxValue = 100.0, Indeterminate = false, DoubleValue = Controller.ProgressBarPercentage }; ProgressIndicator.StartAnimation(this); CancelButton = new NSButton() { Title = "Cancel" }; FinishButton = new NSButton() { Title = "Finish", Enabled = false }; Controller.UpdateProgressBarEvent += delegate(double percentage) { InvokeOnMainThread(() => { ProgressIndicator.DoubleValue = percentage; }); }; CancelButton.Activated += delegate { Controller.SyncingCancelled(); }; ContentView.AddSubview(ProgressIndicator); Buttons.Add(FinishButton); Buttons.Add(CancelButton); } if (type == PageType.Error) { Header = "Oops! Something went wrong…"; Description = "Please check the following:"; // Displaying marked up text with Cocoa is // a pain, so we just use a webview instead WebView web_view = new WebView(); web_view.Frame = new RectangleF(190, Frame.Height - 525, 375, 400); string html = "<style>" + "* {" + " font-family: 'Lucida Grande';" + " font-size: 12px; cursor: default;" + "}" + "body {" + " -webkit-user-select: none;" + " margin: 0;" + " padding: 3px;" + "}" + "li {" + " margin-bottom: 16px;" + " margin-left: 0;" + " padding-left: 0;" + " line-height: 20px;" + "}" + "ul {" + " padding-left: 24px;" + "}" + "</style>" + "<ul>" + " <li><b>" + Controller.PreviousUrl + "</b> is the address we've compiled. Does this look alright?</li>" + " <li>Do you have access rights to this remote project?</li>" + "</ul>"; if (warnings.Length > 0) { string warnings_markup = ""; foreach (string warning in warnings) { warnings_markup += "<br><b>" + warning + "</b>"; } html = html.Replace("</ul>", "<li>Here's the raw error message: " + warnings_markup + "</li></ul>"); } web_view.MainFrame.LoadHtmlString(html, new NSUrl("")); web_view.DrawsBackground = false; CancelButton = new NSButton() { Title = "Cancel" }; TryAgainButton = new NSButton() { Title = "Try again…" }; CancelButton.Activated += delegate { Controller.PageCancelled(); }; TryAgainButton.Activated += delegate { Controller.ErrorPageCompleted(); }; ContentView.AddSubview(web_view); Buttons.Add(TryAgainButton); Buttons.Add(CancelButton); } if (type == PageType.CryptoSetup) { Header = "Set up file encryption"; Description = "This project is supposed to be encrypted, but it doesn't yet have a password set. Please provide one below:"; PasswordLabel = new NSTextField() { Alignment = NSTextAlignment.Right, BackgroundColor = NSColor.WindowBackground, Bordered = false, Editable = false, Frame = new RectangleF(155, Frame.Height - 204, 160, 17), StringValue = "Password:"******"Show password", State = NSCellStateValue.Off }; ShowPasswordCheckButton.SetButtonType(NSButtonType.Switch); WarningImage = NSImage.ImageNamed("NSInfo"); WarningImage.Size = new SizeF(24, 24); WarningImageView = new NSImageView() { Image = WarningImage, Frame = new RectangleF(200, Frame.Height - 320, 24, 24) }; WarningTextField = new NSTextField() { Frame = new RectangleF(235, Frame.Height - 390, 325, 100), StringValue = "This password can't be changed later, and your files can't be recovered if it's forgotten.", BackgroundColor = NSColor.WindowBackground, Bordered = false, Editable = false, Font = SparkleUI.Font }; CancelButton = new NSButton() { Title = "Cancel" }; ContinueButton = new NSButton() { Title = "Continue", Enabled = false }; ShowPasswordCheckButton.Activated += delegate { if (PasswordTextField.Superview == ContentView) { PasswordTextField.RemoveFromSuperview(); ContentView.AddSubview(VisiblePasswordTextField); } else { VisiblePasswordTextField.RemoveFromSuperview(); ContentView.AddSubview(PasswordTextField); } }; (PasswordTextField.Delegate as SparkleTextFieldDelegate).StringValueChanged += delegate { VisiblePasswordTextField.StringValue = PasswordTextField.StringValue; Controller.CheckCryptoSetupPage(PasswordTextField.StringValue); }; (VisiblePasswordTextField.Delegate as SparkleTextFieldDelegate).StringValueChanged += delegate { PasswordTextField.StringValue = VisiblePasswordTextField.StringValue; Controller.CheckCryptoSetupPage(PasswordTextField.StringValue); }; Controller.UpdateCryptoSetupContinueButtonEvent += delegate(bool button_enabled) { InvokeOnMainThread(() => { ContinueButton.Enabled = button_enabled; }); }; ContinueButton.Activated += delegate { Controller.CryptoSetupPageCompleted(PasswordTextField.StringValue); }; CancelButton.Activated += delegate { Controller.CryptoPageCancelled(); }; ContentView.AddSubview(PasswordLabel); ContentView.AddSubview(PasswordTextField); ContentView.AddSubview(ShowPasswordCheckButton); ContentView.AddSubview(WarningImageView); ContentView.AddSubview(WarningTextField); Buttons.Add(ContinueButton); Buttons.Add(CancelButton); NSApplication.SharedApplication.RequestUserAttention(NSRequestUserAttentionType.CriticalRequest); } if (type == PageType.CryptoPassword) { Header = "This project contains encrypted files"; Description = "Please enter the password to see their contents."; PasswordLabel = new NSTextField() { Alignment = NSTextAlignment.Right, BackgroundColor = NSColor.WindowBackground, Bordered = false, Editable = false, Frame = new RectangleF(155, Frame.Height - 224, 160, 17), StringValue = "Password:"******"Show password", State = NSCellStateValue.Off }; ShowPasswordCheckButton.SetButtonType(NSButtonType.Switch); CancelButton = new NSButton() { Title = "Cancel" }; ContinueButton = new NSButton() { Title = "Continue", Enabled = false }; Controller.UpdateCryptoPasswordContinueButtonEvent += delegate(bool button_enabled) { InvokeOnMainThread(() => { ContinueButton.Enabled = button_enabled; }); }; ShowPasswordCheckButton.Activated += delegate { if (PasswordTextField.Superview == ContentView) { PasswordTextField.RemoveFromSuperview(); ContentView.AddSubview(VisiblePasswordTextField); } else { VisiblePasswordTextField.RemoveFromSuperview(); ContentView.AddSubview(PasswordTextField); } }; (PasswordTextField.Delegate as SparkleTextFieldDelegate).StringValueChanged += delegate { VisiblePasswordTextField.StringValue = PasswordTextField.StringValue; Controller.CheckCryptoPasswordPage(PasswordTextField.StringValue); }; (VisiblePasswordTextField.Delegate as SparkleTextFieldDelegate).StringValueChanged += delegate { PasswordTextField.StringValue = VisiblePasswordTextField.StringValue; Controller.CheckCryptoPasswordPage(PasswordTextField.StringValue); }; ContinueButton.Activated += delegate { Controller.CryptoPasswordPageCompleted(PasswordTextField.StringValue); }; CancelButton.Activated += delegate { Controller.CryptoPageCancelled(); }; ContentView.AddSubview(PasswordLabel); ContentView.AddSubview(PasswordTextField); ContentView.AddSubview(ShowPasswordCheckButton); Buttons.Add(ContinueButton); Buttons.Add(CancelButton); NSApplication.SharedApplication.RequestUserAttention(NSRequestUserAttentionType.CriticalRequest); } if (type == PageType.Finished) { Header = "Your shared project is ready!"; Description = "You can find the files in your SparkleShare folder."; if (warnings.Length > 0) { WarningImage = NSImage.ImageNamed("NSInfo"); WarningImage.Size = new SizeF(24, 24); WarningImageView = new NSImageView() { Image = WarningImage, Frame = new RectangleF(200, Frame.Height - 175, 24, 24) }; WarningTextField = new NSTextField() { Frame = new RectangleF(235, Frame.Height - 245, 325, 100), StringValue = warnings [0], BackgroundColor = NSColor.WindowBackground, Bordered = false, Editable = false, Font = SparkleUI.Font }; ContentView.AddSubview(WarningImageView); ContentView.AddSubview(WarningTextField); } OpenFolderButton = new NSButton() { Title = "Show folder" }; FinishButton = new NSButton() { Title = "Finish" }; OpenFolderButton.Activated += delegate { Controller.OpenFolderClicked(); }; FinishButton.Activated += delegate { Controller.FinishPageCompleted(); }; Buttons.Add(FinishButton); Buttons.Add(OpenFolderButton); NSApplication.SharedApplication.RequestUserAttention(NSRequestUserAttentionType.CriticalRequest); } if (type == PageType.Tutorial) { string slide_image_path = Path.Combine(NSBundle.MainBundle.ResourcePath, "Pixmaps", "tutorial-slide-" + Controller.TutorialPageNumber + ".png"); SlideImage = new NSImage(slide_image_path) { Size = new SizeF(350, 200) }; SlideImageView = new NSImageView() { Image = SlideImage, Frame = new RectangleF(215, Frame.Height - 350, 350, 200) }; ContentView.AddSubview(SlideImageView); 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."; SkipTutorialButton = new NSButton() { Title = "Skip Tutorial" }; ContinueButton = new NSButton() { Title = "Continue" }; SkipTutorialButton.Activated += delegate { Controller.TutorialSkipped(); }; ContinueButton.Activated += delegate { Controller.TutorialPageCompleted(); }; ContentView.AddSubview(SlideImageView); Buttons.Add(ContinueButton); Buttons.Add(SkipTutorialButton); 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."; ContinueButton = new NSButton() { Title = "Continue" }; ContinueButton.Activated += delegate { Controller.TutorialPageCompleted(); }; Buttons.Add(ContinueButton); break; } 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."; ContinueButton = new NSButton() { Title = "Continue" }; ContinueButton.Activated += delegate { Controller.TutorialPageCompleted(); }; Buttons.Add(ContinueButton); break; } 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:"; StartupCheckButton = new NSButton() { Frame = new RectangleF(190, Frame.Height - 400, 300, 18), Title = "Add SparkleShare to startup items", State = NSCellStateValue.On }; StartupCheckButton.SetButtonType(NSButtonType.Switch); FinishButton = new NSButton() { Title = "Finish" }; SlideImage.Size = new SizeF(350, 64); StartupCheckButton.Activated += delegate { Controller.StartupItemChanged(StartupCheckButton.State == NSCellStateValue.On); }; FinishButton.Activated += delegate { Controller.TutorialPageCompleted(); }; ContentView.AddSubview(StartupCheckButton); Buttons.Add(FinishButton); break; } } } }
public SparkleSetup() : base() { Controller.HideWindowEvent += delegate { Application.Invoke(delegate { HideAll(); }); }; Controller.ShowWindowEvent += delegate { Application.Invoke(delegate { ShowAll(); Present(); }); }; Controller.ChangePageEvent += delegate(PageType type, string [] warnings) { Application.Invoke(delegate { Reset(); switch (type) { case PageType.Setup: { Header = _("Welcome to SparkleShare!"); Description = "Before we get started, what's your name and email? " + "Don't worry, this information will only be visible to team members."; Table table = new Table(2, 3, true) { RowSpacing = 6, ColumnSpacing = 6 }; Label name_label = new Label("<b>" + _("Full Name:") + "</b>") { UseMarkup = true, Xalign = 1 }; Entry name_entry = new Entry(Controller.GuessedUserName) { Xalign = 0 }; Entry email_entry = new Entry(Controller.GuessedUserEmail) { Xalign = 0 }; name_entry.Changed += delegate { Controller.CheckSetupPage(name_entry.Text, email_entry.Text); }; email_entry.Changed += delegate { Controller.CheckSetupPage(name_entry.Text, email_entry.Text); }; Label email_label = new Label("<b>" + _("Email:") + "</b>") { UseMarkup = true, Xalign = 1 }; table.Attach(name_label, 0, 1, 0, 1); table.Attach(name_entry, 1, 2, 0, 1); table.Attach(email_label, 0, 1, 1, 2); table.Attach(email_entry, 1, 2, 1, 2); VBox wrapper = new VBox(false, 9); wrapper.PackStart(table, true, false, 0); Button cancel_button = new Button(_("Cancel")); cancel_button.Clicked += delegate { Controller.SetupPageCancelled(); }; Button continue_button = new Button(_("Continue")) { Sensitive = false }; continue_button.Clicked += delegate(object o, EventArgs args) { string full_name = name_entry.Text; string email = email_entry.Text; Controller.SetupPageCompleted(full_name, email); }; AddButton(cancel_button); AddButton(continue_button); Add(wrapper); Controller.UpdateSetupContinueButtonEvent += delegate(bool button_enabled) { Application.Invoke(delegate { continue_button.Sensitive = button_enabled; }); }; Controller.CheckSetupPage(name_entry.Text, email_entry.Text); break; } case PageType.Add: { Header = _("Where's your project hosted?"); VBox layout_vertical = new VBox(false, 12); HBox layout_fields = new HBox(true, 12); VBox layout_address = new VBox(true, 0); VBox layout_path = new VBox(true, 0); ListStore store = new ListStore(typeof(Gdk.Pixbuf), typeof(string), typeof(SparklePlugin)); SparkleTreeView tree = new SparkleTreeView(store) { HeadersVisible = false }; ScrolledWindow scrolled_window = new ScrolledWindow(); scrolled_window.AddWithViewport(tree); // Icon column tree.AppendColumn("Icon", new Gtk.CellRendererPixbuf(), "pixbuf", 0); tree.Columns [0].Cells [0].Xpad = 6; // Service column TreeViewColumn service_column = new TreeViewColumn() { Title = "Service" }; CellRendererText service_cell = new CellRendererText() { Ypad = 4 }; service_column.PackStart(service_cell, true); service_column.SetCellDataFunc(service_cell, new TreeCellDataFunc(RenderServiceColumn)); foreach (SparklePlugin plugin in Controller.Plugins) { store.AppendValues( new Gdk.Pixbuf(plugin.ImagePath), "<span size=\"small\"><b>" + plugin.Name + "</b>\n" + "<span fgcolor=\"" + SecondaryTextColorSelected + "\">" + plugin.Description + "</span>" + "</span>", plugin); } tree.AppendColumn(service_column); Entry address_entry = new Entry() { Text = Controller.PreviousAddress, Sensitive = (Controller.SelectedPlugin.Address == null) }; Entry path_entry = new Entry() { Text = Controller.PreviousPath, Sensitive = (Controller.SelectedPlugin.Path == null) }; Label address_example = new Label() { Xalign = 0, UseMarkup = true, Markup = "<span size=\"small\" fgcolor=\"" + SecondaryTextColor + "\">" + Controller.SelectedPlugin.AddressExample + "</span>" }; Label path_example = new Label() { Xalign = 0, UseMarkup = true, Markup = "<span size=\"small\" fgcolor=\"" + SecondaryTextColor + "\">" + Controller.SelectedPlugin.PathExample + "</span>" }; // Select the first plugin by default TreeSelection default_selection = tree.Selection; TreePath default_path = new TreePath("0"); default_selection.SelectPath(default_path); Controller.SelectedPluginChanged(0); Controller.ChangeAddressFieldEvent += delegate(string text, string example_text, FieldState state) { Application.Invoke(delegate { address_entry.Text = text; address_entry.Sensitive = (state == FieldState.Enabled); address_example.Markup = "<span size=\"small\" fgcolor=\"" + SecondaryTextColor + "\">" + example_text + "</span>"; }); }; Controller.ChangePathFieldEvent += delegate(string text, string example_text, FieldState state) { Application.Invoke(delegate { path_entry.Text = text; path_entry.Sensitive = (state == FieldState.Enabled); path_example.Markup = "<span size=\"small\" fgcolor=\"" + SecondaryTextColor + "\">" + example_text + "</span>"; }); }; Controller.CheckAddPage(address_entry.Text, path_entry.Text, 1); // Update the address field text when the selection changes tree.CursorChanged += delegate(object sender, EventArgs e) { Controller.SelectedPluginChanged(tree.SelectedRow); // TODO: Scroll to selected row when using arrow keys }; tree.Model.Foreach(new TreeModelForeachFunc(delegate(TreeModel model, TreePath path, TreeIter iter) { string address; try { address = (model.GetValue(iter, 2) as SparklePlugin).Address; } catch (NullReferenceException) { address = ""; } if (!string.IsNullOrEmpty(address) && address.Equals(Controller.PreviousAddress)) { tree.SetCursor(path, service_column, false); SparklePlugin plugin = (SparklePlugin)model.GetValue(iter, 2); if (plugin.Address != null) { address_entry.Sensitive = false; } if (plugin.Path != null) { path_entry.Sensitive = false; } // TODO: Scroll to the selection return(true); } else { return(false); } })); address_entry.Changed += delegate { Controller.CheckAddPage(address_entry.Text, path_entry.Text, tree.SelectedRow); }; layout_address.PackStart(new Label() { Markup = "<b>" + _("Address:") + "</b>", Xalign = 0 }, true, true, 0); layout_address.PackStart(address_entry, false, false, 0); layout_address.PackStart(address_example, false, false, 0); path_entry.Changed += delegate { Controller.CheckAddPage(address_entry.Text, path_entry.Text, tree.SelectedRow); }; layout_path.PackStart(new Label() { Markup = "<b>" + _("Remote Path:") + "</b>", Xalign = 0 }, true, true, 0); layout_path.PackStart(path_entry, false, false, 0); layout_path.PackStart(path_example, false, false, 0); layout_fields.PackStart(layout_address); layout_fields.PackStart(layout_path); layout_vertical.PackStart(new Label(""), false, false, 0); layout_vertical.PackStart(scrolled_window, true, true, 0); layout_vertical.PackStart(layout_fields, false, false, 0); Add(layout_vertical); // Cancel button Button cancel_button = new Button(_("Cancel")); cancel_button.Clicked += delegate { Controller.PageCancelled(); }; Button add_button = new Button(_("Add")); add_button.Clicked += delegate { string server = address_entry.Text; string folder_name = path_entry.Text; Controller.AddPageCompleted(server, folder_name); }; Controller.UpdateAddProjectButtonEvent += delegate(bool button_enabled) { Application.Invoke(delegate { add_button.Sensitive = button_enabled; }); }; CheckButton check_button = new CheckButton("Fetch prior history") { Active = false }; check_button.Toggled += delegate { Controller.HistoryItemChanged(check_button.Active); }; AddOption(check_button); AddButton(cancel_button); AddButton(add_button); break; } case PageType.Invite: { Header = _("You've received an invite!"); Description = _("Do you want to add this project to SparkleShare?"); Table table = new Table(2, 3, true) { RowSpacing = 6, ColumnSpacing = 6 }; Label address_label = new Label(_("Address:")) { Xalign = 1 }; Label path_label = new Label(_("Remote Path:")) { Xalign = 1 }; Label address_value = new Label("<b>" + Controller.PendingInvite.Address + "</b>") { UseMarkup = true, Xalign = 0 }; Label path_value = new Label("<b>" + Controller.PendingInvite.RemotePath + "</b>") { UseMarkup = true, Xalign = 0 }; table.Attach(address_label, 0, 1, 0, 1); table.Attach(address_value, 1, 2, 0, 1); table.Attach(path_label, 0, 1, 1, 2); table.Attach(path_value, 1, 2, 1, 2); VBox wrapper = new VBox(false, 9); wrapper.PackStart(table, true, false, 0); Button cancel_button = new Button(_("Cancel")); cancel_button.Clicked += delegate { Controller.PageCancelled(); }; Button add_button = new Button(_("Add")); add_button.Clicked += delegate { Controller.InvitePageCompleted(); }; AddButton(cancel_button); AddButton(add_button); Add(wrapper); break; } case PageType.Syncing: { Header = String.Format(_("Adding project ‘{0}’…"), Controller.SyncingFolder); Description = _("This may either take a short or a long time depending on the project's size."); this.progress_bar.Fraction = Controller.ProgressBarPercentage / 100; Button finish_button = new Button() { Sensitive = false, Label = _("Finish") }; Button cancel_button = new Button() { Label = _("Cancel") }; cancel_button.Clicked += delegate { Controller.SyncingCancelled(); }; AddButton(cancel_button); AddButton(finish_button); Controller.UpdateProgressBarEvent += delegate(double percentage) { Application.Invoke(delegate { this.progress_bar.Fraction = percentage / 100; }); }; if (this.progress_bar.Parent != null) { (this.progress_bar.Parent as Container).Remove(this.progress_bar); } VBox bar_wrapper = new VBox(false, 0); bar_wrapper.PackStart(this.progress_bar, false, false, 15); Add(bar_wrapper); break; } case PageType.Error: { Header = _("Something went wrong") + "…"; VBox points = new VBox(false, 0); Image list_point_one = new Image(SparkleUIHelpers.GetIcon("list-point", 16)); Image list_point_two = new Image(SparkleUIHelpers.GetIcon("list-point", 16)); Image list_point_three = new Image(SparkleUIHelpers.GetIcon("list-point", 16)); Label label_one = new Label() { Text = "Is the host online?", Wrap = true, Xalign = 0 }; Label label_two = new Label() { Markup = "<b>" + Controller.PreviousUrl + "</b> is the address we've compiled. " + "Does this look alright?", Wrap = true, Xalign = 0 }; Label label_three = new Label() { Text = "The host needs to know who you are. Did you upload the key that's in " + "your SparkleShare folder?", Wrap = true, Xalign = 0 }; points.PackStart(new Label("Please check the following:") { Xalign = 0 }, false, false, 6); HBox point_one = new HBox(false, 0); point_one.PackStart(list_point_one, false, false, 0); point_one.PackStart(label_one, true, true, 12); points.PackStart(point_one, false, false, 12); HBox point_two = new HBox(false, 0); point_two.PackStart(list_point_two, false, false, 0); point_two.PackStart(label_two, true, true, 12); points.PackStart(point_two, false, false, 12); HBox point_three = new HBox(false, 0); point_three.PackStart(list_point_three, false, false, 0); point_three.PackStart(label_three, true, true, 12); points.PackStart(point_three, false, false, 12); points.PackStart(new Label(""), true, true, 0); Button cancel_button = new Button(_("Cancel")); cancel_button.Clicked += delegate { Controller.PageCancelled(); }; Button try_again_button = new Button(_("Try Again…")) { Sensitive = true }; try_again_button.Clicked += delegate { Controller.ErrorPageCompleted(); }; AddButton(cancel_button); AddButton(try_again_button); Add(points); break; } case PageType.CryptoSetup: { Header = "Set up file encryption"; Description = "This project is supposed to be encrypted, but it doesn't yet have a password set. Please provide one below."; Label password_label = new Label("<b>" + _("Password:"******"</b>") { UseMarkup = true, Xalign = 1 }; Entry password_entry = new Entry() { Xalign = 0, Visibility = false }; CheckButton show_password_check_button = new CheckButton("Show password") { Active = false, Xalign = 0 }; show_password_check_button.Toggled += delegate { password_entry.Visibility = !password_entry.Visibility; }; password_entry.Changed += delegate { Controller.CheckCryptoSetupPage(password_entry.Text); }; Button continue_button = new Button("Continue") { Sensitive = false }; continue_button.Clicked += delegate { Controller.CryptoSetupPageCompleted(password_entry.Text); }; Button cancel_button = new Button("Cancel"); cancel_button.Clicked += delegate { Controller.CryptoPageCancelled(); }; Controller.UpdateCryptoSetupContinueButtonEvent += delegate(bool button_enabled) { Application.Invoke(delegate { continue_button.Sensitive = button_enabled; }); }; Table table = new Table(2, 3, true) { RowSpacing = 6, ColumnSpacing = 6 }; table.Attach(password_label, 0, 1, 0, 1); table.Attach(password_entry, 1, 2, 0, 1); table.Attach(show_password_check_button, 1, 2, 1, 2); VBox wrapper = new VBox(false, 9); wrapper.PackStart(table, true, false, 0); Image warning_image = new Image( SparkleUIHelpers.GetIcon("dialog-information", 24) ); Label warning_label = new Label() { Xalign = 0, Wrap = true, Text = "This password can't be changed later, and your files can't be recovered if it's forgotten." }; HBox warning_layout = new HBox(false, 0); warning_layout.PackStart(warning_image, false, false, 15); warning_layout.PackStart(warning_label, true, true, 0); VBox warning_wrapper = new VBox(false, 0); warning_wrapper.PackStart(warning_layout, false, false, 15); wrapper.PackStart(warning_wrapper, false, false, 0); Add(wrapper); AddButton(cancel_button); AddButton(continue_button); break; } case PageType.CryptoPassword: { Header = "This project contains encrypted files"; Description = "Please enter the password to see their contents."; Label password_label = new Label("<b>" + _("Password:"******"</b>") { UseMarkup = true, Xalign = 1 }; Entry password_entry = new Entry() { Xalign = 0, Visibility = false }; CheckButton show_password_check_button = new CheckButton("Show password") { Active = false, Xalign = 0 }; show_password_check_button.Toggled += delegate { password_entry.Visibility = !password_entry.Visibility; }; password_entry.Changed += delegate { Controller.CheckCryptoPasswordPage(password_entry.Text); }; Button continue_button = new Button("Continue") { Sensitive = false }; continue_button.Clicked += delegate { Controller.CryptoPasswordPageCompleted(password_entry.Text); }; Button cancel_button = new Button("Cancel"); cancel_button.Clicked += delegate { Controller.CryptoPageCancelled(); }; Controller.UpdateCryptoPasswordContinueButtonEvent += delegate(bool button_enabled) { Application.Invoke(delegate { continue_button.Sensitive = button_enabled; }); }; Table table = new Table(2, 3, true) { RowSpacing = 6, ColumnSpacing = 6 }; table.Attach(password_label, 0, 1, 0, 1); table.Attach(password_entry, 1, 2, 0, 1); table.Attach(show_password_check_button, 1, 2, 1, 2); VBox wrapper = new VBox(false, 9); wrapper.PackStart(table, true, false, 0); Add(wrapper); AddButton(cancel_button); AddButton(continue_button); break; } case PageType.Finished: { UrgencyHint = true; if (!HasToplevelFocus) { string title = _("Your shared project is ready!"); string subtext = _("You can find the files in your SparkleShare folder."); SparkleUI.Bubbles.Controller.ShowBubble(title, subtext, null); } Header = _("Your shared project is ready!"); Description = _("You can find it in your SparkleShare folder"); // A button that opens the synced folder Button open_folder_button = new Button(string.Format("Open {0}", System.IO.Path.GetFileName(Controller.PreviousPath))); open_folder_button.Clicked += delegate { Controller.OpenFolderClicked(); }; Button finish_button = new Button(_("Finish")); finish_button.Clicked += delegate { Controller.FinishPageCompleted(); }; if (warnings.Length > 0) { Image warning_image = new Image( SparkleUIHelpers.GetIcon("dialog-information", 24) ); Label warning_label = new Label(warnings [0]) { Xalign = 0, Wrap = true }; HBox warning_layout = new HBox(false, 0); warning_layout.PackStart(warning_image, false, false, 15); warning_layout.PackStart(warning_label, true, true, 0); VBox warning_wrapper = new VBox(false, 0); warning_wrapper.PackStart(warning_layout, false, false, 0); Add(warning_wrapper); } else { Add(null); } AddButton(open_folder_button); AddButton(finish_button); 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."; Button skip_tutorial_button = new Button(_("Skip Tutorial")); skip_tutorial_button.Clicked += delegate { Controller.TutorialSkipped(); }; Button continue_button = new Button(_("Continue")); continue_button.Clicked += delegate { Controller.TutorialPageCompleted(); }; Image slide = SparkleUIHelpers.GetImage("tutorial-slide-1.png"); Add(slide); AddButton(skip_tutorial_button); AddButton(continue_button); 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(_("Continue")); continue_button.Clicked += delegate { Controller.TutorialPageCompleted(); }; Image slide = SparkleUIHelpers.GetImage("tutorial-slide-2.png"); Add(slide); AddButton(continue_button); break; } 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(_("Continue")); continue_button.Clicked += delegate { Controller.TutorialPageCompleted(); }; Image slide = SparkleUIHelpers.GetImage("tutorial-slide-3.png"); Add(slide); AddButton(continue_button); break; } 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:"); Image slide = SparkleUIHelpers.GetImage("tutorial-slide-4.png"); Button finish_button = new Button(_("Finish")); finish_button.Clicked += delegate { Controller.TutorialPageCompleted(); }; CheckButton check_button = new CheckButton("Add SparkleShare to startup items") { Active = true }; check_button.Toggled += delegate { Controller.StartupItemChanged(check_button.Active); }; Add(slide); AddOption(check_button); AddButton(finish_button); break; } } break; } } ShowAll(); }); }; }
public SparkleSetup() : base() { Controller.HideWindowEvent += delegate { Application.Invoke(delegate { HideAll(); }); }; Controller.ShowWindowEvent += delegate { Application.Invoke(delegate { ShowAll(); Present(); }); }; Controller.ChangePageEvent += delegate(PageType type, string [] warnings) { Application.Invoke(delegate { Reset(); switch (type) { case PageType.Setup: { Header = "Welcome to CmisSync!"; Description = "First off, what's your name and email?\nThis information is only visible to team members."; Table table = new Table(2, 3, true) { RowSpacing = 6, ColumnSpacing = 6 }; Label name_label = new Label("<b>" + "Full Name:" + "</b>") { UseMarkup = true, Xalign = 1 }; Entry name_entry = new Entry(UnixUserInfo.GetRealUser().RealName) { Xalign = 0, ActivatesDefault = true }; Entry email_entry = new Entry() { Xalign = 0, ActivatesDefault = true }; name_entry.Changed += delegate { Controller.CheckSetupPage(); }; email_entry.Changed += delegate { Controller.CheckSetupPage(); }; Label email_label = new Label("<b>" + "Email:" + "</b>") { UseMarkup = true, Xalign = 1 }; table.Attach(name_label, 0, 1, 0, 1); table.Attach(name_entry, 1, 2, 0, 1); table.Attach(email_label, 0, 1, 1, 2); table.Attach(email_entry, 1, 2, 1, 2); VBox wrapper = new VBox(false, 9); wrapper.PackStart(table, true, false, 0); Button cancel_button = new Button("Cancel"); cancel_button.Clicked += delegate { Controller.SetupPageCancelled(); }; Button continue_button = new Button("Continue") { Sensitive = false }; continue_button.Clicked += delegate(object o, EventArgs args) { string full_name = name_entry.Text; string email = email_entry.Text; Controller.SetupPageCompleted(); }; AddButton(cancel_button); AddButton(continue_button); Add(wrapper); Controller.UpdateSetupContinueButtonEvent += delegate(bool button_enabled) { Application.Invoke(delegate { continue_button.Sensitive = button_enabled; }); }; Controller.CheckSetupPage(); break; } case PageType.Add1: { Header = "Where is your organization's server?"; VBox layout_vertical = new VBox(false, 12); HBox layout_fields = new HBox(true, 12); VBox layout_address = new VBox(true, 0); VBox layout_user = new VBox(true, 0); VBox layout_password = new VBox(true, 0); // Address Entry address_entry = new Entry() { Text = Controller.PreviousAddress, Sensitive = (Controller.SelectedPlugin.Address == null), ActivatesDefault = true }; Label address_example = new Label() { Xalign = 0, UseMarkup = true, Markup = "<span size=\"small\" fgcolor=\"" + SecondaryTextColor + "\">" + Controller.SelectedPlugin.AddressExample + "</span>" }; Label address_help_label = new Label() { Text = "Help: ", // TODO FontSize = 11, // TODO Foreground = new SolidColorBrush(Color.FromRgb(128, 128, 128)) }; /* TODO Run run = new Run("Where to find this address"); * Hyperlink link = new Hyperlink(run); * link.NavigateUri = new Uri("https://github.com/nicolas-raoul/CmisSync/wiki/What-address"); * address_help_label.Inlines.Add(link); * link.RequestNavigate += (sender, e) => * { * System.Diagnostics.Process.Start(e.Uri.ToString()); * };*/ Label address_error_label = new Label() { // TODO FontSize = 11, // TODO Foreground = new SolidColorBrush(Color.FromRgb(255, 128, 128)), // TODO Visibility = Visibility.Hidden }; // User Entry user_entry = new Entry() { Text = Controller.PreviousPath, Sensitive = (Controller.SelectedPlugin.User == null), ActivatesDefault = true }; Label user_example = new Label() { Xalign = 0, UseMarkup = true, Markup = "<span size=\"small\" fgcolor=\"" + SecondaryTextColor + "\">" + Controller.SelectedPlugin.UserExample + "</span>" }; // Password Entry password_entry = new Entry() { Text = Controller.PreviousPath, Sensitive = (Controller.SelectedPlugin.Password == null), ActivatesDefault = true }; Label password_example = new Label() { Xalign = 0, UseMarkup = true, Markup = "<span size=\"small\" fgcolor=\"" + SecondaryTextColor + "\">" + Controller.SelectedPlugin.PasswordExample + "</span>" }; Controller.ChangeAddressFieldEvent += delegate(string text, string example_text, FieldState state) { Application.Invoke(delegate { address_entry.Text = text; address_entry.Sensitive = (state == FieldState.Enabled); address_example.Markup = "<span size=\"small\" fgcolor=\"" + SecondaryTextColor + "\">" + example_text + "</span>"; }); }; Controller.ChangeUserFieldEvent += delegate(string text, string example_text, FieldState state) { Application.Invoke(delegate { user_entry.Text = text; user_entry.Sensitive = (state == FieldState.Enabled); user_example.Markup = "<span size=\"small\" fgcolor=\"" + SecondaryTextColor + "\">" + example_text + "</span>"; }); }; Controller.ChangePasswordFieldEvent += delegate(string text, string example_text, FieldState state) { Application.Invoke(delegate { password_entry.Text = text; password_entry.Sensitive = (state == FieldState.Enabled); password_example.Markup = "<span size=\"small\" fgcolor=\"" + SecondaryTextColor + "\">" + example_text + "</span>"; }); }; Controller.CheckAddPage(address_entry.Text); address_entry.Changed += delegate { Controller.CheckAddPage(address_entry.Text); }; // Address layout_address.PackStart(new Label() { Markup = "<b>" + "Address:" + "</b>", Xalign = 0 }, true, true, 0); layout_address.PackStart(address_entry, false, false, 0); layout_address.PackStart(address_example, false, false, 0); // User layout_user.PackStart(new Label() { Markup = "<b>" + "User:"******"</b>", Xalign = 0 }, true, true, 0); layout_user.PackStart(user_entry, false, false, 0); layout_user.PackStart(user_example, false, false, 0); // Password layout_password.PackStart(new Label() { Markup = "<b>" + "password:"******"</b>", Xalign = 0 }, true, true, 0); layout_password.PackStart(password_entry, false, false, 0); layout_password.PackStart(password_example, false, false, 0); layout_fields.PackStart(layout_address); layout_fields.PackStart(layout_user); layout_fields.PackStart(layout_password); layout_vertical.PackStart(new Label(""), false, false, 0); layout_vertical.PackStart(layout_fields, false, false, 0); Add(layout_vertical); // Cancel button Button cancel_button = new Button("Cancel"); cancel_button.Clicked += delegate { Controller.PageCancelled(); }; // Continue button Button continue_button = new Button("Continue") { Sensitive = false }; continue_button.Clicked += delegate { // Show wait cursor // TODO System.Windows.Forms.Cursor.Current = System.Windows.Forms.Cursors.WaitCursor; SparkleLogger.LogInfo("SparkleSetup", "address:" + address_entry.Text + " user:"******" password:"******"Sorry, CmisSync can not find a CMIS server at this address.\nPlease check again.\nIf you are sure about the address, open it in a browser and post\nthe resulting XML to the CmisSync forum."; // TODO address_error_label.Visibility = Visibility.Visible; } else { SparkleLogger.LogInfo("SparkleSetup", "repositories[0]:" + Controller.repositories[0]); // Continue to folder selection Controller.Add1PageCompleted( address_entry.Text, user_entry.Text, password_entry.Text); } }; Controller.UpdateAddProjectButtonEvent += delegate(bool button_enabled) { Application.Invoke(delegate { continue_button.Sensitive = button_enabled; }); }; AddButton(cancel_button); AddButton(continue_button); Controller.CheckAddPage(address_entry.Text); break; } case PageType.Add2: { Header = "Which remote folder do you want to sync?"; VBox layout_vertical = new VBox(false, 12); HBox layout_fields = new HBox(true, 12); VBox layout_repository = new VBox(true, 0); VBox layout_path = new VBox(true, 0); // Repository Entry repository_entry = new Entry() { Text = Controller.repositories[0], // TODO put all elements in a tree Sensitive = (Controller.SelectedPlugin.Repository == null), ActivatesDefault = true }; Label repository_example = new Label() { Xalign = 0, UseMarkup = true, Markup = "<span size=\"small\" fgcolor=\"" + SecondaryTextColor + "\">" + Controller.SelectedPlugin.RepositoryExample + "</span>" }; // Path Entry path_entry = new Entry() { Text = "/", Sensitive = (Controller.SelectedPlugin.Path == null), ActivatesDefault = true }; Label path_example = new Label() { Xalign = 0, UseMarkup = true, Markup = "<span size=\"small\" fgcolor=\"" + SecondaryTextColor + "\">" + Controller.SelectedPlugin.PathExample + "</span>" }; Controller.ChangeRepositoryFieldEvent += delegate(string text, string example_text, FieldState state) { Application.Invoke(delegate { repository_entry.Text = text; repository_entry.Sensitive = (state == FieldState.Enabled); repository_example.Markup = "<span size=\"small\" fgcolor=\"" + SecondaryTextColor + "\">" + example_text + "</span>"; }); }; Controller.ChangePathFieldEvent += delegate(string text, string example_text, FieldState state) { Application.Invoke(delegate { path_entry.Text = text; path_entry.Sensitive = (state == FieldState.Enabled); path_example.Markup = "<span size=\"small\" fgcolor=\"" + SecondaryTextColor + "\">" + example_text + "</span>"; }); }; //Controller.CheckAddPage (address_entry.Text); // Repository layout_repository.PackStart(new Label() { Markup = "<b>" + "Repository:" + "</b>", Xalign = 0 }, true, true, 0); layout_repository.PackStart(repository_entry, false, false, 0); layout_repository.PackStart(repository_example, false, false, 0); // Path layout_path.PackStart(new Label() { Markup = "<b>" + "Remote Path:" + "</b>", Xalign = 0 }, true, true, 0); layout_path.PackStart(path_entry, false, false, 0); layout_path.PackStart(path_example, false, false, 0); layout_fields.PackStart(layout_repository); layout_fields.PackStart(layout_path); layout_vertical.PackStart(new Label(""), false, false, 0); layout_vertical.PackStart(layout_fields, false, false, 0); Add(layout_vertical); // Cancel button Button cancel_button = new Button("Cancel"); cancel_button.Clicked += delegate { Controller.PageCancelled(); }; Button add_button = new Button("Add") { //Sensitive = false }; add_button.Clicked += delegate { Controller.Add2PageCompleted(repository_entry.Text, path_entry.Text); }; Controller.UpdateAddProjectButtonEvent += delegate(bool button_enabled) { Application.Invoke(delegate { add_button.Sensitive = button_enabled; }); }; AddButton(cancel_button); AddButton(add_button); //Controller.CheckAddPage (address_entry.Text); break; } case PageType.Invite: { Header = "You've received an invite!"; Description = "Do you want to add this project to SparkleShare?"; Table table = new Table(2, 3, true) { RowSpacing = 6, ColumnSpacing = 6 }; Label address_label = new Label("Address:") { Xalign = 1 }; Label path_label = new Label("Remote Path:") { Xalign = 1 }; Label address_value = new Label("<b>" + Controller.PendingInvite.Address + "</b>") { UseMarkup = true, Xalign = 0 }; Label path_value = new Label("<b>" + Controller.PendingInvite.RemotePath + "</b>") { UseMarkup = true, Xalign = 0 }; table.Attach(address_label, 0, 1, 0, 1); table.Attach(address_value, 1, 2, 0, 1); table.Attach(path_label, 0, 1, 1, 2); table.Attach(path_value, 1, 2, 1, 2); VBox wrapper = new VBox(false, 9); wrapper.PackStart(table, true, false, 0); Button cancel_button = new Button("Cancel"); cancel_button.Clicked += delegate { Controller.PageCancelled(); }; Button add_button = new Button("Add"); add_button.Clicked += delegate { Controller.InvitePageCompleted(); }; AddButton(cancel_button); AddButton(add_button); Add(wrapper); break; } case PageType.Syncing: { Header = String.Format("Adding project ‘{0}’…", Controller.SyncingFolder); Description = "This may either take a short or a long time depending on the project's size."; this.progress_bar.Fraction = Controller.ProgressBarPercentage / 100; Button finish_button = new Button() { Sensitive = false, Label = "Finish" }; Button cancel_button = new Button() { Label = "Cancel" }; cancel_button.Clicked += delegate { Controller.SyncingCancelled(); }; AddButton(cancel_button); AddButton(finish_button); Controller.UpdateProgressBarEvent += delegate(double percentage) { Application.Invoke(delegate { this.progress_bar.Fraction = percentage / 100; }); }; if (this.progress_bar.Parent != null) { (this.progress_bar.Parent as Container).Remove(this.progress_bar); } VBox bar_wrapper = new VBox(false, 0); bar_wrapper.PackStart(this.progress_bar, false, false, 15); Add(bar_wrapper); break; } case PageType.Error: { Header = "Oops! Something went wrong" + "…"; VBox points = new VBox(false, 0); Image list_point_one = new Image(SparkleUIHelpers.GetIcon("go-next", 16)); Image list_point_two = new Image(SparkleUIHelpers.GetIcon("go-next", 16)); Image list_point_three = new Image(SparkleUIHelpers.GetIcon("go-next", 16)); Label label_one = new Label() { Markup = "<b>" + Controller.PreviousUrl + "</b> is the address we've compiled. " + "Does this look alright?", Wrap = true, Xalign = 0 }; Label label_two = new Label() { Text = "Do you have access rights to this remote project?", Wrap = true, Xalign = 0 }; points.PackStart(new Label("Please check the following:") { Xalign = 0 }, false, false, 6); HBox point_one = new HBox(false, 0); point_one.PackStart(list_point_one, false, false, 0); point_one.PackStart(label_one, true, true, 12); points.PackStart(point_one, false, false, 12); HBox point_two = new HBox(false, 0); point_two.PackStart(list_point_two, false, false, 0); point_two.PackStart(label_two, true, true, 12); points.PackStart(point_two, false, false, 12); if (warnings.Length > 0) { string warnings_markup = ""; foreach (string warning in warnings) { warnings_markup += "\n<b>" + warning + "</b>"; } Label label_three = new Label() { Markup = "Here's the raw error message:" + warnings_markup, Wrap = true, Xalign = 0 }; HBox point_three = new HBox(false, 0); point_three.PackStart(list_point_three, false, false, 0); point_three.PackStart(label_three, true, true, 12); points.PackStart(point_three, false, false, 12); } points.PackStart(new Label(""), true, true, 0); Button cancel_button = new Button("Cancel"); cancel_button.Clicked += delegate { Controller.PageCancelled(); }; Button try_again_button = new Button("Try Again…") { Sensitive = true }; try_again_button.Clicked += delegate { Controller.ErrorPageCompleted(); }; AddButton(cancel_button); AddButton(try_again_button); Add(points); break; } case PageType.CryptoSetup: { Header = "Set up file encryption"; Description = "This project is supposed to be encrypted, but it doesn't yet have a password set. Please provide one below."; Label password_label = new Label("<b>" + "Password:"******"</b>") { UseMarkup = true, Xalign = 1 }; Entry password_entry = new Entry() { Xalign = 0, Visibility = false, ActivatesDefault = true }; CheckButton show_password_check_button = new CheckButton("Show password") { Active = false, Xalign = 0, }; show_password_check_button.Toggled += delegate { password_entry.Visibility = !password_entry.Visibility; }; password_entry.Changed += delegate { Controller.CheckCryptoSetupPage(password_entry.Text); }; Button continue_button = new Button("Continue") { Sensitive = false }; continue_button.Clicked += delegate { Controller.CryptoSetupPageCompleted(password_entry.Text); }; Button cancel_button = new Button("Cancel"); cancel_button.Clicked += delegate { Controller.CryptoPageCancelled(); }; Controller.UpdateCryptoSetupContinueButtonEvent += delegate(bool button_enabled) { Application.Invoke(delegate { continue_button.Sensitive = button_enabled; }); }; Table table = new Table(2, 3, true) { RowSpacing = 6, ColumnSpacing = 6 }; table.Attach(password_label, 0, 1, 0, 1); table.Attach(password_entry, 1, 2, 0, 1); table.Attach(show_password_check_button, 1, 2, 1, 2); VBox wrapper = new VBox(false, 9); wrapper.PackStart(table, true, false, 0); Image warning_image = new Image( SparkleUIHelpers.GetIcon("dialog-information", 24) ); Label warning_label = new Label() { Xalign = 0, Wrap = true, Text = "This password can't be changed later, and your files can't be recovered if it's forgotten." }; HBox warning_layout = new HBox(false, 0); warning_layout.PackStart(warning_image, false, false, 15); warning_layout.PackStart(warning_label, true, true, 0); VBox warning_wrapper = new VBox(false, 0); warning_wrapper.PackStart(warning_layout, false, false, 15); wrapper.PackStart(warning_wrapper, false, false, 0); Add(wrapper); AddButton(cancel_button); AddButton(continue_button); break; } case PageType.CryptoPassword: { Header = "This project contains encrypted files"; Description = "Please enter the password to see their contents."; Label password_label = new Label("<b>" + "Password:"******"</b>") { UseMarkup = true, Xalign = 1 }; Entry password_entry = new Entry() { Xalign = 0, Visibility = false, ActivatesDefault = true }; CheckButton show_password_check_button = new CheckButton("Show password") { Active = false, Xalign = 0 }; show_password_check_button.Toggled += delegate { password_entry.Visibility = !password_entry.Visibility; }; password_entry.Changed += delegate { Controller.CheckCryptoPasswordPage(password_entry.Text); }; Button continue_button = new Button("Continue") { Sensitive = false }; continue_button.Clicked += delegate { Controller.CryptoPasswordPageCompleted(password_entry.Text); }; Button cancel_button = new Button("Cancel"); cancel_button.Clicked += delegate { Controller.CryptoPageCancelled(); }; Controller.UpdateCryptoPasswordContinueButtonEvent += delegate(bool button_enabled) { Application.Invoke(delegate { continue_button.Sensitive = button_enabled; }); }; Table table = new Table(2, 3, true) { RowSpacing = 6, ColumnSpacing = 6 }; table.Attach(password_label, 0, 1, 0, 1); table.Attach(password_entry, 1, 2, 0, 1); table.Attach(show_password_check_button, 1, 2, 1, 2); VBox wrapper = new VBox(false, 9); wrapper.PackStart(table, true, false, 0); Add(wrapper); AddButton(cancel_button); AddButton(continue_button); break; } case PageType.Finished: { UrgencyHint = true; if (!HasToplevelFocus) { string title = "Your documents are ready!"; string subtext = "You can find them in your CmisSync folder."; Program.UI.Bubbles.Controller.ShowBubble(title, subtext, null); } Header = "Your documents are ready!"; Description = "You can find them in your CmisSync folder."; // A button that opens the synced folder Button open_folder_button = new Button(string.Format("Open {0}", System.IO.Path.GetFileName(Controller.PreviousPath))); open_folder_button.Clicked += delegate { Controller.OpenFolderClicked(); }; Button finish_button = new Button("Finish"); finish_button.Clicked += delegate { Controller.FinishPageCompleted(); }; if (warnings.Length > 0) { Image warning_image = new Image( SparkleUIHelpers.GetIcon("dialog-information", 24) ); Label warning_label = new Label(warnings [0]) { Xalign = 0, Wrap = true }; HBox warning_layout = new HBox(false, 0); warning_layout.PackStart(warning_image, false, false, 15); warning_layout.PackStart(warning_label, true, true, 0); VBox warning_wrapper = new VBox(false, 0); warning_wrapper.PackStart(warning_layout, false, false, 0); Add(warning_wrapper); } else { Add(null); } AddButton(open_folder_button); AddButton(finish_button); break; } case PageType.Tutorial: { switch (Controller.TutorialPageNumber) { case 1: { Header = "What's happening next?"; Description = "CmisSync creates a special folder on your computer " + "that will keep track of your folders."; Button skip_tutorial_button = new Button("Skip Tutorial"); skip_tutorial_button.Clicked += delegate { Controller.TutorialSkipped(); }; Button continue_button = new Button("Continue"); continue_button.Clicked += delegate { Controller.TutorialPageCompleted(); }; Image slide = SparkleUIHelpers.GetImage("tutorial-slide-1.png"); Add(slide); AddButton(skip_tutorial_button); AddButton(continue_button); break; } case 2: { Header = "Sharing files with others"; Description = "All files added to the server are automatically synced to your " + "local folder."; Button continue_button = new Button("Continue"); continue_button.Clicked += delegate { Controller.TutorialPageCompleted(); }; Image slide = SparkleUIHelpers.GetImage("tutorial-slide-2.png"); Add(slide); AddButton(continue_button); break; } case 3: { Header = "The status icon is here to help"; Description = "It shows the syncing progress, provides easy access to " + "your folders and let's you view recent changes."; Button continue_button = new Button("Continue"); continue_button.Clicked += delegate { Controller.TutorialPageCompleted(); }; Image slide = SparkleUIHelpers.GetImage("tutorial-slide-3.png"); Add(slide); AddButton(continue_button); break; } case 4: { Header = "Adding repository folders to CmisSync"; Description = " " + " "; Image slide = SparkleUIHelpers.GetImage("tutorial-slide-4.png"); Button finish_button = new Button("Finish"); finish_button.Clicked += delegate { Controller.TutorialPageCompleted(); }; CheckButton check_button = new CheckButton("Add CmisSync to startup items") { Active = true }; check_button.Toggled += delegate { Controller.StartupItemChanged(check_button.Active); }; Add(slide); AddOption(check_button); AddButton(finish_button); break; } } break; } } ShowAll(); }); }; }