private void OpenInNewTab() { var openDialog = CreateOpenLSLDialog(); var showDialog = openDialog.ShowDialog(); if (showDialog == null || !showDialog.Value) { return; } var alreadyOpen = EditorTabs.FirstOrDefault(x => x.FilePath == openDialog.FileName); if (alreadyOpen != null) { TabControl.SelectedIndex = EditorTabs.IndexOf(alreadyOpen); return; } var tab = CreateEditorTab(); if (!tab.OpenFileInteractive(openDialog.FileName)) { return; } EditorTabs.Add(tab); TabControl.SelectedIndex = EditorTabs.Count - 1; }
public MainForm(MainCtrl mainCtrl) { this.mainCtrl = mainCtrl; Ribbon = new RibbonLib.Ribbon { ResourceName = "MindMate.Win7.View.Ribbon.RibbonMarkup.ribbon" }; InitializeComponent(); this.Controls.Add(Ribbon); SetupSideBar(); // moving splitter makes it the focused control, below event focuses the last control again splitContainer1.GotFocus += SplitContainer1_GotFocus; // changing side bar tab gives focus away to tab control header, below event focuses relevant control again SideBarTabs.SelectedIndexChanged += SideBarTabs_SelectedIndexChanged; EditorTabs = new EditorTabs(); splitContainer1.Panel1.Controls.Add(EditorTabs); Shown += MainForm_Shown; #if (Win7) //this is required for Windows 7 & 8, otherwise sidebar is not laid out properly Load += (sender, args) => Ribbon.Minimized = true; Shown += (sender, args) => Ribbon.Minimized = false; #endif }
public MainForm(MainCtrl mainCtrl) { this.mainCtrl = mainCtrl; Ribbon = new RibbonLib.Ribbon {ResourceName = "MindMate.Win7.View.Ribbon.RibbonMarkup.ribbon"}; InitializeComponent(); this.Controls.Add(Ribbon); SetupSideBar(); // moving splitter makes it the focused control, below event focuses the last control again splitContainer1.GotFocus += SplitContainer1_GotFocus; // changing side bar tab gives focus away to tab control header, below event focuses relevant control again SideBarTabs.SelectedIndexChanged += SideBarTabs_SelectedIndexChanged; EditorTabs = new EditorTabs(); splitContainer1.Panel1.Controls.Add(EditorTabs); Shown += MainForm_Shown; #if (Win7) //this is required for Windows 7 & 8, otherwise sidebar is not laid out properly Load += (sender, args) => Ribbon.Minimized = true; Shown += (sender, args) => Ribbon.Minimized = false; #endif }
private void TabbedMainWindow_OnClosing(object sender, CancelEventArgs e) { var tabs = EditorTabs.ToList(); int i = -1; foreach (EditorTab tab in tabs) { i++; if (!tab.ChangesPending) { continue; } TabControl.SelectedIndex = i; if (tab.Close()) { // a tab will be removed when it closes i--; continue; } e.Cancel = true; break; } }
private void FocusLastControl() { if (FocusedControl != null) { FocusedControl.Focus(); } else { EditorTabs.Focus(); } }
public void OpenTab_NonMapView() { MetaModel.MetaModel.Initialize(); var sut = new EditorTabs(); Form f = CreateForm(); f.Controls.Add(sut); f.Show(); TabPage tab = sut.OpenTab(new Control(), "Hello"); Assert.IsNotNull(tab); }
public void OpenTab_MapView() { MetaModel.MetaModel.Initialize(); var sut = new EditorTabs(); Form f = CreateForm(); f.Controls.Add(sut); f.Show(); PersistenceManager pManager = new PersistenceManager(); Tab tab = sut.OpenTab(pManager.NewTree()); Assert.IsNotNull(tab.MapView); }
public void FindTab() { MetaModel.MetaModel.Initialize(); var sut = new EditorTabs(); Form f = CreateForm(); f.Controls.Add(sut); f.Show(); PersistenceManager pManager = new PersistenceManager(); PersistentTree tree = pManager.NewTree(); Tab tab = sut.OpenTab(tree); Assert.IsNotNull(sut.FindTab(tree)); }
public MainForm() { InitializeComponent(); toolStrip1.MainMenu = MainMenu; SetupSideBar(); // moving splitter makes it the focused control, below event focuses the last control again splitContainer1.GotFocus += SplitContainer1_GotFocus; EditorTabs = new EditorTabs(); splitContainer1.Panel1.Controls.Add(EditorTabs); Shown += MainForm_Shown; }
public void Focus() { MetaModel.MetaModel.Initialize(); var sut = new EditorTabs(); Form f = CreateForm(); f.Controls.Add(sut); f.Show(); PersistenceManager pManager = new PersistenceManager(); Tab tab = sut.OpenTab(pManager.NewTree()); sut.Focus(); Assert.IsTrue(tab.Control.Focused); }
public void UpdateAppTitle() { MetaModel.MetaModel.Initialize(); var sut = new EditorTabs(); Form f = CreateForm(); f.Controls.Add(sut); f.Show(); PersistenceManager pManager = new PersistenceManager(); PersistentTree tree = pManager.NewTree(); tree.RootNode.Text = "UpdateTitle"; Tab tab = sut.OpenTab(tree); Assert.IsTrue(f.Text.Contains("UpdateTitle")); }
public MainForm() { InitializeComponent(); toolStrip1.MainMenu = MainMenu; SetupSideBar(); // moving splitter makes it the focused control, below event focuses the last control again splitContainer1.GotFocus += SplitContainer1_GotFocus; // changing side bar tab gives focus away to tab control header, below event focuses relevant control again SideBarTabs.SelectedIndexChanged += SideBarTabs_SelectedIndexChanged; EditorTabs = new EditorTabs(); splitContainer1.Panel1.Controls.Add(EditorTabs); Shown += MainForm_Shown; }
public void ControlGotFocus() { MetaModel.MetaModel.Initialize(); var sut = new EditorTabs(); Form f = CreateForm(); f.Controls.Add(sut); int gotFocus = 0; sut.ControlGotFocus += (a, b) => gotFocus++; f.Show(); PersistenceManager pManager = new PersistenceManager(); PersistentTree tree = pManager.NewTree(); Tab tab = sut.OpenTab(tree); sut.Focus(); Assert.AreEqual(1, gotFocus); }
private void TabOnDrop(object sender, DragEventArgs e) { var textBlock = e.Source as TextBlock; if (textBlock == null) { return; } var stackPanel = textBlock.Parent as StackPanel; if (stackPanel == null) { return; } var contentPresenter = stackPanel.TemplatedParent as ContentPresenter; if (contentPresenter == null) { return; } var tabItemTarget = contentPresenter.Content as EditorTab; if (tabItemTarget == null) { return; } var tabItemSourceContentPresenter = e.Data.GetData(typeof(ContentPresenter)) as ContentPresenter; if (tabItemSourceContentPresenter == null) { return; } var tabItemSource = tabItemSourceContentPresenter.Content as EditorTab; if (tabItemSource == null) { return; } if (tabItemTarget.Equals(tabItemSource)) { return; } _droppingTabAfterDragging = true; var sourceIndex = EditorTabs.IndexOf(tabItemSource); var targetIndex = EditorTabs.IndexOf(tabItemTarget); EditorTabs.Remove(tabItemSource); EditorTabs.Insert(targetIndex, tabItemSource); EditorTabs.Remove(tabItemTarget); EditorTabs.Insert(sourceIndex, tabItemTarget); TabControl.SelectedIndex = targetIndex; _droppingTabAfterDragging = false; }
private NamedPipeServerStream CreateOpenTabPipeServer(string pipeName) { var ps = new PipeSecurity(); ps.AddAccessRule(new PipeAccessRule("Users", PipeAccessRights.ReadWrite | PipeAccessRights.CreateNewInstance, AccessControlType.Allow)); ps.AddAccessRule(new PipeAccessRule("SYSTEM", PipeAccessRights.FullControl, AccessControlType.Allow)); var pipeClientConnection = new NamedPipeServerStream(pipeName, PipeDirection.In, 5, PipeTransmissionMode.Byte, PipeOptions.Asynchronous, 1024, 1024, ps); pipeClientConnection.BeginWaitForConnection(asyncResult => { using (var conn = (NamedPipeServerStream)asyncResult.AsyncState) { conn.EndWaitForConnection(asyncResult); var newServer = CreateOpenTabPipeServer(pipeName); var streamReader = new StreamReader(conn); while (true) { string file = streamReader.ReadLine(); if (file == ":KILL:") { if (pipeClientConnection.IsConnected) { pipeClientConnection.Disconnect(); } pipeClientConnection.Close(); pipeClientConnection.Dispose(); if (newServer.IsConnected) { newServer.Disconnect(); } newServer.Close(); newServer.Dispose(); Dispatcher.Invoke(Close); } if (file == ":EOF:") { break; } Dispatcher.Invoke(() => { var alreadyOpen = EditorTabs.FirstOrDefault(x => x.FilePath == file); if (alreadyOpen != null) { TabControl.SelectedIndex = EditorTabs.IndexOf(alreadyOpen); return; } var tab = CreateEditorTab(); if (!tab.OpenFileInteractive(file)) { return; } EditorTabs.Add(tab); TabControl.SelectedIndex = EditorTabs.Count - 1; }); } } }, pipeClientConnection); return(pipeClientConnection); }
public void EditorTabs() { var sut = new EditorTabs(); }
public void FocusMapView() { EditorTabs.Focus(); }
private void Initialize(bool newInstance, string[] args) { ShowEndOfLine = AppSettings.Settings.ShowEndOfLine; ShowSpaces = AppSettings.Settings.ShowSpaces; ShowTabs = AppSettings.Settings.ShowTabs; var entryAssembly = Assembly.GetEntryAssembly(); Title = "LSLCCEditor v" + entryAssembly.GetName().Version; var assembly = entryAssembly.Location; var appDirectory = Path.GetDirectoryName(assembly); _libraryDataProvider = new LSLXmlLibraryDataProvider(new[] { "lsl" }); try { _libraryDataProvider.FillFromXmlDirectory(Path.Combine(appDirectory, "library_data")); } catch (LSLLibraryDataXmlSyntaxException err) { MessageBox.Show(this, "There is a syntax error in one of your XML library data files and the application must close." + LSLFormatTools.CreateNewLinesString(2) + err.Message, "Library Data Syntax Error", MessageBoxButton.OK, MessageBoxImage.Error); Application.Current.Shutdown(); } _codeValidatorStrategies = new LSLCodeValidatorStrategies { ExpressionValidator = new LSLDefaultExpressionValidator(), StringLiteralPreProcessor = new LSLDefaultStringPreProcessor(), SyntaxErrorListener = new WindowSyntaxErrorListener(this), SyntaxWarningListener = new WindowSyntaxWarningListener(this), LibraryDataProvider = _libraryDataProvider }; foreach (var dataMenuItem in _libraryDataProvider.SubsetDescriptions.Select(subset => new MenuItem { StaysOpenOnClick = true, IsCheckable = true, Header = subset.Value.FriendlyName, Tag = subset.Value.Subset, ToolTip = new ToolTip { Content = new TextBlock { Text = subset.Value.Description } } })) { dataMenuItem.Checked += DataMenuItemOnChecked; dataMenuItem.Unchecked += DataMenuItemOnUnChecked; TabLibraryDataMenu.Items.Add(dataMenuItem); } FindDialogManager = new FindReplaceMgr { OwnerWindow = this, InterfaceConverter = new IEditorConverter(), ShowSearchIn = false }; if (args.Length > 0) { foreach (string arg in args) { var tab = CreateEditorTab(); if (tab.OpenFileInteractive(arg)) { EditorTabs.Add(tab); } } } else { EditorTabs.Add(CreateEditorTab()); } if (!newInstance) { StartOpenTabPipeServer(); } _selectingStartupTabDuringWindowLoad = true; TabControl.SelectedIndex = 0; var initialTab = (EditorTab)TabControl.SelectedItem; initialTab.IsSelected = true; SetLibraryMenuFromTab(initialTab); FindDialogManager.CurrentEditor = initialTab.Content.EditControl.Editor; initialTab.Content.EditControl.Editor.TextChanged += Editor_OnTextChanged; EditRedoMenuItem.IsEnabled = initialTab.Content.EditControl.Editor.CanRedo; EditUndoMenuItem.IsEnabled = initialTab.Content.EditControl.Editor.CanUndo; _selectingStartupTabDuringWindowLoad = false; }
private void NewFile_OnClick(object sender, RoutedEventArgs e) { EditorTabs.Add(CreateEditorTab()); TabControl.SelectedIndex = (EditorTabs.Count - 1); }
public MainWindow(string cmd) { Instance = this; base.Topmost = Settings.Instance.TopMost; InitializeComponent(); base.ResizeMode = ResizeMode.NoResize; tabEditWindow = new TabEditWindow(EditorTabs); scriptsContextMenu = new ScriptsContextMenu(this); EditorTabs.Loaded += delegate { EditorTabs.GetTemplateChild <Button>("AddTabButton").Click += delegate { MakeTab("", "New Tab"); }; tabScroller = EditorTabs.GetTemplateChild <ScrollViewer>("TabScrollViewer"); }; OutputTab.Loaded += delegate { OutputTab.GetTemplateChild <Button>("CloseButton").Visibility = Visibility.Collapsed; }; OutputTab.MouseWheel += ScrollTabs; OutputTab.Tag = true; MakeTab("", "New Tab"); base.Closing += delegate { CloseWindows(); }; watcher = new FileSystemWatcher("scripts\\"); watcher.Created += delegate { base.Dispatcher.Invoke(ReloadScripts); }; watcher.Renamed += delegate { base.Dispatcher.Invoke(ReloadScripts); }; watcher.Deleted += delegate { base.Dispatcher.Invoke(ReloadScripts); }; watcher.EnableRaisingEvents = true; ReloadScripts(); int attachedPid = 0; this.Output.TextChanged += delegate(object sender, EventArgs e) { Output.ScrollToEnd(); }; IPC instance = IPC.Instance; instance.Connected += delegate { base.Dispatcher.Invoke(delegate { Output.AppendText("Client has connected.\n"); Bridge.Sentinel.UnlockFPS(Settings.Instance.UnlockFPS); }); }; instance.Disconnected += delegate { base.Dispatcher.Invoke(delegate { attachedPid = 0; Output.AppendText("Client has disconnected.\n"); }); }; instance.Error += delegate { base.Dispatcher.Invoke(delegate { }); }; DispatcherTimer dispatcherTimer = new DispatcherTimer(); dispatcherTimer.Interval = TimeSpan.FromMilliseconds(500.0); dispatcherTimer.Tick += delegate { if (Body2.Visibility != Visibility.Hidden && Settings.Instance.AutoAttach) { Process[] processesByName = Process.GetProcessesByName("RobloxPlayerBeta"); if (processesByName.Length == 1 && processesByName[0].Id != attachedPid && !(processesByName[0].MainWindowHandle == IntPtr.Zero)) { attachedPid = processesByName[0].Id; Bridge.Injector.Inject(); } } }; dispatcherTimer.Start(); }