public void SetUpSteps() { AddStep("Restart editor", () => Editor.Restart()); AddStep("Load a command", () => { InputBar = Editor.CommandPanel.AddInputBar; InputBar.CommandToValues(new ApproachesDistanceCommand()); }); }
protected override void Run() { if (RunButton.Disabled || string.IsNullOrWhiteSpace(InputBar.Text)) { return; } RunButton.Disabled = true; var msg = _client._netManager.CreateNetMessage <MsgScriptEval>(); msg.ScriptSession = _session; msg.Code = _lastEnteredText = InputBar.Text; _client._netManager.ClientSendMessage(msg); InputBar.Clear(); }
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 override void Opened() { InputBar.GrabKeyboardFocus(); }
protected override async void Run() { var code = InputBar.Text; InputBar.Clear(); // Remove > or . at the end of the output panel. OutputPanel.RemoveEntry(^ 1); _inputBuffer.AppendLine(code); _linesEntered += 1; var tree = SyntaxFactory.ParseSyntaxTree(SourceText.From(_inputBuffer.ToString()), ScriptInstanceShared.ParseOptions); if (!SyntaxFactory.IsCompleteSubmission(tree)) { if (_linesEntered == 1) { OutputPanel.AddText($"> {code}"); } else { OutputPanel.AddText($". {code}"); } OutputPanel.AddText("."); return; } code = _inputBuffer.ToString().Trim(); // Remove echo of partial submission from the output panel. for (var i = 1; i < _linesEntered; i++) { OutputPanel.RemoveEntry(^ 1); } _inputBuffer.Clear(); _linesEntered = 0; Script newScript; if (_state != null) { newScript = _state.Script.ContinueWith(code); } else { var options = ScriptInstanceShared.GetScriptOptions(_reflectionManager); newScript = CSharpScript.Create(code, options, typeof(ScriptGlobals)); } // Compile ahead of time so that we can do syntax highlighting correctly for the echo. newScript.Compile(); // Echo entered script. var echoMessage = new FormattedMessage(); echoMessage.PushColor(Color.FromHex("#D4D4D4")); echoMessage.AddText("> "); ScriptInstanceShared.AddWithSyntaxHighlighting(newScript, echoMessage, code, _highlightWorkspace); OutputPanel.AddMessage(echoMessage); try { if (_state != null) { _state = await newScript.RunFromAsync(_state, _ => true); } else { _state = await newScript.RunAsync(_globals, _ => true); } } catch (CompilationErrorException e) { var msg = new FormattedMessage(); msg.PushColor(Color.Crimson); foreach (var diagnostic in e.Diagnostics) { msg.AddText(diagnostic.ToString()); msg.AddText("\n"); } OutputPanel.AddMessage(msg); OutputPanel.AddText(">"); return; } if (_state.Exception != null) { var msg = new FormattedMessage(); msg.PushColor(Color.Crimson); msg.AddText(CSharpObjectFormatter.Instance.FormatException(_state.Exception)); OutputPanel.AddMessage(msg); } else if (ScriptInstanceShared.HasReturnValue(newScript)) { var msg = new FormattedMessage(); msg.AddText(CSharpObjectFormatter.Instance.FormatObject(_state.ReturnValue)); OutputPanel.AddMessage(msg); } OutputPanel.AddText(">"); }
internal async Task FocusEntryAsync() { await Task.Delay(1); InputBar.FocusEntry(); }
private void OnListTapped(object sender, ItemTappedEventArgs e) { InputBar.UnFocusEntry(); }