Exemplo n.º 1
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;
        }
Exemplo n.º 2
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;
            }
        }