Beispiel #1
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;
        }