Пример #1
0
        private void mousePhoto(PointingDevice pd)
        {
            if (pd.LeftButton == ButtonState.Released && pd.oldLeftButton == ButtonState.Pressed)
            {
                //Console.WriteLine("ds");
                if (mousePhotoConnection.ContainsKey(pd.Header))
                {
                    //Console.WriteLine(pd.oldLeftButton + i++);
                    Photo photo = mousePhotoConnection[pd.Header];
                    photo.underMouse = true;
                    photo.PositionDisplay = pd.GamePosition + photo.StartDragPosition * photo.ScaleDisplay;
                    photo.Position = photo.PositionDisplay;
                    //Console.WriteLine(photo.Position);
                    photo.SetDisplayTarget();
                    mousePhotoConnection.Remove(pd.Header);
                    List<string> newTags = strokeGroup.checkInside(photo.Position, photo);
                    if (newTags.Count > 0)
                    {
                        photo.ptag.allTags.AddRange(newTags);
                        createPhoto.addTag(photo.FileName, newTags);
                    }
                    List<string> removeTags = strokeGroup.checkOutside(photo.Position, photo);
                    if (removeTags.Count > 0)
                    {
                        photo.ptag.allTags = new List<string>(photo.ptag.allTags.Except(removeTags));
                        createPhoto.removeTag(photo.FileName, removeTags);
                    }
                }
            }

            else if (pd.LeftButton == ButtonState.Pressed && mousePhotoConnection.ContainsKey(pd.Header))
            {
                Photo photo = mousePhotoConnection[pd.Header];

                photo.underMouse = true;
                photo.IsClicked = true;
                photo.PositionDisplay = pd.GamePosition + photo.StartDragPosition * photo.ScaleDisplay;
                photo.Position = photo.PositionDisplay;
                //Console.WriteLine(photo.Position);
                photo.SetDisplayTarget();
                if(pd.Type == PointingDevice.DeviceType.Touch)
                    photo.touchCount = 1;
            }

            //指点到图像上并拽动鼠标
            else
            foreach (Photo photo in photos)
            {
                if (photo.BoundingBoxDisplay.Contains(pd.GamePosition) == ContainmentType.Contains)
                {
                    photo.underMouse = true;
                    //photo.DistanceToMouse = pd.GamePosition - photo.Position ;
                    //Console.WriteLine(photo.IsGazeds);
                    if (pd.LeftButton == ButtonState.Pressed && pd.oldLeftButton == ButtonState.Released)
                    {
                        photo.KeepGazed();
                        photo.IsClicked = true;
                        photo.ClickedPoint = photo.BoundingBoxDisplay.Offset(pd.GamePosition);
                        Console.WriteLine(photo.ClickedPoint);
                        Console.WriteLine(pd.GamePosition);
                        photo.StartDragPosition = (photo.PositionDisplay - pd.GamePosition)/photo.ScaleDisplay;
                        photo.Position = photo.PositionDisplay;
                        //photo.tagClickedCheck(pd.GamePosition);
                            //systemState.SwapColor();
                        mousePhotoConnection[pd.Header] = photo;
                        if (pd.Type == PointingDevice.DeviceType.Touch)
                        {
                            photo.touchCount = 1;
                        }
                    }

                    break;
                }

            }
        }
Пример #2
0
 void moveLine(PointingDevice pd)
 {
     if (pd.RightButton == ButtonState.Pressed && pd.oldRightButton == ButtonState.Released && keyboard.ctrlKey)
     {
         pd.state = (int)PointingDevice.State.Cross;
         List<Stroke> s = strokeGroup.strokeList;
         for (int j = 0; j < s.Count; ++j)
         {
             if (s[j].IsInternal(pd.GamePosition, s[j].Strokes))
             {
                 strokeGroup.remove(s[j]);
             }
         }
         return;
     }
     if (pd.RightButton == ButtonState.Released && pd.oldRightButton == ButtonState.Pressed)
     {
         pd.state = (int)PointingDevice.State.Curosr;
         return;
     }
     if (strokeMouse.ContainsKey(pd.Header))
     {
         if (strokeMouse[pd.Header].Interact(pd) == (int)Stroke.StrokeState.NOTHING)
         {
             strokeGroup.moveTextBox(strokeMouse[pd.Header]);
             strokeMouse.Remove(pd.Header);
         }
     }
     else
     {
         List<Stroke> s = strokeGroup.strokeList;
         for (int j = 0; j < s.Count; ++j)
         {
             if (s[j].Interact(pd) != (int)Stroke.StrokeState.NOTHING)
             {
                 strokeMouse[pd.Header] = s[j];
                 break;
             }
         }
     }
 }
Пример #3
0
        private void mouseBar(PointingDevice pd)
        {
            if (pd.LeftButton == ButtonState.Pressed)
            {
                Vector2 pos = pd.GamePosition;
                Vector2 posOld = pd.OldGamePosition;
                Vector2 v = pos - posOld;

                if (pd.oldLeftButton == ButtonState.Released)
                {
                    if (sBar.LeftContains(pos) == ContainmentType.Contains)
                    {
                        barDrag[pd.Header] = ScrollBar.DragRegion.LEFT;

                    }
                    else if (sBar.RightContains(pos) == ContainmentType.Contains)
                    {
                        barDrag[pd.Header] = ScrollBar.DragRegion.RIGHT;

                    }
                    else if (sBar.CenterContains(pos) == ContainmentType.Contains)
                    {
                        barDrag[pd.Header] = ScrollBar.DragRegion.CENTER;

                    }
                    else
                    {
                        barDrag[pd.Header] = ScrollBar.DragRegion.NONE;
                    }
                }
                else
                {
                    if(barDrag.ContainsKey(pd.Header))
                    {
                        ScrollBar.DragRegion region = barDrag[pd.Header];
                        if(region == ScrollBar.DragRegion.LEFT)
                            sBar.MoveBar((int)pos.X, sBar.Max);
                        else if(region == ScrollBar.DragRegion.RIGHT)
                            sBar.MoveBar(sBar.Min, (int)pos.X);
                        else if (region == ScrollBar.DragRegion.CENTER)
                        {
                            if ((pos.X > sBar.Min && pos.X < sBar.Max) || (posOld.X > sBar.Min && posOld.X < sBar.Max))
                            {
                                sBar.MoveBar(sBar.Min + (int)v.X, sBar.Max + (int)v.X);
                            }
                        }
                    }
                }

            }
            else barDrag[pd.Header] = ScrollBar.DragRegion.NONE;
        }
Пример #4
0
        bool mouseOnMenu(PointingDevice pd)
        {
            // icon, piemenu, controlpanel, tagform 这些, 鼠标是否在其上
            foreach (Icon icon in dock.Icons)
            {
                icon.tooltip.IsDel = true;
                if (icon.BoundingBox.Contains(pd.GamePosition) == ContainmentType.Contains)
                {
                    iconMouse(icon, pd);
                    return true;
                }
            }

            if (systemState.curState == SystemState.ATTRACTOR_TIME)
            {
                if ((barDrag.ContainsKey(pd.Header) && barDrag[pd.Header] != ScrollBar.DragRegion.NONE) || sBar.BoundingBox.Contains(pd.GamePosition) == ContainmentType.Contains)
                {
                    mouseBar(pd);
                    return true;
                }
            }

            if(strokeGroup.underMouse(pd))
                return true;
            //foreach (var tb in ftBoxes)
            //{
            //    if (tb.boundingBox.Contains(pd.GamePosition) == ContainmentType.Contains)
            //    {
            //        return true;
            //    }
            //}
            return false;
        }
Пример #5
0
        void drawLine(PointingDevice pd)
        {
            if (photos.Count == 0)
                return;
            if (pd.showTouchPie && strokeUnderDrawing.ContainsKey(pd))
            {
                strokeUnderDrawing.Remove(pd);
                return;
            }
            if (pd.RightButton == ButtonState.Pressed && pd.oldRightButton == ButtonState.Released && keyboard.ctrlKey)
            {
                pd.state = (int)PointingDevice.State.Cross;
                List<Stroke> s = strokeGroup.strokeList;
                for (int j = 0; j < s.Count; ++j)
                {
                    if (s[j].IsInternal(pd.GamePosition, s[j].Strokes))
                    {
                        strokeGroup.remove(s[j]);
                    }
                }
                return;
            }

            if (pd.RightButton == ButtonState.Released && pd.oldRightButton == ButtonState.Pressed)
            {
                pd.state = (int)PointingDevice.State.Curosr;
                return;
            }

            if (pd.LeftButton == ButtonState.Pressed && pd.oldLeftButton == ButtonState.Released)
            {
                //press left button, add stroke
                if (strokeUnderDrawing.ContainsKey(pd))
                {
                    strokeGroup.remove(strokeUnderDrawing[pd]);
                    strokeUnderDrawing.Remove(pd);
                }
                strokeUnderDrawing[pd] = strokeGroup.createStroke(pd.GamePosition);

            }
            else if (pd.LeftButton == ButtonState.Pressed && strokeUnderDrawing.ContainsKey(pd))
            {
                Stroke s = strokeUnderDrawing[pd];
                if ((s.Last - pd.GamePosition).Length() > Stroke.StrokeTh)
                {
                    // drag and draw
                    s.AddStroke(pd.GamePosition);
                }
            }

            else if(pd.LeftButton == ButtonState.Released && pd.oldLeftButton == ButtonState.Pressed)
            {
                if (strokeUnderDrawing.ContainsKey(pd))
                {
                    Stroke s = strokeUnderDrawing[pd];
                    if (!s.IsClosed)
                    {
                        if (s.Strokes.Count > 2)
                        {
                            //if >= 3 points
                            s.End();
                            //pdCollection.touchState = PieMenu.PieMode.MoveLine;
                            //create text box
                            strokeGroup.createTextBox(pd.GamePosition, s);
                        }
                        else
                        {
                            //less than 3 points
                            strokeGroup.remove(strokeUnderDrawing[pd]);
                        }
                    }
                    strokeUnderDrawing.Remove(pd);
                }

            }
        }
Пример #6
0
        void iconMouse(Icon icon, PointingDevice pd)
        {
            //show tips
            icon.tooltip.IsDel = false;

            if (pd.LeftButton == ButtonState.Pressed && pd.oldLeftButton == ButtonState.Released)
            {
                if (icon.Attractor == SystemState.ATTRACTOR_BOUND)
                {
                    systemState.SwapBound();
                    icon.IsOn = !icon.IsOn;
                }
                //else if (icon.Attractor == SystemState.ATTRACTOR_SCALEUP)
                //{
                //    systemState.SwapScaleUp();
                //    icon.IsOn = !icon.IsOn;
                //}
                else if (icon.Attractor == SystemState.ATTRACTOR_TIME)
                {
                    if (systemState.curState == SystemState.ATTRACTOR_GEOGRAPH)
                    {
                        systemState.SwapGeograph();
                        systemState.SwapScaleUp();
                        foreach (Icon ic in dock.Icons)
                        {
                            if (ic.Attractor == SystemState.ATTRACTOR_GEOGRAPH && ic.IsOn)
                            {
                                ic.IsOn = !ic.IsOn;
                                break;
                            }
                            if (ic.Attractor == SystemState.TOHOKU_MAP && ic.IsOn)
                            {
                                ic.IsOn = !ic.IsOn;
                                break;
                            }
                        }

                    }
                    systemState.SwapTime();
                    icon.IsOn = !icon.IsOn;
                }
                else if (icon.Attractor == SystemState.ATTRACTOR_GEOGRAPH)
                {
                    if (systemState.curState == SystemState.ATTRACTOR_TIME)
                    {
                        systemState.SwapTime();
                        foreach (Icon ic in dock.Icons)
                        {
                            if (ic.Attractor == SystemState.ATTRACTOR_TIME)
                            {
                                ic.IsOn = !ic.IsOn;
                                break;
                            }
                        }
                    }
                    icon.IsOn = !icon.IsOn;
                    if (icon.IsOn)
                    {
                        ResourceManager.IfTohoku = false;
                        if (systemState.curState != SystemState.ATTRACTOR_GEOGRAPH)
                        {
                            systemState.SwapGeograph();
                            systemState.SwapScaleUp();
                        }
                        else
                        {
                            foreach (Icon ic in dock.Icons)
                            {
                                if (ic.Attractor == SystemState.TOHOKU_MAP)
                                {
                                    ic.IsOn = !ic.IsOn;
                                    break;
                                }
                            }
                        }
                    }
                    else
                    {
                        systemState.SwapGeograph();
                        systemState.SwapScaleUp();
                    }

                }
                //tohoku map
                else if (icon.Attractor == SystemState.TOHOKU_MAP)
                {
                    if (systemState.curState == SystemState.ATTRACTOR_TIME)
                    {
                        systemState.SwapTime();
                        foreach (Icon ic in dock.Icons)
                        {
                            if (ic.Attractor == SystemState.ATTRACTOR_TIME)
                            {
                                ic.IsOn = !ic.IsOn;
                                break;
                            }
                        }
                    }
                    icon.IsOn = !icon.IsOn;
                    if (icon.IsOn)
                    {
                        ResourceManager.IfTohoku = true;
                        if (systemState.curState != SystemState.ATTRACTOR_GEOGRAPH)
                        {
                            systemState.SwapGeograph();
                            systemState.SwapScaleUp();
                        }
                        else
                        {
                            foreach (Icon ic in dock.Icons)
                            {
                                if (ic.Attractor == SystemState.ATTRACTOR_GEOGRAPH)
                                {
                                    ic.IsOn = !ic.IsOn;
                                    break;
                                }
                            }
                        }
                    }
                    else
                    {
                        systemState.SwapGeograph();
                        systemState.SwapScaleUp();
                    }

                }
                else if (icon.Attractor == SystemState.FILE_OPEN)
                {
                    FileOpenDialog dialog = new FileOpenDialog();
                    if (dialog.fileNames.Count > 0)
                    {
                        //photos_.Clear();
                        createPhoto.createPhoto(dialog.fileNames, 1);
                        //foreach(Photo p in createPhoto.photos)
                        //    photos[p.ID] = p;
                        photos = createPhoto.photos;
                        photoDisplayManager.PhotosToShow(photos);
                        strokeGroup.photos = photos;
                        strokeGroup.recalPhoto();
                    }
                    //icon.IsOn = !icon.IsOn;

                }

                else if (icon.Attractor == SystemState.MOVE)
                {
                    pdCollection.touchState = PieMenu.PieMode.DragPhoto;
                    dock.touchState = (pdCollection.touchState);
                }
                else if (icon.Attractor == SystemState.QUERY)
                {
                    pdCollection.touchState = PieMenu.PieMode.DrawLine;
                    dock.touchState = (pdCollection.touchState);
                }
                else if (icon.Attractor == SystemState.TRANSFORM)
                {
                    pdCollection.touchState = PieMenu.PieMode.MoveLine;
                    dock.touchState = (pdCollection.touchState);
                }
                else if (icon.Attractor == SystemState.DELETE)
                {
                    pdCollection.touchState = PieMenu.PieMode.DeletePhoto;
                    dock.touchState = (pdCollection.touchState);
                }
            }
        }
Пример #7
0
 private void deletePhoto(PointingDevice pd)
 {
     if (pd.LeftButton == ButtonState.Pressed && pd.oldLeftButton == ButtonState.Released)
     {
         foreach (Photo p in photos)
         {
             if (p.boundingBox_.Contains(pd.GamePosition) == ContainmentType.Contains)
             {
                 p.IsDel = true;
                 break;
             }
         }
         //if (pd.Type == PointingDevice.DeviceType.Touch)
         //{
         //    List<Stroke> s = strokeGroup.strokeList;
         //    for (int j = 0; j < s.Count; ++j)
         //    {
         //        if (s[j].touchDelete(pd))
         //        {
         //            pd.state = (int)PointingDevice.State.Cross;
         //            strokeGroup.remove(s[j]);
         //        }
         //        else
         //        {
         //            pd.state = (int)PointingDevice.State.Curosr;
         //        }
         //    }
         //}
     }
 }
        public bool remove(PointingDevice pd)
        {
            if (pd.Type == PointingDevice.DeviceType.Touch)
            {
                PieMenu pm = pd.getPieMenu();
                if (pm.IsShown)
                {
                    pd.RightButton = Microsoft.Xna.Framework.Input.ButtonState.Released;
                    return false;
                }
                //if(pd.countTouchTime < 50 && pd.getPieMenu().Mode == PieMenu.PieMode.MoveLine)

            }
            pointingDevices.Remove(pd);
            return true;
        }
 public void add(PointingDevice pd)
 {
     pointingDevices.Add(pd);
     //mouseMenu[pd] = new PieMenu();
 }
Пример #10
0
        //public bool touchDelete(PointingDevice pd)
        //{
        //    Vector2 ndist = Vector2.One * float.MaxValue;
        //    for (int k = 0, klen = Strokes.Count - 1; k < klen; ++k)
        //    {
        //        Vector2 dist = Strokes[k] - pd.GamePosition;
        //        if (dist.LengthSquared() < ndist.LengthSquared())
        //        {
        //            enlargeIndex = k;
        //            ndist = dist;
        //        }
        //    }
        //    if (ndist.Length() <= dragTh_)
        //    {
        //        return true;
        //    }
        //    return false;
        //}
        public int Interact(PointingDevice pd)
        {
            if (pointingDevice == null)
            {
                if (pd.LeftButton == ButtonState.Pressed && pd.oldLeftButton == ButtonState.Released)
                {
                    if (!IsClosed)
                    {
                        state = (int)StrokeState.NOTHING;
                        return state;
                    }
                    Vector2 ndist = Vector2.One * float.MaxValue;
                    for (int k = 0, klen = Strokes.Count - 1; k < klen; ++k)
                    {
                        Vector2 dist = Strokes[k] - pd.GamePosition;
                        if (dist.LengthSquared() < ndist.LengthSquared())
                        {
                            //dragSIndexes_[i][j] = k;
                            enlargeIndex = k;
                            ndist = dist;
                            //s[j].BeginMove();
                        }
                    }
                    if (ndist.Length() > dragTh_ && IsInternal(pd.GamePosition, strokes_))
                    {
                        BeginMove();
                        state = (int)Stroke.StrokeState.DragStroke;
                        pointingDevice = pd;
                    }
                    else if (ndist.Length() <= dragTh_)
                    {
                        state = (int)Stroke.StrokeState.ExpansionStroke;
                        pointingDevice = pd;
                    }
                }
            }
            else if (pointingDevice == pd)
            {
                // 左键移动锚点
                if (pd.LeftButton == ButtonState.Pressed)
                {
                    Vector2 mov = pd.GamePosition - pd.OldGamePosition;
                    if (state == (int)Stroke.StrokeState.DragStroke)
                    {

                        MoveStroke(mov);

                    }
                    else if (state == (int)Stroke.StrokeState.ExpansionStroke)
                    {
                        EnlargeStroke(enlargeIndex, mov);

                    }
                }
                else if (pd.LeftButton == ButtonState.Released && pd.oldLeftButton == ButtonState.Pressed)
                {
                    // 拖动结束
                    if (state == (int)Stroke.StrokeState.DragStroke)
                        EndMove();
                    pointingDevice = null;
                    state = (int)Stroke.StrokeState.NOTHING;
                }
            }
            return state;
        }
Пример #11
0
 public bool underMouse(PointingDevice pd)
 {
     foreach (var tb in StrokeBox.Values)
     {
         if (tb != null && tb.boundingBox.Contains(pd.GamePosition) == ContainmentType.Contains && tb.IsShown)
         {
             return true;
         }
     }
     foreach (var s in StrokeBox.Keys)
     {
         var box = s.boundingbox;
         if (box.Contains(pd.GamePosition) == ContainmentType.Contains)
         {
             if (pd.oldLeftButton == Microsoft.Xna.Framework.Input.ButtonState.Released && pd.LeftButton == Microsoft.Xna.Framework.Input.ButtonState.Pressed)
             {
                 s.deleteIcon = StrokeBox[s].showAgain(s.Strokes[s.Strokes.Count - 2]);
                 s.barBounding = new BoundingBox2D(s.deleteIcon, s.deleteIcon + new Vector2(ResourceManager.batsuTex_.Width, ResourceManager.batsuTex_.Height), 0);
             }
             return true;
         }
     }
     List<Stroke> sc = new List<Stroke>(StrokeBox.Keys);
     for (int i = 0; i < StrokeBox.Keys.Count; i++)
     {
         var s = sc[i];
         if (s.barBounding.Contains(pd.GamePosition) == ContainmentType.Contains)
         {
             if (pd.oldLeftButton == Microsoft.Xna.Framework.Input.ButtonState.Released && pd.LeftButton == Microsoft.Xna.Framework.Input.ButtonState.Pressed)
                 this.remove(s);
             return true;
         }
     }
     return false;
 }