Exemple #1
0
 private void button2_Click(object sender, EventArgs e)
 {
     if (textBox1.Text != "")
     {
         route = new Route();
         float length;
         if (!float.TryParse(textBox2.Text.Replace('.', ','), out length))
         {
             MessageBox.Show("Потрібно ввести нормальну довжину маршруту!");
             return;
         }
         route.Name = textBox1.Text;
         if (!Model.Context.Routes.Any(r => r.Name == textBox1.Text))
         {
             route.Length = length;
             if (image != null)
                 route.Image = new System.Data.Linq.Binary(image);
             Model.Context.Routes.InsertOnSubmit(route);
             Model.Context.SubmitChanges();
             DialogResult = DialogResult.OK;
             Close();
         }
         else
         {
             MessageBox.Show("Маршрут з таким іменем вже існує!");
         }
     }
     else
     {
         MessageBox.Show("Потрібно ввести назву маршруту!");
     }
 }
 partial void DeleteRoute(Route instance);
 partial void UpdateRoute(Route instance);
 partial void InsertRoute(Route instance);
Exemple #5
0
        private void LoadPicture(Route r)
        {
            if (imageCache.ContainsKey(r.Name))
            {
                image = imageCache[r.Name];
            }
            else if (r.Image != null)
            {
                image = (Image)convertor.ConvertFrom(r.Image.ToArray());
                imageCache.Add(r.Name, image);
            }

            if (image != null)
            {
                hb = image.Width > pictureBox1.Width;
                vb = image.Height > pictureBox1.Height;
                if (hb)
                {
                    if (vb)
                        imageOffset = Point.Empty;
                    else
                        imageOffset = new Point(0, (pictureBox1.Height - image.Height) / 2);
                }
                else if (vb)
                {
                    imageOffset = new Point((pictureBox1.Width - image.Width) / 2, 0);
                }
                else
                {
                    imageOffset = new Point((pictureBox1.Width - image.Width) / 2, (pictureBox1.Height - image.Height) / 2);
                }
            }
            else
            {
                imageOffset = Point.Empty;
            }
        }
Exemple #6
0
        private void comboBox1_SelectedIndexChanged(object sender, EventArgs e)
        {
            if (comboBox1.SelectedIndex >= 0)
            {

                System.Diagnostics.Stopwatch watch = System.Diagnostics.Stopwatch.StartNew();

                //  Route r = Model.Context.Routes.First(rt => rt.Name == comboBox1.SelectedItem.ToString());
                Route r = d_routes[comboBox1.SelectedItem.ToString()];
                selectedRoute = r;
                double result = watch.ElapsedTicks / (double)System.Diagnostics.Stopwatch.Frequency;

                LoadPicture(selectedRoute);

                label2.Text = "Довжина  " + r.Length.ToString("F3") + " км";

                RefreshGrid();

                pictureBox1.Invalidate();
            }
        }