Ejemplo n.º 1
0
        /// <summary>
        ///     Method triggered when the Poller Type box changes
        /// </summary>
        private void PollerTypeBox_SelectedIndexChanged(object sender, EventArgs e)
        {
            if (_ignoreUpdate)
            {
                return;
            }

            // Delete the old data
            _current.Poller = null;

            // Ensure that the type is a Poller
            if (PollerTypeBox.SelectedItem == null)
            {
                return;
            }
            var type = _typeMappingPoller[(string)PollerTypeBox.SelectedItem];

            if (type == null || !typeof(PollingMechanism).IsAssignableFrom(type))
            {
                throw new Exception("Invalid object type! Not a Polling Mechanism!");
            }

            // Start creating the skeleton, and display it
            _current.Poller = (PollingMechanism)Activator.CreateInstance(type, _core);
            IOBlockViewer.UpdatePollerComponent();
        }
Ejemplo n.º 2
0
        /// <summary>
        ///     Refreshes the block types available for creation
        /// </summary>
        private void RefreshBlockListings()
        {
            var isOutput = InputOutputBox.SelectedIndex > 0;

            var oldConverter = ConverterTypeBox.SelectedItem as Type;
            var oldMedia     = MediaTypeBox.SelectedItem as Type;
            var oldPoller    = PollerTypeBox.SelectedItem as Type;

            _typeMappingConverter.Clear();
            _typeMappingMedia.Clear();
            _typeMappingPoller.Clear();

            MediaTypeBox.Items.Clear();
            PollerTypeBox.Items.Clear();
            ConverterTypeBox.Items.Clear();

            foreach (var plugin in _core.Plugins)
            {
                foreach (var connectable in plugin.DataConverterTypes)
                {
                    _typeMappingConverter.Add(connectable.Key, connectable.Value);
                    ConverterTypeBox.Items.Add(connectable.Key);
                }
                foreach (var connectable in plugin.PollerTypes)
                {
                    _typeMappingPoller.Add(connectable.Key, connectable.Value);
                    PollerTypeBox.Items.Add(connectable.Key);
                }
                foreach (var connectable in plugin.StreamTypes)
                {
                    // Prevent any illegal connections from showing up
                    var mdata = connectable.Value.GetCustomAttribute <MetadataDataStreamAttribute>();
                    if (mdata == null || (isOutput && !mdata.AllowAsOutput) || (!isOutput && !mdata.AllowAsInput))
                    {
                        continue;
                    }

                    _typeMappingMedia.Add(connectable.Key, connectable.Value);
                    MediaTypeBox.Items.Add(connectable.Key);
                }
            }

            // Restore all of the previously selected values
            _ignoreUpdate = true;

            if (oldConverter != null && ConverterTypeBox.Items.Contains(oldConverter))
            {
                ConverterTypeBox.SelectedItem = oldConverter;
            }
            else
            {
                _current.Converter = null;
            }
            if (oldMedia != null && MediaTypeBox.Items.Contains(oldMedia))
            {
                MediaTypeBox.SelectedItem = oldMedia;
            }
            else
            {
                _current.MediaConnection = null;
            }
            if (oldPoller != null && PollerTypeBox.Items.Contains(oldPoller))
            {
                PollerTypeBox.SelectedItem = oldPoller;
            }
            else
            {
                _current.Poller = null;
            }

            UpdateTypeBoxVisibility();

            IOBlockViewer.UpdateConverterComponent();
            IOBlockViewer.UpdatePollerComponent();



            _ignoreUpdate = false;
        }