Пример #1
0
        public DictionarySectionUI(DualSectionImporter dualSection, IDictionarySectionImporter importer)
        {
            InitializeComponent();

            this.dualSection = dualSection;
            this.importer    = importer;
        }
Пример #2
0
        void select_SelectedIndexChanged(object sender, EventArgs e)
        {
            ImporterItem item = (select.SelectedItem as ImporterItem);

            if (item != null)
            {
                if (importer != null)
                {
                    UnwireImporterEvents();
                    importer.Dispose();
                }

                IImporterUI <IBilingualDictionary> newUI = null;

                if (item.Type.GetInterfaces().Contains(typeof(IDictionarySectionImporter)))
                {
                    var si  = (IDictionarySectionImporter)item.Type.GetConstructor(new Type[] { }).Invoke(new object[] { });
                    var dsi = new DualSectionImporter();
                    newUI    = new Controls.DictionarySectionUI(dsi, si);
                    importer = dsi;
                }
                else if (item.Type.IsSubclassOf(typeof(IBilingualDictionary)))
                {
                    importer = (IImporter <IBilingualDictionary>)item.Type.GetConstructor(new Type[] { }).Invoke(new object[] { });

                    foreach (Type t in importer.GetType().Assembly.GetTypes())
                    {
                        var attr = Attribute.GetCustomAttribute(t, typeof(ImporterUIAttribute)) as ImporterUIAttribute;
                        if (attr != null)
                        {
                            newUI = (IImporterUI <IBilingualDictionary>)Activator.CreateInstance(t, importer);
                            break;
                        }
                    }
                }

                WireImporterEvents();

                if (newUI == null)
                {
                    CurrentUI = new Controls.ErrorUI("No UI for " + item.Name, "");
                    UnwireImporterEvents();
                    importer.Dispose();
                    importer = null;
                    return;
                }

                newUI.Finished += new EventHandler(this.ImporterUIFinished);
                CurrentUI       = (Control)newUI;
            }
        }
Пример #3
0
		void select_SelectedIndexChanged(object sender, EventArgs e) {
			ImporterItem item = (select.SelectedItem as ImporterItem);
			if (item != null) {
				if (importer != null) {
					UnwireImporterEvents();
					importer.Dispose();
				}

				IImporterUI<IBilingualDictionary> newUI = null;

				if (item.Type.GetInterfaces().Contains(typeof(IDictionarySectionImporter))) {
					var si = (IDictionarySectionImporter)item.Type.GetConstructor(new Type[] { }).Invoke(new object[] { });
					var dsi = new DualSectionImporter();
					newUI = new Controls.DictionarySectionUI(dsi, si);
					importer = dsi;
				} else if(item.Type.IsSubclassOf(typeof(IBilingualDictionary))) {
					importer = (IImporter<IBilingualDictionary>)item.Type.GetConstructor(new Type[] { }).Invoke(new object[] { });

					foreach (Type t in importer.GetType().Assembly.GetTypes()) {
						var attr = Attribute.GetCustomAttribute(t, typeof(ImporterUIAttribute)) as ImporterUIAttribute;
						if (attr != null) {
							newUI = (IImporterUI<IBilingualDictionary>)Activator.CreateInstance(t, importer);
							break;
						}
					}
				}

				WireImporterEvents();
				
				if (newUI == null) {
					CurrentUI = new Controls.ErrorUI("No UI for " + item.Name, "");
					UnwireImporterEvents();
					importer.Dispose();
					importer = null;
					return;
				}

				newUI.Finished += this.ImporterUIFinished;
				CurrentUI = (Control)newUI;
			}
		}