Ejemplo n.º 1
0
    void ZoomCamera()
    {
        ZoomCommand zoom = inputs.ZoomInputHandler();

        zoom.setSensitivity(ZoomSpeed);
        zoom.Execute(gameObject);
    }
 private void InitCommands()
 {
     OpenCommand              = new OpenCommand(this);
     ApplyCommand             = new ApplyCommand(this);
     FlipCommand              = new FlipCommand(this);
     HistogramEqualizeCommand = new HistogramEqualizeCommand(this);
     HistogramStretchCommand  = new HistogramStretchCommand(this);
     CropCommand              = new CropCommand(this);
     InpaintCommand           = new InpaintCommand(this);
     ResizeCommand            = new ResizeCommand(this);
     RotateCommand            = new RotateCommand(this);
     SaveAsCommand            = new SaveAsCommand(this);
     SaveCommand              = new SaveCommand(this);
     ZoomCommand              = new ZoomCommand(this);
     ResetCommand             = new ResetCommand(this);
     CloseCommand             = new CloseCommand(this);
     SelectToolCommand        = new SelectToolCommand(this);
     UndoCommand              = new UndoCommand(this);
     RedoCommand              = new RedoCommand(this);
     DropboxCommand           = new DropboxCommand(this);
     DownloadCommand          = new DownloadCommand(this);
     UploadCommand            = new UploadCommand(this);
     DCommand       = new DCommand(this);
     ECommand       = new ECommand(this);
     PrewittCommand = new PrewittCommand(this);
 }
Ejemplo n.º 3
0
 public override void _presenter_MouseLeftButtonUp(object sender, System.Windows.Input.MouseButtonEventArgs e)
 {
     if (_startPoint != null)
     {
         Point       cur     = e.GetPosition(_inkCanvas);
         StylusPoint current = new StylusPoint(cur.X, cur.Y);
         double      dist1   = MathTool.getInstance().distanceP2P(center, current);
         double      dist2   = MathTool.getInstance().distanceP2P(center, _startPoint);
         double      scaling = dist1 / dist2;
         if (selectedStrokes.Count > 0)   //笔迹处理
         {
             foreach (MyStroke myStroke in selectedStrokes)
             {
                 ZoomCommand zc = new ZoomCommand(myStroke, scaling);
                 _inkCollector.CommandStack.Push(zc);
             }
         }
         if (selectedImages.Count > 0)    //图片处理
         {
             foreach (MyImage image in selectedImages)
             {
                 ImageZoomCommand izc = new ImageZoomCommand(image, scaling);
                 _inkCollector.CommandStack.Push(izc);
                 foreach (ImageConnector connector in image.ConnectorCollection)
                 {
                     connector.adjustConnector();
                 }
             }
         }
         if (selectedButtons.Count > 0)    //button处理
         {
             int i = 0;
             foreach (MyButton myButton in selectedButtons)
             {
                 ButtonZoomCommand bzc = new ButtonZoomCommand(myButton, scaling, _inkCollector, preMyButtonInkFrameList[i]);
                 _inkCollector.CommandStack.Push(bzc);
                 i++;
             }
         }
     }
     _inkCanvas.ReleaseMouseCapture();
     pressedMouseLeftButtonDown = false;
 }
Ejemplo n.º 4
0
 protected void Zoom(ZoomDirection direction, double amount, Point center)
 {
     ZoomCommand?.Execute(direction, amount, center);
 }
Ejemplo n.º 5
0
 /// <summary>
 /// モーションズームする値を設定する
 /// </summary>
 /// <param name="pane"></param>
 /// <param name="zoom"></param>
 /// <param name="step"></param>
 public void SetMotionZoomValue(IRichPane pane, XyBase zoom, int step)
 {
     _motionZoom[pane] = new ZoomCommand(zoom, step);
 }
Ejemplo n.º 6
0
        public override void Update(long gameTime, NamelessGame namelessGame)
        {
            foreach (IEntity entity in RegisteredEntities)
            {
                InputComponent inputComponent = entity.GetComponentOfType <InputComponent>();
                if (inputComponent != null)
                {
                    var playerEntity = namelessGame.PlayerEntity;
                    foreach (Intent intent in inputComponent.Intents)
                    {
                        switch (intent.Intention)
                        {
                        case IntentEnum.MoveUp:
                        case IntentEnum.MoveDown:
                        case IntentEnum.MoveLeft:
                        case IntentEnum.MoveRight:
                        case IntentEnum.MoveTopLeft:
                        case IntentEnum.MoveTopRight:
                        case IntentEnum.MoveBottomLeft:
                        case IntentEnum.MoveBottomRight:
                        {
                            Position position     = playerEntity.GetComponentOfType <Position>();
                            var      actionPoints = playerEntity.GetComponentOfType <ActionPoints>();
                            if (position != null && actionPoints.Points >= 100)
                            {
                                int newX =
                                    intent.Intention == IntentEnum.MoveLeft || intent.Intention == IntentEnum.MoveBottomLeft ||
                                    intent.Intention == IntentEnum.MoveTopLeft ? position.Point.X - 1 :
                                    intent.Intention == IntentEnum.MoveRight || intent.Intention == IntentEnum.MoveBottomRight ||
                                    intent.Intention == IntentEnum.MoveTopRight ? position.Point.X + 1 :
                                    position.Point.X;
                                int newY =
                                    intent.Intention == IntentEnum.MoveDown || intent.Intention == IntentEnum.MoveBottomLeft ||
                                    intent.Intention == IntentEnum.MoveBottomRight ? position.Point.Y - 1 :
                                    intent.Intention == IntentEnum.MoveUp || intent.Intention == IntentEnum.MoveTopLeft ||
                                    intent.Intention == IntentEnum.MoveTopRight ? position.Point.Y + 1 :
                                    position.Point.Y;

                                IEntity        worldEntity   = namelessGame.TimelineEntity;
                                IWorldProvider worldProvider = null;
                                if (worldEntity != null)
                                {
                                    worldProvider = worldEntity.GetComponentOfType <TimeLine>().CurrentTimelineLayer.Chunks;
                                }

                                Tile tileToMoveTo = worldProvider.GetTile(newX, newY);


                                IEntity entityThatOccupiedTile = null;
                                foreach (IEntity tileEntity in tileToMoveTo.GetEntities())
                                {
                                    OccupiesTile occupiesTile =
                                        tileEntity.GetComponentOfType <OccupiesTile>();
                                    if (occupiesTile != null)
                                    {
                                        entityThatOccupiedTile = tileEntity;
                                        break;
                                    }
                                }


                                if (entityThatOccupiedTile != null)
                                {
                                    Door      door = entityThatOccupiedTile.GetComponentOfType <Door>();
                                    Character characterComponent =
                                        entityThatOccupiedTile.GetComponentOfType <Character>();
                                    if (door != null)
                                    {
                                        SimpleSwitch simpleSwitch =
                                            entityThatOccupiedTile.GetComponentOfType <SimpleSwitch>();
                                        if (simpleSwitch != null == simpleSwitch.isSwitchActive())
                                        {
                                            entityThatOccupiedTile.GetComponentOfType <Drawable>()
                                            .Representation = 'o';
                                            entityThatOccupiedTile.RemoveComponentOfType <BlocksVision>();
                                            entityThatOccupiedTile.RemoveComponentOfType <OccupiesTile>();

                                            namelessGame.Commander.EnqueueCommand(
                                                new ChangeSwitchStateCommand(simpleSwitch, false));
                                            var ap = playerEntity.GetComponentOfType <ActionPoints>();
                                            ap.Points -= Constants.ActionsMovementCost;
                                            //   playerEntity.RemoveComponentOfType<HasTurn>();
                                        }
                                        else
                                        {
                                            worldProvider.MoveEntity(playerEntity,
                                                                     new Point(newX, newY));
                                            var ap = playerEntity.GetComponentOfType <ActionPoints>();
                                            ap.Points -= Constants.ActionsMovementCost;
                                        }
                                    }

                                    if (characterComponent != null)
                                    {
                                        //TODO: if hostile
                                        namelessGame.Commander.EnqueueCommand(new AttackCommand(playerEntity,
                                                                                                entityThatOccupiedTile));

                                        var ap = playerEntity.GetComponentOfType <ActionPoints>();
                                        ap.Points -= Constants.ActionsAttackCost;
                                        // playerEntity.RemoveComponentOfType<HasTurn>();

                                        //TODO: do something else if friendly: chat, trade, etc
                                    }
                                }
                                else
                                {
                                    worldProvider.MoveEntity(playerEntity,
                                                             new Point(newX, newY));
                                    var ap = playerEntity.GetComponentOfType <ActionPoints>();
                                    ap.Points -= Constants.ActionsMovementCost;
                                }
                            }
                        }

                        break;

                        case IntentEnum.LookAtMode:
                            //InputReceiver receiver = new InputReceiver();
                            //Player player = entity.GetComponentOfType<Player>();
                            //cursor = entity.GetComponentOfType<Cursor>();
                            //entity.RemoveComponentOfType<InputReceiver>();
                            //if (player != null)
                            //{
                            //    IEntity cursorEntity = namelessGame.CursorEntity;
                            //    cursorEntity.AddComponent(receiver);
                            //    Drawable cursorDrawable = cursorEntity.GetComponentOfType<Drawable>();
                            //    cursorDrawable.setVisible(true);
                            //    Position cursorPosition = cursorEntity.GetComponentOfType<Position>();
                            //    Position playerPosition = entity.GetComponentOfType<Position>();
                            //    cursorPosition.p.X = (playerPosition.p.X);
                            //    cursorPosition.p.Y = (playerPosition.p.Y);

                            //}
                            //else if (cursor != null)
                            //{
                            //    IEntity playerEntity = namelessGame.PlayerEntity;
                            //    playerEntity.AddComponent(receiver);
                            //    Drawable cursorDrawable = entity.GetComponentOfType<Drawable>();
                            //    cursorDrawable.setVisible(false);

                            //}

                            break;

                        case IntentEnum.PickUpItem:
                        {
                            var actionPoints = playerEntity.GetComponentOfType <ActionPoints>();

                            if (actionPoints.Points >= 100)
                            {
                                IEntity        worldEntity   = namelessGame.TimelineEntity;
                                IWorldProvider worldProvider = null;
                                if (worldEntity != null)
                                {
                                    worldProvider = worldEntity.GetComponentOfType <TimeLine>().CurrentTimelineLayer
                                                    .Chunks;
                                }


                                var position   = playerEntity.GetComponentOfType <Position>();
                                var itemHolder = playerEntity.GetComponentOfType <ItemsHolder>();
                                var tile       = worldProvider.GetTile(position.Point.X, position.Point.Y);

                                List <IEntity> itemsToPickUp = new List <IEntity>();
                                foreach (var entityOnTIle in tile.GetEntities())
                                {
                                    var itemComponent = entityOnTIle.GetComponentOfType <Item>();
                                    if (itemComponent != null)
                                    {
                                        itemsToPickUp.Add(entityOnTIle);
                                    }
                                }

                                if (itemsToPickUp.Any())
                                {
                                    if (itemsToPickUp.Count > 1)
                                    {
                                        namelessGame.ContextToSwitch =
                                            ContextFactory.GetPickUpItemContext(namelessGame);
                                        UiFactory.PickUpItemsScreen.FillItems(namelessGame);
                                        if (UiFactory.PickUpItemsScreen.ItemsTable.Items.Any())
                                        {
                                            UiFactory.PickUpItemsScreen.ItemsTable.SelectedIndex = 0;
                                        }
                                    }
                                    else
                                    {
                                        StringBuilder builder      = new StringBuilder();
                                        var           itemsCommand = new PickUpItemCommand(itemsToPickUp, itemHolder,
                                                                                           position.Point);
                                        namelessGame.Commander.EnqueueCommand(itemsCommand);

                                        foreach (var entity1 in itemsToPickUp)
                                        {
                                            var desc = entity1.GetComponentOfType <Description>();
                                            if (desc != null)
                                            {
                                                builder.Append($"Picked up: {desc.Name} \n");
                                            }
                                        }

                                        var logCommand = new HudLogMessageCommand();
                                        logCommand.LogMessage += builder.ToString();
                                        namelessGame.Commander.EnqueueCommand(logCommand);
                                    }

                                    var ap = playerEntity.GetComponentOfType <ActionPoints>();
                                    ap.Points -= Constants.ActionsPickUpCost;
                                    //playerEntity.RemoveComponentOfType<HasTurn>();
                                }
                            }

                            break;
                        }

                        case IntentEnum.SkipTurn:
                        {
                            var actionPoints = playerEntity.GetComponentOfType <ActionPoints>();

                            if (actionPoints.Points >= 100)
                            {
                                var ap = entity.GetComponentOfType <ActionPoints>();
                                ap.Points -= Constants.ActionsMovementCost;
                                var logCommand = new HudLogMessageCommand();
                                logCommand.LogMessage += "Waiting";
                                namelessGame.Commander.EnqueueCommand(logCommand);

                                //   playerEntity.RemoveComponentOfType<HasTurn>();
                            }
                        }
                        break;

                        case IntentEnum.Quicksave:
                            namelessGame.ScheduleSave();
                            break;

                        case IntentEnum.Quickload:
                            namelessGame.ScheduleLoad();
                            break;

                        case IntentEnum.ZoomIn:
                            var zoomCommand = new ZoomCommand(false);
                            namelessGame.Commander.EnqueueCommand(zoomCommand);
                            break;

                        case IntentEnum.ZoomOut:
                            var zoomOutCommand = new ZoomCommand();
                            namelessGame.Commander.EnqueueCommand(zoomOutCommand);
                            break;

                        default:
                            break;
                        }
                    }

                    inputComponent.Intents.Clear();
                }
            }
        }
Ejemplo n.º 7
0
 private void OnSliderValueChanged(object sender, RoutedPropertyChangedEventArgs <double> e)
 {
     ZoomCommand?.Execute(e.NewValue);
 }
Ejemplo n.º 8
0
 public override void _presenter_MouseMove(object sender, System.Windows.Input.MouseEventArgs e)
 {
     if (pressedMouseLeftButtonDown)
     {
         Point       cur     = e.GetPosition(_inkCanvas);
         StylusPoint current = new StylusPoint(cur.X, cur.Y);
         double      dist1   = MathTool.getInstance().distanceP2P(center, current);
         double      dist2   = MathTool.getInstance().distanceP2P(center, _prepoint);
         if (dist2 == 0)
         {
             dist2 = 1;
         }
         double scaling = dist1 / dist2;
         if (selectedStrokes.Count > 0)   //笔迹处理
         {
             foreach (MyStroke myStroke in selectedStrokes)
             {
                 ZoomCommand zc = new ZoomCommand(myStroke, scaling);
                 zc.execute();
             }
         }
         if (selectedImages.Count > 0)    //图片处理
         {
             foreach (MyImage image in selectedImages)
             {
                 ImageZoomCommand izc = new ImageZoomCommand(image, scaling);
                 izc.execute();
                 image.adjustBound();
                 foreach (ImageConnector connector in image.ConnectorCollection)
                 {
                     connector.adjustConnector();
                 }
             }
         }
         if (selectedButtons.Count > 0)    //button处理
         {
             foreach (MyButton myButton in selectedButtons)
             {
                 ButtonZoomCommand bzc = new ButtonZoomCommand(myButton, scaling, _inkCollector, 1);
                 bzc.execute();
             }
         }
         //piemenu移动
         double dist3 = MathTool.getInstance().distanceP2P(center, current);
         double dist4 = MathTool.getInstance().distanceP2P(center, _startPoint);
         if (dist4 == 0)
         {
             dist4 = 1;
         }
         double scaling2 = dist3 / dist4;
         _inkCollector._mainPage.OperatePieMenu.Margin = new System.Windows.Thickness(_inkCollector.BoundSelect.Margin.Left + _inkCollector.BoundSelect.Width * scaling2, _inkCollector._mainPage.OperatePieMenu.Margin.Top, 0, 0);
         if (_inkCollector._mainPage.OperatePieMenu.Margin.Top < _inkCanvas.Margin.Top)       //上面
         {
             _inkCollector._mainPage.OperatePieMenu.Margin = new Thickness(_inkCollector._mainPage.OperatePieMenu.Margin.Left, 10, 0, 0);
         }
         //右边
         if (_inkCollector._mainPage.OperatePieMenu.Margin.Left > _inkCanvas.Margin.Left + _inkCanvas.ActualWidth - _inkCollector._mainPage.OperatePieMenu.ActualWidth)
         {
             _inkCollector._mainPage.OperatePieMenu.Margin = new Thickness(_inkCanvas.Margin.Left + _inkCanvas.ActualWidth - _inkCollector._mainPage.OperatePieMenu.ActualWidth, _inkCollector._mainPage.OperatePieMenu.Margin.Top, 0, 0);
         }
         _prepoint = current;
     }
 }
Ejemplo n.º 9
0
 public ImageData()
 {
     _openImageFileCommand = new OpenImageFileCommand(this);
     _zoomCommand          = new ZoomCommand(this);
 }
Ejemplo n.º 10
0
        protected override void StartMove(Selection sel)
        {
            Drawable          drawable = null;
            SelectionPosition pos = SelectionPosition.BottomRight;
            bool resize = true, copycolor = true, sele = true;

            if (Tool == DrawTool.Selection)
            {
                if (Selections.Count == 0 && currentZoom != 1)
                {
                    widget.SetCursorForTool(DrawTool.Move);
                    inZooming = true;
                }
                return;
            }

            if (sel != null)
            {
                ClearSelection();
            }

            switch (Tool)
            {
            case DrawTool.Line:
                drawable = new Line(MoveStart, new Point(MoveStart.X + 1, MoveStart.Y + 1),
                                    LineType, LineStyle);
                drawable.FillColor = Color;
                pos = SelectionPosition.LineStop;
                break;

            case DrawTool.Cross:
                drawable = new Cross(MoveStart, new Point(MoveStart.X + 1, MoveStart.Y + 1),
                                     LineStyle);
                break;

            case DrawTool.Ellipse:
                drawable = new Ellipse(MoveStart, 2, 2);
                break;

            case DrawTool.Rectangle:
                drawable = new Rectangle(MoveStart, 2, 2);
                break;

            case DrawTool.CircleArea:
                drawable           = new Ellipse(MoveStart, 2, 2);
                drawable.FillColor = Color.Copy();
                break;

            case DrawTool.RectangleArea:
                drawable           = new Rectangle(MoveStart, 2, 2);
                drawable.FillColor = Color.Copy();
                break;

            case DrawTool.Counter:
                drawable           = new Counter(MoveStart, 3 * LineWidth, 0);
                drawable.FillColor = Color.Copy();
                (drawable as Counter).TextColor = TextColor.Copy();
                resize = false;
                break;

            case DrawTool.Text:
            case DrawTool.Player: {
                int  width, heigth;
                Text text = new Text(MoveStart, 1, 1, "");
                if (ConfigureObjectEvent != null)
                {
                    ConfigureObjectEvent(text, Tool);
                }
                if (text.Value == null)
                {
                    return;
                }
                App.Current.DrawingToolkit.MeasureText(text.Value, out width, out heigth,
                                                       App.Current.Style.Font, FontSize, FontWeight.Normal);
                text.Update(new Point(MoveStart.X, MoveStart.Y + heigth / 2),
                            width, heigth);
                text.TextColor = TextColor.Copy();
                text.FillColor = text.StrokeColor = TextBackgroundColor.Copy();
                text.TextSize  = FontSize;
                resize         = copycolor = sele = false;
                drawable       = text;
                break;
            }

            case DrawTool.Pen:
            case DrawTool.Eraser:
                handdrawing = true;
                break;

            case DrawTool.Zoom: {
                double newZoom = currentZoom;

                if (modifier == ButtonModifier.Shift)
                {
                    newZoom -= 0.1;
                }
                else
                {
                    newZoom += 0.1;
                }
                newZoom = Math.Max(newZoom, MinZoom);
                newZoom = Math.Min(newZoom, MaxZoom);
                //FIXME: When Commands accepts more than one arguments it should pass MoveStart
                // to the list of arguments and remove centerZoom
                centerZoom = MoveStart;
                ZoomCommand.Execute(newZoom);
                break;
            }
            }

            if (drawable != null)
            {
                if (copycolor)
                {
                    drawable.StrokeColor = Color.Copy();
                }
                if (!(Tool.Equals(DrawTool.RectangleArea) ||
                      Tool.Equals(DrawTool.CircleArea)))
                {
                    drawable.LineWidth = LineWidth;
                }
                drawable.Style = LineStyle;
                var selo = Add(drawable);
                drawing.Drawables.Add(drawable);
                if (Tool == DrawTool.Counter)
                {
                    UpdateCounters();
                }
                if (sele)
                {
                    if (resize)
                    {
                        UpdateSelection(new Selection(selo, pos, 5));
                    }
                    else
                    {
                        UpdateSelection(new Selection(selo, SelectionPosition.All, 5));
                    }
                    inObjectCreation = true;
                }
                widget.ReDraw();
            }
        }