Exemplo n.º 1
0
        public TextEditorControl()
        {
            if (null != textEditorControl)
                throw new InvalidOperationException("'TextEditorControl' should be a singleton!");

            textEditorControl = this;
            InitializeComponent();
            InitializeEditor();
        }
Exemplo n.º 2
0
        internal void Initialize(TextEditorControl textEditorControl)
        {
            this.mainEditorGrid = textEditorControl.FindName("grid") as Grid;
            this.mainSplitter   = textEditorControl.FindName("MainGridSplitter") as GridSplitter;

            // If you get this assertion, then the "grid" element in XAML has
            // been modified. Which means the following codes that expect a
            // particular grid layout, need changing too. Look for all parts
            // in this file with GRIDLAYOUTSPECIFIC tag and update their logic!
            //
            System.Diagnostics.Debug.Assert(mainEditorGrid.RowDefinitions.Count == 7);
            System.Diagnostics.Debug.Assert(mainEditorGrid.RowDefinitions[3].Height.IsStar);
            mainEditorGrid.RowDefinitions[5].Height = new GridLength(0.0);
            mainSplitter.Visibility = Visibility.Collapsed;
        }
        /// <summary>
        /// Event trigger when a keyboard button is pressed in the watch window
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e">
        /// Keys accepted:
        /// Delete - to delete an item in the watch window
        /// Enter - to bring up the editing textbox for watch variables
        /// </param>
        private void OnWatchWindowKeyDown(object sender, KeyEventArgs e)
        {
            // Method to delete items from the watch window
            if (e.Key == Key.Delete)
            {
                InspectionData     selectedData = inspectionView.SelectedItem as InspectionData;
                InspectionViewItem parent       = ContainerFromItem(null, selectedData);
                if (null != parent && parent.Level == 0)
                {
                    // Get the sibling item so that we can move selection on it later.
                    InspectionData siblingData = GetSiblingItemFromData(selectedData);

                    InspectionData removedItem = (InspectionData)inspectionView.SelectedItem;
                    if (dataCollection.RemoveInspectionData(inspectionView.SelectedItem))
                    {
                        Solution.Current.RemoveWatchExpressions(removedItem.DisplayText);
                        inspectionView.Items.Refresh();
                    }

                    // Set focus back to the item.
                    InspectionViewItem siblingItem = ContainerFromItem(null, siblingData);
                    if (null != siblingItem)
                    {
                        siblingItem.IsSelected = true;
                    }
                }
            }
            // Method to allow user to bring up the editing textbox in the
            // watch window. This makes usage of watch window easy
            else if (e.Key == Key.Enter)
            {
                ShowVariableEditBox(null);
            }
            else if (e.Key >= Key.A && (e.Key <= Key.Z))
            {
                char character = TextEditorControl.GetKeyboardCharacter(e);
                ShowVariableEditBox(new string(character, 1));
            }
        }
Exemplo n.º 4
0
        internal void Initialize(TextEditorControl textEditorControl)
        {
            this.mainEditorGrid = textEditorControl.FindName("grid") as Grid;
            this.mainSplitter = textEditorControl.FindName("MainGridSplitter") as GridSplitter;

            // If you get this assertion, then the "grid" element in XAML has
            // been modified. Which means the following codes that expect a
            // particular grid layout, need changing too. Look for all parts
            // in this file with GRIDLAYOUTSPECIFIC tag and update their logic!
            //
            System.Diagnostics.Debug.Assert(mainEditorGrid.RowDefinitions.Count == 7);
            System.Diagnostics.Debug.Assert(mainEditorGrid.RowDefinitions[3].Height.IsStar);
            mainEditorGrid.RowDefinitions[5].Height = new GridLength(0.0);
            mainSplitter.Visibility = Visibility.Collapsed;
        }
Exemplo n.º 5
0
 /// <summary>
 /// As an extension, information of the core and the control needs to be present in all extensions, therefore
 /// it is a protected base class member
 /// </summary>
 /// <param name="editor"> TextEditorControl object </param>
 /// <param name="core"> TextCore Singleton object </param>
 public void SetEditorCore(TextEditorControl editor, ITextEditorCore core)
 {
     textEditorControl = editor;
     textCore = core;
     textEditorCanvas = textEditorControl.FindName("textCanvas") as TextEditorCanvas;
     scrollViewer = textEditorControl.FindName("scrollViewer") as ScrollViewer;
 }
Exemplo n.º 6
0
        public TextEditorControl(IHostApplication hostApplication)
        {
            Stopwatch launchWatch = new Stopwatch();
            launchWatch.Start();

            if (null != TextEditorControl.hostApplication)
                throw new InvalidOperationException("'TextEditorControl' should be a singleton!");
            if (null != textEditorControl)
                throw new InvalidOperationException("'TextEditorControl' should be a singleton!");

            textEditorControl = this;
            TextEditorControl.hostApplication = hostApplication;

            TextEditorControl.dialogProvider = new DialogProvider();
            CoreInterfaceFactory.RegisterInterfaces(hostApplication, dialogProvider);
            textCore = CoreInterfaceFactory.CreateTextEditorCore(OnExecutionStateChanged);

            actionRecorder = new CommandRecorder();
            textCore.SetCommandRecorder(actionRecorder); // Only for human users.

            InitializeComponent();
            InitializeEditor();
            startUpWorker = new StartUpWorker();
            startUpWorker.InitializeStartUpWorker();
            startUpWorker.RunWorkerCompleted += new RunWorkerCompletedEventHandler(OnStartUpWorkerRunWorkerCompleted);
            startUpWorker.RunWorkerAsync();
            EnumerateExtensions();

            this.LayoutUpdated += new EventHandler(OnTextEditorLayoutUpdated);
            launchWatch.Stop();
            Logger.LogPerf("TextEditorControl.ctor", launchWatch.ElapsedMilliseconds + " ms");
        }
Exemplo n.º 7
0
 private void OnMainWindowLoaded(object sender, RoutedEventArgs e)
 {
     hostApplication = new HostApplication(App.arguments);
     textEditorControl = new TextEditorControl(hostApplication);
     EditorGrid.Children.Add(textEditorControl);
 }