Esempio n. 1
0
 //---------------------------------------------------------------------
 //constructors
 //---------------------------------------------------------------------
 /// <summary>
 /// Initializes a new instance of the QuickBar class.
 /// </summary>
 public QuickBar(GraphData data, int width, int height)
     : base(data, width, height)
 {
     textColor = Color.Black;
     textFont = new Font("Verdana", 8, FontStyle.Regular);
     textStringFormat = new StringFormat();
     textStringFormat.Alignment = StringAlignment.Center;
     textStringFormat.LineAlignment = StringAlignment.Center;
 }
Esempio n. 2
0
        /// <summary>
        /// Initializes a new instance of the Pie2D class requiring graph data, width and height.
        /// </summary>
        /// <param name="data"></param>
        /// <param name="width"></param>
        /// <param name="height"></param>
        public Pie2D(GraphData data, int width, int height)
            : base(data, width, height)
        {
            GraphCanvasRectangle = new Rectangle(0, 0, width, height);
            GraphRectangle = GraphCanvasRectangle;

            TitleColor = Color.Black;
            //TitleFont = new Font("Verdana", 12, FontStyle.Bold);
            TitleStringFormat = new StringFormat();
            TitleStringFormat.Alignment = StringAlignment.Center;
            TitleStringFormat.LineAlignment = StringAlignment.Center;

            //LegendFont = new Font("Tahoma", 9, FontStyle.Regular);
            LegendStringFormat = new StringFormat();
            LegendStringFormat.Alignment = StringAlignment.Center;
            LegendStringFormat.LineAlignment = StringAlignment.Center;
        }
Esempio n. 3
0
 //---------------------------------------------------------------------
 //constructors
 //---------------------------------------------------------------------
 /// <summary>
 /// Initializes a new instance of the Pie2D class requiring graph data.
 /// </summary>
 /// <param name="data"></param>
 public Pie2D(GraphData data)
     : base(data)
 {
 }
Esempio n. 4
0
        /// <summary>
        /// Creates the a 2D pie chart image.
        /// </summary>
        /// <param name="engine">The engine.</param>
        /// <param name="activities">The activities.</param>
        /// <param name="width">The width.</param>
        /// <param name="height">The height.</param>
        /// <returns></returns>
        public static Image CreatePie2D(TaskClerkEngine engine, Collection<TaskActivity> activities, int width, int height)
        {
            string graphViewStyle = (string)engine.SettingsProvider.Get("GraphViewStyle", "Minutes");
            string graphGroupStyle =
                (string)engine.SettingsProvider.Get("GraphGroupStyle", "Group by Task");

            decimal totalMinutes = 0;
            GraphData data = new GraphData();
            data.Title = string.Format("{0} / {1}", graphGroupStyle, graphViewStyle);
            foreach (TaskActivity activity in activities)
            {

                string label = activity.TaskDescription.Name;
                Color color = activity.TaskDescription.Color;
                if (activity.TaskDescription.IsEmpty())
                {
                    label = "Empty";
                    color = Color.Black;
                }

                if (graphGroupStyle == "Group by Category")
                {
                    TaskDescription category =
                        (TaskDescription)engine.TaskDescriptionsProvider.CategoryFromTaskDescription(activity.TaskDescription);
                    if (category != null)
                    {
                        label = category.Name;
                        color = category.Color;
                    }
                    else
                    {
                        label = "Unknown";
                        color = Color.Black;
                    }
                }

                // only show activities and activities that have at least 0.01 minute of duration.
                if ((!activity.TaskDescription.IsEvent) && (activity.Duration > 0))
                {
                    GraphRange range = data.FindGraphRange(label);
                    if (range == null)
                    {
                        range = new GraphRange(
                            label,
                            color,
                            Color.DimGray,
                            0);
                        data.Ranges.Add(range);
                    }
                    range.Values.Add(new GraphValue(activity.Duration));
                    totalMinutes += activity.Duration;
                }
            }

            switch (graphViewStyle)
            {
                case "Hours":
                    foreach (GraphRange gr in data.Ranges)
                    {
                        foreach (GraphValue gv in gr.Values)
                        {
                            gv.Point = gv.Point / 60;
                        }
                    }
                    break;
                case "Percent (%)":
                    double divider = (double)(totalMinutes / 100);
                    foreach (GraphRange gr in data.Ranges)
                    {
                        double tot = 0;
                        foreach (GraphValue gv in gr.Values)
                        {
                            tot += gv.Point;
                        }
                        double answer = tot / divider;
                        gr.Values.Clear();
                        gr.Values.Add(new GraphValue(answer));
                    }
                    break;
                default:
                    break;
            }

            //PieChart
            Pie2D pie = new Pie2D(data, width, height);
            Font temp = (Font)AppContext.Current.SettingsProvider.Get("GeneralFont", SystemFonts.DefaultFont);
            pie.TitleFont = new Font(temp.FontFamily, temp.Size+2, FontStyle.Regular);
            pie.LegendFont = new Font(temp.FontFamily, temp.Size, FontStyle.Regular);
            pie.DrawLegend = true;
            pie.DrawTitle = true;
            if (graphViewStyle == "Task")
            {
                pie.TextLabels = true;
            }
            pie.Paint();
            return pie.Bitmap;
        }
Esempio n. 5
0
 /// <summary>
 /// Initializes a new instance of the <see cref="LineGraph"/> class.
 /// </summary>
 /// <param name="data">The data.</param>
 /// <param name="width">The width.</param>
 /// <param name="height">The height.</param>
 public LineGraph(GraphData data, int width, int height)
     : base(data, width, height)
 {
     GraphRectangle = new Rectangle(0, 0, width, height);
 }
Esempio n. 6
0
 /// <summary>
 /// Initializes a new instance of the <see cref="LineGraph"/> class.
 /// </summary>
 /// <param name="data">The data.</param>
 public LineGraph(GraphData data)
     : base(data)
 {
     GraphRectangle = new RectangleF(0, 0, 500, 500);
 }
Esempio n. 7
0
 /// <summary>
 /// Initializes a new instance of the <see cref="LineGraph"/> class.
 /// </summary>
 /// <param name="data">The data.</param>
 /// <param name="width">The width.</param>
 /// <param name="height">The height.</param>
 public LineGraph(GraphData data, int width, int height)
     : base(data, width, height)
 {
     GraphRectangle = new Rectangle(0, 0, width, height);
 }
Esempio n. 8
0
 /// <summary>
 /// Initializes a new instance of the <see cref="LineGraph"/> class.
 /// </summary>
 /// <param name="data">The data.</param>
 public LineGraph(GraphData data)
     : base(data)
 {
     GraphRectangle = new RectangleF(0, 0, 500, 500);
 }