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

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

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

            if (type == null || !typeof(DataConverter).IsAssignableFrom(type))
            {
                throw new Exception("Invalid object type! Not a Data Converter!");
            }

            // Start creating the skeleton, and display it
            _current.Converter = (DataConverter)Activator.CreateInstance(type);
            IOBlockViewer.UpdateConverterComponent();
        }
Esempio 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;
        }