示例#1
0
        private void UnloadResources()
        {
            m_compositeEffect.Dispose();
            m_affineTransformEffect.Dispose();
            m_ShadowFullScreen.Dispose();
            m_Shadow.Dispose();
            m_Bitmap1FullScreen.Dispose();
            m_Bitmap1.Dispose();
            fontFamily.Dispose();
            m_textFormat15.Dispose();
            m_textFormat10.Dispose();
            roundedRecInColor.Dispose();
            roundedRecOutColor.Dispose();
            m_textBrush.Dispose();

            if (m_TitleName != null)
            {
                m_TitleName.Dispose();
            }
            if (m_VideoBitmap != null)
            {
                m_VideoBitmap.Dispose();
            }
            if (m_CDGBitmap != null)
            {
                m_CDGBitmap.Dispose();
            }
        }
示例#2
0
 protected override void OnCleanUpDeviceIndependentResources()
 {
     base.OnCleanUpDeviceIndependentResources();
     _textAnalyzer.Dispose();
     _textLayout.Dispose();
     _textFormat.Dispose();
 }
        public override void Dispose()
        {
            format?.Dispose();
            format = null;

            base.Dispose();
        }
示例#4
0
 public void Dispose()
 {
     watch.Stop();
     textFormat.Dispose();
     foregroundBrush.Dispose();
     barBrush.Dispose();
 }
示例#5
0
文件: Base.cs 项目: TETYYS/socon
            public static Tuple <TextLayout, TextFormat> RebaseText(TextLayout Tl, TextFormat Tf, string Text)
            {
                Tf.Dispose();
                var tfNew = new TextFormat(
                    Base.DWFactory,
                    Tl.FontFamilyName,
                    Tl.FontCollection,
                    Tl.FontWeight,
                    Tl.FontStyle,
                    Tl.FontStretch,
                    Tl.FontSize,
                    Tl.LocaleName
                    )
                {
                    TextAlignment      = Tl.TextAlignment,
                    ParagraphAlignment = Tl.ParagraphAlignment,
                    FlowDirection      = Tl.FlowDirection,
                    IncrementalTabStop = Tl.IncrementalTabStop,
                    ReadingDirection   = Tl.ReadingDirection,
                    WordWrapping       = Tl.WordWrapping
                };

                var tlNew = new TextLayout(
                    Base.DWFactory,
                    Text,
                    tfNew,
                    Tl.MaxWidth,
                    Tl.MaxHeight);

                Tl.Dispose();
                return(Tuple.Create(tlNew, tfNew));
            }
示例#6
0
 //Dispose of resources.
 public void Dispose()
 {
     textSceneColorBrush.Dispose();
     textFormatTitle.Dispose();
     textFormatHorizontal.Dispose();
     textFormatVertical.Dispose();
 }
        private void Dispose(bool disposing)
        {
            if (!this.disposed)
            {
                if (disposing)
                {
                    //There are no managed resources to dispose
                }

                Font.Dispose();
                ReferenceCount--;
                foreach (var Table in CharTables)
                {
                    Table.Value.SRV.Dispose();
                    Table.Value.Texture.Dispose();
                }
                if (ReferenceCount <= 0)
                {
                    D3DDevice10.Dispose();
                    WriteFactory.Dispose();
                    D2DFactory.Dispose();
                }
            }
            this.disposed = true;
        }
示例#8
0
        protected void DrawObjectUnselected(RenderTarget rt, LiveRect r)
        {
            var brush      = Color.Pink.SolidBrush(rt);
            var frameBrush = Color.White.SolidBrush(rt);

            rt.FillRectangle(r.Rectangle.ToRectF(), brush);
            rt.DrawRectangle(r.Rectangle.ToRectF(), frameBrush, 1);
            brush.Dispose();
            frameBrush.Dispose();

            var           textBrush        = Color.White.SolidBrush(rt);
            DWriteFactory dw               = DWriteFactory.CreateFactory();
            TextFormat    normalTextFormat = dw.CreateTextFormat("微软雅黑", 20);

            if (r.Rectangle.Bottom > Mapper.GetScreenY(0))
            {
                rt.DrawText(r.Value.ToString(), normalTextFormat, new RectangleF(r.Rectangle.X - 5, r.Rectangle.Top - 40, 100, 100).ToRectF(), textBrush);
            }
            else
            {
                rt.DrawText(r.Value.ToString(), normalTextFormat, new RectangleF(r.Rectangle.X - 5, r.Rectangle.Bottom + 20, 100, 100).ToRectF(), textBrush);
            }
            dw.Dispose();
            textBrush.Dispose();
            normalTextFormat.Dispose();
        }
示例#9
0
        private void ReleaseResources()
        {
            ReleaseD2DObjects();
            ReleaseRenderingObjects();

            void ReleaseD2DObjects()
            {
                renderTarget2d?.Dispose();
                surface?.Dispose();
                renderView?.Dispose();
                backBuffer?.Dispose();
                swapChain?.Dispose();
                device?.Dispose();
                factoryWrite?.Dispose();
                factory2d?.Dispose();
                factory?.Dispose();
            }

            void ReleaseRenderingObjects()
            {
                foreach (var cell in cells)
                {
                    cell.Dispose();
                }
                textFormat?.Dispose();
                sColorBrush?.Dispose();
            }
        }
示例#10
0
 public override void Dispose()
 {
     base.Dispose();
     TargetBrush.Dispose();
     TagBrush.Dispose();
     TextBrush.Dispose();
     TextFormat.Dispose();
 }
示例#11
0
 public void Dispose()
 {
     if (Format != null && !Format.Disposed)
     {
         Format.Dispose();
     }
     GC.SuppressFinalize(this);
 }
示例#12
0
        private void setupInstance(bool deleteOld = false)
        {
            if (deleteOld)
            {
                try
                {
                    _brush.Dispose();
                    _font.Dispose();

                    _fontFactory.Dispose();
                    _factory.Dispose();
                    _device.Dispose();
                }
                catch
                {
                }
            }

            _factory     = new Factory(SharpDX.Direct2D1.FactoryType.MultiThreaded, DebugLevel.None);
            _fontFactory = new FontFactory();

            RECT bounds = default(RECT);

            User32.GetWindowRect(TargetHandle, out bounds);

            _targetProperties = new HwndRenderTargetProperties()
            {
                Hwnd           = TargetHandle,
                PixelSize      = new Size2(Math.Abs(bounds.Right - bounds.Left), Math.Abs(bounds.Bottom - bounds.Top)),
                PresentOptions = VSync ? PresentOptions.None : PresentOptions.Immediately
            };

            var renderTargetProperties = new RenderTargetProperties(
                RenderTargetType.Hardware,
                new PixelFormat(Format.B8G8R8A8_UNorm, SharpDX.Direct2D1.AlphaMode.Premultiplied),
                0, 0,
                RenderTargetUsage.None, FeatureLevel.Level_DEFAULT
                );

            _device = new WindowRenderTarget(_factory, renderTargetProperties, _targetProperties);

            _device.TextAntialiasMode = SharpDX.Direct2D1.TextAntialiasMode.Aliased;
            _device.AntialiasMode     = AntialiasMode.Aliased;

            _brush = new SolidColorBrush(_device, new RawColor4(0, 0, 0, 0));
        }
示例#13
0
        public override void LoadContent()
        {
            if (DebugTextFormat != null && !DebugTextFormat.IsDisposed)
            {
                DebugTextFormat.Dispose();
            }
            DebugTextFormat = new TextFormat(Surface.FactoryDirectWrite, "Calibri", 16)
            {
                TextAlignment = TextAlignment.Leading, ParagraphAlignment = ParagraphAlignment.Near
            };

            WhiteBrush = new SolidColorBrush(Surface.RenderTarget2D, SharpDX.Color.White);
            RedBrush   = new SolidColorBrush(Surface.RenderTarget2D, SharpDX.Color.Red);
            GreenBrush = new SolidColorBrush(Surface.RenderTarget2D, SharpDX.Color.LimeGreen);
            BlueBrush  = new SolidColorBrush(Surface.RenderTarget2D, SharpDX.Color.Blue);
            GrayBrush  = new SolidColorBrush(Surface.RenderTarget2D, new RawColor4(.3f, .3f, .3f, 1));
        }
        public static void DrawSimpleTip(this MusicCanvasControl canvas, string text, RawVector2?pos = new RawVector2?())
        {
            if (MusicCanvasControl.EnableControlTip && canvas.IsAltKeyPressed())
            {
                Trimming     trimming;
                InlineObject obj2;
                if (!pos.HasValue)
                {
                    Point point = canvas.PointToClient(Control.MousePosition);
                    pos = new RawVector2((float)(point.X + 0x18), (float)(point.Y - 0x18));
                }
                RenderTarget renderTarget = canvas.RenderTarget2D;
                SharpDX.DirectWrite.Factory factoryDWrite = canvas.FactoryDWrite;
                TextFormat textFormat = new TextFormat(factoryDWrite, "微软雅黑", FontWeight.Bold, SharpDX.DirectWrite.FontStyle.Normal, FontStretch.Normal, 12f);
                textFormat.GetTrimming(out trimming, out obj2);
                trimming.Granularity = TrimmingGranularity.Word;
                textFormat.SetTrimming(trimming, obj2);
                textFormat.TextAlignment      = TextAlignment.Center;
                textFormat.ParagraphAlignment = ParagraphAlignment.Center;
                TextLayout layout = new TextLayout(factoryDWrite, text, textFormat, 1920f, 1080f);
                textFormat.TextAlignment      = TextAlignment.Leading;
                textFormat.ParagraphAlignment = ParagraphAlignment.Far;
                TextLayout textLayout = new TextLayout(factoryDWrite, text, textFormat, layout.Metrics.Width, layout.Metrics.Height);
                layout.Dispose();
                RawVector2 origin = new RawVector2(pos.Value.X, pos.Value.Y);
                switch (textFormat.TextAlignment)
                {
                case TextAlignment.Trailing:
                    origin.X = pos.Value.X - textLayout.Metrics.Width;
                    break;

                case TextAlignment.Center:
                case TextAlignment.Justified:
                    origin.X = pos.Value.X - (textLayout.Metrics.Width / 2f);
                    break;
                }
                switch (textFormat.ParagraphAlignment)
                {
                case ParagraphAlignment.Far:
                    origin.Y = pos.Value.Y - textLayout.Metrics.Height;
                    break;

                case ParagraphAlignment.Center:
                    origin.Y = pos.Value.Y - (textLayout.Metrics.Height / 2f);
                    break;
                }
                origin.X += 4f;
                origin.Y += 4f;
                textFormat.Dispose();
                RawRectangleF rectF = new RawRectangleF(pos.Value.X, pos.Value.Y - textLayout.Metrics.Height, (pos.Value.X + textLayout.Metrics.Width) + 8f, pos.Value.Y + 8f);
                canvas.FillRoundedRectangle(rectF, 4f, Color.FromArgb(150, 0x1f, 0x1f, 0x22));
                canvas.DrawRoundedRectangle(rectF, 4f, Color.FromArgb(150, 0xe9, 0xe9, 0xe9), 2f);
                SolidColorBrush defaultForegroundBrush = new SolidColorBrush(renderTarget, Color.FromArgb(250, Color.DarkGray).ToRawColor4(1f));
                renderTarget.DrawTextLayout(origin, textLayout, defaultForegroundBrush, DrawTextOptions.Clip);
                defaultForegroundBrush.Dispose();
                textLayout.Dispose();
            }
        }
示例#15
0
        public void ToogleVisibility()
        {
            if (IsEnabled)
            {
                IsEnabled = false;
                TextRect.Dispose();
                LayoutRect.Dispose();
                FontFactory.Dispose();
                TextRectangleBrush.Dispose();
                consoleTextFormat.Dispose();
                historyTextFormat.Dispose();
                LayoutBrush.Dispose();
                TextBrush.Dispose();
            }
            else
            {
                TextRect = new RoundedRectangleGeometry(d2dFactory, new RoundedRectangle()
                {
                    RadiusX = 1,
                    RadiusY = 1,
                    Rect    = new RectangleF(10, gameInst.RenderForm.Height - 80, gameInst.RenderForm.Width - 10 * 4, 30)
                });

                LayoutRect = new RoundedRectangleGeometry(d2dFactory, new RoundedRectangle()
                {
                    RadiusX = 0,
                    RadiusY = 0,
                    Rect    = new RectangleF(0, 0, gameInst.RenderForm.Width, gameInst.RenderForm.Height)
                });

                FontFactory = new DirectWrite.Factory();

                consoleTextFormat = new TextFormat(FontFactory, "Segoe UI", 20.0f);
                ConsoleLayout     = new TextLayout(FontFactory, ConsoleString, consoleTextFormat, gameInst.RenderForm.Width - 40, 40);

                historyTextFormat = new TextFormat(FontFactory, "Segoe UI", 12.0f);
                HistoryLayout     = new TextLayout(FontFactory, HistoryText, historyTextFormat, gameInst.RenderForm.Width - 40, gameInst.RenderForm.Height - 150.0f);

                TextRectangleBrush = new SolidColorBrush(d2dRenderTarget, Color.Black);
                LayoutBrush        = new SolidColorBrush(d2dRenderTarget, new RawColor4(0.1f, 0.1f, 0.1f, 0.85f));
                TextBrush          = new SolidColorBrush(d2dRenderTarget, Color.Red);

                IsEnabled = true;
            }
        }
示例#16
0
 public void Dispose()
 {
     brush.Dispose();
     brushRed.Dispose();
     _tyNear.Dispose();
     _tyCenter.Dispose();
     formatNear.Dispose();
     formatCenter.Dispose();
 }
 /// <summary>
 /// Пересоздает класс в котором храняться данные о формате выводимого теста.
 /// </summary>
 private void InitTextFormat()
 {
     _TextFormat?.Dispose();
     _TextFormat = new TextFormat(_FactoryDWrite, TextFont, TextSize)
     {
         TextAlignment      = TextAlignment.Leading,
         ParagraphAlignment = ParagraphAlignment.Near
     };
 }
 protected override void OnCleanUpDeviceIndependentResources()
 {
     base.OnCleanUpDeviceIndependentResources();
     _textFormat.Dispose();
     _textLayout.Dispose();
     _blueColorDrawingEffect.Dispose();
     _redColorDrawingEffect.Dispose();
     _greenColorDrawingEffect.Dispose();
 }
示例#19
0
 //============================================================
 // <T>释放资源。</T>
 //============================================================
 public override void Dispose()
 {
     if (_native != null)
     {
         _native.Dispose();
         _native = null;
     }
     base.Dispose();
 }
示例#20
0
 public void Dispose()
 {
     Font.Dispose();
     foreach (var Table in CharTables)
     {
         Table.Value.SRV.Dispose();
         Table.Value.Texture.Dispose();
     }
 }
示例#21
0
 public void Dispose()
 {
     if (_disposed)
     {
         return;
     }
     _disposed = true;
     _tf.Dispose();
 }
示例#22
0
        /// <summary>
        /// Releases all resources used by this Font.
        /// </summary>
        /// <param name="disposing">A Boolean value indicating whether this is called from the destructor.</param>
        protected virtual void Dispose(bool disposing)
        {
            if (!disposedValue)
            {
                TextFormat?.Dispose();

                disposedValue = true;
            }
        }
示例#23
0
        protected override void InitializeComponents(RenderTarget rt)
        {
            base.InitializeComponents(rt);
            normalLineBrush?.Dispose();
            selectedLineBrush?.Dispose();
            normalTextFormat?.Dispose();
            selectedTextFormat?.Dispose();
            normalTextBrush?.Dispose();
            selectedTextBrush?.Dispose();

            normalLineBrush   = Model.LineColor.SolidBrush(rt);
            selectedLineBrush = Model.SelectedLineColor.SolidBrush(rt);
            normalTextBrush   = Model.FontColor.SolidBrush(rt);
            selectedTextBrush = Model.SelectedFontColor.SolidBrush(rt);
            using (var dw = DWriteFactory.CreateFactory())
            {
                normalTextFormat   = dw.CreateTextFormat(Model.FontName, Model.FontSize);
                selectedTextFormat = dw.CreateTextFormat(Model.SelectedFontName, Model.SelectedFontSize);
            }
        }
示例#24
0
 // Dispose of resources.
 public void Dispose()
 {
     _textRenderTarget.Dispose();
     _textSceneColorBrush.Dispose();
     _textFormatTitle.Dispose();
     _textFormatHorizontal.Dispose();
     _textFormatVertical.Dispose();
     _ambientLight.Dispose();
     _barOutlineLight.Dispose();
     _barLight.Dispose();
 }
示例#25
0
 /// <summary>
 /// Dispose anything to do with the overlay form
 /// </summary>
 private static void DisposeOverlayComponents()
 {
     _renderTarget.Dispose();
     _renderForm.Dispose();
     _newDevice.ImmediateContext.ClearState();
     _newDevice.ImmediateContext.Flush();
     _newDevice.Dispose();
     _newSwapChain.Dispose();
     _fontFactory.Dispose();
     _font.Dispose();
 }
示例#26
0
 public override void Dispose()
 {
     base.Dispose();
     normalLineBrush?.Dispose();
     selectedLineBrush?.Dispose();
     normalTextFormat?.Dispose();
     selectedTextFormat?.Dispose();
     normalTextBrush?.Dispose();
     selectedTextBrush?.Dispose();
     strokeStyle?.Dispose();
 }
示例#27
0
        protected override void Dispose(bool disposing)
        {
            if (IsDisposed)
            {
                textBrush?.Dispose();
                textFormat?.Dispose();
                bitmap?.Dispose();
                //fileSystemWatcher?.Dispose();
            }

            base.Dispose(disposing);
        }
示例#28
0
 protected override void OnCleanUpDeviceIndependentResources()
 {
     base.OnCleanUpDeviceIndependentResources();
     _strokeStyle.Dispose();
     _textFormat.Dispose();
     _circleGeometry1.Dispose();
     _circleGeometry2.Dispose();
     _geometryUnion.Dispose();
     _geometryIntersect.Dispose();
     _geometryXor.Dispose();
     _geometryExclude.Dispose();
 }
示例#29
0
        public void Dispose()
        {
            if (pinnedMemBuffer.IsAllocated)
            {
                pinnedMemBuffer.Free();
            }

            TryReleaseFrame();
            if (Settings.SettingsHwnd != IntPtr.Zero)  // restore window background color
            {
                try {
                    device?.ImmediateContext.ClearRenderTargetView(renderTarget, SharpDX.Color.WhiteSmoke);
                    renderWindow?.Present(0, PresentFlags.None);
                } catch { }
            }

            Settings.Model.PropertyChanged -= LedsChanged;
            fpsCounter?.Dispose();
            fpsColor?.Dispose();
            fpsFont?.Dispose();
            renderOverlay?.Dispose();
            renderTarget?.Dispose();
            renderTexture?.Dispose();
            renderWindow?.Dispose();

            try {
                device?.ImmediateContext?.ClearState();
                device?.ImmediateContext?.Flush();
                device?.ImmediateContext?.Dispose();
            } catch { }

            adapter?.Dispose();
            output?.Dispose();
            device?.Dispose();
            duplicator?.Dispose();
            capture?.Dispose();
            scaler?.Dispose();
            gpuTexture?.Dispose();
            cpuTexture?.Dispose();
        }
示例#30
0
        protected override void OnRender(ChartControl chartControl, ChartScale chartScale)
        {
            // Set text to chart label color and font
            TextFormat textFormat = chartControl.Properties.LabelFont.ToDirectWriteTextFormat();

            // Loop through each Plot Values on the chart
            for (int seriesCount = 0; seriesCount < Values.Length; seriesCount++)
            {
                double y                  = -1;
                double startX             = -1;
                double endX               = -1;
                int    firstBarIdxToPaint = -1;
                int    firstBarPainted    = ChartBars.FromIndex;
                int    lastBarPainted     = ChartBars.ToIndex;
                Plot   plot               = Plots[seriesCount];

                for (int i = newSessionBarIdxArr.Count - 1; i >= 0; i--)
                {
                    int prevSessionBreakIdx = newSessionBarIdxArr[i];
                    if (prevSessionBreakIdx <= lastBarPainted)
                    {
                        firstBarIdxToPaint = prevSessionBreakIdx;
                        break;
                    }
                }

                // Loop through visble bars to render plot values
                for (int idx = lastBarPainted; idx >= Math.Max(firstBarPainted, lastBarPainted - width); idx--)
                {
                    if (idx < firstBarIdxToPaint)
                    {
                        break;
                    }

                    startX = chartControl.GetXByBarIndex(ChartBars, idx);
                    endX   = chartControl.GetXByBarIndex(ChartBars, lastBarPainted);
                    double val = Values[seriesCount].GetValueAt(idx);
                    y = chartScale.GetYByValue(val);
                }

                // Draw pivot lines
                Point startPoint = new Point(startX, y);
                Point endPoint   = new Point(endX, y);
                RenderTarget.DrawLine(startPoint.ToVector2(), endPoint.ToVector2(), plot.BrushDX, plot.Width, plot.StrokeStyle);

                // Draw pivot text
                TextLayout textLayout = new TextLayout(Globals.DirectWriteFactory, plot.Name, textFormat, ChartPanel.W, textFormat.FontSize);
                RenderTarget.DrawTextLayout(startPoint.ToVector2(), textLayout, plot.BrushDX);
                textLayout.Dispose();
            }
            textFormat.Dispose();
        }
示例#31
0
        /// <summary>
        /// Measures the text.
        /// </summary>
        /// <param name="text">The text.</param>
        /// <param name="fontFamily">The font family.</param>
        /// <param name="fontSize">Size of the font.</param>
        /// <param name="fontWeight">The font weight.</param>
        /// <returns>The text size.</returns>
        public OxySize MeasureText(string text, string fontFamily, double fontSize, double fontWeight)
        {
            if (string.IsNullOrWhiteSpace(fontFamily))
            {
                fontFamily = "Arial";
            }

            if (text == null)
            {
                text = string.Empty;
            }

            var format = new TextFormat(this.dwtFactory, fontFamily, GetFontWeight(fontWeight), FontStyle.Normal, FontStretch.Normal, (float)fontSize);

            var layout = new TextLayout(this.dwtFactory, text, format, 1000f, 1000f);
            var res = new OxySize(layout.Metrics.Width, layout.Metrics.Height);

            format.Dispose();
            layout.Dispose();

            return res;
        }
示例#32
0
        /// <summary>
        /// Draws the text.
        /// </summary>
        /// <param name="p">The position.</param>
        /// <param name="text">The text.</param>
        /// <param name="fill">The fill color.</param>
        /// <param name="fontFamily">The font family.</param>
        /// <param name="fontSize">Size of the font.</param>
        /// <param name="fontWeight">The font weight.</param>
        /// <param name="rotate">The rotation angle.</param>
        /// <param name="halign">The horizontal alignment.</param>
        /// <param name="valign">The vertical alignment.</param>
        /// <param name="maxSize">The maximum size of the text.</param>
        public void DrawText(
            ScreenPoint p,
            string text,
            OxyColor fill,
            string fontFamily,
            double fontSize,
            double fontWeight,
            double rotate,
            OxyPlot.HorizontalAlignment halign,
            OxyPlot.VerticalAlignment valign,
            OxySize? maxSize)
        {
            if (string.IsNullOrWhiteSpace(fontFamily))
            {
                fontFamily = "Arial";
            }

            if (text == null)
            {
                text = string.Empty;
            }

            var format = new TextFormat(this.dwtFactory, fontFamily, GetFontWeight(fontWeight), FontStyle.Normal, FontStretch.Normal, (float)fontSize);
            var maxWidth = 1000f;
            var maxHeight = 1000f;
            if (maxSize != null)
            {
                maxHeight = (float)maxSize.Value.Height;
                maxWidth = (float)maxSize.Value.Width;
            }

            var layout = new TextLayout(this.dwtFactory, text, format, maxWidth, maxHeight);

            var size = new Size2F(layout.Metrics.Width, layout.Metrics.Height);
            if (maxSize != null)
            {
                if (size.Width > maxSize.Value.Width)
                {
                    size.Width = (float)maxSize.Value.Width;
                }

                if (size.Height > maxSize.Value.Height)
                {
                    size.Height = (float)maxSize.Value.Height;
                }
            }

            float dx = 0;
            if (halign == OxyPlot.HorizontalAlignment.Center)
            {
                dx = -size.Width / 2;
            }

            if (halign == OxyPlot.HorizontalAlignment.Right)
            {
                dx = -size.Width;
            }

            float dy = 0;
            if (valign == OxyPlot.VerticalAlignment.Middle)
            {
                dy = -size.Height / 2;
            }

            if (valign == OxyPlot.VerticalAlignment.Bottom)
            {
                dy = -size.Height;
            }

            this.renderUnits.Add(new TextRenderUnit(layout, this.GetBrush(fill), Matrix3x2.Translation(dx, dy) * Matrix3x2.Rotation((float)rotate) * Matrix3x2.Translation(p.ToVector2())));
            format.Dispose();
        }