示例#1
0
        private void CloseScriptExecuted(object sender, ExecutedRoutedEventArgs e)
        {
            Logger.LogDebug("Text-Editor-Control-CloseScriptExecuted", "CloseScriptExecuted");


            ScriptTabControl.CloseCurrentTab();
        }
示例#2
0
        private void OnTextCanvasGotKeyboardFocus(object sender, KeyboardFocusChangedEventArgs e)
        {
            if (textCore.ReadOnlyState == false)
            {
                List <int> scriptsToClose = new List <int>();
                textCore.CheckForExternalModifications(ref scriptsToClose);
                if (scriptsToClose.Count > 0)
                {
                    foreach (int index in scriptsToClose)
                    {
                        ScriptTabControl.CloseTab(index);
                        textCore.CloseScript(index);
                    }

                    // IDE-644 Crash on file reload if existing open file renamed in explorer.
                    // If at the end of all these there's no script left, clean up script display.
                    if (Solution.Current.ScriptCount <= 0)
                    {
                        ShowTabControls(false);
                        CheckTabControlVisibility(true);
                    }
                    else
                    {
                        // Repaint text canvas...
                        HandleScriptActivation();
                    }
                }
            }
        }
示例#3
0
        private Scintilla AddNewTab( )
        {
            DevExpress.XtraTab.XtraTabPage page = this.ScriptTabControl.TabPages.Add("Script" + this.ScriptTabControl.TabPages.Count);
            ScriptTabControl.SuspendLayout();

            Scintilla richText = new Scintilla();

            richText.ConfigurationManager.Language = "sql";
            richText.Dock = System.Windows.Forms.DockStyle.Fill;
            richText.Indentation.ShowGuides      = true;
            richText.Indentation.SmartIndentType = SmartIndent.Simple;
            richText.Location = new System.Drawing.Point(0, 0);
            richText.Margins.Margin0.Width = 40;
            richText.Margins.Margin2.Width = 20;
            richText.Name = "Script";
            richText.Size = new System.Drawing.Size(644, 452);
            richText.Styles.BraceBad.FontName       = "Verdana";
            richText.Styles.BraceLight.FontName     = "Verdana";
            richText.Styles.ControlChar.FontName    = "Verdana";
            richText.Styles.Default.FontName        = "Verdana";
            richText.Styles.Default.Size            = 8;
            richText.Styles.IndentGuide.FontName    = "Verdana";
            richText.Styles.LastPredefined.FontName = "Verdana";
            richText.Styles.LineNumber.FontName     = "Verdana";
            richText.Styles.Max.FontName            = "Verdana";
            richText.TabIndex        = 2;
            richText.Whitespace.Mode = WhitespaceMode.VisibleAfterIndent;
            richText.Dock            = DockStyle.Fill;
            //     richText.Font=new Font( richText.Font.FontFamily , 9 );
            richText.PreviewKeyDown += new PreviewKeyDownEventHandler(Script_PreviewKeyDown);
            page.Controls.Add(richText);
            ScriptTabControl.SelectedTabPage = page;
            ScriptTabControl.ResumeLayout();
            return(richText);
        }
        private bool ActivateScriptByPath(string scriptPath)
        {
            int index = Solution.Current.GetScriptIndexFromPath(scriptPath);

            if (-1 == index)
            {
                // The script is not currently opened, attempt to do that.
                if (textCore.LoadScriptFromFile(scriptPath) == false)
                {
                    return(false);
                }

                SetupTabInternal(scriptPath);
                return(true);
            }

            index = Solution.Current.GetScriptIndexFromPath(scriptPath);
            if (ScriptTabControl.CurrentTab == index)
            {
                return(true);
            }

            ScriptTabControl.ActivateTab(index);
            HandleScriptActivation();
            return(true);
        }
        private void UpdateTabDisplayText()
        {
            IScriptObject currScript   = Solution.Current.ActiveScript;
            IParsedScript parsedScript = currScript.GetParsedScript();

            if (null != parsedScript)
            {
                string   filePath = parsedScript.GetScriptPath();
                FileInfo fileInfo = new FileInfo(filePath);
                int      tabIndex = ScriptTabControl.CurrentTab;
                ScriptTabControl.SetDisplayText(tabIndex, fileInfo.Name);
                currScript.GetTextBuffer().ScriptModified = false;
            }
        }
示例#6
0
        private void CloseSolutionExecuted(object sender, ExecutedRoutedEventArgs e)
        {
            Logger.LogDebug("Text-Editor-Control-CloseSolutionExecuted", "CloseSolutionExecuted");

            if (Solution.Current.IsModified != false && Solution.Current.ShowSaveDialog != false)
            {
                MessageBoxResult result = MessageBoxResult.Cancel;
                result = MessageBox.Show(Configurations.ConfirmSaveSolution,
                                         "Save Solution", MessageBoxButton.YesNoCancel, MessageBoxImage.Question);

                switch (result)
                {
                case MessageBoxResult.Yes:
                    if (SaveSolutionInternal() == false)
                    {
                        return;
                    }
                    Solution.CloseSolution(Solution.Current, false);
                    break;

                case MessageBoxResult.No:
                    // Proceed to discard the solution.
                    Solution.CloseSolution(Solution.Current, true);
                    break;

                case MessageBoxResult.Cancel:
                    return;     // Abort close solution.
                }
            }
            else
            {
                Solution.CloseSolution(Solution.Current, false);
            }

            ScriptTabControl.CloseAllTabs();
            ShowTabControls(false);
            OutputWindow.ClearOutput();

            InspectionViewControl.Instance.RemoveAllVariables();
            CommandManager.InvalidateRequerySuggested();
        }
示例#7
0
        private void OnTextBufferModified(object sender, EventArgs e)
        {
            ITextBuffer textBuffer = (ITextBuffer)sender;

            if (textBuffer == null)
            {
                return;
            }

            // Changing Save Button State
            //this.SaveButton.IsEnabled = textBuffer.ScriptModified;
            //this.SaveItem.IsEnabled = textBuffer.ScriptModified;

            //Changing name of the script on CurvyTab
            int           tabIndex;
            IScriptObject owningScript = textBuffer.OwningScript;

            if (owningScript == null)
            {
                tabIndex = ScriptTabControl.CurrentTab;
            }
            else
            {
                string currentScriptPath = owningScript.GetParsedScript().GetScriptPath();
                tabIndex = Solution.Current.GetScriptIndexFromPath(currentScriptPath);
            }

            string currentDisplayText = ScriptTabControl.GetDisplayText(tabIndex);

            ScriptTabControl.SetHighlightTab(tabIndex, textBuffer.ScriptModified);

            if (textBuffer.ScriptModified == true)
            {
                ScriptTabControl.SetDisplayText(tabIndex, "*" + currentDisplayText);
            }

            if (textBuffer.ScriptModified == false)
            {
                UpdateTabDisplayText();
            }
        }
        public bool EnsureScriptsSaved()
        {
            int numberOfTabs = ScriptTabControl.TabCount;

            for (int i = 0; i < numberOfTabs; i++)
            {
                ScriptTabControl.ActivateTab(0);
                HandleScriptActivation();
                if (textEditorControl.ScriptTabClosingCallback())
                {
                    ScriptTabControl.CloseTab(0);
                    textCore.CloseScript(0);
                }
                else
                {
                    return(false);
                }
            }

            return(true);
        }
示例#9
0
        private void OpenSolutionExecuted(object sender, ExecutedRoutedEventArgs e)
        {
            Logger.LogDebug("Text-Editor-Control-OpenSolutionExecuted", "OpenSolutionExecuted");

            // Check to see if the solution needs saving. But then we cannot do
            // this because we ALWAYS have a start-up script, so user will be
            // prompt to save the solution even if she has not done anything after
            // launching DesignScript Studio.
            //
            // if (SaveSolutionInternal() == false)
            //    return;


            if (OpenSolutionInternal() == false)
            {
                return;
            }

            ScriptTabControl.CloseAllTabs();

            int count = Solution.Current.ScriptCount;

            for (int index = 0; index < count; ++index)
            {
                string path = Solution.Current.GetScriptPathFromIndex(index);
                string name = System.IO.Path.GetFileName(path);
                ScriptTabControl.InsertNewTab(name, scrollViewer);
            }

            int activeScript = Solution.Current.ActiveScriptIndex;

            ScriptTabControl.ActivateTab(activeScript);

            HandleScriptActivation();

            // Remove and add all expressions stored in the solution.
            InspectionViewControl.Instance.PopulateVariablesFromSolution();
            CommandManager.InvalidateRequerySuggested();
        }
示例#10
0
        private void OpenScriptExecuted(object sender, ExecutedRoutedEventArgs e)
        {
            e.Handled = true;
            Logger.LogDebug("Text-Editor-Control-OnOpenScriptButton", "UserPressed");
            Stopwatch sw = new Stopwatch();

            sw.Start();

            if (null == TextEditorControl.HostApplication)
            {
                return; // Nothing to do.
            }
            string filePath = TextEditorControl.HostApplication.PromptScriptSelection();

            if (string.IsNullOrEmpty(filePath))
            {
                return; // Nothing to do, again.
            }
            if (parseTimer == null)
            {
                parseTimer          = new DispatcherTimer();
                parseTimer.Tick    += new EventHandler(OnParseTimerTick);
                parseTimer.Interval = new TimeSpan(0, 0, 1);
                parseTimer.Start();
            }

            if (textCore.LoadScriptFromFile(filePath))
            {
                SetupTabInternal(filePath);
            }
            else
            {
                // Even though "LoadScriptFromFile" returns false, it may be
                // due to the fact that the script has already been opened.
                // In such cases, we will be able to get the script index
                // given its name. If the index turns out to be valid here,
                // then we will simply activate the corresponding tab.
                //
                int index = Solution.Current.GetScriptIndexFromPath(filePath);
                if (index >= 0)
                {
                    ScriptTabControl.ActivateTab(index);
                }
                else
                {
                    MessageBox.Show(Configurations.UnsupportedFileType);
                }
            }

            HandleScriptActivation();

            grid.UpdateLayout();
            CommandManager.InvalidateRequerySuggested();
            textCanvas.Focus();

            IScriptObject script = Solution.Current.ActiveScript;

            Logger.LogPerf("TextEditorControl.OnOpenScriptButton", sw.ElapsedMilliseconds + " ms");
            if (null != script)
            {
                Logger.LogInfo("Text-Editor-Control-OnOpenScriptButton-Script", script.GetTextBuffer().GetContent());
            }
        }