Ejemplo n.º 1
0
        /// <summary>
        /// 新建一个空白通道
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void New_Click(object sender, RoutedEventArgs e)
        {
            ChannelManager.AddChannel();
            ObservableCollection <ChannelItem> ChannelItems = new ObservableCollection <ChannelItem>();

            foreach (Channel chan in ChannelManager.Channels)
            {
                ChannelItem channelItem = new ChannelItem(chan);
                ChannelItems.Add(channelItem);
            }
            this.ParentListBox.BindingChannels(ChannelItems);
            this.StartDisplay();
            //关闭窗口
            this.Close();
        }
        public event ChangedEventHandler ValueChanged;      //定义事件

        //关闭信道item
        private void btnClose_Click(object sender, RoutedEventArgs e)
        {
            ListBoxItem listItem = GetParentObject <ListBoxItem>((DependencyObject)sender);

            ChannelItem c = (ChannelItem)(listItem).DataContext;

            this.ChannelItems.Remove(c);
            foreach (Channel chan in ChannelManager.Channels)
            {
                if (chan.Id == c.Id)
                {
                    ChannelManager.Channels.Remove(chan);
                    _OscPanel.RemoveOscSwiperBtn(chan.Id);
                    return;
                }
            }
        }
        //隐藏按钮,点击隐藏信道
        private void show_Click(object sender, RoutedEventArgs e)
        {
            ListBoxItem listItem = GetParentObject <ListBoxItem>((DependencyObject)sender);
            ChannelItem c        = (ChannelItem)(listItem).DataContext;

            listItem.IsSelected = true;
            if (listItem.Background != Brushes.Gray)
            {
                //隐藏
                listItem.Background = Brushes.Gray;
                c.IsShow            = false;
            }
            else
            {
                //显示
                listItem.Background = listItem.BorderBrush;
                c.IsShow            = true;
            }
        }