예제 #1
0
        private void Button_Click_Dodaj(object sender, RoutedEventArgs e)
        {
            if (ikonica.Source == null)
            {
                for (int i = 0; i < Tipovi.listaTipova.Count; i++)
                {
                    if (Tipovi.listaTipova[i].Oznaka.Equals(izaberiTip.Text))
                    {
                        ImageSourceConverter imgConv = new ImageSourceConverter();
                        string      path             = Tipovi.listaTipova[i].Slika;
                        ImageSource imageSource      = (ImageSource)imgConv.ConvertFromString(path);
                        ikonica.Source = imageSource;
                    }
                }
            }
            if (validate())
            {
                Dogadjaj dogadjaj = new Dogadjaj(oznaka.Text, ime.Text, opis.Text, izaberiTip.Text, posecenost.Text, ikonica.Source.ToString(), (bool)humanitarno.IsChecked, troskovi.Text, drzava.Text, grad.Text, istorija_datuma.Text, datum_odrzavanja.Text, izabraneEtikete);

                Dogadjaji.listaDogadjaja.Add(dogadjaj);

                oznaka.Text           = "";
                ime.Text              = "";
                opis.Text             = "";
                izaberiTip.Text       = "";
                posecenost.Text       = "";
                ikonica.Source        = null;
                humanitarno.IsChecked = false;
                troskovi.Text         = "";
                drzava.Text           = "";
                grad.Text             = "";
                istorija_datuma.Text  = "";
                datum_odrzavanja.Text = "";
                izaberiEtikete.SelectedItems.Clear();

                foreach (Tip t in Tipovi.listaTipova)
                {
                    t.DogadjajiTipa.Clear();
                    foreach (Dogadjaj s in Dogadjaji.listaDogadjaja)
                    {
                        if (s.Tip.Equals(t.Oznaka))
                        {
                            t.DogadjajiTipa.Add(s);
                            foreach (Ikonica mi in MainWindow.mapaIkonica)
                            {
                                if (mi.Do.Oznaka.Equals(s.Oznaka))
                                {
                                    t.DogadjajiTipa.Remove(s);
                                }
                            }
                        }
                    }
                }
            }
            else
            {
                System.Windows.MessageBox.Show("Popunite obavezna polja na ispravan nacin.");
            }
        }
예제 #2
0
        private void Button_Click_2(object sender, RoutedEventArgs e)
        {
            Dogadjaj dogadjaj = listaD.SelectedItem as Dogadjaj;

            if (dogadjaj != null)
            {
                listaDogadjaja.Remove(dogadjaj);
            }
            else
            {
                MessageBox.Show("Morate selektovati dogadjaj koji zelite da obrisete.");
            }
        }
예제 #3
0
        private void Button_Click_1(object sender, RoutedEventArgs e)
        {
            Dogadjaj dogadjaj = listaD.SelectedItem as Dogadjaj;

            if (dogadjaj != null)
            {
                // dogadjajIzmeni di = new dogadjajIzmeni(dogadjaj);
                // di.Show();
                DogadjajFrame.Content = new dogadjajIzmeni(dogadjaj);
            }
            else
            {
                MessageBox.Show("Morate selektovati dogadjaj koji zelite da izmenite.");
            }
        }
예제 #4
0
        private void canvasMapa_MouseMove(object sender, MouseEventArgs e)
        {
            Point  mousePos = e.GetPosition(canvasMapa);
            Vector diff     = start - mousePos;

            if (e.LeftButton == MouseButtonState.Pressed &&
                (Math.Abs(diff.X) > SystemParameters.MinimumHorizontalDragDistance ||
                 Math.Abs(diff.Y) > SystemParameters.MinimumVerticalDragDistance))
            {
                Dogadjaj d = razdaljina(start);

                if (d != null)
                {
                    DataObject dragData = new DataObject("myFormat", d);
                    DragDrop.DoDragDrop((DependencyObject)e.OriginalSource, dragData, DragDropEffects.Move);
                }
            }
        }
예제 #5
0
        public dogadjajDodaj()
        {
            //WindowStartupLocation = System.Windows.WindowStartupLocation.CenterScreen;
            InitializeComponent();

            d = new Dogadjaj();
            izabraneEtikete  = new ObservableCollection <Etiketa>();
            d.ListaEtiketa   = Etikete.listaEtiketa;
            listaE           = Etikete.listaEtiketa;
            this.DataContext = d;


            listaT.Clear();
            for (int i = 0; i < Tipovi.listaTipova.Count; i++)
            {
                listaT.Add(Tipovi.listaTipova[i].Oznaka);
            }
            izaberiTip.ItemsSource = listaT;
        }
예제 #6
0
        public Dogadjaji()
        {
            WindowStartupLocation = System.Windows.WindowStartupLocation.CenterScreen;

            InitializeComponent();

            listaD.ItemsSource = listaDogadjaja;
            Dogadjaj d = new Dogadjaj();

            d.ListaEtiketa   = Etikete.listaEtiketa;
            listaE           = Etikete.listaEtiketa;
            this.DataContext = d;
            View             = CollectionViewSource.GetDefaultView(listaD);

            listaT.Clear();
            for (int i = 0; i < Tipovi.listaTipova.Count; i++)
            {
                listaT.Add(Tipovi.listaTipova[i].Oznaka);
            }
            izaberiTip.ItemsSource = listaT;
        }
예제 #7
0
        private void Stablo_MouseMove(object sender, MouseEventArgs e)
        {
            Point  mousePos = e.GetPosition(null);
            Vector diff     = start - mousePos;

            if (e.LeftButton == MouseButtonState.Pressed &&
                (Math.Abs(diff.X) > SystemParameters.MinimumHorizontalDragDistance ||
                 Math.Abs(diff.Y) > SystemParameters.MinimumVerticalDragDistance))
            {
                TreeView     treeview     = sender as TreeView;
                TreeViewItem treeViewItem = FindAncestor <TreeViewItem>((DependencyObject)e.OriginalSource);

                if (treeview.SelectedItem is Dogadjaj)
                {
                    Dogadjaj d = (Dogadjaj)treeview.SelectedItem;

                    if (treeViewItem != null && d != null)        //inicijalizacija drag n dropa
                    {
                        DataObject dragData = new DataObject("myFormat", d);
                        DragDrop.DoDragDrop(treeViewItem, dragData, DragDropEffects.Move);
                    }
                }
            }
        }
예제 #8
0
        private void canvasMapa_Drop(object sender, DragEventArgs e)
        {
            if (e.Data.GetDataPresent("myFormat"))
            {
                Dogadjaj sp = e.Data.GetData("myFormat") as Dogadjaj;

                foreach (Tip t in Tipovi.listaTipova)
                {
                    foreach (Dogadjaj dog in t.DogadjajiTipa)
                    {
                        if (dog.Equals(sp))
                        {
                            t.DogadjajiTipa.Remove(dog);
                            break;
                        }
                    }
                }

                Image ikonica = new Image();
                ikonica.Height = 20;
                ikonica.Width  = 20;
                ikonica.Name   = sp.Oznaka;
                ImageSourceConverter imgConv = new ImageSourceConverter();
                string      path             = sp.Ikona;
                ImageSource imageSource      = (ImageSource)imgConv.ConvertFromString(path);
                ikonica.Source  = imageSource;
                ikonica.ToolTip = "Oznaka: " + sp.Oznaka + "\nIme: " + sp.Ime + "\nTip: " + sp.Tip;
                if (!promena)
                {
                    this.canvasMapa.Children.Add(ikonica);

                    Point p = e.GetPosition(this.canvasMapa);

                    Ikonica saCanvasa = new Ikonica(e.GetPosition(this.canvasMapa).X, e.GetPosition(this.canvasMapa).Y, sp);

                    if (CanDrop(e.GetPosition(this.canvasMapa).X, e.GetPosition(this.canvasMapa).Y, saCanvasa))
                    {
                        Canvas.SetLeft(ikonica, p.X);
                        Canvas.SetTop(ikonica, p.Y);

                        Ikonica icon = new Ikonica(p.X, p.Y, sp);
                        mapaIkonica.Add(icon);
                    }
                    else
                    {
                        foreach (Tip t in Tipovi.listaTipova)
                        {
                            if (t.Oznaka.Equals(sp.Tip))
                            {
                                t.DogadjajiTipa.Add(sp);
                            }
                        }

                        this.canvasMapa.Children.Remove(ikonica);
                        MessageBox.Show("Izaberite drugu lokaciju.");
                    }
                }
                else
                {
                    Point p = e.GetPosition(this.canvasMapa);
                    for (int i = 0; i < mapaIkonica.Count; i++)
                    {
                        if (mapaIkonica[i].Do.Oznaka.Equals(sp.Oznaka))
                        {
                            Ikonica saCanvasa = mapaIkonica[i];
                            canvasMapa.Children.RemoveAt(i);
                            canvasMapa.Children.Insert(i, ikonica);

                            int flagg = 0;
                            if (!CanDrop(e.GetPosition(this.canvasMapa).X, e.GetPosition(this.canvasMapa).Y, saCanvasa))
                            {
                                p.X   = saCanvasa.X;
                                p.Y   = saCanvasa.Y;
                                flagg = 1;
                            }

                            Canvas.SetLeft(ikonica, p.X);
                            Canvas.SetTop(ikonica, p.Y);

                            mapaIkonica[i].X = p.X;
                            mapaIkonica[i].Y = p.Y;


                            if (flagg == 1)
                            {
                                MessageBox.Show("Izaberite drugu lokaciju.");
                            }

                            break;
                        }
                    }
                }
            }
        }
예제 #9
0
파일: Ikonica.cs 프로젝트: andrearakic/HCI
 public Ikonica(double x, double y, Dogadjaj d)
 {
     this.x = x;
     this.y = y;
     this.d = d;
 }