Ejemplo n.º 1
0
 private void listBox1_SelectedIndexChanged(object sender, EventArgs e)
 {
     StatusTextBox.Text = LinkList.SelectedItem.ToString();
     StatusTextBox.SelectAll();
     StatusTextBox.Copy();
     StatusTextBox.Text = "Copied to clipboard: " + LinkList.SelectedItem.ToString();
 }
Ejemplo n.º 2
0
        private void newWorkerSubmit_Click(object sender, EventArgs e)
        {
            string newUserBannerId    = BannerTextBox.Text;
            string newUserFirstName   = FirstNameTextBox.Text;
            string newUserLastName    = LastNameTextBox.Text;
            string newUserPhoneNumber = PhoneNumberTextBox.Text;
            string newUserEmail       = EmailTextBox.Text;
            string newUserUserType    = UserTypeTextBox.Text;
            string newUserNotes       = NotesTextBox.Text;
            string newUserStatus      = StatusTextBox.Text;

            User newUser = new User(newUserBannerId, newUserFirstName, newUserLastName, newUserPhoneNumber, newUserEmail, newUserUserType, newUserNotes, newUserStatus);

            newUser.insert();

            BannerTextBox.Clear();
            FirstNameTextBox.Clear();
            LastNameTextBox.Clear();
            PhoneNumberTextBox.Clear();
            EmailTextBox.Clear();
            UserTypeTextBox.Clear();
            NotesTextBox.Clear();
            StatusTextBox.Clear();

            NewWorkerNotificationLabel.Text = "User added to database";
        }
Ejemplo n.º 3
0
        private void StartButton_Click(object sender, EventArgs e)
        {
            StartButton.Enabled = false;

            StatusTextBox.Clear();
            BackgroundWorker.RunWorkerAsync();
        }
Ejemplo n.º 4
0
        private void LoadBtn_Click(object sender, EventArgs e)
        {
            if (openFileDialog.ShowDialog() != DialogResult.OK)
            {
                return;
            }
            LoaderUtils.DataType dataType = GetDataType();
            StatusTextBox.AppendText("Loading " + LoaderUtils.DataTypeName(dataType).ToLower() + "(s) from file '" + openFileDialog.FileName + "'\n");
            String json = File.ReadAllText(openFileDialog.FileName);

            ProgressBar.Visible = true;
            ProgressLbl.Visible = true;
            try
            {
                int recordsLoaded = LoadJSON(json, dataType);
                StatusTextBox.AppendText(String.Format("Processed {0} {1}(s) from {2}\n",
                                                       recordsLoaded, LoaderUtils.DataTypeName(dataType).ToLower(), openFileDialog.FileName));
            }
            catch (DuplicateException de)
            {
                StatusTextBox.AppendText("Error: " + de.Message + "\n");
            }
            catch (JsonReaderException je)
            {
                StatusTextBox.AppendText("Error: " + je.Message + "\n");
            }
            ProgressBar.Visible = false;
            ProgressLbl.Visible = false;
        }
Ejemplo n.º 5
0
        private void exportListsBtn_Click(object sender, EventArgs e)
        {
            if (folderDlg.ShowDialog() != DialogResult.OK)
            {
                return;
            }
            string listDir = String.Format(@"{0}\l", folderDlg.SelectedPath);

            if (!Directory.Exists(listDir))
            {
                if (File.Exists(listDir))
                {
                    StatusTextBox.AppendText("ERROR: File '" + listDir + "' exists." + "\r\n");
                    return;
                }
                try
                {
                    Directory.CreateDirectory(listDir);
                }
                catch (Exception ex)
                {
                    StatusTextBox.AppendText("Error creating '" + listDir + "': " + ex.Message + "\r\n");
                    return;
                }
            }
            foreach (ProblemList pl in moonServer.ProblemLists)
            {
                StatusTextBox.AppendText("Exporting list '" + pl.Name + "'\r\n");
                writeProblems(pl.ProblemListEntries.Select(ple => ple.Problem), listDir, pl.Name, false);
            }
            StatusTextBox.AppendText("Done.\r\n");
        }
Ejemplo n.º 6
0
        /// <summary>
        /// Occurs when the dialer has completed a dialing operation.
        /// </summary>
        /// <param name="sender">The object that raised the event.</param>
        /// <param name="e">An <see cref="DotRas.DialCompletedEventArgs"/> containing event data.</param>
        private void Dialer_DialCompleted(object sender, DialCompletedEventArgs e)
        {
            if (e.Cancelled)
            {
                StatusTextBox.AppendText("Cancelled!");
            }
            else if (e.TimedOut)
            {
                StatusTextBox.AppendText("Connection attempt timed out!");
            }
            else if (e.Error != null)
            {
                StatusTextBox.AppendText(e.Error.ToString());
            }
            else if (e.Connected)
            {
                StatusTextBox.AppendText("Connection successful!");
            }

            if (!e.Connected)
            {
                // The connection was not connected, disable the disconnect button.
                DisconnectButton.Enabled = false;
            }
        }
Ejemplo n.º 7
0
Archivo: Main.cs Proyecto: sotaria/gsf
        // Registers or unregisters the OIDs used by GPA client applications based on user selection.
        private void ClientOIDCheckBox_CheckedChanged(object sender, EventArgs e)
        {
            if (!m_checkedEventsEnabled)
            {
                return;
            }

            if (ClientOIDCheckBox.Checked)
            {
                StatusTextBox.AppendText("Registering client OIDs... ");

                foreach (string clientOID in ClientOIDs)
                {
                    RegisterOID(clientOID);
                }
            }
            else
            {
                StatusTextBox.AppendText("Unregistring client OIDs... ");

                foreach (string clientOID in ClientOIDs)
                {
                    UnregisterOID(clientOID);
                }
            }

            AppendStatusMessage("Done.");
        }
Ejemplo n.º 8
0
        private byte[] ReadBySize(int size = 4)
        {
            var readEvent     = new AutoResetEvent(false);
            var buffer        = new byte[size]; //Receive buffer
            var totalRecieved = 0;

            do
            {
                var recieveArgs = new SocketAsyncEventArgs()
                {
                    UserToken = readEvent
                };
                recieveArgs.SetBuffer(buffer, totalRecieved, size - totalRecieved);//Receive bytes from x to total - x, x is the number of bytes already recieved
                recieveArgs.Completed += recieveArgs_Completed;
                sockClient.ReceiveAsync(recieveArgs);
                readEvent.WaitOne();                   //Wait for recieve

                if (recieveArgs.BytesTransferred == 0) //If now bytes are recieved then there is an error
                {
                    if (recieveArgs.SocketError != SocketError.Success)
                    {
                        StatusTextBox.AppendText($"SocketError:{recieveArgs.SocketError}");
                    }
                    //throw new ReadException(ReadExceptionCode.UnexpectedDisconnect, "Unexpected Disconnect");
                    //throw new ReadException(ReadExceptionCode.DisconnectGracefully);
                }
                totalRecieved += recieveArgs.BytesTransferred;
            } while (totalRecieved != size);//Check if all bytes has been received
            return(buffer);
        }
Ejemplo n.º 9
0
 private void openFileDialog1_FileOk(object sender, CancelEventArgs e)
 {
     imageLoaded  = true;
     loadedImage  = (Bitmap)Image.FromFile(openFileDialog1.FileName);
     resizedImage = (Bitmap)Image.FromFile(openFileDialog1.FileName);
     StatusTextBox.AppendText(Environment.NewLine + $"Loaded \"{openFileDialog1.SafeFileName}\"");
 }
Ejemplo n.º 10
0
Archivo: Main.cs Proyecto: sotaria/gsf
        // Sets the registry key to enable or disable the automatic root certificate list updates.
        private void RootCertificateListCheckBox_CheckedChanged(object sender, EventArgs e)
        {
            if (!m_checkedEventsEnabled)
            {
                return;
            }

            StatusTextBox.AppendText(string.Format("{0} automatic root certificate list update through Windows Update... ", RootCertificateListCheckBox.Checked ? "Disabling" : "Enabling"));

            using (RegistryKey authRootKey = Registry.LocalMachine.CreateSubKey(@"Software\Policies\Microsoft\SystemCertificates\AuthRoot"))
            {
                if ((object)authRootKey != null)
                {
                    if (RootCertificateListCheckBox.Checked)
                    {
                        authRootKey.SetValue("DisableRootAutoUpdate", 1);
                    }
                    else
                    {
                        authRootKey.DeleteValue("DisableRootAutoUpdate");
                    }

                    AppendStatusMessage("Done.");
                }
                else
                {
                    AppendStatusMessage("Failed. Unable to update the registry key.");
                    m_checkedEventsEnabled = false;
                    RootCertificateListCheckBox.Checked = !RootCertificateListCheckBox.Checked;
                    m_checkedEventsEnabled = true;
                }
            }
        }
Ejemplo n.º 11
0
        private void saveFileDialog1_FileOk(object sender, CancelEventArgs e)
        {
            string fileName = saveFileDialog1.FileName;

            File.WriteAllText(fileName, sb.ToString());
            StatusTextBox.AppendText(Environment.NewLine + $"Saved \"{openFileDialog1.SafeFileName}\" as \"{fileName}\"");
        }
Ejemplo n.º 12
0
        /// <summary>
        /// Occurs when the user clicks the Dial button.
        /// </summary>
        /// <param name="sender">The object that raised the event.</param>
        /// <param name="e">An <see cref="System.EventArgs"/> containing event data.</param>
        private void DialButton_Click(object sender, EventArgs e)
        {
            StatusTextBox.Clear();

            // This button will be used to dial the connection.
            Dialer.EntryName     = EntryName;
            Dialer.PhoneBookPath = PHONE_BOOK_PATH;

            try
            {
                // Set the credentials the dialer should use.
                Dialer.Credentials = new NetworkCredential("Test", "User");

                // NOTE: The entry MUST be in the phone book before the connection can be dialed.
                // Begin dialing the connection; this will raise events from the dialer instance.
                handle = Dialer.DialAsync();

                // Enable the disconnect button for use later.
                DisconnectButton.Enabled = true;
            }
            catch (Exception ex)
            {
                StatusTextBox.AppendText(ex.ToString());
            }
        }
Ejemplo n.º 13
0
 private void AppendStatusText(string text)
 {
     if (StatusTextBox.Text.Length != 0)
     {
         this.Invoke(() => StatusTextBox.AppendText(Environment.NewLine));
     }
     this.Invoke(() => StatusTextBox.AppendText(DateTime.Now.ToString("HH:mm:ss.fff") + " " + text));
 }
Ejemplo n.º 14
0
 public void AppendText(string str, bool newline)
 {
     if (newline)
     {
         str += Environment.NewLine;
     }
     StatusTextBox.AppendText(str);
 }
Ejemplo n.º 15
0
 private void AppendStatusText(string text)
 {
     if (StatusTextBox.Text.Length != 0)
     {
         this.Invoke(() => StatusTextBox.AppendText(Environment.NewLine));
     }
     this.Invoke(() => StatusTextBox.AppendText(text));
 }
Ejemplo n.º 16
0
        private void SocketReceiveEventCompleted(object sender, SocketAsyncEventArgs e)
        {
            if (e.SocketError != SocketError.Success)
            {
                var ex = new SocketException((int)e.SocketError);
                StatusTextBox.AppendText($"RecieveComplete socket error:{ex.Message}, ErrorCode:{ex.SocketErrorCode}");

                return;
            }

            try
            {
                //_timer8.Change(Timeout.Infinite, Timeout.Infinite);
                var receivedCount = e.BytesTransferred;
                if (receivedCount == 0)
                {
                    StatusTextBox.AppendText("Received 0 byte.\n");
                    //CommunicationStateChanging(ConnectionState.Retry);
                    return;
                }
                dealwithMessage(e.Buffer, receivedCount);
                //var _msgHeader = MessageHeader.Decode(e.Buffer, 0);
                //                if (_secsDecoder.Decode(receivedCount))
                //                {
                //#if !DISABLE_T8
                //                    //_logger.Debug($"Start T8 Timer: {T8 / 1000} sec.");
                //                    //_timer8.Change(T8, Timeout.Infinite);
                //#endif
                //                }

                //                if (_secsDecoder.Buffer.Length != DecoderBufferSize)
                //                {
                //                    // buffer size changed
                //                    e.SetBuffer(_secsDecoder.Buffer, _secsDecoder.BufferOffset, _secsDecoder.BufferCount);
                //                    DecoderBufferSize = _secsDecoder.Buffer.Length;
                //                }
                //                else
                //                {
                //                    e.SetBuffer(_secsDecoder.BufferOffset, _secsDecoder.BufferCount);
                //                }

                if (sockClient is null || IsDisposed)
                {
                    return;
                }

                if (!sockClient.ReceiveAsync(e))
                {
                    SocketReceiveEventCompleted(sender, e);
                }
            }
            catch (Exception ex)
            {
                StatusTextBox.AppendText($"Unexpected exception: {ex.Message}");
                //CommunicationStateChanging(ConnectionState.Retry);
            }
        }
Ejemplo n.º 17
0
        private async void ReadHTML_Click(object sender, RoutedEventArgs e)
        {
            HtmlTextBox.Text = await Task.Run(() => _scrapper.ReadHtml(_htmlLocalization));

            await Task.Delay(100);

            ConvertButton.IsEnabled = true;
            StatusTextBox.Text     += $"{DateTime.Now:T} Html file read\n";
            StatusTextBox.ScrollToEnd();
        }
Ejemplo n.º 18
0
 private void Data2ReceivedHandler(object sender, SecsDataReceivedEventArgs arg)
 {
     Stream2TextBox.Text   = arg.SecsMessage.S.ToString();
     Function2TextBox.Text = arg.SecsMessage.F.ToString();
     StatusTextBox.AppendText("get msg header for device 0.\n");
     Message2TextBox.Text = arg.SecsMessage.ToString();
     Message2TextBox.AppendText("\n");
     Message2TextBox.AppendText(arg.SecsMessage.SecsItem.ToString());
     StatusTextBox.AppendText("get msg data for device 0.\n");
 }
Ejemplo n.º 19
0
  internal void ShowStatus(string Status)
    {
    if (IsClosing)
      return;

    // if( StatusTextBox.Text.Length > (80 * 5000))
      // StatusTextBox.Text = "";

    StatusTextBox.AppendText( Status + "\r\n" );
    }
Ejemplo n.º 20
0
 private void StartButton_Click(object sender, EventArgs e)
 {
     ServerGroupBox.Enabled          = false;
     SpreadsheetTextBox.Enabled      = false;
     OptionsFileBrowseButton.Enabled = false;
     StartButton.Enabled             = false;
     UpdateDatabaseCheckBox.Enabled  = false;
     StatusTextBox.Clear();
     BackgroundWorker.RunWorkerAsync();
 }
Ejemplo n.º 21
0
        private void StartButton_Click(object sender, EventArgs e)
        {
            StartButton.Enabled         = false;
            BrowseCsvPathButton.Enabled = false;
            CsvPathTextBox.Enabled      = false;
            ServerGroupBox.Enabled      = false;

            StatusTextBox.Clear();
            BackgroundWorker.RunWorkerAsync();
        }
Ejemplo n.º 22
0
        private void StartFillInLegislativeDistricts()
        {
            StartButton.Enabled       = false;
            OperationGroupBox.Enabled = false;
            ServerGroupBox.Enabled    = false;
            FillInLegislativeDistrictsPanel.Enabled = false;

            StatusTextBox.Clear();
            FillInLegislativeDistrictsBackgroundWorker.RunWorkerAsync();
        }
Ejemplo n.º 23
0
Archivo: Main.cs Proyecto: sotaria/gsf
        // Registers the service OID for the given product.
        private void RegisterServiceOID(Product product)
        {
            List <Product>   productsUsingThisOID;
            X509Certificate2 certificate;
            string           certificatePath;
            string           keyAlgorithm;

            // If the service is already registered, don't need to do anything
            if ((object)product.ServiceOID == null)
            {
                // Get the path to the certificate used to obtain the OID for this fix
                certificatePath = Path.Combine(product.InstallPath, product.Name + ".cer");

                if (File.Exists(certificatePath))
                {
                    StatusTextBox.AppendText(string.Format("Registering service OID for {0}... ", product.Name));

                    // Get the key algorithm of the certificate,
                    // which is the OID used by the service
                    certificate  = new X509Certificate2(certificatePath);
                    keyAlgorithm = certificate.GetKeyAlgorithm();

                    // Determine which other products are sharing this service OID
                    productsUsingThisOID = m_products
                                           .Where(p => p.ServiceOID == keyAlgorithm)
                                           .ToList();

                    // Set service OID to the key algorithm of the certificate
                    product.ServiceOID = keyAlgorithm;

                    // Store the OID of that certificate in case we need to unregister it later
                    using (RegistryKey productKey = Registry.LocalMachine.CreateSubKey(string.Format(@"Software\Grid Protection Alliance\{0}", product.Name)))
                    {
                        if ((object)productKey != null)
                        {
                            productKey.SetValue("ServiceOID", keyAlgorithm);
                        }
                    }

                    if (productsUsingThisOID.Count == 0)
                    {
                        RegisterOID(keyAlgorithm);
                        AppendStatusMessage("Done.");
                    }
                    else if (productsUsingThisOID.Count == 1)
                    {
                        AppendStatusMessage(string.Format("Service OID already registered for {0}.", productsUsingThisOID[0].Name));
                    }
                    else
                    {
                        AppendStatusMessage(string.Format("Service OID already registered for {0} other products.", productsUsingThisOID.Count));
                    }
                }
            }
        }
Ejemplo n.º 24
0
        private void StartButton_Click(object sender, EventArgs e)
        {
            StartButton.Enabled            = false;
            StartAtLabel.Enabled           = false;
            StartAtTextBox.Enabled         = false;
            SuppressUpdate                 = SuppressUpdateCheckBox.Checked;
            SuppressUpdateCheckBox.Enabled = false;

            StatusTextBox.Clear();
            BackgroundWorker.RunWorkerAsync();
        }
Ejemplo n.º 25
0
        private void StartButton_Click(object sender, EventArgs e)
        {
            StartButton.Enabled = false;
            BrowseZipPlus4PathButton.Enabled = false;
            ZipPlus4PathTextBox.Enabled      = false;
            BrowseOutputFileButton.Enabled   = false;
            OutputFileTextBox.Enabled        = false;

            StatusTextBox.Clear();
            BackgroundWorker.RunWorkerAsync();
        }
Ejemplo n.º 26
0
        private void StartButton_Click(object sender, EventArgs e)
        {
            StartButton.Enabled    = false;
            ServerGroupBox.Enabled = false;
            StatusTextBox.Clear();

            var tableInfoList = GetTableInfo();

            SelectTables(tableInfoList);
            BackgroundWorker.RunWorkerAsync(tableInfoList);
        }
Ejemplo n.º 27
0
 private void ReportError(string message)
 {
     StatusTextBox.AppendText("Row: " + Count.ToString());
     StatusTextBox.AppendText(Environment.NewLine);
     StatusTextBox.AppendText("From: " + UriFrom.ToString());
     StatusTextBox.AppendText(Environment.NewLine);
     StatusTextBox.AppendText("To: " + UriTo.ToString());
     StatusTextBox.AppendText(Environment.NewLine);
     StatusTextBox.AppendText("New: " + message);
     StatusTextBox.AppendText(Environment.NewLine);
     StatusTextBox.AppendText(Environment.NewLine);
 }
Ejemplo n.º 28
0
        private void Report()
        {
            this.Invoke(() => StatusTextBox.Clear());
            AppendStatusText("Patterns");

            foreach (string pattern in Patterns.Keys.OrderBy(pattern => pattern))
            {
                AppendStatusText(pattern);
            }

            AppendStatusText("{0} rows processed", RowsProcessed);
        }
Ejemplo n.º 29
0
 private void AppendStatusText(string text)
 {
     if (StatusTextBox.Text.Length != 0)
     {
         this.Invoke(() => StatusTextBox.AppendText(Environment.NewLine));
     }
     if (!string.IsNullOrWhiteSpace(text))
     {
         text = DateTime.Now.ToString("HH:mm:ss.fff") + " " + text;
     }
     this.Invoke(() => StatusTextBox.AppendText(text));
 }
Ejemplo n.º 30
0
        private void SetStatus(string Message)
        {
            //Check for cross threading
            if (StatusTextBox.Dispatcher.CheckAccess() == false)
            {
                Dispatcher.BeginInvoke(DispatcherPriority.Normal, (Action <string>)SetStatus, Message);
                return;
            }

            StatusTextBox.AppendText(Environment.NewLine + Message);
            StatusTextBox.ScrollToEnd();
        }