Beispiel #1
0
        public OutputLine(string name, string section, int index, BaseVM vm, string location)
        {
            this.name     = name;
            this.Index    = index;
            this.Parent   = vm;
            this.section  = section;
            this.Location = location;

            CommonBaseVM commonVm = this.Parent as CommonBaseVM;

            this.DeleteCmd = new Command(() =>
            {
                if (this.Valid)
                {
                    this.Delete(null, null);
                }
                else
                {
                    this.Valid = true;
                    commonVm.EnableLine(this);
                }
                this.RaiseChanges();

                if (this.Previous != null)
                {
                    this.Previous.RaiseChanges();
                }

                if (this.Next != null)
                {
                    this.Next.RaiseChanges();
                }
            });

            this.OnDragCmd = new Command((arg) =>
            {
                SwipeType?swipe = arg as SwipeType?;
                if ((swipe.Value & SwipeType.Up) != 0)
                {
                    this.CommonVM.Order.MoveOutputLine(this, -1, SwipeType.Up);
                }
                else if ((swipe.Value & SwipeType.Down) != 0)
                {
                    this.CommonVM.Order.MoveOutputLine(this, -1, SwipeType.Down);
                }
                else if ((swipe.Value & SwipeType.Left) != 0)
                {
                    this.CommonVM.Order.MoveOutputLine(this, -1, SwipeType.Up);
                }
                else if ((swipe.Value & SwipeType.Right) != 0)
                {
                    this.CommonVM.Order.MoveOutputLine(this, -1, SwipeType.Down);
                }

                commonVm.RaiseChanges();
            });
        }
Beispiel #2
0
        public static System.Windows.Input.ICommand GetMoveSectionCmd(CommonBaseVM vm, IOrdered line)
        {
            return(new Command((arg) =>
            {
                line.TimeStamp = DateTime.Now;

                Task.Factory.StartNew(() => Task.Delay(3000))
                .ContinueWith((t, x) =>
                {
                    if ((DateTime.Now.Subtract((x as IOrdered).TimeStamp).TotalSeconds > 3))
                    {
                        (x as IOrdered).OrderImageName = "empty.png";
                    }
                },
                              line);


                SwipeAction swipe = (arg as SwipeAction?).Value;
                SwipeType swipeType = SwipeType.None;
                if ((swipe.Type & SwipeType.Up) != 0 || (swipe.Type & SwipeType.Left) != 0)
                {
                    line.OrderImageName = "up.png";
                    swipeType = SwipeType.Up;
                }
                else if ((swipe.Type & SwipeType.Down) != 0 || (swipe.Type & SwipeType.Right) != 0)
                {
                    line.OrderImageName = "down.png";
                    swipeType = SwipeType.Down;
                }
                else
                {
                    line.OrderImageName = "empty.png";
                }

                if (swipe.Finished)
                {
                    vm.Order.MoveOutputLine(line, -1, swipeType);
                    line.OrderImageName = "empty.png";
                }

                vm.RaiseChanges();
            }));
        }