public static XOApplication InitializeFromAppConfig()
        {
            StartupBunch sttpBunch = AppConfigHandler.Initialize();

            _appConfig = SelectApp(sttpBunch);

            if (AppConfig == null) return null;

            SplashScreen.ShowSplashScreen(AppConfig.FullImgSplashFileName);

            DataAvail.Serialization.FileSerializationStream.DeafaultDirectory = AppConfig.FullXmlFolderPath;

            XElement Model; 
            XElement View;
            XElement Security;

            LoadModel(out Model, out View, out Security);

            if(Model == null)
            {
                throw new AppShellInitializerException("Can't reach the model, without it project can't be started.");
            }

            XOApplication.xmlReaderLog = AppShellLog.Log;

            XOApplication app = new XOApplication(Model, View, Security,
                new XOApplicationConfigParams() { pluginsDirectory = AppConfig.FullPluginsFolderPath, sharedPluginsDirectory = sttpBunch.SharedPluginsFolder });

            InitializeDbContext(AppConfig.FullModelFileName, app.XopDataSet);

            System.Data.DataSet dataSet = DataAvail.DataSetParser.DataSetBuilder.Build(AppConfig.FullModelFileName);

            FillStorage(app, dataSet);

            Controller.controllerContext = new ControllerContext(new XtraBindingControllerProvider(dataSet, LoadCalculatorManager()));

            InitializeControllerContext(app);

            if (app.XwpApplication != null)
                InitializeAppApperance(app.XwpApplication.AppView);

            return app;
        }
        private IEnumerable<AppConfig> GetAppConfigs(StartupBunch StartupBunch, XElement AppsElements)
        {
            foreach (XElement appEl in AppsElements.Elements("app"))
            {
                XElement modelEl = appEl.Element("modelFolder");
                XElement plugEl = appEl.Element("plugins");

                AppConfig config = new AppConfig(StartupBunch)
                    {
                        Caption = XmlLinq.GetAttributeSafe(appEl, "caption"),
                        BaseFolder = XmlLinq.GetAttributeSafe(appEl, "path"),
                        ImgSplashFile = XmlLinq.GetAttributeSafe(appEl, "imgSplash"),
                        TmpFolder = XmlLinq.GetAttributeSafe(appEl.Element("tmpFolder"), "path"),
                        XmlFolder = XmlLinq.GetAttributeSafe(appEl.Element("xmlFolder"), "path"),
                        PluginsFolder = XmlLinq.GetAttributeSafe(plugEl, "path"),
                        IsActive = XmlLinq.ReadAttributeBool(appEl, "active", true, null)
                    };

                if (plugEl != null)
                {
                    config.ClaulatorFile = XmlLinq.GetAttributeSafe(plugEl.Element("calculator"), "path");
                }

                if (modelEl != null)
                {
                    config.ModelFolder = XmlLinq.GetAttributeSafe(modelEl, "path");
                    config.ModelFile = XmlLinq.GetAttributeSafe(modelEl.Element("model"), "path");
                    config.ViewFile = XmlLinq.GetAttributeSafe(modelEl.Element("view"), "path");
                    config.SecurityFile = XmlLinq.GetAttributeSafe(modelEl.Element("security"), "path");
                }

                if (string.IsNullOrEmpty(config.ModelFolder))
                    config.ModelFolder = DefModelBasePath;

                if (string.IsNullOrEmpty(config.ModelFile))
                    config.ModelFile = DefModelFileName;

                if (string.IsNullOrEmpty(config.ViewFile))
                    config.ViewFile = DefViewFileName;

                if (string.IsNullOrEmpty(config.SecurityFile))
                    config.SecurityFile = DefSecurityFileName;

                if (string.IsNullOrEmpty(config.XmlFolder))
                    config.XmlFolder = DefSerializationPath;

                if (string.IsNullOrEmpty(config.PluginsFolder))
                    config.PluginsFolder = DefPluginsFolderPath;

                yield return config;
            }
        }
        protected override void OnFormClosing(FormClosingEventArgs e)
        {
            _selectedAppConfig = imageListBoxControl1.SelectedValue as AppConfig;

            base.OnFormClosing(e);
        }