Example #1
0
 private void OnObjectMoved(ShowView affectedObject, ManipulationDelta deltaManipulation)
 {
     if (ObjectMoved != null)
     {
         ObjectMoved(this, new ObjectMovedEventArgs(affectedObject, deltaManipulation));
     }
 }
Example #2
0
        private void UpdatePosition(ShowView view, ManipulationDelta delta, Point manipulationOrigin, int numTouches)
        {
            //Get the deltas into World frame-of-reference
            Vector deltaTranslation = ScreenToWorld(delta.Translation);
            double deltaRotation    = delta.Rotation;
            Vector deltaScale       = delta.Scale;

            manipulationOrigin = ScreenToWorld(manipulationOrigin);

            //Only allow rotation with 3 or more touches. (Only Images have rotation enabled by default.)
            if (numTouches < 3)
            {
                deltaRotation = 0;
            }

            ManipulationDelta deltaManipulation = new ManipulationDelta(deltaTranslation, deltaRotation, deltaScale, delta.Expansion);

            view.ProcessManipulationDelta(deltaManipulation, manipulationOrigin);

            //Special case, use 3 touches to move a zone without moving the containing group
            if (numTouches < 3)
            {
                foreach (ZoomCanvasItem item in view.ManipulationGroup)
                {
                    item.View.ProcessManipulationDelta(deltaManipulation, manipulationOrigin);
                }
            }

            OnObjectMoved(view, deltaManipulation);
        }
Example #3
0
 private void OnObjectDoubleTap(ShowView affectedObject)
 {
     if (ObjectDoubleTap != null)
     {
         ObjectDoubleTap(this, new ObjectSelectedEventArgs(affectedObject));
     }
 }
Example #4
0
        void controlBar_AddZoneCommand(object sender, AddObjectEventArgs e)
        {
            Point centerStart = zoomCanvas.PointFromScreen(e.Center);

            Point centerTarget = new Point(zoomCanvas.ActualWidth / 2 + rand.Next(-100, 100),
                                           zoomCanvas.ActualHeight / 2 + rand.Next(-100, 100));

            double orientationStart  = -180;
            double orientationTarget = 0;

            Vector scaleStart  = new Vector(0.2, 0.2);
            Vector scaleTarget = zoomCanvas.ViewScaleInvert * 3;

            if (e.IsMap)
            {
                GenerateMapModel(centerStart, centerTarget, orientationStart, orientationTarget, scaleStart, scaleTarget);
            }
            else
            {
                ShowZoneModel zoneModel = new ShowZoneModel();
                zoneModel.Text = "Zone";

                ShowView view = GenerateModel(zoneModel, centerStart, centerTarget, orientationStart, orientationTarget, scaleStart, scaleTarget);

                textEntry.SelectCursor(view);
                textEntry.SelectAll = true;
            }
        }
Example #5
0
        //设置显示区域,方便产生滚动条
        private void SetViewSize()
        {
            var size = ShowView.GetViewSize();

            this.AutoScrollMinSize = new Size(size.Width + 2 * ViewMargin, size.Height + 2 * ViewMargin);
            ShowView.Init(new Rectangle(100, 100, size.Width, size.Height));
        }
Example #6
0
        void container_TouchUp(object sender, TouchEventArgs e)
        {
            ZoomCanvasItem selectedChild = GetZoomCanvasItem(sender);

            if (selectedChild == null)
            {
                return;
            }

            ShowView view = selectedChild.View;

            if (view == null)
            {
                return;
            }

            if (firstTapItem == selectedChild &&
                doubleTapSequence == DoubleTapSequence.FirstTouchDown)
            {
                doubleTapSequence = DoubleTapSequence.FirstTouchUp;
            }
            else
            {
                doubleTapSequence = DoubleTapSequence.None;
            }
        }
Example #7
0
        protected override void PrepareContainerForItemOverride(DependencyObject element, object item)
        {
            base.PrepareContainerForItemOverride(element, item);
            this.InvalidateArrange();
            ZoomCanvasItem container = element as ZoomCanvasItem;

            container.RenderTransformOrigin = new Point(0.5, 0.5);

            container.IsManipulationEnabled = true;
            container.TouchDown            += child_TouchDown;
            container.TouchUp += container_TouchUp;

            container.ManipulationDelta           += child_ManipulationDelta;
            container.ManipulationStarting        += child_ManipulationStarting;
            container.ManipulationInertiaStarting += child_ManipulationInertiaStarting;
            container.ManipulationCompleted       += container_ManipulationCompleted;
            container.ViewChanged += DisplayData_ViewChanged;

            ShowView view = item as ShowView;

            if (view != null)
            {
                view.Model.DisplayMatrix.ViewChanged += container.DisplayMatrix_ViewChanged;
            }

            isPositionUpdateNecessary = true;
            dirtyItems.Add(container);
        }
Example #8
0
        void zoomCanvas_ObjectDoubleTap(object sender, ObjectSelectedEventArgs e)
        {
            if (this.isLocked)
            {
                ShowView      view   = e.AffectedObject;
                Rect          bounds = view.Bounds;
                DisplayMatrix data   = view.Model.DisplayMatrix;

                double margin       = 0.95;
                double scaleFactorX = margin * zoomCanvas.ActualWidth / (view.ActualWidth * data.Scale.X);
                double scaleFactorY = margin * zoomCanvas.ActualHeight / (view.ActualHeight * data.Scale.Y);
                double scaleFactor  = Math.Min(scaleFactorX, scaleFactorY);
                Vector scale        = new Vector(scaleFactor, scaleFactor);

                DisplayMatrix newTransform = new DisplayMatrix();
                newTransform.Center      = zoomCanvas.CurrentView.Center;
                newTransform.Orientation = zoomCanvas.CurrentView.Orientation;
                newTransform.Scale       = scale;

                Point p1 = newTransform.TransformMatrix.Transform(data.Center);

                Vector offset = new Vector(zoomCanvas.ActualWidth / 2, zoomCanvas.ActualHeight / 2);
                Vector p2     = offset - new Vector(p1.X, p1.Y);

                Point center = zoomCanvas.CurrentView.Center + p2;

                ZoomViewTo(center, 0, scale);
            }
            else
            {
                showContext.SendToFront(e.AffectedObject.Model);
            }
        }
Example #9
0
        void child_TouchDown(object sender, TouchEventArgs e)
        {
            ZoomCanvasItem selectedChild = GetZoomCanvasItem(sender);

            if (selectedChild == null)
            {
                return;
            }

            ShowView view = selectedChild.View;

            if (view == null)
            {
                return;
            }

            if (firstTapItem == null)
            {
                firstTapItem = selectedChild;
                doubleTapTimer.Start();
                doubleTapSequence = DoubleTapSequence.FirstTouchDown;
            }
            else if (firstTapItem == selectedChild &&
                     doubleTapSequence == DoubleTapSequence.FirstTouchUp)
            {
                OnObjectDoubleTap(selectedChild.View);

                doubleTapSequence = DoubleTapSequence.SecondTouchDown;
            }

            OnObjectSelected(view);

            //TODO: double tap gesture, boundstomatrix, zoom in currentview
        }
Example #10
0
        protected override void OnPaint(PaintEventArgs e)
        {
            base.OnPaint(e);
            Graphics g = e.Graphics;

            g.ScaleTransform(ZoomFactor, ZoomFactor);
            g.TranslateTransform(_viewOffset.X, _viewOffset.Y);
            ShowView.DrawView(g);
        }
Example #11
0
        public void SelectCursor(ShowView view)
        {
            DeselectCursor();

            if (view == null)
            {
                return;
            }

            CursorView  = view;
            CursorModel = view.Model;

            CursorModel.Color = Colors.Blue;
        }
Example #12
0
        public List <ShowView> CreateViews()
        {
            List <ShowView> views = new List <ShowView>();

            foreach (ShowModel model in Models)
            {
                ShowView view = CreateView(model);
                if (view != null)
                {
                    views.Add(view);
                }
            }

            return(views);
        }
Example #13
0
        private bool GetIsLocked(ZoomCanvasItem item)
        {
            if (item == null)
            {
                return(false);
            }

            ShowView view = item.View;

            if (view == null)
            {
                return(false);
            }

            return(view.IsLocked);
        }
Example #14
0
        void container_ManipulationCompleted(object sender, ManipulationCompletedEventArgs e)
        {
            ZoomCanvasItem child = GetZoomCanvasItem(sender);

            if (child == null)
            {
                return;
            }

            ShowView zoneView = child.View;

            if (zoneView == null)
            {
                return;
            }

            zoneView.ManipulationGroup.Clear();
        }
Example #15
0
        void child_ManipulationDelta(object sender, ManipulationDeltaEventArgs e)
        {
            ZoomCanvasItem child = GetZoomCanvasItem(sender);

            if (child == null)
            {
                return;
            }

            ShowView view = child.View;

            if (view == null || GetIsLocked(child))
            {
                //Since the element is locked, forward the touches to the layoutroot for moving whole background
                child.TouchesCaptured.ToList().ForEach(t => layoutRoot.CaptureTouch(t));

                e.Complete();
                return;
            }

            UpdatePosition(view, e.DeltaManipulation, e.ManipulationOrigin, child.TouchesCaptured.Count());

            PositionChild(child);
            if (dirtyItems.Contains(child))
            {
                dirtyItems.Remove(child);
            }

            foreach (ZoomCanvasItem item in view.ManipulationGroup)
            {
                PositionChild(item);
                if (dirtyItems.Contains(item))
                {
                    dirtyItems.Remove(item);
                }
            }

            //We took care of the event
            e.Handled = true;
        }
Example #16
0
        private ShowView GenerateModel(ShowModel model, Point centerStart, Point centerTarget, double orientationStart, double orientationTarget, Vector scaleStart, Vector scaleTarget)
        {
            centerStart  = zoomCanvas.ScreenToWorld(centerStart);
            centerTarget = zoomCanvas.ScreenToWorld(centerTarget);

            model.IsLocked                  = this.isLocked;
            model.DisplayMatrix.Center      = centerStart;
            model.DisplayMatrix.Orientation = orientationStart;
            model.DisplayMatrix.Scale       = scaleStart;

            AnimateUtility.AnimateElementPoint(model.DisplayMatrix, DisplayMatrix.CenterProperty, centerTarget, 0, 1);
            AnimateUtility.AnimateElementDouble(model.DisplayMatrix, DisplayMatrix.OrientationProperty, orientationTarget, 0, 1);
            AnimateUtility.AnimateElementVector(model.DisplayMatrix, DisplayMatrix.ScaleProperty, scaleTarget, 0, 1);

            showContext.Models.Add(model);
            showContext.SendToFront(model);

            ShowView view = showContext.CreateView(model);

            zoomCanvas.Items.Add(view);

            return(view);
        }
Example #17
0
        /// <summary>
        /// 查询FM
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void Select(object sender, EventArgs e)
        {
            //获取FM当前小说下所有的话ID
            Root result = _downFm.Select(Idtext.Text.Trim()) as Root;

            if (result == null)
            {
                AllDwBt.Enabled = false;
                MessageBox.Show(ErrorCode.SelectNull, ErrorCode.Caption);
                return;
            }
            AllDwBt.Enabled = true;
            ShowView.Items.Clear();
            ShowView.Items.AddRange(result.info.episodes.episode.OrderBy(s => s.id).Select(s => new ListViewItem()
            {
                ImageIndex = 1, Text = s.name, ToolTipText = s.soundstr
            })
                                    .ToArray());
            ShowView.EndUpdate();
            skinTextBox1.Text      = result.info.drama.name;
            Newtext.Text           = result.info.drama.newest;
            pictureBox1.WaitOnLoad = false;
            pictureBox1.LoadAsync(result.info.drama.cover);
        }
Example #18
0
        void LayoutRootCanvas_ManipulationDelta(object sender, ManipulationDeltaEventArgs e)
        {
            if (zoomElement == null || layoutRoot == null)
            {
                return;
            }

            if (this.doubleTapSequence == DoubleTapSequence.SecondTouchDown)
            {
                return;
            }

            if (this.CurrentView.HasAnimatedProperties)
            {
                AnimateUtility.StopAnimation(this.CurrentView, DisplayMatrix.CenterProperty);
                AnimateUtility.StopAnimation(this.CurrentView, DisplayMatrix.OrientationProperty);
                AnimateUtility.StopAnimation(this.CurrentView, DisplayMatrix.ScaleProperty);
            }

            //Get the deltas into World frame-of-reference
            Vector deltaTranslation   = e.DeltaManipulation.Translation;
            double deltaRotation      = e.DeltaManipulation.Rotation;
            Vector deltaScale         = e.DeltaManipulation.Scale;
            Point  manipulationOrigin = e.ManipulationOrigin;

            UpdateZoomView(deltaTranslation, deltaRotation, deltaScale, manipulationOrigin);

            //We took care of the event
            e.Handled = true;

            foreach (object item in this.Items)
            {
                ZoomCanvasItem child = GetZoomCanvasItem(item);

                if (child != null && !GetIsLocked(child) && child.AreAnyTouchesCaptured)
                {
                    ShowView view = child.View;

                    Vector scale = deltaScale;
                    if (scale.X != 0)
                    {
                        scale.X = 1 / scale.X;
                    }
                    if (scale.Y != 0)
                    {
                        scale.Y = 1 / scale.Y;
                    }

                    ManipulationDelta deltaManipulation = new ManipulationDelta(-1 * deltaTranslation,
                                                                                -1 * deltaRotation,
                                                                                scale,
                                                                                new Vector());
                    UpdatePosition(view, deltaManipulation, manipulationOrigin, 1);

                    PositionChild(child);
                    if (dirtyItems.Contains(child))
                    {
                        dirtyItems.Remove(child);
                    }
                }
            }

            OnViewChanged();
        }
Example #19
0
File: Form1.cs Project: 287396159/A
        public void receivedData(byte comType, object data)
        {
            switch (comType)
            {
            case 0x00:
                showView = new ShowView(receivedData00);
                break;

            case 0x10:
                showView = new ShowView(receivedData18);
                break;

            case 0x12:
                showView = new ShowView(receivedData12);
                break;

            case 0x13:
                showView = new ShowView(receivedData12);
                break;

            case 0x14:
                showView = new ShowView(receivedData14);
                break;

            case 0x15:
                showView = new ShowView(receivedData14);
                break;

            case 0x16:
                showView = new ShowView(receivedData16);
                break;

            case 0x17:
                showView = new ShowView(receivedData16);
                break;

            case 0x18:
                showView = new ShowView(receivedData18);
                break;

            case 0x40:
                showView = new ShowView(receivedData40);
                break;

            case 0x41:
                showView = new ShowView(receivedData41);
                break;

            case 0x43:
                showView = new ShowView(receivedData41);
                break;

            case 0x44:
                showView = new ShowView(receivedData44);
                break;

            case 0x45:
                showView = new ShowView(receivedData44);
                break;

            case 0x46:
                showView = new ShowView(receivedData46);
                break;

            case 0x47:
                showView = new ShowView(receivedData46);
                break;

            case 0x48:
                showView = new ShowView(receivedData48);
                break;

            case 0x49:
                showView = new ShowView(receivedData49);
                break;

            default:
                break;
            }
            BeginInvoke(showView, data);
        }
Example #20
0
 public ObjectMovedEventArgs(ShowView affectedObject, ManipulationDelta deltaManipulation)
 {
     this.AffectedObject    = affectedObject;
     this.DeltaManipulation = deltaManipulation;
 }
Example #21
0
 public ObjectSelectedEventArgs(ShowView affectedObject)
 {
     this.AffectedObject = affectedObject;
 }