public CreateFileViewModel()
        {
            OkCommand = new RelayCommand(p =>
            {
                var pw     = ((PasswordBox)p).Password;
                var result = new LockerObject {
                    name = Name, encrypted = Encrypt && !string.IsNullOrEmpty(pw)
                };
                CompleteAction?.Invoke(result, _file, pw);
                _file        = null;
                OpenFileText = Resources.OpenFile;
            }, DataValid);

            CancelCommand = new RelayCommand(p =>
            {
                CompleteAction?.Invoke(null, null, null);
            });

            OpenFileCommand = new RelayCommand(OpenFile);
        }
Пример #2
0
        public override void Process()
        {
            Point location = Target?.CurrentLocation ?? MapTarget;

            if (location == Origin)
            {
                CompleteAction?.Invoke();
                Remove();
                return;
            }

            int x = (Origin.X - MapObject.User.CurrentLocation.X + MapObject.OffSetX) * MapObject.CellWidth - MapObject.User.MovingOffSet.X;
            int y = (Origin.Y - MapObject.User.CurrentLocation.Y + MapObject.OffSetY) * MapObject.CellHeight - MapObject.User.MovingOffSet.Y;

            int x1 = (location.X - MapObject.User.CurrentLocation.X + MapObject.OffSetX) * MapObject.CellWidth - MapObject.User.MovingOffSet.X;
            int y1 = (location.Y - MapObject.User.CurrentLocation.Y + MapObject.OffSetY) * MapObject.CellHeight - MapObject.User.MovingOffSet.Y;

            Direction16 = Functions.Direction16(new Point(x, y / 32 * 48), new Point(x1, y1 / 32 * 48));
            long duration = Functions.Distance(new Point(x, y / 32 * 48), new Point(x1, y1 / 32 * 48)) * TimeSpan.TicksPerMillisecond;

            if (!Has16Directions)
            {
                Direction16 /= 2;
            }

            if (duration == 0)
            {
                CompleteAction?.Invoke();
                Remove();
                return;
            }

            int x2 = x1 - x;
            int y2 = y1 - y;

            if (x2 == 0)
            {
                x2 = 1;
            }
            if (y2 == 0)
            {
                y2 = 1;
            }

            TimeSpan time = CEnvir.Now - StartTime;

            int frame = GetFrame();

            if (Reversed)
            {
                frame = FrameCount - frame - 1;
            }

            DrawFrame = frame + StartIndex + Direction16 * Skip;

            DrawX = x + (int)(time.Ticks / (duration / x2)) + AdditionalOffSet.X;
            DrawY = y + (int)(time.Ticks / (duration / y2)) + AdditionalOffSet.Y;

            if (_particleEmitter != null)
            {
                Point offset = Library.GetOffSet(DrawFrame);

                _particleEmitter.SetLocation(Direction16, DrawX + offset.X, DrawY + offset.Y);
            }

            if ((CEnvir.Now - StartTime).Ticks > duration)
            {
                if (Target == null && !Explode)
                {
                    Size s = Library.GetSize(FrameIndex);

                    if (DrawX + s.Width > 0 && DrawX < GameScene.Game.Size.Width &&
                        DrawY + s.Height > 0 && DrawY < GameScene.Game.Size.Height)
                    {
                        return;
                    }
                }

                CompleteAction?.Invoke();
                Remove();
                return;
            }
        }