예제 #1
0
        void populateIconForDataSource(DataSource ds)
        {
            if (ds == null)
            {
                return;
            }
            StaticProvider provider = ds.StaticProvider;

            if (provider == null)
            {
                return;
            }
            this.imageList.Images.Add(provider.Icon);
            int providerIconImageIndex = this.imageList.Images.Count - 1;

            if (this.imageIndexByStaticProviderType.ContainsKey(provider.GetType()) == false)
            {
                this.imageIndexByStaticProviderType.Add(provider.GetType(), providerIconImageIndex);
            }
        }
예제 #2
0
        public void PopulateStaticStreamingBrokerListViewsFromDataSource()
        {
            if (base.IsDisposed)
            {
                string msg = "base.IsDisposed=true for DataSourceEditorForm::PopulateStaticStreamingBrokerListViewsFromDataSource()";
                Assembler.PopupException(msg);
                return;
            }

            this.lvStaticProviders.Items.Clear();
            foreach (StaticProvider staticProviderPrototype in StaticProvidersByName.Values)
            {
                try {
                    StaticProvider staticProviderEditingInstance = null;                        // staticProviderPrototype;
                    if (ds.StaticProvider != null && ds.StaticProvider.GetType().FullName == staticProviderPrototype.GetType().FullName)
                    {
                        staticProviderEditingInstance = ds.StaticProvider;
                    }
                    // I still want to get a new instance, so if user choses it, I'll Initialize() it and put into serialize-able DataSource
                    if (staticProviderEditingInstance == null)
                    {
                        staticProviderEditingInstance = (StaticProvider)Activator.CreateInstance(staticProviderPrototype.GetType());
                    }
                    ListViewItem lvi = new ListViewItem()
                    {
                        Text = staticProviderEditingInstance.Name,
                        Name = staticProviderEditingInstance.GetType().Name,
                        Tag  = staticProviderEditingInstance
                    };
                    if (staticProviderEditingInstance.Icon != null)
                    {
                        this.imglStaticProviders.Images.Add(staticProviderEditingInstance.Icon);
                        lvi.ImageIndex = this.imglStaticProviders.Images.Count - 1;
                    }
                    this.lvStaticProviders.Items.Add(lvi);
                } catch (Exception e) {
                    this.assemblerInstance.StatusReporter.PopupException(e);
                    return;
                }
            }

            this.lvStreamingProviders.Items.Clear();
            ListViewItem lviAbsentStreaming = new ListViewItem()
            {
                Text = StreamingProvider.NO_STREAMING_PROVIDER,
                Name = StreamingProvider.NO_STREAMING_PROVIDER,
            };

            this.lvStreamingProviders.Items.Add(lviAbsentStreaming);
            foreach (StreamingProvider streamingProviderPrototype in StreamingProvidersByName.Values)
            {
                try {
                    StreamingProvider streamingProviderInstance = null;                         // streamingProviderPrototype;
                    if (ds.StreamingProvider != null && ds.StreamingProvider.GetType().FullName == streamingProviderPrototype.GetType().FullName)
                    {
                        streamingProviderInstance = ds.StreamingProvider;
                    }
                    // I still want to get a new instance, so if user choses it, I'll Initialize() it and put into serialize-able DataSource
                    if (streamingProviderInstance == null)
                    {
                        streamingProviderInstance = (StreamingProvider)Activator.CreateInstance(streamingProviderPrototype.GetType());
                    }

                    if (streamingProviderInstance.EditorInstanceInitialized == false)
                    {
                        try {
                            streamingProviderInstance.StreamingEditorInitialize(this);
                        } catch (Exception e) {
                            string msg = "can't initialize streamingProviderInstance[" + streamingProviderInstance + "]";
                            this.assemblerInstance.StatusReporter.PopupException(new Exception(msg, e));
                            return;
                        }
                    }

                    ListViewItem lvi = new ListViewItem()
                    {
                        Text = streamingProviderInstance.Name,
                        Name = streamingProviderInstance.GetType().Name,
                        Tag  = streamingProviderInstance
                    };
                    if (streamingProviderInstance.Icon != null)
                    {
                        this.imglStreamingProviders.Images.Add(streamingProviderInstance.Icon);
                        lvi.ImageIndex = this.imglStreamingProviders.Images.Count - 1;
                    }
                    this.lvStreamingProviders.Items.Add(lvi);
                } catch (Exception e) {
                    this.assemblerInstance.StatusReporter.PopupException(e);
                    return;
                }
            }

            this.lvBrokerProviders.Items.Clear();
            ListViewItem lviAbsentBroker = new ListViewItem()
            {
                Text = BrokerProvider.NO_BROKER_PROVIDER,
                Name = BrokerProvider.NO_BROKER_PROVIDER,
            };

            this.lvBrokerProviders.Items.Add(lviAbsentBroker);
            foreach (BrokerProvider brokerProviderPrototype in BrokerProvidersByName.Values)
            {
                try {
                    BrokerProvider brokerProviderInstance = null;                       // brokerProviderPrototype;
                    if (ds.BrokerProvider != null && ds.BrokerProvider.GetType().FullName == brokerProviderPrototype.GetType().FullName)
                    {
                        brokerProviderInstance = ds.BrokerProvider;
                    }
                    // I still want to get a new instance, so if user choses it, I'll Initialize() it and put into serialize-able DataSource
                    if (brokerProviderInstance == null)
                    {
                        brokerProviderInstance = (BrokerProvider)Activator.CreateInstance(brokerProviderPrototype.GetType());
                    }

                    if (brokerProviderInstance.EditorInstanceInitialized == false)
                    {
                        try {
                            brokerProviderInstance.BrokerEditorInitialize(this);
                        } catch (Exception e) {
                            string msg = "can't initialize brokerProviderInstance[" + brokerProviderInstance + "]";
                            this.assemblerInstance.StatusReporter.PopupException(new Exception(msg, e));
                            return;
                        }
                    }

                    //if (this.DataSource == null) return;	//changing market for ASCII DataProvider
                    //this.DataSource.DataSourceManager.DataSourceSaveTreeviewRefill(this.DataSource);


                    ListViewItem lvi = new ListViewItem()
                    {
                        Text = brokerProviderInstance.Name,
                        Name = brokerProviderInstance.GetType().Name,
                        Tag  = brokerProviderInstance
                    };
                    if (brokerProviderInstance.Icon != null)
                    {
                        this.imglBrokerProviders.Images.Add(brokerProviderInstance.Icon);
                        lvi.ImageIndex = this.imglBrokerProviders.Images.Count - 1;
                    }
                    this.lvBrokerProviders.Items.Add(lvi);
                } catch (Exception e) {
                    this.assemblerInstance.StatusReporter.PopupException(e);
                    return;
                }
            }
        }