コード例 #1
0
        private void channelsPanel_SizeChanged(object sender, SizeChangedEventArgs e)
        {
            int    minWidth        = 200;
            int    maxWidth        = 300;
            double stackPanelWidth = channelsPanel.ActualWidth;

            double integer  = Math.Truncate(stackPanelWidth / maxWidth) + 1;
            double fraction = (stackPanelWidth / minWidth) - integer;
            double k        = fraction / integer;

            int childrenCount = channelsPanel.Children.Count;

            for (int i = 0; i < childrenCount; i++)
            {
                ChannelItem channel = (ChannelItem)channelsPanel.Children[i];
                channel.Width = (int)(stackPanelWidth / integer);
            }
            //int minWidth = 200;
            //int maxWidth = 300;
            //double stackPanelWidth = channelsPanel.ActualWidth;

            //double integer = Math.Truncate(stackPanelWidth / minWidth);
            //double fraction = (stackPanelWidth / minWidth) - integer;
            //double k = fraction / integer;

            //int childrenCount = channelsPanel.Children.Count;
            //for (int i = 0; i < childrenCount; i++)
            //{
            //    ChannelItem channel = (ChannelItem)channelsPanel.Children[i];
            //    channel.Width = minWidth + (int)(minWidth * k);
            //}


            //double stackPanelWidth = channelsPanel.Width;
            //int childrenCount = channelsPanel.Children.Count;
            //if (stackPanelWidth <= 500)
            //{
            //    for (int i = 0; i < childrenCount; i++)
            //    {
            //        ChannelItem channel = (ChannelItem)channelsPanel.Children[i];
            //        channel.Width = channelsPanel.Width;
            //    }
            //}
            //else if (stackPanelWidth > 700 && stackPanelWidth < 1000)
            //{
            //    for (int i = 0; i < childrenCount; i++)
            //    {
            //        ChannelItem channel = (ChannelItem)channelsPanel.Children[i];
            //        channel.Width = (int)((int)channelsPanel.Width / 2);
            //    }
            //}
        }
コード例 #2
0
        private void AddChannels(Channel channel)
        {
            ChannelItem item = new ChannelItem(this, channel);

            channelsPanel.Children.Add(item);
        }