public BracketHighlightRenderer(TextView textView, LanguageContext languageContext)
        {
            _languageContext = languageContext;
            _textView = textView;

            UpdateColors(DefaultBackground, DefaultBorder);
        }
Esempio n. 2
0
        public InsightService(CodeEditor editor, LanguageContext languageContext, DebuggerService debuggerService)
        {
            _editor = editor;
            _languageContext = languageContext;
            _debuggerService = debuggerService;

            AttachEvents();
        }
Esempio n. 3
0
        public CompletionProvider(IBackendContext backendContext, LanguageContext languageContext)
        {
            _languageContext = languageContext;
            _backendContext = backendContext;
            _snippetsCollection = AppContext.Resolve<ISnippetsCollection>();

            _runspace = RunspaceFactory.CreateRunspace();
            _runspace.Open();
        }
        public void Generate(string templatePath, string documentOutputPath, string drawingOutputPath)
        {
            var languageContext = new LanguageContext();

            // Generate a word documentation
            GenerateWord(templatePath, documentOutputPath);

            // Generate a visio drawing
            GenerateVisio(drawingOutputPath);
        }
        public InlineScriptDocumentTransformer(TextView textView, LanguageContext languageContext)
        {
            _languageContext = languageContext;
            _textView = textView;

            SetBrush(new SolidColorBrush(Color.FromArgb(0x44, 0xcc, 0xcc, 0xcc)));

            // Detect scroll changes
            _textView.ScrollOffsetChanged += _textView_ScrollOffsetChanged;
            //_textView.VisualLinesChanged += _textView_VisualLinesChanged;
            //Refresh();
        }
Esempio n. 6
0
        public KeystrokeService(ICodeViewModel codeViewModel, TextArea textArea, ICompletionProvider completionProvider, LanguageContext languageContext, DebuggerService debuggerService, BookmarkManager bookmarkManager)
        {
            _completionProvider = completionProvider;
            _completionProvider.OnCompletionCompleted += OnCompletionResultRetrieved;
            _languageContext = languageContext;
            _debuggerService = debuggerService;
            _bookmarkManager = bookmarkManager;
            _codeViewModel = codeViewModel;

            _textArea = textArea;
            _textArea.KeyUp += OnKeyReleased;
            _textArea.TextEntered += OnTextEntered;
        }
Esempio n. 7
0
        public CodeEditor()
        {
            _keystrokeTimer = new System.Timers.Timer(2000);
            _keystrokeTimer.Elapsed += KeystrokeTimeElapsed;

            _languageContext = new LanguageContext();

            FontFamily = new FontFamily("Consolas");
            FontSize = 12;
            ShowLineNumbers = true;
            Options = new TextEditorOptions
            {
                ConvertTabsToSpaces = true,
                HighlightCurrentLine = true,
                IndentationSize = 4,
                AllowScrollBelowDocument = true
            };

            MouseHover += OnMouseHover;
            MouseHoverStopped += OnMouseHoverStopped;
            TextArea.Caret.PositionChanged += HighlightBrackets;

            _foldingStrategy = new PowershellFoldingStrategy();

            var foldingUpdateTimer = new DispatcherTimer { Interval = TimeSpan.FromSeconds(4) };
            foldingUpdateTimer.Tick += delegate { UpdateFoldings(); };
            foldingUpdateTimer.Start();

            _bracketRenderer = new BracketHighlightRenderer(this.TextArea.TextView, _languageContext);
            TextArea.TextView.BackgroundRenderers.Add(_bracketRenderer);

            _inlineScriptTransformer = new InlineScriptDocumentTransformer(this.TextArea.TextView, _languageContext);
            TextArea.TextView.BackgroundRenderers.Add(_inlineScriptTransformer);

            InitializeColorizer();
        }
        private void GenerateVisio(string drawingOutputPath)
        {
            var pageWidth = 16.53543307086614;
            var pageHeight = 11.69291338582677;
            var left = 0.1;
            var processWidth = 1.5;
            var processHeight = 1.0;
            var processPaddingHorizontal = 0.4;
            var processPaddingVertical = 1.4;
            var maxProcessCountPerRow = 10;
            var activityPos = 1;
            var activityYPos = 0;
            var addToHorizontal = 1;
            var shapes = new List<VisioShape>();

            // Clean up the template and remove the existing pages
            var templateXml = XDocument.Load("DrawingTemplate.vdx");
            //VisioTemplate.CleanUpTemplate(templateXml);

            var template = new VisioTemplate(templateXml.ToString());
            var document = new VisioDrawing(template);
            document.DocumentProperties.Creator = "Automation Studio";
            document.DocumentProperties.TimeCreated = DateTime.Now;

            // Configure the page
            var runbooks = _backendContext.Runbooks;
            var runbooksList = new List<RunbookModelProxy>();
            foreach (var runbook in runbooks)
                runbooksList.Add((runbook.Tag as RunbookModelProxy));

            var languageContext = new LanguageContext();

            foreach (var runbook in runbooks)
            {
                if (!(runbook.Tag as RunbookModelProxy).PublishedRunbookVersionID.HasValue)
                    continue;

                var runbookProxy = (runbook.Tag as RunbookModelProxy);
                _statusManager.SetText("Generating visio drawing for " + runbookProxy.RunbookName);
                var viewModel = (runbook.Tag as RunbookModelProxy).GetViewModel<RunbookViewModel>();

                var page = ConfigureVisioPage(viewModel.Runbook.RunbookName, pageWidth, pageHeight);
                document.Pages.Add(page);

                var publishedContent = viewModel.GetContent(RunbookType.Published, true);
                languageContext.Parse(publishedContent);

                var references = languageContext.GetReferences(runbooksList);

                if (references.Count == 0)
                    continue;

                var totalRows = (double)(runbooksList.Count / maxProcessCountPerRow);

                if (runbooksList.Count <= maxProcessCountPerRow)
                    totalRows = 2.0;

                var y = (pageHeight / totalRows) + (totalRows * ((processHeight + processPaddingVertical)) / totalRows);
                var x = (pageWidth / (maxProcessCountPerRow - 1)) + ((processWidth + processPaddingHorizontal) * activityPos);
                var ay = y - ((processHeight + processPaddingVertical) * activityYPos);

                // Add the current runbook as the start activity
                var processId = document.GetMasterMetaData("Process").ID;
                var visioActivity = new VisioShape(processId, x, ay, processWidth, processHeight);

                var charFormat = new VisioAutomation.VDX.Sections.Char();
                charFormat.Size.Result = 12;

                visioActivity.CharFormats = new List<VisioAutomation.VDX.Sections.Char>();
                visioActivity.CharFormats.Add(charFormat);
                visioActivity.Text.Add(runbookProxy.RunbookName);

                page.Shapes.Add(visioActivity);
                shapes.Add(visioActivity);

                activityPos += addToHorizontal;

                foreach (var reference in references)
                {
                    x = (pageWidth / (maxProcessCountPerRow - 1)) + ((processWidth + processPaddingHorizontal) * activityPos);
                    ay = y - ((processHeight + processPaddingVertical) * activityYPos);

                    // Add all references
                    processId = document.GetMasterMetaData("Process").ID;
                    visioActivity = new VisioShape(processId, x, ay, processWidth, processHeight);

                    visioActivity.CharFormats = new List<VisioAutomation.VDX.Sections.Char>();
                    visioActivity.CharFormats.Add(charFormat);
                    visioActivity.Text.Add(reference.RunbookName);

                    page.Shapes.Add(visioActivity);
                    shapes.Add(visioActivity);

                    /*//if (!String.IsNullOrEmpty(activity.Description))
                    {
                        int shapeID = visioActivity.ID;

                        var callOut = new VisioShape(26, x + 0.3, ay + 1.0);
                        //callOut.Text.Add(activity.Description);
                        callOut.Geom = new VisioAutomation.VDX.Sections.Geom();

                        page.Shapes.Add(callOut);
                    }*/

                    activityPos++;

                    if (activityPos >= maxProcessCountPerRow)
                    {
                        addToHorizontal = -1;
                        activityPos += addToHorizontal;
                        activityYPos++;
                    }
                    else
                    {
                        addToHorizontal = 1;
                        activityPos += addToHorizontal;
                        activityYPos++;
                    }
                }

                // Add connectors between the activities
                for (int i = 0; i < shapes.Count; i++)
                {
                    // We only add connectors up until the latest process object
                    if ((i + 1) >= shapes.Count)
                        break;

                    VisioShape a1 = shapes[i];
                    VisioShape a2 = shapes[i + 1];

                    var line = VisioShape.CreateDynamicConnector(document);
                    line.XForm1D.EndY.Result = 0;

                    line.Line = new VisioLine();
                    line.Line.EndArrow.Result = 2;

                    page.Shapes.Add(line);
                    page.ConnectShapesViaConnector(line, a1, a2);
                }

                shapes.Clear();
                languageContext.ClearCache();
            }

            document.Save(drawingOutputPath);
        }