コード例 #1
0
        public static void RemoveDrawObjects(this ICanvasDataContext canvasDataContext, ICollection <DrawObject> drawObjects)
        {
            if (drawObjects == null)
            {
                throw new ArgumentNullException(nameof(drawObjects));
            }

            if (drawObjects.Count == 0)
            {
                return;
            }

            //激发即将移除事件;
            var removingArgs = new CanvasDrawObjectsRemovingEventArgs(drawObjects, canvasDataContext);

            CommonEventHelper.Publish <CanvasDrawObjectsRemovingEvent, CanvasDrawObjectsRemovingEventArgs>(removingArgs);
            CommonEventHelper.PublishEventToHandlers <ICanvasDrawObjectsRemovingEventHandler, CanvasDrawObjectsRemovingEventArgs>(removingArgs);
            //若指示取消或集合为空,则不继续执行;
            if (removingArgs.Cancel || removingArgs.RemovingDrawObjects.Count == 0)
            {
                return;
            }

            var removingGroups = removingArgs.RemovingDrawObjects.
                                 GroupBy(p => p.Parent as CanvasLayer).Where(p => p.Key != null).ToArray();

            void RemoveDrawObjects()
            {
                try {
                    foreach (var tuple in removingGroups)
                    {
                        tuple.Key.RemoveDrawObjects(tuple);
                    }
                }
                catch (Exception ex) {
                    LoggerService.WriteException(ex);
                    MsgBoxService.ShowError(ex.Message);
                }
            }

            void AddDrawObjects()
            {
                try {
                    foreach (var tuple in removingGroups)
                    {
                        tuple.Key.AddDrawObjects(tuple);
                    }
                }
                catch (Exception ex) {
                    LoggerService.WriteException(ex);
                    MsgBoxService.ShowError(ex.Message);
                }
            }

            RemoveDrawObjects();

            var action = new StandardEditTransaction(AddDrawObjects, RemoveDrawObjects);

            canvasDataContext.CommitTransaction(action);
        }
コード例 #2
0
        protected override void InitializeModules()
        {
            ServiceProvider.SetServiceProvider(new ServiceProviderWrapper(ServiceLocator.Current));

            ViewProvider.SetViewProvider(new ViewProviderImpl(ServiceProvider.Current));



            //应用程序域服务初始化;

            AppDomainService.Current.Initialize();

            //因为各个模块都可能用到语言服务,必须先初始化语言服务;

            LanguageService.Current.Initialize();



            //初始化设定服务;

            SettingsService.Current.Initialize();



            base.InitializeModules();

            ModulesInitializing?.Invoke(this, EventArgs.Empty);



            CommonEventHelper.GetEvent <ApplicationStartUpEvent>().Publish();

            CommonEventHelper.PublishEventToHandlers <IApplicationStartUpEventHandler>();
        }
コード例 #3
0
        public void Initialize()
        {
            _items.Clear();
            _stackGrid.Clear();

            foreach (var item in _statusBarItems)
            {
                AddStatusBarItem(item);
            }

            //添加默认状态栏项;
            //var defaultItem = CreateStatusBarTextItem(Constants.StatusBarItemDefault);
            //defaultItem.Margin = new Thickness(3, 0, 3, 0);
            //AddStatusBarItem(defaultItem, GridChildLength.Auto);


            //添加中间的空余项;
            //var indentItem = CreateStatusBarObjectItem(Constants.StatusBarItemIndent, null);
            //AddStatusBarItem(
            //    indentItem,
            //    new GridChildLength(new GridLength(1, GridUnitType.Star)),
            //    Contracts.StatusBar.Constants.StatusBarOrder_Indent
            //);

            CommonEventHelper.Publish <StatusBarInitializeEvent, IStatusBarService>(this);
            CommonEventHelper.PublishEventToHandlers <IStatusBarInitializeEventHandler, IStatusBarService>(this);
        }
コード例 #4
0
 public void Initialize()
 {
     try {
         CommonEventHelper.Publish <CanvasDataContextInitializingEvent, ICanvasDataContext>(CanvasDataContext);
         CommonEventHelper.PublishEventToHandlers <ICanvasDataContextInitializingEventHandler, ICanvasDataContext>(CanvasDataContext);
     }
     catch (Exception ex) {
         LoggerService.WriteException(ex);
     }
 }
コード例 #5
0
        public void Initialize()
        {
            CommonEventHelper.GetEvent <SplashMessageEvent>().
            Publish(LanguageService.FindResourceString(Constants.CaseModuleBeingLoaded));

            CommonEventHelper.PublishEventToHandlers(GenericServiceStaticInstances <ICaseModuleLoadingEventHandler> .Currents);

            _caseUiService = ServiceProvider.Current?.GetInstance <ICaseUIService>();
            _caseUiService?.Initialize();
        }
コード例 #6
0
ファイル: SettingsService.cs プロジェクト: tthaiker/Tida.CAD
        public void Initialize()
        {
            var dir = AppDomainService.ExecutingAssemblyDirectory;

            try {
                CommonEventHelper.Publish <SettingsServiceInitializeEvent, ISettingsService>(this);
                CommonEventHelper.PublishEventToHandlers <ISettingsServiceInitializeEventHandler, ISettingsService>(this);
            }
            catch (Exception ex) {
            }
        }
コード例 #7
0
        public void LoadHexDataContext(IHexDataContext hexDataContext)
        {
            if (hexDataContext == null)
            {
                throw new ArgumentNullException(nameof(hexDataContext));
            }

            CommonEventHelper.PublishEventToHandlers(hexDataContext, _hexDataContextLoadedEventHandlers);

            CommonEventHelper.GetEvent <HexDataContextLoadedEvent>().Publish(hexDataContext);
        }
コード例 #8
0
 public void LoadDescriptorsFromFile(string fileName)
 {
     try {
         LoadDescriptorInternal(fileName);
         CommonEventHelper.GetEvent <NameCategoryDescriptorsLoadedEvent>().Publish();
         CommonEventHelper.PublishEventToHandlers(GenericServiceStaticInstances <INameCategoryDescriptorsLoadedEventHandler> .Currents);
     }
     catch (Exception ex) {
         LoggerService.WriteCallerLine(ex.Message);
         throw;
     }
 }
コード例 #9
0
        public void Initialize()
        {
            if (Initialized)
            {
                return;
            }

            _shell.Closing += Shell_Closing;
            CommonEventHelper.GetEvent <ShellInitializingEvent>().Publish();
            CommonEventHelper.PublishEventToHandlers <IShellInitializingEventHandler>();
            Initialized = true;
        }
コード例 #10
0
        public void Initialize()
        {
            CommonEventHelper.GetEvent <SplashMessageEvent>().
            Publish(LanguageService.FindResourceString(Constants.FileExploerLoading));

            try {
                CommonEventHelper.GetEvent <FileExplorerModuleLoadingEvent>().Publish();
                CommonEventHelper.PublishEventToHandlers(GenericServiceStaticInstances <IFileExplorerModuleLoadingEventHandler> .Currents);
            }
            catch (Exception ex) {
                LoggerService.WriteException(ex);
            }
        }
コード例 #11
0
        public void Initialize()
        {
            CommonEventHelper.GetEvent <SplashMessageEvent>().
            Publish(LanguageService.FindResourceString(Constants.HashModuleLoading));

            try {
                CommonEventHelper.GetEvent <HashModuleLoadingEvent>().Publish();
                CommonEventHelper.PublishEventToHandlers <IHashModuleLoadingEventHandler>();
            }
            catch (Exception ex) {
                LoggerService.WriteException(ex);
            }
        }
コード例 #12
0
        /// <summary>
        /// Ribbon的Tab发生变化时激发事件;
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void RibbonMenu_SelectionChanged(object sender, RadSelectionChangedEventArgs e)
        {
            if (e.AddedItems.Count == 0)
            {
                return;
            }

            if (!((e.AddedItems[0] as RadRibbonTab)?.DataContext is RibbonTabDataContext ribbonTabDataContext))
            {
                return;
            }

            var args = new SelectedRibbonTabChangedEventArgs(ribbonTabDataContext.RibbonTabMetaData);

            CommonEventHelper.Publish <SelectedRibbonTabChangedEvent, SelectedRibbonTabChangedEventArgs>(args);
            CommonEventHelper.PublishEventToHandlers <ISelectedRibbonTabChangedEventHandler, SelectedRibbonTabChangedEventArgs>(args);
        }
コード例 #13
0
        public IFolderBrowserDataContext CreateFolderBrowserDataContext(IHaveFileCollection haveFileCollection)
        {
            var dataContext = new FolderBrowserDataContext(haveFileCollection);

            try {
                CommonEventHelper.PublishEventToHandlers(dataContext as IFolderBrowserDataContext, _folderBrowserViewModelCreatedEventHandlers);
                CommonEventHelper.GetEvent <FolderBrowserDataContextCreatedEvent>().Publish(dataContext);
            }
            catch (Exception ex) {
                LoggerService.WriteException(ex);
            }

            //try {
            //    dataContext.Initialize();
            //}
            //catch(Exception ex) {
            //    LoggerService.WriteException(ex);
            //}

            return(dataContext);
        }
コード例 #14
0
 private void Shell_Closing(object sender, CancelEventArgs e)
 {
     CommonEventHelper.Publish <ShellClosingEvent, CancelEventArgs>(e);
     CommonEventHelper.PublishEventToHandlers <IShellClosingEventHandler, CancelEventArgs>(e);
 }
コード例 #15
0
        /// <summary>
        /// 加载案件;
        /// </summary>
        /// <param name="cFile"></param>
        public void LoadCase(ICase cs)
        {
            if (cs == null)
            {
                throw new ArgumentNullException(nameof(cs));
            }

            //关闭尚未关闭的案件;
            if (CurrentCase != null)
            {
                CloseCurrentCase();
            }

            //若当前案件仍不为空,则关闭案件未完成,需中断加载案件;
            if (CurrentCase != null)
            {
                return;
            }

            //发布案件加载中事件;
            CommonEventHelper.GetEvent <CaseLoadingEvent>().Publish(cs);
            CurrentCase = cs;

            //从文档中加载证据项;
            var msg = ServiceProvider.Current.GetInstance <IDialogService>()?.CreateDoubleLoadingDialog();

            if (msg == null)
            {
                LoggerService.Current?.WriteCallerLine($"{nameof(IDialogService)} can't be null.");
                return;
            }

            msg.Title = LanguageService.Current?.FindResourceString(LoadingCase);

            msg.DoWork += delegate {
                //构建进度回调器;
                var reporter = ProgessReporterFactory.CreateNew();
                reporter.ProgressReported += (sender, e) => {
                    msg.ReportProgress(e.totalPer, e.detailPer, e.desc, e.detail);
                };

                //证据项元素;
                var evidenceElems = cs.XDoc.Root.Elements(Contracts.Casing.Constants.CaseEvidenceRootElemName);

                foreach (var elem in evidenceElems)
                {
                    try {
                        var csEvidence = LoadCaseEvidenceFromXElem(elem);

                        //加载证据项;
                        CurrentCase.LoadCaseEvidence(csEvidence, reporter);
                    }
                    catch (Exception ex) {
                        Logger.WriteCallerLine(ex.Message);
                        ThreadInvoker.UIInvoke(() => {
                            MsgBoxService.ShowError(ex.Message);
                        });
                    }
                }

                //发布加载案件完成的事件;
                CommonEventHelper.GetEvent <CaseLoadedEvent>().Publish();
                CommonEventHelper.PublishEventToHandlers <ICaseLoadedEventHandler>();
            };


            msg.ShowDialog();
        }