private void ListView_Drop2(object sender, DragEventArgs e) { if (list == 2) { if (e.Data.GetDataPresent("myFormat")) { Model.Softver soft = e.Data.GetData("myFormat") as Model.Softver; if (SaveList2 == null) { SaveList2 = new List <Softver>(); foreach (Softver s in List2) { if (s != null) { SaveList2.Add(s); } } } List2.Remove(soft); List1.Add(soft); SaveList2.Remove(soft); /* SaveList2 = new List<Softver>(); * foreach (Softver s in List2) * if (s != null) * SaveList2.Add(s); * Search = ""; * just_do_it();*/ } } }
private void ListView_MouseMove(object sender, MouseEventArgs e) { Point mousePos = e.GetPosition(null); Vector diff = startPoint - mousePos; if (e.LeftButton == MouseButtonState.Pressed && (Math.Abs(diff.X) > SystemParameters.MinimumHorizontalDragDistance || Math.Abs(diff.Y) > SystemParameters.MinimumVerticalDragDistance)) { // Get the dragged ListViewItem ListView listView = sender as ListView; ListViewItem listViewItem = FindAncestor <ListViewItem>((DependencyObject)e.OriginalSource); if (listViewItem == null) { return; } // Find the data behind the ListViewItem Model.Softver student = (Model.Softver)listView.ItemContainerGenerator. ItemFromContainer(listViewItem); // Initialize the drag & drop operation DataObject dragData = new DataObject("myFormat", student); DragDrop.DoDragDrop(listViewItem, dragData, DragDropEffects.Move); } }
private void ListView_Drop(object sender, DragEventArgs e) { if (list == 1) { if (e.Data.GetDataPresent("myFormat")) { Model.Softver soft = e.Data.GetData("myFormat") as Model.Softver; List1.Remove(soft); List2.Add(soft); //SaveList2.Add(soft); } } }
List <Softver> otvoriSoftver(String fileName) { List <Softver> softveri = new List <Softver>(); FileStream f = new FileStream("../../Save/softver.txt", FileMode.OpenOrCreate); f.Close(); RegexOptions options = RegexOptions.None; Regex regex = new Regex("[\r\n]{3,}", options); string recentText = File.ReadAllText("../../Save/softver.txt"); string[] tekst = recentText.Split('\n'); foreach (string softver in tekst) { Model.Softver s = new Model.Softver(); if (softver == "") { return(softveri); } string[] sf = softver.Split('|'); s.Oznaka = sf[0]; s.Naziv = sf[1]; s.Cena = Convert.ToDouble(sf[2]); s.GodinaIzdavanja = Convert.ToInt32(sf[3]); s.Sistem = sf[4]; s.Opis = sf[5]; s.Proizvodjac = sf[6]; s.File = sf[7]; s.Sajt = sf[8].Trim(); if (s.File == fileName) { softveri.Add(s); } } return(softveri); }