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(); }
private void CreateNote() { var user_image = new Image(Controller.AvatarFilePath); /* TODO: Style the entry neatly, multiple lines, and add placeholder text * string balloon_image_path = new string [] { UserInterface.AssetsPath, "pixmaps", "text-balloon.png" }.Combine (); * Image balloon_image = new Image (balloon_image_path); * CssProvider balloon_css_provider = new CssProvider (); * * balloon_css_provider.LoadFromData ("GtkEntry {" + * "background-image: url('" + balloon_image_path + "');" + * "background-repeat: no-repeat;" + * "background-position: left top;" + * "}"); * * balloon.StyleContext.AddProvider (balloon_css_provider, 800); */ var balloon_label = new Label("<b>Anything to add?</b>") { Xalign = 0, UseMarkup = true }; var balloon = new Entry { MaxLength = 144 }; var cancel_button = new Button("Cancel"); var sync_button = new Button("Sync"); // TODO: Make default button sync_button.CanDefault = true; cancel_button.Clicked += delegate { Controller.CancelClicked(); }; sync_button.Clicked += delegate { Controller.SyncClicked(balloon.Buffer.Text); }; var layout_vertical = new VBox(false, 16); var layout_horizontal = new HBox(false, 16); var buttons = new HBox { Homogeneous = false, Spacing = 6 }; var user_label = new Label { Markup = "<b>" + SparkleShare.Controller.CurrentUser.Name + "</b>\n" + "<span fgcolor=\"" + SparkleShare.UI.SecondaryTextColor + "\">" + SparkleShare.Controller.CurrentUser.Email + "</span>" }; layout_horizontal.PackStart(user_image, false, false, 0); layout_horizontal.PackStart(user_label, false, false, 0); buttons.PackStart(new Label(""), true, true, 0); buttons.PackStart(cancel_button, false, false, 0); buttons.PackStart(sync_button, false, false, 0); layout_vertical.PackStart(layout_horizontal, false, false, 0); layout_vertical.PackStart(balloon_label, false, false, 0); layout_vertical.PackStart(balloon, false, false, 0); layout_vertical.PackStart(buttons, false, false, 0); Default = sync_button; Add(layout_vertical); }