Ejemplo n.º 1
0
        public Texture(
			GraphicsContext graphics,
			int width,
			int height)
            : base(graphics)
        {
            this.Index = this.Graphics.AllocateTextureIndex();
            this.Handle = this.Graphics.GL.GenTexture();

            graphics.GL.ActiveTexture(GLContext.Texture0 + this.Index);
            graphics.GL.BindTexture(GLContext.Texture2D, this.Handle);

            graphics.GL.TexImage2D(
                GLContext.Texture2D,
                0,
                (int)GLContext.Rgba8,
                width,
                height,
                0,
                GLContext.Rgba,
                (int)GLContext.UnsignedByte,
                null);

            this.Width = width;
            this.Height = height;
        }
Ejemplo n.º 2
0
        public static Texture2D LoadFromBytes(GraphicsContext graphics, byte[] bytes, int width, int height, TextureParams parameters)
        {
            if (graphics == null)
                throw new ArgumentNullException("graphics");

            if (bytes == null)
                throw new ArgumentNullException("bytes");

            Texture2D texture = new Texture2D(graphics);

            Texture.Initialize(texture, graphics, GLContext.Texture2D, bytes, parameters);

            graphics.GL.TexImage2D(
                GLContext.Texture2D,
                0,
                (int)GLContext.Rgba8,
                width,
                height,
                0,
                GLContext.Rgba,
                (int)GLContext.UnsignedByte,
                bytes);

            texture.Width = width;
            texture.Height = height;

            return texture;
        }
Ejemplo n.º 3
0
        public static Texture1D LoadFromBytes(GraphicsContext graphics, byte[] bytes, int length, TextureParams parameters)
        {
            if (graphics == null)
                throw new ArgumentNullException("graphics");

            if (bytes == null)
                throw new ArgumentNullException("bytes");

            Texture1D texture = new Texture1D(graphics);

            Texture.Initialize(texture, graphics, GLContext.Texture1D, bytes, parameters);

            graphics.GL.TexImage1D(
                GLContext.Texture1D,
                0,
                (int)GLContext.Rgba8,
                length,
                0,
                GLContext.Rgba,
                (int)GLContext.UnsignedByte,
                bytes);

            texture.Length = length;

            return texture;
        }
Ejemplo n.º 4
0
        public override void renderCell(GraphicsContext g, object value, CellRenderState render_state = CellRenderState.Normal)
        {
            base.renderCell(g, value, render_state);

            if (value != null)
            {
                GraphicsState gs = g.Graphics.Save();

                //aplikuje padding
                Padding pad = this.Padding;

                RectangleF area = new RectangleF(g.Graphics.ClipBounds.X + pad.Left,
                                                 g.Graphics.ClipBounds.Y + pad.Top,
                                                 g.Graphics.ClipBounds.Width - pad.Right - pad.Left,
                                                 g.Graphics.ClipBounds.Height - pad.Bottom - pad.Top);

                g.Graphics.SetClip(area);

                string hodnota = value.ToString();

                SizeF velikost = g.Graphics.MeasureString(hodnota, g.Font); //spocitam jakou velikost zabere vykreslena hodnota

                Font font;

                Color color;

                font = g.Font;
                color = this.GetFontColor(render_state);

                g.Graphics.DrawString(hodnota, font, new SolidBrush(color), g.Graphics.ClipBounds, string_format);

                g.Graphics.Restore(gs);
            }
        }
Ejemplo n.º 5
0
        protected override void OnPaint(PaintEventArgs e)
        {
            base.OnPaint(e);
            GraphicsContext gc = new GraphicsContext();
            gc.Graphics = e.Graphics;

            this.RenderRow(gc, this.row);

            this.RenderVerticalLines(gc);
        }
Ejemplo n.º 6
0
        public static Texture1D LoadFromFile(GraphicsContext graphics, string fileName, TextureParams parameters)
        {
            if (graphics == null)
                throw new ArgumentNullException("graphics");

            if (fileName == null)
                throw new ArgumentNullException("fileName");

            using (FileStream file = new FileStream(fileName, FileMode.Open, FileAccess.Read))
                return LoadFromStream(graphics, file, parameters);
        }
Ejemplo n.º 7
0
        protected override void OnPaint(PaintEventArgs e)
        {
            base.OnPaint(e);
            GraphicsContext gc = new GraphicsContext();
            gc.Graphics = e.Graphics;

            foreach (IRow r in this.Rows.GetPinnedRows())
            {
                this.RenderRow(gc, r);
            }

            this.RenderVerticalLines(gc);
        }
 public void Dispose(bool disposing)
 {
     if (this.nextContext != null)
     {
         this.nextContext.Dispose();
         this.nextContext = null;
     }
     if (this.clipRegion != null)
     {
         this.clipRegion.Dispose();
         this.clipRegion = null;
     }
 }
 public GraphicsContainer BeginContainer()
 {
     GraphicsContext context = new GraphicsContext(this);
     int state = 0;
     int status = SafeNativeMethods.Gdip.GdipBeginContainer2(new HandleRef(this, this.NativeGraphics), out state);
     if (status != 0)
     {
         context.Dispose();
         throw SafeNativeMethods.Gdip.StatusException(status);
     }
     context.State = state;
     this.PushContext(context);
     return new GraphicsContainer(state);
 }
Ejemplo n.º 10
0
        public static Texture1D LoadFromStream(GraphicsContext graphics, Stream stream, TextureParams parameters)
        {
            if (graphics == null)
                throw new ArgumentNullException("graphics");

            if (stream == null)
                throw new ArgumentNullException("stream");

            using (Bitmap bitmap = (Bitmap)Bitmap.FromStream(stream))
            {
                byte[] bytes = BitmapHelper.GetBytes(bitmap);
                return LoadFromBytes(graphics, bytes, bitmap.Width * bitmap.Height, parameters);
            }
        }
 public GraphicsContainer BeginContainer(RectangleF dstrect, RectangleF srcrect, GraphicsUnit unit)
 {
     GraphicsContext context = new GraphicsContext(this);
     int state = 0;
     GPRECTF dstRect = dstrect.ToGPRECTF();
     GPRECTF srcRect = srcrect.ToGPRECTF();
     int status = SafeNativeMethods.Gdip.GdipBeginContainer(new HandleRef(this, this.NativeGraphics), ref dstRect, ref srcRect, (int) unit, out state);
     if (status != 0)
     {
         context.Dispose();
         throw SafeNativeMethods.Gdip.StatusException(status);
     }
     context.State = state;
     this.PushContext(context);
     return new GraphicsContainer(state);
 }
Ejemplo n.º 12
0
        protected override void OnPaint(PaintEventArgs e)
        {
            base.OnPaint(e);

            if (this.Columns == null || this.Rows == null) return;

            //vykresli bunky
            GraphicsContext gc = new GraphicsContext();
            gc.Graphics = e.Graphics;
            int y = 0;
            for (int i = this.StartIndex; i < this.Rows.Count && y < this.ClientSize.Height; i++)
            {
                IRow radek = this.Rows[i];

                y += radek.Height + 1;

                this.RenderRow(gc, radek);
            }

            gc.Graphics.ResetTransform();

            RenderVerticalLines(gc);
        }
Ejemplo n.º 13
0
 private void drawText(string text, GraphicsContext gc, Brush brush)
 {
     gc.Graphics.DrawString(text, TypingFont, brush, gc.DocumentArea, TextStringFormat);
 }
Ejemplo n.º 14
0
        private void drawShadowText(GraphicsContext gc)
        {
            string shadowText = ImportedText.Expanded.Substring(0, TypedText.ExpandedLength);

            if (TypedText.Length > 0)
            {
                string importedText = ImportedText.Expanded.ToString();
                int lastIndex = TypedText.ExpandedLength - 1;

                int lineJumpIndex = findLineJump(importedText, lastIndex, gc);
                if (lineJumpIndex < lastIndex)
                    shadowText = insertSpacesAfterJump(importedText, shadowText,
                                                       lineJumpIndex, lastIndex,
                                                       gc);
            }

            drawText(shadowText, gc, Theme.TypedTextColor);
        }
Ejemplo n.º 15
0
 private void drawImportedText(GraphicsContext gc)
 {
     drawText(ImportedText.Expanded.ToString(), gc, Theme.ImportedTextColor);
 }
Ejemplo n.º 16
0
        private void drawErrorChars(GraphicsContext gc)
        {
            RectangleF[] errorCharAreas = getCharAreas(ImportedText.Expanded.ToString(),
                                                       TypedText.ExpandedErrorsUncorrected,
                                                       gc);

            for (int i = 0; i < TypedText.ErrorsUncorrected.Count; i++)
            {
                gc.Graphics.FillRectangle(Theme.ErrorBackColor, fracOffsetCharArea(errorCharAreas[i], 0, ErrorBackgroundVOffset));

                drawChar(TypedText[TypedText.ErrorsUncorrected[i]],
                         gc, Theme.ErrorForeColor,
                         errorCharAreas[i]);
            }
        }
Ejemplo n.º 17
0
        private void drawDebugMessage(string message, GraphicsContext gc, bool atBottom)
        {
            float y = atBottom ? (gc.TypingArea.Y + gc.TypingArea.Height - 16) : gc.TypingArea.Y;

            RectangleF position = new RectangleF(gc.TypingArea.X, y,
                                                 gc.TypingArea.Width, 16);

            using (Font font = new Font("Courier New", 10))
                gc.Graphics.DrawString(message, font, Brushes.Red, position, TextStringFormat);
        }
Ejemplo n.º 18
0
 private RectangleF[] getCharAreas(string text, int[] charIndexes, GraphicsContext gc)
 {
     return getCharAreas(text, charIndexes, gc.Graphics, gc.DocumentArea);
 }
Ejemplo n.º 19
0
        protected override void OnPaint(PaintEventArgs pe)
        {
            base.OnPaint (pe);

            var focused = GetFocusedExpr ();
            if (_visual != null)
            {
                pe.Graphics.SmoothingMode = SmoothingMode.AntiAlias;
                var ctx = new GraphicsContext (pe.Graphics, focused, VisualStyle.Default);
                GraphicsContext.HitRects = StrictList<HitRect>.Empty;
                _visual.Render (ctx, _size);
                _hitRects = GraphicsContext.HitRects;
            }
        }
Ejemplo n.º 20
0
        private int findLineJump(string text, int lastIndex, GraphicsContext gc)
        {
            RectangleF importedCharArea, shadowCharArea;
            int lineJumpIndex = lastIndex;

            while (lineJumpIndex >= 0)
            {
                importedCharArea = getCharArea(text, lineJumpIndex, gc);

                shadowCharArea = getCharArea(text.Substring(0, lineJumpIndex + 1), lineJumpIndex, gc);

                if (importedCharArea.IsEmpty || shadowCharArea.IsEmpty)
                    return lastIndex;

                if (shadowCharArea.Y == importedCharArea.Y)
                    return lineJumpIndex;

                lineJumpIndex--;
            }

            return lastIndex;
        }
Ejemplo n.º 21
0
 /// <summary>
 /// standardni vykresleni hlavicky sloupce
 /// </summary>
 /// <param name="g"></param>
 /// <param name="context"></param>
 public void renderHead(GraphicsContext g, ColumnContext context)
 {
     g.Graphics.Clear(Color.DarkGray);
     g.Graphics.DrawString(this.HeadText, g.Font, Brushes.Black, new PointF(3, 3));
 }
Ejemplo n.º 22
0
 /// <summary>
 /// vykresli pozadi pod bunkou
 /// </summary>
 /// <param name="g"></param>
 /// <param name="render_state"></param>
 public void renderCellBackground(GraphicsContext g, CellRenderState render_state = CellRenderState.Normal)
 {
 }
Ejemplo n.º 23
0
 public virtual void renderCell(GraphicsContext g, object value, CellRenderState render_state = CellRenderState.Normal)
 {
     if (render_state == CellRenderState.Selected)
     {
         Rectangle r = new Rectangle(0, 0, (int)g.Graphics.ClipBounds.Width, (int)g.Graphics.ClipBounds.Height);
         g.Graphics.FillRectangle(SystemBrushes.Highlight, r);
     }
 }
Ejemplo n.º 24
0
        public void Run()
        {
            var renderer = (Platform.GetExecutingPlatform() == PlatformType.Windows)
                               ? Renderer.DirectX
                               : Renderer.OpenGL;

            if (Environment.CommandLine.Contains("-opengl"))
            {
                renderer = Renderer.OpenGL;
            }

            GraphicsContext = GraphicsContextLoader.Create(renderer, _windowAttributes);

            GraphicsContext.MouseMove += OnMouseMove;
            GraphicsContext.MouseDown += OnMouseDown;
            GraphicsContext.KeyDown += HandleDebugKeyDown;
            GraphicsContext.KeyUp += OnKeyUp;
            GraphicsContext.KeyPress += OnKeyPress;
            GraphicsContext.MouseUp += OnMouseUp;
            GraphicsContext.MouseWheel += OnMouseWheel;
            GraphicsContext.RenderBegin += OnRenderBegin;
            GraphicsContext.Render += OnRender;
            GraphicsContext.Resize += OnResize;

            // todo: form closed?
            /*
            _form.Closed += (o, args) => {
                isFormClosed = true;
                OnFormClosed();

            };
             */

            OnInitialize();
            OnResourceLoad();

            GraphicsContext.Run();

            OnResourceUnload();
        }
Ejemplo n.º 25
0
 private RectangleF getCharArea(string text, int charIndex, GraphicsContext gc)
 {
     return getCharArea(text, charIndex, gc.Graphics, gc.DocumentArea);
 }
Ejemplo n.º 26
0
        private void drawClipMargins(GraphicsContext gc)
        {
            gc.Graphics.FillRectangle(Brushes.White, new RectangleF()
            {
                X = 0,
                Y = 0,
                Width = gc.ControlBounds.Width,
                Height = gc.TypingArea.Y + 1,
            });

            gc.Graphics.FillRectangle(Brushes.White, new RectangleF()
            {
                X = 0,
                Y = 0,
                Width = gc.TypingArea.X,
                Height = gc.ControlBounds.Height,
            });
        }
Ejemplo n.º 27
0
        private string insertSpacesAfterJump(string text, string shadowText, int lineJumpIndex, int lastIndex, GraphicsContext gc)
        {
            RectangleF importedCharArea = getCharArea(text, lastIndex, gc);

            RectangleF shadowCharArea;
            int spaces = 0;

            do
            {
                shadowText = shadowText.Insert(lineJumpIndex + 1, " ");
                spaces++;

                shadowCharArea = getCharArea(shadowText, lastIndex + spaces, gc);
            }
            while (shadowCharArea.Y < importedCharArea.Y);

            return shadowText;
        }
Ejemplo n.º 28
0
        private void drawCursor(GraphicsContext gc)
        {
            CancelEventArgs e = new CancelEventArgs(false);

            OnDrawingCursor(e);

            if (!e.Cancel)
            {
                RectangleF cursorArea = getCharArea(ImportedText.Expanded.ToString(),
                                                    TypedText.ExpandedLength, gc);

                cursorArea = fracOffsetCharArea(cursorArea, 0,
                                                CursorAsVerticalBar ? BarCursorVOffset : CharCursorVOffset);

                if (CursorAsVerticalBar)
                {
                    int barCursorWidth = Math.Max(1, 1 + (int)Math.Round(gc.CellSize.Width * BarCursorRelativeWidth, 0));

                    gc.Graphics.FillRectangle(Theme.CursorColor, new RectangleF()
                    {
                        X = cursorArea.X - (0.125f * cursorArea.Width) - (0.5f * barCursorWidth),
                        Y = cursorArea.Y,
                        Width = barCursorWidth,
                        Height = cursorArea.Height,
                    });
                }
                else
                    drawChar(CharCursorChar, gc, Theme.CursorColor, cursorArea);
            }
        }
Ejemplo n.º 29
0
        private void drawChar(char ch, GraphicsContext gc, Brush brush, RectangleF charArea)
        {
            if (ch == '\n')
                ch = pilcrow;

            gc.Graphics.DrawString(ch.ToString(), TypingFont, brush, charArea, SingleCharStringFormat);
        }
Ejemplo n.º 30
0
 private void drawDebugMessage(string message, GraphicsContext gc)
 {
     drawDebugMessage(message, gc, true);
 }