private void Root2_MouseMove(object sender, MouseEventArgs e) { Point mousePos = e.GetPosition(null); Vector diff = startPoint - mousePos; e.Handled = true; if (e.LeftButton == MouseButtonState.Pressed && (Math.Abs(diff.X) > SystemParameters.MinimumHorizontalDragDistance || Math.Abs(diff.Y) > SystemParameters.MinimumVerticalDragDistance)) { // Get the dragged ListViewItem ItemsControl itemControl = sender as ItemsControl; MonumentRow itemControlItem1 = Map.FindAncestor <MonumentRow>((DependencyObject)e.OriginalSource); Monument monument; if (itemControlItem1 == null) { MonumentRowDetail itemControlItem2 = Map.FindAncestor <MonumentRowDetail>((DependencyObject)e.OriginalSource); monument = (Monument)itemControlItem2.DataContext; } else { monument = (Monument)itemControlItem1.DataContext; } // Find the data behind the ListViewItem // Initialize the drag & drop operation DataObject dragData = new DataObject("myFormat", monument); DragDrop.DoDragDrop((DependencyObject)e.OriginalSource, dragData, DragDropEffects.Move); } }
public void monumentClicked(int id) { this.UpdateLayout(); MonumentRow myMonumentUC = null; MonumentRowDetail myMonumentDUC = null; foreach (MonumentRow tb in FindVisualChildren <MonumentRow>(RootWoot)) { tb.Visibility = Visibility.Visible; if (tb.Tag.Equals(id)) { myMonumentUC = tb; } else { this.EnlargenedMonuments.Remove(tb.MonumentId); } } foreach (MonumentRowDetail tb in FindVisualChildren <MonumentRowDetail>(RootWoot)) { tb.Visibility = Visibility.Collapsed; if (tb.Tag.Equals(id)) { myMonumentDUC = tb; } else { this.EnlargenedMonuments.Remove(tb.MonumentId); } } if (myMonumentUC != null && myMonumentDUC != null) { if (this.EnlargenedMonuments.IndexOf(id) == -1) { myMonumentUC.Visibility = Visibility.Collapsed; myMonumentDUC.Visibility = Visibility.Visible; this.EnlargenedMonuments.Add(id); } else { myMonumentDUC.Visibility = Visibility.Collapsed; myMonumentUC.Visibility = Visibility.Visible; this.EnlargenedMonuments.Remove(id); } MonumentSelectionChangedCallback(); } }
public static void MonumentDemon(MainContent mainContent) { while (true) { System.Windows.Point absolutePos = new System.Windows.Point(0, 0); absolutePos = getElementPos(mainContent.MonumentTable.AddMonumentButton); MoveCursorSlowly((int)absolutePos.X + 10, (int)absolutePos.Y + 5); //uvek koristi ovo da bi otvarao dijaloge, nemoj ni slucajno ono moje cudo clickButton MouseEvent(MouseEventFlags.LeftDown); MouseEvent(MouseEventFlags.LeftUp); //Thread sleep da bi dijalog stigao da se inicijalizuje Thread.Sleep(1000); AddMonumentFormDemon(mainContent.AddMonumentDemonDialog); //ova logika pronalazi monument koji treba da se edituje Thread.Sleep(1000); mainContent.MonumentTable.FindVisualChildren <MonumentRowDetail>(mainContent.MonumentTable.RootWoot); List <MonumentRowDetail> myList = new List <MonumentRowDetail>(); bool done = false; MonumentRowDetail rowDetail = null; mainContent.MonumentTable.Dispatcher.Invoke(() => { foreach (MonumentRowDetail m in mainContent.MonumentTable.FindVisualChildren <MonumentRowDetail>(mainContent.MonumentTable.RootWoot)) { if (m.Tag.Equals(mainContent.MonumentTable.EnlargenedMonuments.SingleOrDefault())) { rowDetail = m; absolutePos = getElementPos(m.EditButton); done = true; } } }); while (!done) { } //nakon sto ga nadjemo kliknemo ga MoveCursorSlowly((int)absolutePos.X + 10, (int)absolutePos.Y + 5); MouseEvent(MouseEventFlags.LeftDown); MouseEvent(MouseEventFlags.LeftUp); //Thread sleep da bi dijalog stigao da se inicijalizuje Thread.Sleep(1000); EditMonumentFormDemon(mainContent.EditMonumentDemonDialog); Thread.Sleep(1000); rowDetail = null; done = false; mainContent.MonumentTable.Dispatcher.Invoke(() => { foreach (MonumentRowDetail m in mainContent.MonumentTable.FindVisualChildren <MonumentRowDetail>(mainContent.MonumentTable.RootWoot)) { if (m.Tag.Equals(mainContent.MonumentTable.EnlargenedMonuments.SingleOrDefault())) { rowDetail = m; done = true; } } }); while (!done) { } //ovo bi radilo vrv ukoliko bi rowDetail bio dobar absolutePos = getElementPos(rowDetail.DeleteBtn); MoveCursorSlowly((int)absolutePos.X + 10, (int)absolutePos.Y + 5); MouseEvent(MouseEventFlags.LeftDown); MouseEvent(MouseEventFlags.LeftUp); Thread.Sleep(1000); System.Windows.Forms.SendKeys.SendWait("{ENTER}"); } }