Ejemplo 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();
        }
Ejemplo n.º 2
0
        /// <summary>
        ///     Creates a new IO Block Creator panel for the specified Streamline Core
        /// </summary>
        public IOBlockCreatorPanel(StreamlineCore core)
        {
            _core         = core;
            _current      = new DataConnection(core);
            _current.Name = _current.InternalName;

            InitializeComponent();

            _ignoreUpdate = true;
            InputOutputBox.SelectedIndex = 0;
            _current.IsOutput            = false;
            _ignoreUpdate = false;

            IOBlockViewer.AttributeList.AllowEnable = false;
            IOBlockViewer.SetViewingComponent(_current);
            RefreshBlockListings();
        }
Ejemplo n.º 3
0
        /// <summary>
        ///     Creates a new central control panel using a given core
        /// </summary>
        public ControlPanel(StreamlineCore core)
        {
            Core = core;
            InitializeComponent();

            // Don't show debug if not a dev
            if (!Core.Settings.DebugMode)
            {
                debugToolStripMenuItem.Dispose();
            }

            // Hide the components until something is selected
            BlockViewer.Hide();
            IOBlockViewer.Hide();

            // Set up the block editor
            BlockSchematic.SetCore(Core);
            BlockSchematic.OnBlockSelected += DetermineViewingComponent;
        }
Ejemplo n.º 4
0
        /// <summary>
        ///     Updates each of the type boxes to change if they are visible or not
        /// </summary>
        private void UpdateTypeBoxVisibility()
        {
            IOBlockViewer.UpdateMediaComponent();

            // Make everything visible if no chance of collision
            if (_current.MediaConnection == null)
            {
                PollerTypeBox.Show();
                PollerTypeLabel.Show();
                ConverterTypeBox.Show();
                ConverterTypeLabel.Show();
                return;
            }

            // Disable the Poller if non-applicable
            if (!_current.MediaConnection.UsesGenericPollers)
            {
                PollerTypeBox.Hide();
                PollerTypeBox.SelectedIndex = -1;
                PollerTypeLabel.Hide();
            }
            else
            {
                PollerTypeBox.Show();
                PollerTypeLabel.Show();
            }

            // Disable the Converter if non-applicable
            if (!_current.MediaConnection.UsesGenericConverters)
            {
                ConverterTypeBox.Hide();
                ConverterTypeBox.SelectedIndex = -1;
                ConverterTypeLabel.Hide();
            }
            else
            {
                ConverterTypeBox.Show();
                ConverterTypeLabel.Show();
            }
        }
Ejemplo n.º 5
0
        /// <summary>
        ///     Determines which block viewer should be shown for the user
        /// </summary>
        private void DetermineViewingComponent(object owner, IConnectable c)
        {
            var dc = c as DataConnection;

            if (dc != null)
            {
                // Treat as Data Connection
                BlockViewer.SetViewingComponent(null);
                IOBlockViewer.SetViewingComponent(dc);
                IOBlockViewer.UpdateAllComponents();
                BlockViewer.Hide();
                IOBlockViewer.Show();
            }
            else
            {
                // Treat as generic block
                BlockViewer.SetViewingComponent(c);
                IOBlockViewer.SetViewingComponent(null);
                BlockViewer.Show();
                IOBlockViewer.Hide();
            }
        }
Ejemplo n.º 6
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;
        }