Beispiel #1
0
        public ReaderViewBase()
        {
            this.DefaultStyleKey = typeof(ReaderViewBase);

            _gestureRecognizer = new GestureRecognizer();
            _gestureRecognizer.GestureSettings        = GestureSettings.ManipulationTranslateX;
            _gestureRecognizer.ManipulationStarted   += _gestureRecognizer_ManipulationStarted;
            _gestureRecognizer.ManipulationUpdated   += _gestureRecognizer_ManipulationUpdated;
            _gestureRecognizer.ManipulationCompleted += _gestureRecognizer_ManipulationCompleted;

            PointerWheelChangedEventHandler = new PointerEventHandler(_PointerWheelChanged);
            PointerPressedEventHandler      = new PointerEventHandler(_PointerPressed);
            PointerMovedEventHandler        = new PointerEventHandler(_PointerMoved);
            PointerReleasedEventHandler     = new PointerEventHandler(_PointerReleased);
            PointerCanceledEventHandler     = new PointerEventHandler(_PointerCanceled);
            TouchTappedEventHandler         = new TappedEventHandler(_TouchTapped);
            TouchHoldingEventHandler        = new HoldingEventHandler(_TouchHolding);

            this.AddHandler(UIElement.PointerWheelChangedEvent, PointerWheelChangedEventHandler, true);
            this.AddHandler(UIElement.PointerPressedEvent, PointerPressedEventHandler, true);
            this.AddHandler(UIElement.PointerMovedEvent, PointerMovedEventHandler, true);
            this.AddHandler(UIElement.PointerReleasedEvent, PointerReleasedEventHandler, true);
            this.AddHandler(UIElement.PointerCanceledEvent, PointerCanceledEventHandler, true);
            this.AddHandler(UIElement.TappedEvent, TouchTappedEventHandler, true);
            this.AddHandler(UIElement.HoldingEvent, TouchHoldingEventHandler, true);
            this.SizeChanged += ReaderViewBase_SizeChanged;

            CreateContentDelayer = new EventDelayer();
            _tempOverflowList    = new List <RenderOverflow>();
            CreateContentDelayer.ResetWhenDelayed = true;
            CreateContentDelayer.Arrived         += CreateContentWaiter_Arrived;
        }
Beispiel #2
0
 public TwoArgumentsEventHandlerController(Action <object, object> assertionHandler)
 {
     tappedHandler             = (s, e) => assertionHandler(s, e);
     loadedHandler             = (s, e) => assertionHandler(s, e);
     changedHandler            = (s, e) => assertionHandler(s, e);
     dataContextChangedHandler = (s, e) => assertionHandler(s, e);
 }
        public PointersEvents()
        {
            _logPointerPressed = new PointerEventHandler((snd, e) =>
            {
                CreateHandler(PointerPressedEvent, "Pressed", _ptPressedHandle)(snd, e);
                if (_ptPressedCapture.IsChecked ?? false)
                {
                    ((UIElement)snd).CapturePointer(e.Pointer);
                }
            });

            this.InitializeComponent();

            _logPointerEntered        = new PointerEventHandler(CreateHandler(PointerEnteredEvent, "Entered", _ptEnteredHandle));
            _logPointerMoved          = new PointerEventHandler(CreateHandler(PointerMovedEvent, "Moved", _ptMovedHandle));
            _logPointerReleased       = new PointerEventHandler(CreateHandler(PointerReleasedEvent, "Released", _ptReleasedHandle));
            _logPointerExited         = new PointerEventHandler(CreateHandler(PointerExitedEvent, "Exited", _ptExitedHandle));
            _logPointerCanceled       = new PointerEventHandler(CreateHandler(PointerCanceledEvent, "Canceled", _ptCanceledHandle));
            _logPointerCaptureLost    = new PointerEventHandler(CreateHandler(PointerCaptureLostEvent, "CaptureLost", _ptCaptureLostHandle));
            _logManipulationStarting  = new ManipulationStartingEventHandler(CreateHandler(ManipulationStartingEvent, "Manip starting", _manipStartingHandle));
            _logManipulationStarted   = new ManipulationStartedEventHandler(CreateHandler(ManipulationStartedEvent, "Manip started", _manipStartedHandle));
            _logManipulationDelta     = new ManipulationDeltaEventHandler(CreateHandler(ManipulationDeltaEvent, "Manip delta", _manipDeltaHandle));
            _logManipulationCompleted = new ManipulationCompletedEventHandler(CreateHandler(ManipulationCompletedEvent, "Manip completed", _manipCompletedHandle));
            _logTapped       = new TappedEventHandler(CreateHandler(TappedEvent, "Tapped", _gestureTappedHandle));
            _logDoubleTapped = new DoubleTappedEventHandler(CreateHandler(DoubleTappedEvent, "DoubleTapped", _gestureDoubleTappedHandle));

            _log.ItemsSource           = _eventLog;
            _pointerType.ItemsSource   = Enum.GetNames(typeof(PointerDeviceType));
            _pointerType.SelectedValue = PointerDeviceType.Touch.ToString();
            _manipMode.ItemsSource     = _manipulationModes.Keys;
            _manipMode.SelectedValue   = _manipulationModes.First().Key;

            _isReady = true;
            OnConfigChanged(null, null);
        }
        public async Task <SnapsCoordinate> GetTappedCoordinateAsync()
        {
            enableTouch();

            SnapsCoordinate tappedPositionResult = new SnapsCoordinate();

            AutoResetEvent GetTappedPositionCompleteEvent = new AutoResetEvent(false);

            var tcs = new TaskCompletionSource <object>();
            TappedEventHandler lambda = (s, e) =>
            {
                // Get the position relative to the graphics canvas as this
                // is the one we will be drawing
                Point p = e.GetPosition(manager.DisplayGrid);//   (Grid) s);
                tappedPositionResult.XValue = (int)Math.Round(p.X);
                tappedPositionResult.YValue = (int)Math.Round(p.Y);
                tcs.TrySetResult(null);
            };

            try
            {
                this.Tapped += lambda;
                await tcs.Task;
            }
            finally
            {
                this.Tapped -= lambda;
                disableTouch();
            }
            return(tappedPositionResult);
        }
Beispiel #5
0
        void unBindTappedHandlers()
        {
            // Tapped and point handlers are always managed together
            // So if one is set the other is also set.

            if (TappedHandler == null)
            {
                return;
            }

            manager.InvokeOnUIThread(
                () =>
            {
                if (TappedHandler != null)
                {
                    manager.DisplayGrid.Tapped -= TappedHandler;
                    TappedHandler = null;
                }
                if (PointHandler != null)
                {
                    manager.DisplayGrid.PointerPressed -= PointHandler;
                    PointHandler = null;
                }
            });
        }
Beispiel #6
0
        void bindTappedHandlers()
        {
            // Tapped and point handlers are always managed together
            // So if one is set the other is also set.

            if (TappedHandler != null)
            {
                return;
            }

            // Create the handlers

            TappedHandler = (s, e) =>
            {
                TappedFlag = true;
                e.Handled  = false;
            };

            PointHandler = (s, e) =>
            {
                TappedFlag = true;
                e.Handled  = false;
            };

            // Bind them - this must happen on the UI thread

            manager.InvokeOnUIThread(
                () =>
            {
                manager.DisplayGrid.Tapped         += TappedHandler;
                manager.DisplayGrid.PointerPressed += PointHandler;
            });
        }
Beispiel #7
0
 private void UnregisterTapped(TappedEventHandler handler)
 {
     _tap.Value.Event -= handler;
     if (_tap.Value.IsAttached)
     {
         _tap.Value.Detach();
     }
 }
Beispiel #8
0
 private void RegisterTapped(TappedEventHandler handler)
 {
     _tap.Value.Event += handler;
     if (_areGesturesAttached)
     {
         _tap.Value.Attach();
     }
 }
Beispiel #9
0
        public AppProtection()
        {
            this.InitializeComponent();

            AppExitTappedEventHandler  = AppExitTapped;
            AppLoginTappedEventHandler = AppLoginTapped;
            PasswordKeyUpEventHandler  = PasswordKeyUp;
        }
Beispiel #10
0
        internal static new void InvokeHandler(Delegate handler, IntPtr sender, IntPtr args)
        {
            TappedEventHandler handler_ = (TappedEventHandler)handler;

            if (handler_ != null)
            {
                handler_(Extend.GetProxy(sender, false), new TappedEventArgs(args, false));
            }
        }
Beispiel #11
0
        public static void RemoveTappedHandler(DependencyObject d, TappedEventHandler handler)
        {
            UIElement element = d as UIElement;

            if (element != null)
            {
                element.RemoveHandler(TappedEvent, handler);
            }
        }
Beispiel #12
0
 private void SearchTextBox_KeyDown(object sender, KeyRoutedEventArgs e)
 {
     if (e.Key == Windows.System.VirtualKey.Enter)
     {
         TappedRoutedEventArgs TappedArgs_e = new TappedRoutedEventArgs();
         TappedEventHandler    handler      = SearchIcon_Tapped;
         if (handler != null)
         {
             handler(this, TappedArgs_e);
         }
     }
 }
Beispiel #13
0
        protected override void RegisterEventHandler()
        {
            PlayListListViewSelectionChangedEventHandler = PlayListListViewSelectionChanged;

            RenameTappedEventHandler         = RenameTapped;
            DeletePlayListTappedEventHandler = DeletePlayListTapped;
            RefreshTappedEventHandler        = RefreshTapped;
            SelectItemTappedEventHandler     = SelectItemTapped;

            BackNormalButtonSetTappedEventHandler = BackNormalButtonSetTapped;
            AllCheckItemTappedEventHandler        = AllCheckItemTapped;
            ResetPausedTimeItemTappedEventHandler = ResetPausedTimeItemTapped;
            DeleteItemTappedEventHandler          = DeleteItemTapped;
        }
Beispiel #14
0
        /// <summary>
        /// Invoked when the application is launched normally by the end user.  Other entry points
        /// will be used such as when the application is launched to open a specific file.
        /// </summary>
        /// <param name="e">Details about the launch request and process.</param>
        protected override void OnLaunched(LaunchActivatedEventArgs e)
        {
            Frame rootFrame = Window.Current.Content as Frame;

            // Do not repeat app initialization when the Window already has content,
            // just ensure that the window is active
            if (rootFrame == null)
            {
                // Create a Frame to act as the navigation context and navigate to the first page
                rootFrame = new Frame();

                rootFrame.NavigationFailed += OnNavigationFailed;
                Popup.Init();

                // Need that .NET Native has worked
                Xamarin.Forms.Forms.Init(e, Popup.GetExtraAssemblies());
                var rendererAssemblies = new List <Assembly>()
                {
                };
                rendererAssemblies.AddRange(Popup.GetExtraAssemblies());
                Xamarin.Forms.Forms.Init(e, rendererAssemblies);
                Xamarin.Forms.DependencyService.Register <ICreateHtmlFiles, CreateHtmlFiles>();
                ConfigureSession();
                if (e.PreviousExecutionState == ApplicationExecutionState.Terminated)
                {
                    //TODO: Load state from previously suspended application
                }
                TappedEventHandler       tapped                  = TappedCallback;
                DoubleTappedEventHandler doubleTapped            = DoubleTappedCallback;
                RightTappedEventHandler  rightTappedEventHandler = RightTappedCallback;

                Window.Current.CoreWindow.PointerMoved   += onCoreWindowPointerMoved;
                Window.Current.CoreWindow.KeyDown        += CoreWindow_KeyDown;
                Window.Current.CoreWindow.KeyUp          += CoreWindow_KeyUp;
                Window.Current.CoreWindow.PointerPressed += CoreWindow_PointerPressed;
                // Place the frame in the current Window
                Window.Current.Content = rootFrame;
            }

            if (rootFrame.Content == null)
            {
                // When the navigation stack isn't restored navigate to the first page,
                // configuring the new page by passing required information as a navigation
                // parameter
                rootFrame.Navigate(typeof(MainPage), e.Arguments);
            }
            // Ensure the current window is active
            Window.Current.Activate();
        }
        public void DisplayEvent(MapControl map, Geopoint position, int eventId, TappedEventHandler tapped)
        {
            Image image = new Image();

            ImageSource source = new BitmapImage(new Uri("ms-appx:///Assets/BeerIcon.png", UriKind.Absolute));

            image.Stretch = Stretch.Uniform;
            image.Source  = source;
            image.Name    = eventId.ToString();
            image.Tapped += tapped;
            image.Width   = 40;

            map.Children.Add(image);
            MapControl.SetLocation(image, position);
            MapControl.SetNormalizedAnchorPoint(image, new Point(0.5, 1));
        }
 public static NetworkItemInfo ToNetworkItemInfo(this FtpItem item, Uri uri, TappedEventHandler tapped, RightTappedEventHandler rightTapped, HoldingEventHandler holding, bool isOrderByName)
 {
     return(new NetworkItemInfo()
     {
         ServerType = ServerTypes.FTP,
         Created = item.Created,
         IsFile = item.Type == FtpFileSystemObjectType.File,
         Modified = item.Modified,
         Name = item.Name,
         Size = item.Size,
         Uri = new Uri(uri, item.FullName),
         Tapped = tapped,
         RightTapped = rightTapped,
         Holding = holding,
         IsOrderByName = isOrderByName,
     });
 }
Beispiel #17
0
        private void InitListTapEvent()
        {
            if (listTapHandler == null)
            {
                listTapHandler = new TappedEventHandler((sender, e) =>
                {
                    var o = ((One)((TextBlock)((ListBox)sender).SelectedItem).Tag);

                    playing = o; isLive = false;

                    Play("http://media2.neu6.edu.cn/review/program-"
                         + o.start.ToString() + "-"
                         + o.end.ToString() + "-" + live.GetSimpleName() + ".m3u8");
                });
                see_back_list.Tapped += listTapHandler;
            }
        }
Beispiel #18
0
        public HexagonGrid(int width, int height, Canvas canvas, TappedEventHandler tapHandler )
        {
            // Size of the grid ( size x size)
            Width = width;
            Height = height;

            // Determine hexagon size
            _canvas = canvas;
            _hexagonRadius = (int)(Window.Current.Bounds.Height / Height / 2);
            _hexagonHeight = _hexagonRadius * Math.Sin(Math.PI / 3);

            // Determine pixel width/height
            double pixelWidth = Width * 1.5 * _hexagonRadius + (Width % 2) * _hexagonRadius;
            double pixelHeight = _hexagonHeight * 2 * Height;

            // Offset for centering on screen
            _offsetX = (Window.Current.Bounds.Width - pixelWidth) / 2 + _hexagonRadius;
            _offsetY = (Window.Current.Bounds.Height - pixelHeight) / 2 + _hexagonHeight / 2;

            // Create grid
            Grid = new Hexagon[Width, Height];

            // Populate grid to null
            for (int i = 0; i < Width; i++)
            {
                for (int j = 0; j < Height; j++)
                {
                    Hexagon hex = new Hexagon(_hexagonRadius, i, j);
                    Point coord = coordinatesToHexagonPosition(i, j);

                    // Position Grid
                    hex.Top = _offsetY + coord.Y;
                    hex.Left = _offsetX + coord.X;

                    // Hide (for now)
                    hex.IsVisible = false;

                    // Save grid
                    Grid[i, j] = hex;

                    // Add to visual tree
                    hex.UIElement.Tapped += tapHandler;
                    _canvas.Children.Add(hex.UIElement);
                }
            }
        }
 public static NetworkItemInfo ToNetworkItemInfo(this WebDavSessionItem item, TappedEventHandler tapped, RightTappedEventHandler rightTapped, HoldingEventHandler holding, bool isOrderByName)
 {
     return(new NetworkItemInfo()
     {
         ServerType = ServerTypes.WebDAV,
         ContentType = item.ContentType,
         Created = item.CreationDate.GetValueOrDefault(),
         //IsFile = !item.IsCollection && item.ContentType?.ToLower() != "httpd/unix-directory",
         IsFile = !item.IsFolder.GetValueOrDefault() || item.ContentType?.ToLower() != "httpd/unix-directory",
         Modified = item.LastModified.GetValueOrDefault(),
         Name = item.Name,
         Size = item.ContentLength.GetValueOrDefault(),
         Uri = item.Uri,
         Tapped = tapped,
         RightTapped = rightTapped,
         Holding = holding,
         IsOrderByName = isOrderByName,
     });
 }
Beispiel #20
0
        /// <summary>
        /// 재생목록을 로딩한다.
        /// </summary>
        /// <param name="playList">로딩될 리스트</param>
        public void LoadPlayList(ICollection <PlayList> playList, TappedEventHandler eventHandler)
        {
            using (var pstmt = conn.Prepare(DML_SELECT_PLAYLIST))
            {
                while (pstmt.Step() == SQLiteResult.ROW)
                {
                    PlayList fi = new PlayList()
                    {
                        Seq  = pstmt.GetInteger("SEQ"),
                        Name = pstmt.GetText("NAME")
                    };

                    if (eventHandler != null)
                    {
                        fi.ItemTapped = eventHandler;
                    }

                    playList.Add(fi);
                }
            }
        }
Beispiel #21
0
 private void UserControl_Unloaded(object sender, RoutedEventArgs e)
 {
     MainContent.RemoveHandler(UIElement.TappedEvent, MainContentTappedHandler);
     MainContentTappedHandler = null;
     foreach (var c in LeftContent)
     {
         if (c is SidebarItem sb)
         {
             sb.PropertyChanged -= LeftItemPropertyChanged;
         }
     }
     foreach (var c in RightContent)
     {
         if (c is SidebarItem sb)
         {
             sb.PropertyChanged -= RightItemPropertyChanged;
         }
     }
     LeftContent  = null;
     RightContent = null;
 }
        protected override void OnApplyTemplate()
        {
            base.OnApplyTemplate();

            if (GetTemplateChild(PART_NOTIFICATION_ROOT) is FrameworkElement notificationRoot)
            {
                this.notificationRoot         = notificationRoot;
                notificationRoot.SizeChanged += (s, e) => OnSizeChanged();

                if (GetTemplateChild(PART_TRANSFORM) is TranslateTransform translation)
                {
                    this.translation = translation;
                    notificationRoot.ManipulationDelta     += NotificationRoot_ManipulationDelta;
                    notificationRoot.ManipulationCompleted += NotificationRoot_ManipulationCompleted;
                }
            }

            if (GetTemplateChild(PART_TARGET) is Grid target)
            {
                TappedEventHandler tappedHandler = null;
                tappedHandler += (s, e) =>
                {
                    target.Tapped -= tappedHandler;

                    Action?.Invoke();
                    Hide();
                };

                target.Tapped += tappedHandler;
            }

            if (GetTemplateChild(PART_DISMISS_BUTTON) is Button dismissButton)
            {
                dismissButton.Click += (s, e) => Hide();
            }

            UpdateManipulationPredicates();
        }
Beispiel #23
0
 private void SearchTextBox_KeyDown(object sender, KeyRoutedEventArgs e)
 {
     if (e.Key == Windows.System.VirtualKey.Enter)
     {
         TappedRoutedEventArgs TappedArgs_e = new TappedRoutedEventArgs();
         TappedEventHandler    handler      = SearchIcon_Tapped;
         if (handler != null)
         {
             handler(this, TappedArgs_e);
         }
         //InputPane.GetForCurrentView().TryHide();
         //ResultsTextBlock.Focus(FocusState.Programmatic);
         //var items = await DataSource.GetRelativeItemsAsync(SearchTextBox.Text);
         //this.DefaultViewModel["RelativeItems"] = items;
         //if (items == null)
         //{
         //    ResultsTextBlock.Visibility = Visibility.Visible;
         //}
         //else
         //{
         //    ResultsTextBlock.Visibility = Visibility.Collapsed;
         //}
     }
 }
        public async Task <SnapsCoordinate> GetDraggedCoordinateAsync()
        {
            enableTouch();

            SnapsCoordinate draggedPositionResult = new SnapsCoordinate();

            AutoResetEvent GetDraggedPositionCompleteEvent = new AutoResetEvent(false);

            var tcs = new TaskCompletionSource <object>();

            TappedEventHandler pointerTappedHandler = (s, e) =>
            {
                // Get the position relative to the graphics canvas as this
                // is the one we will be drawing
                Point p = e.GetPosition(manager.DisplayGrid);//   (Grid) s);
                draggedPositionResult.XValue = (int)Math.Round(p.X);
                draggedPositionResult.YValue = (int)Math.Round(p.Y);
                tcs.TrySetResult(null);
            };


            PointerEventHandler pointerMovedHandler = (s, e) =>
            {
                bool doDraw = false;

                // Get the position relative to the graphics canvas as this
                // is the one we will be drawing
                PointerPoint p = e.GetCurrentPoint(this);//   (Grid) s);

                switch (p.PointerDevice.PointerDeviceType)
                {
                case Windows.Devices.Input.PointerDeviceType.Mouse:

                    if (p.Properties.IsLeftButtonPressed)
                    {
                        doDraw = true;
                    }
                    break;

                case Windows.Devices.Input.PointerDeviceType.Pen:
                    if (p.Properties.Pressure > 0)
                    {
                        doDraw = true;
                    }
                    break;

                case Windows.Devices.Input.PointerDeviceType.Touch:
                    doDraw = true;
                    break;
                }

                if (doDraw)
                {
                    draggedPositionResult.XValue = (int)Math.Round(p.RawPosition.X);
                    draggedPositionResult.YValue = (int)Math.Round(p.RawPosition.Y);
                    tcs.TrySetResult(null);
                }
            };

            try
            {
                this.Tapped       += pointerTappedHandler;
                this.PointerMoved += pointerMovedHandler;
                await tcs.Task;
            }
            finally
            {
                this.Tapped       -= pointerTappedHandler;
                this.PointerMoved -= pointerMovedHandler;
                disableTouch();
            }
            return(draggedPositionResult);
        }
        public static NetworkItemInfo ToNetworkItemInfo(this Microsoft.OneDrive.Sdk.Item item, TappedEventHandler tapped, RightTappedEventHandler rightTapped, HoldingEventHandler holding, bool isOrderByName)
        {
            var networkItemInfo = new NetworkItemInfo()
            {
                Id               = item.Id,
                Created          = (DateTime)item.CreatedDateTime?.DateTime,
                Modified         = (DateTime)item.LastModifiedDateTime?.DateTime,
                ServerType       = ServerTypes.OneDrive,
                IsFile           = item.File != null,
                Name             = item.Name,
                Size             = (long)item.Size,
                ParentFolderPath = item.ParentReference?.Path,
                Tapped           = tapped,
                RightTapped      = rightTapped,
                Holding          = holding,
                IsOrderByName    = isOrderByName,
            };

            return(networkItemInfo);
        }
Beispiel #26
0
 private void UnregisterTapped(TappedEventHandler handler)
 {
     LogUnRegisterPointerReleasedNotImplemented();
 }
Beispiel #27
0
 public void LoadSpatialData(SpatialDataSet data, TappedEventHandler geometryTappedEvent)
 {
     MapTools.LoadGeometries(data, PinLayer, ShapeLayer, DefaultStyle, geometryTappedEvent);
 }
Beispiel #28
0
 private void UnregisterTapped(TappedEventHandler handler)
 {
     _gestures.Value.UnregisterTapped(handler);
 }
Beispiel #29
0
 public void setEvent(TappedEventHandler e)
 {
     imagen.Tapped += new TappedEventHandler(e);
 }
Beispiel #30
0
 private void AddToCart(object sender, TappedEventHandler e)
 {
     Debug.WriteLine(sender.ToString());
 }
 protected override void RegisterEventHandler()
 {
     LoadedEventHandler                    = Loaded;
     SavePasswordTappedEventHandler        = SavePasswordTapped;
     ChangeFileExtensionTappedEventHandler = ChangeFileExtensionTapped;
 }
Beispiel #32
0
 protected override void RegisterEventHandler()
 {
     LoadedEventHandler = Loaded;
     ClearThumbnailCacheTappedEventHandler = ClearThumbnailCacheTapped;
     ResetSettingsTappedEventHandler       = ResetSettingsTapped;
 }