private void ScriptTextBox_SelectionChanged(object sender, EventArgs e) { int selectionStart = ScriptTextBox.SelectionStart; int index = ScriptTextBox.GetFirstCharIndexOfCurrentLine(); int row = ScriptTextBox.GetLineFromCharIndex(selectionStart) + 1; int column = selectionStart - index + 1; Console.WriteLine(row.ToString() + "," + column.ToString()); }
private void AgregarButton_Click(object sender, EventArgs e) { Comando nuevoComando = (Comando)((Comando)ComandoComboBox.SelectedItem).Clone(); nuevoComando.Valor = ValorTextBox.Text; nuevoComando.Objetivo = ObjetivoTextBox.Text; nuevoComando.Descripcion = DescripcionTextBox.Text; ScriptTextBox.AppendText(nuevoComando.Escribir() + "\n"); }
// Command line execution private async void ExecuteJavaScriptBtn_Click(object sender, RoutedEventArgs e) { if (/*Browser.CanExecuteJavascriptInMainFrame &&*/ !string.IsNullOrWhiteSpace(ScriptTextBox.Text)) { JavascriptResponse response = await Browser.EvaluateScriptAsync(ScriptTextBox.Text); } // TODO - view history and active geometry ScriptTextBox.Clear(); }
//删除脚本 private void DelToolStripMenuItem_Click(object sender, EventArgs e) { if (ClickNode.Tag.ToString() == SelectScript) { ScriptTextBox.Clear(); SelectScript = ""; toolStatusScriptLabel.Text = string.Empty; } File.Delete(ClickNode.Tag.ToString()); LoadTreeNodes(); }
public void first_init() { if (m_line_height < 0) { ScriptTextBox.Text = "x\nx"; m_line_height = ScriptTextBox.GetPositionFromCharIndex(2).Y - ScriptTextBox.GetPositionFromCharIndex(0).Y; ScriptTextBox.Text = ""; } update_line_number_pixbox_width(); }
// Enter to execute command line private async void textBoxKeyDown(object sender, KeyEventArgs e) { if (e.Key == Key.Enter) { if (!string.IsNullOrWhiteSpace(ScriptTextBox.Text)) { JavascriptResponse response = await Browser.EvaluateScriptAsync(ScriptTextBox.Text); } ScriptTextBox.Clear(); } }
private void AddVirtualKey(Keys keyCode) { if (string.IsNullOrWhiteSpace(ScriptTextBox.Text)) { ScriptTextBox.AppendText(keyCode.ToString()); } else { ScriptTextBox.AppendText(", "); ScriptTextBox.AppendText(keyCode.ToString()); } }
private void UpdateScript(bool silent) { if (Model.SelectedTable != null) { ScriptTextBox.Text = GenerateScript(silent); ScriptTextBox.SelectAll(); } else { ScriptTextBox.Text = string.Empty; } }
private void ScriptTextBox_KeyDown(object sender, KeyEventArgs e) { if (e.KeyCode == Keys.F5 && e.Control) { RunBtn_Click(null, null); } else if (e.Control && e.KeyCode == Keys.V) { e.SuppressKeyPress = true; ScriptTextBox.Paste(DataFormats.GetFormat(DataFormats.Text)); } }
private void RecordHotkey_Pressed() { m_isRecording = !m_isRecording; if (m_isRecording) { ScriptTextBox.Clear(); } else { m_lastEventTime = null; } UpdateWindowTitle(); }
private void GlobalHookKeyDown(object sender, System.Windows.Forms.KeyEventArgs e) { if (!IsKeyboardFocusWithin) { if (_modified) { ScriptTextBox.GetBindingExpression( TextBox.TextProperty) .UpdateSource(); _modified = false; } ForView.Unwrap <MainViewModel>(DataContext, vm => vm.KeyDown(e)); } }
private void OnChanged(object source, FileSystemEventArgs e) { Console.WriteLine("Watch Text Changed"); //判断当前form是否处于窗口最前位置,即是否获得焦点,如果没有获取焦点,则进行文件的重载 if (!this.Focused) { //重新加载这个文件 ScriptTextBox.Clear(); string temp = DataProcess.ReadScriptFile(SelectScript); ScriptTextBox.Text = temp; OldText = ScriptTextBox.Text; ScriptTextBox.SelectionStart = selectionStart; //Console.WriteLine("1"+SelectScript); //Console.WriteLine("2"+ClickNode.Tag.ToString()); } }
private void Script_textbox_KeyUp(object sender, KeyEventArgs e) { script = ScriptTextBox.Text; int linecount = ScriptTextBox.GetLastVisibleLineIndex() + 1; if (linecount != maxLC) { LineNumberTextBox.Clear(); for (int i = 1; i < linecount + 1; i++) { LineNumberTextBox.AppendText(Convert.ToString(i) + "\n"); } maxLC = linecount; } SaveStatus.Content = "Changed"; }
void update_line_numbers() { if (LineNumberPixBox.Image == null || (LineNumberPixBox.Width != LineNumberPixBox.Image.Width || LineNumberPixBox.Height != LineNumberPixBox.Image.Height)) { if (LineNumberPixBox.Image != null) { LineNumberPixBox.Image.Dispose(); } Bitmap pbox_bmp = new Bitmap(LineNumberPixBox.Width, LineNumberPixBox.Height, PixelFormat.Format32bppPArgb); LineNumberPixBox.Image = pbox_bmp; m_gfx = Graphics.FromImage(pbox_bmp); } m_gfx.Clear(Color.White); if (ScriptTextBox.Lines.Length > 0 && m_line_height > 0) { update_line_number_pixbox_width(); int pix_offset = (ScriptTextBox.GetPositionFromCharIndex(0).Y % m_line_height); m_tmp_pos.X = m_tmp_pos.Y = 0; int first_ind = ScriptTextBox.GetCharIndexFromPosition(m_tmp_pos); int first_line = ScriptTextBox.GetLineFromCharIndex(first_ind); m_tmp_pos.X = ClientRectangle.Width; m_tmp_pos.Y = ClientRectangle.Height; int last_ind = ScriptTextBox.GetCharIndexFromPosition(m_tmp_pos); int last_line = ScriptTextBox.GetLineFromCharIndex(last_ind); int line_offset; int y_step; for (int i = 0; i <= last_line - first_line; i++) { line_offset = first_line + i; y_step = pix_offset + (i * m_line_height); m_gfx.FillRectangle(((line_offset & 0x01) == 0x01) ? m_brush_white:m_brush_gray, 0, y_step, LineNumberScriptFieldSplitContainer.SplitterDistance, m_line_height); m_gfx.DrawString((line_offset + 1).ToString(), ScriptTextBox.Font, m_brush_dark_gray, 0, y_step); } } LineNumberPixBox.Invalidate(); }
private void DropStoredProcedure(string procName, Schema spSchema) { Database db = (Database)DatabasesComboBox.SelectedItem; if (db.StoredProcedures.Contains(procName, spSchema.Name) == true) { ScriptTextBox.AppendText(string.Format( System.Globalization.CultureInfo.InvariantCulture, Properties.Resources.DroppingStoredProcedure, spSchema.ToString(), BracketObjectName(procName)) + Environment.NewLine); ScrollToBottom(); // Drop the existing stored procedure db.StoredProcedures[procName, spSchema.Name].Drop(); } }
private async void ScriptTextBox_KeyDown(object sender, KeyEventArgs e) { switch (e.Key) { case Key.Enter: e.Handled = true; HistoryText.Document.Blocks.Add(new Paragraph(new Run($"> {ScriptTextBox.Text}"))); _scriptsHistory.Add(ScriptTextBox.Text); _historyIndex = _scriptsHistory.Count; await _scriptHandler.ExecuteCode(ScriptTextBox.Text); ScriptTextBox.Text = string.Empty; ScriptTextBox.Focus(); break; case Key.Up: _historyIndex = Math.Max(0, _historyIndex - 1); if (_scriptsHistory.Count > _historyIndex) { ScriptTextBox.Text = _scriptsHistory[_historyIndex]; ScriptTextBox.CaretIndex = ScriptTextBox.Text.Length; } e.Handled = true; break; case Key.Down: _historyIndex = Math.Min(_scriptsHistory.Count, _historyIndex + 1); if (_scriptsHistory.Count > _historyIndex) { ScriptTextBox.Text = _scriptsHistory[_historyIndex]; ScriptTextBox.CaretIndex = ScriptTextBox.Text.Length; } else { ScriptTextBox.Text = string.Empty; } e.Handled = true; break; } }
//打开脚本 private void OpenScript() { if (SaveFile()) { SelectScript = ClickNode.Tag.ToString(); ScriptTextBox.Clear(); string temp = DataProcess.ReadScriptFile(ClickNode.Tag.ToString()); ScriptTextBox.Text = temp; OldText = ScriptTextBox.Text; ScriptNameLabel.Text = ClickNode.Text; } ScriptWatcher.Path = ClickNode.Parent.Tag.ToString(); //设置监听的目录 ScriptWatcher.Filter = "*.txt"; //设置监听的文件 ScriptWatcher.NotifyFilter = NotifyFilters.LastWrite; //监听的动作类型,多种类型用或|连接 ScriptWatcher.Changed += new FileSystemEventHandler(OnChanged); //设置文件更改回调函数 ScriptWatcher.EnableRaisingEvents = true; }
private void Log(string message) { ScriptTextBox.AppendText(message + Environment.NewLine); }
private void CreateSelectProcedure(Schema spSchema, Table tbl) { String procName; StringBuilder sbSQL = new StringBuilder(); StringBuilder sbSelect = new StringBuilder(); StringBuilder sbWhere = new StringBuilder(); StoredProcedure sp; StoredProcedureParameter parm; try { // Create stored procedure name from user entry and table name procName = PrefixTextBox.Text + tbl.Name + @"Select"; if (DropOnlyCheckBox.CheckState == CheckState.Checked) { DropStoredProcedure(procName, spSchema); } else { DropStoredProcedure(procName, spSchema); ScriptTextBox.AppendText(string.Format( System.Globalization.CultureInfo.InvariantCulture, Properties.Resources.CreatingStoredProcedure, spSchema.ToString(), BracketObjectName(procName)) + Environment.NewLine); ScrollToBottom(); // Create the new stored procedure object sp = new StoredProcedure(tbl.Parent, procName, spSchema.Name); sp.TextMode = false; foreach (Column col in tbl.Columns) { // Select columns if (sbSelect.Length > 0) { sbSelect.Append(", " + Environment.NewLine); } // Note: this does not fix object names with embedded brackets sbSelect.Append("\t["); sbSelect.Append(col.Name); sbSelect.Append(@"]"); // Create parameters and where clause from indexed fields if (col.InPrimaryKey == true) { // Parameter columns parm = new StoredProcedureParameter(sp, "@" + col.Name); parm.DataType = col.DataType; parm.DataType.MaximumLength = col.DataType.MaximumLength; sp.Parameters.Add(parm); // Where columns if (sbWhere.Length > 0) { sbWhere.Append(" " + Environment.NewLine + "\tAND "); } // Note: this does not fix object names with embedded brackets sbWhere.Append(@"["); sbWhere.Append(col.Name); sbWhere.Append(@"] = @"); sbWhere.Append(col.Name); } } // Put where clause into string if (sbWhere.Length > 0) { sbWhere.Insert(0, @"WHERE "); } sbrStatus.Text = string.Format(System.Globalization.CultureInfo.InvariantCulture, Properties.Resources.Creating, procName); sbSQL.Append("SELECT "); sbSQL.Append(sbSelect); sbSQL.Append(" " + Environment.NewLine + "FROM "); sbSQL.Append(tbl.ToString()); sbSQL.Append(" " + Environment.NewLine); sbSQL.Append(sbWhere); sp.TextBody = sbSQL.ToString(); sp.Create(); } } catch (SmoException ex) { ExceptionMessageBox emb = new ExceptionMessageBox(ex); emb.Show(this); } finally { // Clean up. sbSQL = null; sbSelect = null; sbWhere = null; sp = null; parm = null; } }
private void ScrollToBottom() { ScriptTextBox.Select(); ScriptTextBox.SelectionStart = ScriptTextBox.Text.Length; ScriptTextBox.ScrollToCaret(); }
private void SetEnbled(bool result) { if (NewBaseTextBox.InvokeRequired) { Enableddelegate en = SetEnbled; NewBaseTextBox.Invoke(en, result); } else { NewBaseTextBox.Enabled = result; } if (projectComboBox.InvokeRequired) { Enableddelegate en = SetEnbled; projectComboBox.Invoke(en, result); } else { projectComboBox.Enabled = result; } if (QuickSwitch.InvokeRequired) { Enableddelegate en = SetEnbled; QuickSwitch.Invoke(en, result); } else { QuickSwitch.Enabled = result; } if (useSwitch.InvokeRequired) { Enableddelegate en = SetEnbled; useSwitch.Invoke(en, result); } else { useSwitch.Enabled = result; } if (restSwitch.InvokeRequired) { Enableddelegate en = SetEnbled; restSwitch.Invoke(en, result); } else { restSwitch.Enabled = result; } if (ScriptTextBox.InvokeRequired) { Enableddelegate en = SetEnbled; ScriptTextBox.Invoke(en, result); } else { ScriptTextBox.Enabled = result; } if (startButton.InvokeRequired) { Enableddelegate en = SetEnbled; startButton.Invoke(en, result); } else { startButton.Enabled = result; } }
private void ExecuteButton_Click(object sender, EventArgs e) { Cursor csr = null; Database db; Schema spSchema; // Timing DateTime start = DateTime.Now; if (System.Windows.Forms.MessageBox.Show(this, Properties.Resources.ReallyCreate, this.Text, MessageBoxButtons.YesNo, MessageBoxIcon.Question, MessageBoxDefaultButton.Button2, 0) == DialogResult.No) { return; } try { csr = this.Cursor; // Save the old cursor this.Cursor = Cursors.WaitCursor; // Display the waiting cursor // Clear control ScriptTextBox.Clear(); db = (Database)DatabasesComboBox.SelectedItem; // Create SmoDemo schema to contain stored procedures if (db.Schemas.Contains("SmoDemo") == false) { spSchema = new Schema(db, "SmoDemo"); spSchema.Create(); } else { spSchema = db.Schemas["SmoDemo"]; } // Limit the table properties returned to just those that we use SqlServerSelection.SetDefaultInitFields(typeof(Table), new String[] { "Name" }); // Limit the column properties returned to just those that we use SqlServerSelection.SetDefaultInitFields(typeof(Column), new String[] { "Name", "DataType", "Length", "InPrimaryKey" }); // Limit the stored procedure properties returned to just those that we use SqlServerSelection.SetDefaultInitFields(typeof(StoredProcedure), new String[] { "Name", "Schema" }); // Create a SELECT stored procedure for each table foreach (Table tbl in db.Tables) { if (db.IsSystemObject == false) { CreateSelectProcedure(spSchema, tbl); } } ScriptTextBox.AppendText(Properties.Resources.Completed); ScrollToBottom(); sbrStatus.Text = Properties.Resources.Ready; } catch (SmoException ex) { ExceptionMessageBox emb = new ExceptionMessageBox(ex); emb.Show(this); } finally { // Clean up. this.Cursor = csr; // Restore the original cursor // Timing TimeSpan diff = DateTime.Now - start; ScriptTextBox.AppendText(String.Format( System.Threading.Thread.CurrentThread.CurrentCulture, Environment.NewLine + Properties.Resources.ElapsedTime, (diff.Minutes * 60) + diff.Seconds, diff.Milliseconds)); } }
private void Window_Loaded(object sender, RoutedEventArgs e) { ScriptTextBox.Focus(); }
private void ScriptTableButton_Click(System.Object sender, System.EventArgs e) { Cursor csr = null; Database db; StringCollection strColl; Scripter scrptr; SqlSmoObject[] smoObjects; Table tbl; Int32 count; try { csr = this.Cursor; // Save the old cursor this.Cursor = Cursors.WaitCursor; // Display the waiting cursor // Use the selected database db = (Database)DatabasesComboBox.SelectedItem; if (db.Name.Length == 0) { ExceptionMessageBox emb = new ExceptionMessageBox(); emb.Text = Properties.Resources.NoDatabaseSelected; emb.Show(this); return; } // Create scripter object scrptr = new Scripter(SqlServerSelection); if (ScriptDropCheckBox.CheckState == CheckState.Checked) { scrptr.Options.ScriptDrops = true; } else { scrptr.Options.ScriptDrops = false; } scrptr.DiscoveryProgress += new ProgressReportEventHandler( this.ScriptTable_DiscoveryProgressReport); scrptr.ScriptingProgress += new ProgressReportEventHandler( this.ScriptTable_ScriptingProgressReport); if (TablesComboBox.SelectedIndex >= 0) { // Get selected table smoObjects = new SqlSmoObject[1]; tbl = (Table)TablesComboBox.SelectedItem; if (tbl.IsSystemObject == false) { smoObjects[0] = tbl; } if (DependenciesCheckBox.CheckState == CheckState.Checked) { scrptr.Options.WithDependencies = true; } else { scrptr.Options.WithDependencies = false; } strColl = scrptr.Script(smoObjects); // Clear control ScriptTextBox.Clear(); count = 0; foreach (String str in strColl) { count++; sbrStatus.Text = string.Format( System.Globalization.CultureInfo.InvariantCulture, Properties.Resources.AppendingScript, count, strColl.Count); ScriptTextBox.AppendText(str); ScriptTextBox.AppendText(Properties.Resources.Go); } } else { ExceptionMessageBox emb = new ExceptionMessageBox(); emb.Text = Properties.Resources.ChooseTable; emb.Show(this); } } catch (SmoException ex) { ExceptionMessageBox emb = new ExceptionMessageBox(ex); emb.Show(this); } finally { // Clean up sbrStatus.Text = Properties.Resources.Done; // Restore the original cursor this.Cursor = csr; } }