Beispiel #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;
        }
Beispiel #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;
        }
Beispiel #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;
        }
Beispiel #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);
            }
        }
Beispiel #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);
        }
Beispiel #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);
        }
Beispiel #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);
 }
Beispiel #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);
 }
Beispiel #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);
        }
Beispiel #13
0
 private void drawText(string text, GraphicsContext gc, Brush brush)
 {
     gc.Graphics.DrawString(text, TypingFont, brush, gc.DocumentArea, TextStringFormat);
 }
Beispiel #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);
        }
Beispiel #15
0
 private void drawImportedText(GraphicsContext gc)
 {
     drawText(ImportedText.Expanded.ToString(), gc, Theme.ImportedTextColor);
 }
Beispiel #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]);
            }
        }
Beispiel #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);
        }
Beispiel #18
0
 private RectangleF[] getCharAreas(string text, int[] charIndexes, GraphicsContext gc)
 {
     return getCharAreas(text, charIndexes, gc.Graphics, gc.DocumentArea);
 }
Beispiel #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;
            }
        }
Beispiel #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;
        }
Beispiel #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));
 }
Beispiel #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)
 {
 }
Beispiel #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);
     }
 }
Beispiel #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();
        }
Beispiel #25
0
 private RectangleF getCharArea(string text, int charIndex, GraphicsContext gc)
 {
     return getCharArea(text, charIndex, gc.Graphics, gc.DocumentArea);
 }
Beispiel #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,
            });
        }
Beispiel #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;
        }
Beispiel #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);
            }
        }
Beispiel #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);
        }
Beispiel #30
0
 private void drawDebugMessage(string message, GraphicsContext gc)
 {
     drawDebugMessage(message, gc, true);
 }