Ejemplo n.º 1
0
        private void OnValidateComplete(object sender, ValidationCompleteEventArgs e)
        {
            switch (e.Status)
            {
            case ValidationStatus.FAILED:
            {
                Console.ForegroundColor = ConsoleColor.Red;
                Console.WriteLine(e.Message + " One or more errors detected." + Environment.NewLine);
                Console.ForegroundColor = ConsoleColor.White;
            }
            break;

            case ValidationStatus.CANCELLED:
            {
                Console.ForegroundColor = ConsoleColor.Yellow;
                Console.WriteLine(e.Message + Environment.NewLine);
                Console.ForegroundColor = ConsoleColor.White;
                break;
            }

            case ValidationStatus.PASSED:
            {
                Console.ForegroundColor = ConsoleColor.Green;
                Console.WriteLine(e.Message + Environment.NewLine);
                Console.ForegroundColor = ConsoleColor.White;
                break;
            }
            }
        }
Ejemplo n.º 2
0
        private void Word_ValidationComplete(object sender, ValidationCompleteEventArgs e)
        {
            InvokeMain(() =>
            {
                progWorker.Visible = false;

                if (e.MatchedCount == 0)
                {
                    if (MessageBox.Show(Texts.NoDocumentMatchedMsg, Texts.SaveDocument, MessageBoxButtons.YesNo) == DialogResult.Yes)
                    {
                        WordDocument.SaveInDatabase(CurrentFilePath);
                    }
                }
                else
                {
                    if (e.ExistsDocumentId.HasValue)
                    {
                        MessageBox.Show(string.Format(Texts.DocumentExistsMsg, e.ExistsDocumentId), Texts.DuplicateDocument);
                    }
                }


                btnValidate.Enabled = true;
                btnSaveInDb.Enabled = true;
            });
        }
Ejemplo n.º 3
0
        private void OnValidateComplete(object sender, ValidationCompleteEventArgs e)
        {
            if (InvokeRequired) // Make sure to check that if being called from a different thread
            {
                this.Invoke(new Action(() =>
                {
                    if (tbStatus.Text.Length + e.Message.Length > tbStatus.MaxLength) // Make sure we dont store too much text to avoid out of memory error
                    {
                        tbStatus.Clear();
                    }
                }));
            }
            else
            {
                if (tbStatus.Text.Length + e.Message.Length > tbStatus.MaxLength) // Make sure we dont store too much text to avoid out of memory error
                {
                    tbStatus.Clear();
                }
            }

            switch (e.Status)
            {
            case ValidationStatus.FAILED:
            {
                if (InvokeRequired)         // Make sure to check that if being called from a different thread
                {
                    this.Invoke(new Action(() =>
                        {
                            tbStatus.SelectionColor = Color.Red;
                            tbStatus.AppendText(e.Message + " Error detected." + Environment.NewLine);
                            tbStatus.SelectionColor = Color.Black;
                        }));
                }
                else
                {
                    tbStatus.SelectionColor = Color.Red;
                    tbStatus.AppendText(e.Message + Environment.NewLine);
                    tbStatus.SelectionColor = Color.Black;
                }

                break;
            }

            case ValidationStatus.CANCELLED:
            {
                if (InvokeRequired)         // Make sure to check that if being called from a different thread
                {
                    this.Invoke(new Action(() =>
                        {
                            tbStatus.SelectionColor = Color.Yellow;
                            tbStatus.AppendText(e.Message + " Validation cancelled." + Environment.NewLine);
                            tbStatus.SelectionColor = Color.Black;
                        }));
                }
                else
                {
                    tbStatus.SelectionColor = Color.Yellow;
                    tbStatus.AppendText(e.Message + " Validation cancelled." + Environment.NewLine);
                    tbStatus.SelectionColor = Color.Black;
                }
                break;
            }

            case ValidationStatus.PASSED:
            {
                if (InvokeRequired)         // Make sure to check that if being called from a different thread
                {
                    this.Invoke(new Action(() =>
                        {
                            tbStatus.SelectionColor = Color.Green;
                            tbStatus.AppendText(e.Message + " Completed without error." + Environment.NewLine);
                            tbStatus.SelectionColor = Color.Black;
                        }));
                }
                else
                {
                    tbStatus.SelectionColor = Color.Green;
                    tbStatus.AppendText(e.Message + " Completed without error." + Environment.NewLine);
                    tbStatus.SelectionColor = Color.Black;
                }
                break;
            }
            }
        }