예제 #1
0
        private BlockList(BlockList Owner)
        {
            InitializeComponent();

            this.Owner = Owner;
            if (Owner != null)
            {
                groupLevel = Owner.groupLevel + 1;
            }

            UpdateBrushes();
            Clear();
        }
예제 #2
0
        private void OnSelectionChanged(object sender, SelectionChangedEventArgs e)
        {
            if (Owner != null && Owner.listBlocks.SelectedItems.Count > 1 && ParentGroup != null)
            {
                Owner.listBlocks.SelectedItem = ParentGroup.BlockItem;
            }

            bool groupOpen = false;

            if (listBlocks.SelectedItems.Count == 1)
            {
                IBlock block = (IBlock)((ListBoxItem)listBlocks.SelectedItem).Tag;
                if (block is IBlockGroup)
                {
                    if (GroupList == null)
                    {
                        GroupList           = new BlockList(this);
                        ccGroupList.Content = GroupList;
                    }
                    GroupList.ParentGroup = (IBlockGroup)block;
                    bdrBar.Background     = SelectedBrush;
                    BlockList owner = Owner;
                    while (owner != null)
                    {
                        owner.bdrBar.Background = UnselectedBrush;
                        owner = owner.Owner;
                    }
                    SplitterOpen = true;
                    groupOpen    = true;
                }
            }

            if (!groupOpen && GroupList != null)
            {
                GroupList.ParentGroup = null;
                bdrBar.Background     = UnselectedBrush;
                if (Owner != null)
                {
                    Owner.bdrBar.Background = SelectedBrush;
                }
            }

            if (SelectionChanged != null)
            {
                SelectionChanged(this, new EventArgs());
            }
        }
예제 #3
0
        public void Select(IBlock block)
        {
            // Push block groups on the stack up to the root:
            Stack <IBlockGroup> groupStack = new Stack <IBlockGroup>();
            IBlockGroup         group      = block.BlockGroup;

            while (group != null)
            {
                groupStack.Push(group);
                group = group.BlockGroup;
            }

            // Pop block groups off the stack and open them:
            ListBoxItem item;
            BlockList   bl = this;

            while (groupStack.Count > 0)
            {
                group = groupStack.Pop();
                item  = group.BlockItem;
                if (bl.listBlocks.Items.Contains(item))
                {
                    if (!bl.SplitterOpen && bl.listBlocks.SelectedItem == item)
                    {
                        bl.listBlocks.SelectedItem = null;
                    }
                    bl.listBlocks.SelectedItem = item;
                    bl.listBlocks.ScrollIntoView(item);
                }
                bl = bl.GroupList;
            }

            // Select the item:
            item = block.BlockItem;
            if (bl != null && bl.listBlocks.Items.Contains(item))
            {
                bl.listBlocks.SelectedItem = item;
                bl.listBlocks.ScrollIntoView(item);
                if (bl.GroupList != null)
                {
                    bl.GroupList.listBlocks.UnselectAll();
                }
            }
        }
예제 #4
0
        public RemotePanel()
        {
            InitializeComponent();
            BlockManager = new BlockManager();
            foreach (IBlock block in BlockManager.BlockTypes)
            {
                listAdd.Items.Add(block.BlockItem);
            }

            BlockList = new BlockList();
            BlockList.MouseDoubleClick += OnMouseDoubleClick;
            ccBlockList.Content         = BlockList;

            BlockList.OrderChanged     += ListBlocks_OrderChanged;
            BlockList.SelectionChanged += ListBlocks_SelectionChanged;
            listCode.SelectionChanged  += ListCode_SelectionChanged;

            AddTimer          = new DispatcherTimer();
            AddTimer.Tick    += AddTimer_Tick;
            AddTimer.Interval = TimeSpan.FromMilliseconds(200);
        }