// ------------------------------------------------------------------------- // Programme principal // ------------------------------------------------------------------------- public MainWindow() { // On met les Recent Registry (from Parameter File) dans une liste RecentsRegs.Add(Properties.Settings.Default.Recent_1); RecentsRegs.Add(Properties.Settings.Default.Recent_2); RecentsRegs.Add(Properties.Settings.Default.Recent_3); RecentsRegs.Add(Properties.Settings.Default.Recent_4); RecentsRegs.Add(Properties.Settings.Default.Recent_5); RecentsRegs.Add(Properties.Settings.Default.Recent_6); InitializeComponent(); // Cette instruction permet de rendre les classes visibles depuis le XAML DataContext = this; // On charge le dictionnaire des unités préférées UnitDictionnary = new KeyUnitDictionnary("Config.xml"); // On initialise le parseur Parser1 = new RegFileParser(RegistryTree1, UnitDictionnary); Parser2 = new RegHiveParser(RegistryTree1, UnitDictionnary); // ----------------------------- // On definit les bindings: // Normalement on devrait pouvoir mettre ceci dans le XAML du TreeView, mais ça marche pas: // ... ItemsSource="{Binding Source=RegistryTree1}" ... // ... ItemsSource="{Binding Source=StaticResource RegistryTree1}" ... // ----------------------------- // Bind du StackPanel qui contient la liste des Recent Registry RecentRegData.ItemsSource = this.RecentsRegs; // Bind du RegistryTree avec le TreeView de l'affichage TreeView1.ItemsSource = RegistryTree1; Lb_SearchedWordCount.Text = ""; }
// ------------------------------------------------------------------ // Constructeur (on repasse les paramètre à la classe de base) // ------------------------------------------------------------------ public RegFileParser(ObservableCollection <RegistryItem> registrytree, KeyUnitDictionnary dictionnary) : base(registrytree, dictionnary) { // On initialise les variables des statistiques du fichier Array.Clear(TableStats, 0, TableStats.Length); AverageLabelLength = 0; ModalLabelLength = 0; }
// -------------------------------------------- // Passe à l'unité suivante dans la liste // -------------------------------------------- public void ChangeToNextUnit(KeyUnitDictionnary unitDictionnary) { // On récupère l'unité suivante this.UserFriendlyUnit = unitDictionnary.GetNextUnit(this.UserFriendlyUnit); // On recalcule la UserFriendyValue this.UpdateUserFriendyValue(); // On ajoute la nouvelle correspondance dans le dictionnaire unitDictionnary.SetValue(Name, this.UserFriendlyUnit); }
// ------------------------------------------------------------------ // CONSTRUCTEUR // Le constructeur de la sous-classe appelle toujours celui de la classe de base, implicitement ou explicitement. // Si rien n'est spécifié, le compilateur génère un appel implicite au constructeur de la classe de base ne comportant aucun paramètre. // ------------------------------------------------------------------ public BaseParser(ObservableCollection <RegistryItem> registrytree, KeyUnitDictionnary dictionnary) { // On mémorise le registrytree et le dictionnaire RegistryTree = registrytree; PreferedUnits = dictionnary; // On crée un objet NodeList NodeList = new List <RegistryItem>(); this.InitParser(); }
// ------------------------------------------------------------------ // Constructeur (on repasse les paramètres à la classe de base) // ------------------------------------------------------------------ public RegHiveParser(ObservableCollection <RegistryItem> registrytree, KeyUnitDictionnary dictionnary) : base(registrytree, dictionnary) { }