コード例 #1
0
        /// <summary>
        /// Shows the specified new map size and updates the ranges of all <see
        /// cref="NumericUpDown"/> controls on the <see cref="SizeTab"/> page.</summary>
        /// <param name="newSize">
        /// The dimensions to show in the "New Size" <see cref="GroupBox"/>.</param>

        private void ShowMapSize(SizeI newSize)
        {
            // show new map size
            NewWidthBox.Text  = newSize.Width.ToString("N0", ApplicationInfo.Culture);
            NewHeightBox.Text = newSize.Height.ToString("N0", ApplicationInfo.Culture);

            // original and maximum map size
            SizeI oldSize = this._originalMapSize;
            int   maxSize = SimpleXml.MaxSizeIValue;

            // compute new edge offsets
            int leftEdge   = -oldSize.Width + MoveLeft;
            int rightEdge  = oldSize.Width + MoveRight;
            int topEdge    = -oldSize.Height + MoveTop;
            int bottomEdge = oldSize.Height + MoveBottom;

            // update range for left edge
            LeftUpDown.Minimum = rightEdge - maxSize;
            LeftUpDown.Maximum = rightEdge - 1;

            // update range for right edge
            RightUpDown.Minimum = leftEdge + 1;
            RightUpDown.Maximum = leftEdge + maxSize;

            // update range for top edge
            TopUpDown.Minimum = bottomEdge - maxSize;
            TopUpDown.Maximum = bottomEdge - 1;

            // update range for bottom edge
            BottomUpDown.Minimum = topEdge + 1;
            BottomUpDown.Maximum = topEdge + maxSize;
        }
コード例 #2
0
ファイル: SampleForm.cs プロジェクト: CrazyLiu00/GMap
        public SampleForm(Base parent)
            : base(parent, "Sample Form", true)
        {
            DeleteOnClose = true;

            Size = new SizeI(530, 290);
        }
コード例 #3
0
        /// <summary>
        /// Raises and handles the <see cref="Window.Closing"/> event.</summary>
        /// <param name="args">
        /// A <see cref="CancelEventArgs"/> object containing event data.</param>
        /// <remarks><para>
        /// <b>OnClosing</b> raises the <see cref="Window.Closing"/> event by calling the base class
        /// implementation of <see cref="Window.OnClosing"/> with the specified <paramref
        /// name="args"/>.
        /// </para><para>
        /// If the event was not requested to <see cref="CancelEventArgs.Cancel"/>, <b>OnClosing</b>
        /// handles the <see cref="Window.Closing"/> event by clearing the <see cref="DataChanged"/>
        /// flag and resetting all <b>Move</b> properties to zero if the <see
        /// cref="Window.DialogResult"/> is not <c>true</c>, indicating that the user cancelled the
        /// dialog and wants to discard all changes.
        /// </para><para>
        /// Otherwise, <b>OnClosing</b> checks whether the current values of the <b>Move</b>
        /// properties would result in a map size that is less than one or greater than <see
        /// cref="SimpleXml.MaxSizeIValue"/> in either dimension, and cancels the event if so.
        /// </para></remarks>

        protected override void OnClosing(CancelEventArgs args)
        {
            base.OnClosing(args);
            if (args.Cancel)
            {
                return;
            }

            // user cancelled dialog, ignore changes
            if (DialogResult != true)
            {
                DataChanged = false;
                MoveLeft    = MoveRight = MoveTop = MoveBottom = 0;
                return;
            }

            // check against minimum and maximum size
            SizeI mapSize = MapGrid.Size;

            if (mapSize.Width < 1 || mapSize.Width > SimpleXml.MaxSizeIValue ||
                mapSize.Height < 1 || mapSize.Height > SimpleXml.MaxSizeIValue)
            {
                string message = String.Format(ApplicationInfo.Culture,
                                               Global.Strings.DialogMapBoundsInvalid, SimpleXml.MaxSizeIValue);

                MessageBox.Show(this, message, Global.Strings.TitleMapBoundsInvalid,
                                MessageBoxButton.OK, MessageBoxImage.Information);

                args.Cancel = true;
            }
        }
コード例 #4
0
ファイル: Direct2DRenderer.cs プロジェクト: WildGenie/carmp
 public void Resize(SizeI pSize)
 {
     if (_renderer is HwndRenderTarget)
     {
         (_renderer as HwndRenderTarget).Resize(new SizeU((uint)pSize.Width, (uint)pSize.Height));
     }
 }
 public RectI(PointI pos, SizeI size) : this(IronSightEnginePINVOKE.new_RectI__SWIG_3(PointI.getCPtr(pos), SizeI.getCPtr(size)), true)
 {
     if (IronSightEnginePINVOKE.SWIGPendingException.Pending)
     {
         throw IronSightEnginePINVOKE.SWIGPendingException.Retrieve();
     }
 }
コード例 #6
0
ファイル: BitmapBuffer.cs プロジェクト: prepare/Tektosyne.NET
        /// <summary>
        /// Grows the <see cref="BitmapBuffer"/> to the specified size.</summary>
        /// <param name="width">
        /// The new minimum <see cref="SizeI.Width"/> component of the <see cref="Size"/> property.
        /// </param>
        /// <param name="height">
        /// The new minimum <see cref="SizeI.Height"/> component of the <see cref="Size"/> property.
        /// </param>
        /// <remarks><para>
        /// <b>Grow</b> sets the <see cref="Size"/> property to the specified <paramref
        /// name="width"/> and <paramref name="height"/> if one or both exceed the corresponding
        /// <see cref="Size"/> component; otherwise, <b>Grow</b> does nothing.
        /// </para><para>
        /// As usual, changing <see cref="Size"/> reallocates both the <see cref="Pixels"/> array
        /// and the associated <see cref="Bitmap"/>, if any. Their existing contents are lost.
        /// </para></remarks>

        public void Grow(int width, int height)
        {
            if (_size.Width < width || _size.Height < height)
            {
                Size = new SizeI(width, height);
            }
        }
 public void Inflate(SizeI s)
 {
     IronSightEnginePINVOKE.RectI_Inflate__SWIG_0(swigCPtr, SizeI.getCPtr(s));
     if (IronSightEnginePINVOKE.SWIGPendingException.Pending)
     {
         throw IronSightEnginePINVOKE.SWIGPendingException.Retrieve();
     }
 }
コード例 #8
0
        /// <summary>
        /// ワールドマップ初期化
        /// </summary>
        /// <param name="mapFname">ワールドBMPファイル名</param>
        public WorldMap(string mapFname)
        {
            WldOffset    = new PointI();
            AreaGridSize = new SizeI();
            mapBmp       = new Bitmap(mapFname);

            WorldSize.w = mapBmp.Width;
            WorldSize.h = mapBmp.Height;
        }
コード例 #9
0
ファイル: WorldMap.cs プロジェクト: terakenxx/TukubaChallenge
        /// <summary>
        /// ワールドマップ初期化
        /// </summary>
        /// <param name="mapFname">ワールドBMPファイル名</param>
        public WorldMap( string mapFname )
        {
            WldOffset = new PointI();
            AreaGridSize = new SizeI();
            mapBmp = new Bitmap(mapFname);

            WorldSize.w = mapBmp.Width;
            WorldSize.h = mapBmp.Height;
        }
コード例 #10
0
ファイル: SizeTest.cs プロジェクト: prepare/Tektosyne.NET
        public void Constructor()
        {
            Assert.Throws <ArgumentOutOfRangeException>(() => { var size = new SizeD(-1, 2); });
            Assert.Throws <ArgumentOutOfRangeException>(() => { var size = new SizeD(1, -2); });

            Assert.Throws <ArgumentOutOfRangeException>(() => { var size = new SizeF(-1, 2); });
            Assert.Throws <ArgumentOutOfRangeException>(() => { var size = new SizeF(1, -2); });

            Assert.Throws <ArgumentOutOfRangeException>(() => { var size = new SizeI(-1, 2); });
            Assert.Throws <ArgumentOutOfRangeException>(() => { var size = new SizeI(1, -2); });
        }
コード例 #11
0
        public void BeginRender(UnityEngine.Camera camera, UnityEngine.Renderer renderer, int width, int height, bool flipY)
        {
            m_flipY = flipY;

            m_CurrentUnityEngineRenderer = renderer;
            //NoNeed	m_CurrentUnityEngineCamera = camera;

            RenderTargetSize = new SizeI(width, height);

            BeginRender();
        }
コード例 #12
0
        /// <summary>
        /// Handles the <see cref="NumericUpDown.ValueChanged"/> event for the "Left", "Top",
        /// "Right", and "Bottom" <see cref="NumericUpDown"/> controls on the <see cref="SizeTab"/>
        /// page.</summary>
        /// <param name="sender">
        /// The <see cref="NumericUpDown"/> control sending the event.</param>
        /// <param name="args">
        /// An <see cref="EventArgs"/> object containing event data.</param>
        /// <remarks><para>
        /// <b>OnBoundsChanged</b> sets the <see cref="MoveLeft"/>, <see cref="MoveTop"/>, <see
        /// cref="MoveRight"/>, and <see cref="MoveBottom"/> properties to the current values of the
        /// corresponding <see cref="NumericUpDown"/> controls.
        /// </para><para>
        /// <b>OnBoundsChanged</b> then calls <see cref="UpdateMapSize"/> and <see
        /// cref="ShowMapSize"/> to compute and show the resulting new map size, and to update the
        /// ranges of all <see cref="NumericUpDown"/> controls.</para></remarks>

        private void OnBoundsChanged(object sender, EventArgs args)
        {
            // retrieve edge modifiers from numeric controls
            MoveLeft   = (int)LeftUpDown.Value;
            MoveTop    = (int)TopUpDown.Value;
            MoveRight  = (int)RightUpDown.Value;
            MoveBottom = (int)BottomUpDown.Value;

            // compute & show new map size
            SizeI newSize = UpdateMapSize();

            ShowMapSize(newSize);
        }
コード例 #13
0
        Unity_RenderManager()
        {
            m_Instance = this;


            int maxTextureSize = SystemInfo.maxTextureSize;

            MaxTextureSize = new SizeI(maxTextureSize, maxTextureSize);            //new SizeI(2048, 2048);

            //	TEMP (need process NPOTSupport.Restricted mode - Limited NPOT support: no mip-maps and clamp wrap mode will be forced)
            NonPowerOf2TexturesSupported = SystemInfo.npotSupport != NPOTSupport.None;

            RenderLinesByPolygons                    = false;
            MaxTextureCountPerBrushMaterial          = 1;
            MaxTextureCoordsSetCountPerBrushMaterial = MaxTextureCountPerBrushMaterial;

            //	test RenderTexture (not available if not Unity Pro)

            /*
             * RenderTexture renderTexture = null;
             * try
             * {
             *      renderTexture = new RenderTexture(2, 2, 0, RenderTextureFormat.ARGB32);
             *      renderTexture.Create();
             *      RenderToTextureSupported = renderTexture.IsCreated();
             * }
             * catch (Exception ex)
             * {
             *      Console.WriteLine(ex.ToString());
             *
             *      RenderToTextureSupported = false;
             * }
             * finally
             * {
             *      if (renderTexture != null)
             *      {
             *              renderTexture.Release();
             *              //renderTexture.Destroy();
             *              renderTexture = null;
             *      }
             * }*/
            RenderToTextureSupported = SystemInfo.supportsRenderTextures;

            TextureMatrixSupported = true;
            ClippingSupported      = true;


            //	We prefer to use Software Render BackBuffers, because it's faster in most cases and
            //	hasn't proplems with premultiplied alpha
            RenderToTextureSupported = false;
        }
コード例 #14
0
        void UpdateMatrices()
        {
            SizeI renderTargetSize = RenderTargetSize;
            SizeI viewSize         =
#if TRY_CLIPPINGRECT
                !m_LastClipRectangle.IsZero ? m_LastClipRectangle.Size.ToSizeI() :
#endif
                renderTargetSize;

            if (RenderTexture.active == null)
            {
                GL.LoadPixelMatrix(0, viewSize.Width, 0, viewSize.Height);
            }
            else
            {
                if (m_flipY)
                {
                    GL.LoadPixelMatrix(0, viewSize.Width, 0, viewSize.Height);
                }
                else
                {
                    GL.LoadPixelMatrix(0, viewSize.Width, viewSize.Height, 0);
                }
            }

#if TRY_CLIPPINGRECT
            if (m_LastClipRectangle.IsZero)
            {
                GL.Viewport(new UnityEngine.Rect(0, 0, (float)renderTargetSize.Width, (float)renderTargetSize.Height));
            }
            else
            {
                GL.Viewport(new UnityEngine.Rect(
                                (float)m_LastClipRectangle.X, (float)m_LastClipRectangle.Y,
                                (float)m_LastClipRectangle.Width, (float)m_LastClipRectangle.Height));
            }
#endif

            m_WorldMatrix = Matrix4.Identity;
            m_WorldMatrix.SetTranslation(0, viewSize.Height, 0);
            m_WorldMatrix.SetScale(
                1.0,
                -1.0,
                1);

            m_WorldMatrixLines =
                //m_WorldMatrix;
                Matrix4.Mult(Matrix4.CreateTranslation(0.5, 0.5), m_WorldMatrix);
        }
コード例 #15
0
ファイル: ImageFilter.cs プロジェクト: inforithmics/Svg.Skia
 public static ImageFilter CreateMatrixConvolution(SizeI kernelSize, float[] kernel, float gain, float bias, PointI kernelOffset, ShaderTileMode tileMode, bool convolveAlpha, ImageFilter?input = null, CropRect?cropRect = null)
 {
     return(new MatrixConvolutionImageFilter
     {
         KernelSize = kernelSize,
         Kernel = kernel,
         Gain = gain,
         Bias = bias,
         KernelOffset = kernelOffset,
         TileMode = tileMode,
         ConvolveAlpha = convolveAlpha,
         Input = input,
         CropRect = cropRect
     });
 }
コード例 #16
0
        public Unity_Renderer(Unity_RenderManager renderManager, UnityEngine.RenderTexture renderTexture) :
            base(renderManager, Alt.Sketch.Graphics.RSN_Unity)
        {
            //NoNeed	m_RenderTexture = renderTexture;

            TransformMatrixSupported = true;

            RenderLinesByPolygons = renderManager.RenderLinesByPolygons;

            //  Now supports only 1 texture (need more shaders researches)
            MaxTextureCountPerBrushMaterial          = 1; // renderManager.MaxTextureCountPerBrushMaterial;
            MaxTextureCoordsSetCountPerBrushMaterial = 1; // renderManager.MaxTextureCoordsSetCountPerBrushMaterial;

            NonPowerOf2TexturesSupported = renderManager.NonPowerOf2TexturesSupported;

            //  We cah't use NeoAxis RenderToTexture yet, so use Software render
            RenderToTextureSupported = renderManager.RenderToTextureSupported;

            //  Can't to set Texture Matrix yet
            TextureMatrixSupported = false;// renderManager.TextureMatrixSupported;

            //  Clipping is not supported (We can't get ScissorRect or Viewport to work...)
            ClippingSupported =
#if TRY_CLIPPINGRECT
                renderManager.ClippingSupported;
#else
                false;
#endif

            SizeI maxTextureSize = renderManager.MaxTextureSize;
            //  LinearGradientTextureMaxSize
            {
                SizeI baseLinearGradientTextureMaxSize = base.LinearGradientTextureMaxSize;

                LinearGradientTextureMaxSize = new SizeI(
                    System.Math.Min(maxTextureSize.Width, baseLinearGradientTextureMaxSize.Width),
                    System.Math.Min(maxTextureSize.Height, baseLinearGradientTextureMaxSize.Height));
            }
            //  RadialGradientTextureMaxSize
            {
                SizeI baseRadialGradientTextureMaxSize = base.RadialGradientTextureMaxSize;

                RadialGradientTextureMaxSize = new SizeI(
                    System.Math.Min(maxTextureSize.Width, baseRadialGradientTextureMaxSize.Width),
                    System.Math.Min(maxTextureSize.Height, baseRadialGradientTextureMaxSize.Height));
            }
        }
コード例 #17
0
            protected override void OnPaint(GUI.PaintEventArgs e)
            {
                base.OnPaint(e);

                if (!string.IsNullOrEmpty(Info))
                {
                    if (m_Font == null)
                    {
                        m_Font = new Font("Arial", 14, FontStyle.Bold);
                    }

                    SizeI size = e.Graphics.MeasureString(Info, m_Font).ToSizeI();

                    e.Graphics.DrawString(Info, m_Font, Brushes.White,
                                          new Point((Width - size.Width) / 2, (Height - size.Height) / 2));
                }
            }
コード例 #18
0
        /// <summary>
        /// Adds all defined <see cref="ImageFrame"/> sizes to the "Image Frame Sizes" <see
        /// cref="ComboBox"/> on the <see cref="StructureTab"/> page.</summary>
        /// <remarks><para>
        /// <b>AddImageSizes</b> iterates through all <see cref="EntityImage.Frames"/> of every <see
        /// cref="EntityImage"/> in the current <see cref="ImageSection"/>, and adds all unique <see
        /// cref="ImageFrame.Bounds"/> sizes to the "Image Frame Sizes" combo box.
        /// </para><para>
        /// The combo box and the "Circumscribe" button are disabled if the <see
        /// cref="ImageSection"/> does not define any <see cref="ImageFrame"/> objects.
        /// </para></remarks>

        private void AddImageSizes()
        {
            // extract all distinct sizes of image frames
            List <SizeI> sizes = new List <SizeI>();

            foreach (EntityImage image in MasterSection.Instance.Images.Collection.Values)
            {
                if (image != null)
                {
                    for (int i = 0; i < image.Frames.Count; i++)
                    {
                        SizeI size = image.Frames[i].Bounds.Size;
                        if (!sizes.Contains(size))
                        {
                            sizes.Add(size);
                        }
                    }
                }
            }

            if (sizes.Count == 0)
            {
                // disable controls if no image sizes defined
                CircumscribeButton.IsEnabled = false;
                ImageSizeCombo.IsEnabled     = false;
                ImageSizeCombo.Items.Add(Global.Strings.LabelNone);
            }
            else
            {
                // sort image sizes by width, then by height
                sizes.Sort((x, y) => {
                    int delta = x.Width - y.Width;
                    return(delta != 0 ? delta : x.Height - y.Height);
                });

                // add image sizes to combo box
                foreach (SizeI size in sizes)
                {
                    ImageSizeItem item = new ImageSizeItem(size);
                    ImageSizeCombo.Items.Add(item);
                }
            }

            Debug.Assert(ImageSizeCombo.Items.Count > 0);
            ImageSizeCombo.SelectedIndex = 0;
        }
コード例 #19
0
        protected override void OnPaint(PaintEventArgs e)
        {
            base.OnPaint(e);

            if (e.Graphics is SoftwareGraphics)
            {
                if (m_SoftwareGraphicsInfoFont == null)
                {
                    m_SoftwareGraphicsInfoFont  = new Font("Arial", 14, FontStyle.Bold);
                    m_SoftwareGraphicsInfoBrush = new SolidColorBrush(Color.FromArgb(255, Color.Red * 0.8));
                }

                SizeI size = e.Graphics.MeasureString(m_SoftwareGraphicsInfo, m_SoftwareGraphicsInfoFont).ToSizeI();
                e.Graphics.DrawString(m_SoftwareGraphicsInfo, m_SoftwareGraphicsInfoFont, m_SoftwareGraphicsInfoBrush,
                                      new Point((Width - size.Width) / 2, (Height - size.Height) / 2 - 50));

                size = e.Graphics.MeasureString(m_SoftwareGraphicsInfo2, m_SoftwareGraphicsInfoFont).ToSizeI();
                e.Graphics.DrawString(m_SoftwareGraphicsInfo2, m_SoftwareGraphicsInfoFont, m_SoftwareGraphicsInfoBrush,
                                      new Point((Width - size.Width) / 2, (Height - size.Height) / 2 - 50 + m_SoftwareGraphicsInfoFont.Height));
            }
        }
コード例 #20
0
        void Client_Paint(object sender, GUI.PaintEventArgs e)
        {
            Graphics graphics = e.Graphics;

            Color color = Color.WhiteSmoke;

            graphics.Clear(color);

            if (m_AtlasBitmap != null)
            {
                int x = (m_Client.ClientWidth - m_AtlasBitmap.PixelWidth) / 2;
                int y = (m_Client.ClientHeight - m_AtlasBitmap.PixelHeight) / 2;
                x = Math.Min(x, y);
                x = 15;

                RectI rect = new RectI(x - 1, y - 1, m_AtlasBitmap.PixelSize + SizeI.One);
                graphics.FillRectangle(Color.White, rect);

                graphics.DrawImage(m_AtlasBitmap, x, y);

                graphics.DrawRectangle(Color.DodgerBlue * 0.6, rect);

                x = x * 2 + m_AtlasBitmap.PixelWidth;
                y = m_Client.ClientHeight / 2;
                m_FontAtlas.GetFont(0).DrawString(graphics, x, y - 170, "Font 1");
                m_FontAtlas.GetFont(1).DrawString(graphics, x, y - 70, "Font 2");
                m_FontAtlas.GetFont(2).DrawString(graphics, x, y - 10, "Font 3");
                m_FontAtlas.GetFont(3).DrawString(graphics, x, y + 50, "Font 4");
                m_FontAtlas.GetFont(4).DrawString(graphics, x, y + 100, "Font 5");
            }


            Font font = new Font("Times New Roman", 36);

            string s    = "Texture Atlas";
            SizeI  size = graphics.MeasureString(s, font).ToSizeI();

            graphics.DrawString(s, font, Brushes.Red, (m_Client.ClientSize - size).ToPointI() - new Point(10, 3));
        }
コード例 #21
0
        public TileGrid(int width, int height)
        {
            _size = new SizeI(20, 20);
            _grid = new Tile[width, height];
            GridHelper.Foreach(_grid, (x, y) =>
            {
                _grid[x, y] = new Tile(x, y);
                if (x == 0 || y == 0 || x == width - 1 || y == height - 1)
                {
                    _grid[x, y].AddImpenetrableWall();
                }
            });

            for (int i = 0; i < 10; i++)
            {
                GetRandomEmptyTile().AddWall(1);
            }

            for (int i = 0; i < 3; i++)
            {
                GetRandomEmptyTile().AddWall(2);
            }
        }
コード例 #22
0
ファイル: MapViewRenderer.cs プロジェクト: prepare/HexKit
        /// <summary>
        /// Ensures that the <see cref="PaintBuffer"/> covers the specified minimum size.</summary>
        /// <param name="required">
        /// The new minimum size, in device-independent pixels, for the <see cref="PaintBuffer"/>.
        /// </param>
        /// <returns>
        /// <c>true</c> if the <see cref="PaintBuffer"/> must be cleared by the caller; otherwise,
        /// <c>false</c>.</returns>
        /// <remarks>
        /// To avoid frequent buffer reallocations, <b>EnsureBufferSize</b> grows the <see
        /// cref="PaintBuffer"/> to cover twice its current area or to the specified <paramref
        /// name="required"/> size, whichever is bigger. However, <b>EnsureBufferSize</b> will not
        /// grow the <see cref="PaintBuffer"/> beyond the device-independent size of the current
        /// virtual screen, unless the <paramref name="required"/> size is greater.</remarks>

        private bool EnsureBufferSize(SizeI required)
        {
            int   width, height;
            SizeI estimate = required;

            if (PaintBuffer != null)
            {
                width  = PaintBuffer.PixelWidth;
                height = PaintBuffer.PixelHeight;

                // quit if existing buffer is large enough
                if (width >= required.Width && height >= required.Height)
                {
                    return(true);
                }

                // new estimate: double current buffer area
                estimate = new SizeD(width * 1.4, height * 1.4).Round();
            }

            // default to virtual screen size
            SizeI screen = new SizeI(
                Fortran.Ceiling(SystemParameters.VirtualScreenWidth),
                Fortran.Ceiling(SystemParameters.VirtualScreenHeight));

            SizeI minimum = new SizeI(
                Math.Min(screen.Width, estimate.Width),
                Math.Min(screen.Height, estimate.Height));

            // choose maximum of screen size or required size
            width  = Math.Max(minimum.Width, required.Width);
            height = Math.Max(minimum.Height, required.Height);

            // reallocate buffer with new size
            PaintBuffer = new WriteableBitmap(width, height, 96, 96, PixelFormats.Pbgra32, null);
            return(false);
        }
コード例 #23
0
        protected override void OnLoad(EventArgs e)
        {
            base.OnLoad(e);


            Alt.GUI.Temporary.Gwen.Control.Label label;
#if SILVERLIGHT || UNITY_WEBPLAYER
            label = new Alt.GUI.Temporary.Gwen.Control.Label(this);
            label.AutoSizeToContents = true;
            label.Text = //Description + "\n" + "(This example is not available in this Demo, please download SDK)";
                         "THIS EXAMPLE IS NOT AVAILABLE IN THIS DEMO,\nPLEASE DOWNLOAD AltGUI SDK";
            label.TextColor = Color.Orange * 1.2;
            label.Dock      = Pos.Top;
            label.Margin    = new Margin(0, 0, 0, 5);
            label.Font      = Example_NotAvailable_ScreenShot.Font;
#endif


            //  GUI
            {
                m_Top1 = new Base(this);
                {
                    m_Top1.Dock   = Pos.Top;
                    m_Top1.Height = 30;

                    loadDemoImage1ToolStripMenuItem = new Alt.GUI.Temporary.Gwen.Control.Button(m_Top1);
                    loadDemoImage2ToolStripMenuItem = new Alt.GUI.Temporary.Gwen.Control.Button(m_Top1);
                    loadDemoImage3ToolStripMenuItem = new Alt.GUI.Temporary.Gwen.Control.Button(m_Top1);
                    loadDemoImage4ToolStripMenuItem = new Alt.GUI.Temporary.Gwen.Control.Button(m_Top1);

                    loadDemoImage1ToolStripMenuItem.Text   = "Load demo image 1";
                    loadDemoImage1ToolStripMenuItem.Click += new System.EventHandler(loadDemoImage1ToolStripMenuItem_Click);
                    loadDemoImage1ToolStripMenuItem.Dock   = Pos.Left;
                    loadDemoImage1ToolStripMenuItem.AutoSizeToContents = true;
                    loadDemoImage1ToolStripMenuItem.NormalTextColor    = Color.Red * 0.8;

                    loadDemoImage2ToolStripMenuItem.Text               = "Load demo image 2";
                    loadDemoImage2ToolStripMenuItem.Click             += new System.EventHandler(loadDemoImage2ToolStripMenuItem_Click);
                    loadDemoImage2ToolStripMenuItem.Dock               = Pos.Left;
                    loadDemoImage2ToolStripMenuItem.Margin             = new Margin(10, 0, 0, 0);
                    loadDemoImage2ToolStripMenuItem.AutoSizeToContents = true;
                    loadDemoImage2ToolStripMenuItem.NormalTextColor    = Color.Brown;

                    loadDemoImage3ToolStripMenuItem.Text               = "Load demo image 3";
                    loadDemoImage3ToolStripMenuItem.Click             += new System.EventHandler(loadDemoImage3ToolStripMenuItem_Click);
                    loadDemoImage3ToolStripMenuItem.Dock               = Pos.Left;
                    loadDemoImage3ToolStripMenuItem.Margin             = new Margin(10, 0, 0, 0);
                    loadDemoImage3ToolStripMenuItem.AutoSizeToContents = true;
                    loadDemoImage3ToolStripMenuItem.NormalTextColor    = Color.Green;

                    loadDemoImage4ToolStripMenuItem.Text               = "Load demo image 4";
                    loadDemoImage4ToolStripMenuItem.Click             += new System.EventHandler(loadDemoImage4ToolStripMenuItem_Click);
                    loadDemoImage4ToolStripMenuItem.Dock               = Pos.Left;
                    loadDemoImage4ToolStripMenuItem.Margin             = new Margin(10, 0, 0, 0);
                    loadDemoImage4ToolStripMenuItem.AutoSizeToContents = true;
                    loadDemoImage4ToolStripMenuItem.NormalTextColor    = Color.Blue;
                }


                m_Top2 = new Alt.GUI.Temporary.Gwen.Control.Base(this);
                {
                    m_Top2.Dock   = Pos.Top;
                    m_Top2.Height = 25;

                    label = new Alt.GUI.Temporary.Gwen.Control.Label(m_Top2);
                    label.AutoSizeToContents = true;
                    label.Text      = "Legend:";
                    label.Dock      = Pos.Left;
                    label.TextColor = Color.Orange;
                    label.Margin    = new Margin(0, 4, 0, 0);


                    SizeI  boxSize     = new SizeI(m_Top2.Height, m_Top2.Height);
                    Margin boxMargin   = new Margin(10, 0, 0, 0);
                    Margin labelMargin = new Margin(5, 4, 0, 0);


                    //  1
                    label = new Alt.GUI.Temporary.Gwen.Control.Label(m_Top2);
                    label.ClientBackColor = Color.Yellow;
                    label.DrawBorder      = true;
                    label.BorderColor     = Color.DodgerBlue;
                    label.Dock            = Pos.Left;
                    label.Margin          = boxMargin;
                    label.Size            = boxSize;

                    label                    = new Alt.GUI.Temporary.Gwen.Control.Label(m_Top2);
                    label.Dock               = Pos.Left;
                    label.Margin             = labelMargin;
                    label.AutoSizeToContents = true;
                    label.Text               = "Circles";


                    //  2
                    label = new Alt.GUI.Temporary.Gwen.Control.Label(m_Top2);
                    label.ClientBackColor = Color.Red;
                    label.DrawBorder      = true;
                    label.BorderColor     = Color.DodgerBlue;
                    label.Dock            = Pos.Left;
                    label.Margin          = boxMargin;
                    label.Size            = boxSize;

                    label                    = new Alt.GUI.Temporary.Gwen.Control.Label(m_Top2);
                    label.Dock               = Pos.Left;
                    label.Margin             = labelMargin;
                    label.AutoSizeToContents = true;
                    label.Text               = "Quadrilaterals";


                    //  3
                    label = new Alt.GUI.Temporary.Gwen.Control.Label(m_Top2);
                    label.ClientBackColor = Color.Brown;
                    label.DrawBorder      = true;
                    label.BorderColor     = Color.DodgerBlue;
                    label.Dock            = Pos.Left;
                    label.Margin          = boxMargin;
                    label.Size            = boxSize;
                    label.SetToolTipText("Trapezoid, Parallelogram, Rectangle, Rhombus or Square");
                    label.MouseInputEnabled = true;

                    label                    = new Alt.GUI.Temporary.Gwen.Control.Label(m_Top2);
                    label.Dock               = Pos.Left;
                    label.Margin             = labelMargin;
                    label.AutoSizeToContents = true;
                    label.Text               = "Known quadrilaterals";
                    label.SetToolTipText("Trapezoid, Parallelogram, Rectangle, Rhombus or Square");
                    label.MouseInputEnabled = true;


                    //  4
                    label = new Alt.GUI.Temporary.Gwen.Control.Label(m_Top2);
                    label.ClientBackColor = Color.Blue;
                    label.DrawBorder      = true;
                    label.BorderColor     = Color.DodgerBlue;
                    label.Dock            = Pos.Left;
                    label.Margin          = boxMargin;
                    label.Size            = boxSize;

                    label                    = new Alt.GUI.Temporary.Gwen.Control.Label(m_Top2);
                    label.Dock               = Pos.Left;
                    label.Margin             = labelMargin;
                    label.AutoSizeToContents = true;
                    label.Text               = "Triangles";


                    //  5
                    label = new Alt.GUI.Temporary.Gwen.Control.Label(m_Top2);
                    label.ClientBackColor = Color.Green;
                    label.DrawBorder      = true;
                    label.BorderColor     = Color.DodgerBlue;
                    label.Dock            = Pos.Left;
                    label.Margin          = boxMargin;
                    label.Size            = boxSize;
                    label.SetToolTipText("Equilateral, Isosceles, Rectangled or Rectangled Isosceles Triangle");
                    label.MouseInputEnabled = true;

                    label                    = new Alt.GUI.Temporary.Gwen.Control.Label(m_Top2);
                    label.Dock               = Pos.Left;
                    label.Margin             = labelMargin;
                    label.AutoSizeToContents = true;
                    label.Text               = "Known triangles";
                    label.SetToolTipText("Equilateral, Isosceles, Rectangled or Rectangled Isosceles Triangle");
                    label.MouseInputEnabled = true;
                }


                pictureBox          = new Alt.GUI.Temporary.Gwen.Control.PictureBox(this);
                pictureBox.Dock     = Pos.Fill;
                pictureBox.SizeMode = PictureBoxSizeMode.CenterImage;
            }


            LoadDemo("coins.jpg");
        }
コード例 #24
0
    public virtual Result CreateElement(/*cstype*/ string text, SWIGTYPE_p_LPD3DFONT font, int x, int y, DockType dock, Color color, SizeI size)
    {
        Result ret = new Result(IronSightEnginePINVOKE.IHUD_CreateElement__SWIG_12(swigCPtr, new IronSightEnginePINVOKE.SWIGStringMarshal(text).swigCPtr, SWIGTYPE_p_LPD3DFONT.getCPtr(font), x, y, (int)dock, Color.getCPtr(color), SizeI.getCPtr(size)), true);

        //
        if (IronSightEnginePINVOKE.SWIGPendingException.Pending)
        {
            throw IronSightEnginePINVOKE.SWIGPendingException.Retrieve();
        }
        if (IronSightEnginePINVOKE.SWIGPendingException.Pending)
        {
            throw IronSightEnginePINVOKE.SWIGPendingException.Retrieve();
        }
        return(ret);
    }
コード例 #25
0
ファイル: Example_Clipper.cs プロジェクト: CrazyLiu00/GMap
        void DrawingPanel_Paint(object sender, GUI.PaintEventArgs e)
        {
            GUI.Cursor.Current = GUI.Cursors.WaitCursor;

            Graphics      graphics            = e.Graphics;
            SmoothingMode fillSmoothingMode   = graphics is SoftwareGraphics ? SmoothingMode.AntiAlias : SmoothingMode.None;
            SmoothingMode strokeSmoothingMode = SmoothingMode.AntiAlias;

            graphics.SmoothingMode = fillSmoothingMode;

            graphics.Clear(Color.White);


            GraphicsPath path = new GraphicsPath();

            if (rbNonZero.IsChecked)
            {
                path.FillMode = FillMode.Winding;
            }

            //draw subjects ...
            foreach (Polygon pg in subjects)
            {
                Point[] pts = PolygonToPointArray(pg, scale);
                path.AddPolygon(pts);
                pts = null;
            }

            Pen myPen = new Pen(
                //Color.FromArgb(196, 0xC3, 0xC9, 0xCF),
                Color.FromArgb(128, 0, 0, 255),
                0.6);
            SolidColorBrush myBrush = new SolidColorBrush(
                //Color.FromArgb(127, 0xDD, 0xDD, 0xF0));
                //Color.FromArgb(255, 210, 210, 255));
                Color.FromArgb(127, Color.LightBlue));

            graphics.SmoothingMode = fillSmoothingMode;
            graphics.FillPath(myBrush, path);
            graphics.SmoothingMode = strokeSmoothingMode;
            graphics.DrawPath(myPen, path);
            path.Reset();

            //draw clips ...
            if (rbNonZero.IsChecked)
            {
                path.FillMode = FillMode.Winding;
            }
            foreach (Polygon pg in clips)
            {
                Point[] pts = PolygonToPointArray(pg, scale);
                path.AddPolygon(pts);
                pts = null;
            }
            myPen.Color   = Color.FromArgb(128, Color.Red); //0xF9, 0xBE, 0xA6);
            myBrush.Color =                                 //Color.FromArgb(127, 0xFF, 0xE0, 0xE0);
                            Color.FromArgb(50, 255, 0, 0);

            graphics.SmoothingMode = fillSmoothingMode;
            graphics.FillPath(myBrush, path);
            graphics.SmoothingMode = strokeSmoothingMode;
            graphics.DrawPath(myPen, path);

            //do the clipping ...
            if ((clips.Count > 0 || subjects.Count > 0) &&
                !rbNone.IsChecked)
            {
                Polygons solution2 = new Polygons();
                Clipper  c         = new Clipper(0);
                c.AddPaths(subjects, PolyType.ptSubject, true);
                c.AddPaths(clips, PolyType.ptClip, true);
                solution.Clear();
                bool succeeded = c.Execute(GetClipType(), solution, GetPolyFillType(), GetPolyFillType());
                if (succeeded)
                {
                    myBrush.Color = Color.Black;
                    path.Reset();

                    //It really shouldn't matter what FillMode is used for solution
                    //polygons because none of the solution polygons overlap.
                    //However, FillMode.Winding will show any orientation errors where
                    //holes will be stroked (outlined) correctly but filled incorrectly  ...
                    path.FillMode = FillMode.Winding;

                    //or for something fancy ...
                    if (nudOffset.Value != 0)
                    {
                        //old   solution2 = Clipper.OffsetPolygons(solution, (double)nudOffset.Value * scale, JoinType.jtMiter);
                        ClipperOffset co = new ClipperOffset(2, 0.25);
                        co.AddPaths(solution, JoinType.jtMiter, EndType.etClosedPolygon);
                        co.Execute(ref solution2, (double)nudOffset.Value * scale);
                    }
                    else
                    {
                        solution2 = new Polygons(solution);
                    }

                    foreach (Polygon pg in solution2)
                    {
                        Point[] pts = PolygonToPointArray(pg, scale);
                        if (pts.Length//Count()
                            > 2)
                        {
                            path.AddPolygon(pts);
                        }
                        pts = null;
                    }
                    //myBrush.Color = Color.FromArgb(127, 0x66, 0xEF, 0x7F);
                    myBrush.Color = Color.FromArgb(100, 0, 255, 0);
                    myPen.Color   = Color.FromArgb(255, 0, 0x33, 0);
                    myPen.Width   = 1;

                    graphics.SmoothingMode = fillSmoothingMode;
                    graphics.FillPath(myBrush, path);
                    graphics.SmoothingMode = strokeSmoothingMode;
                    graphics.DrawPath(myPen, path);

                    //now do some fancy testing ...
                    Font   f = new Font("Arial", 8);
                    Brush  b = Brushes.Navy;
                    double subj_area = 0, clip_area = 0, int_area = 0, union_area = 0;
                    c.Clear();
                    c.AddPaths(subjects, PolyType.ptSubject, true);
                    c.Execute(ClipType.ctUnion, solution2, GetPolyFillType(), GetPolyFillType());
                    foreach (Polygon pg in solution2)
                    {
                        subj_area += Clipper.Area(pg);
                    }
                    c.Clear();
                    c.AddPaths(clips, PolyType.ptClip, true);
                    c.Execute(ClipType.ctUnion, solution2, GetPolyFillType(), GetPolyFillType());
                    foreach (Polygon pg in solution2)
                    {
                        clip_area += Clipper.Area(pg);
                    }
                    c.AddPaths(subjects, PolyType.ptSubject, true);
                    c.Execute(ClipType.ctIntersection, solution2, GetPolyFillType(), GetPolyFillType());
                    foreach (Polygon pg in solution2)
                    {
                        int_area += Clipper.Area(pg);
                    }
                    c.Execute(ClipType.ctUnion, solution2, GetPolyFillType(), GetPolyFillType());
                    foreach (Polygon pg in solution2)
                    {
                        union_area += Clipper.Area(pg);
                    }

                    StringFormat lftStringFormat = new StringFormat();
                    lftStringFormat.Alignment     = StringAlignment.Near;
                    lftStringFormat.LineAlignment = StringAlignment.Near;
                    StringFormat rtStringFormat = new StringFormat();
                    rtStringFormat.Alignment     = StringAlignment.Far;
                    rtStringFormat.LineAlignment = StringAlignment.Near;
                    RectI rec = new RectI(WorkArea.Width - 114, WorkArea.Height - 116, 104, 106);
                    graphics.FillRectangle(new SolidColorBrush(Color.FromArgb(196, Color.WhiteSmoke)), rec);
                    graphics.DrawRectangle(myPen, rec);
                    rec.Inflate(new SizeI(-2, 0));

                    //  because of Alt.Sketch smaller top offset
                    rec += new PointI(0, 1);
                    rec -= new SizeI(0, 1);

                    graphics.DrawString("Areas", f, b, rec, rtStringFormat);
                    rec.Offset(new PointI(0, 14));
                    graphics.DrawString("subj: ", f, b, rec, lftStringFormat);
                    graphics.DrawString((subj_area / 100000).ToString("0,0"), f, b, rec, rtStringFormat);
                    rec.Offset(new PointI(0, 12));
                    graphics.DrawString("clip: ", f, b, rec, lftStringFormat);
                    graphics.DrawString((clip_area / 100000).ToString("0,0"), f, b, rec, rtStringFormat);
                    rec.Offset(new PointI(0, 12));
                    graphics.DrawString("intersect: ", f, b, rec, lftStringFormat);
                    graphics.DrawString((int_area / 100000).ToString("0,0"), f, b, rec, rtStringFormat);
                    rec.Offset(new PointI(0, 12));
                    graphics.DrawString("---------", f, b, rec, rtStringFormat);
                    rec.Offset(new PointI(0, 10));
                    graphics.DrawString("s + c - i: ", f, b, rec, lftStringFormat);
                    graphics.DrawString(((subj_area + clip_area - int_area) / 100000).ToString("0,0"), f, b, rec, rtStringFormat);
                    rec.Offset(new PointI(0, 10));
                    graphics.DrawString("---------", f, b, rec, rtStringFormat);
                    rec.Offset(new PointI(0, 10));
                    graphics.DrawString("union: ", f, b, rec, lftStringFormat);
                    graphics.DrawString((union_area / 100000).ToString("0,0"), f, b, rec, rtStringFormat);
                    rec.Offset(new PointI(0, 10));
                    graphics.DrawString("---------", f, b, rec, rtStringFormat);
                } //end if succeeded
            }     //end if something to clip

            //TEMP  pictureBox1.Image = mybitmap;
            graphics.Dispose();
            GUI.Cursor.Current = GUI.Cursors.Default;
        }
コード例 #26
0
            /// <summary>
            /// Initializes a new instance of the <see cref="ImageSizeItem"/> class.</summary>
            /// <param name="value">
            /// The initial value for the <see cref="Value"/> field.</param>

            internal ImageSizeItem(SizeI value)
            {
                Value = value;
            }
コード例 #27
0
 public Window(string title, int width = 1280, int height = 720)
 {
     Title      = title;
     ClientSize = new(width, height);
     PlatformConstruct();
 }
コード例 #28
0
 public D3D11GraphicsDevice(SizeI size, Format depthStencilFormat = Format.D32_Float)
     : this(null, size, depthStencilFormat)
 {
 }
コード例 #29
0
    private D3D11GraphicsDevice(Window?window, SizeI size, Format depthStencilFormat = Format.D32_Float)
    {
        Window = window;
        Size   = size;

        Factory = CreateDXGIFactory1 <IDXGIFactory2>();

        using (IDXGIAdapter1 adapter = GetHardwareAdapter())
        {
            DeviceCreationFlags creationFlags = DeviceCreationFlags.BgraSupport;
#if DEBUG
            if (SdkLayersAvailable())
            {
                creationFlags |= DeviceCreationFlags.Debug;
            }
#endif

            if (D3D11CreateDevice(
                    adapter,
                    DriverType.Unknown,
                    creationFlags,
                    s_featureLevels,
                    out ID3D11Device tempDevice, out FeatureLevel, out ID3D11DeviceContext tempContext).Failure)
            {
                // If the initialization fails, fall back to the WARP device.
                // For more information on WARP, see:
                // http://go.microsoft.com/fwlink/?LinkId=286690
                D3D11CreateDevice(
                    IntPtr.Zero,
                    DriverType.Warp,
                    creationFlags,
                    s_featureLevels,
                    out tempDevice, out FeatureLevel, out tempContext).CheckError();
            }

            Device        = tempDevice.QueryInterface <ID3D11Device1>();
            DeviceContext = tempContext.QueryInterface <ID3D11DeviceContext1>();
            tempContext.Dispose();
            tempDevice.Dispose();
        }

        if (window != null)
        {
            IntPtr hwnd = window.Handle;

            SwapChainDescription1 swapChainDescription = new()
            {
                Width             = window.ClientSize.Width,
                Height            = window.ClientSize.Height,
                Format            = Format.R8G8B8A8_UNorm,
                BufferCount       = FrameCount,
                BufferUsage       = Usage.RenderTargetOutput,
                SampleDescription = SampleDescription.Default,
                Scaling           = Scaling.Stretch,
                SwapEffect        = SwapEffect.FlipDiscard,
                AlphaMode         = AlphaMode.Ignore
            };

            SwapChainFullscreenDescription fullscreenDescription = new SwapChainFullscreenDescription
            {
                Windowed = true
            };

            SwapChain = Factory.CreateSwapChainForHwnd(Device, hwnd, swapChainDescription, fullscreenDescription);
            Factory.MakeWindowAssociation(hwnd, WindowAssociationFlags.IgnoreAltEnter);

            BackBufferTexture = SwapChain.GetBuffer <ID3D11Texture2D>(0);
            RenderTargetView  = Device.CreateRenderTargetView(BackBufferTexture);
        }
        else
        {
            // Create offscreen texture
            OffscreenTexture = Device.CreateTexture2D(Format.R8G8B8A8_UNorm, Size.Width, Size.Height, 1, 1, null, BindFlags.ShaderResource | BindFlags.RenderTarget);
            RenderTargetView = Device.CreateRenderTargetView(OffscreenTexture);
        }

        if (depthStencilFormat != Format.Unknown)
        {
            DepthStencilTexture = Device.CreateTexture2D(depthStencilFormat, Size.Width, Size.Height, 1, 1, null, BindFlags.DepthStencil);
            DepthStencilView    = Device.CreateDepthStencilView(DepthStencilTexture !, new DepthStencilViewDescription(DepthStencilTexture, DepthStencilViewDimension.Texture2D));
        }

        ReadOnlySpan <VertexPositionColor> triangleVertices = stackalloc VertexPositionColor[]
        {
            new VertexPositionColor(new Vector3(0f, 0.5f, 0.0f), new Color4(1.0f, 0.0f, 0.0f, 1.0f)),
            new VertexPositionColor(new Vector3(0.5f, -0.5f, 0.0f), new Color4(0.0f, 1.0f, 0.0f, 1.0f)),
            new VertexPositionColor(new Vector3(-0.5f, -0.5f, 0.0f), new Color4(0.0f, 0.0f, 1.0f, 1.0f))
        };

        bool dynamic = false;
        if (dynamic)
        {
            _vertexBuffer = Device.CreateBuffer(VertexPositionColor.SizeInBytes * 3, BindFlags.VertexBuffer, ResourceUsage.Dynamic, CpuAccessFlags.Write);
            MappedSubresource mappedSubresource = DeviceContext.Map(_vertexBuffer, 0, MapMode.WriteDiscard);
            triangleVertices.CopyTo(mappedSubresource.AsSpan <VertexPositionColor>(3));
            DeviceContext.Unmap(_vertexBuffer, 0);
        }
        else
        {
            _vertexBuffer = Device.CreateBuffer(triangleVertices, BindFlags.VertexBuffer);
        }

        InputElementDescription[] inputElementDescs = new[]
        {
            new InputElementDescription("POSITION", 0, Format.R32G32B32_Float, 0, 0),
            new InputElementDescription("COLOR", 0, Format.R32G32B32A32_Float, 12, 0)
        };

        Span <byte> vertexShaderByteCode = CompileBytecode("Triangle.hlsl", "VSMain", "vs_4_0");
        Span <byte> pixelShaderByteCode  = CompileBytecode("Triangle.hlsl", "PSMain", "ps_4_0");

        _vertexShader = Device.CreateVertexShader(vertexShaderByteCode);
        _pixelShader  = Device.CreatePixelShader(pixelShaderByteCode);
        _inputLayout  = Device.CreateInputLayout(inputElementDescs, vertexShaderByteCode);
    }
コード例 #30
0
 internal static global::System.Runtime.InteropServices.HandleRef getCPtr(SizeI obj)
 {
     return((obj == null) ? new global::System.Runtime.InteropServices.HandleRef(null, global::System.IntPtr.Zero) : obj.swigCPtr);
 }
コード例 #31
0
ファイル: SimpleXml.cs プロジェクト: prepare/HexKit
        /// <summary>
        /// Writes the data of the specified <see cref="SizeI"/> instance to the specified <see
        /// cref="XmlWriter"/>.</summary>
        /// <param name="writer">
        /// The <see cref="XmlWriter"/> to which to write.</param>
        /// <param name="size">
        /// The <see cref="SizeI"/> instance whose data to write to <paramref name="writer"/>.
        /// </param>
        /// <remarks>
        /// <b>WriteSizeI</b> writes the components of the specified <paramref name="size"/> as
        /// attributes named "width" and "height" to the specified <paramref name="writer"/>.
        /// </remarks>

        public static void WriteSizeI(XmlWriter writer, SizeI size)
        {
            writer.WriteAttributeString("width", XmlConvert.ToString(size.Width));
            writer.WriteAttributeString("height", XmlConvert.ToString(size.Height));
        }