예제 #1
0
        /// <summary>
        /// ����������� ������.
        /// </summary>
        /// <param name="device">�������������� ����������.</param>
        public DeviceDiagram(IDevice device, string hostName)
        {
            if (device == null)
                throw new ArgumentNullException("device");

            _device = device;

            _hostName = hostName;

            _partitionControls = new List<PartitionControl>();

            // �������� ������� �����������.
            SetStyle(ControlStyles.AllPaintingInWmPaint, true);
            SetStyle(ControlStyles.OptimizedDoubleBuffer, true);

            MinimumSize = new Size(150, 150);

            foreach (IPartition part in _device.GetPartitions())
            {
                _partitionControls.Add(new PartitionControl(this, part, _hostName));
            }

            _device.PropertyChanged += new EventHandler<DeviceEventArgs>(_device_PropertyChanged);
            _device.PartitionAdded += new EventHandler<DeviceEventArgs>(_device_PartitionAdded);
            _device.PartitionRemoved += new EventHandler<DeviceEventArgs>(_device_PartitionRemoved);

            _centerControl = new DeviceControl(this, _device);

            RearrangePartitions();
        }
예제 #2
0
        private new void Dispose(bool disposing)
        {
            if (disposing)
            {
                lock (this)
                {

                    _device.PropertyChanged -= _device_PropertyChanged;
                    _device.PartitionAdded -= _device_PartitionAdded;
                    _device.PartitionRemoved -= _device_PartitionRemoved;

                    foreach (PartitionControl partitionControl in _partitionControls)
                    {
                        partitionControl.Dispose();
                    }

                    _partitionControls.Clear();
                    _partitionControls = null;

                    _centerControl.Dispose();
                    _centerControl = null;

                    _device = null;
                }
            }
            base.Dispose(disposing);
        }