コード例 #1
0
        /// <summary>
        /// 增加Tab;
        /// </summary>
        /// <param name="doc"></param>
        public void AddDocument(IDocumentBase doc)
        {
            if (doc == null)
            {
                throw new ArgumentNullException(nameof(doc));
            }

            if (!(doc is DocumentBase document))
            {
                throw new InvalidOperationException($"{doc.GetType()} is not a valid type,please user ${nameof(IDocumentService.CreateNewDocument)} instead.");
            }

            if (VM.Documents.FirstOrDefault(p => p == doc) != null)
            {
                SelectedDocument = doc;
                return;
            }

            CommonEventHelper.GetEvent <DocumentAddingEvent>().Publish((doc, this));

            document.CloseRequest += Document_CloseRequest;

            VM.Documents.Add(document);

            CommonEventHelper.PublishEventToHandlers((doc, this as IDocumentService), _documentAddedEventHandlers);
            CommonEventHelper.GetEvent <DocumentAddedEvent>().Publish((doc, this));

            SelectedDocument = document;
        }
コード例 #2
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);
        }
コード例 #3
0
        public TestPartitionsBrowser()
        {
            InitializeComponent();
            this.Loaded += delegate {
                RegionHelper.RequestNavigate(
                    SingularityForensic.Contracts.MainPage.Constants.MainPageDocumentRegion,
                    SingularityForensic.Contracts.Document.Constants.DocumentTabsView
                    );


                SingularityForensic.Contracts.Casing.CaseService.Current.LoadCase("E:\\Cases\\001\\001\\001.sfproj");



                //"J://Z0176-809.dd"
                //"E://anli/FAT32.img"
                //var cs = SingularityForensic.Contracts.Casing.CaseService.Current.CreateNewCase();
                //foreach (var evi in SingularityForensic.Contracts.Casing.CaseService.Current.CurrentCase.CaseEvidences.ToList()) {
                //    SingularityForensic.Contracts.Casing.CaseService.Current.CurrentCase.RemoveCaseEvidence(evi);
                //}

                //SingularityForensic.Contracts.Imaging.ImgService.Current.AddImg("E://anli/FAT32.img");
                var file = FileSystemService.Current.MountedUnits.First().File;

                //var file = FileSystemService.Current.MountStream(System.IO.File.OpenRead(), "mmp", null, null);
                var unit = TreeUnitFactory.CreateNew(SingularityForensic.Contracts.FileExplorer.Constants.TreeUnitType_FileSystem);
                unit.SetInstance(file, SingularityForensic.Contracts.FileExplorer.Constants.TreeUnitTag_FileSystem_File);
                CommonEventHelper.GetEvent <TreeUnitSelectedChangedEvent>().Publish((unit, MainTreeService.Current));
                CommonEventHelper.PublishEventToHandlers((unit, MainTreeService.Current), GenericServiceStaticInstances <ITreeUnitSelectedChangedEventHandler> .Currents);
                CommonEventHelper.GetEvent <TreeUnitSelectedChangedEvent>().Publish((unit, MainTreeService.Current));
                CommonEventHelper.GetEvent <TreeUnitSelectedChangedEvent>().Publish((unit, MainTreeService.Current));
            };
        }
コード例 #4
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>();
        }
コード例 #5
0
        public void AddDocumentTest()
        {
            var newDoc        = _documentService.CreateNewDocument();
            var addingCatched = false;
            var addedCathed   = true;

            CommonEventHelper.GetEvent <DocumentAddingEvent>().Subscribe(tuple => {
                addingCatched = true;
                Assert.AreEqual(tuple.tab, newDoc);
            });
            CommonEventHelper.GetEvent <DocumentAddedEvent>().Subscribe(tuple => {
                addedCathed = true;
                Assert.AreEqual(tuple.tab, newDoc);
            });

            _documentService.AddDocument(newDoc);

            Assert.IsTrue(addingCatched);
            Assert.IsTrue(addedCathed);

            Assert.AreEqual(_documentService.CurrentDocuments.Count(), 1);
            Assert.AreEqual(_documentService.SelectedDocument, newDoc);
            Assert.AreEqual(_documentService.CurrentDocuments.First(), newDoc);

            Assert.AreEqual(_documentService.VM.Documents.Count, 1);
            Assert.AreEqual(_documentService.VM.Documents.First(), newDoc);
        }
コード例 #6
0
        public SnapPositionStatuBarItem() : base(StatusBarItem_SnapPosition)
        {
            this.Text  = LanguageService.FindResourceString(StatusBarText_CurrentSnapPosition);
            this.Order = StatusBarOrder_SnapingPosition;

            CommonEventHelper.GetEvent <CanvasMouseHoverSnapShapeChangedEvent>().Subscribe(CanvasDataContext_MouseHoverSnapShapeChanged);
        }
コード例 #7
0
        public void TestLoadCaseEvidence()
        {
            AddNewCaseEvidence();

            //测试案件文件加载中/已加载是否能够被正常触发;
            var evidenceLoading = false;
            var evidenceLoaded  = false;

            CommonEventHelper.GetEvent <CaseEvidenceLoadingEvent>().Subscribe(tuple => {
                evidenceLoading = true;
                Assert.AreEqual(tuple.csEvidence, _csEvidence);
            });

            CommonEventHelper.GetEvent <CaseEvidenceLoadedEvent>().Subscribe(csEvidence => {
                evidenceLoaded = true;
                Assert.AreEqual(csEvidence, _csEvidence);
            });

            LoadCaseEvidence();

            Assert.IsTrue(evidenceLoading);
            Assert.IsTrue(evidenceLoaded);

            Assert.AreEqual(_csService.CurrentCase.CaseEvidences.Count(), 1);
            Assert.AreEqual(_csService.CurrentCase.CaseEvidences.First(), _csEvidence);
        }
コード例 #8
0
        public void AddUnit(ITreeUnit parentUnit, ITreeUnit nUnit)
        {
            if (nUnit == null)
            {
                throw new ArgumentNullException($"{nameof(nUnit)}");
            }

            ThreadInvoker.UIInvoke(() => {
                if (parentUnit == null)
                {
                    VM.AddUnit(nUnit);
                }
                else
                {
                    parentUnit.Children.Add(nUnit);
                }
            });

            try {
                CommonEventHelper.GetEvent <TreeUnitAddedEvent>().Publish((nUnit, this));
                CommonEventHelper.PublishEventToHandlers((nUnit, this as ITreeService), _treeUnitAddedEventHandlers);
            }
            catch (Exception ex) {
                LoggerService.WriteCallerLine(ex.Message);
            }
        }
コード例 #9
0
        public IPartitionsBrowserViewModel CreatePartitionsBrowserViewModel(IDevice device)
        {
            var vm = new PartitionsBrowserViewModel(device);

            CommonEventHelper.GetEvent <PartitionsBrowserViewModelCreatedEvent>().Publish(vm);
            return(vm);
        }
コード例 #10
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);
        }
コード例 #11
0
        private void RegisterEvents()
        {
            CommonEventHelper.GetEvent <CaseEvidenceLoadingEvent>().Subscribe(OnCaseEvidenceLoading);

            CommonEventHelper.GetEvent <CaseEvidenceRemovedEvent>().Subscribe(OnCaseEvidenceRemoved);

            CommonEventHelper.GetEvent <CaseUnloadedEvent>().Subscribe(OnCaseUnloaded);
        }
コード例 #12
0
        private void RegisterEvents()
        {
            CommonEventHelper.GetEvent <CaseEvidenceLoadingEvent>().SubscribeCheckingSubscribed((Action <(ICaseEvidence csEvidence, IProgressReporter reporter)>)OnCaseEvidenceLoading);

            CommonEventHelper.GetEvent <CaseEvidenceRemovedEvent>().SubscribeCheckingSubscribed((Action <ICaseEvidence>)OnCaseEvidenceRemoved);

            CommonEventHelper.GetEvent <CaseUnloadedEvent>().SubscribeCheckingSubscribed((Action <ICase>)OnCaseUnloaded);
        }
コード例 #13
0
 private void RegisterEvents()
 {
     CommonEventHelper.GetEvent <CaseLoadingEvent>().Subscribe(cs => {
         _caseLoading = true;
     });
     CommonEventHelper.GetEvent <CaseLoadedEvent>().Subscribe(() => {
         _caseLoaded = true;
     });
 }
コード例 #14
0
        /// <summary>
        /// 注册事件;
        /// </summary>
        private void RegisterEvents()
        {
            //订阅HDD/卷案件加载事件;
            CommonEventHelper.GetEvent <CaseEvidenceLoadingEvent>().Subscribe(OnCaseLoadingOnDrive);

            CommonEventHelper.GetEvent <CaseUnloadedEvent>().Subscribe(OnCaseUnloadedOnDrive);

            CommonEventHelper.GetEvent <CaseEvidenceRemovedEvent>().Subscribe(OnCaseEvidenceRemovedOnDrive);
        }
コード例 #15
0
        public void Initialize()
        {
            CommonEventHelper.
            GetEvent <Contracts.Splash.Events.SplashMessageEvent>().
            Publish(LanguageService.FindResourceString(Constants.SplashText_HexModuleBeingLoaded));


            HexUIService.Current.Initialize();
        }
コード例 #16
0
        private void VM_SelectedDocumentChanged(object sender, EventArgs e)
        {
            if (sender != VM)
            {
                return;
            }

            CommonEventHelper.GetEvent <SelectedDocumentChangedEvent>().Publish((SelectedDocument, this));
        }
コード例 #17
0
        public void Handle(IStatusBarService statusBarService)
        {
            if (statusBarService == null)
            {
                return;
            }

            //画布当前鼠标位置发生变化时,通知状态栏;
            CommonEventHelper.GetEvent <CanvasCurrentMousePositionChangedEvent>().Subscribe(CanvasDataContext_CurrentMousePositionChanged);
        }
コード例 #18
0
        public void Initialize()
        {
            CommonEventHelper.GetEvent <SplashMessageEvent>().
            Publish(LanguageService.FindResourceString(Constants.CaseModuleBeingLoaded));

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

            _caseUiService = ServiceProvider.Current?.GetInstance <ICaseUIService>();
            _caseUiService?.Initialize();
        }
コード例 #19
0
        public void ClearUnits()
        {
            var cArgs = new CancelEventArgs();

            CommonEventHelper.GetEvent <TreeUnitsClearingEvent>().Publish((cArgs, this));
            if (!cArgs.Cancel)
            {
                VM.TreeUnits.Clear();
            }
        }
コード例 #20
0
 public void Initialize()
 {
     try {
         CommonEventHelper.Publish <CanvasDataContextInitializingEvent, ICanvasDataContext>(CanvasDataContext);
         CommonEventHelper.PublishEventToHandlers <ICanvasDataContextInitializingEventHandler, ICanvasDataContext>(CanvasDataContext);
     }
     catch (Exception ex) {
         LoggerService.WriteException(ex);
     }
 }
コード例 #21
0
        /// <summary>
        /// 注册关闭事件;
        /// </summary>
        private void RegisterCloseEvents()
        {
            CommonEventHelper.GetEvent <DocumentClosingEvent>().Subscribe(tuple => {
                closingCatched = true;
            });

            CommonEventHelper.GetEvent <DocumentClosedEvent>().Subscribe(tuple => {
                closedCatched = true;
            });
        }
コード例 #22
0
        public void LoadHexDataContext(IHexDataContext hexDataContext)
        {
            if (hexDataContext == null)
            {
                throw new ArgumentNullException(nameof(hexDataContext));
            }

            CommonEventHelper.PublishEventToHandlers(hexDataContext, _hexDataContextLoadedEventHandlers);

            CommonEventHelper.GetEvent <HexDataContextLoadedEvent>().Publish(hexDataContext);
        }
コード例 #23
0
        public CurrentEditToolStatusBarItem(
            [ImportMany] IEnumerable <Lazy <IEditToolProvider, IEditToolProviderMetaData> > mefEditToolProviders
            ) : base(StatusBarItem_CurrentEditTool)
        {
            this.Order            = StatusBarOrder_CurrentEditTool;
            _mefEditToolProviders = mefEditToolProviders;

            CommonEventHelper.GetEvent <CanvasEditToolChangedEvent>().Subscribe(EditTool_Loaded);

            Text = _statusBarText_CurrentEditTool;
        }
コード例 #24
0
        public PropertyGridViewModel(MefPropertyGridManager mefPropertyManager,
                                     [ImportMany] IEnumerable <Lazy <IObjectTypeDescriptor, IObjectTypeDescriptorMetaData> > mefObjectTypeDescriptors
                                     )
        {
            _mefPropertyManager       = mefPropertyManager;
            _mefObjectTypeDescriptors = mefObjectTypeDescriptors.Select(p => new CreatedObjectTypeDescriptor(p.Value, p.Metadata)).ToArray();

            CommonEventHelper.GetEvent <CanvasDrawObjectIsSelectedChangedEvent>().Subscribe(DrawObject_IsSelectedChanged);
            CommonEventHelper.GetEvent <CanvasDrawObjectsAddedEvent>().Subscribe(DrawObjects_Added);
            CommonEventHelper.GetEvent <CanvasDrawObjectsRemovedEvent>().Subscribe(DrawObjects_Removed);
        }
コード例 #25
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) {
            }
        }
コード例 #26
0
        public void TestPartitionDoubleClick()
        {
            var clicked = false;

            CommonEventHelper.GetEvent <PartitionDoubleClickedEvent>().Subscribe(tuple => {
                clicked = true;
                Assert.AreEqual(tuple.part, _vm.Partitions[0].File);
            });

            _vm.NotifyDoubleClickOnRow(_vm.Partitions[0]);
            Assert.IsTrue(clicked);
        }
コード例 #27
0
        public void TestOnTreeUnitAdded()
        {
            var csUnit     = TreeUnitFactory.CreateNew(SingularityForensic.Contracts.Casing.Constants.TreeUnitType_CaseEvidence);
            var csEvidence = CaseService.Current.CreateNewCaseEvidence(new string[] { }, string.Empty, string.Empty);
            var file       = _fsService.MountStream(File.OpenRead(AppMockers.OpenFileName), csEvidence.Name, csEvidence.EvidenceGUID, null);

            csUnit.SetInstance(csEvidence, SingularityForensic.Contracts.Casing.Constants.TreeUnitTag_CaseEvidence);

            CommonEventHelper.GetEvent <TreeUnitAddedEvent>().Publish((csUnit, MainTreeService.Current));

            Assert.AreEqual(csUnit.Children.Count, 1);
        }
コード例 #28
0
        public void Initialize()
        {
            if (Initialized)
            {
                return;
            }

            _shell.Closing += Shell_Closing;
            CommonEventHelper.GetEvent <ShellInitializingEvent>().Publish();
            CommonEventHelper.PublishEventToHandlers <IShellInitializingEventHandler>();
            Initialized = true;
        }
コード例 #29
0
        public object CreateView(string viewName, object dataContext)
        {
            var elem = _serviceProvider.GetInstance <FrameworkElement>(viewName);

            if (elem != null)
            {
                elem.DataContext = dataContext;
            }
            CommonEventHelper.GetEvent <ViewCreatedEvent>().Publish((elem as object, viewName));
            CommonEventHelper.PublishEventToHandlers((elem as object, viewName), ViewCreateEventHandlers);
            return(elem);
        }
コード例 #30
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;
     }
 }