Exemplo n.º 1
0
        public override void Initialize(IAppContext context)
        {
            _context = context;

            _metadataService = context.Container.GetSingleton <SymbologyMetadataService>();
            _labelMover      = context.Container.GetSingleton <LabelMover>();
            _legendListener  = context.Container.GetInstance <LegendListener>();
            _menuGenerator   = context.Container.GetInstance <MenuGenerator>();
            _menuListener    = context.Container.GetInstance <MenuListener>();
        }
Exemplo n.º 2
0
        public MainPresenter(
            IAppContext context,
            IMainView view,
            IProjectService projectService,
            IConfigService configService,
            LegendPresenter legendPresenter,
            ToolboxPresenter toolboxPresenter,
            IRepository repository)
            : 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");
            }
            if (repository == null)
            {
                throw new ArgumentNullException("repository");
            }

            // PM 2016-03-02 Added:
            if (legendPresenter == null)
            {
                throw new ArgumentNullException("legendPresenter");
            }
            if (toolboxPresenter == null)
            {
                throw new ArgumentNullException("toolboxPresenter");
            }

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

            GlobalListeners.Attach(Logger.Current);

            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, legendPresenter, toolboxPresenter, repository);

                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>();
                _menuListener       = container.GetSingleton <MenuListener>();
                _mapListener        = container.GetSingleton <MapListener>();
                _mainPluginListener = container.GetSingleton <MainPluginListener>();
                _legendListener     = container.GetSingleton <LegendListener>();

                _menuUpdater = new MenuUpdater(_context, PluginIdentity.Default);

                SplashView.Instance.ShowStatus("Loading plugins");
                // must be called after docking is initialized:
                appContext.InitPlugins(configService, p => SplashView.Instance.ShowStatus($"Loading plugins: {p.Name}"));

                // 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");
        }