Beispiel #1
0
 private void button1_Click(object sender, EventArgs e)
 {
     DialogResult = DialogResult.OK;
     selectedUser = users.FirstOrDefault(u => u.Name == textBox1.Text);
     if (selectedUser == null)
     {
         selectedUser = new User() { Name = textBox1.Text, Password = GetHash(textBox2.Text) };
         linqtsql.Model.Context.Users.InsertOnSubmit(selectedUser);
         linqtsql.Model.Context.SubmitChanges();
         Settings.Default.saveUP = checkBox2.Checked;
         if (checkBox2.Checked)
         {
             Settings.Default.User = textBox1.Text;
             Settings.Default.PWD = textBox2.Text;
         }
         Settings.Default.Save();
         Close();
     }
     else
     {
         if (selectedUser.Password == GetHash(textBox2.Text))
         {
             Settings.Default.saveUP = checkBox2.Checked;
             if (checkBox2.Checked)
             {
                 Settings.Default.User = textBox1.Text;
                 Settings.Default.PWD = textBox2.Text;
             }
             Settings.Default.Save();
             Close();
         }
         else
         {
             MessageBox.Show("Такий користувач вже є!");
         }
     }
 }
 partial void DeleteUser(User instance);
 partial void UpdateUser(User instance);
 partial void InsertUser(User instance);
Beispiel #5
0
 public Form1(User user)
 {
     InitializeComponent();
     FormClosing += new FormClosingEventHandler(Form1_FormClosing);
     currentUser = user;
 }
Beispiel #6
0
 public ChartForm(User user)
 {
     InitializeComponent();
     current = user;
 }
Beispiel #7
0
        private void pictureBox1_Paint(object sender, PaintEventArgs e)
        {
            Graphics g = e.Graphics;
            System.Diagnostics.Stopwatch watch = System.Diagnostics.Stopwatch.StartNew();

            g.CompositingQuality = System.Drawing.Drawing2D.CompositingQuality.HighQuality;

            if (selected != null)
            {

                int daycount;
                float dayW;
                float zoom = (canvas.Height) / (maxVal - minVal);
                float avgSpeed = 0;
                int n = 0;
                if (everything)
                {

                    foreach (var item in selected)
                    {
                        PointF[] points;
                        if (avgSpeed_RB.Checked)
                            points = GetPointsAverage(item, minVal, maxVal);
                        else if (speed_RB.Checked)
                            points = GetPointsNormal(item, minVal, maxVal, out avgSpeed);
                        else
                            points = GetDistance(item, maxVal);

                        if (points.Length == 1)
                            g.DrawLine(pens[n], points[0].X, points[0].Y, canvas.Width - legendWidth, points[0].Y);
                        else
                            g.DrawLines(pens[n], points);

                        if (speed_RB.Checked && avg_CB.Checked)
                            g.DrawLine(new Pen(pens[n].Color, 2) { DashStyle = System.Drawing.Drawing2D.DashStyle.DashDot }, 0, avgSpeed, canvas.Width - legendWidth, avgSpeed);

                        if (dots_CB.Checked)
                            for (int i = 0; i < points.Length; i++)
                                g.FillEllipse(new SolidBrush(Color.FromKnownColor(kcolors[n])), points[i].X - 2.5f, points[i].Y - 2.5f, 5, 5);
                        n++;
                    }

                    DateTime current;
                    if (!GlobalStats)
                        current = runs[0].Date;
                    else
                        current = new DateTime(2010, 1, 1);

                    g.DrawString(current.Day.ToString().PadLeft(2, '0') + "." + current.Month.ToString().PadLeft(2, '0'), font, Brushes.Black, 2, canvas.Height - 20);

                    double d6;
                    if (!GlobalStats)
                        d6 = (runs[runs.Count - 1].Date - current).TotalDays / 30;
                    else
                        d6 = 364 / 30f;

                    dayW = (canvas.Width - legendWidth) / 30.0f;

                    current = current.AddDays(d6 * 5);

                    for (int i = 5; i <= 30; i += 5)
                    {
                        g.DrawLine(Pens.Gray, i * dayW, 0, i * dayW, canvas.Height);
                        g.DrawString(current.Day.ToString().PadLeft(2, '0') + "." + current.Month.ToString().PadLeft(2, '0'), font, Brushes.Black, i * dayW - 20, canvas.Height - 20);
                        current = current.AddDays(d6 * 5);
                    }

                }
                else
                {
                    daycount = 31;
                    dayW = ((float)canvas.Width - legendWidth) / daycount;
                    foreach (var runCollection in selected)
                    {
                        if (runCollection.Count > 0)
                        {
                            PointF[] points;
                            if (avgSpeed_RB.Checked)
                                points = GetPointsAverage(runCollection, minVal, maxVal);
                            else if (speed_RB.Checked)
                                points = GetPointsNormal(runCollection, minVal, maxVal, out avgSpeed);
                            else
                                points = GetDistance(runCollection, maxVal);

                            if (points.Length == 1)
                                g.DrawLine(pens[monthes_LB.SelectedIndices[n]], points[0].X, points[0].Y, canvas.Width - legendWidth, points[0].Y);
                            else
                            {
                                g.DrawLines(pens[monthes_LB.SelectedIndices[n]], points);
                                if (speed_RB.Checked && avg_CB.Checked)
                                {
                                    g.DrawLine(new Pen(pens[monthes_LB.SelectedIndices[n]].Color, 2) { DashStyle = System.Drawing.Drawing2D.DashStyle.DashDot }, 0, avgSpeed, canvas.Width - legendWidth, avgSpeed);
                                }
                            }

                            if (dots_CB.Checked)
                                for (int i = 0; i < points.Length; i++)
                                    g.FillEllipse(new SolidBrush(Color.FromKnownColor(kcolors[monthes_LB.SelectedIndices[n]])), points[i].X - 3, points[i].Y - 3, 6, 6);
                        }
                        n++;
                    }

                    g.DrawString("0", font, Brushes.Black, 2, canvas.Height - 20);

                    for (int i = 5; i <= 30; i += 5)
                    {
                        g.DrawLine(Pens.Gray, i * dayW, 0, i * dayW, canvas.Height);
                        g.DrawString(i.ToString(), font, Brushes.Black, i * dayW - 6, canvas.Height - 20);
                    }
                }

                int lb = (int)Math.Floor(minVal);
                int ub = (int)Math.Ceiling(maxVal);
                if (!distance_RB.Checked)
                {

                    for (int i = lb + 1; i <= ub; i++)
                    {
                        float y = canvas.Height - (i - minVal) * zoom;
                        g.DrawLine(Pens.Gray, 0, y, canvas.Width - legendWidth, y);
                        g.DrawString(i.ToString(), font, Brushes.Black, 3, y - 25);
                        y = canvas.Height - (i - 0.5f - minVal) * zoom;
                        g.DrawLine(Pens.Gray, 0, y, canvas.Width - legendWidth, y);
                        g.DrawString((i - 0.5).ToString("F1"), font, Brushes.Black, 3, y - 25);
                    }
                }
                else
                {
                    int dd = 3;
                    while ((ub - minVal) / dd > 18)
                        dd *= 2;

                    for (int i = 0; i <= ub; i += dd)
                    {
                        float y = canvas.Height - (i - minVal) * zoom;
                        g.DrawLine(Pens.Gray, 0, y, canvas.Width - legendWidth, y);
                        g.DrawString(i.ToString(), font, Brushes.Black, 3, y);
                    }
                }

                g.DrawRectangle(new Pen(Color.Black, 2), 1, 1, canvas.Width - legendWidth - 2, canvas.Height - 2);
                g.DrawRectangle(new Pen(Color.Black, 2), canvas.Width - legendWidth - 1, 1, legendWidth, canvas.Height - 2);

                int lineWidth = 18;
                int perLine = 16;
                int upperOffset = 30;

                if (everything)
                {
                    g.DrawLine(pens[0], canvas.Width - legendWidth + 4, upperOffset, canvas.Width - legendWidth + lineWidth + 4, upperOffset);
                    for (int i = 0; i < selected.Count; i++)
                    {
                        int y = upperOffset + perLine * i;
                        g.DrawLine(pens[i], canvas.Width - legendWidth + 4, y, canvas.Width - legendWidth + lineWidth + 4, y);
                        g.DrawString(selected[i][0].Date.Year.ToString(), font, Brushes.Black, canvas.Width - legendWidth + lineWidth + 9, y - 9);
                    }

                    //g.DrawString("Усі", font, Brushes.Black, pictureBox1.Width - legendWidth + lineWidth + 9, upperOffset - 9);
                }
                else
                {
                    for (int i = 0; i < selected.Count; i++)
                    {
                        int y = upperOffset + perLine * i;
                        g.DrawLine(pens[monthes_LB.SelectedIndices[i]], canvas.Width - legendWidth + 4, y, canvas.Width - legendWidth + lineWidth + 4, y);
                        g.DrawString(monthes_LB.SelectedItems[i].ToString(), font, Brushes.Black, canvas.Width - legendWidth + lineWidth + 9, y - 9);
                    }
                }
            }

            double result = watch.ElapsedTicks / (double)System.Diagnostics.Stopwatch.Frequency;
            Text = result.ToString();
        }