예제 #1
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);
            }
        }
예제 #2
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++;
                }
            }
        }
예제 #3
0
        private void DrawCategories(Gdk.Window win)
        {
            int i = 0;

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

            using (Cairo.Context g = Gdk.CairoHelper.Create(win)) {
                foreach (String label in labelsDict.Keys)
                {
                    int y = LINE_WIDTH / 2 + i * SECTION_HEIGHT - (int)Scroll;
                    CairoUtils.DrawRoundedRectangle(g, 2, y + 3, Allocation.Width - 3,
                                                    SECTION_HEIGHT - 3, SECTION_HEIGHT / 7,
                                                    CairoUtils.RGBToCairoColor(labelsDict[label]),
                                                    CairoUtils.RGBToCairoColor(labelsDict[label]));
                    DrawCairoText(label, 0 + 3, y + SECTION_HEIGHT / 2 - 5);
                    i++;
                }
            }
        }
예제 #4
0
        protected override bool OnExposeEvent(EventExpose evnt)
        {
            int    width, height, center, lCenter, vCenter, totalCount;
            double localPercent, visitorPercent;

            this.GdkWindow.Clear();

            width   = Allocation.Width;
            center  = width / 2;
            lCenter = center - textSize / 2;
            vCenter = center + textSize / 2;
            width   = width - textSize - 10;

            height = Allocation.Height;

            if (category != null)
            {
                totalCount = category.TotalCount;
            }
            else
            {
                totalCount = stat.TotalCount;
            }
            if (totalCount != 0)
            {
                localPercent   = (double)stat.LocalTeamCount / totalCount;
                visitorPercent = (double)stat.VisitorTeamCount / totalCount;
            }
            else
            {
                localPercent   = 0;
                visitorPercent = 0;
            }

            using (Cairo.Context g = Gdk.CairoHelper.Create(this.GdkWindow)) {
                int localW, visitorW;

                localW   = (int)(width / 2 * localPercent);
                visitorW = (int)(width / 2 * visitorPercent);

                /* Home bar */
                CairoUtils.DrawRoundedRectangle(g, lCenter - localW, 0, localW, height, 0,
                                                HomeColor, HomeColor);
                /* Away bar  */
                CairoUtils.DrawRoundedRectangle(g, vCenter, 0, visitorW, height, 0,
                                                AwayColor, AwayColor);

                /* Category name */
                layout.Width     = Pango.Units.FromPixels(textSize);
                layout.Alignment = Pango.Alignment.Center;
                layout.SetMarkup(String.Format(name_tpl, GLib.Markup.EscapeText(stat.Name)));
                GdkWindow.DrawLayout(Style.TextGC(StateType.Normal), center - textSize / 2, 0, layout);

                /* Home count */
                layout.Width     = Pango.Units.FromPixels(COUNT_WIDTH);
                layout.Alignment = Pango.Alignment.Right;
                layout.SetMarkup(String.Format(count_tpl, stat.LocalTeamCount, (localPercent * 100).ToString("f2")));
                GdkWindow.DrawLayout(Style.TextGC(StateType.Normal), lCenter - (COUNT_WIDTH + 3), 0, layout);

                /* Away count */
                layout.Width     = Pango.Units.FromPixels(COUNT_WIDTH);
                layout.Alignment = Pango.Alignment.Left;
                layout.SetMarkup(String.Format(count_tpl, stat.VisitorTeamCount, (visitorPercent * 100).ToString("f2")));
                GdkWindow.DrawLayout(Style.TextGC(StateType.Normal), vCenter + 3, 0, layout);
            }

            return(true);
        }