Ejemplo n.º 1
0
        private void Window_ContentRendered(object sender, EventArgs e)
        {
            skp = new Skype();
            ThemeManager.ChangeTheme(this, new MahApps.Metro.Accent("Steel", new Uri("pack://application:,,,/MahApps.Metro;component/Styles/Accents/Steel.xaml")), Theme.Light);
                                                                        // Change the accent of the title bar to a more fitting "Steel" color.

            rm = Languages.Text.ResourceManager;                        // Initialize the ResourceManager

            var dc = new DisclaimerWindow();                            // Display the Disclaimer Window
            dc.WindowStartupLocation = WindowStartupLocation.Manual;    // And PROPERLY center it - WindowStartupLocation.CenterOwner doesn't do it properly for some reason
            dc.Left = this.Left + ((this.Width - dc.Width) / 2);        // Basically : position + ( size difference / 2 )
            dc.Top = this.Top + ((this.Height - dc.Height) / 2);
            dc.ShowDialog();

            if (dc.DialogResult != true)                    // If the dislaimer is not confirmed (the window is "just" closed)
                Environment.Exit(0);                        // Then exit.

            if (!skp.Client.IsRunning)                      // Check if the Skype client is running
            {
                //MessageBox.Show(rm.GetString("errSkypeNotFound"), rm.GetString("titleError"), MessageBoxButton.OK, MessageBoxImage.Error);
                var mmb = new ModernMsgBox(rm.GetString("errSkypeNotFound"), MessageBoxImage.Error);    // Since MahApps.Metro doesn't contain a way to
                mmb.Left = this.Left + ((this.Width - mmb.Width) / 2);                                  // display a message box fitting into the design
                mmb.Top = this.Top + ((this.Height - mmb.Height) / 2);                                  // I made one myself, more info in its code
                mmb.ShowDialog();                                                                       // I'm including the MessageBox equivalent in comment
                Environment.Exit(0);                                                                    // every time we need to invoke it for refference...
            }

            try
            {
                skp.Attach(6, true);            // Try to attach to Skype, and prepare for problems...
            }
            catch (COMException)
            {
                //MessageBox.Show(rm.GetString("errSkypeTookTooLong"), rm.GetString("titleError"), MessageBoxButton.OK, MessageBoxImage.Error);
                var mmb = new ModernMsgBox(rm.GetString("errSkypeTookTooLong"), MessageBoxImage.Error); // If it screws up, display an error message
                mmb.Left = this.Left + ((this.Width - mmb.Width) / 2);
                mmb.Top = this.Top + ((this.Height - mmb.Height) / 2);
                mmb.ShowDialog();
                Environment.Exit(0);
            }

            statusLabel.Content = rm.GetString("statusConnected");
        }
Ejemplo n.º 2
0
        // This is for the launch button, this is where the fun begins!
        private void btnFlood_Click(object sender, RoutedEventArgs e)
        {
            string message = messageTextBox.Text;   // We define a few variables to store the parameters of the work
            int _count = 0;
            int _delay = 0;

            if (message == "")      // If the message to send is empty, then cuss out- *ahem* I meant warn the user and return from the void
            {
                //MessageBox.Show(rm.GetString("warnInputMessage"), rm.GetString("titleWarning"), MessageBoxButton.OK, MessageBoxImage.Warning);
                var mmb = new ModernMsgBox(rm.GetString("warnInputMessage"), MessageBoxImage.Warning);
                mmb.Left = this.Left + ((this.Width - mmb.Width) / 2);
                mmb.Top = this.Top + ((this.Height - mmb.Height) / 2);
                mmb.ShowDialog();
                return;
            }

            bool msgAmountParsable = Int32.TryParse(countTextBox.Text, out _count);     // For some reason try/catch blocks don't work reliably inside WPF...
            if (msgAmountParsable == false)                                             // So we have to make due without it! Int32.TryParse is perfect for it,
                                                                                        // since in the event of a successful conversion we can save the result
            {                                                                           // but if it fails nothing happens, and that's awesome
                //MessageBox.Show(rm.GetString("warnMsgAmountInvalid"), rm.GetString("titleWarning"), MessageBoxButton.OK, MessageBoxImage.Warning);
                var mmb = new ModernMsgBox(rm.GetString("warnMsgAmountInvalid"), MessageBoxImage.Warning);  // So anyway, it it fails, show a simple polite warning to the user
                mmb.Left = this.Left + ((this.Width - mmb.Width) / 2);                                      // and return from this void
                mmb.Top = this.Top + ((this.Height - mmb.Height) / 2);
                mmb.ShowDialog();
                return;
            }

            if (_count <= 0)        // If the amount of messages to send is too low, then once again warn the user and return...
            {
                //MessageBox.Show(rm.GetString("warnMsgAmountTooSmall"), rm.GetString("titleWarning"), MessageBoxButton.OK, MessageBoxImage.Warning);
                var mmb = new ModernMsgBox(rm.GetString("warnMsgAmountTooSmall"), MessageBoxImage.Warning);
                mmb.Left = this.Left + ((this.Width - mmb.Width) / 2);
                mmb.Top = this.Top + ((this.Height - mmb.Height) / 2);
                mmb.ShowDialog();
                return;
            }

            bool msgSendIntervalParsable = Int32.TryParse(delayTextBox.Text, out _delay);   // If we got this far, we go and try to parse the sending interval
            if (msgSendIntervalParsable == false)                                           // Exactly the same thing as before...
            {
                //MessageBox.Show(rm.GetString("warnSendingIntervalInvalid"), rm.GetString("titleWarning"), MessageBoxButton.OK, MessageBoxImage.Warning);
                var mmb = new ModernMsgBox(rm.GetString("warnSendingIntervalInvalid"), MessageBoxImage.Warning);
                mmb.Left = this.Left + ((this.Width - mmb.Width) / 2);
                mmb.Top = this.Top + ((this.Height - mmb.Height) / 2);
                mmb.ShowDialog();
                return;
            }

            if (_delay <= 0)
            {
                //MessageBox.Show(rm.GetString("warnSendingIntervalTooSmall"), rm.GetString("titleWarning"), MessageBoxButton.OK, MessageBoxImage.Warning);
                var mmb = new ModernMsgBox(rm.GetString("warnSendingIntervalTooSmall"), MessageBoxImage.Warning);
                mmb.Left = this.Left + ((this.Width - mmb.Width) / 2);
                mmb.Top = this.Top + ((this.Height - mmb.Height) / 2);
                mmb.ShowDialog();
                return;
            }
                                                        // If we got here, it means all the user input is correct and we can go 'make some noise'!
            stopButton.IsEnabled = true;                // We enable the stop button
            launchButton.IsEnabled = false;             // And disable the launch button
            statusLabel.Content = rm.GetString("statusWorking");    // Change the status label to notify the user we're working
            messagesSent = 0;                           // Since we're about to start, we set the amount of messages sent (used outside this void) to 0

                                                        // We prepare the taskbar "progress" bar by setting the progress state to normal. We need to ALWAYS
                                                        // check if we're running atleast Windows 7, because calling Windows API functions that aren't there
            if (tbProgressSupported)                    // will most likely lead to severe program issues... Luckily, we have a boolean for that
                Win7ProgressBar.TBProgress.SetProgressState(new WindowInteropHelper(this).Handle, ThumbnailProgressState.Normal);

            string[] floodData_ = { message, countTextBox.Text, delayTextBox.Text, iuc[userSearchListBox.SelectedIndex + 1].Handle };
                                                        // We prepare a little four string array to pass to the worker
            floodWorker = new BackgroundWorker();       // Then we define the BackgroundWorker and set up it's properties...
            floodWorker.WorkerReportsProgress = true;
            floodWorker.WorkerSupportsCancellation = true;
            floodWorker.DoWork += floodWorker_DoWork;   // ..enabling us to define the three events it raises
            floodWorker.ProgressChanged += floodWorker_ProgressChanged;
            floodWorker.RunWorkerCompleted += floodWorker_Completed;
            floodWorker.RunWorkerAsync(floodData_);     // And we start it, passing the work data to it
        }
Ejemplo n.º 3
0
        // This is for the "search" button
        private void button1_Click(object sender, RoutedEventArgs e)
        {
            if (userSearchTextBox.Text == "")                           // If the textBox is empty, warn the user
            {
                //MessageBox.Show(rm.GetString("warnInputUsername"), rm.GetString("titleWarning"), MessageBoxButton.OK, MessageBoxImage.Warning);
                var mmb = new ModernMsgBox(rm.GetString("warnInputUsername"), MessageBoxImage.Warning); // If you pass the MessageBoxImage as warning,
                mmb.Left = this.Left + ((this.Width - mmb.Width) / 2);                                  // then ModernMsgBox displays differently
                mmb.Top = this.Top + ((this.Height - mmb.Height) / 2);
                mmb.ShowDialog();
                return;
            }

            userSearchListBox.Items.Clear();                        // First, we clean the listBox
            iuc = skp.SearchForUsers(userSearchTextBox.Text);       // Then we define the Skype4COM IUserCollection using a SearchForUsers method with the input from the name

            foreach (IUser u in iuc)                                // Even though it's an independent class, IUserCollection can be looped through with a foreach statement
            {
                userSearchListBox.Items.Add(u.FullName + " (" + u.Handle + ")");    // We add every user as a new item to the listBox using both his
            }                                                                       // FullName and Handle property to allow for certain identification
        }