public static GetImageSource ( string name ) : BitmapFrame | ||
name | string | |
Résultat | BitmapFrame |
public SparkleAbout() { Title = "About SparkleShare"; ResizeMode = ResizeMode.NoResize; Height = 288; Width = 640; Icon = SparkleUIHelpers.GetImageSource("sparkleshare-app", "ico"); WindowStartupLocation = WindowStartupLocation.CenterScreen; Closing += Close; CreateAbout(); Controller.ShowWindowEvent += delegate { Dispatcher.BeginInvoke((Action) delegate { Show(); Activate(); BringIntoView(); }); }; Controller.HideWindowEvent += delegate { Dispatcher.BeginInvoke((Action) delegate { Hide(); }); }; Controller.UpdateLabelEvent += delegate(string text) { Dispatcher.BeginInvoke((Action) delegate { this.updates.Content = text; this.updates.UpdateLayout(); }); }; }
private void CreateAbout() { Image image = new Image() { Width = 640, Height = 260 }; image.Source = SparkleUIHelpers.GetImageSource("about"); Label version = new Label() { Content = "version " + Controller.RunningVersion, FontSize = 11, Foreground = new SolidColorBrush(Colors.White) }; this.updates = new Label() { Content = "Checking for updates...", FontSize = 11, Foreground = new SolidColorBrush(Color.FromRgb(135, 178, 227)) }; TextBlock credits = new TextBlock() { FontSize = 11, Foreground = new SolidColorBrush(Colors.White), Text = "Copyright © 2010–" + DateTime.Now.Year + " Hylke Bons and others.\n" + "\n" + "SparkleShare is Open Source software. You are free to use, modify, " + "and redistribute it under the GNU General Public License version 3 or later.", TextWrapping = TextWrapping.Wrap, Width = 318 }; Canvas canvas = new Canvas(); canvas.Children.Add(image); Canvas.SetLeft(image, 0); Canvas.SetTop(image, 0); canvas.Children.Add(version); Canvas.SetLeft(version, 289); Canvas.SetTop(version, 92); canvas.Children.Add(this.updates); Canvas.SetLeft(this.updates, 289); Canvas.SetTop(this.updates, 109); canvas.Children.Add(credits); Canvas.SetLeft(credits, 294); Canvas.SetTop(credits, 142); Content = canvas; }
public SparkleSpinner(int size) : base() { if (DesignerProperties.GetIsInDesignMode(this)) { return; } Width = size; Height = size; int current_frame = 0; BitmapSource spinner_gallery = SparkleUIHelpers.GetImageSource("process-working-22"); int frames_in_width = spinner_gallery.PixelWidth / size; int frames_in_height = spinner_gallery.PixelHeight / size; int frame_count = (frames_in_width * frames_in_height) - 1; Image [] frames = new Image [frame_count]; int i = 0; for (int y = 0; y < frames_in_height; y++) { for (int x = 0; x < frames_in_width; x++) { if (!(y == 0 && x == 0)) { CroppedBitmap crop = new CroppedBitmap(spinner_gallery, new Int32Rect(size * x, size * y, size, size)); frames [i] = new Image(); frames [i].Source = crop; i++; } } } this.timer = new Timer() { Interval = 400 / frame_count }; this.timer.Elapsed += delegate { Dispatcher.BeginInvoke((Action) delegate { if (current_frame < frame_count - 1) { current_frame++; } else { current_frame = 0; } Source = frames [current_frame].Source; }); }; }
public SparkleSetupWindow() { Title = "SparkleShare Setup"; Width = 640; Height = 440; ResizeMode = ResizeMode.NoResize; Background = new SolidColorBrush(Colors.WhiteSmoke); Icon = SparkleUIHelpers.GetImageSource("sparkleshare-app", "ico"); TaskbarItemInfo = new TaskbarItemInfo() { Description = "SparkleShare" }; WindowStartupLocation = WindowStartupLocation.CenterScreen; Content = ContentCanvas; Closing += Close; this.bar = new Rectangle() { Width = Width, Height = 40, Fill = new SolidColorBrush(Color.FromRgb(240, 240, 240)) }; this.line = new Rectangle() { Width = Width, Height = 1, Fill = new SolidColorBrush(Color.FromRgb(223, 223, 223)) }; this.side_splash = new Image() { Width = 150, Height = 482 }; this.side_splash.Source = SparkleUIHelpers.GetImageSource("side-splash"); ContentCanvas.Children.Add(this.bar); Canvas.SetRight(bar, 0); Canvas.SetBottom(bar, 0); ContentCanvas.Children.Add(this.line); Canvas.SetRight(this.line, 0); Canvas.SetBottom(this.line, 40); ContentCanvas.Children.Add(this.side_splash); Canvas.SetLeft(this.side_splash, 0); Canvas.SetBottom(this.side_splash, 0); }
public SparkleNote() { InitializeComponent(); Background = new SolidColorBrush(Color.FromRgb(240, 240, 240)); AllowsTransparency = false; Icon = SparkleUIHelpers.GetImageSource("sparkleshare-app", "ico"); WindowStartupLocation = WindowStartupLocation.CenterScreen; Closing += this.OnClosing; Controller.ShowWindowEvent += delegate { Dispatcher.BeginInvoke((Action)(() => { Show(); Activate(); CreateNote(); BringIntoView(); })); }; Controller.HideWindowEvent += delegate { Dispatcher.BeginInvoke((Action)(() => { Hide(); this.balloon_text_field.Clear(); })); }; this.cancel_button.Click += delegate { Dispatcher.BeginInvoke((Action)(() => { Controller.CancelClicked(); })); }; this.sync_button.Click += delegate { Dispatcher.BeginInvoke((Action)(() => { string note = this.balloon_text_field.Text; if (note.Equals(default_text, StringComparison.InvariantCultureIgnoreCase)) { note = String.Empty; } Controller.SyncClicked(note); })); }; this.balloon_text_field.GotFocus += OnTextBoxGotFocus; this.balloon_text_field.LostFocus += OnTextBoxLostFocus; CreateNote(); }
public SparkleAbout() { Title = "About SparkleShare"; ResizeMode = ResizeMode.NoResize; Height = 288; Width = 640; Icon = SparkleUIHelpers.GetImageSource("sparkleshare-app", "ico"); WindowStartupLocation = WindowStartupLocation.CenterScreen; Closing += Close; CreateAbout(); Controller.ShowWindowEvent += delegate { Dispatcher.BeginInvoke((Action) delegate { Show(); Activate(); BringIntoView(); }); }; Controller.HideWindowEvent += delegate { Dispatcher.BeginInvoke((Action) delegate { Hide(); }); }; Controller.NewVersionEvent += delegate(string new_version) { Dispatcher.BeginInvoke((Action) delegate { this.updates.Content = "A newer version (" + new_version + ") is available!"; this.updates.UpdateLayout(); }); }; Controller.VersionUpToDateEvent += delegate { Dispatcher.BeginInvoke((Action) delegate { this.updates.Content = "You are running the latest version."; this.updates.UpdateLayout(); }); }; Controller.CheckingForNewVersionEvent += delegate { Dispatcher.BeginInvoke((Action) delegate { this.updates.Content = "Checking for updates..."; this.updates.UpdateLayout(); }); }; }
public SparkleSpinner(int size) : base() { Width = size; Height = size; BitmapSource spinner_gallery = SparkleUIHelpers.GetImageSource("process-working-22"); int frames_in_width = spinner_gallery.PixelWidth / size; int frames_in_height = spinner_gallery.PixelHeight / size; this.num_steps = (frames_in_width * frames_in_height) - 1; this.images = new Image [this.num_steps]; int i = 0; for (int y = 0; y < frames_in_height; y++) { for (int x = 0; x < frames_in_width; x++) { if (!(y == 0 && x == 0)) { CroppedBitmap crop = new CroppedBitmap( spinner_gallery, new Int32Rect(size * x, size * y, size, size) ); this.images [i] = new Image(); this.images [i].Source = crop; i++; } } } this.timer = new Timer() { Interval = 400 / this.num_steps }; this.timer.Elapsed += delegate { Dispatcher.Invoke((Action) delegate { NextImage(); }); }; Start(); }
private void CreateNote() { ImageSource avatar = SparkleUIHelpers.GetImageSource("user-icon-default"); if (File.Exists(Controller.AvatarFilePath)) { avatar = SparkleUIHelpers.GetImage(Controller.AvatarFilePath); } this.user_image.ImageSource = avatar; this.Title = Controller.CurrentProject ?? "Add Note"; this.user_name_text_block.Text = SparkleShare.Controller.CurrentUser.Name; this.user_email_text_field.Text = SparkleShare.Controller.CurrentUser.Email; this.balloon_text_field.Text = default_text; ElementHost.EnableModelessKeyboardInterop(this); }
private void WriteOutImages() { string tmp_path = SparkleLib.SparkleConfig.DefaultConfig.TmpPath; string pixmaps_path = Path.Combine(tmp_path, "Pixmaps"); if (!Directory.Exists(pixmaps_path)) { Directory.CreateDirectory(pixmaps_path); File.SetAttributes(tmp_path, File.GetAttributes(tmp_path) | FileAttributes.Hidden); } char [] letters = new char [] { 'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k' }; foreach (char letter in letters) { BitmapSource image = SparkleUIHelpers.GetImageSource("avatar-" + letter); string file_path = Path.Combine(pixmaps_path, "avatar-" + letter + ".png"); using (FileStream stream = new FileStream(file_path, FileMode.Create)) { BitmapEncoder encoder = new PngBitmapEncoder(); encoder.Frames.Add(BitmapFrame.Create(image)); encoder.Save(stream); } } string [] actions = new string [] { "added", "deleted", "edited", "moved" }; foreach (string action in actions) { BitmapSource image = SparkleUIHelpers.GetImageSource("document-" + action + "-12"); string file_path = Path.Combine(pixmaps_path, "document-" + action + "-12.png"); using (FileStream stream = new FileStream(file_path, FileMode.Create)) { BitmapEncoder encoder = new PngBitmapEncoder(); encoder.Frames.Add(BitmapFrame.Create(image)); encoder.Save(stream); } } }
private void WriteOutImages() { string tmp_path = SparkleLib.SparkleConfig.DefaultConfig.TmpPath; string pixmaps_path = Path.Combine(tmp_path, "Images".SHA1()); if (!Directory.Exists(pixmaps_path)) { Directory.CreateDirectory(pixmaps_path); File.SetAttributes(tmp_path, File.GetAttributes(tmp_path) | FileAttributes.Hidden); } BitmapSource image = SparkleUIHelpers.GetImageSource("user-icon-default"); string file_path = Path.Combine(pixmaps_path, "user-icon-default.png"); using (FileStream stream = new FileStream(file_path, FileMode.Create)) { BitmapEncoder encoder = new PngBitmapEncoder(); encoder.Frames.Add(BitmapFrame.Create(image)); encoder.Save(stream); } string [] actions = new string [] { "added", "deleted", "edited", "moved" }; foreach (string action in actions) { image = SparkleUIHelpers.GetImageSource("document-" + action + "-12"); file_path = Path.Combine(pixmaps_path, "document-" + action + "-12.png"); using (FileStream stream = new FileStream(file_path, FileMode.Create)) { BitmapEncoder encoder = new PngBitmapEncoder(); encoder.Frames.Add(BitmapFrame.Create(image)); encoder.Save(stream); } } }
public void CreateMenu() { this.context_menu = new ContextMenu(); this.state_item = new SparkleMenuItem() { Header = Controller.StateText, IsEnabled = false }; this.notify_icon.HeaderText = "SparkleShare\n" + Controller.StateText; Image folder_image = new Image() { Source = SparkleUIHelpers.GetImageSource("sparkleshare-folder"), Width = 16, Height = 16 }; SparkleMenuItem folder_item = new SparkleMenuItem() { Header = "SparkleShare", Icon = folder_image }; folder_item.Click += delegate { Controller.SparkleShareClicked(); }; SparkleMenuItem add_item = new SparkleMenuItem() { Header = "Add hosted project…" }; add_item.Click += delegate { Controller.AddHostedProjectClicked(); }; this.log_item = new SparkleMenuItem() { Header = "Recent changes…", IsEnabled = Controller.OpenRecentEventsItemEnabled }; this.log_item.Click += delegate { Controller.OpenRecentEventsClicked(); }; SparkleMenuItem notify_item = new SparkleMenuItem() { Header = "Notifications" }; CheckBox notify_check_box = new CheckBox() { Margin = new Thickness(6, 0, 0, 0), IsChecked = (Controller.Folders.Length > 0 && Program.Controller.NotificationsEnabled) }; notify_item.Icon = notify_check_box; notify_check_box.Click += delegate { this.context_menu.IsOpen = false; Program.Controller.ToggleNotifications(); notify_check_box.IsChecked = Program.Controller.NotificationsEnabled; }; notify_item.Click += delegate { Program.Controller.ToggleNotifications(); notify_check_box.IsChecked = Program.Controller.NotificationsEnabled; }; SparkleMenuItem about_item = new SparkleMenuItem() { Header = "About SparkleShare" }; about_item.Click += delegate { Controller.AboutClicked(); }; this.exit_item = new SparkleMenuItem() { Header = "Exit" }; this.exit_item.Click += delegate { this.notify_icon.Dispose(); Controller.QuitClicked(); }; this.context_menu.Items.Add(this.state_item); this.context_menu.Items.Add(new Separator()); this.context_menu.Items.Add(folder_item); if (Controller.Folders.Length > 0) { foreach (string folder_name in Controller.Folders) { SparkleMenuItem subfolder_item = new SparkleMenuItem() { Header = folder_name }; subfolder_item.Click += OpenFolderDelegate(folder_name); Image subfolder_image = new Image() { Source = SparkleUIHelpers.GetImageSource("folder"), Width = 16, Height = 16 }; if (Program.Controller.UnsyncedFolders.Contains(folder_name)) { subfolder_item.Icon = new Image() { Source = (BitmapSource)Imaging.CreateBitmapSourceFromHIcon( System.Drawing.SystemIcons.Exclamation.Handle, Int32Rect.Empty, BitmapSizeOptions.FromWidthAndHeight(16, 16) ) }; } else { subfolder_item.Icon = subfolder_image; } this.context_menu.Items.Add(subfolder_item); } SparkleMenuItem more_item = new SparkleMenuItem() { Header = "More projects" }; foreach (string folder_name in Controller.OverflowFolders) { SparkleMenuItem subfolder_item = new SparkleMenuItem() { Header = folder_name }; subfolder_item.Click += OpenFolderDelegate(folder_name); Image subfolder_image = new Image() { Source = SparkleUIHelpers.GetImageSource("folder"), Width = 16, Height = 16 }; if (Program.Controller.UnsyncedFolders.Contains(folder_name)) { subfolder_item.Icon = new Image() { Source = (BitmapSource)Imaging.CreateBitmapSourceFromHIcon( System.Drawing.SystemIcons.Exclamation.Handle, Int32Rect.Empty, BitmapSizeOptions.FromWidthAndHeight(16, 16) ) }; } else { subfolder_item.Icon = subfolder_image; } more_item.Items.Add(subfolder_item); } if (more_item.Items.Count > 0) { this.context_menu.Items.Add(new Separator()); this.context_menu.Items.Add(more_item); } } this.context_menu.Items.Add(new Separator()); this.context_menu.Items.Add(add_item); this.context_menu.Items.Add(this.log_item); this.context_menu.Items.Add(new Separator()); this.context_menu.Items.Add(notify_item); this.context_menu.Items.Add(new Separator()); this.context_menu.Items.Add(about_item); this.context_menu.Items.Add(new Separator()); this.context_menu.Items.Add(this.exit_item); this.notify_icon.ContextMenu = this.context_menu; }
public SparkleSetup() { Controller.ShowWindowEvent += delegate { Dispatcher.Invoke((Action) delegate { Show(); Activate(); BringIntoView(); }); }; Controller.HideWindowEvent += delegate { Dispatcher.Invoke((Action) delegate { Hide(); }); }; Controller.ChangePageEvent += delegate(PageType type, string [] warnings) { Dispatcher.Invoke((Action) delegate { Reset(); switch (type) { case PageType.Setup: { Header = "Welcome to SparkleShare!"; Description = "Before we get started, what's your name and email?\n" + "Don't worry, this information will only be visible to team members."; TextBlock name_label = new TextBlock() { Text = "Full Name:", Width = 150, TextAlignment = TextAlignment.Right, FontWeight = FontWeights.Bold }; TextBox name_box = new TextBox() { Text = Controller.GuessedUserName, Width = 175 }; TextBlock email_label = new TextBlock() { Text = "Email:", Width = 150, TextAlignment = TextAlignment.Right, FontWeight = FontWeights.Bold }; TextBox email_box = new TextBox() { Width = 175, Text = Controller.GuessedUserEmail }; Button cancel_button = new Button() { Content = "Cancel" }; Button continue_button = new Button() { Content = "Continue", IsEnabled = false }; ContentCanvas.Children.Add(name_label); Canvas.SetLeft(name_label, 180); Canvas.SetTop(name_label, 200 + 3); ContentCanvas.Children.Add(name_box); Canvas.SetLeft(name_box, 340); Canvas.SetTop(name_box, 200); ContentCanvas.Children.Add(email_label); Canvas.SetLeft(email_label, 180); Canvas.SetTop(email_label, 230 + 3); ContentCanvas.Children.Add(email_box); Canvas.SetLeft(email_box, 340); Canvas.SetTop(email_box, 230); Buttons.Add(continue_button); Buttons.Add(cancel_button); name_box.Focus(); name_box.Select(name_box.Text.Length, 0); Controller.UpdateSetupContinueButtonEvent += delegate(bool enabled) { Dispatcher.Invoke((Action) delegate { continue_button.IsEnabled = enabled; }); }; name_box.TextChanged += delegate { Controller.CheckSetupPage(name_box.Text, email_box.Text); }; email_box.TextChanged += delegate { Controller.CheckSetupPage(name_box.Text, email_box.Text); }; cancel_button.Click += delegate { Dispatcher.Invoke((Action) delegate { SparkleUI.StatusIcon.Dispose(); Controller.SetupPageCancelled(); }); }; continue_button.Click += delegate { Controller.SetupPageCompleted(name_box.Text, email_box.Text); }; Controller.CheckSetupPage(name_box.Text, email_box.Text); break; } case PageType.Invite: { Header = "You've received an invite!"; Description = "Do you want to add this project to SparkleShare?"; TextBlock address_label = new TextBlock() { Text = "Address:", Width = 150, TextAlignment = TextAlignment.Right }; TextBlock address_value = new TextBlock() { Text = Controller.PendingInvite.Address, Width = 175, FontWeight = FontWeights.Bold }; TextBlock path_label = new TextBlock() { Text = "Remote Path:", Width = 150, TextAlignment = TextAlignment.Right }; TextBlock path_value = new TextBlock() { Width = 175, Text = Controller.PendingInvite.RemotePath, FontWeight = FontWeights.Bold }; Button cancel_button = new Button() { Content = "Cancel" }; Button add_button = new Button() { Content = "Add" }; ContentCanvas.Children.Add(address_label); Canvas.SetLeft(address_label, 180); Canvas.SetTop(address_label, 200); ContentCanvas.Children.Add(address_value); Canvas.SetLeft(address_value, 340); Canvas.SetTop(address_value, 200); ContentCanvas.Children.Add(path_label); Canvas.SetLeft(path_label, 180); Canvas.SetTop(path_label, 225); ContentCanvas.Children.Add(path_value); Canvas.SetLeft(path_value, 340); Canvas.SetTop(path_value, 225); Buttons.Add(add_button); Buttons.Add(cancel_button); cancel_button.Click += delegate { Controller.PageCancelled(); }; add_button.Click += delegate { Controller.InvitePageCompleted(); }; break; } 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.Invoke((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.Invoke((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.Invoke((Action) delegate { add_button.IsEnabled = button_enabled; }); }; list_view.SelectionChanged += delegate { Controller.SelectedPluginChanged(list_view.SelectedIndex); }; list_view.KeyDown += delegate { Controller.SelectedPluginChanged(list_view.SelectedIndex); }; 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 either take a short or a long time depending on the project's size."; 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(finish_button); Buttons.Add(cancel_button); Controller.UpdateProgressBarEvent += delegate(double percentage) { Dispatcher.Invoke((Action) delegate { progress_bar.Value = percentage; TaskbarItemInfo.ProgressValue = percentage / 100; }); }; cancel_button.Click += delegate { Controller.SyncingCancelled(); }; break; } case PageType.Error: { Header = "Something went wrong…"; Description = "Please check the following:"; TextBlock help_block = new TextBlock() { TextWrapping = TextWrapping.Wrap, Width = 310 }; help_block.Inlines.Add("Is the host online?\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("The host needs to know who you are. Did you upload the key that's in your SparkleShare folder?"); TextBlock bullets_block = new TextBlock() { Text = "•\n\n•\n\n\n•" }; 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.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 open_folder_button = new Button() { Content = string.Format("Open {0}", Path.GetFileName(Controller.PreviousPath)) }; 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(finish_button); Buttons.Add(open_folder_button); finish_button.Click += delegate { Controller.FinishPageCompleted(); }; open_folder_button.Click += delegate { Controller.OpenFolderClicked(); }; SystemSounds.Exclamation.Play(); break; } case PageType.Tutorial: { switch (Controller.TutorialPageNumber) { case 1: { Header = "What's happening next?"; Description = "SparkleShare creates a special folder on your computer " + "that will keep track of your projects."; WPF.Image slide_image = new WPF.Image() { Width = 350, Height = 200 }; slide_image.Source = SparkleUIHelpers.GetImageSource("tutorial-slide-1-windows"); 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, 215); Canvas.SetTop(slide_image, 130); Buttons.Add(continue_button); Buttons.Add(skip_tutorial_button); skip_tutorial_button.Click += delegate { Controller.TutorialSkipped(); }; continue_button.Click += delegate { Controller.TutorialPageCompleted(); }; break; } case 2: { Header = "Sharing files with others"; Description = "All files added to your project folders are synced automatically with " + "the host and your team members."; Button continue_button = new Button() { Content = "Continue" }; WPF.Image slide_image = new WPF.Image() { Width = 350, Height = 200 }; slide_image.Source = SparkleUIHelpers.GetImageSource("tutorial-slide-2-windows"); ContentCanvas.Children.Add(slide_image); Canvas.SetLeft(slide_image, 215); Canvas.SetTop(slide_image, 130); Buttons.Add(continue_button); continue_button.Click += delegate { Controller.TutorialPageCompleted(); }; break; } case 3: { Header = "The status icon is here to help"; 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 = 350, Height = 200 }; slide_image.Source = SparkleUIHelpers.GetImageSource("tutorial-slide-3-windows"); ContentCanvas.Children.Add(slide_image); Canvas.SetLeft(slide_image, 215); Canvas.SetTop(slide_image, 130); Buttons.Add(continue_button); continue_button.Click += delegate { Controller.TutorialPageCompleted(); }; break; } case 4: { Header = "Adding projects to SparkleShare"; Description = "You can do this through the status icon menu, or by clicking " + "magic buttons on webpages that look like this:"; Button finish_button = new Button() { Content = "Finish" }; WPF.Image slide_image = new WPF.Image() { Width = 350, Height = 64 }; slide_image.Source = SparkleUIHelpers.GetImageSource("tutorial-slide-4"); CheckBox check_box = new CheckBox() { Content = "Add SparkleShare to startup items", IsChecked = true }; ContentCanvas.Children.Add(slide_image); Canvas.SetLeft(slide_image, 215); Canvas.SetTop(slide_image, 130); 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(); }; break; } } break; } } ShowAll(); }); }; }
public void CreateMenu() { this.context_menu = new ContextMenu(); this.state_item = new SparkleMenuItem { Header = Controller.StateText, IsEnabled = false }; Image folder_image = new Image { Source = SparkleUIHelpers.GetImageSource("sparkleshare-folder"), Width = 16, Height = 16 }; SparkleMenuItem folder_item = new SparkleMenuItem { Header = "SparkleShare", Icon = folder_image }; SparkleMenuItem add_item = new SparkleMenuItem { Header = "Add hosted project…" }; this.log_item = new SparkleMenuItem { Header = "Recent changes…", IsEnabled = Controller.RecentEventsItemEnabled }; SparkleMenuItem link_code_item = new SparkleMenuItem { Header = "Client ID" }; if (Controller.LinkCodeItemEnabled) { SparkleMenuItem code_item = new SparkleMenuItem { Header = Program.Controller.CurrentUser.PublicKey.Substring(0, 20) + "..." }; SparkleMenuItem copy_item = new SparkleMenuItem { Header = "Copy to Clipboard" }; copy_item.Click += delegate { Controller.CopyToClipboardClicked(); }; link_code_item.Items.Add(code_item); link_code_item.Items.Add(new Separator()); link_code_item.Items.Add(copy_item); } CheckBox notify_check_box = new CheckBox { Margin = new Thickness(6, 0, 0, 0), IsChecked = Program.Controller.NotificationsEnabled }; SparkleMenuItem notify_item = new SparkleMenuItem { Header = "Notifications", Icon = notify_check_box }; SparkleMenuItem about_item = new SparkleMenuItem { Header = "About SparkleShare" }; this.exit_item = new SparkleMenuItem { Header = "Exit" }; add_item.Click += delegate { Controller.AddHostedProjectClicked(); }; this.log_item.Click += delegate { Controller.RecentEventsClicked(); }; about_item.Click += delegate { Controller.AboutClicked(); }; notify_check_box.Click += delegate { this.context_menu.IsOpen = false; Program.Controller.ToggleNotifications(); notify_check_box.IsChecked = Program.Controller.NotificationsEnabled; }; notify_item.Click += delegate { Program.Controller.ToggleNotifications(); notify_check_box.IsChecked = Program.Controller.NotificationsEnabled; }; this.exit_item.Click += delegate { this.notify_icon.Dispose(); Controller.QuitClicked(); }; this.context_menu.Items.Add(this.state_item); this.context_menu.Items.Add(new Separator()); this.context_menu.Items.Add(folder_item); state_menu_items = new SparkleMenuItem[Controller.Projects.Length]; if (Controller.Projects.Length > 0) { int i = 0; foreach (ProjectInfo project in Controller.Projects) { SparkleMenuItem subfolder_item = new SparkleMenuItem { Header = project.Name.Replace("_", "__"), Icon = new Image { Source = SparkleUIHelpers.GetImageSource("folder"), Width = 16, Height = 16 } }; state_menu_items[i] = new SparkleMenuItem { Header = project.StatusMessage, IsEnabled = false }; subfolder_item.Items.Add(state_menu_items[i]); subfolder_item.Items.Add(new Separator()); SparkleMenuItem open_item = new SparkleMenuItem { Header = "Open folder", Icon = new Image { Source = SparkleUIHelpers.GetImageSource("folder"), Width = 16, Height = 16 } }; open_item.Click += new RoutedEventHandler(Controller.OpenFolderDelegate(project.Name)); subfolder_item.Items.Add(open_item); subfolder_item.Items.Add(new Separator()); if (project.IsPaused) { SparkleMenuItem resume_item; if (project.UnsyncedChangesInfo.Count > 0) { foreach (KeyValuePair <string, string> pair in project.UnsyncedChangesInfo) { subfolder_item.Items.Add(new SparkleMenuItem { Header = pair.Key, // TODO image IsEnabled = false }); } if (!string.IsNullOrEmpty(project.MoreUnsyncedChanges)) { subfolder_item.Items.Add(new SparkleMenuItem { Header = project.MoreUnsyncedChanges, IsEnabled = false }); } subfolder_item.Items.Add(new Separator()); resume_item = new SparkleMenuItem { Header = "Sync and Resume…" }; } else { resume_item = new SparkleMenuItem { Header = "Resume" }; } resume_item.Click += (sender, e) => Controller.ResumeDelegate(project.Name)(sender, e); subfolder_item.Items.Add(resume_item); } else { if (Controller.Projects[i].HasError) { subfolder_item.Icon = new Image { Source = Imaging.CreateBitmapSourceFromHIcon( Drawing.SystemIcons.Exclamation.Handle, Int32Rect.Empty, BitmapSizeOptions.FromWidthAndHeight(16, 16)) }; SparkleMenuItem try_again_item = new SparkleMenuItem { Header = "Try Again" }; try_again_item.Click += (sender, e) => Controller.TryAgainDelegate(project.Name)(sender, e); subfolder_item.Items.Add(try_again_item); } else { SparkleMenuItem pause_item = new SparkleMenuItem { Header = "Pause" }; pause_item.Click += (sender, e) => Controller.PauseDelegate(project.Name)(sender, e); subfolder_item.Items.Add(pause_item); } } this.context_menu.Items.Add(subfolder_item); i++; } ; } folder_item.Items.Add(this.log_item); folder_item.Items.Add(add_item); folder_item.Items.Add(new Separator()); folder_item.Items.Add(notify_item); folder_item.Items.Add(new Separator()); folder_item.Items.Add(link_code_item); folder_item.Items.Add(new Separator()); folder_item.Items.Add(about_item); this.context_menu.Items.Add(new Separator()); this.context_menu.Items.Add(this.exit_item); this.notify_icon.ContextMenu = this.context_menu; }
public SparkleSetupWindow() { Title = "SparkleShare Setup"; Width = 640; Height = 440; ResizeMode = ResizeMode.NoResize; Background = new SolidColorBrush(Colors.WhiteSmoke); Icon = SparkleUIHelpers.GetImageSource("sparkleshare-app", "ico"); TaskbarItemInfo = new TaskbarItemInfo() { Description = "SparkleShare" }; WindowStartupLocation = WindowStartupLocation.CenterScreen; Content = ContentCanvas; // Remove the close button Closing += Close; SourceInitialized += delegate { const int gwl_style = -16; const int ws_sysmenu = 0x00080000; WindowInteropHelper helper = new WindowInteropHelper(this); int style = GetWindowLong(helper.Handle, gwl_style); SetWindowLong(helper.Handle, gwl_style, style & ~ws_sysmenu); }; this.bar = new Rectangle() { Width = Width, Height = 40, Fill = new SolidColorBrush(Color.FromRgb(240, 240, 240)) }; this.line = new Rectangle() { Width = Width, Height = 1, Fill = new SolidColorBrush(Color.FromRgb(223, 223, 223)) }; this.side_splash = new Image() { Width = 150, Height = 482 }; this.side_splash.Source = SparkleUIHelpers.GetImageSource("side-splash"); ContentCanvas.Children.Add(this.bar); Canvas.SetRight(bar, 0); Canvas.SetBottom(bar, 0); ContentCanvas.Children.Add(this.line); Canvas.SetRight(this.line, 0); Canvas.SetBottom(this.line, 40); ContentCanvas.Children.Add(this.side_splash); Canvas.SetLeft(this.side_splash, 0); Canvas.SetBottom(this.side_splash, 0); }
public void CreateMenu() { this.context_menu = new ContextMenu(); this.state_item = new SparkleMenuItem() { Header = Controller.StateText, IsEnabled = false }; Image folder_image = new Image() { Source = SparkleUIHelpers.GetImageSource("sparkleshare-folder"), Width = 16, Height = 16 }; SparkleMenuItem folder_item = new SparkleMenuItem() { Header = "SparkleShare", Icon = folder_image }; SparkleMenuItem add_item = new SparkleMenuItem() { Header = "Add hosted project…" }; this.log_item = new SparkleMenuItem() { Header = "Recent changes…", IsEnabled = Controller.RecentEventsItemEnabled }; SparkleMenuItem link_code_item = new SparkleMenuItem() { Header = "Client ID" }; if (Controller.LinkCodeItemEnabled) { SparkleMenuItem code_item = new SparkleMenuItem(); code_item.Header = Program.Controller.CurrentUser.PublicKey.Substring(0, 20) + "..."; SparkleMenuItem copy_item = new SparkleMenuItem() { Header = "Copy to Clipboard" }; copy_item.Click += delegate { Controller.CopyToClipboardClicked(); }; link_code_item.Items.Add(code_item); link_code_item.Items.Add(new Separator()); link_code_item.Items.Add(copy_item); } CheckBox notify_check_box = new CheckBox() { Margin = new Thickness(6, 0, 0, 0), IsChecked = Program.Controller.NotificationsEnabled }; SparkleMenuItem notify_item = new SparkleMenuItem() { Header = "Notifications" }; notify_item.Icon = notify_check_box; SparkleMenuItem about_item = new SparkleMenuItem() { Header = "About SparkleShare" }; this.exit_item = new SparkleMenuItem() { Header = "Exit" }; add_item.Click += delegate { Controller.AddHostedProjectClicked(); }; this.log_item.Click += delegate { Controller.RecentEventsClicked(); }; about_item.Click += delegate { Controller.AboutClicked(); }; notify_check_box.Click += delegate { this.context_menu.IsOpen = false; Program.Controller.ToggleNotifications(); notify_check_box.IsChecked = Program.Controller.NotificationsEnabled; }; notify_item.Click += delegate { Program.Controller.ToggleNotifications(); notify_check_box.IsChecked = Program.Controller.NotificationsEnabled; }; this.exit_item.Click += delegate { this.notify_icon.Dispose(); Controller.QuitClicked(); }; this.context_menu.Items.Add(this.state_item); this.context_menu.Items.Add(new Separator()); this.context_menu.Items.Add(folder_item); if (Controller.Folders.Length > 0) { int i = 0; foreach (string folder_name in Controller.Folders) { SparkleMenuItem subfolder_item = new SparkleMenuItem() { Header = folder_name.Replace("_", "__") }; Image subfolder_image = new Image() { Source = SparkleUIHelpers.GetImageSource("folder"), Width = 16, Height = 16 }; if (!string.IsNullOrEmpty(Controller.FolderErrors [i])) { subfolder_item.Icon = new Image() { Source = (BitmapSource)Imaging.CreateBitmapSourceFromHIcon( System.Drawing.SystemIcons.Exclamation.Handle, Int32Rect.Empty, BitmapSizeOptions.FromWidthAndHeight(16, 16)) }; SparkleMenuItem error_item = new SparkleMenuItem() { Header = Controller.FolderErrors [i], IsEnabled = false }; SparkleMenuItem try_again_item = new SparkleMenuItem() { Header = "Try again" }; try_again_item.Click += delegate { Controller.TryAgainDelegate(folder_name); }; subfolder_item.Items.Add(error_item); subfolder_item.Items.Add(new Separator()); subfolder_item.Items.Add(try_again_item); } else { subfolder_item.Icon = subfolder_image; subfolder_item.Click += new RoutedEventHandler(Controller.OpenFolderDelegate(folder_name)); } this.context_menu.Items.Add(subfolder_item); i++; } } folder_item.Items.Add(this.log_item); folder_item.Items.Add(add_item); folder_item.Items.Add(new Separator()); folder_item.Items.Add(notify_item); folder_item.Items.Add(new Separator()); folder_item.Items.Add(link_code_item); folder_item.Items.Add(new Separator()); folder_item.Items.Add(about_item); this.context_menu.Items.Add(new Separator()); this.context_menu.Items.Add(this.exit_item); this.notify_icon.ContextMenu = this.context_menu; }
private void CreateAbout() { Image image = new Image() { Width = 640, Height = 260 }; image.Source = SparkleUIHelpers.GetImageSource("about"); Label version = new Label() { Content = "version " + Controller.RunningVersion, FontSize = 11, Foreground = new SolidColorBrush(Colors.White) }; this.updates = new Label() { Content = "Checking for updates...", FontSize = 11, Foreground = new SolidColorBrush(Color.FromArgb(128, 255, 255, 255)) }; TextBlock credits = new TextBlock() { FontSize = 11, Foreground = new SolidColorBrush(Colors.White), Text = "Copyright © 2010–" + DateTime.Now.Year + " Hylke Bons and others.\n" + "\n" + "SparkleShare is Open Source software. You are free to use, modify, " + "and redistribute it under the GNU General Public License version 3 or later.", TextWrapping = TextWrapping.Wrap, Width = 318 }; SparkleLink website_link = new SparkleLink("Website", Controller.WebsiteLinkAddress); SparkleLink credits_link = new SparkleLink("Credits", Controller.CreditsLinkAddress); SparkleLink report_problem_link = new SparkleLink("Report a problem", Controller.ReportProblemLinkAddress); SparkleLink debug_log_link = new SparkleLink("Debug log", Controller.DebugLogLinkAddress); Canvas canvas = new Canvas(); canvas.Children.Add(image); Canvas.SetLeft(image, 0); Canvas.SetTop(image, 0); canvas.Children.Add(version); Canvas.SetLeft(version, 289); Canvas.SetTop(version, 92); canvas.Children.Add(this.updates); Canvas.SetLeft(this.updates, 289); Canvas.SetTop(this.updates, 109); canvas.Children.Add(credits); Canvas.SetLeft(credits, 294); Canvas.SetTop(credits, 142); canvas.Children.Add(website_link); Canvas.SetLeft(website_link, 289); Canvas.SetTop(website_link, 222); canvas.Children.Add(credits_link); Canvas.SetLeft(credits_link, 289 + website_link.ActualWidth + 60); Canvas.SetTop(credits_link, 222); canvas.Children.Add(report_problem_link); Canvas.SetLeft(report_problem_link, 289 + website_link.ActualWidth + credits_link.ActualWidth + 115); Canvas.SetTop(report_problem_link, 222); canvas.Children.Add(debug_log_link); Canvas.SetLeft(debug_log_link, 289 + website_link.ActualWidth + credits_link.ActualWidth + report_problem_link.ActualWidth + 220); Canvas.SetTop(debug_log_link, 222); Content = canvas; }
public SparkleEventLogWindow() { InitializeComponent(); Background = new SolidColorBrush(Color.FromRgb(240, 240, 240)); AllowsTransparency = false; Icon = SparkleUIHelpers.GetImageSource("sparkleshare-app", "ico"); WindowStartupLocation = WindowStartupLocation.CenterScreen; WriteOutImages(); this.label_Size.Content = "Size: " + Controller.Size; this.label_History.Content = "History: " + Controller.HistorySize; this.webbrowser.ObjectForScripting = new SparkleScriptingObject(); // Disable annoying IE clicking sound CoInternetSetFeatureEnabled(21, 0x00000002, true); Closing += this.OnClosing; Controller.ShowWindowEvent += delegate { Dispatcher.BeginInvoke((Action)(() => { Show(); Activate(); BringIntoView(); })); }; Controller.HideWindowEvent += delegate { Dispatcher.BeginInvoke((Action)(() => { Hide(); this.spinner.Visibility = Visibility.Visible; this.webbrowser.Visibility = Visibility.Collapsed; })); }; Controller.UpdateSizeInfoEvent += delegate(string size, string history_size) { Dispatcher.BeginInvoke((Action)(() => { this.label_Size.Content = "Size: " + size; this.label_History.Content = "History: " + history_size; })); }; Controller.UpdateChooserEvent += delegate(string [] folders) { Dispatcher.BeginInvoke((Action)(() => UpdateChooser(folders)) ); }; Controller.UpdateChooserEnablementEvent += delegate(bool enabled) { Dispatcher.BeginInvoke((Action)(() => this.combobox.IsEnabled = enabled )); }; Controller.UpdateContentEvent += delegate(string html) { Dispatcher.BeginInvoke((Action)(() => { UpdateContent(html); this.spinner.Visibility = Visibility.Collapsed; this.webbrowser.Visibility = Visibility.Visible; })); }; Controller.ContentLoadingEvent += () => this.Dispatcher.BeginInvoke( (Action)(() => { this.spinner.Visibility = Visibility.Visible; this.spinner.Start(); this.webbrowser.Visibility = Visibility.Collapsed; })); Controller.ShowSaveDialogEvent += delegate(string file_name, string target_folder_path) { Dispatcher.BeginInvoke((Action)(() => { SaveFileDialog dialog = new SaveFileDialog() { FileName = file_name, InitialDirectory = target_folder_path, Title = "Restore from History", DefaultExt = "." + Path.GetExtension(file_name), Filter = "All Files|*.*" }; bool?result = dialog.ShowDialog(this); if (result == true) { Controller.SaveDialogCompleted(dialog.FileName); } else { Controller.SaveDialogCancelled(); } })); }; }
public SparkleEventLog() { Title = "Recent Changes"; Height = 640; Width = 480; ResizeMode = ResizeMode.NoResize; // TODO Background = new SolidColorBrush(Color.FromRgb(240, 240, 240)); AllowsTransparency = false; Icon = SparkleUIHelpers.GetImageSource("sparkleshare-app", "ico"); int x = (int)(SystemParameters.PrimaryScreenWidth * 0.61); int y = (int)(SystemParameters.PrimaryScreenHeight * 0.5 - (Height * 0.5)); WindowStartupLocation = WindowStartupLocation.Manual; Left = x; Top = y; WriteOutImages(); Label size_label = new Label() { Content = "Size:", FontWeight = FontWeights.Bold }; this.size_label_value = new Label() { Content = Controller.Size }; size_label.Measure(new Size(Double.PositiveInfinity, Double.PositiveInfinity)); Rect size_label_rect = new Rect(size_label.DesiredSize); Label history_label = new Label() { Content = "History:", FontWeight = FontWeights.Bold }; this.history_label_value = new Label() { Content = Controller.HistorySize, }; history_label.Measure(new Size(Double.PositiveInfinity, Double.PositiveInfinity)); Rect history_label_rect = new Rect(history_label.DesiredSize); Shapes.Rectangle line = new Shapes.Rectangle() { Width = Width, Height = 1, Fill = new SolidColorBrush(Color.FromRgb(223, 223, 223)) }; Shapes.Rectangle background = new Shapes.Rectangle() { Width = Width, Height = Height, Fill = new SolidColorBrush(Color.FromRgb(250, 250, 250)) }; this.web_browser = new WebBrowser() { Width = Width - 6, Height = Height - 36 - 11 }; this.web_browser.ObjectForScripting = new SparkleScriptingObject(); spinner = new SparkleSpinner(22); // Disable annoying IE clicking sound CoInternetSetFeatureEnabled(21, 0x00000002, true); this.canvas = new Canvas(); Content = this.canvas; this.canvas.Children.Add(size_label); Canvas.SetLeft(size_label, 24); Canvas.SetTop(size_label, 4); this.canvas.Children.Add(this.size_label_value); Canvas.SetLeft(this.size_label_value, 22 + size_label_rect.Width); Canvas.SetTop(this.size_label_value, 4); this.canvas.Children.Add(history_label); Canvas.SetLeft(history_label, 130); Canvas.SetTop(history_label, 4); this.canvas.Children.Add(this.history_label_value); Canvas.SetLeft(this.history_label_value, 130 + history_label_rect.Width); Canvas.SetTop(this.history_label_value, 4); this.canvas.Children.Add(background); Canvas.SetLeft(background, 0); Canvas.SetTop(background, 36); this.canvas.Children.Add(spinner); Canvas.SetLeft(spinner, (Width / 2) - 15); Canvas.SetTop(spinner, (Height / 2) - 22); this.canvas.Children.Add(line); Canvas.SetLeft(line, 0); Canvas.SetTop(line, 35); Closing += Close; Controller.ShowWindowEvent += delegate { Dispatcher.BeginInvoke((Action) delegate { Show(); Activate(); BringIntoView(); }); }; Controller.HideWindowEvent += delegate { Dispatcher.BeginInvoke((Action) delegate { Hide(); if (this.canvas.Children.Contains(this.web_browser)) { this.canvas.Children.Remove(this.web_browser); } }); }; Controller.UpdateSizeInfoEvent += delegate(string size, string history_size) { Dispatcher.BeginInvoke((Action) delegate { this.size_label_value.Content = size; this.size_label_value.UpdateLayout(); this.history_label_value.Content = history_size; this.history_label_value.UpdateLayout(); }); }; Controller.UpdateChooserEvent += delegate(string [] folders) { Dispatcher.BeginInvoke((Action) delegate { UpdateChooser(folders); }); }; Controller.UpdateContentEvent += delegate(string html) { Dispatcher.BeginInvoke((Action) delegate { UpdateContent(html); }); }; Controller.ContentLoadingEvent += delegate { Dispatcher.BeginInvoke((Action) delegate { this.spinner.Start(); if (this.canvas.Children.Contains(this.web_browser)) { this.canvas.Children.Remove(this.web_browser); } }); }; }
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(); }); }; }