Esempio n. 1
0
        /// <summary>
        /// This function is called when the language combobox is loaded and sets up the options depending on the available languages
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void cb_language_Loaded(object sender, RoutedEventArgs e)
        {
            var comboBox = sender as ComboBox;

            onLoad = true;

            comboBox.ItemsSource = LanguageFile.GetLanguages();

            comboBox.SelectedItem = App.CurrentLanguage;
        }
Esempio n. 2
0
        /// <summary>
        /// This function is called when the user selects a language from the ComboBox
        /// This function then updates the DataContext of the program.
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void cb_language_SelectionChanged(object sender, SelectionChangedEventArgs e)
        {
            if (onLoad)
            {
                e.Handled = true;
                onLoad    = false;
                return;
            }

            var comboBox = sender as ComboBox;

            LanguageFile.Language value = (LanguageFile.Language)comboBox.SelectedItem;

            Properties.Settings.Default.lan = value.sName;

            App.translation = LanguageFile.GetTranslation(value.sName);
        }
Esempio n. 3
0
        /// <summary>
        /// Consturctor
        /// </summary>
        public App()
        {
            Sniffer = new PacketSniffer();

            // Load settings...

            string lan = NSA4Dummies.Properties.Settings.Default.lan;

            // Check if there is at least one language file existing

            if (null == LanguageFile.GetLanguages())
            {
                languageFileMissing = true;
                System.Windows.MessageBox.Show("There was no language file found! Please add one manually or reinstall the software.", "ERROR! No language file found", MessageBoxButton.OK, MessageBoxImage.Error);
            }
            else
            {
                // Load language file...

                translation = LanguageFile.GetTranslation(lan);

                this.niContextMenu  = new System.Windows.Forms.ContextMenu();
                this.niStartSniffer = new System.Windows.Forms.MenuItem();
                this.niStopSniffer  = new System.Windows.Forms.MenuItem();
                this.niExit         = new System.Windows.Forms.MenuItem();
                this.components     = new System.ComponentModel.Container();

                // Initialize niContextMenu.
                this.niContextMenu.MenuItems.AddRange(new System.Windows.Forms.MenuItem[] { this.niStartSniffer, this.niStopSniffer, this.niExit });

                // Initialize niStartSniffer.
                this.niStartSniffer.Index  = 0;
                this.niStartSniffer.Text   = App.translation["notifyIcon.niStartSniffer"];
                this.niStartSniffer.Click += new System.EventHandler(this.niStart_Click);

                // Initialize niStopSniffer.
                this.niStopSniffer.Index  = 1;
                this.niStopSniffer.Text   = App.translation["notifyIcon.niStopSniffer"];
                this.niStopSniffer.Click += new System.EventHandler(this.niStop_Click);


                // Initialize niExit.
                this.niExit.Index  = 2;
                this.niExit.Text   = App.translation["notifyIcon.niExit"];
                this.niExit.Click += new System.EventHandler(this.niExit_Click);

                // Create the NotifyIcon.
                this.ntfyIcon = new System.Windows.Forms.NotifyIcon(this.components);

                // Set the icon for the systray.
                ntfyIcon.Icon        = (Icon)NSA4Dummies.Properties.Resources.NotifyIcon;
                ntfyIcon.ContextMenu = this.niContextMenu;
                ntfyIcon.Text        = App.translation["notifyIcon.niText"];
                ntfyIcon.Visible     = true;

                // Click events for NotifyIcon.
                ntfyIcon.Click       += new System.EventHandler(this.ntfyIcon_Click);
                ntfyIcon.DoubleClick += new System.EventHandler(this.ntfyIcon_DoubleClick);

                // Start network sniffing
                Sniffer.StartSniffer();
            }
        }