Пример #1
0
 private void Init()
 {
     mainThread = new MainThreadImpl(this.Activity);
     presenter  = new OverviewPresenterImpl(TaskExecutor.GetInstance(), mainThread, this, new HabitRepositoryImpl(), new RoutineRepositoryImpl(), new TodoRepositoryImpl(), new UserRepositoryImpl(), LocalData.Username, LocalData.Password);
 }
Пример #2
0
        /*private readonly LegendListener _legendListener;
         * private readonly MainPluginListener _mainPluginListener;
         *
         *
         * private readonly MenuListener _menuListener;
         */
        //
        //

        public MainPresenter(
            IAppContext context,
            IMainView view,
            IConfigService configService,
            MapLegendPresenter mapLegendPresenter,
            OverviewPresenter overviewPresenter,
            IProjectService projectService)
            : base(view)
        {
            Logger.Current.Trace("Start MainPresenter");
            if (view == null)
            {
                throw new ArgumentNullException("view");
            }
            if (projectService == null)
            {
                throw new ArgumentNullException("projectService");
            }
            if (configService == null)
            {
                throw new ArgumentNullException("configService");
            }


            _context        = context;
            _configService  = configService;
            _projectService = projectService;

            //  view.Map.Lock();
            try
            {
                var appContext = context as AppContext;
                if (appContext == null)
                {
                    throw new InvalidCastException("Invalid type of IAppContext instance");
                }

                appContext.Init(view, projectService, configService, mapLegendPresenter, overviewPresenter);
                //projectService, configService);

                //最后去整理,当前的工作环境需要的配置参数有哪些

                /* view.Map.Initialize();
                 * view.Map.ApplyConfig(configService);*/

                view.ViewClosing  += OnViewClosing;
                view.ViewUpdating += OnViewUpdating;
                view.BeforeShow   += OnBeforeShow;

                var container = context.Container;
                _statusBarListener = container.GetSingleton <StatusBarListener>();
                _menuGenerator     = container.GetSingleton <MenuGenerator>();
                _menuUpdater       = new MenuUpdater(_context, PluginIdentity.Default, _menuGenerator.GetMenuKeys());
                _mapListener       = container.GetSingleton <MapListener>();

                /*_menuListener = container.GetSingleton<MenuListener>();
                 *
                 * _mainPluginListener = container.GetSingleton<MainPluginListener>();
                 * _legendListener = container.GetSingleton<LegendListener>();
                 *
                 */

                SplashView.Instance.ShowStatus("开始引导插件...");
                appContext.InitPlugins(configService); // must be called after docking is initialized

                _context.RibbonMenu.ReorderTabs();

                // this will display progress updates and debug window
                // file based-logger is already working
                Logger.Current.Init(appContext);
            }
            finally
            {
                /*view.Map.Unlock();
                 * context.Legend.Unlock();*/
            }

            View.AsForm.Shown += ViewShown;
            Logger.Current.Trace("End MainPresenter");
        }
Пример #3
0
        /// <summary>
        /// Sets all the necessary references from the main view.
        /// </summary>
        /// <remarks>We don't use contructor injection here since most of other services use this one as a parameter.
        /// Perhaps property injection can be used.</remarks>
        internal void Init(
            IMainView mainView,
            IProjectService project,
            IConfigService configService,
            MapLegendPresenter mapLegendPresenter,
            OverviewPresenter overviewPresenter
            )
        {
            Logger.Current.Trace("Start AppContext.Init()");
            if (mainView == null)
            {
                throw new ArgumentNullException("mainView");
            }
            if (project == null)
            {
                throw new ArgumentNullException("project");
            }
            if (mapLegendPresenter == null)
            {
                throw new ArgumentNullException("legendPresenter");
            }
            //初始化图例控件
            _mapLegendPresenter = mapLegendPresenter;
            var legend = _mapLegendPresenter.LegendControl;

            legend.LegendControl.SetBuddyControl(mainView.MapControl);


            // it's expected here that we are on the UI thread
            SynchronizationContext = SynchronizationContext.Current;

            PluginManager = Container.GetSingleton <IPluginManager>();
            Broadcaster   = Container.GetSingleton <IBroadcasterService>();
            Container.RegisterInstance <IMapControl2>(mainView.MapControl);

            MainView       = mainView;
            View           = new AppView(mainView, _styleService);
            _project       = project;
            _configService = configService;
            MainView.AddFrameworkControl(legend.LegendControl.Object);

            _overviewPresenter = overviewPresenter;
            _overviewPresenter.SetBuddyControl(mainView.MapControl);
            MainView.AddFrameworkControl(_overviewPresenter.OverviewControl);

            //  _map = mainView.Map;
            //
            //   Repository = repository;

            //  Legend.Lock();

            DockPanels = new DockPanelCollection(mainView.DockingManager, mainView as Form, Broadcaster, _styleService);

            //Menu到最后丢弃不用,Menu部分全部采用Ribbon
            RibbonMenu = RibbonFactory.InitMenus((RibbonControl)mainView.RibbonManager,
                                                 mainView.RibbonStatusBar as RibbonStatusBar);

            // Menu = MenuFactory.CreateMainMenu(mainView.RibbonManager,true);
            // Toolbars = MenuFactory.CreateMainToolbars(mainView.MenuManager);
            // StatusBar = MenuFactory.CreateStatusBar(mainView.RibbonStatusBar, PluginIdentity.Default);

            // _projectionDatabase.ReadFromExecutablePath(Application.ExecutablePath);

            // Repository.Initialize(this);

            // comment this line to prevent locator loading
            // may be useful for ocx debugging to not create additional
            // instance of map
            // _locator = new LocatorPresenter(_map);

            this.InitDocking();

            //YTHookHelper设置

            OperationStack  = new OperationStackClass();
            m_pStyleGallery = null;

            //Catalog配置
            GxCatalog = new GxCatalog();
            //GxSelection=new GxSelection();
            //if (this._gxSelection is IGxSelectionEvents)
            //{
            //    (this._gxSelection as IGxSelectionEvents).OnSelectionChanged += new OnSelectionChangedEventHandler(this.GxSelection_Changed);
            //}

            Initialized = true;
            Logger.Current.Trace("End AppContext.Init()");

            //为了减少修改,给ApplicationRef赋值
            ApplicationRef.AppContext = this;
        }