Ejemplo n.º 1
0
        public About()
        {
            Title      = "About SparkleShare";
            ResizeMode = ResizeMode.NoResize;
            Height     = 288;
            Width      = 720;
            Icon       = UserInterfaceHelpers.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();
                });
            };
        }
Ejemplo n.º 2
0
        public Spinner(int size) : base()
        {
            if (DesignerProperties.GetIsInDesignMode(this))
            {
                return;
            }

            Width  = size;
            Height = size;

            int          current_frame    = 0;
            BitmapSource spinner_gallery  = UserInterfaceHelpers.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;
                });
            };
        }
Ejemplo n.º 3
0
        public Note()
        {
            InitializeComponent();

            Background         = new SolidColorBrush(Color.FromRgb(240, 240, 240));
            AllowsTransparency = false;
            Icon = UserInterfaceHelpers.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();
        }
Ejemplo n.º 4
0
        private void CreateNote()
        {
            ImageSource avatar = UserInterfaceHelpers.GetImageSource("user-icon-default");

            if (File.Exists(Controller.AvatarFilePath))
            {
                avatar = UserInterfaceHelpers.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);
        }
Ejemplo n.º 5
0
        public SetupWindow()
        {
            Title      = "SparkleShare Setup";
            Width      = 640;
            Height     = 440;
            ResizeMode = ResizeMode.NoResize;
            Background = new SolidColorBrush(Colors.WhiteSmoke);
            Icon       = UserInterfaceHelpers.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 = UserInterfaceHelpers.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);
        }
Ejemplo n.º 6
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 = UserInterfaceHelpers.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 = SparkleShare.Controller.UserAuthenticationInfo.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 = SparkleShare.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;
                SparkleShare.Controller.ToggleNotifications();
                notify_check_box.IsChecked = SparkleShare.Controller.NotificationsEnabled;
            };

            notify_item.Click += delegate {
                SparkleShare.Controller.ToggleNotifications();
                notify_check_box.IsChecked = SparkleShare.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 = UserInterfaceHelpers.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 = UserInterfaceHelpers.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 = "Retry Sync"
                            };
                            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;
        }
Ejemplo n.º 7
0
        private void CreateAbout()
        {
            Image image = new Image()
            {
                Width  = 720,
                Height = 260
            };

            image.Source = UserInterfaceHelpers.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;
        }