Ejemplo n.º 1
0
        public ClassFigure()
            : base()
        {
            FillColor = new Cairo.Color(0.8, 0.0, 0.0, 0.8);

            classname = new SimpleTextFigure("ClassName");
        }
Ejemplo n.º 2
0
 public Segment (string title, double percent, Cairo.Color color, bool showInBar)
 {
     this.title = title;
     this.percent = percent;
     this.color = color;
     this.show_in_bar = showInBar;
 }
 protected AbstractHandle(Figure owner)
 {
     Owner = owner;
     LineWidth = 1.0;
     FillColor = new Cairo.Color (0.2, 1.0, 0.2, 0.8);
     LineColor = new Cairo.Color (0.0, 0.0, 0.0, 1.0);
 }
Ejemplo n.º 4
0
		// these methods all assume that the BitsPerSample is 8 (byte).  Pixbuf documentation
		// states that values from 1-16 are allowed, but currently only 8 bit samples are supported.
		// http://library.gnome.org/devel/gdk-pixbuf/unstable/gdk-pixbuf-gdk-pixbuf.html#GdkPixbuf--bits-per-sample
		
		/// <summary>
		/// Applies a color transformation to each pixel in a pixbuf.
		/// </summary>
		/// <param name="colorTransform">
		/// A <see cref="Func<Cairo.Color, Cairo.Color>"/>
		/// </param>
		/// <returns>
		/// A reference to the input Pixbuf (the 'this' reference).
		/// </returns>
		public static Pixbuf PixelColorTransform (this Pixbuf source, Func<Cairo.Color, Cairo.Color> colorTransform)
		{
			try {
				if (source.BitsPerSample != 8)
					throw new Exception ("Pixbuf does not have 8 bits per sample, it has " + source.BitsPerSample);
				
				unsafe {
					double r, g, b;
					byte* pixels = (byte*) source.Pixels;
					for (int i = 0; i < source.Height * source.Rowstride / source.NChannels; i++) {
						r = (double) pixels[0];
						g = (double) pixels[1];
						b = (double) pixels[2];
						
						Cairo.Color color = new Cairo.Color (r / byte.MaxValue, 
						                                     g / byte.MaxValue, 
						                                     b / byte.MaxValue);
						
						color = colorTransform.Invoke (color);
						
						pixels[0] = (byte) (color.R * byte.MaxValue);
						pixels[1] = (byte) (color.G * byte.MaxValue);
						pixels[2] = (byte) (color.B * byte.MaxValue);
						
						pixels += source.NChannels;
					}
				}
			} catch (Exception e) {
				Log<DrawingService>.Error ("Error transforming pixbuf: {0}", e.Message);
				Log<DrawingService>.Debug (e.StackTrace);
			}
			return source;
		}
Ejemplo n.º 5
0
        protected override void OnColorsRefreshed ()
        {
            base.OnColorsRefreshed ();

            rule_color = CairoExtensions.ColorShade (ViewFill, 0.95);
            border_color = Colors.GetWidgetColor (GtkColorClass.Dark, StateType.Active);
        }
		public void SetFillColor (Cairo.Color color)
		{
			this.ModifyBase (Gtk.StateType.Normal, CairoExtensions.CairoColorToGdkColor (color));
			this.ModifyBg (Gtk.StateType.Normal, CairoExtensions.CairoColorToGdkColor (color));
			fill_color = color;
			fill_color_set = true;
			QueueDraw ();
		}
Ejemplo n.º 7
0
		protected virtual void OnColorsRefreshed ()
		{
			selection_fill = colors.GetWidgetColor (GtkColorClass.Dark, StateType.Active);
			selection_stroke = colors.GetWidgetColor (GtkColorClass.Background, StateType.Selected);
			
			view_fill = colors.GetWidgetColor (GtkColorClass.Base, StateType.Normal);
			view_fill_transparent = view_fill;
			view_fill_transparent.A = 0;
		}
Ejemplo n.º 8
0
        protected Game(string configPath)
            : this()
        {
            #if DRAWGRID
            _gridColor = Config.Instance.Grid;
            #endif
            Configuration = new Config(configPath);

            State = new InitialState(this, Configuration.SplashScreenColor);
        }
Ejemplo n.º 9
0
        protected override void OnColorsRefreshed ()
        {
            base.OnColorsRefreshed ();

            rule_color = CairoExtensions.ColorShade (ViewFill, 0.95);

            // On Windows we use Normal b/c Active incorrectly returns black (at least on XP)
            border_color = Colors.GetWidgetColor (GtkColorClass.Dark,
              Hyena.PlatformDetection.IsWindows ? StateType.Normal : StateType.Active
            );
        }
Ejemplo n.º 10
0
 public DrawingWidget()
 {
     this.Build();
     lineColor = new Cairo.Color(Double.MaxValue,0,0);
     lineWidth = 6;
     Transparency=0.8;
     selectedTool = DrawTool.PEN;
     loaded = false;
     visible = true;
     preview=false;
 }
Ejemplo n.º 11
0
		public static Cairo.Color CairoColor (Gdk.Color color) {
			double blue = (double)color.Blue / System.UInt16.MaxValue;
			double green = (double)color.Green / System.UInt16.MaxValue;
			double red   = (double)color.Red / System.UInt16.MaxValue;
			
			blue  = Convert.ToDouble (decimal.Round ((decimal) blue, 2));
			green = Convert.ToDouble (decimal.Round ((decimal) green, 2));
			red   = Convert.ToDouble (decimal.Round ((decimal) red, 2));

			Cairo.Color cairo = new Cairo.Color (red, green, blue);
			return cairo;
		}
Ejemplo n.º 12
0
        public AnalogClockHandHandle(IFigure owner, ILocator locator)
            : base(owner, locator)
        {
            _default  = new Cairo.Color (1, 0, 0, 0.8);
            _selected = new Cairo.Color (1, 0, 1, 0.8);
            //We kept the pointer to use it later when requesting cursor
            //and value to update
            _hand     = (AnalogClockHandLocator) locator;

            FillColor = _default;
            LineColor = new Cairo.Color (0.0, 0.0, 0.0, 1.0);
        }
Ejemplo n.º 13
0
        protected virtual void OnColorsRefreshed ()
        {
            selection_fill = colors.GetWidgetColor (GtkColorClass.Dark, StateType.Active);
            selection_stroke = colors.GetWidgetColor (GtkColorClass.Background, StateType.Selected);

            view_fill = colors.GetWidgetColor (GtkColorClass.Base, StateType.Normal);
            view_fill_transparent = view_fill;
            view_fill_transparent.A = 0;

            text_mid = CairoExtensions.AlphaBlend (
                colors.GetWidgetColor (GtkColorClass.Base, StateType.Normal),
                colors.GetWidgetColor (GtkColorClass.Text, StateType.Normal),
                0.5);
        }
Ejemplo n.º 14
0
        public UseCaseFigure()
            : base()
        {
            FillColor = new Cairo.Color(0.8, 0.8, 1.0, 0.8);

            _text = new MultiLineTextFigure("Use Case");

            _text.TextChanged += delegate(object sender, EventArgs args) {
                Resize();
            };

            _text.FontAlignment = Pango.Alignment.Center;
            _text.Padding = 10.0;
        }
Ejemplo n.º 15
0
        public static Color BlendColors(double blend, Color a, Color b)
        {
            if (blend < 0.0 || blend > 1.0)
                throw new ArgumentException (
                    "Blend amount must be greater than 0.0 and less than 1.0.");

            double blend_ratio = 1.0 - blend;

            double blr = (a.R + b.R) * blend_ratio;
            double blg = (a.G + b.G) * blend_ratio;
            double blb = (a.B + b.B) * blend_ratio;

            return new Color (blr, blg, blb);
        }
Ejemplo n.º 16
0
        void DrawTimeNodes(Gdk.Window win)
        {
            bool hasSelectedTimeNode = false;

            using (Cairo.Context g = Gdk.CairoHelper.Create(win)) {
                int height;
                int width;

                win.Resize((int)(frames / pixelRatio), Allocation.Height);
                win.GetSize(out width, out height);

                g.Operator = Operator.Over;

                foreach (T tn in list)
                {
                    if (filter != null && !filter.IsVisible(tn))
                    {
                        continue;
                    }

                    if (!tn.Equals(selected))
                    {
                        Cairo.Color borderColor = new Cairo.Color(color.R + 0.1, color.G + 0.1, color.B + 0.1, 1);
                        CairoUtils.DrawRoundedRectangle(g, tn.StartFrame / pixelRatio, 3,
                                                        tn.TotalFrames / pixelRatio, height - 6,
                                                        SECTION_HEIGHT / 7, color, borderColor);
                    }
                    else
                    {
                        hasSelectedTimeNode = true;
                    }
                }
                //Then we draw the selected TimeNode over the others
                if (hasSelectedTimeNode)
                {
                    Cairo.Color borderColor = new Cairo.Color(0, 0, 0, 1);
                    CairoUtils.DrawRoundedRectangle(g, selected.StartFrame / pixelRatio, 3,
                                                    selected.TotalFrames / pixelRatio, height - 6,
                                                    SECTION_HEIGHT / 7, color, borderColor);
                    if (selected.HasDrawings)
                    {
                        g.MoveTo(selected.KeyFrame / pixelRatio, 3);
                        g.LineTo(selected.KeyFrame / pixelRatio, SECTION_HEIGHT - 3);
                        g.StrokePreserve();
                    }
                }
                DrawLines(win, g, height, width);
            }
        }
Ejemplo n.º 17
0
        public override void DrawColumnHighlight(Cairo.Context cr, Gdk.Rectangle alloc, Cairo.Color color)
        {
            Cairo.Color light_color = CairoExtensions.ColorShade(color, 1.6);
            Cairo.Color dark_color  = CairoExtensions.ColorShade(color, 1.3);

            LinearGradient grad = new LinearGradient(alloc.X, alloc.Y, alloc.X, alloc.Bottom - 1);

            grad.AddColorStop(0, light_color);
            grad.AddColorStop(1, dark_color);

            cr.Pattern = grad;
            cr.Rectangle(alloc.X + 1.5, alloc.Y + 1.5, alloc.Width - 3, alloc.Height - 2);
            cr.Fill();
            grad.Destroy();
        }
Ejemplo n.º 18
0
        public void DrawFooterBackground(Cairo.Context cr, Gdk.Rectangle alloc, int top_offset, bool fill)
        {
            Color gtk_background_color = GetWidgetColor(GtkColorClass.Background, StateType.Normal);
            Color gtk_base_color       = GetWidgetColor(GtkColorClass.Base, StateType.Normal);
            Color light_color          = gtk_background_color.ColorShade(1.1);
            Color dark_color           = gtk_background_color.ColorShade(0.95);

            const CairoCorners corners = CairoCorners.BottomLeft | CairoCorners.BottomRight;

            if (fill)
            {
                LinearGradient grad = new LinearGradient(alloc.X, alloc.Y, alloc.X, alloc.Y + alloc.Height);
                grad.AddColorStop(0, light_color);
                grad.AddColorStop(0.75, dark_color);
                grad.AddColorStop(0, light_color);

                cr.Pattern = grad;
                cr.RoundedRectangle(alloc.X, alloc.Y + top_offset, alloc.Width, alloc.Height - top_offset, BORDER_RADIUS, corners);
                cr.Fill();

                cr.Color = gtk_base_color;
                cr.Rectangle(alloc.X, alloc.Y, alloc.Width, top_offset);
                cr.Fill();
            }
            else
            {
                cr.Color = gtk_base_color;
                cr.RoundedRectangle(alloc.X, alloc.Y, alloc.Width, alloc.Height, BORDER_RADIUS, corners);
                cr.Fill();
            }

            cr.LineWidth = 1.0;
            cr.Translate(alloc.Y + 0.5, alloc.Y - 0.5);

            cr.Color = border_color;
            cr.RoundedRectangle(alloc.X, alloc.Y - 4, alloc.Width - 1, alloc.Height + 4, BORDER_RADIUS, corners);
            cr.Stroke();

            if (fill)
            {
                cr.LineWidth = 1;
                cr.Antialias = Cairo.Antialias.None;
                cr.MoveTo(alloc.X + 1, alloc.Y + 1 + top_offset);
                cr.LineTo(alloc.X + alloc.Width - 1, alloc.Y + 1 + top_offset);
                cr.Stroke();
                cr.Antialias = Cairo.Antialias.Default;
            }
        }
Ejemplo n.º 19
0
		internal MenuItemWidget (MenuItem item) : base()
		{
			TextColor = new Cairo.Color (1, 1, 1);
			this.item = item;
			item.IconChanged += ItemIconChanged;
			item.TextChanged += ItemTextChanged;
			item.DisabledChanged += ItemDisabledChanged;
			
			AddEvents ((int) Gdk.EventMask.AllEventsMask);
			
			HasTooltip = true;
			VisibleWindow = false;
			AboveChild = true;
			
			CalcTextWidth ();
		}
Ejemplo n.º 20
0
    private static void plotArc(int centerx, int centery, int radius, double start, double end,
                                Cairo.Context g, Cairo.Color color)
    {
        //pie chart
        g.MoveTo(centerx, centery);
        g.Arc(centerx, centery, radius, start * Math.PI, end * Math.PI);

        //commented because gets ugly on last radius line (specially if angle is low)
        //g.ClosePath();
        g.SetSourceRGB(color.R, color.G, color.B);
        g.FillPreserve();

        g.SetSourceRGB(0, 0, 0);
        g.LineWidth = 2;
        g.Stroke();
    }
Ejemplo n.º 21
0
        internal MenuItemWidget(MenuItem item) : base()
        {
            TextColor             = new Cairo.Color(1, 1, 1);
            this.item             = item;
            item.IconChanged     += ItemIconChanged;
            item.TextChanged     += ItemTextChanged;
            item.DisabledChanged += ItemDisabledChanged;

            AddEvents((int)Gdk.EventMask.AllEventsMask);

            HasTooltip    = true;
            VisibleWindow = false;
            AboveChild    = true;

            CalcTextWidth();
        }
Ejemplo n.º 22
0
        public static string ToHTMLColor(this Color color, bool withAlpha = false)
        {
            if (withAlpha)
            {
                return(string.Format("#{0:x2}{1:x2}{2:x2}{3:x2}",
                                     (byte)(color.R * 255.0),
                                     (byte)(color.G * 255.0),
                                     (byte)(color.B * 255.0),
                                     (byte)(color.A * 255.0)));
            }

            return(string.Format("#{0:x2}{1:x2}{2:x2}",
                                 (byte)(color.R * 255.0),
                                 (byte)(color.G * 255.0),
                                 (byte)(color.B * 255.0)));
        }
Ejemplo n.º 23
0
        private void FillHalf(PointD coord, Cairo.Color color, Half half)
        {
            if (half == Half.Bottom)
            {
                coord.Y += cellHeight / 2;
            }

            using (Cairo.Context g = Gdk.CairoHelper.Create(this.GdkWindow))
            {
                g.SetSourceRGBA(color.R, color.G, color.B, color.A);
                g.MoveTo(coord);
                g.Rectangle(coord, cellWidth, cellHeight / 2);
                g.Fill();
                g.GetTarget().Dispose();
            }
        }
Ejemplo n.º 24
0
        public ImageCanvas(string fileName, List<BarierPoint> shapeListPoint)
        {
            this.fileName = fileName;
            if (shapeListPoint != null)
                this.shapeListPoint = shapeListPoint;
            else
                shapeListPoint = new List<BarierPoint>();

            if(MainClass.Settings.ImageEditors == null){
                MainClass.Settings.ImageEditors =  new Option.Settings.ImageEditorSetting();
                MainClass.Settings.ImageEditors.LineWidth = 3;
                MainClass.Settings.ImageEditors.PointWidth = 5;

                MainClass.Settings.ImageEditors.LineColor = new Option.Settings.BackgroundColors(10,10,255,32767);
                MainClass.Settings.ImageEditors.PointColor = new Option.Settings.BackgroundColors(10,10,255,32767);
                MainClass.Settings.ImageEditors.SelectPointColor = new Option.Settings.BackgroundColors(255,10,10,32767);
            }

            lineWitdth = MainClass.Settings.ImageEditors.LineWidth;
            pointWidth = MainClass.Settings.ImageEditors.PointWidth;

            Gdk.Color gdkLineColor = new Gdk.Color(MainClass.Settings.ImageEditors.LineColor.Red,
                MainClass.Settings.ImageEditors.LineColor.Green,MainClass.Settings.ImageEditors.LineColor.Blue);

            Gdk.Color gdkPointColor =  new Gdk.Color(MainClass.Settings.ImageEditors.PointColor.Red,
                MainClass.Settings.ImageEditors.PointColor.Green,MainClass.Settings.ImageEditors.PointColor.Blue);

            Gdk.Color gdkSelPointColor =  new Gdk.Color(MainClass.Settings.ImageEditors.SelectPointColor.Red,
                MainClass.Settings.ImageEditors.SelectPointColor.Green,MainClass.Settings.ImageEditors.SelectPointColor.Blue);

            colorLine = gdkLineColor.ToCairoColor(MainClass.Settings.ImageEditors.LineColor.Alpha);
            colorPoint = gdkPointColor.ToCairoColor(MainClass.Settings.ImageEditors.PointColor.Alpha);
            colorSelectPoint = gdkSelPointColor.ToCairoColor(MainClass.Settings.ImageEditors.SelectPointColor.Alpha);

            Gdk.Pixbuf bg;
            try{
                using (var fs = new System.IO.FileStream(fileName, System.IO.FileMode.Open))
                    bg = new Gdk.Pixbuf(fs);

                bg = bg.ApplyEmbeddedOrientation();
                this.HeightImage = bg.Height;
                this.WidthImage= bg.Width;

            }catch(Exception ex){
                Tool.Logger.Error(ex.Message,null);
            }
        }
Ejemplo n.º 25
0
    public void drawTerrain(Context gr)
    {
        Cairo.Color normal_color = new Cairo.Color(0.9, 0.9, 0.9, 1);
        Cairo.Color water_color  = new Cairo.Color(0.8, 0.8, 1.0, 1);

        for (double i = 0; i < width; ++i)
        {
            int  k     = (int)i;
            bool water = false;

            gr.SetSourceColor(normal_color);
            PointD start2 = new PointD(i / width, 0);
            gr.MoveTo(start2);

            PointD end2 = new PointD(i / width, 1 / height);
            for (double j = 1; j < height; ++j)
            {
                if (r.GetColor((int)i, (int)j).R == 0 && !water)
                {
                    gr.LineTo(end2);
                    gr.Stroke();
                    gr.SetSourceColor(water_color);
                    start2.Y = j / height;
                    gr.MoveTo(start2);
                    end2.Y = j / height;
                    water  = true;
                }
                else if (r.GetColor((int)i, (int)j).R > 0 && water)
                {
                    gr.LineTo(end2);
                    gr.Stroke();
                    gr.SetSourceColor(normal_color);
                    start2.Y = j / height;
                    gr.MoveTo(start2);
                    end2.Y = j / height;
                    water  = false;
                }
                else
                {
                    end2.Y = j / height;
                }
            }
            gr.LineTo(end2);
            gr.Stroke();
        }
    }
Ejemplo n.º 26
0
        private void InitJaugeWidget(string title, double min, double max)
        {
            this.title = title;

            this.minValue     = min;
            this.maxValue     = max;
            this.currentValue = min;

            this.fillColor   = new Cairo.Color(0.0, 0.0, 0.0);
            this.borderColor = new Cairo.Color(0.0, 0.0, 0.0);
            this.fontColor   = new Cairo.Color(0.0, 0.0, 0.0);

            if (drawingWidget != null)
            {
                drawingWidget.ExposeEvent += new ExposeEventHandler(HandleExposeEventHandler);
            }
        }
Ejemplo n.º 27
0
        public override void DrawRowSelection(Cairo.Context cr, int x, int y, int width, int height,
                                              bool filled, bool stroked, Cairo.Color color, CairoCorners corners)
        {
            Cairo.Color selection_color     = color;
            Cairo.Color selection_highlight = CairoExtensions.ColorShade(selection_color, 1.24);
            Cairo.Color selection_stroke    = CairoExtensions.ColorShade(selection_color, 0.85);
            selection_highlight.A = 0.5;
            selection_stroke.A    = color.A;

            if (filled)
            {
                Cairo.Color selection_fill_light = CairoExtensions.ColorShade(selection_color, 1.12);
                Cairo.Color selection_fill_dark  = selection_color;

                selection_fill_light.A = color.A;
                selection_fill_dark.A  = color.A;

                LinearGradient grad = new LinearGradient(x, y, x, y + height);
                grad.AddColorStop(0, selection_fill_light);
                grad.AddColorStop(0.4, selection_fill_dark);
                grad.AddColorStop(1, selection_fill_light);

                cr.Pattern = grad;
                CairoExtensions.RoundedRectangle(cr, x, y, width, height, Context.Radius, corners, true);
                cr.Fill();
                grad.Destroy();
            }

            if (filled && stroked)
            {
                cr.LineWidth = 1.0;
                cr.Color     = selection_highlight;
                CairoExtensions.RoundedRectangle(cr, x + 1.5, y + 1.5, width - 3, height - 3,
                                                 Context.Radius - 1, corners, true);
                cr.Stroke();
            }

            if (stroked)
            {
                cr.LineWidth = 1.0;
                cr.Color     = selection_stroke;
                CairoExtensions.RoundedRectangle(cr, x + 0.5, y + 0.5, width - 1, height - 1,
                                                 Context.Radius, corners, true);
                cr.Stroke();
            }
        }
Ejemplo n.º 28
0
        public static void ShadowedText(Cairo.Context g, Cairo.Color c, string text, double x, double y, string font, int point)
        {
            g.Save();

            g.SelectFontFace(font, FontSlant.Normal, FontWeight.Normal);
            g.SetFontSize(point);


            g.MoveTo(x + SHADOW_SPACING, y + SHADOW_SPACING);
            g.Color = Colors.BLACK;
            g.ShowText(text);

            g.MoveTo(x, y);
            g.Color = c;
            g.ShowText(text);

            g.Restore();
        }
Ejemplo n.º 29
0
        protected virtual void OnColorsRefreshed()
        {
            selection_fill   = CairoExtensions.GdkRGBAToCairoColor(Widget.StyleContext.GetBackgroundColor(StateFlags.Active));
            selection_fill   = CairoExtensions.ColorShade(selection_fill, 0.8);
            selection_stroke = CairoExtensions.GdkRGBAToCairoColor(Widget.StyleContext.GetBackgroundColor(StateFlags.Selected));

            Widget.StyleContext.Save();
            Widget.StyleContext.AddClass("entry");
            view_fill = CairoExtensions.GdkRGBAToCairoColor(Widget.StyleContext.GetBackgroundColor(StateFlags.Normal));
            var text_color = CairoExtensions.GdkRGBAToCairoColor(Widget.StyleContext.GetColor(StateFlags.Normal));

            Widget.StyleContext.Restore();

            view_fill_transparent   = view_fill;
            view_fill_transparent.A = 0;

            text_mid = CairoExtensions.AlphaBlend(view_fill, text_color, 0.5);
        }
Ejemplo n.º 30
0
        public virtual void SetStyle(Gtk.Style style)
        {
            Style = style;
            try {
                OnStyleSet(style);
            } catch (Exception e) {
                Log <AbstractDockItem> .Error(e.Message);

                Log <AbstractDockItem> .Debug(e.StackTrace);
            }
            Gdk.Color gdkColor = Style.Backgrounds [(int)StateType.Selected];
            badgeColors [0] = new Cairo.Color((double)gdkColor.Red / ushort.MaxValue,
                                              (double)gdkColor.Green / ushort.MaxValue,
                                              (double)gdkColor.Blue / ushort.MaxValue,
                                              1.0).SetValue(1).SetSaturation(0.47);
            badgeColors [1] = badgeColors [0].SetValue(0.5).SetSaturation(0.51);
            QueueRedraw();
        }
Ejemplo n.º 31
0
        private void FillHalf(HalfCell cell, Cairo.Color color)
        {
            PointD coord = GetCellCoordinates(cell.CellNumber.Y, cell.CellNumber.X);

            if (cell.half == Half.Bottom)
            {
                coord.Y += cellHeight / 2;
            }

            using (Cairo.Context g = Gdk.CairoHelper.Create(this.GdkWindow))
            {
                g.SetSourceRGBA(color.R, color.G, color.B, color.A);
                g.MoveTo(coord);
                g.Rectangle(coord, cellWidth, cellHeight / 2);
                g.Fill();
                g.GetTarget().Dispose();
            }
        }
Ejemplo n.º 32
0
        public TimeScaleBase(List <T> list, uint frames)
        {
            this.frames   = frames;
            this.list     = list;
            this.color    = new Cairo.Color(0, 0, 1);
            this.color.A  = ALPHA;
            HeightRequest = SECTION_HEIGHT;
            Size((int)(frames / pixelRatio), SECTION_HEIGHT);
            Events = EventMask.PointerMotionMask | EventMask.ButtonPressMask | EventMask.ButtonReleaseMask;

            dic = new Dictionary <MenuItem, T>();

            layout           = new Pango.Layout(PangoContext);
            layout.Wrap      = Pango.WrapMode.Char;
            layout.Alignment = Pango.Alignment.Left;

            SetMenu();
        }
Ejemplo n.º 33
0
        public void DrawRowSelection(Cairo.Context cr, int x, int y, int width, int height)
        {
            Color selection_color = GetWidgetColor(GtkColorClass.Background, StateType.Selected);

            LinearGradient grad = new LinearGradient(x, y, x, y + height);

            grad.AddColorStop(0, selection_color.ColorShade(1.1));
            grad.AddColorStop(1, selection_color.ColorShade(0.85));

            cr.Pattern = grad;
            cr.RoundedRectangle(x, y, width, height, BORDER_RADIUS);
            cr.Fill();

            cr.LineWidth = 0.5;
            cr.Color     = selection_color.ColorShade(0.75);
            cr.RoundedRectangle(x + 1, y + 1, width - 2, height - 2, BORDER_RADIUS);
            cr.Stroke();
        }
Ejemplo n.º 34
0
        public static Rectangle FillRectangle(this Context g, Rectangle r, Cairo.Color color)
        {
            g.Save();

            g.MoveTo(r.X, r.Y);
            g.LineTo(r.X + r.Width, r.Y);
            g.LineTo(r.X + r.Width, r.Y + r.Height);
            g.LineTo(r.X, r.Y + r.Height);
            g.LineTo(r.X, r.Y);

            g.Color = color;

            Rectangle dirty = g.StrokeExtents();

            g.Fill();
            g.Restore();

            return(dirty);
        }
Ejemplo n.º 35
0
        //int? height;
        //public override Size Measure (Size available)
        //{
        //int min, max;
        //GetWidthRange (ParentLayout.View.PangoLayout, out min, out max);
        //

        /*if (height == null) {
         *  using (var layout = new Pango.Layout (ParentLayout.View.PangoContext)) {
         *      if (layout.FontDescription == null) {
         *          layout.FontDescription = new Pango.FontDescription ();
         *      }
         *      UpdateText (layout, 100, "Woo Mar");
         *      height = TextHeight;
         *  }
         * }*/

        //return FixedSize ?? new Size (0, (double)height + Padding.Y);
        //}

        public override void Render(CellContext context, double cellWidth, double cellHeight)
        {
            UpdateText(context, cellWidth);
            if (String.IsNullOrEmpty(last_text))
            {
                return;
            }

            //context.Context.Rectangle (0, 0, cellWidth, cellHeight);
            //context.Context.Clip ();
            context.Context.MoveTo(Padding.Left, ((int)cellHeight - text_height) / 2);
            Cairo.Color color = context.Theme.Colors.GetWidgetColor(
                context.TextAsForeground ? GtkColorClass.Foreground : GtkColorClass.Text, context.State);
            color.A = Alpha ?? (context.Opaque ? 1.0 : 0.5);
            context.Context.SetSourceColor(color);

            PangoCairoHelper.ShowLayout(context.Context, context.Layout);
            //context.Context.ResetClip ();
        }
Ejemplo n.º 36
0
        void DrawLines(Gdk.Window win, Cairo.Context g, int height, int width)
        {
            if (Environment.OSVersion.Platform == PlatformID.Unix)
            {
                Cairo.Color color = new Cairo.Color(0, 0, 0);
                CairoUtils.DrawLine(g, currentFrame / pixelRatio, 0, currentFrame / pixelRatio, height,
                                    1, color);
                CairoUtils.DrawLine(g, 0, 0, width, 0, 1, color);
                CairoUtils.DrawLine(g, 0, height, width, height, 1, color);
            }

            else
            {
                win.DrawLine(Style.DarkGC(StateType.Normal), 0, 0, width, 0);
                win.DrawLine(Style.DarkGC(StateType.Normal),
                             (int)(currentFrame / pixelRatio), 0,
                             (int)(currentFrame / pixelRatio), height);
            }
        }
Ejemplo n.º 37
0
        /// <summary>
        /// Adjust the brightness of a Color
        /// </summary>
        /// <param name="color">
        /// A <see cref="Cairo.Color"/>
        /// </param>
        /// <param name="brightness">
        /// A <see cref="System.Double"/>
        /// </param>
        /// <returns>
        /// A <see cref="Cairo.Color"/>
        /// </returns>
        public static Cairo.Color ShadeColor(this Cairo.Color color, double brightness)
        {
            Gdk.Color gdk_color = ConvertToGdk(color);

            byte   r, g, b;
            double h, s, v;

            r = (byte)((gdk_color.Red) >> 8);
            g = (byte)((gdk_color.Green) >> 8);
            b = (byte)((gdk_color.Blue) >> 8);

            Util.Appearance.RGBToHSV(r, g, b, out h, out s, out v);
            v = Math.Min(100, v * brightness);
            Util.Appearance.HSVToRGB(h, s, v, out r, out g, out b);

            return(new Cairo.Color((double)r / byte.MaxValue,
                                   (double)g / byte.MaxValue,
                                   (double)b / byte.MaxValue,
                                   color.A));
        }
Ejemplo n.º 38
0
 internal static void StrokeRectangle(this Cairo.Context g,
                                      Rect rect,
                                      Color topColor,
                                      Color rightColor,
                                      Color bottomColor,
                                      Color leftColor)
 {
     g.NewPath();
     g.MoveTo(rect.TopLeft.X, rect.TopLeft.Y);
     g.SetSourceColor(topColor);
     g.LineTo(rect.TopRight.X, rect.TopRight.Y);       //Top
     g.SetSourceColor(rightColor);
     g.LineTo(rect.BottomRight.X, rect.BottomRight.Y); //Right
     g.SetSourceColor(bottomColor);
     g.LineTo(rect.BottomLeft.X, rect.BottomRight.Y);  //Bottom
     g.SetSourceColor(leftColor);
     g.LineTo(rect.TopLeft.X, rect.TopLeft.Y);         //Left
     g.ClosePath();
     g.Stroke();
 }
Ejemplo n.º 39
0
        /// <summary>
        /// Adjust the saturation of a color
        /// </summary>
        /// <param name="color">
        /// A <see cref="Cairo.Color"/>
        /// </param>
        /// <param name="saturation">
        /// A <see cref="System.Double"/>
        /// </param>
        /// <returns>
        /// A <see cref="Cairo.Color"/>
        /// </returns>
        public static Cairo.Color SaturateColor(this Cairo.Color color, double saturation)
        {
            Gdk.Color gdk_color = ConvertToGdk(color);

            byte   r, g, b;
            double h, s, v;

            r = (byte)((gdk_color.Red) >> 8);
            g = (byte)((gdk_color.Green) >> 8);
            b = (byte)((gdk_color.Blue) >> 8);

            Util.Appearance.RGBToHSV(r, g, b, out h, out s, out v);
            s *= saturation;
            Util.Appearance.HSVToRGB(h, s, v, out r, out g, out b);

            return(new Cairo.Color((double)r / byte.MaxValue,
                                   (double)g / byte.MaxValue,
                                   (double)b / byte.MaxValue,
                                   color.A));
        }
Ejemplo n.º 40
0
        public static Rectangle FillPolygonal(this Context g, PointD[] points, Cairo.Color color)
        {
            g.Save();

            g.MoveTo(points [0]);
            foreach (var point in points)
            {
                g.LineTo(point);
            }

            g.Color = color;

            Rectangle dirty = g.StrokeExtents();

            g.Fill();

            g.Restore();

            return(dirty);
        }
Ejemplo n.º 41
0
        public SectionView(Report parentReport,IControlViewFactory controlViewFactory,Section section,Cairo.PointD sectionSpan)
            : base(section)
        {
            DesignCrossSectionControlsToAdd = new List<ControlViewBase> ();
            DesignCrossSectionControlsToRemove = new List<ControlViewBase> ();
            this.controlViewFactory = controlViewFactory;
            this.parentReport = parentReport;

            if (section is DetailSection)
                AllowCrossSectionControl = false; else {
                AllowCrossSectionControl = true;
            }

            SectionSpan = sectionSpan;
            controls = new System.Collections.Generic.List<ControlViewBase> ();
            AddControls (this.section.Controls);
            SectionGripperColor = sectionHeaderColor1;

            InvalidateBound ();
        }
Ejemplo n.º 42
0
        protected virtual void ShapeSurface(Context cr, Cairo.Color color)
        {
            cr.Operator = Operator.Source;
            Cairo.Pattern p = new Cairo.SolidPattern(new Cairo.Color(0, 0, 0, 0));
            cr.SetSource(p);
            p.Dispose();
            cr.Paint();
            cr.Operator = Operator.Over;

            Cairo.Pattern r = new SolidPattern(color);
            cr.SetSource(r);
            r.Dispose();
            cr.MoveTo(round, 0);
            if (x_align == 1.0)
            {
                cr.LineTo(Allocation.Width, 0);
            }
            else
            {
                cr.Arc(Allocation.Width - round, round, round, -Math.PI * 0.5, 0);
            }
            if (x_align == 1.0 || y_align == 1.0)
            {
                cr.LineTo(Allocation.Width, Allocation.Height);
            }
            else
            {
                cr.Arc(Allocation.Width - round, Allocation.Height - round, round, 0, Math.PI * 0.5);
            }
            if (y_align == 1.0)
            {
                cr.LineTo(0, Allocation.Height);
            }
            else
            {
                cr.Arc(round, Allocation.Height - round, round, Math.PI * 0.5, Math.PI);
            }
            cr.Arc(round, round, round, Math.PI, Math.PI * 1.5);
            cr.ClosePath();
            cr.Fill();
        }
Ejemplo n.º 43
0
        public CellRendererSurface(int width, int height)
        {
            // TODO: Respect cell padding (Xpad and Ypad).
            SetFixedSize (width, height);

            transparent = new Cairo.ImageSurface (Cairo.Format.ARGB32, width, height);
            Cairo.Color gray = new Cairo.Color (.75, .75, .75);

            // Create checkerboard background
            int grid_width = 4;

            using (Cairo.Context g = new Cairo.Context (transparent)) {
                g.Color = new Cairo.Color (1, 1, 1);
                g.Paint ();

                for (int y = 0; y < height; y += grid_width)
                    for (int x = 0; x < width; x += grid_width)
                        if ((x / grid_width % 2) + (y / grid_width % 2) == 1)
                            g.FillRectangle (new Cairo.Rectangle (x, y, grid_width, grid_width), gray);
            }
        }
Ejemplo n.º 44
0
        protected override void DrawFrame (Cairo.Context context, double lineWidth, Cairo.Color lineColor, Cairo.Color fillColor)
        {          
            rect = DisplayBox;
            rect.OffsetDot5();
            CairoFigures.AngleFrame(context, rect, 0, 0, 0, 0);

            Cairo.Color fillColorOrigin;
            fillColorOrigin = fillColor;

            lineWidth = 1;
            fillColor = new Cairo.Color (1.0, 1.0, 1.0, 1.0);

            context.Color = fillColor;  
            context.FillPreserve();
            context.Color = lineColor;
            context.LineWidth = lineWidth;

            double[] dash = {2, 0, 2};
            context.SetDash (dash, 0);

            context.Stroke();

            rect2 = DisplayBox;
            rect2.Width = DisplayBox.Width;
            rect2.Height = 30;
            rect2.OffsetDot5();
            CairoFigures.AngleFrame(context, rect2, 0, 0, 0, 0);
            fillColor = fillColorOrigin;
            context.Color = fillColor;  
            context.FillPreserve();
            context.Color = lineColor;
            context.LineWidth = lineWidth;

            context.Stroke();

            // HERZUM SPRINT 1.1 LOOP 
            DrawScope ();
            // END HERZUM SPRINT 1.1 LOOP

        }
Ejemplo n.º 45
0
        void DrawBackground(Cairo.Context context, Gdk.Rectangle region, int radius, StateType state)
        {
            double rad     = radius - 0.5;
            int    centerX = region.X + region.Width / 2;
            int    centerY = region.Y + region.Height / 2;

            context.MoveTo(centerX + rad, centerY);
            context.Arc(centerX, centerY, rad, 0, Math.PI * 2);

            Cairo.Color high = this.Style.Backgrounds[this.State.GetHashCode()].ToCairoColor();
            Cairo.Color low  = this.Style.Backgrounds[this.State.GetHashCode()].ToCairoColor();
//			switch (state) {
//			case StateType.Selected:
//                high = Styles.Shift (0.85, high);
//                low = Styles.Shift (1.0, low);
//				break;
//			case StateType.Prelight:
//                high = Styles.Shift (1.0, high);
//                low = Styles.Shift (0.9, high);
//				break;
//			case StateType.Insensitive:
//                high = Styles.Shift (0.95, high);
//                low = Styles.Shift (0.83, high);
//				break;
//			default:
//                high = Styles.Shift (1.0, high);
//                low = Styles.Shift (0.85, low);
//				break;
//			}
            using (var lg = new LinearGradient(0, centerY - rad, 0, centerY + rad)) {
                lg.AddColorStop(0, high);
                lg.AddColorStop(1, low);
                context.SetSource(lg);
                context.FillPreserve();
            }

            context.SetSourceRGBA(0, 0, 0, 0.4);
            context.LineWidth = this.Style.XThickness;             // 1;
            context.Stroke();
        }
Ejemplo n.º 46
0
        private void DrawCategories(Gdk.Window win)
        {
            int i = 0;

            if (labelsDict.Count == 0)
            {
                return;
            }

            using (Cairo.Context g = Gdk.CairoHelper.Create(win)) {
                foreach (Label label in labelsDict.Keys)
                {
                    Cairo.Color color;
                    Category    cat;
                    int         y;

                    cat = labelsDict[label];
                    y   = LINE_WIDTH / 2 + i * SECTION_HEIGHT - (int)Scroll;

                    if (cat != null)
                    {
                        if (filter != null && !filter.VisibleCategories.Contains(cat))
                        {
                            continue;
                        }
                        color = CairoUtils.RGBToCairoColor(Helpers.Misc.ToGdkColor(cat.Color));
                    }
                    else
                    {
                        color = new Cairo.Color(0, 0, 0);
                    }
                    CairoUtils.DrawRoundedRectangle(g, 2, y + 3, Allocation.Width - 3,
                                                    SECTION_HEIGHT - 3, SECTION_HEIGHT / 7,
                                                    color, color);
                    DrawCairoText(label.Text, 0 + 3, y + SECTION_HEIGHT / 2 - 5);
                    i++;
                }
            }
        }
Ejemplo n.º 47
0
        protected override void OnStyleSet(Style previous)
        {
            base.OnStyleSet(previous);

            text_color       = CairoExtensions.GdkColorToCairoColor(Style.Foreground(StateType.Normal));
            background_color = CairoExtensions.GdkColorToCairoColor(Style.Background(StateType.Normal));
            text_light_color = Hyena.Gui.Theming.GtkTheme.GetCairoTextMidColor(this);

            if (missing_audio_image != null)
            {
                ((IDisposable)missing_audio_image).Dispose();
                missing_audio_image = null;
            }

            if (missing_video_image != null)
            {
                ((IDisposable)missing_video_image).Dispose();
                missing_video_image = null;
            }

            OnThemeChanged();
        }
Ejemplo n.º 48
0
        public void RefreshSetting()
        {
            lineWitdth = MainClass.Settings.ImageEditors.LineWidth;
            pointWidth = MainClass.Settings.ImageEditors.PointWidth;

            Gdk.Color gdkLineColor = new Gdk.Color(MainClass.Settings.ImageEditors.LineColor.Red,
                                                   MainClass.Settings.ImageEditors.LineColor.Green, MainClass.Settings.ImageEditors.LineColor.Blue);

            Gdk.Color gdkPointColor = new Gdk.Color(MainClass.Settings.ImageEditors.PointColor.Red,
                                                    MainClass.Settings.ImageEditors.PointColor.Green, MainClass.Settings.ImageEditors.PointColor.Blue);

            Gdk.Color gdkSelPointColor = new Gdk.Color(MainClass.Settings.ImageEditors.SelectPointColor.Red,
                                                       MainClass.Settings.ImageEditors.SelectPointColor.Green, MainClass.Settings.ImageEditors.SelectPointColor.Blue);

            colorLine        = gdkLineColor.ToCairoColor(MainClass.Settings.ImageEditors.LineColor.Alpha);
            colorPoint       = gdkPointColor.ToCairoColor(MainClass.Settings.ImageEditors.PointColor.Alpha);
            colorSelectPoint = gdkSelPointColor.ToCairoColor(MainClass.Settings.ImageEditors.SelectPointColor.Alpha);

            try{
                GdkWindow.InvalidateRect(new Gdk.Rectangle(drawOffsetX, drawOffsetY, width, height), false);
            } catch {}
        }
Ejemplo n.º 49
0
        protected override void OnStyleSet(Gtk.Style old_style)
        {
            base.OnStyleSet(old_style);

            // Normal Crumb Background
            this.m_NormalBgBegin = CrumbHelper.ToCairoColor(
                Style.Background(StateType.Normal), 1);
            this.m_NormalBgEnd = CrumbHelper.ToCairoColor(
                Style.Mid(StateType.Normal), 1);

            // Cursor Hover Crumb Background
            this.m_PrelightBgBegin = CrumbHelper.ToCairoColor(
                Style.Background(StateType.Prelight), 1);
            this.m_PrelightBgEnd = CrumbHelper.ToCairoColor(
                Style.Mid(StateType.Prelight), 1);

            // Selected Crumb Background
            this.m_SelectedBgBegin = CrumbHelper.ToCairoColor(
                Style.Light(StateType.Selected), 1);
            this.m_SelectedBgEnd = CrumbHelper.ToCairoColor(
                Style.Mid(StateType.Selected), 1);
        }
Ejemplo n.º 50
0
Archivo: Theme.cs Proyecto: GNOME/hyena
        protected virtual void OnColorsRefreshed()
        {
            selection_stroke = CairoExtensions.GdkRGBAToCairoColor (Widget.StyleContext.GetBackgroundColor (StateFlags.Selected));

            Widget.StyleContext.Save ();
            Widget.StyleContext.AddClass ("entry");
            var view_fill = CairoExtensions.GdkRGBAToCairoColor (Widget.StyleContext.GetBackgroundColor (StateFlags.Normal));
            var text_color = CairoExtensions.GdkRGBAToCairoColor (Widget.StyleContext.GetColor (StateFlags.Normal));
            Widget.StyleContext.Restore ();

            text_mid = CairoExtensions.AlphaBlend (view_fill, text_color, 0.5);
        }
Ejemplo n.º 51
0
        public static Cairo.Color ToCairoColor(this MonoReports.Model.Color color)
        {
            Cairo.Color c = new Cairo.Color ();
            c.A =  (((double)color.A) );
            c.R = (((double)color.R) );
            c.G = (((double)color.G) );
            c.B = (((double)color.B) );

            return c;
        }
Ejemplo n.º 52
0
        protected override void OnStyleUpdated()
        {
            base.OnStyleUpdated ();

            text_color = CairoExtensions.GdkRGBAToCairoColor (StyleContext.GetColor (StateFlags.Normal));
            BackgroundColor = CairoExtensions.GdkRGBAToCairoColor (StyleContext.GetBackgroundColor (StateFlags.Normal));
            text_light_color = Hyena.Gui.Theming.GtkTheme.GetCairoTextMidColor (this);

            ResetMissingImages ();

            OnThemeChanged ();
        }
Ejemplo n.º 53
0
        protected override void OnColorsRefreshed()
        {
            base.OnColorsRefreshed ();

            rule_color = CairoExtensions.ColorShade (ViewFill, 0.95);

            // On Windows we use Normal b/c Active incorrectly returns black (at least on XP)
            // TODO: Check if this is still needed with GTK 3
            border_color = CairoExtensions.GdkRGBAToCairoColor (Widget.StyleContext.GetBorderColor (
                    Hyena.PlatformDetection.IsWindows ? StateFlags.Normal : StateFlags.Active));
        }
Ejemplo n.º 54
0
        private void CairoDraw(EventExpose evnt,int height,int width)
        {
            Time time = new Time();
            using(Cairo.Context g = Gdk.CairoHelper.Create(evnt.Window)) {
                Cairo.Color color = new Cairo.Color(0, 0, 0);
                /* Drawing position triangle */
                CairoUtils.DrawTriangle(g,CurrentFrame/pixelRatio-Scroll, height, 10, 15, color);
                /* Draw '0' */
                CairoUtils.DrawLine(g, 0-Scroll, height, width, height, 2, color);
                g.MoveTo(new PointD(0-Scroll,height-20));
                g.ShowText("0");

                for(int i=10*FrameRate; i<=frames/pixelRatio;) {
                    CairoUtils.DrawLine(g, i-Scroll, height,i-Scroll,
                                        height-10, 2, color);
                    g.MoveTo(new PointD(i-Scroll-13,height-20));
                    time.Seconds = (int)(i/FrameRate*pixelRatio);
                    g.ShowText(time.ToSecondsString());
                    i=i+10*FrameRate;
                }
                for(int i=0; i<=frames/pixelRatio;) {
                    CairoUtils.DrawLine(g, i-Scroll, height,i-Scroll,
                                        height-5, 1, color);
                    i=i+FrameRate;
                }
            }
        }
Ejemplo n.º 55
0
        public void RefreshSetting()
        {
            lineWitdth = MainClass.Settings.ImageEditors.LineWidth;
            pointWidth = MainClass.Settings.ImageEditors.PointWidth;

            Gdk.Color gdkLineColor = new Gdk.Color(MainClass.Settings.ImageEditors.LineColor.Red,
                MainClass.Settings.ImageEditors.LineColor.Green,MainClass.Settings.ImageEditors.LineColor.Blue);

            Gdk.Color gdkPointColor =  new Gdk.Color(MainClass.Settings.ImageEditors.PointColor.Red,
                MainClass.Settings.ImageEditors.PointColor.Green,MainClass.Settings.ImageEditors.PointColor.Blue);

            Gdk.Color gdkSelPointColor =  new Gdk.Color(MainClass.Settings.ImageEditors.SelectPointColor.Red,
                MainClass.Settings.ImageEditors.SelectPointColor.Green,MainClass.Settings.ImageEditors.SelectPointColor.Blue);

            colorLine = gdkLineColor.ToCairoColor(MainClass.Settings.ImageEditors.LineColor.Alpha);
            colorPoint = gdkPointColor.ToCairoColor(MainClass.Settings.ImageEditors.PointColor.Alpha);
            colorSelectPoint = gdkSelPointColor.ToCairoColor(MainClass.Settings.ImageEditors.SelectPointColor.Alpha);

            try{
                GdkWindow.InvalidateRect(new Gdk.Rectangle(drawOffsetX, drawOffsetY, width, height), false);
            } catch{}
        }
Ejemplo n.º 56
0
        protected override void OnColorsRefreshed()
        {
            base.OnColorsRefreshed ();

            if (widget == null) {
                return;
            }

            rule_color = CairoExtensions.ColorShade (CairoExtensions.GdkRGBAToCairoColor (widget.StyleContext.GetBackgroundColor (StateFlags.Normal)), 0.95);
            border_color = CairoExtensions.GdkRGBAToCairoColor (widget.StyleContext.GetBorderColor (StateFlags.Normal));
        }
Ejemplo n.º 57
0
 public Pen()
 {
     color = new Color(0.0,0.0,0.0,1.0);
     size = 3.0;
 }
Ejemplo n.º 58
0
        public override void Draw(GameTime gameTime)
        {
            if (Client.Local.LocalPlayer == null || Client.Local.LocalPlayer.CurrentUnit == null)
                return;
            Renderer.Clear(ColorPresets.Gray85);
            Cairo.Context g = Renderer.Context;

            Client.Local.ViewOrigin = new Vector2(Renderer.Width / 10, 0);
            int gridSize = Convert.ToInt32(Renderer.GetUnitSize(Config.GridSizeLarge));
            Vector2 gridOffset = new Vector2((float)(Client.Local.ViewPosition.X % gridSize), (float)(Client.Local.ViewPosition.Y % gridSize));
            int gridWidth = viewportWidth + 2 * gridSize;
            int gridHeight = Renderer.Height + 2 * gridSize;

            // Minor grid
            /*for (int i = 0; i < ((int)Math.Floor((double)gridWidth / (double)gridSize)) * 4; i++) {
                g.MoveTo((viewOrigin - gridOffset - new Vector2(0, gridSize) + new Vector2(i * gridSize / 4, 0)).ToPointD());
                g.LineTo((viewOrigin - gridOffset + new Vector2(0, gridSize) + new Vector2(i * gridSize / 4, Renderer.Height)).ToPointD());
                Renderer.SetColor(ColorPresets.Gray83);
                g.Stroke();
            }
            for (int i = 0; i < ((int)Math.Floor((double)gridHeight / (double)gridSize)) * 4; i++) {
                g.MoveTo((viewOrigin - gridOffset - new Vector2(gridSize, 0) + new Vector2(0, i * gridSize / 4)).ToPointD());
                g.LineTo((viewOrigin - gridOffset + new Vector2(gridSize, 0) + new Vector2(viewportWidth, i * gridSize / 4)).ToPointD());
                Renderer.SetColor(ColorPresets.Gray83);
                g.Stroke();
            }*/

            // Major grid
            for (int i = 0; i < ((int)Math.Floor((double)gridWidth / (double)gridSize)); i++) {
                g.MoveTo((Client.Local.ViewOrigin - gridOffset - new Vector2(0, gridSize) + new Vector2(i * gridSize, 0)).ToPointD());
                g.LineTo((Client.Local.ViewOrigin - gridOffset + new Vector2(0, gridSize) + new Vector2(i * gridSize, Renderer.Height)).ToPointD());
                Renderer.SetColor(ColorPresets.Gray83);
                g.Stroke();
            }
            for (int i = 0; i < ((int)Math.Floor((double)gridHeight / (double)gridSize)); i++) {
                g.MoveTo((Client.Local.ViewOrigin - gridOffset - new Vector2(gridSize, 0) + new Vector2(0, i * gridSize)).ToPointD());
                g.LineTo((Client.Local.ViewOrigin - gridOffset + new Vector2(gridSize, 0) + new Vector2(viewportWidth, i * gridSize)).ToPointD());
                Renderer.SetColor(ColorPresets.Gray83);
                g.Stroke();
            }

            Client.Local.Draw(gameTime);

            HUD.Draw(gameTime, Renderer, Client.Local.LocalPlayer);

            //Renderer.DrawText(Client.Local.ViewOrigin, string.Format("({0}, {1})", Client.Local.LocalPlayer.CurrentUnit.Position.X, Client.Local.LocalPlayer.CurrentUnit.Position.Y), 20, TextAlign.Left, TextAlign.Top, ColorPresets.White, ColorPresets.Black, null, 0, null);

            /*if (Client.Local.LocalPlayer.CurrentUnit != null && Client.Local.LocalPlayer.CurrentUnit.Position != Client.Local.LocalPlayer.CurrentUnit.IntendedPosition && Client.Local.LocalPlayer.CurrentUnit.AttackTarget == null) {
                Vector2 intendedPos = new Vector2((float)(Client.Local.LocalPlayer.CurrentUnit.IntendedPosition.X * Renderer.Zoom), (float)(Client.Local.LocalPlayer.CurrentUnit.IntendedPosition.Y * Renderer.Zoom)) - Client.Local.ViewPosition + Client.Local.ViewOrigin;
                g.Save();
                g.SetDash(new double[] { 4, 4 }, 0);
                if (Client.Local.LocalPlayer.CurrentUnit.AttackTarget == null)
                    Client.Local.LocalPlayer.CurrentUnit.Actor.Shape.Draw(Renderer, intendedPos, Client.Local.LocalPlayer.CurrentUnit.IntendedDirection, null, new Cairo.Color(0.25, 0.25, 0.25, 0.25), Renderer.GetUnitSize((double)Config.ActorSize / 2) * (1 + 1 * markerAnimationPercent));
                g.MoveTo(Client.Local.LocalPlayer.CurrentUnit.Actor.Position.ToPointD());
                g.LineTo(Client.Local.LocalPlayer.CurrentUnit.AttackTarget == null ? (intendedPos).ToPointD() : Client.Local.LocalPlayer.CurrentUnit.AttackTarget.Position.ToPointD());
                Renderer.SetColor(new Cairo.Color(0.1, 0.1, 0.1, 0.1));
                g.Stroke();
                g.Restore();
            }*/

            Cairo.Color cursorColor = new Cairo.Color(1, 1, 1);

            /*foreach (Actor a in Client.Local.Actors) {
                if (a == Client.Local.LocalPlayer.CurrentUnit.Actor)
                    continue;
                if (Vector2.Distance(a.Position, cursorPosition) < Renderer.GetUnitSize(Config.ActorSize)) {
                    if (Client.Local.LocalPlayer.CurrentUnit.AttitudeTowards(a.Unit.Owner) == Attitude.Enemy)
                        cursorColor = new Cairo.Color(1, 0, 0);
                    if (Client.Local.LocalPlayer.CurrentUnit.AttitudeTowards(a.Unit.Owner) == Attitude.Friend)
                        cursorColor = new Cairo.Color(0, 1, 0);
                }
            }*/

            if (IsLastActiveState) {
                cursor.Draw(Renderer, cursorPosition, 0, cursorColor, new Cairo.Color(0.1, 0.1, 0.1), 22);
            }
        }
Ejemplo n.º 59
0
        public static void Recalculate(Renderer Renderer)
        {
            MainTextFill = new Cairo.Color(1, 1, 1);
            MainTextStroke = new Cairo.Color(0, 0, 0);
            AbilityNameBackground = new Cairo.Color(0.5, 0.5, 0.5);
            AbilityEnergyBackground = new Cairo.Color(0, 0, 0.9);
            AbilityCooldownBackground = new Cairo.Color(0.9, 0, 0.9);
            AbilityKeyBackground = new Cairo.Color(0, 0.4, 0.4);

            TextBoxPadding = Padding;
            BoxWidth = Renderer.Width / 10;
            BarWidth = (BoxWidth - 4 * Margin) / 3;
            MinimapSize = (BoxWidth - 2 * Margin);
            AbilitySize = MinimapSize;
            BarHeight = Renderer.Height - Margin * 4 - MinimapSize * 2;
            CornerPadding = new Vector2(Padding, Padding);
            Ability.Clear();
            TemporaryKeyList = new List<string>() { "Q", "W", "E", "R" };
            LeftBox = new List<Vector2>() {
                new Vector2(0, 0),
                new Vector2(BoxWidth, 0),
                new Vector2(BoxWidth, Renderer.Height),
                new Vector2(0, Renderer.Height)
            };
            RightBox = new List<Vector2>() {
                new Vector2(Renderer.Width, 0),
                new Vector2(Renderer.Width - BoxWidth, 0),
                new Vector2(Renderer.Width - BoxWidth, Renderer.Height),
                new Vector2(Renderer.Width, Renderer.Height)
            };
            MinimapBackground = new List<Vector2>() {
                new Vector2((float)(0 + Margin), (float)(Renderer.Height - Margin - MinimapSize)),
                new Vector2((float)(0 + Margin), (float)(Renderer.Height - Margin)),
                new Vector2((float)(0 + Margin + MinimapSize), (float)(Renderer.Height - Margin)),
                new Vector2((float)(0 + Margin + MinimapSize), (float)(Renderer.Height - Margin - MinimapSize))
            };
            Ability.Add(new List<Vector2>() {
                new Vector2((float)(Renderer.Width - Margin - AbilitySize), (float)(Renderer.Height / 2 - 3 * Margin / 2 - AbilitySize * 2)),
                new Vector2((float)(Renderer.Width - Margin), (float)(Renderer.Height / 2 - 3 * Margin / 2 - AbilitySize * 2)),
                new Vector2(Renderer.Width - Margin, (float)(Renderer.Height / 2 - 3 * Margin / 2 - AbilitySize)),
                new Vector2((float)(Renderer.Width - Margin - AbilitySize), (float)(Renderer.Height / 2 - 3 * Margin / 2 - AbilitySize))
            });
            Ability.Add(new List<Vector2>() {
                new Vector2((float)(Renderer.Width - Margin - AbilitySize), (float)(Renderer.Height / 2 - Margin / 2 - AbilitySize)),
                new Vector2((float)(Renderer.Width - Margin), (float)(Renderer.Height / 2 - Margin / 2 - AbilitySize)),
                new Vector2(Renderer.Width - Margin, Renderer.Height / 2 - Margin / 2),
                new Vector2((float)(Renderer.Width - Margin - AbilitySize), (float)(Renderer.Height / 2 - Margin / 2))
            });
            Ability.Add(new List<Vector2>() {
                new Vector2((float)(Renderer.Width - Margin - AbilitySize), (float)(Renderer.Height / 2 + Margin / 2)),
                new Vector2(Renderer.Width - Margin, Renderer.Height / 2 + Margin / 2),
                new Vector2((float)(Renderer.Width - Margin), (float)(Renderer.Height / 2 + Margin / 2 + AbilitySize)),
                new Vector2((float)(Renderer.Width - Margin - AbilitySize), (float)(Renderer.Height / 2 + Margin / 2 + AbilitySize))
            });
            Ability.Add(new List<Vector2>() {
                new Vector2((float)(Renderer.Width - Margin - AbilitySize), (float)(Renderer.Height / 2 + 3 * Margin / 2 + AbilitySize)),
                new Vector2(Renderer.Width - Margin, (float)(Renderer.Height / 2 + 3 * Margin / 2 + AbilitySize)),
                new Vector2((float)(Renderer.Width - Margin), (float)(Renderer.Height / 2 + 3 * Margin / 2 + AbilitySize * 2)),
                new Vector2((float)(Renderer.Width - Margin - AbilitySize), (float)(Renderer.Height / 2 + 3 * Margin / 2 + AbilitySize * 2))
            });
        }
Ejemplo n.º 60
0
 public void SetFillColor(Cairo.Color color)
 {
     fill_color = color;
     fill_color_set = true;
     QueueDraw ();
 }