コード例 #1
0
        public void UngroupSelectedBlocks()
        {
            using (ActionManager.CreateTransaction())
            {
                foreach (var groupVM in SelectedBlocks.OfType <GroupBlockViewModel>().ToArray())
                {
                    SelectedBlocks.Remove(groupVM);

                    GroupBlock group = (GroupBlock)groupVM.GetModel();
                    ActionManager.RecordRemove(model.Blocks, group);

                    foreach (Block b in group.Children.ToArray())
                    {
                        // create an independent copy of the block so transforming its time back to global reference frame does not screw up undo
                        Block independentBlock = Block.FromXML(model, b.ToXML());

                        independentBlock.StartTime += group.StartTime;
                        ActionManager.RecordRemove(group.Children, b);
                        ActionManager.RecordAdd(model.Blocks, independentBlock);

                        SelectBlock(BlockViewModel.FromModel(this, independentBlock), CompositionMode.Additive);
                    }
                }
            }
        }
コード例 #2
0
        // ===== Commands =====


        public void SelectBlock(BlockViewModel block, CompositionMode compositionMode)
        {
            Debug.WriteLine("single select (mode: {0}, block: {1})", compositionMode, block);

            switch (compositionMode)
            {
            case CompositionMode.None:
                SelectedBlocks.Clear();
                if (block != null && !SelectedBlocks.Contains(block))
                {
                    SelectedBlocks.Add(block);
                }
                break;

            case CompositionMode.Additive:
                if (block != null && !SelectedBlocks.Contains(block))
                {
                    SelectedBlocks.Add(block);
                }
                break;

            case CompositionMode.Subtractive:
                if (block != null)
                {
                    SelectedBlocks.Remove(block);
                }
                break;
            }
        }
コード例 #3
0
        private void RemoveDrop(object sender, DragEventArgs e)
        {
            var source = (Block)e.Data.GetData(typeof(Block));

            if (source.Count != 0)
            {
                SelectedBlocks.Remove(source);
                UpdateString();
            }
        }
コード例 #4
0
        private void RemoveButton_Click(object sender, RoutedEventArgs e)
        {
            var selected = new object[selectedBlockList.SelectedItems.Count];

            selectedBlockList.SelectedItems.CopyTo(selected, 0);
            foreach (var block in selected)
            {
                SelectedBlocks.Remove((Block)block);
            }
            selectedBlockList.UnselectAll();
            UpdateString();
        }
コード例 #5
0
        private void SelectUnselectedBlock(TimetableBlock block)
        {
            var timetableBlock = Timetable.Blocks.SingleOrDefault(b => b.StartDate == block.StartDate);

            if (CheckSelection(block))
            {
                SelectedBlocks.Remove(block);
                timetableBlock.WorkItem = null;
            }
            else
            {
                SelectedBlocks.Add(block);
            }
        }
コード例 #6
0
        private void RemoveSelected(object sender, KeyEventArgs e)
        {
            if (e.Key != Key.Delete)
            {
                return;
            }

            var selected = new object[selectedBlockList.SelectedItems.Count];

            selectedBlockList.SelectedItems.CopyTo(selected, 0);
            foreach (var block in selected)
            {
                SelectedBlocks.Remove((Block)block);
            }
            selectedBlockList.UnselectAll();
            UpdateString();
        }