Exemple #1
0
    public static void ChronopicColors(Gtk.Viewport v, Gtk.Label l1, Gtk.Label l2, bool connected)
    {
        //if(! v.Style.Background(StateType.Normal).Equal(BLUE))
        if (!v.Style.Background(StateType.Normal).Equal(v.Style.Background(StateType.Selected)))
        {
            chronopicViewportDefaultBg = v.Style.Background(StateType.Normal);
        }
        if (!l1.Style.Foreground(StateType.Normal).Equal(WHITE))
        {
            chronopicLabelsDefaultFg = l1.Style.Foreground(StateType.Normal);
        }

        if (connected)
        {
            v.ModifyBg(StateType.Normal, chronopicViewportDefaultBg);
            l1.ModifyFg(StateType.Normal, chronopicLabelsDefaultFg);
            l2.ModifyFg(StateType.Normal, chronopicLabelsDefaultFg);
        }
        else
        {
            //v.ModifyBg(StateType.Normal, BLUE);
            v.ModifyBg(StateType.Normal, v.Style.Background(StateType.Selected));
            l1.ModifyFg(StateType.Normal, WHITE);
            l2.ModifyFg(StateType.Normal, WHITE);
        }
    }
Exemple #2
0
        /// <summary>
        /// Returns a new color which is the result of blending the two supplied colors.
        /// </summary>
        /// <param name="a">
        /// A <see cref="Gdk.Color"/>
        /// </param>
        /// <param name="b">
        /// A <see cref="Gdk.Color"/>
        /// </param>
        /// <returns>
        /// A <see cref="Gdk.Color"/>
        /// </returns>
        public Gdk.Color ColorBlend(Gdk.Color a, Gdk.Color b)
        {
            // at some point, might be nice to allow any blend?
            double blend = 0.5;

            if (blend < 0.0 || blend > 1.0)
            {
                throw new ApplicationException("blend < 0.0 || blend > 1.0");
            }

            double blendRatio = 1.0 - blend;

            int aR = a.Red >> 8;
            int aG = a.Green >> 8;
            int aB = a.Blue >> 8;

            int bR = b.Red >> 8;
            int bG = b.Green >> 8;
            int bB = b.Blue >> 8;

            double mR = aR + bR;
            double mG = aG + bG;
            double mB = aB + bB;

            double blR = mR * blendRatio;
            double blG = mG * blendRatio;
            double blB = mB * blendRatio;

            Gdk.Color color = new Gdk.Color((byte)blR, (byte)blG, (byte)blB);
            Gdk.Colormap.System.AllocColor(ref color, true, true);
            return(color);
        }
Exemple #3
0
 void UpdateStyle()
 {
     if (!m_BackgroundSet)
     {
         m_Background = this.Style.Background(Gtk.StateType.Selected);
     }
 }
Exemple #4
0
        private void BuildPage()
        {
            _defaultBackgroundColor = Style.Backgrounds[(int)StateType.Normal];

            _toolbar = new HBox();
            _content = new GtkFormsContainer();

            var root = new VBox(false, 0);

            _headerContainer = new GtkFormsContainer();
            root.PackStart(_headerContainer, false, false, 0);

            _image        = new ImageControl();
            _image.Aspect = ImageAspect.Fill;

            _contentContainerWrapper = new GtkFormsContainer();
            _contentContainerWrapper.SizeAllocated += OnContentContainerWrapperSizeAllocated;
            _contentContainer = new Fixed();
            _contentContainer.Add(_image);
            _contentContainerWrapper.Add(_contentContainer);

            root.PackStart(_contentContainerWrapper, true, true, 0);             // Should fill all available space

            Attach(root, 0, 1, 0, 1);

            ShowAll();
        }
Exemple #5
0
 /// <summary>
 /// Initializes a new instance of the <see cref="CmisSync.CmisTree.StatusCellRenderer"/> class with a default foreground color
 /// </summary>
 public StatusCellRenderer() : base()
 {
     Gdk.Color foreground = new Gdk.Color();
     /// Default color is a light gray
     Gdk.Color.Parse("#999", ref foreground);
     base.ForegroundGdk = foreground;
 }
        public static Gdk.Color ColorBlend(Gdk.Color a, Gdk.Color b, double blend)
        {
            if(blend < 0.0 || blend > 1.0) {
                throw new ApplicationException("blend < 0.0 || blend > 1.0");
            }

            double blendRatio = 1.0 - blend;

            int aR = a.Red >> 8;
            int aG = a.Green >> 8;
            int aB = a.Blue >> 8;

            int bR = b.Red >> 8;
            int bG = b.Green >> 8;
            int bB = b.Blue >> 8;

            double mR = aR + bR;
            double mG = aG + bG;
            double mB = aB + bB;

            double blR = mR * blendRatio;
            double blG = mG * blendRatio;
            double blB = mB * blendRatio;

            Gdk.Color color = new Gdk.Color((byte)blR, (byte)blG, (byte)blB);
            Gdk.Colormap.System.AllocColor(ref color, true, true);
            return color;
        }
Exemple #7
0
        public CameraView()
        {
            this.Build();

            devicelistStore = new Gtk.ListStore(typeof(string), typeof(IDevice));
            CellRendererText ct = new CellRendererText();


            source_box.PackStart(ct, false);
            source_box.AddAttribute(ct, "text", 0);
            source_box.Model = devicelistStore;

            textColor = new Gdk.Color();
            bgColor   = new Gdk.Color();

            Gdk.Color.Parse("white", ref textColor);
            Gdk.Color.Parse("black", ref bgColor);

            bgstats.ModifyBg(StateType.Normal, bgColor);
            bgstats.ModifyBase(StateType.Normal, bgColor);

            IPaddresLabel.ModifyBase(StateType.Normal, bgColor);
            IPaddresLabel.ModifyBg(StateType.Normal, bgColor);
            IPaddresLabel.ModifyFg(StateType.Normal, textColor);

            NameLabel.ModifyFg(StateType.Normal, textColor);
            FpsLabel.ModifyFg(StateType.Normal, textColor);
            DriverLabel.ModifyFg(StateType.Normal, textColor);

            timer = new Stopwatch();
            timer.Start();
        }
Exemple #8
0
        public DemoColorSelection() : base("Color Selection")
        {
            BorderWidth = 8;
            VBox vbox = new VBox(false, 8);

            vbox.BorderWidth = 8;
            Add(vbox);

            // Create the color swatch area
            Frame frame = new Frame();

            frame.ShadowType = ShadowType.In;
            vbox.PackStart(frame, true, true, 0);

            drawingArea              = new DrawingArea();
            drawingArea.ExposeEvent += new ExposeEventHandler(ExposeEventCallback);
            // set a minimum size
            drawingArea.SetSizeRequest(200, 200);
            // set the color
            color = new Gdk.Color(0, 0, 0xff);
            drawingArea.ModifyBg(StateType.Normal, color);
            frame.Add(drawingArea);

            Alignment alignment = new Alignment(1.0f, 0.5f, 0.0f, 0.0f);
            Button    button    = new Button("_Change the above color");

            button.Clicked += new EventHandler(ChangeColorCallback);
            alignment.Add(button);
            vbox.PackStart(alignment);

            ShowAll();
        }
 public UnderlineMarker(Gdk.Color color, int start, int end)
 {
     this.Color    = color;
     this.StartCol = start;
     this.EndCol   = end;
     this.Wave     = false;
 }
Exemple #10
0
        public static Cairo.Color RandomShadeOfGdkColor(Gdk.Color gdkcolor)
        {
            var r     = s_random.Next(300, 1000) / 1013.856;
            var color = GdkColorToCairoColor(gdkcolor);

            return(ColorShade(color, r));
        }
Exemple #11
0
 public void UpdateBackgroundColor(Gdk.Color color)
 {
     if (_boxView != null)
     {
         _boxView.ModifyBg(StateType.Normal, color);
     }
 }
Exemple #12
0
        private void RecursiveAttach(int depth, TextView view, TextChildAnchor anchor)
        {
            if (depth > 4)
            {
                return;
            }

            TextView childView = new TextView(view.Buffer);

            // Event box is to add a black border around each child view
            EventBox eventBox = new EventBox();

            Gdk.Color color = new Gdk.Color();
            Gdk.Color.Parse("black", ref color);
            eventBox.ModifyBg(StateType.Normal, color);

            Alignment align = new Alignment(0.5f, 0.5f, 1.0f, 1.0f);

            align.BorderWidth = 1;

            eventBox.Add(align);
            align.Add(childView);

            view.AddChildAtAnchor(eventBox, anchor);

            RecursiveAttach(depth + 1, childView, anchor);
        }
		public DemoColorSelection () : base ("Color Selection")
		{
			BorderWidth = 8;
			VBox vbox = new VBox (false,8);
			vbox.BorderWidth = 8;
			Add (vbox);

			// Create the color swatch area
			Frame frame = new Frame ();
			frame.ShadowType = ShadowType.In;
			vbox.PackStart (frame, true, true, 0);

			drawingArea = new DrawingArea ();
			drawingArea.ExposeEvent += new ExposeEventHandler (ExposeEventCallback);
			// set a minimum size
			drawingArea.SetSizeRequest (200,200);
			// set the color
			color = new Gdk.Color (0, 0, 0xff);
			drawingArea.ModifyBg (StateType.Normal, color);
			frame.Add (drawingArea);

			Alignment alignment = new Alignment (1.0f, 0.5f, 0.0f, 0.0f);
			Button button = new Button ("_Change the above color");
			button.Clicked += new EventHandler (ChangeColorCallback);
			alignment.Add (button);
			vbox.PackStart (alignment);

			ShowAll ();
		}
Exemple #14
0
        public Cairo.Color GetColorFromString(string colorString)
        {
            string refColorString;

            if (customPalette.TryGetValue(colorString, out refColorString))
            {
                return(this.GetColorFromString(refColorString));
            }
            ChunkStyle style;

            if (styleLookupTable.TryGetValue(colorString, out style))
            {
                return(style.CairoColor);
            }
            if (colorString.Length > 0 && colorString[0] == '#')
            {
                if (colorString.Length == 9)
                {
                    // #AARRGGBB
                    return(new Cairo.Color(GetNumber(colorString, 3) / 255.0, GetNumber(colorString, 5) / 255.0, GetNumber(colorString, 7) / 255.0, GetNumber(colorString, 1) / 255.0));
                }
                if (colorString.Length == 7)
                {
                    // #RRGGBB
                    return(new Cairo.Color(GetNumber(colorString, 1) / 255.0, GetNumber(colorString, 3) / 255.0, GetNumber(colorString, 5) / 255.0));
                }
                throw new ArgumentException("colorString", "colorString must either be #RRGGBB (length 7) or #AARRGGBB (length 9) your string " + colorString + " is invalid because it has a length of " + colorString.Length);
            }
            Gdk.Color color = new Gdk.Color();
            if (Gdk.Color.Parse(colorString, ref color))
            {
                return((Cairo.Color)((HslColor)color));
            }
            throw new Exception("Failed to parse color or find named color '" + colorString + "'");
        }
Exemple #15
0
		public void SetBackground(Gdk.Color backgroundColor)
		{
			if (_root != null)
			{
				_root.ModifyBg(StateType.Normal, backgroundColor);
			}
		}
 public static Gdk.Color GdkColor(Cairo.Color color)
 {
     var gdk = new Gdk.Color ((byte) (color.R * System.Byte.MaxValue),
                              (byte) (color.G * System.Byte.MaxValue),
                              (byte) (color.B * System.Byte.MaxValue));
     return gdk;
 }
Exemple #17
0
        protected override bool OnExposeEvent(Gdk.EventExpose evt)
        {
            Rectangle headerRect, bgRect;
            int       headerHeight = header.Allocation.Height;

            Gdk.Color white, bg, mid;

            headerRect        = bgRect = Allocation;
            headerRect.Height = headerHeight;
            bgRect.Y         += headerHeight;
            bgRect.Height    -= headerHeight;

            GdkWindow.DrawRectangle(Style.BaseGC(State), true, bgRect);

            white = Style.Base(State);
            bg    = Style.Background(State);

            mid       = new Gdk.Color();
            mid.Red   = (ushort)((white.Red + bg.Red) / 2);
            mid.Green = (ushort)((white.Green + bg.Green) / 2);
            mid.Blue  = (ushort)((white.Blue + bg.Blue) / 2);
            Style.BaseGC(State).RgbFgColor = mid;
            GdkWindow.DrawRectangle(Style.BaseGC(State), true, headerRect);
            Style.BaseGC(State).Foreground = white;

            return(base.OnExposeEvent(evt));
        }
Exemple #18
0
 protected void OnColorClicked(Gdk.Color color)
 {
     if (ColorClicked != null)
     {
         ColorClicked(this, new ColorClickedEventArgs(color));
     }
 }
            public MasterDetailMasterTitleContainer()
            {
                _defaultBackgroundColor = Style.Backgrounds[(int)StateType.Normal];

                _root           = new HBox();
                _hamburguerIcon = new Gtk.Image();

                try
                {
                    _hamburguerIcon = new Gtk.Image(HamburgerPixBuf);
                }
                catch (Exception ex)
                {
                    Internals.Log.Warning("MasterDetailPage HamburguerIcon", "Could not load hamburguer icon: {0}", ex);
                }

                _hamburguerButton = new ToolButton(_hamburguerIcon, string.Empty);
                _hamburguerButton.HeightRequest = GtkToolbarConstants.ToolbarItemHeight;
                _hamburguerButton.WidthRequest  = GtkToolbarConstants.ToolbarItemWidth;
                _hamburguerButton.Clicked      += OnHamburguerButtonClicked;

                _titleLabel       = new Gtk.Label();
                _defaultTextColor = _titleLabel.Style.Foregrounds[(int)StateType.Normal];

                _root.PackStart(_hamburguerButton, false, false, GtkToolbarConstants.ToolbarItemSpacing);
                _root.PackStart(_titleLabel, false, false, 25);

                Add(_root);
            }
Exemple #20
0
 static Cairo.Color Convert(Gdk.Color color)
 {
     return(new Cairo.Color(
                color.Red / (double)ushort.MaxValue,
                color.Green / (double)ushort.MaxValue,
                color.Blue / (double)ushort.MaxValue));
 }
Exemple #21
0
        private void DetermineDisplayColor(LedColor ledColor, Gdk.Color referenceColor)
        {
            HSLColor hsl = new HSLColor(referenceColor.ToRgbColor());

            ledColor.Alpha = hsl.Lightness;

            if (hsl.Saturation == 0)
            {
                hsl.Lightness = 1;
            }
            else
            {
                if (ledColor.Alpha > 0.5)
                {
                    ledColor.Alpha = 1;
                }
                else
                {
                    ledColor.Alpha = ledColor.Alpha * 2;
                    hsl.Lightness  = 0.5;
                }
            }

            ledColor.Red   = hsl.Color.R / 255.0;
            ledColor.Green = hsl.Color.G / 255.0;
            ledColor.Blue  = hsl.Color.B / 255.0;
        }
Exemple #22
0
    public MainWindow()
        : base(Gtk.WindowType.Toplevel)
    {
        Build ();
        this.SetPosition(Gtk.WindowPosition.Center);
        #region Labelstyle
        //projectTitelLabel.Pattern = "________________________________________________________________________________"; //Unterstreichung - Projekttitel
        Gdk.Color bluecolor = new Gdk.Color (255, 100, 50);
        //dateLabel.ModifyFg (Gtk.StateType.Normal, bluecolor);
        dateLabel.ModifyFont (Pango.FontDescription.FromString ("Calibri, 11"));
        timeLabel.ModifyFont (Pango.FontDescription.FromString ("Calibri, 11"));
        musicFestivalLabel.ModifyFont (Pango.FontDescription.FromString ("Calibri, Bold 12"));
        musicNameLabel.ModifyFont (Pango.FontDescription.FromString ("Calibri, Bold 12"));
        #endregion

        #region Datumanzeige / Uhrzeitanzeige

        DateTime now = DateTime.Now;
        string currentDate = now.ToShortDateString ();
        string currentTime = now.ToShortTimeString ();

        dateLabel.Text = currentDate;
        timeLabel.Text = currentTime;

        #endregion
    }
    public override Widget Create(object caller)
    {
        Drawing.Color val = (Drawing.Color) field.GetValue(Object);

        colorButton = new ColorButton();
        //Console.WriteLine("ChooseColorWidget Create val {0},{1},{2},{3}", val.Red, val.Green, val.Blue, val.Alpha);
        // Get if we should use alpha
        ChooseColorSettingAttribute chooseColorSetting = (ChooseColorSettingAttribute)
            field.GetCustomAttribute(typeof(ChooseColorSettingAttribute));
        useAlpha = chooseColorSetting.UseAlpha;

        if (useAlpha)
            colorButton.UseAlpha = true;
        Gdk.Color color = new Gdk.Color();
        color.Red = (ushort) (val.Red * 65535f);
        color.Green = (ushort) (val.Green * 65535f);
        color.Blue = (ushort) (val.Blue * 65535f);

        if (useAlpha)
            colorButton.Alpha = (ushort) (val.Alpha * 65535f);
        colorButton.Color = color;
        colorButton.ColorSet += OnChooseColor;

        colorButton.Name = field.Name;

        // Create a tooltip if we can.
        CreateToolTip(caller, colorButton);

        return colorButton;
    }
Exemple #24
0
        public CameraView()
        {
            this.Build ();

            devicelistStore = new Gtk.ListStore (typeof(string), typeof(IDevice));
            CellRendererText ct = new CellRendererText ();

            source_box.PackStart (ct, false);
            source_box.AddAttribute (ct, "text", 0);
            source_box.Model = devicelistStore;

            textColor = new Gdk.Color();
            bgColor = new Gdk.Color();

            Gdk.Color.Parse("white", ref textColor);
            Gdk.Color.Parse("black", ref bgColor);

            bgstats.ModifyBg (StateType.Normal,bgColor);
            bgstats.ModifyBase(StateType.Normal,bgColor);

            IPaddresLabel.ModifyBase(StateType.Normal,bgColor);
            IPaddresLabel.ModifyBg(StateType.Normal,bgColor);
            IPaddresLabel.ModifyFg (StateType.Normal,textColor);

            NameLabel.ModifyFg (StateType.Normal,textColor);
            FpsLabel.ModifyFg (StateType.Normal,textColor);
            DriverLabel.ModifyFg (StateType.Normal,textColor);

            timer = new Stopwatch ();
            timer.Start ();
        }
Exemple #25
0
 /// <summary>
 /// Initializes a new instance of the <see cref="CmisSync.CmisTree.StatusCellRenderer"/> class with a default foreground color
 /// </summary>
 public StatusCellRenderer () : base()
 {
     Gdk.Color foreground = new Gdk.Color();
     /// Default color is a light gray
     Gdk.Color.Parse ("#999", ref foreground);
     base.ForegroundGdk = foreground;
 }
Exemple #26
0
 public static Cairo.Color ToCairoColor(Gdk.Color color, double alpha)
 {
     return(new Cairo.Color((double)color.Red / ushort.MaxValue,
                            (double)color.Green / ushort.MaxValue,
                            (double)color.Blue / ushort.MaxValue,
                            alpha));
 }
Exemple #27
0
 public void UpdateColor(Gdk.Color color)
 {
     if (_boxView != null)
     {
         _boxView.Color = color;
     }
 }
 public void UpdateColor(Gdk.Color color)
 {
     if (_activityIndicator != null)
     {
         _activityIndicator.Color = color;
     }
 }
        public WelcomePageWidget()
        {
            logoPixbuf = WelcomePageBranding.GetLogoImage();
            bgPixbuf   = WelcomePageBranding.GetTopBorderImage();

            Gdk.Color color = Gdk.Color.Zero;
            if (!Gdk.Color.Parse(WelcomePageBranding.BackgroundColor, ref color))
            {
                color = Style.White;
            }
            ModifyBg(StateType.Normal, color);

            var mainAlignment = new Gtk.Alignment(0f, 0f, 1f, 1f);

            mainAlignment.SetPadding((uint)(WelcomePageBranding.LogoHeight + WelcomePageBranding.Spacing), 0, (uint)WelcomePageBranding.Spacing, 0);
            this.Add(mainAlignment);

            colBox = new Gtk.HBox(false, WelcomePageBranding.Spacing);
            mainAlignment.Add(colBox);

            BuildContent();

            ShowAll();

            IdeApp.Workbench.GuiLocked   += OnLock;
            IdeApp.Workbench.GuiUnlocked += OnUnlock;
        }
Exemple #30
0
 /// <summary>
 /// This returns the hexadecimal value of an GDK color.
 /// </summary>
 /// <param name="color">
 /// The color to convert to a hex string.
 /// </param>
 public static string ColorGetHex(Gdk.Color color)
 {
     return(String.Format("#{0:x2}{1:x2}{2:x2}",
                          (byte)(color.Red >> 8),
                          (byte)(color.Green >> 8),
                          (byte)(color.Blue >> 8)));
 }
Exemple #31
0
 public static Cairo.Color ToCairoColor(Gdk.Color color, double alpha)
 {
     return(new Cairo.Color((double)(color.Red >> 8) / 255.0,
                            (double)(color.Green >> 8) / 255.0,
                            (double)(color.Blue >> 8) / 255.0,
                            alpha));
 }
Exemple #32
0
 public static Gdk.Color GdkColor(Cairo.Color color)
 {
     Gdk.Color gdk = new Gdk.Color((byte)(color.R * System.Byte.MaxValue),
                                   (byte)(color.G * System.Byte.MaxValue),
                                   (byte)(color.B * System.Byte.MaxValue));
     return(gdk);
 }
Exemple #33
0
        /// <summary>
        ///	Creates a Pixbuf based on the given parameters.
        /// </summary>
        /// <returns>The pixbuf.</returns>
        /// <param name="c">The color</param>
        /// <param name="w">The width.</param>
        /// <param name="h">The height.</param>
        public static Pixbuf ColoredPixbuf(Gdk.Color c, int w = 24, int h = 24)
        {
            var pixbuf = new Pixbuf(Colorspace.Rgb, false, 8, w, h);

            pixbuf.Fill(RGBAFromGdkColor(c));
            return(pixbuf);
        }
Exemple #34
0
        /// <summary>
        /// Adjust the Hue of a color
        /// </summary>
        /// <param name="color">
        /// A <see cref="Cairo.Color"/>
        /// </param>
        /// <param name="hue">
        /// A <see cref="System.Double"/>
        /// </param>
        /// <returns>
        /// A <see cref="Cairo.Color"/>
        /// </returns>
        public static Cairo.Color SetHue(this Cairo.Color color, double hue)
        {
            if (hue <= 0 || hue > 360)
            {
                return(color);
            }

            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);
            h = hue;
            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));
        }
Exemple #35
0
        /// <summary>
        /// Colorize grey colors to allow for better theme matching.  Colors with saturation will
        /// have nothing done to them
        /// </summary>
        /// <param name="color">
        /// A <see cref="Cairo.Color"/>
        /// </param>
        /// <param name="hue">
        /// A <see cref="System.Double"/>
        /// </param>
        /// <returns>
        /// A <see cref="Cairo.Color"/>
        /// </returns>
        public static Cairo.Color ColorizeColor(this Cairo.Color color, Cairo.Color reference_color)
        {
            //Color has no saturation to it, we need to give it some
            if (color.B == color.G && color.B == color.R)
            {
                Gdk.Color gdk_color0 = ConvertToGdk(color);
                Gdk.Color gdk_color1 = ConvertToGdk(reference_color);
                byte      r0, g0, b0, r1, g1, b1;
                double    h0, s0, v0, h1, s1, v1;

                r0 = (byte)((gdk_color0.Red) >> 8);
                g0 = (byte)((gdk_color0.Green) >> 8);
                b0 = (byte)((gdk_color0.Blue) >> 8);
                r1 = (byte)((gdk_color1.Red) >> 8);
                g1 = (byte)((gdk_color1.Green) >> 8);
                b1 = (byte)((gdk_color1.Blue) >> 8);

                Util.Appearance.RGBToHSV(r0, g0, b0, out h0, out s0, out v0);
                Util.Appearance.RGBToHSV(r1, g1, b1, out h1, out s1, out v1);
                h0 = h1;
                s0 = (s0 + s1) / 2;
                Util.Appearance.HSVToRGB(h0, s0, v0, out r0, out g0, out b0);

                return(new Cairo.Color((double)r0 / byte.MaxValue,
                                       (double)g0 / byte.MaxValue,
                                       (double)b0 / byte.MaxValue,
                                       color.A));
            }
            else                 //color is already saturated in some manner, do nothing
            {
                return(color);
            }
        }
        protected virtual Pixbuf GetPixbuf(int i, bool highlighted)
        {
            string thumb_path;
            Pixbuf current;

            try {
                thumb_path = FSpot.ThumbnailGenerator.ThumbnailPath((selection.Collection [i]).DefaultVersionUri);
                current    = PixbufUtils.ShallowCopy(thumb_cache.Get(thumb_path));
            } catch (IndexOutOfRangeException) {
                thumb_path = null;
                current    = null;
            }

            if (current == null)
            {
                try {
                    ThumbnailGenerator.Default.Request((selection.Collection [i]).DefaultVersionUri, 0, 256, 256);

                    if (SquaredThumbs)
                    {
                        current = new Pixbuf(thumb_path);
                        current = PixbufUtils.IconFromPixbuf(current, ThumbSize);
                    }
                    else
                    {
                        current = new Pixbuf(thumb_path, -1, ThumbSize);
                    }
                    thumb_cache.Add(thumb_path, current);
                } catch {
                    try {
                        current = FSpot.Global.IconTheme.LoadIcon("gtk-missing-image", ThumbSize, (Gtk.IconLookupFlags) 0);
                    } catch {
                        current = null;
                    }
                    thumb_cache.Add(thumb_path, null);
                }
            }

            //FIXME
            if (FSpot.ColorManagement.IsEnabled)
            {
                current = current.Copy();
                FSpot.ColorManagement.ApplyScreenProfile(current);
            }

            if (!highlighted)
            {
                return(current);
            }

            Pixbuf highlight = new Pixbuf(Gdk.Colorspace.Rgb, true, 8, current.Width, current.Height);

            Gdk.Color color = Style.Background(StateType.Selected);
            uint      ucol  = (uint)((uint)color.Red / 256 << 24) + ((uint)color.Green / 256 << 16) + ((uint)color.Blue / 256 << 8) + 255;

            highlight.Fill(ucol);
            current.CopyArea(1, 1, current.Width - 2, current.Height - 2, highlight, 1, 1);
            return(highlight);
        }
Exemple #37
0
        public static double Brightness(Gdk.Color c)
        {
            double r = c.Red / (double)ushort.MaxValue;
            double g = c.Green / (double)ushort.MaxValue;
            double b = c.Blue / (double)ushort.MaxValue;

            return(System.Math.Sqrt(r * .241 + g * .691 + b * .068));
        }
		public static void Main (string[] args)
		{
			Thread.CurrentThread.CurrentCulture = new System.Globalization.CultureInfo("sl-SI");
			Thread.CurrentThread.CurrentCulture.SetSlovenian();
			
			Gdk.Color c = new Gdk.Color(255,125,0);
			System.Console.WriteLine(c.ToHtmlColor());
			Application.Init ();
			MainWindow win = new MainWindow ();
			win.Show ();
			Application.Run ();
		}
        public PreviewRenderer(Preview preview, Gdk.GC gc, Dimensions dimensions)
        {
            _window = preview.GdkWindow;
              _gc = gc;
              _width = dimensions.Width - 1;
              _height = dimensions.Height - 1;

              var colormap = Colormap.System;
              _inactive = new Gdk.Color(0xff, 0, 0);
              _active = new Gdk.Color(0, 0xff, 0);
              colormap.AllocColor(ref _inactive, true, true);
              colormap.AllocColor(ref _active, true, true);
        }
        public static void DrawGrid(Gdk.Drawable wnd, int Size)
        {
            int Width, Height;
            var gc = new Gdk.GC (wnd);

            Gdk.Color line_color = new Gdk.Color (0, 255, 255);
            gc.RgbFgColor = line_color;

            wnd.GetSize (out Width, out Height);
            for (int i = 0; i < Width; i += Size)
                wnd.DrawLine (gc, i, 0, i, Height);
            for (int i = 0; i < Height; i += Size)
                wnd.DrawLine (gc, 0, i, Width, i);
        }
Exemple #41
0
        public TimesWidget()
        {
            this.Build ();

            #region Labelstyle
            //projectTitelLabel.Pattern = "________________________________________________________________________________"; //Unterstreichung - Projekttitel
            Gdk.Color bluecolor = new Gdk.Color (255, 100, 50);
            //dateLabel.ModifyFg (Gtk.StateType.Normal, bluecolor);
            headerLabel.ModifyFont (Pango.FontDescription.FromString ("Calibri, Bold 15"));
            timesManagementHeaderLabel.ModifyFont (Pango.FontDescription.FromString ("Calibri, Bold 11"));
            outputHeaderLabel.ModifyFont (Pango.FontDescription.FromString ("Calibri, Bold 11"));
            #endregion
            fillTreeView();
        }
Exemple #42
0
    public MainWindow()
        : base(Gtk.WindowType.Toplevel)
    {
        Build ();

        table=new Table(1,1,true);

        vbox1.Add(table);
        table.Visible=true;
        List<Button> buttons = new List<Button>();

        for (uint index = 0; index < 75; index++){

            Button button = new Button();
            button.Label = string.Format ("{0}", index+1);
            button.Visible = true;

            buttons.Add(button);

            uint fila = index / 10;
            uint columna = index % 10;

            table.Attach (button, columna, columna+1, fila, fila+1);
        }

        Gdk.Color verde = new Gdk.Color(0,255,0);
        numeros= new List <int>();

        //TODO 90 parece que será un parámetro de la aplicación
        for(int numero = 1; numero <= 75 ; numero++){
            numeros.Add(numero);
        }

        showNumeros();

        goForwardAction.Activated += delegate {

            int indexAleatorio = random.Next(numeros.Count);
            int numeroExtraido = numeros [ indexAleatorio ];

            entryNumero.Text = numeroExtraido.ToString();
            espeak(numeroExtraido);
            buttons[numeroExtraido-1].ModifyBg (StateType.Normal, verde);
            numeros.Remove(numeroExtraido);

            showNumeros();

        };
    }
 public static void Draw(Window window, Gdk.GC gc, int units, int width, int height)
 {
     var darkColor = new Gdk.Color(50, 50, 50);
     var brightColor = new Gdk.Color(100, 100, 100);
     int nw = width / units;
     int nh = height / units;
     for (int i = 0; i <= nw; i++) {
         for (int j = 0; j <= nh; j++) {
             bool dark = ((i + j) % 2) == 0;
             if (dark) gc.RgbFgColor = darkColor;
             else gc.RgbFgColor = brightColor;
             window.DrawRectangle(gc, true, units * i, units * j, units, units);
         }
     }
 }
Exemple #44
0
        /// <summary>
        /// Initializes a new instance of the <see cref="PrototypeBackend.Sequence"/> class.
        /// </summary>
        /// <param name="info">Info.</param>
        /// <param name="context">Context.</param>
        public Sequence(SerializationInfo info, StreamingContext context)
        {
            Pin = new DPin ();
            Pin = (DPin)info.GetValue ("Pin", Pin.GetType ());

            Name = info.GetString ("Name");

            GroupName = info.GetString ("GroupName");

            Chain = new List<SequenceOperation> ();
            Chain = (List<SequenceOperation>)info.GetValue ("Chain", Chain.GetType ());

            Repetitions = info.GetInt32 ("Repetitions");

            Color = new Gdk.Color (info.GetByte ("RED"), info.GetByte ("GREEN"), info.GetByte ("BLUE"));
        }
Exemple #45
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);
            }
        }
Exemple #46
0
 /// <summary>
 /// Initializes a new instance of the <see cref="PrototypeBackend.APin"/> class.
 /// </summary>
 public APin()
 {
     Type = Backend.PinType.ANALOG;
     Mode = Backend.PinMode.INPUT;
     Name = "";
     Number = 0;
     PlotColor = new Gdk.Color (0, 0, 0);
     Slope = 1;
     Offset = 0;
     MeanValuesCount = 1;
     Interval = 1000;
     Values = new List<DateTimeValue> ();
     RAWValues = new List<DateTimeValue> ();
     Unit = "V";
     OnNewValue = null;
     OnNewRAWValue = null;
 }
Exemple #47
0
    public MainWindow()
        : base(Gtk.WindowType.Toplevel)
    {
        Build ();
        total.Markup = "<span size='xx-large' weight='bold'> Total: 0,0 Euros</span>";

        string connectionString = "Server=localhost;Database=dbcafeteria;User Id=dbcafeteria;Password=dbcafeteria";
        ApplicationContext.Instance.DbConnection = new NpgsqlConnection(connectionString);
        dbConnection = ApplicationContext.Instance.DbConnection;
        dbConnection.Open ();

        dbConnection = ApplicationContext.Instance.DbConnection;

        //Objeto fondo creado para poner un color de fondo en el boton "INICIAR PEDIDO"
        Gdk.Color fondo = new Gdk.Color();
        Gdk.Color.Parse("red", ref fondo);
        buttonNuevoPedido.ModifyBg(StateType.Normal, fondo);
    }
        // ============================================
        // PUBLIC Constructors
        // ============================================
        public BandwidthGraph(float secTotal, float secInterval)
        {
            this.secTotal = secTotal;
            this.secInterval = secInterval;

            int blk = (int) (this.secTotal/this.secInterval);
            this.dw_speeds = new int[blk];
            this.up_speeds = new int[blk];

            this.maxByteSpeed = 1;
            this.downloadColor = new Gdk.Color(0x6a, 0xcd, 0x5a);
            this.borderColor = new Gdk.Color(0x80, 0x80, 0x80);
            this.uploadColor = new Gdk.Color(0x6a, 0x5a, 0xcd);
            this.textColor = new Gdk.Color(0xD3, 0xD3, 0xD3);

            this.Realized += new EventHandler(OnRealized);
            this.ExposeEvent += new ExposeEventHandler(OnExposed);
        }
        public ArrowWindow(DockToolbarFrame frame, Direction dir)
            : base(Gtk.WindowType.Popup)
        {
            SkipTaskbarHint = true;
            Decorated = false;
            TransientFor = frame.TopWindow;

            direction = dir;
            arrow = CreateArrow ();
            if (direction == Direction.Up || direction == Direction.Down) {
                 width = PointerWidth;
                 height = LineLength + PointerLength + 1;
            } else {
                 height = PointerWidth;
                 width = LineLength + PointerLength + 1;
            }

            // Create the mask for the arrow

            Gdk.Color black, white;
            black = new Gdk.Color (0, 0, 0);
            black.Pixel = 1;
            white = new Gdk.Color (255, 255, 255);
            white.Pixel = 0;

            Gdk.Pixmap pm = new Pixmap (this.GdkWindow, width, height, 1);
            Gdk.GC gc = new Gdk.GC (pm);
            gc.Background = white;
            gc.Foreground = white;
            pm.DrawRectangle (gc, true, 0, 0, width, height);

            gc.Foreground = black;
            pm.DrawPolygon (gc, false, arrow);
            pm.DrawPolygon (gc, true, arrow);

            this.ShapeCombineMask (pm, 0, 0);

            Realize ();

            redgc = new Gdk.GC (GdkWindow);
               		redgc.RgbFgColor = new Gdk.Color (255, 0, 0);

            Resize (width, height);
        }
		void CreateShape (int width, int height)
		{
			Gdk.Color black, white;
			black = new Gdk.Color (0, 0, 0);
			black.Pixel = 1;
			white = new Gdk.Color (255, 255, 255);
			white.Pixel = 0;
			
			Gdk.Pixmap pm = new Pixmap (this.GdkWindow, width, height, 1);
			Gdk.GC gc = new Gdk.GC (pm);
			gc.Background = white;
			gc.Foreground = white;
			pm.DrawRectangle (gc, true, 0, 0, width, height);
			
			gc.Foreground = black;
			pm.DrawRectangle (gc, false, 0, 0, width - 1, height - 1);
			pm.DrawRectangle (gc, false, 1, 1, width - 3, height - 3);
			
			this.ShapeCombineMask (pm, 0, 0);
		}
    public MainWindow()
        : base(Gtk.WindowType.Toplevel)
    {
        Build ();
        canvas.ExposeEvent += OnExposed;
        canvas.Move (0, 0);

        fixed3.SizeAllocated += (o, args) => {
            canvas.SetSizeRequest (fixed3.GetWidth (), fixed3.GetHeight ());
        }  ;

        Gdk.Color col = new Gdk.Color ();
        Gdk.Color.Parse ("black", ref col);
        canvas.ModifyBg (StateType.Normal, col);

        hp [0] = CreateHermitePoint (new Color (255, 0, 0));
        hp [1] = CreateHermitePoint (new Color (255, 0, 0));
        hp [2] = CreateHermitePoint (new Color (0, 255, 0));
        hp [3] = CreateHermitePoint (new Color (0, 255, 0));

        fixed3.Put(hp [0].Area, 200, 100);
        fixed3.Put(hp [1].Area, 100, 100);
        fixed3.Put(hp [2].Area, 250, 200);
        fixed3.Put(hp [3].Area, 100, 200);

        hp [0].Area.ExposeEvent += (o, args) => {
            hp [0].Area.DrawText (0, 0, "P1");
        };

        hp [1].Area.ExposeEvent += (o, args) => {
            hp [1].Area.DrawText (0, 0, "P2");
        };

        hp [2].Area.ExposeEvent += (o, args) => {
            hp [2].Area.DrawText (0, 0, "T1");
        };

        hp [3].Area.ExposeEvent += (o, args) => {
            hp [3].Area.DrawText (0, 0, "T2");
        };
    }
Exemple #52
0
    public MainWindow()
        : base(Gtk.WindowType.Toplevel)
    {
        Build ();

        Gdk.Color COLOR_GREEN = new Gdk.Color(0, 255, 0);
        int count = arrayButton.Rows * arrayButton.Columns;

        for (int index = 0; index < count; index++){
            arrayButton.GetButton (index).Label = string.Format("{0}", index + 1);

            if (index % 2 == 0)
                arrayButton.GetButton (index).ModifyBg (StateType.Normal, COLOR_GREEN);

        }

        arrayButton.GetButton (1, 2).Label = "*";
        arrayButton[2, 4].Label = "-";

        arrayButton.SetLabel (new string[]{"Uno", "Dos", "Tres"});
        arrayButton.SetLabel (new string[]{"Uno", "Dos", "Tres", "Cuatro"});
    }
Exemple #53
0
        public void Init()
        {
            this.ParentWindow = Gdk.Window.ForeignNewForDisplay (Gdk.Display.Default, (uint)handle.ToInt32 ());
            Gdk.Color col = new Gdk.Color();
            Gdk.Color.Parse("White", ref col);
            this.ModifyBg (Gtk.StateType.Normal, col);

            //			this.ButtonPressEvent += delegate (object sender, ButtonPressEventArgs e) {
            //				DebugHelper.WriteLine ("ButtonPress");
            //			};
            //
            //			this.FocusInEvent += delegate (object sender, FocusInEventArgs e) {
            //				DebugHelper.WriteLine ("FocusInEvent");
            //			};
            //

            //			((Widget)this).WidgetEvent += delegate (object sender, WidgetEventArgs e) {
            //				DebugHelper.WriteLine ("WidgetEvent " + e.Event.Type);
            //				while (Gtk.Application.EventsPending ())
            //					Gtk.Application.RunIteration ();
            //			};
        }
        /// <summary>
        /// Initializes a new instance of the <see cref="PrototypeBackend.MeasurementCombination"/> class.
        /// </summary>
        /// <param name="info">Info.</param>
        /// <param name="context">Context.</param>
        public MeasurementCombination(SerializationInfo info, StreamingContext context)
        {
            Pins = new List<APin> ();
            Pins = (List<APin>)info.GetValue ("Pins", Pins.GetType ());

            Name = info.GetString ("Name");
            Unit = info.GetString ("Unit");
            Color = new Gdk.Color (info.GetByte ("RED"), info.GetByte ("GREEN"), info.GetByte ("BLUE"));
            MeanValuesCount = info.GetInt32 ("Interval");

            OperationString = info.GetString ("OperationString");
            if (!string.IsNullOrEmpty (OperationString) && Pins.Count > 0 && Pins.All (o => o != null))
            {
                try
                {
                    Operation = OperationCompiler.CompileOperation (OperationString, Pins.Select (o => o.DisplayNumberShort).ToArray<string> ());
                } catch (Exception e)
                {
                    throw e;
                }
            }

            Values = new List<DateTimeValue> ();
        }
Exemple #55
0
  public NotifyWindow(Gtk.Widget parent, string message, string details,
 Gtk.MessageType messageType, uint timeout)
      : base(Gtk.WindowType.Popup)
  {
      this.AppPaintable = true;
         parentWidget = parent;
         this.timeout = timeout;
         activeBackgroundColor = new Gdk.Color(249, 253, 202);
         inactiveBackgroundColor = new Gdk.Color(255, 255, 255);
         Gtk.HBox outBox = new HBox();
         this.Add(outBox);
         outBox.BorderWidth = (uint)wbsize;
         Gtk.VBox closeBox = new VBox();
         closeBox.BorderWidth = 3;
         outBox.PackEnd(closeBox, true, true, 0);
         EventBox eBox = new EventBox();
         eBox.ButtonPressEvent +=
      new ButtonPressEventHandler(OnCloseEvent);
         Gtk.Image closeImg = new Gtk.Image();
         closeImg.SetFromStock(Gtk.Stock.Close,
         IconSize.Menu);
         eBox.Add(closeImg);
         closeBox.PackStart(eBox, false, false, 0);
         Label padder = new Label("");
         outBox.PackStart(padder, false, false, 5);
         Gtk.VBox vbox = new VBox();
         outBox.PackStart(vbox, true, true, 0);
         vbox.BorderWidth = 10;
         Gtk.HBox hbox = new HBox();
         hbox.Spacing = 5;
         vbox.PackStart(hbox, false, false, 0);
         VBox iconVBox = new VBox();
         hbox.PackStart(iconVBox, false, false, 0);
         Gtk.Image msgImage = new Gtk.Image();
         switch(messageType)
         {
      case Gtk.MessageType.Info:
       msgImage.SetFromStock(Gtk.Stock.DialogInfo,
         IconSize.Button);
       break;
      case Gtk.MessageType.Warning:
       msgImage.SetFromStock(Gtk.Stock.DialogWarning,
         IconSize.Button);
       break;
      case Gtk.MessageType.Question:
       msgImage.SetFromStock(Gtk.Stock.DialogQuestion,
         IconSize.Button);
       break;
      case Gtk.MessageType.Error:
       msgImage.SetFromStock(Gtk.Stock.DialogError,
         IconSize.Button);
       break;
         }
         iconVBox.PackStart(msgImage, false, false, 0);
         VBox messageVBox = new VBox();
         hbox.PackStart(messageVBox, true, true, 0);
         Label l = new Label();
         l.Markup = "<span size=\"small\" weight=\"bold\">" + message + "</span>";
         l.LineWrap = false;
         l.UseMarkup = true;
         l.Selectable = false;
         l.Xalign = 0;
         l.Yalign = 0;
         l.LineWrap = true;
         l.Wrap = true;
         l.WidthRequest = messageTextWidth;
         messageVBox.PackStart(l, false, true, 0);
         detailsTextView = new LinkTextView(details);
         detailsTextView.Editable = false;
         detailsTextView.CursorVisible = false;
         detailsTextView.WrapMode = WrapMode.Word;
         detailsTextView.SizeAllocate(new Gdk.Rectangle(0, 0, messageTextWidth, 600));
         detailsTextView.LinkClicked +=
      new LinkClickedEventHandler(OnLinkClicked);
         messageVBox.PackStart(detailsTextView, false, false, 3);
         Label spacer = new Label();
         spacer.UseMarkup = true;
         spacer.Markup = "<span size=\"xx-small\"> </span>";
         messageVBox.PackEnd(spacer, false, false, 0);
         closeWindowTimeoutID = 0;
  }
Exemple #56
0
		public static HslColor Parse (string color)
		{
			Gdk.Color col = new Gdk.Color (0, 0, 0);
			Gdk.Color.Parse (color, ref col);
			return (HslColor)col;
		}
Exemple #57
0
	void RealizeHanlder (object o, EventArgs sender)
        {
                white_gc = Style.WhiteGC;

                bkgr_gc = Style.BackgroundGC (StateType.Normal);

                selection_gc = new Gdk.GC (GdkWindow);
                selection_gc.Copy (Style.BackgroundGC (StateType.Normal));
                Gdk.Color fgcol = new Gdk.Color ();
                fgcol.Pixel = 0x000077ee;
                selection_gc.Foreground = fgcol;
                selection_gc.SetLineAttributes (3, LineStyle.Solid, CapStyle.NotLast, JoinStyle.Round);
        }
		protected override void Render (Drawable window, Widget widget, Gdk.Rectangle background_area, Gdk.Rectangle cell_area, Gdk.Rectangle expose_area, CellRendererState flags)
		{
			if (isDisposed)
				return;
			if (diffMode) {
				
				if (path.Equals (selctedPath)) {
					selectedLine = -1;
					selctedPath = null;
				}
				
				int w, maxy;
				window.GetSize (out w, out maxy);
				if (DrawLeft) {
					cell_area.Width += cell_area.X - leftSpace;
					cell_area.X = leftSpace;
				}
				var treeview = widget as FileTreeView;
				var p = treeview != null? treeview.CursorLocation : null;
				
				cell_area.Width -= RightPadding;
				
				window.DrawRectangle (widget.Style.BaseGC (Gtk.StateType.Normal), true, cell_area.X, cell_area.Y, cell_area.Width - 1, cell_area.Height);
				
				Gdk.GC normalGC = widget.Style.TextGC (StateType.Normal);
				Gdk.GC removedGC = new Gdk.GC (window);
				removedGC.Copy (normalGC);
				removedGC.RgbFgColor = baseRemoveColor.AddLight (-0.3);
				Gdk.GC addedGC = new Gdk.GC (window);
				addedGC.Copy (normalGC);
				addedGC.RgbFgColor = baseAddColor.AddLight (-0.3);
				Gdk.GC infoGC = new Gdk.GC (window);
				infoGC.Copy (normalGC);
				infoGC.RgbFgColor = widget.Style.Text (StateType.Normal).AddLight (0.2);
				
				Cairo.Context ctx = CairoHelper.Create (window);
				Gdk.Color bgColor = new Gdk.Color (0,0,0);
				
				
				// Rendering is done in two steps:
				// 1) Get a list of blocks to render
				// 2) render the blocks
				
				int y = cell_area.Y + 2;
				
				// cline keeps track of the current source code line (the one to jump to when double clicking)
				int cline = 1;
				bool inHeader = true;
				BlockInfo currentBlock = null;
				
				List<BlockInfo> blocks = new List<BlockInfo> ();
				
				for (int n=0; n<lines.Length; n++, y += lineHeight) {
					
					string line = lines [n];
					if (line.Length == 0) {
						currentBlock = null;
						y -= lineHeight;
						continue;
					}
					
					char tag = line [0];
	
					if (line.StartsWith ("---") || line.StartsWith ("+++")) {
						// Ignore this part of the header.
						currentBlock = null;
						y -= lineHeight;
						continue;
					}
					if (tag == '@') {
						int l = ParseCurrentLine (line);
						if (l != -1) cline = l - 1;
						inHeader = false;
					} else if (tag != '-' && !inHeader)
						cline++;
					
					BlockType type;
					bool hasBg = false;
					switch (tag) {
						case '-': type = BlockType.Removed; break;
						case '+': type = BlockType.Added; break;
						case '@': type = BlockType.Info; break;
						default: type = BlockType.Unchanged; break;
					}

					if (currentBlock == null || type != currentBlock.Type) {
						if (y > maxy)
							break;
					
						// Starting a new block. Mark section ends between a change block and a normal code block
						if (currentBlock != null && IsChangeBlock (currentBlock.Type) && !IsChangeBlock (type))
							currentBlock.SectionEnd = true;
						
						currentBlock = new BlockInfo () {
							YStart = y,
							FirstLine = n,
							Type = type,
							SourceLineStart = cline,
							SectionStart = (blocks.Count == 0 || !IsChangeBlock (blocks[blocks.Count - 1].Type)) && IsChangeBlock (type)
						};
						blocks.Add (currentBlock);
					}
					// Include the line in the current block
					currentBlock.YEnd = y + lineHeight;
					currentBlock.LastLine = n;
				}

				// Now render the blocks

				// The y position of the highlighted line
				int selectedLineRowTop = -1;

				BlockInfo lastCodeSegmentStart = null;
				BlockInfo lastCodeSegmentEnd = null;
				
				foreach (BlockInfo block in blocks)
				{
					if (block.Type == BlockType.Info) {
						// Finished drawing the content of a code segment. Now draw the segment border and label.
						if (lastCodeSegmentStart != null)
							DrawCodeSegmentBorder (infoGC, ctx, cell_area.X, cell_area.Width, lastCodeSegmentStart, lastCodeSegmentEnd, lines, widget, window);
						lastCodeSegmentStart = block;
					}
					
					lastCodeSegmentEnd = block;
					
					if (block.YEnd < 0)
						continue;
					
					// Draw the block background
					DrawBlockBg (ctx, cell_area.X + 1, cell_area.Width - 2, block);
					
					// Get all text for the current block
					StringBuilder sb = new StringBuilder ();
					for (int n=block.FirstLine; n <= block.LastLine; n++) {
						string s = ProcessLine (lines [n]);
						if (sb.Length > 0)
							sb.Append ('\n');
						if (block.Type != BlockType.Info && s.Length > 0)
							sb.Append (s, 1, s.Length - 1);
						else
							sb.Append (s);
					}
					
					// Draw a special background for the selected line
					
					if (block.Type != BlockType.Info && p.HasValue && p.Value.X >= cell_area.X && p.Value.X <= cell_area.Right && p.Value.Y >= block.YStart && p.Value.Y <= block.YEnd) {
						int row = (p.Value.Y - block.YStart) / lineHeight;
						double yrow = block.YStart + lineHeight * row + 0.5;
						double xrow = cell_area.X + LeftPaddingBlock + 0.5;
						int wrow = cell_area.Width - 1 - LeftPaddingBlock;
						if (block.Type == BlockType.Added)
							ctx.Color = baseAddColor.AddLight (0.1).ToCairoColor ();
						else if (block.Type == BlockType.Removed)
							ctx.Color = baseRemoveColor.AddLight (0.1).ToCairoColor ();
						else {
							ctx.Color = widget.Style.Base (Gtk.StateType.Prelight).AddLight (0.1).ToCairoColor ();
							xrow -= LeftPaddingBlock;
							wrow += LeftPaddingBlock;
						}
						ctx.Rectangle (xrow, yrow, wrow, lineHeight);
						ctx.Fill ();
						selectedLine = block.SourceLineStart + row;
						selctedPath = path;
						selectedLineRowTop = (int)yrow;
					}
					
					// Draw the line text. Ignore header blocks, since they are drawn as labels in DrawCodeSegmentBorder
					
					if (block.Type != BlockType.Info) {
						layout.SetMarkup ("");
						layout.SetText (sb.ToString ());
						Gdk.GC gc;
						switch (block.Type) {
							case BlockType.Removed: gc = removedGC; break;
							case BlockType.Added: gc = addedGC; break;
							case BlockType.Info: gc = infoGC; break;
							default: gc = normalGC; break;
						}
						window.DrawLayout (gc, cell_area.X + 2 + LeftPaddingBlock, block.YStart, layout);
					}
					
					// Finally draw the change symbol at the left margin
					
					DrawChangeSymbol (ctx, cell_area.X + 1, cell_area.Width - 2, block);
				}
				
				// Finish the drawing of the code segment
				if (lastCodeSegmentStart != null)
					DrawCodeSegmentBorder (infoGC, ctx, cell_area.X, cell_area.Width, lastCodeSegmentStart, lastCodeSegmentEnd, lines, widget, window);
				
				// Draw the source line number at the current selected line. It must be done at the end because it must
				// be drawn over the source code text and segment borders.
				if (selectedLineRowTop != -1)
					DrawLineBox (normalGC, ctx, ((Gtk.TreeView)widget).VisibleRect.Right - 4, selectedLineRowTop, selectedLine, widget, window);
				
				((IDisposable)ctx).Dispose ();
				removedGC.Dispose ();
				addedGC.Dispose ();
				infoGC.Dispose ();
			} else {
				// Rendering a normal text row
				int y = cell_area.Y + (cell_area.Height - height)/2;
				window.DrawLayout (widget.Style.TextGC (GetState(flags)), cell_area.X, y, layout);
			}
		}
Exemple #59
0
 protected virtual void RenderTreeCell( Gtk.TreeViewColumn _column, Gtk.CellRenderer _cell, Gtk.TreeModel _model, Gtk.TreeIter _iter)
 {
     object o = _model.GetValue(_iter, 0);
     GuiComponents.TvEpisodeNodeItem node = o as GuiComponents.TvEpisodeNodeItem;
     Gdk.Color background = new Gdk.Color(255, 255, 255);
     if(node != null && (_model.GetPath(_iter).Indices[1] % 2) == 0)
         background = new Gdk.Color(240, 240, 255);
     if(_cell is Gtk.CellRendererText)
     {
         if(node != null)
         {
             switch(_column.SortColumnId)
             {
                 case 1: (_cell as Gtk.CellRendererText).Text = node.EpisodeNames; break;
                 case 3: (_cell as Gtk.CellRendererText).Text = node.Filename; break;
             }
         }
         else if(o is KeyNode && _column.SortColumnId == 0)
         {
             (_cell as Gtk.CellRendererText).Markup = ((KeyNode)o).Markup;
         }
         else
             (_cell as Gtk.CellRendererText).Text = "";
         (_cell as Gtk.CellRendererText).BackgroundGdk = background;
     }
     else if(_cell is TreeItemCellRenderer)
     {
         TreeItemCellRenderer render = (TreeItemCellRenderer)_cell;
         render.CellBackgroundGdk = background;
         render.Pixbuf = null;
         if(node != null)
         {
             render.Text = node.EpisodeNumbersString;
             render.Pixbuf = node.StatusIcon;
         }
         else
             render.Text = ((KeyNode)o).Key;
     }
     else
     {
         if(node != null)
         {
             switch(_column.SortColumnId)
             {
                 case 2: (_cell as Gtk.CellRendererPixbuf).Pixbuf = node.RatingIcon; break;
             }
         }
         else
         {
             (_cell as Gtk.CellRendererPixbuf).Pixbuf = Images.Empty;
         }
         (_cell as Gtk.CellRendererPixbuf).CellBackgroundGdk = background;
     }
 }
        public PersonWidget()
        {
            this.Build ();

            #region Labelstyle
            //projectTitelLabel.Pattern = "________________________________________________________________________________"; //Unterstreichung - Projekttitel
            Gdk.Color bluecolor = new Gdk.Color (255, 100, 50);
            //dateLabel.ModifyFg (Gtk.StateType.Normal, bluecolor);
            PHeaderLabel.ModifyFont (Pango.FontDescription.FromString ("Calibri, Bold 11"));
            PVHeaderLabel.ModifyFont (Pango.FontDescription.FromString ("Calibri, Bold 11"));
            #endregion

            #region TreeView füllen
            // Create a column for the date name
            Gtk.TreeViewColumn fnameColumn = new Gtk.TreeViewColumn ();
            fnameColumn.Title = "Vorname";

            // Create the text cell that will display the date
            Gtk.CellRendererText fnameTitleCell = new Gtk.CellRendererText ();
            fnameColumn.PackStart (fnameTitleCell, true); // Add the cell to the column

            // Create a column for the description
            Gtk.TreeViewColumn lnameColumn = new Gtk.TreeViewColumn ();
            lnameColumn.Title = "Nachname";
            Gtk.CellRendererText lnameTitleCell = new Gtk.CellRendererText ();
            lnameColumn.PackStart (lnameTitleCell, true);

            // Create a column for the description
            Gtk.TreeViewColumn areaColumn = new Gtk.TreeViewColumn ();
            areaColumn.Title = "Abteilung";
            Gtk.CellRendererText areaTitleCell = new Gtk.CellRendererText ();
            areaColumn.PackStart (areaTitleCell, true);

            // Create a column for the description
            Gtk.TreeViewColumn taskColumn = new Gtk.TreeViewColumn ();
            taskColumn.Title = "Aufgabe";
            Gtk.CellRendererText taskTitleCell = new Gtk.CellRendererText ();
            taskColumn.PackStart (taskTitleCell, true);

            // Create a column for the description
            Gtk.TreeViewColumn typColumn = new Gtk.TreeViewColumn ();
            typColumn.Title = "Typ";
            Gtk.CellRendererText typTitleCell = new Gtk.CellRendererText ();
            typColumn.PackStart (typTitleCell, true);

            Gtk.TreeViewColumn timesColumn = new Gtk.TreeViewColumn ();
            timesColumn.Title = "Schicht";
            Gtk.CellRendererText timesTitleCell = new Gtk.CellRendererText ();
            timesColumn.PackStart (timesTitleCell, true);

            Gtk.TreeViewColumn starttimeColumn = new Gtk.TreeViewColumn ();
            starttimeColumn.Title = "Start";
            Gtk.CellRendererText starttimeTitleCell = new Gtk.CellRendererText ();
            starttimeColumn.PackStart (starttimeTitleCell, true);

            Gtk.TreeViewColumn endtimeColumn = new Gtk.TreeViewColumn ();
            endtimeColumn.Title = "Ende";
            Gtk.CellRendererText endtimeTitleCell = new Gtk.CellRendererText ();
            endtimeColumn.PackStart (endtimeTitleCell, true);

            Gtk.TreeViewColumn emailColumn = new Gtk.TreeViewColumn ();
            emailColumn.Title = "email";
            Gtk.CellRendererText emailTitleCell = new Gtk.CellRendererText ();
            emailColumn.PackStart (emailTitleCell, true);

            Gtk.TreeViewColumn mobileColumn = new Gtk.TreeViewColumn ();
            mobileColumn.Title = "Handy";
            Gtk.CellRendererText mobileTitleCell = new Gtk.CellRendererText ();
            mobileColumn.PackStart (mobileTitleCell, true);

            Gtk.TreeViewColumn teleColumn = new Gtk.TreeViewColumn ();
            teleColumn.Title = "Telefon";
            Gtk.CellRendererText teleTitleCell = new Gtk.CellRendererText ();
            teleColumn.PackStart (teleTitleCell, true);

            // Add the columns to the TreeView
            personalTreeView.AppendColumn (fnameColumn);
            personalTreeView.AppendColumn (lnameColumn);
            personalTreeView.AppendColumn (areaColumn);
            personalTreeView.AppendColumn (taskColumn);
            personalTreeView.AppendColumn (typColumn);
            personalTreeView.AppendColumn (timesColumn);
            personalTreeView.AppendColumn (starttimeColumn);
            personalTreeView.AppendColumn (endtimeColumn);
            personalTreeView.AppendColumn (emailColumn);
            personalTreeView.AppendColumn (mobileColumn);
            personalTreeView.AppendColumn (teleColumn);

            // Tell the Cell Renderers which items in the model to display
            fnameColumn.AddAttribute (fnameTitleCell, "text", 0);
            lnameColumn.AddAttribute (lnameTitleCell, "text", 1);
            areaColumn.AddAttribute(areaTitleCell, "text", 2);
            taskColumn.AddAttribute(taskTitleCell, "text", 3);
            typColumn.AddAttribute(typTitleCell, "text", 4);
            timesColumn.AddAttribute(timesTitleCell, "text", 5);
            starttimeColumn.AddAttribute(starttimeTitleCell, "text", 6);
            endtimeColumn.AddAttribute(endtimeTitleCell, "text", 7);
            emailColumn.AddAttribute(emailTitleCell, "text", 8);
            mobileColumn.AddAttribute(mobileTitleCell, "text", 9);
            teleColumn.AddAttribute(teleTitleCell, "text", 10);

            // Create a model that will hold two strings - Artist Name and Song Title

            // Add some data to the store
            //			workerListStore.AppendValues ("Martin", "Bischof", "Wein", "Aufgabe", "Typ", "Schicht", "Startzeit", "Endzeit", "Email", "Mobile", "Telefon");
            //			workerListStore.AppendValues ("Andreas", "Stark", "Abteilung", "Aufgabe", "Typ", "Schicht", "Startzeit", "Endzeit", "Email", "Mobile", "Telefon");

            List<String[]> workerList = SelectWidget.connection.readWorker(); // PARAMETER neu einfügen!

            foreach (string[] s in workerList) {
                workerListStore.AppendValues (s[0], s[1], s[2], s[3], s[4],s[5], s[6], s[7], s[8], s[9], s[10]);
            }

            //			workerListStore.AppendValues ("Martin", "Bischof", "Wein", "Aufgabe", "Typ", "Schicht", "Startzeit", "Endzeit", "Email", "Mobile", "Telefon");
            //			workerListStore.AppendValues ("Andreas", "Stark", "Abteilung", "Aufgabe", "Typ", "Schicht", "Startzeit", "Endzeit", "Email", "Mobile", "Telefon");

            //			// Assign the model to the TreeView

            personalTreeView.Model = workerListStore;

            // Instead of assigning the ListStore model directly to the TreeStore, we create a TreeModelFilter
            // which sits between the Model (the ListStore) and the View (the TreeView) filtering what the model sees.
            // Some may say that this is a "Controller", even though the name and usage suggests that it is still part of
            // the Model.
            filter = new Gtk.TreeModelFilter (workerListStore, null);

            // Specify the function that determines which rows to filter out and which ones to display
            filter.VisibleFunc = new Gtk.TreeModelFilterVisibleFunc (FilterTree);

            // Assign the filter as our tree's model
            personalTreeView.Model = filter;

            #endregion

            #region areaComboBox - Fill areas

            List<String> areaList = SelectWidget.connection.readAreas();
            ListStore ls = new ListStore(typeof(string));
            areaCombobox.Model = ls;

            foreach(string s in areaList)
                ls.AppendValues(s);

            ls.AppendValues ("");
            #endregion

            #region typComboBox - Fill Typ
            List<String> typList = SelectWidget.connection.readTyp();
            ListStore typLS = new ListStore(typeof(string));
            typCombobox.Model = typLS;

            foreach(string s in typList)
                typLS.AppendValues(s);

            typLS.AppendValues("");
            #endregion

            #region taskComboBox - Fill Tasks
            int readAreaID = SelectWidget.connection.readAreaID(areaCombobox.ActiveText);
            if(readAreaID != 0)
            {
                List<String> taskList = SelectWidget.connection.readTasks(readAreaID);
                ListStore taskLS = new ListStore(typeof(string));
                taskCombobox.Model = taskLS;

                foreach(string s in taskList)
                    taskLS.AppendValues(s);

                taskLS.AppendValues("");
            }

            #endregion

            #region timesComboBox - Fill Times
            List<String> timeList = SelectWidget.connection.readTime();
            ListStore timeLS = new ListStore(typeof(string));
            timesCombobox.Model = timeLS;

            foreach(string s in timeList)
                timeLS.AppendValues(s);

            timeLS.AppendValues("");
            #endregion
        }