//private void OnCut(object sender, RoutedEventArgs e) //{ // var editor = GetCurrentEditor(); // if (editor != null) // editor.Cut(); //} //private void OnCopy(object sender, RoutedEventArgs e) //{ // var editor = GetCurrentEditor(); // if (editor != null) // editor.Copy(); //} //private void OnPaste(object sender, RoutedEventArgs e) //{ // var editor = GetCurrentEditor(); // if (editor != null) // editor.Paste(); //} private int findEditor(Editor.EditorDocument doc) { for (int i = 0; i < mainTabs.Items.Count; i++) if (((TabItem)mainTabs.Items[i]).Content == doc.EditorControl) return i; throw new ArgumentException("Editor document not found in tabs"); }
private void OnEditorNameChanged(object sender, Editor.EditorEventArgs e) { try { if (e.Document.IsModified) ((TabItem)mainTabs.Items[findEditor(e.Document)]).Header = e.Document.FileName + " *"; else ((TabItem)mainTabs.Items[findEditor(e.Document)]).Header = e.Document.FileName; } catch (Exception err) { GUIUtilities.ReportUnexpectedException(err); } }
private void OnEditorActivated(object sender, Editor.EditorEventArgs e) { try { mainTabs.SelectedIndex = findEditor(e.Document); //if (mainTabs.SelectedItem != null && GetCurrentEditor() != null) // FocusManager.SetFocusedElement((TabItem)mainTabs.SelectedItem, GetCurrentEditor()); } catch (Exception err) { GUIUtilities.ReportUnexpectedException(err); } }
private void OnEditorRemoved(object sender, Editor.EditorEventArgs e) { try { mainTabs.Items.RemoveAt(findEditor(e.Document)); } catch (Exception err) { GUIUtilities.ReportUnexpectedException(err); } }
private void OnEditorInserted(object sender, Editor.EditorEventArgs e) { try { var header = new Grid(); header.Children.Add(new Label() { Content = e.Document.FileName }); header.Children.Add(new Button() { Content = new Image() { Source = new BitmapImage(new Uri("cross.png", UriKind.Relative)) } }); var item = new CloseableTabItemDemo.CloseableTabItem() { Header = e.Document.FileName, Content = e.Document.EditorControl }; item.GotFocus += delegate(object sender2, RoutedEventArgs e2) { e.Document.EditorControl.Focus(); }; item.CloseTab += delegate(object sender2, RoutedEventArgs e2) { editor.RequestClose(e.Document); }; mainTabs.Items.Add(item); mainTabs.SelectedIndex = mainTabs.Items.Count - 1; } catch (Exception err) { GUIUtilities.ReportUnexpectedException(err); } }
//private void OnBrowseManifest(object sender, ExecutedRoutedEventArgs e) //{ // var dlg = new OpenFileDialog(); // if (curManifest != null && curManifest.Length > 0) // dlg.FileName = curManifest; // dlg.DefaultExt = ".manifest.xml"; // dlg.Filter = "DSS Manifest (.manifest.xml)|*.manifest.xml"; // if (dlg.ShowDialog(this) == true) // { // lock (connectionThreadLock) // { // curManifest = dlg.FileName; // if (connectionThread == null || connectionThread.IsAlive == false) // { // connectionThread = new Thread(new ThreadStart(delegate() { connect(); })); // connectionThread.Start(); // } // } // } //} //private void ToggleConnect(object sender, RoutedEventArgs e) //{ // if (curManifest == null || curManifest.Length <= 0) // BrowseManifest(sender, e); // lock (connectionThreadLock) // { // if (connectionThread == null || connectionThread.IsAlive == false) // { // connectionThread = new Thread(new ThreadStart(delegate() { connect(); })); // connectionThread.Start(); // } // } //} private void OnInitialized(object sender, EventArgs e) { try { Robot.RobotStateChangeEvent += OnRobotStateChange; commandWindow.StartScripting(); commandWindow.PythonExecuting += delegate(object source, EventArgs e2) { Dispatcher.Invoke(System.Windows.Threading.DispatcherPriority.Normal, new ThreadStart(delegate() { topBar.IsRunning = true; })); }; commandWindow.PythonFinished += delegate(object source, EventArgs e2) { Dispatcher.Invoke(System.Windows.Threading.DispatcherPriority.Normal, new ThreadStart(delegate() { topBar.IsRunning = false; })); }; editor = new Editor(this); editor.InsertedEditor += OnEditorInserted; editor.RemovedEditor += OnEditorRemoved; editor.ActivatedEditor += OnEditorActivated; editor.ModifiedChanged += OnEditorNameChanged; editor.NameChanged += OnEditorNameChanged; //SetButtonsEnabled(); editor.RequestNewDocument(); webcamDisplay.StartUpdate(); simDisplay = new SimulatorDisplay(); simDisplay.SimulatorFound += OnFoundSimulator; simDisplay.Start(); } catch (Exception err) { GUIUtilities.ReportUnexpectedException(err); } }