Ejemplo n.º 1
0
        private void rechnermodul_Load(object sender, EventArgs e)
        {
            Console.Write(APP_PATH + "\n");

            this.modules = this.loadModules(this.getModulPaths());

            for (int mId = 0; mId < this.modules.Length; mId++)
            {
                RechnermodulBibliothek.ModulInterface modul = this.modules[mId];
                ToolStripMenuItem item = new ToolStripMenuItem();
                item.Text = modul.getFriendlyName();

                ms_module.Items.Add(item);

                FunctionDescriptionInterface[] functions = modul.getFunctionDescriptions();
                for (int fId = 0; fId < functions.Length; fId++)
                {
                    FunctionDescriptionInterface fd = functions[fId];
                    MyMenuItem sub_item             = new MyMenuItem();
                    sub_item.Text       = fd.getName();
                    sub_item.functionId = fId;
                    sub_item.moduleId   = mId;
                    sub_item.Click     += new EventHandler(ms_function_click);
                    item.DropDownItems.Add(sub_item);
                }
            }
        }
Ejemplo n.º 2
0
        private RechnermodulBibliothek.ModulInterface[] loadModules(string[] modulePaths)
        {
            List <RechnermodulBibliothek.ModulInterface> modules = new List <RechnermodulBibliothek.ModulInterface>();

            foreach (string dllPath in modulePaths)
            {
                if (!File.Exists(dllPath))
                {
                    Console.Write("Could not load file " + dllPath);

                    continue;
                }

                var DLL = Assembly.LoadFile(dllPath);
                foreach (Type type in DLL.GetExportedTypes())
                {
                    RechnermodulBibliothek.ModulInterface modul = Activator.CreateInstance(type) as RechnermodulBibliothek.ModulInterface;

                    if (modul != null)
                    {
                        modules.Add(modul);
                    }
                }
            }

            modules.Add(new GrundrechenModul());

            return(modules.ToArray <RechnermodulBibliothek.ModulInterface>());
        }