public PryanetEventLog() { Title = "Recent Changes"; Height = 640; Width = 480; ResizeMode = ResizeMode.NoResize; // TODO Background = new SolidColorBrush (Color.FromRgb (240, 240, 240)); AllowsTransparency = false; Icon = PryanetUIHelpers.GetImageSource ("pryanetshare-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 - 64 }; this.web_browser.ObjectForScripting = new PryanetScriptingObject (); spinner = new PryanetSpinner (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.UpdateChooserEnablementEvent += delegate (bool enabled) { Dispatcher.BeginInvoke ((Action) delegate { this.combo_box.IsEnabled = enabled; }); }; 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); }); }; Controller.ShowSaveDialogEvent += delegate (string file_name, string target_folder_path) { Dispatcher.BeginInvoke ((Action) delegate { SaveFileDialog dialog = new SaveFileDialog () { FileName = file_name, InitialDirectory = target_folder_path, Title = "Restore from History", DefaultExt = "." + Path.GetExtension (file_name), Filter = "All Files|*.*" }; Nullable<bool> result = dialog.ShowDialog (this); if (result == true) Controller.SaveDialogCompleted (dialog.FileName); else Controller.SaveDialogCancelled (); }); }; }
public PryanetEventLog() : base("") { SetSizeRequest (480, (int) (Gdk.Screen.Default.Height * 0.8)); int x = (int) (Gdk.Screen.Default.Width * 0.61); int y = (int) (Gdk.Screen.Default.Height * 0.5 - (HeightRequest * 0.5)); Move (x, y); Resizable = true; BorderWidth = 0; Title = "Recent Changes"; IconName = "folder-pryanetshare"; DeleteEvent += delegate (object o, DeleteEventArgs args) { Controller.WindowClosed (); args.RetVal = true; }; KeyPressEvent += delegate (object o, KeyPressEventArgs args) { if (args.Event.Key == Gdk.Key.Escape || (args.Event.State == Gdk.ModifierType.ControlMask && args.Event.Key == Gdk.Key.w)) { Controller.WindowClosed (); } }; this.size_label = new Label () { Markup = "<b>Size:</b> …", Xalign = 0 }; this.history_label = new Label () { Markup = "<b>History:</b> …", Xalign = 0 }; HBox layout_sizes = new HBox (false, 12); layout_sizes.Add (this.size_label); layout_sizes.Add (this.history_label); VBox layout_vertical = new VBox (false, 0); this.spinner = new PryanetSpinner (22); this.content_wrapper = new EventBox (); this.scrolled_window = new ScrolledWindow (); Gdk.Color white = new Gdk.Color(); Gdk.Color.Parse ("white", ref white); this.content_wrapper.ModifyBg (StateType.Normal, white); this.web_view = new WebView () { Editable = false }; this.web_view.NavigationRequested += WebViewNavigationRequested; this.scrolled_window.Add (this.web_view); this.content_wrapper.Add (this.spinner); this.spinner.Start (); this.layout_horizontal = new HBox (true, 0); this.layout_horizontal.PackStart (layout_sizes, true, true, 12); layout_vertical.PackStart (this.layout_horizontal, false, false, 0); layout_vertical.PackStart (this.content_wrapper, true, true, 0); Add (layout_vertical); Controller.HideWindowEvent += delegate { Application.Invoke (delegate { HideAll (); if (this.content_wrapper.Child != null) this.content_wrapper.Remove (this.content_wrapper.Child); }); }; Controller.ShowWindowEvent += delegate { Application.Invoke (delegate { ShowAll (); Present (); }); }; Controller.ShowSaveDialogEvent += delegate (string file_name, string target_folder_path) { Application.Invoke (delegate { FileChooserDialog dialog = new FileChooserDialog ("Restore from History", this, FileChooserAction.Save, "Cancel", ResponseType.Cancel, "Save", ResponseType.Ok); dialog.CurrentName = file_name; dialog.DoOverwriteConfirmation = true; dialog.SetCurrentFolder (target_folder_path); if (dialog.Run () == (int) ResponseType.Ok) Controller.SaveDialogCompleted (dialog.Filename); else Controller.SaveDialogCancelled (); dialog.Destroy (); }); }; Controller.UpdateChooserEvent += delegate (string [] folders) { Application.Invoke (delegate { UpdateChooser (folders); }); }; Controller.UpdateChooserEnablementEvent += delegate (bool enabled) { Application.Invoke (delegate { this.combo_box.Sensitive = enabled; }); }; Controller.UpdateContentEvent += delegate (string html) { Application.Invoke (delegate { UpdateContent (html); }); }; Controller.ContentLoadingEvent += delegate { Application.Invoke (delegate { if (this.content_wrapper.Child != null) this.content_wrapper.Remove (this.content_wrapper.Child); this.content_wrapper.Add (this.spinner); this.spinner.Start (); this.content_wrapper.ShowAll (); }); }; Controller.UpdateSizeInfoEvent += delegate (string size, string history_size) { Application.Invoke (delegate { this.size_label.Markup = "<b>Size:</b> " + size; this.history_label.Markup = "<b>History:</b> " + history_size; this.size_label.ShowAll (); this.history_label.ShowAll (); }); }; }