/// <inheritdoc />
        protected override void OnStartup(StartupEventArgs e)
        {
            if (e.Args.Any())
            {
                _file = e.Args.First();
            }
            _mevent = new ManualResetEvent(false);
            t2      = RoslynCodeControl.StartSecondaryThread(_mevent);
            JoinableTaskFactory f = new JoinableTaskFactory(new JoinableTaskContext());

            f.RunAsync(Z);
            base.OnStartup(e);
        }
        public async Task InitializeAsync()
        {
            _f = new MyFixture(debugLevel)
            {
                OutputHelper = _outputHelper
            };
            await _f.InitializeAsync();

            _codeControl = new RoslynCodeControl(_f.Debugfn)
            {
                JTF2 = _f.JTF2
            };
            JTF = _codeControl.JTF;
        }
 public void Deconstruct(out RoslynCodeControl roslynCodeControl, out int lineNo, out int offset, out double y, out double x, out TextFormatter textFormatter, out double paragraphWidth, out double pixelsPerDip, out CustomTextSource4 customTextSource4, out double maxY, out double maxX, out string fontFamilyName, out double fontSize, out FontWeight fontWeight)
 {
     roslynCodeControl = RoslynCodeControl;
     lineNo            = LineNo;
     offset            = Offset;
     y                 = Y;
     x                 = X;
     textFormatter     = TextFormatter;
     paragraphWidth    = ParagraphWidth;
     pixelsPerDip      = PixelsPerDip;
     customTextSource4 = CustomTextSource4;
     maxY              = MaxY;
     maxX              = MaxX;
     fontFamilyName    = FontFamilyName;
     fontSize          = FontSize;
     fontWeight        = FontWeight;
 }
Exemple #4
0
        public static async Task OnLoadedAsync(RoslynCodeControl codeControl, bool closeWindow, Window window)
        {
            for (var i = 0; i < 10; i++)
            {
                await codeControl.UpdateFormattedTextAsync();

                var msg = codeControl.LineInfos2.Count.ToString();
                codeControl.DebugFn(msg, 0);
                ProtoLogger.Instance.LogAction(msg);
            }

            // WriteDocument(codeControl);
            if (closeWindow)
            {
                window.Close();
            }
        }
        public async Task TestMethod1()
        {
            Thread.CurrentThread.Name = "Main1";
            _control = new RoslynCodeControl();
            await _f.InitializeAsync();

            var c = _control;

            c.JTF2       = _f.JTF2;
            c.SourceText = "";

            var w = new Window();

            _window   = w;
            w.Content = _control;

            JoinableTask jt1 = null;

            w.Loaded += (sender, args) =>
            {
                jt1 = c.JTF.RunAsync(DoInput1Async);
                var continueWith = jt1.JoinAsync().ContinueWith(async t =>
                {
                    if (c.IsFaulted)
                    {
                    }
                    await c.ShutdownAsync();

                    c.Dispatcher.InvokeShutdown();
                    c.SecondaryDispatcher.InvokeShutdown();
                }, CancellationToken.None, TaskContinuationOptions.None, TaskScheduler.FromCurrentSynchronizationContext());
            };

            try
            {
                w.Show();
            }
            catch (Exception ex)
            {
                _f.Debugfn(ex.ToString());
            }
            Dispatcher.Run();
            await jt1.JoinAsync();
        }
Exemple #6
0
        /// <inheritdoc />
        public async Task InitializeAsync()
        {
            // string name = MyCompanyEventSource.GetName(typeof(MyCompanyEventSource));
            // IEnumerable<EventSource> eventSources = MyCompanyEventSource.GetSources();

            var mEvent = new ManualResetEvent(false);
            var startSecondaryThread = RoslynCodeControl.StartSecondaryThread(mEvent, (d) => { });

            await mEvent.ToTask();

            _d = Dispatcher.FromThread(startSecondaryThread);
            var joinableTaskContext = new JoinableTaskContext(RoslynCodeControl.SecondaryThread,
                                                              new DispatcherSynchronizationContext(_d));

            _coll = joinableTaskContext.CreateCollection();
            var jtf2 = joinableTaskContext.CreateFactory(_coll);

            JTF2 = jtf2;
        }
 public RenderRequestInput(RoslynCodeControl roslynCodeControl, int lineNo, int offset, double y, double x, TextFormatter textFormatter, double paragraphWidth,
                           double pixelsPerDip, CustomTextSource4 customTextSource4, double maxY, double maxX, double fontSize,
                           string fontFamilyName, FontWeight fontWeight)
 {
     // Timestamp = DateTime.Now;
     RoslynCodeControl = roslynCodeControl;
     LineNo            = lineNo;
     Offset            = offset;
     Y                 = y;
     X                 = x;
     TextFormatter     = textFormatter;
     ParagraphWidth    = paragraphWidth;
     PixelsPerDip      = pixelsPerDip;
     CustomTextSource4 = customTextSource4;
     MaxY              = maxY;
     MaxX              = maxX;
     FontSize          = fontSize;
     FontFamilyName    = fontFamilyName;
     FontWeight        = fontWeight;
 }
Exemple #8
0
 protected virtual void OnCodeControlChanged(RoslynCodeControl oldValue, RoslynCodeControl newValue)
 {
 }
Exemple #9
0
 public PostUpdateInput(RoslynCodeControl roslynCodeControl, in int insertionPoint,
Exemple #10
0
 public CustomTextSource4Proxy(RoslynCodeControl codeControl)
 {
     CodeControl = codeControl;
 }
        public void TestRedrawLine1(string code, int lineNo, int offset, double x, double y, double width,
                                    double pixelsPerDip, double maxX, double maxY, double fontSize, string fontFamilyName,
                                    object[] curLineInfoObjects, int outLength, bool isNewLineInfo, int dgCount, int[] runIndiciesAry)
        {
            var face = new Typeface(new FontFamily(fontFamilyName), FontStyles.Normal, FontWeights.Normal,
                                    FontStretches.Normal);

            var rendering =
                FontRendering.CreateInstance(fontSize, TextAlignment.Left, new TextDecorationCollection(),
                                             Brushes.Black, face);

            var source = new CustomTextSource4(pixelsPerDip, rendering,
                                               new GenericTextRunProperties(rendering, pixelsPerDip), _f.Debugfn);

            source.SetText(code);
            var renderRequestInput = new RenderRequestInput(_codeControl,
                                                            lineNo, offset, x, y,
                                                            RoslynCodeControl.Formatter,
                                                            width, pixelsPerDip,
                                                            source, maxY, maxX, fontSize,
                                                            fontFamilyName,
                                                            FontWeights.Regular);
            LineInfo2?curLineInfo = null;

            if (curLineInfoObjects != null)
            {
                curLineInfo = new LineInfo2((int)curLineInfoObjects[0],
                                            (LinkedListNode <CharInfo>)curLineInfoObjects[1], (int)curLineInfoObjects[2],
                                            new Point((double)curLineInfoObjects[3], (double)curLineInfoObjects[4]),
                                            (double)curLineInfoObjects[5],
                                            (int)curLineInfoObjects[6]);
            }
            var result = RoslynCodeControl.RedrawLine(renderRequestInput, rendering, null, curLineInfo);
            var i      = 0;

            foreach (var sourceRunInfo in source.Runs)
            {
                _f.Debugfn($"Run {i} : {sourceRunInfo}");
            }
            var dg = result.DrawingGroup;
            var l  = result.LineInfo;

            i = 0;
            var c = l.FirstCharInfo;

            if (runIndiciesAry != null)
            {
                Assert.NotNull(c);
                Assert.NotNull(c.List);
                var ri    = c.List.Select(c1 => c1.RunIndex);
                var chars = string.Join("", c.List.Select(c1 => c1.Character));
                _f.Debugfn("chars: " + chars);
                Assert.Equal(runIndiciesAry, ri);
                var runIndicies = "{" + string.Join(", ", ri) + "}";
                _f.Debugfn(runIndicies);
            }


            while (c != null)
            {
                Assert.NotNull(c.Value);
                _f.Debugfn($"CharInfo[{i}] {c.Value}");
                c = c.Next;
            }

            _f.Debugfn(l.ToString());
            Assert.Equal(lineNo, l.LineNumber);
            Assert.Equal(outLength, l.Length);
            Assert.Equal(offset, l.Offset);
            Assert.Equal(new Point(x, y), l.Origin);
            Assert.Equal(isNewLineInfo, result.IsNewLineInfo);
            Assert.Collection(dg.Children, drawing =>
            {
                Assert.IsType <DrawingGroup>(drawing);
                Assert.Collection(((DrawingGroup)drawing).Children,
                                  Enumerable.Repeat <Action <Drawing> >(z => { Assert.IsType <GlyphRunDrawing>(z); }, dgCount).ToArray());
            });
        }