Exemple #1
0
        private void btnMonthEffort_Click(object sender, EventArgs e)
        {
            string mes = dTP.Value.Month.ToString();

            List <string> _tasks = new List <string>();
            List <double> _times = new List <double>();

            foreach (DataTable tbl in PBData.Tables)
            {
                //checks if month is in selected day
                string[] s = tbl.TableName.Split(':');
                if (s.Length > 1)
                {
                    s = s[1].Split('-');
                }
                if (s.Length > 1 && s[1] == mes)
                {
                    //adds each task
                    foreach (DataRow r in tbl.Rows)
                    {
                        //position
                        int i = _tasks.IndexOf(r["colTask"].ToString());
                        if (i < 0)
                        {
                            i = _tasks.Count;
                            _tasks.Add(r["colTask"].ToString());
                            _times.Add(0);
                        }

                        //time count
                        _times[i] += (double)((int)r["colElapTimeInSeconds"]);
                    }
                }
            }

            Random rnd = new Random();
            //zedGraph Pie Chart

            DataTable t      = GetDateTbl();
            frmChart  frmBar = new frmChart();

            frmBar.itemsMenu.Visible = false;

            ZedGraph.GraphPane Pane = frmBar.zedGraph.GraphPane;

            //Titulos
            frmBar.Text = btnMonthEffort.Text + ": " + lblMonth.Text + " " +
                          System.Globalization.CultureInfo.CurrentCulture.DateTimeFormat.MonthNames[dTP.Value.Month - 1] + "/" + dTP.Value.Year.ToString();

            Pane.Title.Text          = frmBar.Text;
            Pane.Title.FontSpec.Size = 24f;
            //Pane.Title.FontSpec.IsItalic = true;

            Pane.Fill            = new ZedGraph.Fill(Color.White, Color.LightYellow, 45f);
            Pane.Chart.Fill.Type = ZedGraph.FillType.None;

            //fonte da legenda
            Pane.Legend.FontSpec.Size = 11f;

            Pane.BarSettings.Base = ZedGraph.BarBase.Y;

            //Bars
            double[] yy = new double[_tasks.Count];
            double[] xx = new double[_tasks.Count];
            for (int j = 0; j < _tasks.Count; j++)
            {
                yy[j] = (double)(j + 1);
                xx[j] = Math.Round(_times[j] / 3600, 2);
            }

            Color cor = Color.FromArgb(rnd.Next(240), rnd.Next(240), rnd.Next(240));

            ZedGraph.BarItem p = Pane.AddBar("", xx, yy, Color.White);
            p.Bar.Fill = new ZedGraph.Fill(cor, Color.White, cor);

            Pane.YAxis.Scale.TextLabels         = _tasks.ToArray();
            Pane.YAxis.Type                     = ZedGraph.AxisType.Text;
            Pane.YAxis.MajorTic.IsBetweenLabels = true;

            Pane.XAxis.Title.Text = lblTotalTH.Text;
            Pane.YAxis.Title.Text = lblTask.Text;

            frmBar.zedGraph.AxisChange();

            frmBar.Show();
        }
Exemple #2
0
        private void btnDaySummary_Click(object sender, EventArgs e)
        {
            Random    rnd = new Random();
            DataTable t   = GetDateTbl();

            if (t != null)
            {
                if (frmPie != null && !frmPie.IsDisposed)
                {
                    frmPie.Dispose();
                }

                frmPie = new frmChart();

                ZedGraph.GraphPane Pane = frmPie.zedGraph.GraphPane;

                //Titulos
                frmPie.Text              = lblTimeSpent.Text + ": " + lblDay.Text + " " + dTP.Value.Date.ToString().Split()[0];
                Pane.Title.Text          = frmPie.Text;
                Pane.Title.FontSpec.Size = 24f;
                //Pane.Title.FontSpec.IsItalic = true;

                Pane.Fill            = new ZedGraph.Fill(Color.White, Color.LightYellow, 45f);
                Pane.Chart.Fill.Type = ZedGraph.FillType.None;

                //fonte da legenda
                Pane.Legend.FontSpec.Size = 11f;

                //Slices
                int tempoTot = 0;
                foreach (DataRow r in t.Rows)
                {
                    int tempo = (int)r["colElapTimeInSeconds"];
                    tempoTot += tempo;
                    Color            cor = Color.FromArgb(rnd.Next(240), rnd.Next(240), rnd.Next(240));
                    ZedGraph.PieItem p   = Pane.AddPieSlice(Math.Round((double)tempo / 3600, 2), cor, Color.White, 45f, 0.1, r["colTask"].ToString());

                    //Menu pie slices removal feature
                    ToolStripMenuItem m = new ToolStripMenuItem(r["colTask"].ToString());
                    m.Checked = true;
                    frmPie.itemsMenu.DropDownItems.Add(m);
                    m.Click += new EventHandler(m_Click);
                    frmPie.vals.Add((double)tempo / 3600);
                }

                //Sets menu text
                frmPie.itemsMenu.Text = lblTask.Text;


                TimeSpan tsp = new TimeSpan(0, 0, tempoTot);

                //Total label
                txt = new ZedGraph.TextObj(lblTotTime.Text + "\n" + Math.Round(tsp.TotalHours, 2).ToString() + " h", 0.88f, 0.3f, ZedGraph.CoordType.PaneFraction);
                Pane.GraphObjList.Add(txt);
                txt.FontSpec.Fill = new ZedGraph.Fill(Color.White, Color.Yellow, 45f);
                //shadow
                ZedGraph.TextObj txt2 = new ZedGraph.TextObj(txt);
                txt2.FontSpec.Fill = new ZedGraph.Fill(Color.Black);
                txt2.Location.X   += 0.006f;
                txt2.Location.Y   += 0.008f;
                Pane.GraphObjList.Add(txt2);

                frmPie.zedGraph.AxisChange();

                frmPie.Show();
            }
        }
Exemple #3
0
        private void btnMonthSummary_Click(object sender, EventArgs e)
        {
            string mes = dTP.Value.Month.ToString();

            List <string> _tasks = new List <string>();
            List <double> _times = new List <double>();

            foreach (DataTable tbl in PBData.Tables)
            {
                //checks if month is in selected day
                string[] s = tbl.TableName.Split(':');
                if (s.Length > 1)
                {
                    s = s[1].Split('-');
                }
                if (s.Length > 1 && s[1] == mes)
                {
                    //adds each task
                    foreach (DataRow r in tbl.Rows)
                    {
                        //position
                        int i = _tasks.IndexOf(r["colTask"].ToString());
                        if (i < 0)
                        {
                            i = _tasks.Count;
                            _tasks.Add(r["colTask"].ToString());
                            _times.Add(0);
                        }

                        //time count
                        _times[i] += (double)((int)r["colElapTimeInSeconds"]);
                    }
                }
            }

            Random rnd = new Random();
            //zedGraph Pie Chart

            DataTable t = GetDateTbl();

            if (frmPie != null && !frmPie.IsDisposed)
            {
                frmPie.Dispose();
            }

            frmPie = new frmChart();

            ZedGraph.GraphPane Pane = frmPie.zedGraph.GraphPane;

            //Titulos
            frmPie.Text = lblTimeSpent.Text + ": " + lblMonth.Text + " " +
                          System.Globalization.CultureInfo.CurrentCulture.DateTimeFormat.MonthNames[dTP.Value.Month - 1] + "/" + dTP.Value.Year.ToString();

            Pane.Title.Text          = frmPie.Text;
            Pane.Title.FontSpec.Size = 24f;
            //Pane.Title.FontSpec.IsItalic = true;

            Pane.Fill            = new ZedGraph.Fill(Color.White, Color.LightYellow, 45f);
            Pane.Chart.Fill.Type = ZedGraph.FillType.None;

            //fonte da legenda
            Pane.Legend.FontSpec.Size = 11f;

            //Slices
            TimeSpan tspTot = new TimeSpan(0, 0, 0);

            for (int j = 0; j < _tasks.Count; j++)
            {
                TimeSpan tsp = new TimeSpan(0, 0, (int)_times[j]);
                tspTot += tsp;

                Color            cor = Color.FromArgb(rnd.Next(240), rnd.Next(240), rnd.Next(240));
                ZedGraph.PieItem p   = Pane.AddPieSlice(Math.Round(_times[j] / 3600, 2), cor, Color.White, 45f, 0.1, _tasks[j]);

                //Menu pie slices removal feature
                ToolStripMenuItem m = new ToolStripMenuItem(_tasks[j]);
                m.Checked = true;
                frmPie.itemsMenu.DropDownItems.Add(m);
                m.Click += new EventHandler(m_Click);
                frmPie.vals.Add(_times[j] / 3600);
            }
            //Sets menu text
            frmPie.itemsMenu.Text = lblTask.Text;

            //Total label
            txt = new ZedGraph.TextObj(lblTotTime.Text + "\n" + Math.Round(tspTot.TotalHours, 1).ToString() + " h", 0.9f, 0.17f, ZedGraph.CoordType.PaneFraction);
            Pane.GraphObjList.Add(txt);
            txt.FontSpec.Fill = new ZedGraph.Fill(Color.White, Color.Yellow, 45f);
            //shadow
            ZedGraph.TextObj txt2 = new ZedGraph.TextObj(txt);
            txt2.FontSpec.Fill = new ZedGraph.Fill(Color.Black);
            txt2.Location.X   += 0.006f;
            txt2.Location.Y   += 0.008f;
            Pane.GraphObjList.Add(txt2);

            frmPie.zedGraph.AxisChange();

            frmPie.Show();
        }