Ejemplo n.º 1
0
        /// <summary>
        /// 获取无名称设备宽度
        /// </summary>
        /// <returns></returns>
        public static double GetNoNameDeviceUWidth()
        {
            var control = new UCCabinetDeviceControl();

            //第二列和第三列宽度相加,即为无设备名称宽度
            return(control.root.ColumnDefinitions[1].Width.Value + control.root.ColumnDefinitions[2].Width.Value);
        }
        private void SetCabinetDevice(CabinetDeviceUnit deviceUnit, Style deviceNameStyle)
        {
            stackPanel.Children.Clear();
            double cabinetDeviceUnitHeight = this.Height / deviceUnit.DeviceList.Count;

            foreach (var device in deviceUnit.DeviceList)
            {
                var cabinetDeviceUnitControl = new UCCabinetDeviceControl();
                cabinetDeviceUnitControl.SelectedDeviceChanged = this.DeviceSelectedChanged;
                if (device.DeviceNameVisibility != Visibility.Visible)
                {
                    cabinetDeviceUnitControl.ToolTip = device.DeviceName;
                }

                cabinetDeviceUnitControl.DeviceNameStyle = deviceNameStyle;
                cabinetDeviceUnitControl.DataContext     = device;
                cabinetDeviceUnitControl.Height          = cabinetDeviceUnitHeight;
                stackPanel.Children.Insert(0, cabinetDeviceUnitControl);
            }
        }