public void Decrypt() { UiServices.SetBusyState(); Paragraph paragraph = new Paragraph(); try { Message = LWE.Decrypt(cipher)[0, 0].ToString(); paragraph.Inlines.Add(new Bold(new Underline(new Run("** " + Languages.buttonDecrypt + " **\r\n")))); paragraph.Inlines.Add(new Bold(new Run(Languages.labelCiphertext))); paragraph.Inlines.Add(" " + Cipher + "\r\n"); paragraph.Inlines.Add(new Bold(new Run(Languages.labelPlainText))); paragraph.Inlines.Add(" " + Message + "\r\n"); NotifyPropertyChanged("Message"); } catch (Exception ex) { paragraph.Inlines.Add(new Bold(new Underline(new Run("** " + Languages.buttonDecrypt + " **\r\n")))); paragraph.Inlines.Add(new Bold(new Underline(new Run(Languages.labelAbort)))); paragraph.Inlines.Add(" " + ex.Message + "\r\n"); MessageBox.Show(string.Format(Languages.errorDecryptionError, ex.Message), Languages.error, MessageBoxButton.OK, MessageBoxImage.Error); } finally { if (History.Document.Blocks.FirstBlock != null) { History.Document.Blocks.InsertBefore(History.Document.Blocks.FirstBlock, paragraph); } else { History.Document.Blocks.Add(paragraph); } } }
public void Cryptanalysis() { try { UiServices.SetBusyState(); Paragraph paragraph = new Paragraph(); paragraph.Inlines.Add(new Bold(new Underline(new Run("** " + Languages.buttonCryptanalysis + " **\r\n")))); paragraph.Inlines.Add(new Bold(new Run(Languages.labelCiphertext))); paragraph.Inlines.Add(" " + Cipher + "\r\n"); Message = MerkleHellman.Cryptanalysis(cipher, paragraph); if (History.Document.Blocks.FirstBlock != null) { History.Document.Blocks.InsertBefore(History.Document.Blocks.FirstBlock, paragraph); } else { History.Document.Blocks.Add(paragraph); } NotifyPropertyChanged("Message"); } catch (Exception) { MessageBox.Show(Languages.errorNoSolutionFound, Languages.error, MessageBoxButton.OK, MessageBoxImage.Error); } NotifyPropertyChanged("Message"); }
private void Validate() { if (!UiServices.Contains <IUiNotification>()) { throw CdiHelper.CreateException(CdoWpfErrorCode.NotificationNotInstalled, "Notification service not installed."); } }
public void GenerateNewRSA(int bitSize) { UiServices.SetBusyState(); RSAModel = new RSAModel(bitSize); Paragraph paragraph = new Paragraph(); paragraph.Inlines.Add(new Bold(new Underline(new Run("** " + Languages.buttonGenerateNewCryptosystem + " **\r\n")))); paragraph.Inlines.Add(new Bold(new Run(Languages.labelPrimeP))); paragraph.Inlines.Add(" " + PrimP + "\r\n"); paragraph.Inlines.Add(new Bold(new Run(Languages.labelPrimeQ))); paragraph.Inlines.Add(" " + PrimQ + "\r\n"); paragraph.Inlines.Add(new Bold(new Run(Languages.labelModulus))); paragraph.Inlines.Add(" " + ModulusN + "\r\n"); paragraph.Inlines.Add(new Bold(new Run(Languages.labelPrivateExponentD))); paragraph.Inlines.Add(" " + ExpD + "\r\n"); paragraph.Inlines.Add(new Bold(new Run(Languages.labelPublicExponentE))); paragraph.Inlines.Add(" " + ExpE + "\r\n"); if (History.Document.Blocks.FirstBlock != null) { History.Document.Blocks.InsertBefore(History.Document.Blocks.FirstBlock, paragraph); } else { History.Document.Blocks.Add(paragraph); } NotifyPropertyChanged("PrimP"); NotifyPropertyChanged("PrimQ"); NotifyPropertyChanged("ModulusN"); NotifyPropertyChanged("ExpD"); NotifyPropertyChanged("ExpE"); NotifyPropertyChanged("ValidationInfo"); }
public void GenerateNewLattice(int n, int m, BigInteger codomainStart, BigInteger codomainEnd) { UiServices.SetBusyState(); LatticeND newLattice = new LatticeND(n, m, false); //Zur Generierung von kritischen Gittern //while (Math.Round(newLattice.AngleReducedVectors, 0) != 60) //{ newLattice.GenerateRandomVectors(ReductionMethod == ReductionMethods.reduceGauss, codomainStart, codomainEnd); switch (ReductionMethod) { case ReductionMethods.reduceGauss: newLattice.GaussianReduce(); break; default: newLattice.LLLReduce(); break; } //} Lattice = newLattice; WriteHistoryForNewLattice(Languages.buttonGenerateNewLattice); NotifyPropertyChanged("Lattice"); }
public void GenerateNewGGH(int dim, int l) { UiServices.SetBusyState(); GGH = GGH != null && GGH.dim == dim ? new GGHModel(dim, l, GGH.errorVector) : new GGHModel(dim, l); Paragraph paragraph = new Paragraph(); paragraph.Inlines.Add(new Bold(new Underline(new Run("** " + Languages.buttonGenerateNewCryptosystem + " **\r\n")))); paragraph.Inlines.Add(new Bold(new Run(Languages.labelPrivateKeyR + ":"))); paragraph.Inlines.Add(" " + GGH.privateKeyR + "\r\n"); paragraph.Inlines.Add(new Bold(new Run(Languages.labelPrivateKeyR1 + ":"))); paragraph.Inlines.Add(" " + GGH.privateKeyR1.ToStringLog() + "\r\n"); paragraph.Inlines.Add(new Bold(new Run(Languages.labelPublicKeyB + ":"))); paragraph.Inlines.Add(" " + GGH.publicKeyB + "\r\n"); paragraph.Inlines.Add(new Bold(new Run(Languages.labelPublicKeyB1 + ":"))); paragraph.Inlines.Add(" " + GGH.publicKeyB1.ToStringLog() + "\r\n"); paragraph.Inlines.Add(new Bold(new Run(Languages.labelUnimodularTransformationMatrix + ":"))); paragraph.Inlines.Add(" " + Lattice.LatticeTransformationToString() + "\r\n"); paragraph.Inlines.Add(new Bold(new Run(Languages.labelParameterL))); paragraph.Inlines.Add(" " + GGH.l + "\r\n"); paragraph.Inlines.Add(new Bold(new Run(Languages.labelErrorVector))); paragraph.Inlines.Add(" " + GGH.errorVector + "\r\n"); if (History.Document.Blocks.FirstBlock != null) { History.Document.Blocks.InsertBefore(History.Document.Blocks.FirstBlock, paragraph); } else { History.Document.Blocks.Add(paragraph); } NotifyPropertyChanged("ErrorVector"); }
public static TherapeuteDB Connexion(string login, string pass) { //permet au TU de donner la fausse BD if (conn == null) { bdd = new ReaPlanDBEntities(); UiServices.SetBusyState(); } else { bdd = new ReaPlanDBEntities(conn); } //Cryptage du mot de passe entré pour le comparer avec le mdp crypté de la bd if (pass != null && login != null) { string password = login.ToLower() + pass; UTF8Encoding textConverter = new UTF8Encoding(); byte[] passBytes = textConverter.GetBytes(password); pass = Convert.ToBase64String(new SHA384Managed().ComputeHash(passBytes)); } using (bdd) { var requete = from c in bdd.TherapeuteDBs where c.Login == login && c.MotDePasse == pass select c; TherapeuteDB therapeute = requete.FirstOrDefault(); return(therapeute); } }
protected override void LoadChildren() { UiServices.SetBusyState(); var bookLookup = Directory .GetFiles(ArtFilesSourcePath, "*.*", SearchOption.AllDirectories) .Where(n => ValidRegex.IsMatch(Path.GetFileName(n) ?? "")) .Select(n => new ArtFile(n)) .ToLookup(k => new { k.Id, k.BookType, k.Name }); var books = bookLookup .Select(v => new BookTreeViewItemViewModel(this) { BookType = v.Key.BookType, Name = v.Key.Name, ItemId = v.Key.Id, PageSourcePath = ArtFilesSourcePath, ArtFiles = bookLookup[v.Key].ToList() }) .OrderBy(v => v.BookType); foreach (var bookViewModel in books) { var firstPdf = bookViewModel.ArtFiles.FirstOrDefault(b => b.ArtFileType == ArtFileType.Pdf); if (firstPdf != null) { bookViewModel.PageSourcePath = firstPdf.ParentPath; } Children.Add(bookViewModel); } }
public override async Task ExecuteAsync() { await ShowProgressAndUpdateModelAsync(); UiServices.ShowDiagramWindow(); UiServices.ZoomToDiagram(); }
private void _reloadFiles(MediaDirectoryViewmodel directory) { if (directory?.IsInitialized == true && (!directory.IsIngestDirectory || directory.IsImport)) { UiServices.SetBusyState(); if (_mediaItems != null) { foreach (var m in _mediaItems) { m.Dispose(); } } MediaItems = new ObservableCollection <MediaViewViewmodel>(directory.Directory.GetFiles().Select(f => new MediaViewViewmodel(f))); _mediaView = CollectionViewSource.GetDefaultView(_mediaItems); if (!directory.IsXdcam) { _mediaView.SortDescriptions.Add(new SortDescription(nameof(MediaViewViewmodel.MediaName), ListSortDirection.Ascending)); } if (!directory.IsArchiveDirectory) { _mediaView.Filter = _filter; } if (directory.IsXdcam && !directory.IsWan) { ThreadPool.QueueUserWorkItem(o => _refreshMediaDirectory(directory.Directory)); } } else { MediaItems = null; } }
public MainViewModel() { _windowState = (WindowState)Enum.Parse(typeof(WindowState), Services.UiConfig.WindowState); _windowWidth = Services.UiConfig.WindowWidth ?? 1280; _windowHeight = Services.UiConfig.WindowHeight ?? 960; var(x, y) = (Services.UiConfig.WindowX, Services.UiConfig.WindowY); if (x != null && y != null) { _windowPosition = new PixelPoint(x.Value, y.Value); } _dialogScreen = new DialogScreenViewModel(); _fullScreen = new DialogScreenViewModel(NavigationTarget.FullScreen); _compactDialogScreen = new DialogScreenViewModel(NavigationTarget.CompactDialogScreen); MainScreen = new TargettedNavigationStack(NavigationTarget.HomeScreen); NavigationState.Register(MainScreen, DialogScreen, FullScreen, CompactDialogScreen); _isMainContentEnabled = true; _isDialogScreenEnabled = true; _isFullScreenEnabled = true; _statusBar = new StatusBarViewModel(); UiServices.Initialize(); _addWalletPage = new AddWalletPageViewModel(); _settingsPage = new SettingsPageViewModel(); _privacyMode = new PrivacyModeViewModel(); _navBar = new NavBarViewModel(MainScreen); MusicControls = new MusicControlsViewModel(); NavigationManager.RegisterType(_navBar); RegisterViewModels(); RxApp.MainThreadScheduler.Schedule(async() => await _navBar.InitialiseAsync()); this.WhenAnyValue(x => x.WindowState, x => x.WindowPosition, x => x.WindowWidth, x => x.WindowHeight) .Where(x => x.Item1 != WindowState.Minimized) .Where(x => x.Item2 != new PixelPoint(-32000, -32000)) // value when minimized .ObserveOn(RxApp.MainThreadScheduler) .Subscribe(t => { var(state, position, width, height) = t; Services.UiConfig.WindowState = state.ToString(); if (position is { }) { Services.UiConfig.WindowX = position.Value.X; Services.UiConfig.WindowY = position.Value.Y; } Services.UiConfig.WindowWidth = width; Services.UiConfig.WindowHeight = height; });
public void Encrypt() { UiServices.SetBusyState(); MatrixND mesMat = new MatrixND(1, 1); mesMat[0, 0] = int.Parse(Message); Cipher = LWE.Encrypt(mesMat)[0, 0].ToString(); Paragraph paragraph = new Paragraph(); paragraph.Inlines.Add(new Bold(new Underline(new Run("** " + Languages.buttonEncrypt + " **\r\n")))); paragraph.Inlines.Add(new Bold(new Run(Languages.labelPlainText))); paragraph.Inlines.Add(" " + Message + "\r\n"); paragraph.Inlines.Add(new Bold(new Run(Languages.labelCiphertext))); paragraph.Inlines.Add(" " + Cipher + "\r\n"); if (History.Document.Blocks.FirstBlock != null) { History.Document.Blocks.InsertBefore(History.Document.Blocks.FirstBlock, paragraph); } else { History.Document.Blocks.Add(paragraph); } NotifyPropertyChanged("Cipher"); }
//Méthode appellé quand on clique sur le boutton Previous private void btPrev_Click(object sender, RoutedEventArgs e) { int posi = int.Parse((string)NumPage.Content); posi--; NumPage.Content = posi.ToString(); btNext.IsEnabled = true; UiServices.SetBusyState(); verifCheck(); }
public void OnLog4netEvent(object sender, ViewEventArgs args) { UiServices.Invoke(delegate() { if (System.Windows.Application.Current != null) { AppendText((string)args.Data); } }, true); }
public override async Task ExecuteAsync(IReadOnlyList <IModelEntity> modelEntities) { var diagramNodes = await ShowProgressAndAddItemsAsync(modelEntities); UiServices.ShowDiagramWindow(); if (diagramNodes.Count > 1) { UiServices.FollowDiagramNodes(diagramNodes); } }
public void GenerateNewMerkleHellman(int dim) { UiServices.SetBusyState(); MerkleHellman = new MerkleHellmanModel(dim); WriteHistoryForNewCryptosystem(Languages.buttonGenerateNewLattice); NotifyPropertyChanged("MerkleHellman"); NotifyPropertyChanged("PrivateKey"); NotifyPropertyChanged("PublicKey"); NotifyPropertyChanged("Mod"); NotifyPropertyChanged("R"); NotifyPropertyChanged("RI"); }
protected override void LoadChildren() { UiServices.SetBusyState(); var projectDirs = JobFolderRepo.JobFolders .Where(d => _catRegex.IsMatch(Path.GetFileName(d) ?? "")) .OrderBy(Path.GetFileName) .ToList(); foreach (var projectDir in projectDirs) { Children.Add(new ProjectViewModel(projectDir, this)); } }
void OnConsoleMessage(NotificationMessage <ConsoleMessageEventArgs> msg) { var e = msg.Content; if (string.IsNullOrEmpty(e.Message)) { return; } UiServices.Invoke(delegate() { AppendText(e.Message + "\n"); }, true); }
protected void LoadChildrens() { UiServices.SetBusyState(); foreach (IEvent se in Event.SubEvents) { Childrens.Add(CreateChildEventPanelViewmodelForEvent(se)); IEvent ne = se.Next; while (ne != null) { Childrens.Add(CreateChildEventPanelViewmodelForEvent(ne)); ne = ne.Next; } } }
public override async Task ExecuteAsync() { var modelEntity = await ModelServices.AddCurrentSymbolAsync(); if (modelEntity == null) { return; } var diagramNode = DiagramServices.ShowEntity(modelEntity); UiServices.ShowDiagramWindow(); UiServices.FollowDiagramNode(diagramNode); }
public void Handle(BookSelectedEvent message) { UiServices.SetBusyState(); var bvm = new BookViewModel(_progressViewModel, _windowManager, message.BookTreeViewItemViewModel); if (!message.IsSelected) { DeactivateItem(bvm, true); ActiveItem = null; return; } ActivateItem(bvm); }
public override async Task ExecuteAsync() { var filename = UiServices.SelectSaveFilename("Save Diagram Image to File", "PNG Image|*.png"); if (string.IsNullOrWhiteSpace(filename)) { return; } if (!filename.EndsWith(".png", StringComparison.InvariantCultureIgnoreCase)) { UiServices.ShowMessageBox("Only PNG file format is supported. Please select a file with .png extension."); return; } await CreateAndProcessDiagramImageAsync(i => SaveBitmapAsPng(i, filename), "Saving image file..."); }
public override void Execute(IDiagramNode diagramNode) { var modelEntity = diagramNode?.ModelEntity; if (modelEntity == null) { throw new Exception("Entity missing in DiagramNode."); } if (ModelServices.HasSource(modelEntity)) { ModelServices.ShowSource(modelEntity); } else { UiServices.ShowPopupMessage(NoSourceMessage, NoSourceMessageDuration); } }
protected void ClearChildrens() { if (!Childrens.Any()) { return; } if (!HasDummyChild) { UiServices.SetBusyState(); foreach (var c in Childrens.ToList()) { c.Dispose(); } if (Event.SubEventsCount > 0) { Childrens.Add(DummyChild); } } }
private async Task ShowProgressAndUpdateModelAsync() { using (var progressDialog = UiServices.CreateProgressDialog("Updating model entities:")) { progressDialog.ShowWithDelayAsync(); try { await UpdateModelAsync(progressDialog.CancellationToken, progressDialog.Progress); progressDialog.Reset("Updating diagram nodes:", DiagramServices.Nodes.Count); await UpdateDiagramAsync(progressDialog.CancellationToken, progressDialog.Progress); } catch (OperationCanceledException) { } } }
public override async Task ExecuteAsync() { var modelEntity = await ModelServices.AddCurrentSymbolAsync(); if (modelEntity == null) { return; } var diagramNodes = await ExtendModelAndDiagramAsync(modelEntity); if (diagramNodes == null) { return; } UiServices.ShowDiagramWindow(); UiServices.FollowDiagramNodes(diagramNodes); }
private async Task <IReadOnlyList <IDiagramNode> > ShowProgressAndAddItemsAsync(IReadOnlyList <IModelEntity> modelEntities) { IReadOnlyList <IDiagramNode> diagramNodes = null; using (var progressDialog = UiServices.CreateProgressDialog("Adding model items:", modelEntities.Count)) { progressDialog.ShowWithDelayAsync(); try { diagramNodes = await ShowEntitiesAsync(modelEntities, progressDialog.CancellationToken, progressDialog.Progress); } catch (OperationCanceledException) { } } return(diagramNodes); }
private void btn_buildHSS_Click(object sender, RoutedEventArgs e) { UiServices.SetBusyState(); hssp hss = new hssp(); hss.source = grid.file_def; if (path.Length > 1) { using (new WaitCursor()) { hss.build_package_references(tb_templatedir.Text); hss.buildHSS(delim, grid.startYear, grid.endYear, path); } } else { MessageBox.Show("Invalid output folder", "Error"); } }
private void _addRight(object obj) { using (var selector = new SecurityObjectSelectorViewmodel(_authenticationService)) { if (UiServices.ShowDialog <Views.SecurityObjectSelectorView>(selector) != true) { return; } var right = _engine.AddRightFor(selector.SelectedSecurityObject); if (right == null) { return; } var newRightVm = new EngineRightViewmodel(right); Rights.Add(newRightVm); SelectedRight = newRightVm; SelectedRight.Modified += EventRightViewmodel_Modified; IsModified = true; } }
public void Cryptanalysis() { UiServices.SetBusyState(); Paragraph paragraph = new Paragraph(); try { paragraph.Inlines.Add(new Bold(new Underline(new Run("** " + Languages.buttonCryptanalysis + " **\r\n")))); paragraph.Inlines.Add(new Bold(new Run(Languages.labelCiphertext))); paragraph.Inlines.Add(" " + Cipher + "\r\n"); paragraph.Inlines.Add(new Bold(new Run(Languages.labelKnownPlainText))); paragraph.Inlines.Add(" " + KnownMessage + "\r\n"); string left = message.Substring(0, unknownStart); string right = message.Substring(unknownStart + unknownLength); UnknownMessageResult = RSAModel.StereotypedAttack(left, right, unknownLength, cipher, "4"); paragraph.Inlines.Add(new Bold(new Run(Languages.labelResultUnknownPlainText))); paragraph.Inlines.Add(" " + UnknownMessageResult + "\r\n"); } catch (Exception ex) { UnknownMessageResult = ""; paragraph.Inlines.Add(new Bold(new Run(Languages.labelAbort))); paragraph.Inlines.Add(" " + ex.Message + "\r\n"); MessageBox.Show(ex.Message, Languages.error, MessageBoxButton.OK, MessageBoxImage.Error); } finally { if (History.Document.Blocks.FirstBlock != null) { History.Document.Blocks.InsertBefore(History.Document.Blocks.FirstBlock, paragraph); } else { History.Document.Blocks.Add(paragraph); } } }