void bt2_Click(object sender, RoutedEventArgs e) { if (!(main.Children.Contains(cBox))) { PointF globalPt = new PointF(thisCont.ObjectTouches.MoveCenter.X, thisCont.ObjectTouches.MoveCenter.Y); cBox = new ContactsBox(); main.Children.Add(cBox); cBoxProp.ElementSupport.AddSupportForAll(); cBoxCont = new MTSmoothContainer(cBox, main, cBoxProp); cBoxCont.SetPosition(globalPt.X, globalPt.Y, gridRotateTrans.Angle, 1.0); framework.RegisterElement(cBoxCont); cBox.setInit(main, window, framework, cBoxCont, gridRotateTrans.Angle, userIP); } else { main.Children.Remove(cBox); framework.UnregisterElement(cBoxCont.Id); cBoxCont.isRemoved = true; } }
public override void Drag(float x, float y) { //Console.WriteLine("Drag"); ContactsBox s = Source as ContactsBox; if (s == null) { return; } state = 0; sendIP = ""; PointIn ptIn = new PointIn(); PointF pt = s.thisCont.ObjectTouches.MoveCenter; double ang = s.thisAngle + s.thisCont.RotateFilter.Target; foreach (SmartArea a in SingleToneTrans.getInstance().smartAreaList) { if (ptIn.setPtinRect(s.window, a, pt, ang)) { state = 1; sendIP = a.userIP; break; } else { sendIP = ""; state = 0; } } s.Item_TouchMove(pt, state); base.Drag(x, y); }
int findSelectedItem(ContactsBox s, PointF p) { PointIn ptIn = new PointIn(); PointF pt = s.thisCont.ObjectTouches.MoveCenter; double ang = s.thisAngle + s.thisCont.RotateFilter.Target; ScrollViewer scroll = s.ContactslistBox.FindChild <ScrollViewer>() as ScrollViewer; for (int i = 0; i < s.contactsObjList.Count; i++) { if (ptIn.setPtinRect(s.window, s.contactsObjList.ElementAt(i), pt, ang)) { return(i); } } return(-1); }
public override void TouchUp(PointF p) { //Console.WriteLine("touchUp"); ContactsBox s = Source as ContactsBox; if (s == null) { return; } PointIn ptIn = new PointIn(); PointF pt = s.thisCont.ObjectTouches.MoveCenter; double ang = s.thisAngle + s.thisCont.RotateFilter.Target; s.Item_TouchUp(p, sendIP); base.TouchUp(p); }
public override void TouchDown(PointF p) { //Console.WriteLine("touchDown"); ContactsBox s = Source as ContactsBox; if (s == null) { return; } PointIn ptIn = new PointIn(); PointF pt = s.thisCont.ObjectTouches.MoveCenter; double ang = s.thisAngle + s.thisCont.RotateFilter.Target; if (ptIn.setPtinRect(s.window, s.ContactslistBox, pt, ang)) { isListBox = true; s.thisCont.IsScrollView = true; index = findSelectedItem(s, new PointF(p.X, p.Y)); if (index != -1) { if (ptIn.setPtinRect(s.window, s.contactsObjList.ElementAt(index).bt_img, pt, ang)) { IsSelecting = true; s.Item_TouchDown(p, s.contactsObjList.ElementAt(index)); } else { IsSelecting = false; } } } else { s.thisCont.IsScrollView = false; isListBox = false; IsSelecting = false; } base.TouchDown(p); }
public override void Tap(PointF p) { //Console.WriteLine("Tab"); ContactsBox s = Source as ContactsBox; if (s == null) { return; } RoutedEventArgs e = new RoutedEventArgs(); e.RoutedEvent = Button.ClickEvent; PointIn ptIn = new PointIn(); PointF pt = s.thisCont.ObjectTouches.MoveCenter; double ang = s.thisAngle + s.thisCont.RotateFilter.Target; if (ptIn.setPtinRect(s.window, s.bt_close, pt, ang)) { s.bt_close_Click(); } base.Tap(p); }
/// <summary> /// Checks if the element has a scroll viewer. It it does, uses the scroll viewer /// to scroll the content by the number of pixels moved. /// X and Y are inverted so that the scroll works like the iPhone (i.e. the touched /// item sticks to your finger). Works better without scrollbars shown. /// </summary> /// <param name="x">Change in the horizontal object relative movement center in pixels</param> /// <param name="y">Change in the vertical object relative movement center in pixels</param> public virtual void Scroll(float x, float y) { if (Source is FileBox3) { FileBox3 s = Source as FileBox3; if (isListBox == true) { // This sets it so that we scroll by pixels rather than by lines if (ScrollViewer.GetCanContentScroll(s.itemListBox)) { ScrollViewer.SetCanContentScroll(s.itemListBox, false); } // Find the scrollviewer and scroll it if there is one ScrollViewer scroll = s.itemListBox.FindChild <ScrollViewer>() as ScrollViewer; if (scroll != null) { scroll.ScrollToHorizontalOffset(scroll.HorizontalOffset + (x * -1)); scroll.ScrollToVerticalOffset(scroll.VerticalOffset + (y * -1)); } s.itemListBox.RaiseEvent(new RoutedEventArgs(MTEvents.ScrollEvent, Source)); } } else if (Source is DocViewer) { DocViewer s = Source as DocViewer; if (isDocViewer == true) { // This sets it so that we scroll by pixels rather than by lines if (ScrollViewer.GetCanContentScroll(s.documentviewWord)) { ScrollViewer.SetCanContentScroll(s.documentviewWord, false); } // Find the scrollviewer and scroll it if there is one ScrollViewer scroll = s.documentviewWord.FindChild <ScrollViewer>() as ScrollViewer; if (scroll != null) { scroll.ScrollToHorizontalOffset(scroll.HorizontalOffset + (x * -1)); scroll.ScrollToVerticalOffset(scroll.VerticalOffset + (y * -1)); } s.documentviewWord.RaiseEvent(new RoutedEventArgs(MTEvents.ScrollEvent, Source)); } } else if (Source is ContactsBox) { ContactsBox s = Source as ContactsBox; if (isListBox == true) { // This sets it so that we scroll by pixels rather than by lines if (ScrollViewer.GetCanContentScroll(s.ContactslistBox)) { ScrollViewer.SetCanContentScroll(s.ContactslistBox, false); } // Find the scrollviewer and scroll it if there is one ScrollViewer scroll = s.ContactslistBox.FindChild <ScrollViewer>() as ScrollViewer; if (scroll != null) { scroll.ScrollToHorizontalOffset(scroll.HorizontalOffset + (x * -1)); scroll.ScrollToVerticalOffset(scroll.VerticalOffset + (y * -1)); } s.ContactslistBox.RaiseEvent(new RoutedEventArgs(MTEvents.ScrollEvent, Source)); } } else {// This sets it so that we scroll by pixels rather than by lines if (ScrollViewer.GetCanContentScroll(Source)) { ScrollViewer.SetCanContentScroll(Source, false); } // Find the scrollviewer and scroll it if there is one ScrollViewer scroll = Source.FindChild <ScrollViewer>() as ScrollViewer; if (scroll != null) { scroll.ScrollToHorizontalOffset(scroll.HorizontalOffset + (x * -1)); scroll.ScrollToVerticalOffset(scroll.VerticalOffset + (y * -1)); } Source.RaiseEvent(new RoutedEventArgs(MTEvents.ScrollEvent, Source)); } }