/// <summary>
        /// Initializes a new instance of the <see cref="DevicePropertyControl"/> class.
        /// </summary>
        /// <param name="property">The property.</param>
        /// <param name="isConnectable">if set to <c>true</c> [is connectable].</param>
        public DevicePropertyControl(ns.Base.Plugins.Properties.Property property, bool isConnectable)
            : base(property)
        {
            InitializeComponent();
            IsConnectable = isConnectable;
            this.NameLabel.Content = property.Name;
            _property = property as DeviceProperty;

            this.SelectionBox.ItemsSource = _property.DevicePlugins;
            this.SelectionBox.DisplayMemberPath = "DisplayName";

            Device device = null;
            if (_property.Value == null) {
                if ((device = _property.DevicePlugins.Find(d => d.Name.Contains("ImageFileDevice")) as Device) != null)
                    this.SelectionBox.SelectedItem = device;
            } else {
                device = _property.Value as Device;
                this.SelectionBox.SelectedItem = device;
            }

            if (!string.IsNullOrEmpty(Property.ConnectedToUID)) {
                ConnectClicked(this.SelectionBox as Control, this.ConnectImage);
            }
        }
Exemple #2
0
        /// <summary>
        /// Initialze the Plugin.
        /// </summary>
        /// <returns>
        /// Success of the Operation.
        /// </returns>
        public override bool Initialize()
        {
            base.Initialize();

            bool result = false;
            _deviceProperty = GetProperty("Interface") as DeviceProperty;
            if (_deviceProperty == null) {
                Trace.WriteLine("Device interface is null!", LogCategory.Error);
                return false;
            }
            _deviceProperty.PropertyChanged -= DeviceProperty_PropertyChanged;
            _deviceProperty.PropertyChanged += DeviceProperty_PropertyChanged;
            _device = _deviceProperty.Value as ImageDevice;
            if (_device == null) {
                Trace.WriteLine("Device is null!", LogCategory.Error);
                return false;
            }
            _imageProperty = GetProperty(typeof(ImageProperty)) as ImageProperty;

            if (_device == null) {
                Trace.WriteLine("Device interface is null!", LogCategory.Error);
            } else {
                result = _device.Initialize();
                if (!result)
                    Trace.WriteLine("Could not initialize device!", LogCategory.Error);
            }

            _isRunning = result;
            return result;
        }