示例#1
0
        public void EnableSwipeFeature(FrameworkElement element, FrameworkElement referenceFrame)
        {
            try
            {
                //already enabled
                if (inputProcessors.ContainsKey(element))
                {
                    return;
                }

                GestureRecognizer          gestureRecognizer     = new GestureRecognizer();
                ManipulationInputProcessor elementInputProcessor = new ManipulationInputProcessor(gestureRecognizer, element, referenceFrame);

                //handlers
                elementInputProcessor.ItemSwiped += OnItemSwiped;

                //save
                inputProcessors[element] = elementInputProcessor;
            }
            catch (Exception e)
            {
                var exceptionProperties = new Dictionary <string, string>()
                {
                    { "Details", "Failed to Enable Swipe Feature" }
                };
                var exceptionMetrics = new Dictionary <string, double>()
                {
                    { "Input processors count", inputProcessors.Count }
                };
                App.TelemetryClient.TrackException(e, exceptionProperties, exceptionMetrics);
            }
        }
示例#2
0
        partial void EnableSwipeFeature(FrameworkElement element, FrameworkElement referenceFrame)
        {
            GestureRecognizer          gestureRecognizer     = new GestureRecognizer();
            ManipulationInputProcessor elementInputProcessor = new ManipulationInputProcessor(gestureRecognizer, element, referenceFrame);

            //handlers
            elementInputProcessor.ItemSwiped += OnItemSwiped;

            //save
            inputProcessors[element] = elementInputProcessor;
        }
示例#3
0
        private async void CreateJob_Click(object sender, RoutedEventArgs e)
        {
            Job        j = jobsViewModel.CreateJob(string.Empty, string.Empty, new List <InkStroke>());
            JobControl dragJobControl = new JobControl();

            dragJobControl.DataContext = j;

            //set the visual of the new dragging job control
            dragJobControl.Fill = new SolidColorBrush(Colors.LightGray);

            //position the new dragging job control on the grid in the
            //same position as the original job control
            dragJobControl.VerticalAlignment   = VerticalAlignment.Top;
            dragJobControl.HorizontalAlignment = HorizontalAlignment.Left;
            dragJobControl.Width = this.ActualWidth / 3;
            Grid.SetColumnSpan(dragJobControl, 5);

            Button btn = sender as Button;

            if (btn != null)
            {
                GeneralTransform   gt    = btn.TransformToVisual(JobsGrid);
                TranslateTransform trans = new TranslateTransform();
                Point p = gt.TransformPoint(new Point(0, 0));
                trans.X = p.X;
                trans.Y = p.Y;

                if (btn.Tag.ToString() == "Right")
                {
                    trans.X = trans.X - dragJobControl.Width;
                }

                dragJobControl.RenderTransform = trans;
            }

            //add the new jobcontrol on the jobsgrid
            JobsGrid.Children.Add(dragJobControl);
            //add a recognizer for the new dragging job control
            GestureRecognizer          recognizer            = new GestureRecognizer();
            ManipulationInputProcessor manipulationProcessor = new
                                                               ManipulationInputProcessor(recognizer, dragJobControl, JobsGrid);

            //manipulationProcessor.OnPointerPressed(sender, e);
            //let the view model know that we are moving this job
            jobsViewModel.MoveJob(j);

            jobsViewModel.ShowingMenu = false;
        }
示例#4
0
        private void JobControl_PointerPressed(object sender, PointerRoutedEventArgs e)
        {
            if (sender is JobControl)
            {
                JobControl selectedJobControl = sender as JobControl;

                Job j = selectedJobControl.DataContext as Job;
                if (j == null)
                {
                    return;
                }

                JobControl dragJobControl = new JobControl();
                dragJobControl.DataContext = j;

                //set the visual of the new dragging job control
                dragJobControl.Fill = new SolidColorBrush(Colors.LightGray);
                Grid.SetColumnSpan(dragJobControl, 3);
                dragJobControl.Height = selectedJobControl.ActualHeight;
                dragJobControl.Width  = selectedJobControl.ActualWidth;

                // position the new dragging job control on the grid in the same position
                // as the original job control
                dragJobControl.VerticalAlignment   = VerticalAlignment.Top;
                dragJobControl.HorizontalAlignment = HorizontalAlignment.Left;

                GeneralTransform   gt    = selectedJobControl.TransformToVisual(JobsGrid);
                TranslateTransform trans = new TranslateTransform();
                Point p = gt.TransformPoint(new Point(0, 0));
                trans.X = p.X;
                trans.Y = p.Y;
                dragJobControl.RenderTransform = trans;

                //add the new jobcontrol on the jobsgrid
                JobsGrid.Children.Add(dragJobControl);
                //add a recognizer for the new dragging job control
                GestureRecognizer          recognizer            = new GestureRecognizer();
                ManipulationInputProcessor manipulationProcessor =
                    new ManipulationInputProcessor(recognizer, dragJobControl, JobsGrid);
                manipulationProcessor.OnPointerPressed(sender, e);
                //let the view model know that we are moving this job
                jobsViewModel.MoveJob(j);

                e.Handled = true;
            }
        }
示例#5
0
        protected override bool ApplyTemplateCore()
        {
            var isApplied = base.ApplyTemplateCore();

            this.image             = this.GetTemplateChild("PART_Image") as Image;
            this.manupulationPanel = this.GetTemplateChild("PART_ManipulationPanel") as Panel;

            isApplied &= this.image != null && this.manupulationPanel != null;

            if (isApplied)
            {
                this.image.ImageFailed += this.OnImageImageFailed;
                this.image.ImageOpened += this.OnImageOpened;
                this.image.SizeChanged += this.OnImageSizeChanged;

                this.manipulationInputProcessor = new ManipulationInputProcessor(this.image, this.manupulationPanel, this.GestureSettings);

                return(true);
            }

            return(false);
        }