Exemplo n.º 1
0
        protected override void onDraw(Cairo.Context gr)
        {
            Rectangle rBack = new Rectangle (Slot.Size);

            //rBack.Inflate (-Margin);
            //			if (BorderWidth > 0)
            //				rBack.Inflate (-BorderWidth / 2);

            Background.SetAsSource (gr, rBack);
            CairoHelpers.CairoRectangle(gr, rBack, CornerRadius);
            gr.Fill ();

            if (BorderWidth > 0) {
                Foreground.SetAsSource (gr, rBack);
                CairoHelpers.CairoRectangle(gr, rBack, CornerRadius, BorderWidth);
            }

            gr.Save ();
            if (ClipToClientRect) {
                //clip to client zone
                CairoHelpers.CairoRectangle (gr, ClientRectangle,Math.Max(0.0, CornerRadius-Margin));
                gr.Clip ();
            }

            if (child != null)
                child.Paint (ref gr);
            gr.Restore ();
        }
Exemplo n.º 2
0
        protected virtual void updateMouseLocalPos(Crow.Point mPos)
        {
            Crow.Rectangle r  = ScreenCoordinates(Slot);
            Crow.Rectangle cb = ClientRectangle;
            mousePos = mPos - r.Position;

            mousePos.X = Math.Max(cb.X, mousePos.X);
            mousePos.X = Math.Min(cb.Right, mousePos.X);
            mousePos.Y = Math.Max(cb.Y, mousePos.Y);
            mousePos.Y = Math.Min(cb.Bottom, mousePos.Y);
        }
Exemplo n.º 3
0
        protected override void onDraw(Cairo.Context gr)
        {
            base.onDraw(gr);

            if (string.IsNullOrEmpty(cardName))
            {
                return;
            }

            Crow.Rectangle r = ClientRectangle;
            //int zoom = 50;
            string imgPath = cardName + ".full.jpg";

            string[] imgsPath = Directory.GetFiles(Magic.cardImgsBasePath, imgPath, SearchOption.AllDirectories);

            if (imgsPath.Length == 0)
            {
                return;
            }

            System.Drawing.Bitmap bmp = null;
            using (Stream s = new FileStream(imgsPath[0], FileMode.Open)) {
                bmp = new System.Drawing.Bitmap(s);
            }

            if (bmp == null)
            {
                return;
            }

            System.Drawing.Imaging.BitmapData data = bmp.LockBits
                                                         (new System.Drawing.Rectangle(0, 0, bmp.Width, bmp.Height),
                                                         System.Drawing.Imaging.ImageLockMode.ReadOnly, System.Drawing.Imaging.PixelFormat.Format32bppArgb);

            int stride = data.Stride;


            using (ImageSurface imgSurf = new ImageSurface(data.Scan0, Format.Argb32,
                                                           bmp.Width, bmp.Height, 4 * bmp.Width)) {
                gr.SetSourceSurface(imgSurf, r.Width / 2 - bmp.Width / 2, r.Height / 2 - bmp.Height / 2);
                gr.Paint();
            }
            bmp.UnlockBits(data);
        }
Exemplo n.º 4
0
        public InterfaceControler(Rectangle ifaceBounds)
        {
            iRect = ifaceBounds;

            CrowInterface = new Interface ();

            #if MEASURE_TIME
            PerfMeasures = new List<PerformanceMeasure> (
                new PerformanceMeasure[] {
                    this.CrowInterface.updateMeasure,
                    this.CrowInterface.layoutingMeasure,
                    this.CrowInterface.clippingMeasure,
                    this.CrowInterface.drawingMeasure,
                    this.glDrawMeasure
                }
            );
            #endif

            Thread t = new Thread (interfaceThread);
            t.IsBackground = true;
            t.Start ();

            initGL ();
        }
Exemplo n.º 5
0
 public override void ProcessResize(Rectangle newSize)
 {
 }
Exemplo n.º 6
0
 public ProjectiveIFaceControler(Rectangle ifaceBounds, Matrix4 _ifaceModelMat)
     : base(ifaceBounds)
 {
     ifaceModelMat = _ifaceModelMat;
 }
Exemplo n.º 7
0
 public virtual void ProcessResize(Rectangle newSize)
 {
     iRect = newSize;
     CrowInterface.ProcessResize(newSize);
     createContext ();
     GL.Viewport (0, 0, newSize.Width, newSize.Height);//TODO:find a better place for this
 }
Exemplo n.º 8
0
 public abstract void SetAsSource(Cairo.Context ctx, Rectangle bounds = default(Rectangle));
Exemplo n.º 9
0
        public Rectangle Intersection(Rectangle r)
        {
            Rectangle result = new Rectangle();

            if (r.Left >= this.Left)
                result.Left = r.Left;
            else
                result.TopLeft = this.TopLeft;

            if (r.Right >= this.Right)
                result.Width = this.Right - result.Left;
            else
                result.Width = r.Right - result.Left;

            if (r.Top >= this.Top)
                result.Top = r.Top;
            else
                result.Top = this.Top;

            if (r.Bottom >= this.Bottom)
                result.Height = this.Bottom - result.Top;
            else
                result.Height = r.Bottom - result.Top;

            return result;
        }
Exemplo n.º 10
0
        public bool Intersect(Rectangle r)
        {
            int maxLeft = Math.Max(this.Left, r.Left);
            int minRight = Math.Min(this.Right, r.Right);
            int maxTop = Math.Max(this.Top, r.Top);
            int minBottom = Math.Min(this.Bottom, r.Bottom);

            return (maxLeft < minRight) && (maxTop < minBottom) ?
                true : false;
        }
Exemplo n.º 11
0
 public bool ContainsOrIsEqual(Rectangle r)
 {
     return r.TopLeft >= this.TopLeft && r.BottomRight <= this.BottomRight ? true : false;
 }
Exemplo n.º 12
0
        void computeBounds(uint[] indProfile)
        {
            float minX = float.MaxValue,
            maxX = float.MinValue,
            minY = float.MaxValue,
            maxY = float.MinValue;

            for (int i = 0; i < indProfile.Length; i++) {
                Vector3 p = puzzle.positions [indProfile [i]];
                if (p.X < minX)
                    minX = p.X;
                if (p.X > maxX)
                    maxX = p.X;
                if (p.Y < minY)
                    minY = p.Y;
                if (p.Y > maxY)
                    maxY = p.Y;
            }
            Bounds = new Rectangle<float> (minX, minY, maxX - minX, maxY - minY);
        }
Exemplo n.º 13
0
        protected override void onDraw(Cairo.Context gr)
        {
            if (datas == null)
            {
                return;
            }

            lock (mutex) {
                gr.SelectFontFace(Font.Name, Font.Slant, Font.Wheight);
                gr.SetFontSize(Font.Size);

                Crow.Rectangle scrBar = ClientRectangle;
                if (datas?.Count > visibleLines)
                {
                    scrBar.X    += ClientRectangle.Width - scrBarWidth;
                    scrBar.Width = scrBarWidth;
                }
                Crow.Rectangle r = ClientRectangle;
                r.Width -= scrBarWidth;

                int diffScroll  = lastScroll - scroll;
                int diffVisible = visibleLines - lastVisibleLines;

                int limInf = 0;
                int limSup = diffScroll + diffVisible;

                if (diffScroll < 0)
                {
                    limInf = lastVisibleLines + diffScroll;
                    limSup = visibleLines;
                }

                gr.Save();
                gr.ResetClip();

                gr.Rectangle(r.X, r.Y + limInf * fe.Height, r.Width, (limSup - limInf) * fe.Height);
                if (lastHoverIndex != HoverIndex)
                {
                    if (lastHoverIndex >= 0)
                    {
                        gr.Rectangle(r.X, r.Y + (lastHoverIndex - Scroll) * fe.Height, r.Width, fe.Height);
                    }
                    if (HoverIndex >= 0)
                    {
                        gr.Rectangle(r.X, r.Y + (HoverIndex - Scroll) * fe.Height, r.Width, fe.Height);
                    }
                }
                if (lastSelectedIndex != SelectedIndex)
                {
                    if (lastSelectedIndex >= 0)
                    {
                        gr.Rectangle(r.X, r.Y + (lastSelectedIndex - Scroll) * fe.Height, r.Width, fe.Height);
                    }
                    if (selectedIndex >= 0)
                    {
                        gr.Rectangle(r.X, r.Y + (SelectedIndex - Scroll) * fe.Height, r.Width, fe.Height);
                    }
                }
                if (datas?.Count > visibleLines && diffScroll != 0)
                {
                    gr.Rectangle(scrBar);
                }

                gr.ClipPreserve();
                gr.Operator = Operator.Clear;
                gr.Fill();
                gr.Operator = Operator.Over;

                base.onDraw(gr);

                Foreground.SetAsSource(gr);

                int i = limInf;
                while (i < limSup)
                {
                    if (i + Scroll >= Datas.Count)
                    {
                        break;
                    }
                    drawDataLine(gr, i + Scroll, r.X, r.Y + i * fe.Height, (double)r.Width, fe.Height);
                    i++;
                }
                int redrawnLines = limSup - limInf;
                System.Diagnostics.Debug.WriteLine("draw {0} lines from {1} to {2}", redrawnLines, limInf, limSup - 1);
                if (lastHoverIndex != HoverIndex)
                {
                    if (lastHoverIndex >= 0 && (redrawnLines == 0 || (lastHoverIndex < limInf + Scroll || lastHoverIndex >= limSup + Scroll)))
                    {
                        drawDataLine(gr, lastHoverIndex, r.X, r.Y + (lastHoverIndex - Scroll) * fe.Height, (double)r.Width, fe.Height);
                    }
                    if (HoverIndex >= 0 && (redrawnLines == 0 || (HoverIndex < limInf + Scroll || HoverIndex >= limSup + Scroll)))
                    {
                        drawDataLine(gr, HoverIndex, r.X, r.Y + (HoverIndex - Scroll) * fe.Height, (double)r.Width, fe.Height);
                    }
                }
                if (lastSelectedIndex != SelectedIndex)
                {
                    if (lastSelectedIndex >= 0 && (redrawnLines == 0 || (lastSelectedIndex < limInf + Scroll || lastSelectedIndex >= limSup + Scroll)))
                    {
                        drawDataLine(gr, lastSelectedIndex, r.X, r.Y + (lastSelectedIndex - Scroll) * fe.Height, (double)r.Width, fe.Height);
                    }
                    if (SelectedIndex >= 0 && (redrawnLines == 0 || (SelectedIndex < limInf + Scroll || SelectedIndex >= limSup + Scroll)))
                    {
                        drawDataLine(gr, SelectedIndex, r.X, r.Y + (SelectedIndex - Scroll) * fe.Height, (double)r.Width, fe.Height);
                    }
                }

                double x = ClientRectangle.X;
                gr.LineWidth = 1;
                for (i = 0; i < cols.Length; i++)
                {
                    x += (double)r.Width * cols [i];
                    gr.MoveTo(Math.Floor(x) + 0.5, 0);
                    gr.LineTo(Math.Floor(x) + 0.5, r.Height);
                }
                gr.Stroke();

                lastScroll        = Scroll;
                lastHoverIndex    = HoverIndex;
                lastSelectedIndex = SelectedIndex;
                lastVisibleLines  = visibleLines;

                if (Datas?.Count <= visibleLines)
                {
                    gr.Restore();
                    return;
                }
                if (mouseScrolling)
                {
                    new SolidColor(Crow.Color.Jet.AdjustAlpha(0.5)).SetAsSource(gr);
                }
                else
                {
                    new SolidColor(Crow.Color.LightGray.AdjustAlpha(0.5)).SetAsSource(gr);
                }
                CairoHelpers.CairoRectangle(gr, scrBar, 0.0);
                gr.Fill();
                new SolidColor(Crow.Color.BlueCrayola.AdjustAlpha(0.7)).SetAsSource(gr);
                scrBar.Y     += (int)((double)scrBar.Height * (double)Scroll / (double)Datas.Count);
                scrBar.Height = (int)((double)scrBar.Height * (double)visibleLines / (double)Datas.Count);
                CairoHelpers.CairoRectangle(gr, scrBar, 2.0);
                gr.Fill();
                gr.Restore();
            }
        }
Exemplo n.º 14
0
        public override void SetAsSource(Cairo.Context ctx, Rectangle bounds = default(Rectangle))
        {
            Cairo.Gradient grad = null;
            switch (GradientType) {
            case Type.Vertical:
                grad = new Cairo.LinearGradient (bounds.Left, bounds.Top, bounds.Left, bounds.Bottom);
                break;
            case Type.Horizontal:
                grad = new Cairo.LinearGradient (bounds.Left, bounds.Top, bounds.Right, bounds.Top);
                break;
            case Type.Oblic:
                grad = new Cairo.LinearGradient (bounds.Left, bounds.Top, bounds.Right, bounds.Bottom);
                break;
            case Type.Radial:
                throw new NotImplementedException ();
            }

            foreach (ColorStop cs in Stops)
                grad.AddColorStop (cs.Offset, cs.Color);

            ctx.SetSource (grad);
            grad.Dispose ();
        }
Exemplo n.º 15
0
 public override void SetAsSource(Cairo.Context ctx, Rectangle bounds = default(Rectangle))
 {
     ctx.SetSourceRGBA (color.R, color.G, color.B, color.A);
 }