public void Completed(bool cancelled) { try { ActivityBar.Stop(); } catch (Exception ex) { ErrorManagement.Log(ex); } }
public void InitializeComponent() { if (_contentLoaded) { return; } _contentLoaded = true; this.Loaded += Window_Loaded; this.Closing += Window_Closing; this.Closed += Window_Closed; host = new System.Windows.Forms.Integration.WindowsFormsHost(); host.SnapsToDevicePixels = true; // Create the WebBrowser control. renderer = new System.Windows.Forms.WebBrowser(); _navigateHandler = new System.Windows.Forms.WebBrowserNavigatingEventHandler(renderer_Navigating); renderer.Navigating += _navigateHandler; // setup the default html page SetupDefaultPage(); // Assign the WebBrowser control as the host control's child. host.Child = renderer; #region Window Layout Grid baseGrid = new Grid(); baseGrid.Margin = new Thickness(0, 0, 0, 0); // activiy bar var activityBarRow = new RowDefinition(); activityBarRow.Height = GridLength.Auto; baseGrid.RowDefinitions.Add(activityBarRow); activityBar = new ActivityBar(); activityBar.Foreground = Brushes.White; activityBar.Visibility = Visibility.Collapsed; Grid.SetRow(activityBar, 0); // Add the interop host control to the Grid // control's collection of child controls. var rendererRow = new RowDefinition(); baseGrid.RowDefinitions.Add(rendererRow); Grid.SetRow(host, 1); // standard input bar var stdinRow = new RowDefinition(); stdinRow.Height = GridLength.Auto; baseGrid.RowDefinitions.Add(stdinRow); stdinBar = new InputBar(); stdinBar.Visibility = Visibility.Collapsed; Grid.SetRow(stdinBar, 2); // set activity bar and host baseGrid.Children.Add(activityBar); baseGrid.Children.Add(host); baseGrid.Children.Add(stdinBar); this.Content = baseGrid; #endregion #region Titlebar Buttons // resize buttons var expandToggleButton = new Button() { ToolTip = "Expand/Shrink Window", Focusable = false }; expandToggleButton.Width = 32; expandToggleButton.Content = GetExpandToggleIcon(IsExpanded); expandToggleButton.Click += ExpandToggleButton_Click;; LeftWindowCommands.Items.Insert(0, expandToggleButton); // TODO: add report button, get email from envvars var pinButton = new Button() { ToolTip = "Keep On Top", Focusable = false }; pinButton.Width = 32; pinButton.Content = GetPinIcon(Topmost); pinButton.Click += PinButton_Click; RightWindowCommands.Items.Insert(0, pinButton); var copyButton = new Button() { ToolTip = "Copy All Text", Focusable = false }; copyButton.Width = 32; copyButton.Content = MakeButtonPath("M19,21H8V7H19M19,5H8A2,2 0 0,0 6,7V21A2,2 0 0,0 8,23H19A2,2 0 0,0 21,21V7A2,2 0 0,0 19,5M16,1H4A2,2 0 0,0 2,3V17H4V3H16V1Z"); copyButton.Click += CopyButton_Click; RightWindowCommands.Items.Insert(0, copyButton); var saveButton = new Button() { ToolTip = "Save Contents", Focusable = false }; saveButton.Width = 32; saveButton.Content = MakeButtonPath("M15,9H5V5H15M12,19A3,3 0 0,1 9,16A3,3 0 0,1 12,13A3,3 0 0,1 15,16A3,3 0 0,1 12,19M17,3H5C3.89,3 3,3.9 3,5V19A2,2 0 0,0 5,21H19A2,2 0 0,0 21,19V7L17,3Z"); saveButton.Click += Save_Contents_Button_Clicked; RightWindowCommands.Items.Insert(0, saveButton); var printButton = new Button() { ToolTip = "Print Contents", Focusable = false }; printButton.Width = 32; printButton.Content = MakeButtonPath("M18,3H6V7H18M19,12A1,1 0 0,1 18,11A1,1 0 0,1 19,10A1,1 0 0,1 20,11A1,1 0 0,1 19,12M16,19H8V14H16M19,8H5A3,3 0 0,0 2,11V17H6V21H18V17H22V11A3,3 0 0,0 19,8Z"); printButton.Click += PrintButton_Click;; RightWindowCommands.Items.Insert(0, printButton); var openButton = new Button() { ToolTip = "Open in Browser", Focusable = false }; openButton.Width = 32; openButton.Content = MakeButtonPath("M14,3V5H17.59L7.76,14.83L9.17,16.24L19,6.41V10H21V3M19,19H5V5H12V3H5C3.89,3 3,3.89 3,5V19A2,2 0 0,0 5,21H19A2,2 0 0,0 21,19V12H19V19Z"); openButton.Click += OpenButton_Click; RightWindowCommands.Items.Insert(0, openButton); #endregion this.Width = 900; this.MinWidth = 700; this.Height = 600; this.MinHeight = this.TitlebarHeight; this.ResizeMode = ResizeMode.CanResize; // setup auto-collapse this.Activated += ScriptOutput_GotFocus; this.Deactivated += ScriptOutput_LostFocus; this.OutputTitle = PyRevitLabsConsts.ProductName; }
protected internal F_Message(string message, string title, int amountProgressBars, bool cancelButton) { mController = new Controller(this); Label = new Label { Top = PADDING_TOP, Left = PADDING_LEFT, Text = message, AutoSize = true, Name = "Label" }; Controls.Add(Label); int Top = Label.Top + Label.Height; ProgressBars = new List <ProgressBar>(); for (int index = 0; index < amountProgressBars; index += 1) { ProgressBar pb = new ProgressBar { Top = Top + PADDING_MIDDLE, Left = PADDING_LEFT, Width = Label.Width, Value = 0, Minimum = 0, Maximum = 100 }; Top += pb.Height; Controls.Add(pb); ProgressBars.Add(pb); } ActivityBar = new ActivityBar(20) { Top = Top + PADDING_MIDDLE, Left = PADDING_LEFT, Width = Label.Width }; Top += ActivityBar.Height; Controls.Add(ActivityBar); if (cancelButton) { CancelBtn = new Button { Text = "&Cancel", Top = Top + PADDING_MIDDLE }; Top += CancelBtn.Height; CancelBtn.Click += CmdCancel_Click; Controls.Add(CancelBtn); CancelButton = CancelBtn; } ClientSize = new Size(PADDING_LEFT + Label.Width + PADDING_RIGHT, Top + PADDING_BOTTOM); if (cancelButton) { CancelBtn.Left = ClientSize.Width - CancelBtn.Width - PADDING_RIGHT; } FormBorderStyle = FormBorderStyle.FixedDialog; MinimizeBox = false; MaximizeBox = false; StartPosition = FormStartPosition.CenterScreen; ShowInTaskbar = false; ShowIcon = true; Icon = Icon.ExtractAssociatedIcon(Assembly.GetExecutingAssembly().Location); Text = title; // Events handling Activated += new EventHandler(F_Message_Activated); GotFocus += new EventHandler(F_Message_GotFocus); Shown += new EventHandler(F_Message_Shown); }
public void Failed(Exception e) { ActivityBar.Stop(); MessageBox.Show(e.ToString()); }
public void Start(IController controller) { ActivityBar.Start(); }