示例#1
0
        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;
        }
示例#2
0
        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();

            // 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;

            // Add the interop host control to the Grid
            // control's collection of child controls.
            Grid baseGrid = new Grid();

            if (_debugMode)
            {
                var rendererRow = new RowDefinition();
                var splitterRow = new RowDefinition();
                var replRow     = new RowDefinition();

                splitterRow.Height = new GridLength(6);
                replRow.Height     = new GridLength(100);

                baseGrid.RowDefinitions.Add(rendererRow);
                baseGrid.RowDefinitions.Add(splitterRow);
                baseGrid.RowDefinitions.Add(replRow);

                var splitter = new GridSplitter();
                splitter.ResizeDirection     = GridResizeDirection.Rows;
                splitter.HorizontalAlignment = HorizontalAlignment.Stretch;
                splitter.Background          = Brushes.LightGray;

                var repl = new REPLControl();

                Grid.SetRow(host, 0);
                Grid.SetRow(splitter, 1);
                Grid.SetRow(repl, 2);

                baseGrid.Children.Add(splitter);
                baseGrid.Children.Add(repl);
            }

            baseGrid.Children.Add(host);
            this.Content = baseGrid;

            // taskbar progress object
            var taskbarinfo = new System.Windows.Shell.TaskbarItemInfo();

            taskbarinfo.ProgressState = System.Windows.Shell.TaskbarItemProgressState.Normal;
            this.TaskbarItemInfo      = taskbarinfo;

            // Setup window styles
            this.Background            = Brushes.White;
            this.Width                 = 900;
            this.Height                = 600;
            this.WindowStartupLocation = WindowStartupLocation.Manual;
            this.Title                 = "pyRevit";
        }