Beispiel #1
0
 private void CleanUpDeviceIndependentResources()
 {
     if (this._deviceIndependedResourcesCreated)
     {
         OnCleanUpDeviceIndependentResources();
     }
     if (this._imagingFactory != null)
     {
         this._imagingFactory.Dispose();
         this._imagingFactory = null;
     }
     if (this._directWriteFactory != null)
     {
         this._directWriteFactory.Dispose();
         this._directWriteFactory = null;
     }
     if (this._renderTarget != null)
     {
         this._renderTarget.Dispose();
         this._renderTarget = null;
     }
     if (this._factory != null)
     {
         this._factory.Dispose();
         this._factory = null;
     }
 }
Beispiel #2
0
        private void MainWindow_Load(object sender, EventArgs e)
        {
            DirectWriteFactory f = DirectWriteFactory.Create(DirectWriteFactoryType.Shared);

            _textFormat = f.CreateTextFormat("Verdana", 110, FontWeight.Normal, FontStyle.Normal, FontStretch.Normal);
            _textFormat.ParagraphAlignment = ParagraphAlignment.Far;
            _textFormat.TextAlignment      = TextAlignment.Center;

            ClientSize = new System.Drawing.Size(600, 600);
            _factory   = Direct2DFactory.CreateFactory(FactoryType.SingleThreaded, DebugLevel.None, FactoryVersion.Auto);

            _renderTarget = _factory.CreateWindowRenderTarget(this, PresentOptions.None, RenderTargetProperties.Default);
            AntialiasMode     amode  = _renderTarget.AntialiasMode;
            TextAntialiasMode tamode = _renderTarget.TextAntialiasMode;

            _strokeBrush = _renderTarget.CreateSolidColorBrush(Color.FromKnown(Colors.Cyan, 1));
            try
            {
                _strokeStyle = _factory.CreateStrokeStyle(new StrokeStyleProperties1(LineCapStyle.Flat,
                                                                                     LineCapStyle.Flat, LineCapStyle.Round, LineJoin.Miter, 10, DashStyle.Dot, 0, StrokeTransformType.Normal), null);
            }
            catch (NotSupportedException)
            {
                _strokeStyle = _factory.CreateStrokeStyle(new StrokeStyleProperties(LineCapStyle.Flat,
                                                                                    LineCapStyle.Flat, LineCapStyle.Round, LineJoin.Miter, 10, DashStyle.Dot, 0), null);
            }
            Resize += new EventHandler(MainWindow_Resize);
        }
Beispiel #3
0
 private async void MainWindow_Load(object sender, EventArgs e)
 {
     if (_dxgiDevice != null)
     {
         CleanUp();
     }
     _dxgiDevice = DxgiDevice.CreateDevice();
     _factory    = Direct2DFactory.CreateFactory(FactoryType.SingleThreaded, DebugLevel.None);
     using (Device device = _factory.CreateDevice(_dxgiDevice))
     {
         _deviceContext = device.CreateDeviceContext(DeviceContextOptions.None);
         using (DxgiAdapter adapter = _dxgiDevice.GetAdapter())
             using (DxgiFactory factory = adapter.GetFactory())
             {
                 _swapChain = factory.CreateSwapChainForHwnd(_dxgiDevice, Handle);
                 _dxgiDevice.MaximumFrameLatency = 1;
                 _swapChain.GetBuffer(0, out _surface);
                 _bitmap = _deviceContext.CreateBitmapFromDxgiSurface(_surface);
                 _deviceContext.SetTarget(_bitmap);
                 _brush  = _deviceContext.CreateSolidColorBrush(Color.FromRGB(0.1f, 0.75f, 0.5f, 1f));
                 _brush1 = _deviceContext.CreateSolidColorBrush(Color.FromRGB(0.1f, 0.5f, 0.75f, 1f));
             }
     }
     _directWriteFactory = DirectWriteFactory.Create(DirectWriteFactoryType.Shared);
     await CreatePoints();
 }
Beispiel #4
0
        protected override void OnCreateDeviceIndependentResources(Direct2DFactory factory)
        {
            base.OnCreateDeviceIndependentResources(factory);
            this._textFormat = DirectWriteFactory.CreateTextFormat("Gabriola", 72);
            this._textFormat.TextAlignment      = TextAlignment.Center;
            this._textFormat.ParagraphAlignment = ParagraphAlignment.Center;
            float width  = ClientSize.Width / dpiScaleX;
            float height = ClientSize.Height / dpiScaleY;

            this._textLayout   = DirectWriteFactory.CreateTextLayout("Click on this text Click on this text", this._textFormat, width, height);
            this._textAnalyzer = DirectWriteFactory.CreateTextAnalyzer();
            this._source       = new MyTextSource("Click on this text Click on this text");
            using (FontCollection coll = this._textFormat.FontCollection)
            {
                int count = coll.Count;
                for (int index = 0; index < count; ++index)
                {
                    using (FontFamily ff = coll[index])
                    {
                        using (Font font = ff.GetFirstMatchingFont(FontWeight.Normal, FontStretch.Normal, FontStyle.Normal))
                        {
                            LocalizedStrings ls   = font.FaceNames;
                            LocalizedStrings desc = font.GetInformationalStrings(InformationalStringId.Designer);

                            int         cultureIndex = ls.FindCulture(CultureInfo.CurrentCulture);
                            string      faceName     = ls[cultureIndex];
                            FontMetrics metrics      = font.Metrics;
                        }
                    }
                }
            }
            this._textAnalyzer.AnalyzeLineBreakpoints(_source, 0, (uint)_source.Text.Length);
            this._textAnalyzer.AnalyzeScript(_source, 0, (uint)_source.Text.Length);
        }
Beispiel #5
0
 protected override void OnCreateDeviceIndependentResources(Direct2DFactory factory)
 {
     base.OnCreateDeviceIndependentResources(factory);
     this._textFormat = DirectWriteFactory.CreateTextFormat("Verdana", 10.5f, FontWeight.Bold, FontStyle.Normal, FontStretch.Normal);
     this._textFormat.ParagraphAlignment = ParagraphAlignment.Near;
     this._textFormat.TextAlignment      = TextAlignment.Center;
 }
        protected override void OnCreateDeviceResources(WindowRenderTarget renderTarget)
        {
            base.OnCreateDeviceResources(renderTarget);

            float width  = ClientSize.Width / _dpiScaleX;
            float height = ClientSize.Height / _dpiScaleY;

            this._textLayout = DirectWriteFactory.CreateTextLayout(
                _text,
                this._textFormat,
                width,
                height);

            using (Typography typography = DirectWriteFactory.CreateTypography())
            {
                typography.AddFontFeature(FontFeatureTag.StylisticSet7, 1);
                this._textLayout.SetTypography(typography, new TextRange(0, _text.Length));
            }

            Bitmap bitmap = RenderTarget.CreateBitmap(this.GetType(), "heart.png");

            this._bitmapInlineObject = new BitmapInlineObject(RenderTarget, bitmap);

            this._textLayout.SetInlineObject(this._bitmapInlineObject, new TextRange(2, 1));

            this._blackBrush = renderTarget.CreateSolidColorBrush(Color.FromKnown(Colors.Black, 1));
        }
        protected override void OnCreateDeviceIndependentResources(Direct2DFactory factory)
        {
            base.OnCreateDeviceIndependentResources(factory);

            this._textFormat = DirectWriteFactory.CreateTextFormat("Gabriola",
                                                                   FontWeight.Normal,
                                                                   FontStyle.Normal,
                                                                   FontStretch.Normal,
                                                                   72);

            this._textFormat.TextAlignment      = TextAlignment.Center;
            this._textFormat.ParagraphAlignment = ParagraphAlignment.Center;

            float width  = ClientSize.Width / _dpiScaleX;
            float height = ClientSize.Height / _dpiScaleY;

            this._textLayout = DirectWriteFactory.CreateTextLayout(
                _text,
                this._textFormat,
                width,
                height);

            using (Typography typography = DirectWriteFactory.CreateTypography())
            {
                typography.AddFontFeature(FontFeatureTag.StylisticSet7, 1);
                this._textLayout.SetTypography(typography, new TextRange(0, _text.Length));
            }

            Bitmap bitmap = RenderTarget.CreateBitmap(this.GetType(), "heart.png");

            this._bitmapInlineObject = new BitmapInlineObject(RenderTarget, bitmap);

            this._textLayout.SetInlineObject(this._bitmapInlineObject, new TextRange(2, 1));
        }
Beispiel #8
0
        protected override void OnCreateDeviceIndependentResources(Direct2DFactory factory)
        {
            base.OnCreateDeviceIndependentResources(factory);

            this._textFormat = DirectWriteFactory.CreateTextFormat("Gabriola", 72);

            this._textFormat.TextAlignment      = TextAlignment.Center;
            this._textFormat.ParagraphAlignment = ParagraphAlignment.Center;

            float width  = ClientSize.Width / _dpiScaleX;
            float height = ClientSize.Height / _dpiScaleY;

            this._textLayout = DirectWriteFactory.CreateTextLayout(
                _text,
                this._textFormat,
                width,
                height);

            this._textLayout.SetFontSize(100, new TextRange(20, 6));
            this._textLayout.SetUnderline(true, new TextRange(20, 11));
            this._textLayout.SetFontWeight(FontWeight.Bold, new TextRange(20, 11));

            using (Typography typography = DirectWriteFactory.CreateTypography())
            {
                typography.AddFontFeature(FontFeatureTag.StylisticSet7, 1);
                this._textLayout.SetTypography(typography, new TextRange(0, _text.Length));
            }
        }
Beispiel #9
0
 private void MainWindow_Load(object sender, EventArgs e)
 {
     if (_dxgiDevice != null)
     {
         CleanUp();
     }
     _dxgiDevice = DxgiDevice.CreateDevice();
     _factory    = Direct2DFactory.CreateFactory(FactoryType.SingleThreaded, DebugLevel.None);
     using (Device device = _factory.CreateDevice(_dxgiDevice))
     {
         _deviceContext = device.CreateDeviceContext(DeviceContextOptions.None);
         using (DxgiAdapter adapter = _dxgiDevice.GetAdapter())
             using (DxgiFactory factory = adapter.GetFactory())
             {
                 _swapChain = factory.CreateSwapChainForHwnd(_dxgiDevice, Handle);
                 _dxgiDevice.MaximumFrameLatency = 1;
                 _swapChain.GetBuffer(0, out _surface);
                 _bitmap = _deviceContext.CreateBitmapFromDxgiSurface(_surface);
                 _deviceContext.SetTarget(_bitmap);
             }
         for (int index = 0; index < _brushes.Length; ++index)
         {
             _pens[index]    = _deviceContext.CreateSolidColorBrush(GetRandomColor(_random, 1));
             _brushes[index] = _deviceContext.CreateSolidColorBrush(GetRandomColor(_random, 0.25f));
         }
     }
     _directWriteFactory = DirectWriteFactory.Create(DirectWriteFactoryType.Shared);
 }
Beispiel #10
0
        private static List <string> GetFontNames()
        {
            List <string> fonts = new List <string>();

            using (DirectWriteFactory factory = DirectWriteFactory.Create(DirectWriteFactoryType.Shared))
            {
                using (FontCollection fontCollection = factory.GetSystemFontCollection(false))
                {
                    for (int index = 0; index < fontCollection.Count; ++index)
                    {
                        using (FontFamily fontFamily = fontCollection[index])
                        {
                            using (LocalizedStrings names = fontFamily.FamilyNames)
                            {
                                int cultureIndex = names.FindCulture(CultureInfo.CurrentUICulture);
                                if (cultureIndex < 0)
                                {
                                    cultureIndex = names.FindCulture(new CultureInfo("en-us"));
                                }
                                fonts.Add(names[cultureIndex]);
                            }
                        }
                    }
                }
            }
            fonts.Sort();
            return(fonts);
        }
        protected override void OnCreateDeviceIndependentResources(Direct2DFactory factory)
        {
            base.OnCreateDeviceIndependentResources(factory);

            this._textFormat = DirectWriteFactory.CreateTextFormat("Gabriola", 72);

            this._textFormat.TextAlignment      = TextAlignment.Center;
            this._textFormat.ParagraphAlignment = ParagraphAlignment.Center;
        }
Beispiel #12
0
        protected override void OnCreateDeviceIndependentResources(Direct2DFactory factory)
        {
            base.OnCreateDeviceIndependentResources(factory);
            this._textFormat = DirectWriteFactory.CreateTextFormat("Gabriola", 72);
            this._textFormat.TextAlignment      = TextAlignment.Center;
            this._textFormat.ParagraphAlignment = ParagraphAlignment.Center;

            System.Globalization.CultureInfo ci = this._textFormat.Culture;
            Trimming trimming = this._textFormat.Trimming;
        }
Beispiel #13
0
        protected override void OnCreateDeviceIndependentResources(Direct2DFactory factory)
        {
            base.OnCreateDeviceIndependentResources(factory);
            this._textFormat = DirectWriteFactory.CreateTextFormat("Gabriola", 72);
            this._textFormat.TextAlignment      = TextAlignment.Center;
            this._textFormat.ParagraphAlignment = ParagraphAlignment.Center;
            float width  = ClientSize.Width / dpiScaleX;
            float height = ClientSize.Height / dpiScaleY;

            this._textLayout = DirectWriteFactory.CreateTextLayout("Click on this text", this._textFormat, width, height);
        }
Beispiel #14
0
        protected override void OnCreateDeviceIndependentResources(Direct2DFactory factory)
        {
            base.OnCreateDeviceIndependentResources(factory);
            this._textFormat = DirectWriteFactory.CreateTextFormat("Verdana", FontWeight.Normal, FontStyle.Normal, FontStretch.Normal, 10.5f);
            this._textFormat.TextAlignment = TextAlignment.Center;

            float[] dashes = new float[] { 1, 1, 2, 3, 5 };
            this._strokeStyle = factory.CreateStrokeStyle(
                new StrokeStyleProperties(LineCapStyle.Flat, LineCapStyle.Flat, LineCapStyle.Round, LineJoin.Round, 10, DashStyle.Custom, 0),
                dashes);
            CreateGeometries(factory);
        }
Beispiel #15
0
        protected override void CreateResources()
        {
            string text = "Hello World From ... DirectWrite!";

            _blackBrush = RenderTarget.CreateSolidColorBrush(Color.Black);
            _textLayout = DirectWriteFactory.CreateTextLayout(text, _textFormat, RenderTarget.GetSize());

            // (21, 12) is the range around "DirectWrite!"
            _textLayout.SetFontSize(100, (21, 12));
            _typography = DirectWriteFactory.CreateTypography();
            _typography.AddFontFeature(new FontFeature(FontFeatureTag.StylisticSet7, 1));
            _textLayout.SetTypography(_typography, (0, text.Length));
            _textLayout.SetUnderline(true, (21, 12));
            _textLayout.SetFontWeight(FontWeight.Bold, (21, 12));
        }
Beispiel #16
0
        protected override void OnRender(WindowRenderTarget renderTarget)
        {
            float y = 0;

            for (int index = 0; index < this._paragraphs.Count; ++index)
            {
                using (TextFormat textFormat = DirectWriteFactory.CreateTextFormat(
                           this._paragraphs[index].FontFamily,
                           this._paragraphs[index].Weight,
                           this._paragraphs[index].FontSize * 96f / 72f))
                {
                    textFormat.TextAlignment = _paragraphs[index].TextAlignment;
                    LineSpacing lineSpacing = textFormat.LineSpacing;

                    if (_paragraphs[index].LineSpacing == 0)
                    {
                        textFormat.LineSpacing = LineSpacing.Default;
                    }
                    else
                    {
                        textFormat.LineSpacing = new LineSpacing(_paragraphs[index].LineSpacing);
                    }

                    float width = ClientSize.Width / DpiScaleX - (_marginLeft + _marginRight);

                    using (TextLayout textLayout = DirectWriteFactory.CreateTextLayout(
                               this._paragraphs[index].Text,
                               textFormat,
                               width,
                               0))
                    {
                        y += _paragraphs[index].SpaceBefore;

                        renderTarget.DrawTextLayout(
                            new PointF(_marginLeft, y),
                            textLayout,
                            _blackBrush,
                            DrawTextOptions.None);

                        TextMetrics metrics = textLayout.Metrics;

                        y += metrics.Height + _paragraphs[index].SpaceAfter;
                    }
                }
            }
        }
Beispiel #17
0
        protected virtual void dispose(bool disposing)
        {
            if (!disposed)
            {
                disposed = true;

                if (disposing)
                {
                    if (DeviceContext != null)
                    {
                        Direct2dFactory.Dispose();
                        DirectWriteFactory.Dispose();
                        DeviceContext.Device.Dispose();
                        DeviceContext = null;
                    }
                }
            }
        }
        protected override void OnCreateDeviceIndependentResources(Direct2DFactory factory)
        {
            base.OnCreateDeviceIndependentResources(factory);

            this._redColorDrawingEffect   = new ColorDrawingEffect(Color.FromARGB(Colors.Red, 1));
            this._greenColorDrawingEffect = new ColorDrawingEffect(Color.FromARGB(Colors.Green, 1));
            this._blueColorDrawingEffect  = new ColorDrawingEffect(Color.FromARGB(Colors.Blue, 1));

            this._textFormat = DirectWriteFactory.CreateTextFormat("Gabriola",
                                                                   FontWeight.Normal,
                                                                   FontStyle.Normal,
                                                                   FontStretch.Normal,
                                                                   72);

            this._textFormat.TextAlignment      = TextAlignment.Center;
            this._textFormat.ParagraphAlignment = ParagraphAlignment.Center;

            float width  = ClientSize.Width / _dpiScaleX;
            float height = ClientSize.Height / _dpiScaleY;

            this._textLayout = DirectWriteFactory.CreateTextLayout(
                _text,
                this._textFormat,
                width,
                height);

            this._textLayout.SetFontSize(100, new TextRange(20, 6));

            this._textLayout.SetDrawingEffect(_blueColorDrawingEffect, new TextRange(6, 5));
            this._textLayout.SetDrawingEffect(_redColorDrawingEffect, new TextRange(20, 6));
            this._textLayout.SetDrawingEffect(_greenColorDrawingEffect, new TextRange(26, 5));

            ClientDrawingEffect effect = this._textLayout.GetDrawingEffect(7);

            this._textLayout.SetUnderline(true, new TextRange(20, 11));
            this._textLayout.SetFontWeight(FontWeight.Bold, new TextRange(20, 11));

            using (Typography typography = DirectWriteFactory.CreateTypography())
            {
                typography.AddFontFeature(FontFeatureTag.StylisticSet7, 1);
                this._textLayout.SetTypography(typography, new TextRange(0, _text.Length));
            }
        }
Beispiel #19
0
 private void CleanUpDeviceIndependentResourcesInternal()
 {
     OnCleanUpDeviceIndependentResources();
     if (_imagingFactory != null)
     {
         _imagingFactory.Dispose();
         _imagingFactory = null;
     }
     if (_directWriteFactory != null)
     {
         _directWriteFactory.Dispose();
         _directWriteFactory = null;
     }
     if (_factory != null)
     {
         _factory.Dispose();
         _factory = null;
     }
     _resourcesCreated = false;
 }
Beispiel #20
0
        private void CreateResources()
        {
            _textFormat = DirectWriteFactory.CreateTextFormat(
                FontName,
                FontSize,
                Bold ? FontWeight.Bold : FontWeight.Normal,
                Italic ? FontStyle.Italic : FontStyle.Normal);
            _textFormat.ParagraphAlignment = ParagraphAlignment.Center;
            _textFormat.TextAlignment      = TextAlignment.Center;

            float width  = ClientSize.Width / dpiScaleX;
            float height = ClientSize.Height / dpiScaleY;

            _textLayout = DirectWriteFactory.CreateTextLayout(
                Text,
                _textFormat,
                width,
                height);
            if (Underline)
            {
                _textLayout.SetUnderline(true, new TextRange(0, Text.Length));
            }
        }
 private void CleanUpDeviceIndependentResources()
 {
     if(this._deviceIndependedResourcesCreated)
         OnCleanUpDeviceIndependentResources();
     if (this._imagingFactory != null)
     {
         this._imagingFactory.Dispose();
         this._imagingFactory = null;
     }
     if (this._directWriteFactory != null)
     {
         this._directWriteFactory.Dispose();
         this._directWriteFactory = null;
     }
     if (this._renderTarget != null)
     {
         this._renderTarget.Dispose();
         this._renderTarget = null;
     }
     if (this._factory != null)
     {
         this._factory.Dispose();
         this._factory = null;
     }
 }
 static ClientDrawingEffectsControl()
 {
     DirectWriteFactory.GetDpiScale(out _dpiScaleX, out _dpiScaleY);
 }
Beispiel #23
0
 static SampleTextControl()
 {
     DirectWriteFactory.GetDpiScale(out dpiScaleX, out dpiScaleY);
 }
Beispiel #24
0
        private void StartPart2(string mutexName, string[] remainingArgs)
        {
            IAnimationService animationService;

            Memory.Initialize();
            CultureInfo info = AppSettings.Instance.UI.Language.Value;

            Thread.CurrentThread.CurrentUICulture     = info;
            CultureInfo.DefaultThreadCurrentUICulture = info;
            AppSettings.Instance.UI.Language.Value    = info;
            PdnResources.Culture = info;
            AppSettings.Instance.UI.ErrorFlagsAtStartup.Value = AppSettings.Instance.UI.ErrorFlags.Value;
            UIUtil.IsGetMouseMoveScreenPointsEnabled          = AppSettings.Instance.UI.EnableSmoothMouseInput.Value;
            if (!OS.VerifyFrameworkVersion(4, 6, 0, OS.FrameworkProfile.Full))
            {
                string message = PdnResources.GetString("Error.FXRequirement");
                MessageBoxUtil.ErrorBox(null, message);
                string fxurl = "http://www.microsoft.com/en-us/download/details.aspx?id=40773";
                () => ShellUtil.LaunchUrl2(null, fxurl).Eval <bool>().Observe();
            }
            else if (!OS.VerifyWindowsVersion(6, 1, 1))
            {
                string str4 = PdnResources.GetString("Error.OSRequirement");
                MessageBoxUtil.ErrorBox(null, str4);
            }
            else if (!Processor.IsFeaturePresent(ProcessorFeature.SSE))
            {
                string str5 = PdnResources.GetString("Error.SSERequirement");
                MessageBoxUtil.ErrorBox(null, str5);
            }
            else
            {
                string str;
                if (MultithreadedWorkItemDispatcher.IsSingleThreadForced && PdnInfo.IsFinalBuild)
                {
                    throw new PaintDotNet.InternalErrorException("MultithreadedWorkItemDispatcher.IsSingleThreadForced shouldn't be true for Final builds!");
                }
                if (RefTrackedObject.IsFullRefTrackingEnabled && PdnInfo.IsFinalBuild)
                {
                    throw new PaintDotNet.InternalErrorException("Full ref tracking should not be enabled for non-expiring builds!");
                }
                PaintDotNet.Base.AssemblyServices.RegisterProxies();
                PaintDotNet.Core.AssemblyServices.RegisterProxies();
                PaintDotNet.Framework.AssemblyServices.RegisterProxies();
                ObjectRefProxy.CloseRegistration();
                remainingArgs = TryRemoveArg(remainingArgs, "/showCrashLog=", out str);
                if (!string.IsNullOrWhiteSpace(str))
                {
                    DialogResult?nullable = null;
                    try
                    {
                        string fullPath = Path.GetFullPath(str);
                        if (File.Exists(fullPath))
                        {
                            nullable = new DialogResult?(CrashManager.ShowCrashLogDialog(fullPath));
                        }
                    }
                    catch (Exception exception)
                    {
                        try
                        {
                            MessageBox.Show(exception.ToString(), null, MessageBoxButtons.OK, MessageBoxIcon.Hand);
                        }
                        catch (Exception exception2)
                        {
                            Environment.FailFast(null, exception2);
                        }
                    }
                    DialogResult?nullable2 = nullable;
                    DialogResult oK        = DialogResult.OK;
                    if ((((DialogResult)nullable2.GetValueOrDefault()) == oK) ? nullable2.HasValue : false)
                    {
                        string[] args = new string[] { "/sleep=1000" };
                        StartNewInstance(null, false, args);
                    }
                }
                else
                {
                    string str2;
                    AppDomain.CurrentDomain.UnhandledException += new UnhandledExceptionEventHandler(Startup.OnCurrentDomainUnhandledException);
                    Application.SetUnhandledExceptionMode(UnhandledExceptionMode.CatchException, true);
                    Application.SetUnhandledExceptionMode(UnhandledExceptionMode.CatchException, false);
                    Application.ThreadException += new ThreadExceptionEventHandler(Startup.OnApplicationThreadException);
                    this.canUseCrashDialog       = true;
                    remainingArgs = TryRemoveArg(remainingArgs, "/test", out str2);
                    if (str2 != null)
                    {
                        PdnInfo.IsTestMode = true;
                    }
                    SingleInstanceManager disposeMe = new SingleInstanceManager(mutexName);
                    animationService = null;
                    try
                    {
                        DirectWriteFactory.DefaultDirectWriteSettingsController defaultDirectWriteSettingsController;
                        DrawingContext.DefaultDrawingContextSettingsController  defaultDrawingContextSettingsController;
                        IDisposable               updatesServiceShutdown;
                        IUpdatesServiceHost       updatesServiceHost;
                        PdnSynchronizationContext pdnSyncContext;
                        if (!disposeMe.IsFirstInstance)
                        {
                            disposeMe.FocusFirstInstance();
                            foreach (string str7 in remainingArgs)
                            {
                                disposeMe.SendInstanceMessage(str7, 30);
                            }
                            disposeMe.Dispose();
                            disposeMe = null;
                        }
                        else
                        {
                            CleanupService.Initialize();
                            ResourcesService.Initialize();
                            UserFilesService.Initialize();
                            UserPalettesService.Initialize();
                            animationService           = AnimationService.Initialize();
                            animationService.IsEnabled = true;
                            Document.Initialize(PdnInfo.Version);
                            Layer.Initialize(PdnResources.GetString("Layer.BackgroundLayer.DefaultName"));
                            Effect.SetDefaultServiceProviderValueFactory(effect => new ServiceProviderForEffects());
                            defaultDirectWriteSettingsController = DirectWriteFactory.GetDefaultSettingsController();
                            defaultDirectWriteSettingsController.DefaultCulture = AppSettings.Instance.UI.Language.Value;
                            AppSettings.Instance.UI.Language.ValueChangedT     += (sender, e) => (defaultDirectWriteSettingsController.DefaultCulture = e.NewValue);
                            AeroColors.CurrentScheme = AppSettings.Instance.UI.AeroColorScheme.Value;
                            AppSettings.Instance.UI.AeroColorScheme.ValueChangedT += (sender, e) => (AeroColors.CurrentScheme = e.NewValue);
                            defaultDrawingContextSettingsController = DrawingContext.GetDefaultSettingsController();
                            defaultDrawingContextSettingsController.DefaultTextAntialiasMode = AppSettings.Instance.UI.DefaultTextAntialiasMode.Value;
                            AppSettings.Instance.UI.DefaultTextAntialiasMode.ValueChangedT  += delegate(object sender, ValueChangedEventArgs <TextAntialiasMode> e) {
                                defaultDrawingContextSettingsController.DefaultTextAntialiasMode = e.NewValue;
                                foreach (Form form in Application.OpenForms)
                                {
                                    form.PerformLayoutRecursiveDepthFirst("TextAntialiasMode");
                                    form.Invalidate(true);
                                }
                            };
                            defaultDrawingContextSettingsController.DefaultTextRenderingMode = AppSettings.Instance.UI.DefaultTextRenderingMode.Value;
                            AppSettings.Instance.UI.DefaultTextRenderingMode.ValueChangedT  += delegate(object sender, ValueChangedEventArgs <TextRenderingMode> e) {
                                defaultDrawingContextSettingsController.DefaultTextRenderingMode = e.NewValue;
                                foreach (Form form in Application.OpenForms)
                                {
                                    form.PerformLayoutRecursiveDepthFirst("TextRenderingMode");
                                    form.Invalidate(true);
                                }
                            };
                            PaintDotNet.IndirectUI.ControlInfo.Initialize(Assembly.GetExecutingAssembly());
                            PdnBaseForm.SetStaticHelpRequestedHandler(delegate(object sender, HelpEventArgs e) {
                                HelpService.Instance.ShowHelp(sender as IWin32Window);
                                e.Handled = true;
                            });
                            Control control = new Control();
                            SynchronizationContext current = SynchronizationContext.Current;
                            PdnSynchronizationContextController controller = PdnSynchronizationContext.Install(new WaitForMultipleObjectsExDelegate(WaitHelper.WaitForMultipleObjectsEx), new SleepExDelegate(WaitHelper.SleepEx));
                            pdnSyncContext         = controller.Instance;
                            this.mainForm          = new MainForm(remainingArgs);
                            updatesServiceHost     = this.mainForm.CreateUpdatesServiceHost();
                            updatesServiceShutdown = null;
                            EventHandler initUpdatesOnShown = null;
                            initUpdatesOnShown = delegate(object sender, EventArgs e) {
                                this.mainForm.Shown   -= initUpdatesOnShown;
                                updatesServiceShutdown = UpdatesService.Initialize(updatesServiceHost);
                            };
                            this.mainForm.Shown += initUpdatesOnShown;
                            this.mainForm.SingleInstanceManager = disposeMe;
                            disposeMe = null;
                            int num        = (int)Math.Floor((double)8.3333333333333339);
                            int intervalMs = (int)Math.Floor((double)50.0);
                            using (AnimationTimerUpdateThread timerThread = new AnimationTimerUpdateThread(intervalMs, false))
                            {
                                < > c__DisplayClass20_1 class_3;
Beispiel #25
0
 public HelloWorld() : base()
 {
     _textFormat = DirectWriteFactory.CreateTextFormat("Gabriola", fontSize: 64);
     _textFormat.SetTextAlignment(TextAlignment.Center);
     _textFormat.SetParagraphAlignment(ParagraphAlignment.Center);
 }
Beispiel #26
0
 protected override void OnCreateDeviceIndependentResources(Direct2DFactory factory)
 {
     base.OnCreateDeviceIndependentResources(factory);
     _textFormat = DirectWriteFactory.CreateTextFormat("Gabriola", 96);
     _textLayout = DirectWriteFactory.CreateTextLayout(_text, _textFormat, float.MaxValue, float.MaxValue);
 }
 static MultiformattedTextControl()
 {
     DirectWriteFactory.GetDpiScale(out _dpiScaleX, out _dpiScaleY);
 }
Beispiel #28
0
 static CustomTextControl()
 {
     DirectWriteFactory.GetDpiScale(out _dpiScaleX, out _dpiScaleY);
 }
 static InlineObjectControl()
 {
     DirectWriteFactory.GetDpiScale(out _dpiScaleX, out _dpiScaleY);
 }
Beispiel #30
0
 static MainWindow()
 {
     DirectWriteFactory.GetDpiScale(out DpiScaleX, out DpiScaleY);
 }