Пример #1
0
        private void GroupExecuted(object sender, ExecutedRoutedEventArgs e)
        {
            var items = from item in this.SelectionService.CurrentSelection.OfType <DesktopElement>()
                        select item;

            ShortcutGroupElement   group = new ShortcutGroupElement();
            ShortcutGroupViewModel vm    = new ShortcutGroupViewModel();
            Point position = items.First().GetPosition();

            foreach (DesktopElement item in items)
            {
                vm.Shortcuts.Add(item.DataContext as IShortcutViewModel);

                this.RemoveElement(item);
            }

            group.DataContext = vm;

            this.SelectionService.ClearSelection();

            this.InvokeAsynchronouslyInBackground
            (
                () =>
            {
                this.AddElement(group, position);
            }
            );
        }
Пример #2
0
        public ShortcutsViewModel(ISaveKh3 save)
        {
            _save     = save;
            Shortcut1 = new ShortcutGroupViewModel(_save, 0);
            Shortcut2 = new ShortcutGroupViewModel(_save, 1);
            Shortcut3 = new ShortcutGroupViewModel(_save, 2);

            Magic1 = new ItemComboBoxModel <CommandType>(() => save.Magics[0], x => save.Magics[0] = x);
            Magic2 = new ItemComboBoxModel <CommandType>(() => save.Magics[1], x => save.Magics[1] = x);
            Magic3 = new ItemComboBoxModel <CommandType>(() => save.Magics[2], x => save.Magics[2] = x);
            Magic4 = new ItemComboBoxModel <CommandType>(() => save.Magics[3], x => save.Magics[3] = x);
            Magic5 = new ItemComboBoxModel <CommandType>(() => save.Magics[4], x => save.Magics[4] = x);
            Magic6 = new ItemComboBoxModel <CommandType>(() => save.Magics[5], x => save.Magics[5] = x);
            Link1  = new ItemComboBoxModel <CommandType>(() => save.Links[0], x => save.Links[0] = x);
            Link2  = new ItemComboBoxModel <CommandType>(() => save.Links[1], x => save.Links[1] = x);
            Link3  = new ItemComboBoxModel <CommandType>(() => save.Links[2], x => save.Links[2] = x);
            Link4  = new ItemComboBoxModel <CommandType>(() => save.Links[3], x => save.Links[3] = x);
            Link5  = new ItemComboBoxModel <CommandType>(() => save.Links[4], x => save.Links[4] = x);
        }