コード例 #1
0
        /// <summary>
        /// Mapping Xml Data which has been retrieved by an xpath expression.
        /// </summary>
        /// <param name="list">The list.</param>
        /// <returns>a mapped item of type: <see cref="Common.Region"/></returns>
        private Common.Region MapData(XmlNodeList list)
        {
            Common.Region item = new Common.Region();
            foreach (XmlNode n in list)
            {
                #region Map Data
                switch (n.Name)
                {
                case "nRegionId":
                    item.RegionId = int.Parse(n.InnerText);
                    break;

                case "nCountryId":
                    item.CountryId = int.Parse(n.InnerText);
                    break;

                case "cRegionIso2":
                    item.RegionIso2Code = n.InnerText;
                    break;

                case "cName":
                    item.Name = n.InnerText;
                    break;
                }
                #endregion Map Data
            }
            return(item);
        }
コード例 #2
0
        public void TextFieldTry()
        {
            Textfield tf = new Textfield();
            var       cr = new Common.Region();

            cr.Add(tf.DisplayRectangle);
            tf.Draw(GetSDXContext.GetDrawer(), cr);
        }
コード例 #3
0
ファイル: textfieldy.cs プロジェクト: windygu/noForms
        public override void Draw(IDraw rt, Common.Region dirty)
        {
            float dt = (float)Math.Sin(sw.ElapsedMilliseconds / 1000f) + 1f;

            base.Draw(rt, dirty);
            rt.uDraw.FillRectangle(DisplayRectangle, usb2);
            rt.uDraw.DrawText(t, new Point(dt * 30, dt * 40), ub, UTextDrawOptions.None, false);
        }
コード例 #4
0
ファイル: OTKSwapBuffer.cs プロジェクト: windygu/noForms
        void RenderPass(Common.Region dc, Common.Size ReqSize)
        {
            renderTime.Start();
            // Resize the form and backbuffer to noForm.Size
            Resize(ReqSize);

            Win32Util.Size w32Size = new Win32Util.Size((int)ReqSize.width, (int)ReqSize.height);
            Win32Util.SetWindowSize(w32Size, w32.handle);

            // Allow noform size to change as requested..like a layout hook (truncating layout passes with the render passes for performance)
            RenderSizeChanged(ReqSize);

            // Do Drawing stuff

            // 1) render to fbo
            throw new NotImplementedException();


// Create Color Texture
            uint ColorTexture;
            int  FboWidth  = (int)ReqSize.width;
            int  FboHeight = (int)ReqSize.height;

            GL.GenTextures(1, out ColorTexture);
            GL.BindTexture(TextureTarget.Texture2D, ColorTexture);
            GL.TexParameter(TextureTarget.Texture2D, TextureParameterName.TextureMinFilter, (int)TextureMinFilter.Nearest);
            GL.TexParameter(TextureTarget.Texture2D, TextureParameterName.TextureMagFilter, (int)TextureMagFilter.Nearest);
            GL.TexParameter(TextureTarget.Texture2D, TextureParameterName.TextureWrapS, (int)TextureWrapMode.Clamp);
            GL.TexParameter(TextureTarget.Texture2D, TextureParameterName.TextureWrapT, (int)TextureWrapMode.Clamp);
            GL.TexImage2D(TextureTarget.Texture2D, 0, PixelInternalFormat.Rgba8, FboWidth, FboHeight, 0, PixelFormat.Rgba, PixelType.UnsignedByte, IntPtr.Zero);

            // create fbo
            uint FboHandle;

            GL.Ext.GenFramebuffers(1, out FboHandle);
            GL.Ext.BindFramebuffer(FramebufferTarget.FramebufferExt, FboHandle);
            GL.Ext.FramebufferTexture2D(FramebufferTarget.FramebufferExt, FramebufferAttachment.ColorAttachment0Ext, TextureTarget.Texture2D, ColorTexture, 0);

            // draw to fbo..?
            noForm.DrawBase(this, dc);
            // unbind fbo
            GL.Ext.BindFramebuffer(FramebufferTarget.FramebufferExt, 0); // return to visible framebuffer
            GL.DrawBuffer(DrawBufferMode.Back);

            // 2) go through dirty rects and copy to the window context
            throw new NotImplementedException();
            foreach (var dr in dc.AsRectangles())
            {
                //dostuff
            }

            // 3) call swapbuffers on window context...
            throw new NotImplementedException();

            currentFps = 1f / (float)renderTime.Elapsed.TotalSeconds;
            renderTime.Reset();
        }
コード例 #5
0
 public override void Draw(IDraw rt, Common.Region dirty)
 {
     base.Draw(rt, dirty);
     rt.uDraw.FillRectangle(DisplayRectangle, usb2);
     dtt(0, 0, UHAlign.Left, UVAlign.Top, new Color(1, 1, 0, 0), rt);
     dtt(100, 0, UHAlign.Center, UVAlign.Top, new Color(1, 1, 1, 0), rt);
     dtt(200, 0, UHAlign.Right, UVAlign.Top, new Color(1, 1, 0, 1), rt);
     dtt(0, 100, UHAlign.Left, UVAlign.Middle, new Color(1, 0, 1, 1), rt);
     dtt(100, 100, UHAlign.Center, UVAlign.Middle, new Color(1, 0, 1, 0), rt);
     dtt(200, 100, UHAlign.Right, UVAlign.Middle, new Color(1, 1, 1, 0), rt);
     dtt(0, 200, UHAlign.Left, UVAlign.Bottom, new Color(1, 1, 0, 1), rt);
     dtt(100, 200, UHAlign.Center, UVAlign.Bottom, new Color(1, 1, 1, 0), rt);
     dtt(200, 200, UHAlign.Right, UVAlign.Bottom, new Color(1, 0, 0, 1), rt);
 }
コード例 #6
0
ファイル: D2DSwapChain.cs プロジェクト: windygu/noForms
        void RenderPass(Common.Region dc, Common.Size ReqSize)
        {
            renderTime.Start();
            // Resize the form and backbuffer to noForm.Size
            Resize(ReqSize);

            Win32Util.Size w32Size = new Win32Util.Size((int)ReqSize.width, (int)ReqSize.height);
            Win32Util.SetWindowSize(w32Size, winHandle); // FIXME blocks when closing->endrender event is locked...

            // Allow noform size to change as requested..like a layout hook (truncating layout passes with the render passes for performance)
            RenderSizeChanged(ReqSize);

            // Do Drawing stuff
            DrawingSize rtSize = new DrawingSize((int)d2dRenderTarget.Size.Width, (int)d2dRenderTarget.Size.Height);

            using (Texture2D t2d = new Texture2D(backBuffer.Device, backBuffer.Description))
            {
                using (Surface1 srf = t2d.QueryInterface <Surface1>())
                {
                    using (RenderTarget trt = new RenderTarget(d2dFactory, srf, new RenderTargetProperties(d2dRenderTarget.PixelFormat)))
                    {
                        _backRenderer.renderTarget = trt;
                        trt.BeginDraw();
                        noForm.DrawBase(this, dc);
                        trt.EndDraw();

                        foreach (var rc in dc.AsRectangles())
                        {
                            t2d.Device.CopySubresourceRegion(t2d, 0,
                                                             new ResourceRegion()
                            {
                                Left = (int)rc.left, Right = (int)rc.right, Top = (int)rc.top, Bottom = (int)rc.bottom, Back = 1, Front = 0
                            }, backBuffer, 0,
                                                             (int)rc.left, (int)rc.top, 0);
                        }
                    }
                }
            }
            swapchain.Present(0, PresentFlags.None);

            //System.Threading.Thread.Sleep(1000);
            lastFrameRenderDuration = 1f / (float)renderTime.Elapsed.TotalSeconds;
            renderTime.Reset();
        }
コード例 #7
0
ファイル: BllRegion.cs プロジェクト: windygu/mysoftsolution
        /// <summary>
        /// Gets the by country id.
        /// </summary>
        /// <param name="name">The county name.</param>
        /// <returns>
        /// A list of <see cref="Common.Region"/> objects
        /// </returns>
        public Common.Region GetByName(string name)
        {
            string key = string.Format(cacheKeyNameRegion, name);

            Common.Region result = Common.Util.CacheGet <Common.Region>(key);

            if (result == null)
            {
                foreach (Common.Region region in this.GetAll())
                {
                    if (name.Equals(region.Name))
                    {
                        result = region;
                    }
                }

                // now we can add it to the cache
                Common.Util.CacheAdd(key, result);
            }

            return(result);
        }
コード例 #8
0
        void RenderPass(Common.Region dc, Common.Size ReqSize)
        {
            renderTime.Start();
            // Resize the backbuffer to noForm.Size, and fire the noForms sizechanged
            Resize(ReqSize);

            // Allow noform size to change as requested..like a layout hook (truncating layout passes with the render passes for performance)
            RenderSizeChanged(ReqSize);

            foreach (var dr in dc.AsRectangles())
            {
                var sdr = SDGTr.trF(dr);
                graphics.FillRectangle(blackBack, sdr);
            }

            // Do Drawing stuff
            noForm.DrawBase(this, dc);

            //res
            winForm.Invoke(new System.Windows.Forms.MethodInvoker(() =>
            {
                winForm.ClientSize = new System.Drawing.Size((int)ReqSize.width, (int)ReqSize.height);
                winForm.Location   = SDGTr.trI(noForm.Location);
            }));

            // flush buffer to window
            var winGr = winForm.CreateGraphics();

            foreach (var dr in dc.AsRectangles())
            {
                var sdr = SDGTr.trF(dr);
                winGr.DrawImage(buffer, sdr, sdr, GraphicsUnit.Pixel);
            }
            winGr.Dispose();
            lastFrameRenderDuration = 1f / (float)renderTime.Elapsed.TotalSeconds;
            renderTime.Reset();
        }
コード例 #9
0
        void RenderPass(Common.Region dc, Common.Size ReqSize)
        {
            renderTime.Start();
            // FIXME so much object spam and disposal in this very high frequency function (also inside Resize called belw).  My poor megabytes!

            // Resize the form and backbuffer to noForm.Size, and fire the noForms sizechanged
            Resize(ReqSize);

            // make size...
            Win32Util.Size w32Size = new Win32Util.Size((int)ReqSize.width, (int)ReqSize.height);
            Win32Util.SetWindowSize(w32Size, hWnd);

            // Allow noform size to change as requested..like a layout hook (truncating layout passes with the render passes for performance)
            RenderSizeChanged(ReqSize);

            lock (noForm)
            {
                // Do Drawing stuff
                DrawingSize rtSize = new DrawingSize((int)d2dRenderTarget.Size.Width, (int)d2dRenderTarget.Size.Height);
                using (Texture2D t2d = new Texture2D(backBuffer.Device, backBuffer.Description))
                {
                    using (Surface1 srf = t2d.QueryInterface <Surface1>())
                    {
                        using (RenderTarget trt = new RenderTarget(d2dFactory, srf, new RenderTargetProperties(d2dRenderTarget.PixelFormat)))
                        {
                            _backRenderer.renderTarget = trt;
                            trt.BeginDraw();
                            noForm.DrawBase(this, dc);
                            // Fill with transparency the edgeBuffer!
                            trt.FillRectangle(new RectangleF(0, noForm.Size.height, noForm.Size.width + edgeBufferSize, noForm.Size.height + edgeBufferSize), scbTrans);
                            trt.FillRectangle(new RectangleF(noForm.Size.width, 0, noForm.Size.width + edgeBufferSize, noForm.Size.height + edgeBufferSize), scbTrans);
                            trt.EndDraw();

                            foreach (var rc in dc.AsRectangles())
                            {
                                t2d.Device.CopySubresourceRegion(t2d, 0,
                                                                 new ResourceRegion()
                                {
                                    Left = (int)rc.left, Right = (int)rc.right, Top = (int)rc.top, Bottom = (int)rc.bottom, Back = 1, Front = 0
                                }, backBuffer, 0,
                                                                 (int)rc.left, (int)rc.top, 0);
                            }
                        }
                    }
                }

                // Present DC to windows (ugh layered windows sad times)
                IntPtr dxHdc = surface.GetDC(false);
                System.Drawing.Graphics dxdc     = System.Drawing.Graphics.FromHdc(dxHdc);
                Win32Util.Point         dstPoint = new Win32Util.Point((int)(noForm.Location.X), (int)(noForm.Location.Y));
                Win32Util.Point         srcPoint = new Win32Util.Point(0, 0);
                Win32Util.Size          pSize    = new Win32Util.Size(rtSize.Width, rtSize.Height);
                Win32Util.BLENDFUNCTION bf       = new Win32Util.BLENDFUNCTION()
                {
                    SourceConstantAlpha = 255, AlphaFormat = Win32Util.AC_SRC_ALPHA, BlendFlags = 0, BlendOp = 0
                };

                bool suc = Win32Util.UpdateLayeredWindow(hWnd, someDC, ref dstPoint, ref pSize, dxHdc, ref srcPoint, 1, ref bf, 2);

                surface.ReleaseDC();
                dxdc.Dispose();
            }
            lastFrameRenderDuration = 1f / (float)renderTime.Elapsed.TotalSeconds;
            renderTime.Reset();
        }
コード例 #10
0
		/// <summary>
		/// Mapping Xml Data which has been retrieved by an xpath expression.
		/// </summary>
		/// <param name="list">The list.</param>
		/// <returns>a mapped item of type: <see cref="Common.Region"/></returns>
		private Common.Region MapData(XmlNodeList list)
		{
			Common.Region item = new Common.Region();
			foreach (XmlNode n in list)
			{
				#region Map Data
				switch (n.Name)
				{
					case "nRegionId":
						item.RegionId = int.Parse(n.InnerText);
						break;
					case "nCountryId":
						item.CountryId = int.Parse(n.InnerText);
						break;
					case "cRegionIso2":
						item.RegionIso2Code = n.InnerText;
						break;
					case "cName":
						item.Name = n.InnerText;
						break;
				}
				#endregion Map Data
			}
			return item;
		}
コード例 #11
0
ファイル: textfieldy.cs プロジェクト: windygu/noForms
 public override void Draw(IDraw rt, Common.Region dirty)
 {
     base.Draw(rt, dirty);
     rt.uDraw.FillRectangle(DisplayRectangle, usb2);
 }