Exemple #1
0
        /// <summary>
        /// Create a tab page for passed tabFile.
        /// </summary>
        /// <param name="tabFile"></param>
        private void CreateTab(TabFile tabFile)
        {
            Log.Information("Creating tab for tabFile: " + tabFile);

            var tabPage = new TabPage(tabFile.TabName)
            {
                Width = 100
            };

            var textBox = new MainTextBox {
                Name = "TextBox"
            };

            var host = new ElementHost
            {
                Name  = "Host",
                Dock  = DockStyle.Fill,
                Child = textBox
            };

            tabPage.ToolTipText = tabFile.File;
            tabPage.Name        = tabFile.Name;

            textBox.PreviewKeyDown    += MainTextBox1_PreviewKeyDown;
            textBox.PreviewKeyUp      += MainTextBox1_PreviewKeyUp;
            textBox.PreviewMouseWheel += MainTextBox1_MouseWheel;
            textBox.AllowDrop          = true;
            textBox.Drop      += MainTextBox1_Drop;
            textBox.DragEnter += MainTextBox1_DragEnter;
            textBox.SetDataFile(tabFile.File, _colorRules, Logger, tabPage.Name);

            tabPage.Controls.Add(host);
            tabControl1.TabPages.Add(tabPage);
            textBox.SetSize(host.Width, host.Height);
            textBox.ScrollToEnd();

            _files.Add(tabFile);

            tabControl1.SelectTab(tabPage);
        }
Exemple #2
0
        private void MainTextBox_TextChanged(object sender, TextChangedEventArgs e)
        {
            InputTextBox.Text = null;

            MainTextBox.ScrollToEnd();
        }
Exemple #3
0
        public void SetContext(ApplicationListVM applicationList)
        {
            DataContext = applicationList;
            if (_dispatcherTimer != null)
            {
                _dispatcherTimer.Stop();
            }

            // this is a very inefficient way to poll for changes, we should
            // bind to the OutputDataReceived directly...
            _dispatcherTimer       = new DispatcherTimer();
            _dispatcherTimer.Tick += new EventHandler((s, e) =>
            {
                var colors = Tuple.Create <Brush, Brush>(Brushes.CornflowerBlue, Brushes.White);
                if (applicationList.ActiveApplication != null)
                {
                    var app = applicationList.ActiveApplication;
                    if (ColorDictionary.ContainsKey(app.Status))
                    {
                        colors = ColorDictionary[app.Status];
                    }

                    // we should check that the tab we are in is selected...
                    bool isActive;
                    string output = "";
                    if (Component == "Build")
                    {
                        isActive = app.IsBuilding;
                        if (isActive)
                        {
                            output = app.BuildOutput;
                        }
                    }
                    else if (Component == "Run")
                    {
                        isActive = app.IsRunnning;
                        if (isActive)
                        {
                            output = app.RunOutput;
                        }
                    }
                    else
                    {
                        throw new Exception("No component " + Component);
                    }

                    if (isActive)
                    {
                        MainTextBox.Text = output;
                    }

                    if ((bool)ScrollToEndCheckBox.IsChecked && isActive)
                    {
                        MainTextBox.ScrollToEnd();
                    }

                    MainTextBox.Background = colors.Item1;
                    MainTextBox.Foreground = colors.Item2;
                }
            });
            _dispatcherTimer.Interval = new TimeSpan(0, 0, 0, 0, 10);
            _dispatcherTimer.Start();

            //application.SolutionObj.ExecutionCompleted += (s,e) =>
            //    Dispatcher.BeginInvoke(new Action(() =>
            //    {
            //        MainTextBox.Background = Brushes.Beige;
            //        MainTextBox.Foreground = Brushes.Black;
            //        if(_dispatcherTimer != null)
            //            _dispatcherTimer.Stop();
            //        _dispatcherTimer = null;
            //    }));
        }
Exemple #4
0
 internal void ScrollToEnd()
 {
     MainTextBox.ScrollToEnd();
 }