示例#1
0
        static UCCabinetRowControl()
        {
            var control = new UCCabinetRowControl();

            _titleWidth = ((GridLength)control.Resources["titleWidth"]).Value;
            _cabinetInfoGroupNameStyle = (Style)control.Resources["cabinetInfoGroupNameStyle"];
        }
示例#2
0
        private void UpdateCabinet()
        {
            this.Dispose();//释放前一次资源

            List <CabinetInfoGroup> cabinetInfoGroupList = this.CabinetInfoGroupList;

            if (cabinetInfoGroupList == null || cabinetInfoGroupList.Count == 0)
            {
                return;
            }

            double rowSeparator      = this.RowSeparator;
            double rowSeparatorWidth = double.IsNaN(rowSeparator) ? UCCabinetRowControl.SEPARATOR : rowSeparator;
            double top           = 0d;
            double maxWidth      = 0d;
            int    lastItemIndex = cabinetInfoGroupList.Count - 1;

            for (int i = 0; i < cabinetInfoGroupList.Count; i++)
            {
                var cabinetRowControl = new UCCabinetRowControl();
                cabinetRowControl.SelectedDeviceChanged    += CabinetRowControl_SelectedDeviceChanged;
                cabinetRowControl.TitleVisible              = this.TitleVisible;
                cabinetRowControl.CabinetWidth              = this.CabinetWidth;
                cabinetRowControl.Separator                 = this.ColumnSeparator;
                cabinetRowControl.DeviceNameStyle           = this.DeviceNameStyle;
                cabinetRowControl.CabinetNameStyle          = this.CabinetNameStyle;
                cabinetRowControl.CabinetInfoGroupNameStyle = this.CabinetInfoGroupNameStyle;
                cabinetRowControl.RowNameVisible            = this.RowNameVisible;
                cabinetRowControl.CabinetInfoGroup          = cabinetInfoGroupList[i];
                canvas.Children.Add(cabinetRowControl);

                Canvas.SetTop(cabinetRowControl, top);
                Canvas.SetLeft(cabinetRowControl, 0d);

                if (i < lastItemIndex)
                {
                    top = top + rowSeparator + cabinetRowControl.Height;
                }
                else
                {
                    top = top + cabinetRowControl.Height;
                }

                if (cabinetRowControl.Width > maxWidth)
                {
                    maxWidth = cabinetRowControl.Width;
                }
            }

            this.Width  = maxWidth;
            this.Height = top;
        }