// 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(); }
// 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 RecordHotkey_Pressed() { m_isRecording = !m_isRecording; if (m_isRecording) { ScriptTextBox.Clear(); } else { m_lastEventTime = null; } UpdateWindowTitle(); }
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 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 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 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; } }