private void listBox_SelectionChanged(object sender, SelectionChangedEventArgs e)
 {
     if (!dragging)
     {
         dragging    = true;
         draggedItem = (Putevi)listBox.SelectedItem;
         DragDrop.DoDragDrop(this, draggedItem, DragDropEffects.Copy | DragDropEffects.Move);
     }
 }
Пример #2
0
        private void button_dodaj_Click(object sender, RoutedEventArgs e)
        {
            if (validate())
            {
                Putevi novi_put;

                novi_put = new Putevi(Int32.Parse(textBox_id.Text), textBox_naziv.Text.ToUpper(), comboBox_tip.Text, 0);
                MainWindow.Putevi.Add(novi_put);

                this.Close();
            }
            else
            {
                MessageBox.Show("Podaci nisu dobro popunjeni", "Greska!", MessageBoxButton.OK, MessageBoxImage.Error);
            }
        }
        private void Grafikon_Refresh()
        {
            // Ako je ComboBox selektovan
            if (ComboBox_Grafikon.SelectedItem == null)
            {
                return;
            }


            //Obrisi sve elemente
            if (qGraph.Count != 0)
            {
                qGraph.Clear();
            }

            int i = 0;

            // Ucitaj poslednja 38 reda
            // iz fajla
            foreach (string line in File.ReadLines("Log.txt").Reverse())
            {
                String   substring = line.Substring(25, line.Length - 25);
                string[] obj       = substring.Split(new char[] { '_', ':' });

                string qBoja = "Blue";

                string vreme = null;

                if (obj.Length == 3)
                {
                    if (Putevi.Count > Int32.Parse(obj[1]))
                    {
                        if (Putevi[Int32.Parse(obj[1])].ID == ((Putevi)ComboBox_Grafikon.SelectedItem).ID)
                        {
                            vreme = line.Substring(0, 24);

                            if (Putevi[Int32.Parse(obj[1])].Tip == "Tip - IB")
                            {
                                if (Int32.Parse(obj[2]) > 7000)
                                {
                                    qBoja = "Red";
                                }
                            }
                            else
                            {
                                if (Int32.Parse(obj[2]) > 15000)
                                {
                                    qBoja = "Red";
                                }
                            }

                            Double koef = 350.0 / 19000.0 * Int32.Parse(obj[2]);

                            Putevi qput = Putevi[Int32.Parse(obj[1])];
                            qGraph.Add(new Grafikon(i, qBoja, (int)koef, qput.ID, qput.Naziv, qput.Tip, Int32.Parse(obj[2]), vreme));
                            i++;
                        }
                    }

                    if (i > 38)
                    {
                        break;
                    }
                }
            }

            listgrafikon.Items.Refresh();
        }