Ejemplo n.º 1
0
 public static System.Windows.Input.ICommand GetDelLineCmd(CommonBaseVM vm, OutputLine key)
 {
     return(new Command(() =>
     {
         vm.DeleteOutputLine(vm.OutputList.FirstOrDefault(x => x.Name == key.Name));
     }));
 }
Ejemplo n.º 2
0
 public static System.Windows.Input.ICommand GetDelInputLineCmd(CommonBaseVM vm, Item key)
 {
     return(new Command(() =>
     {
         vm.InputList.Remove(key);
     }));
 }
Ejemplo n.º 3
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();
            });
        }
Ejemplo n.º 4
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();
            }));
        }
Ejemplo n.º 5
0
        public List <OutputLine> SortInputList(List <Item> input, CommonBaseVM vm)
        {
            StoreFactory.CurrentStore = this;
            List <Item> output = new List <Item>();

            foreach (var it in input.Distinct(new ItemComparer()))
            {
                if (output.Count == 0)
                {
                    output.Insert(0, it);
                }
                else
                {
                    int ix = -1;
                    for (int i = 0; i < output.Count; i++)
                    {
                        if (it.Link.Id < output[i].Link.Id)
                        {
                            ix = i;
                            break;
                        }
                    }
                    if (ix < 0)
                    {
                        output.Add(it);
                    }
                    else
                    {
                        output.Insert(ix, it);
                    }
                }
            }

            int k = 0;

            return(output.Select(x => new OutputLine(x.Name, x.Link.Name, k++, vm, "(" + this.GetLocationForItem(x).Text + ")")).ToList());
        }
Ejemplo n.º 6
0
        public List <Item> InitInput(IList <string> input, bool removeDuplicities = true, CommonBaseVM vm = null, bool clean = true)
        {
            List <Item>          ret  = new List <Item>();
            IEnumerable <string> list = removeDuplicities ? input.Distinct() : input.AsEnumerable();

            foreach (var expr in list)
            {
                var item = this.GetItem(expr, true);
                item.Link.ItemLinks.Add(item.Id);
                ret.Add(item);
            }

            if (vm != null)
            {
                if (clean)
                {
                    vm.InputList.Clear();
                }

                foreach (var it in ret)
                {
                    vm.AddItemWithLocationInit(it);
                }
            }
            return(ret);
        }