Example #1
0
        public Question(string myFilename, RichTextBox richMain)
        {
            Filename = Path.GetFileName(myFilename);
            string xmlText = File.ReadAllText(myFilename);
            XmlDocument xmlDoc = new XmlDocument();
            xmlDoc.LoadXml(xmlText);

            try
            {
                XmlNode xmlQD = xmlDoc.GetElementsByTagName("QuestionDesc")[0];
                XmlNode xmlQ = xmlDoc.GetElementsByTagName("QuestionText")[0];
                XmlCDataSection xmlCData = xmlQ.FirstChild as XmlCDataSection;
                XmlNode xmlAA = xmlDoc.GetElementsByTagName("AnswerA")[0];
                XmlNode xmlAB = xmlDoc.GetElementsByTagName("AnswerB")[0];
                XmlNode xmlAC = xmlDoc.GetElementsByTagName("AnswerC")[0];
                XmlNode xmlAD = xmlDoc.GetElementsByTagName("AnswerD")[0];
                XmlNode xmlT = xmlDoc.GetElementsByTagName("Time")[0];
                XmlNode xmlL = xmlDoc.GetElementsByTagName("Level")[0];
                XmlNode xmlA = xmlDoc.GetElementsByTagName("Correct")[0];

                QuestionDescripion = xmlQD.InnerText.ToString();
                QuestionText = xmlCData.InnerText;
                AnswerA = xmlAA.InnerText;
                AnswerB = xmlAB.InnerText;
                AnswerC = xmlAC.InnerText;
                AnswerD = xmlAD.InnerText;
                Correct = xmlA.InnerText;
                Time = Convert.ToInt32(xmlT.InnerText);
                Level = Convert.ToInt32(xmlL.InnerText);
            }
            catch (Exception expError)
            {
                richMain.AppendText("Problem with question file format: " + expError.Message + Environment.NewLine);
            }
        }
Example #2
0
        internal void RetornoDados <T>(T objeto, RichTextBox richTextBox) where T : class
        {
            richTextBox.Document.Blocks.Clear();

            foreach (var atributos in Funcoes.LerPropriedades(objeto))
            {
                richTextBox.AppendText(atributos.Key + " = " + atributos.Value + "\r");
            }
        }
Example #3
0
        public override void Write(string message)
        {
            Action append = delegate()
            {
                output.AppendText(string.Format("[{0}] ", DateTime.Now.ToString("T")));
                output.AppendText(message);
                output.ScrollToEnd();
            };

            if (output.Dispatcher.CheckAccess())
            {
                output.Dispatcher.Invoke(
                    System.Windows.Threading.DispatcherPriority.Normal, append);
            }
            else
            {
                append();
            }
        }
        private void viewFilesToWindowFromVersionInfo(int startingIndexNext, int endIndexNext)
        {
            try
            {
                //if startindex is smaller than track count then clear all track level first
                if (startingIndexNext <= allVersionInfo.Count)
                {
                    List <Label> FileListVisualUI = fileInfoLabels.Children.OfType <Label>().ToList();
                    foreach (System.Windows.Controls.Label lbl in FileListVisualUI)
                    {
                        lbl.Content = "";
                    }

                    List <RichTextBox> FileListVisualUIRich = fileInfoLabels.Children.OfType <RichTextBox>().ToList();
                    foreach (System.Windows.Controls.RichTextBox lbl in FileListVisualUIRich)
                    {
                        lbl.Document.Blocks.Clear();
                    }

                    int count = 1;
                    for (int i = startingIndexNext; i <= endIndexNext; i++)
                    {
                        if (i < allVersionInfo.Count)
                        {
                            //Finding by fileName
                            System.Windows.Controls.Label lbl = this.FindName("lblfileName_" + count) as System.Windows.Controls.Label;
                            lbl.Content    = allVersionInfo[i].fileName;
                            lbl.Visibility = Visibility.Visible;

                            //lblfileDate
                            System.Windows.Controls.Label lblDate = this.FindName("lblfileDate_" + count) as System.Windows.Controls.Label;
                            lblDate.Content    = allVersionInfo[i].modifiedDate;
                            lblDate.Visibility = Visibility.Visible;

                            //lblModifiedBy_1
                            System.Windows.Controls.Label lblModifiedBy = this.FindName("lblModifiedBy_" + count) as System.Windows.Controls.Label;
                            lblModifiedBy.Content    = allVersionInfo[i].modifiedBy;
                            lblModifiedBy.Visibility = Visibility.Visible;

                            //lblCommitMessage
                            System.Windows.Controls.RichTextBox lblCommitMessage = this.FindName("lblCommitMessage_" + count) as System.Windows.Controls.RichTextBox;
                            lblCommitMessage.AppendText(allVersionInfo[i].commitMessage);
                            lblCommitMessage.Visibility = Visibility.Visible;


                            count++;
                        }
                    }
                }
            }catch (Exception err)
            {
                MessageBox.Show(err.ToString());
            }
        }
Example #5
0
 //for system messages
 private void ChangeTextProperly(RichTextBox rtb, string msg)
 {
     if (rtb.Dispatcher.CheckAccess())
     {
         rtb.AppendText(msg + "\n");
         return;
     }
     else
     {
         rtb.Dispatcher.BeginInvoke(DispatcherPriority.Normal, new TextChanger(delegate() { this.ChangeTextProperly(rtb, msg); }));
     }
 }
Example #6
0
 public void logWithTime(string s, RichTextBox rtb)
 {
     DateTime DTN = DateTime.Now;
     string LogDateTime = DateTime.SpecifyKind(DTN, DateTimeKind.Local).ToString();
     try
     {
         rtb.AppendText(LogDateTime + ": " + s + "\r\n");
         rtb.ScrollToEnd();
     }
     catch (Exception ex)
     {
         MessageBox.Show(ex.ToString());
     }
 }
        Window CreateNodeDialog(out RichTextBox richBox)
        {
            var window = new Window {
                Width = 200, Height = 200
            };
            var mp = Mouse.GetPosition(_dockPanel);

            window.Left = mp.X;
            window.Top  = mp.Y;
            var panel = new DockPanel();

            window.Content = panel;

            var textBox = new TextBox {
                Text = "Please modify the node label:"
            };

            DockPanel.SetDock(textBox, Dock.Top);
            panel.Children.Add(textBox);

            richBox           = new RichTextBox();
            richBox.FontSize *= 1.5;
            richBox.AppendText("Label");
            richBox.FontFamily = new FontFamily("Consoles");
            richBox.Width      = window.Width;
            DockPanel.SetDock(richBox, Dock.Top);
            panel.Children.Add(richBox);
            panel.Measure(new Size(double.PositiveInfinity, double.PositiveInfinity));
            panel.Width = textBox.Width;
            var button = new Button {
                Content = "OK"
            };

            button.Click += (a, b) => window.Close();
            DockPanel.SetDock(button, Dock.Bottom);
            button.IsDefault = true;
            button.Width     = 40;
            button.Height    = 40;
            panel.Children.Add(button);
            panel.Measure(new Size(double.PositiveInfinity, double.PositiveInfinity));
            window.SizeToContent = SizeToContent.WidthAndHeight;
            return(window);
        }
        private void showDeck(string deck)
        {
            TextPointer tp;
            TextRange   tr;

            newDeck      = stringToDeck(deck);
            rtb.Document = new FlowDocument();
            string text;

            for (int i = 0; i < numberOfCards; i++)
            {
                text    = convertCardNumberToSymbol(newDeck[i]);
                tp      = rtb.Document.ContentEnd;
                tr      = new TextRange(tp, tp);
                tr.Text = text.Substring(0, 1);
                if (text.Contains(DIAMOND) || text.Contains(HEART))
                {
                    tr.ApplyPropertyValue(TextElement.ForegroundProperty, Brushes.Red);
                }
                if (oldDeck[i] != newDeck[i])
                {
                    tr.ApplyPropertyValue(TextElement.FontWeightProperty, FontWeights.Bold);
                }
                tp      = rtb.Document.ContentEnd;
                tr      = new TextRange(tp, tp);
                tr.Text = text.Substring(1);
                tr.ApplyPropertyValue(TextElement.ForegroundProperty, Brushes.Black);
                if (oldDeck[i] != newDeck[i])
                {
                    tr.ApplyPropertyValue(TextElement.FontWeightProperty, FontWeights.Bold);
                }
                if (i != numberOfCards - 1)
                {
                    rtb.AppendText(",");
                }
            }
        }
 // displays the results
 private void show_results_Click(object sender, RoutedEventArgs e)
 {
     if (testSuitname.Text == "")
     {
         MessageBox.Show("Please provide Test Suite Name");
         return;
     }
     logfilespath.Document.Blocks.Clear() ;
     String filename = "";
     filename = cc.GetLogFile(testSuitname.Text, username.Text, "detailedResults.log");
     //MessageBox.Show(filename);
     RichTextBox rctxtBx = new RichTextBox();
     rctxtBx.Height = 250;
     rctxtBx.Width = 400;
     rctxtBx.VerticalScrollBarVisibility = ScrollBarVisibility.Auto;
     Paragraph p = rctxtBx.Document.Blocks.FirstBlock as Paragraph;
     p.Margin = new Thickness(0);
     p.LineHeight = 10;
     fetchResultGrid.Children.Add(rctxtBx);
        filename = cc.GetLogFile(testSuitname.Text,username.Text, "results.xml");
        //MessageBox.Show(filename);
        if (filename == null || !filename.Contains("xml"))
        {
            MessageBox.Show("File Not Found. Pleasey try after some time or run the tests suite again.");
            return;
        }
       // MessageBox.Show(filename);
        TextReader tr = new StreamReader("Test Results\\" +testSuitname.Text + "_" + "results.xml");
        StringBuilder sb = new StringBuilder();
        sb.Append(tr.ReadToEnd());
        string tempStr = sb.ToString();
        sb.Replace("><",">\n<");
        rctxtBx.AppendText(sb.ToString());
        tr.Close();
        DirectoryInfo d = Directory.CreateDirectory("Test Results");
        String logFilesPath = System.IO.Path.GetFullPath("Test Results\\" +testSuitname.Text + "_" + "results.xml");
        logfilespath.AppendText(logFilesPath);
        logfilespath.AppendText("\n");
        logFilesPath = System.IO.Path.GetFullPath("Test Results\\" + testSuitname.Text + "_" + "detailedResults.log");
        logfilespath.AppendText(logFilesPath);
 }
Example #10
0
        Window CreateNodeDialog(out RichTextBox richBox) {
            var window = new Window {Width = 200, Height = 200};
            var mp = Mouse.GetPosition(_dockPanel);
            window.Left = mp.X;
            window.Top = mp.Y;
            var panel = new DockPanel();

            window.Content = panel;

            var textBox = new TextBox {Text = "Please modify the node label:"};

            DockPanel.SetDock(textBox, Dock.Top);
            panel.Children.Add(textBox);

            richBox = new RichTextBox();
            richBox.FontSize *= 1.5;
            richBox.AppendText("Label");
            richBox.FontFamily = new FontFamily("Consoles");
            richBox.Width = window.Width;
            DockPanel.SetDock(richBox, Dock.Top);
            panel.Children.Add(richBox);
            panel.Measure(new Size(double.PositiveInfinity, double.PositiveInfinity));
            panel.Width = textBox.Width;
            var button = new Button {Content = "OK"};
            button.Click += (a, b) => window.Close();
            DockPanel.SetDock(button, Dock.Bottom);
            button.IsDefault = true;
            button.Width = 40;
            button.Height = 40;
            panel.Children.Add(button);
            panel.Measure(new Size(double.PositiveInfinity, double.PositiveInfinity));
            window.SizeToContent = SizeToContent.WidthAndHeight;
            return window;
        }
Example #11
0
 internal void EnvioStr(RichTextBox richTextBox, string envioStr)
 {
     richTextBox.Document.Blocks.Clear();
     richTextBox.AppendText(envioStr);
 }
Example #12
0
 internal void RetornoStr(RichTextBox richTextBox, string retornoXmlString)
 {
     richTextBox.Document.Blocks.Clear();
     richTextBox.AppendText(retornoXmlString);
 }
 private void asyncOutputBoxAppendNoBreak(RichTextBox targetBox, string text)
 {
     targetBox.Dispatcher.Invoke(new Action(() => targetBox.AppendText(text)));
 }
Example #14
0
 public void logWithoutTime(string s, RichTextBox rtb)
 {
     rtb.AppendText(s + "\r\n");
     rtb.ScrollToEnd();
 }
 //private void cm_showGram(cParserException _ex)
 //{
 //    f_rtbGram.Document.Blocks.Clear();
 //    foreach (cToken _token in _ex.cf_Tokens)
 //    {
 //        switch (_token.cf_Type)
 //        {
 //            case eTokenType.перевод_строки:
 //                f_rtbGram.AppendText(Environment.NewLine);
 //                break;
 //            case eTokenType.стрелка:
 //                f_rtbGram.AppendText(" -> ");
 //                break;
 //            case eTokenType.Null:
 //                f_rtbGram.AppendText(" -> ");
 //                break;
 //            default:
 //                cm_addLexemToRichText(_token.cf_Value as cLexem, f_rtbGram);
 //                break;
 //        }
 //    }
 //}
 private void cm_addLexemToRichText(cLexem a_lexem, RichTextBox a_rtb)
 {
     if (a_lexem.cp_Type == eLexType.NonTerminal)
         a_rtb.AppendText("<");
     else if (a_lexem.cp_Type == eLexType.Action)
         a_rtb.AppendText("{");
     //a_rtb.SelectionFont = new Font(a_rtb.SelectionFont, FontStyle.Bold);
     //a_rtb.AppendText(a_lexem.ToString());
     TextRange _tr = new TextRange(a_rtb.Document.ContentEnd,a_rtb.Document.ContentEnd);
     _tr.Text = a_lexem.ToString();
     _tr.ApplyPropertyValue(TextElement.FontWeightProperty, FontWeights.Bold);
     _tr = new TextRange(a_rtb.Document.ContentEnd, a_rtb.Document.ContentEnd);
     _tr.ApplyPropertyValue(TextElement.FontWeightProperty, FontWeights.Regular);
     //a_rtb.SelectionFont = new Font(a_rtb.SelectionFont, FontStyle.Regular);
     if (a_lexem.cp_Type == eLexType.NonTerminal)
         a_rtb.AppendText(">");
     else if (a_lexem.cp_Type == eLexType.Action)
         a_rtb.AppendText("}");
     a_rtb.AppendText(" ");
 }
        // Loads the XML questions from this directory
        public bool LoadQuestions(string strDirectory, RichTextBox richMain)
        {
            if (Directory.Exists(strDirectory) == false)
            {
                System.Windows.MessageBox.Show("Couldn't find the directory containing questions: " + strDirectory, "Error", System.Windows.MessageBoxButton.OK, System.Windows.MessageBoxImage.Error);
                return false;
            }

            int intCount = 0;
            foreach(string strFile in Directory.EnumerateFiles(strDirectory,"*.xml")){

                XDocument thisXML = XDocument.Load(strFile);
                Question thisQuestion = new Question(strFile,richMain);
                lstQuestions.Add(thisQuestion);
                intCount++;
            }

            richMain.AppendText("Loaded a total of " + lstQuestions.Count() + " files" + Environment.NewLine);
            Count = lstQuestions.Count();

            return true;
        }
        public VersionShowWindow()
        {
            InitializeComponent();

            try
            {
                NotepadPPGateway notepadPPGateway = new NotepadPPGateway();

                //Save the file to original location
                string path = notepadPPGateway.GetCurrentFilePath();

                CommitWindow.currentFileDirectory = path;

                //Save the file to another directory
                string currentFileName = System.IO.Path.GetFileName(path);

                allVersionInfo = versionInfo(currentFileName); //All available version info is stored here

                //Now need to add them to UI
                int count = 1;
                foreach (PmlVersion version in allVersionInfo)
                {
                    if (count < 11)
                    {
                        //Finding and assigning filename
                        System.Windows.Controls.Label lblFileName = this.FindName("lblfileName_" + count) as System.Windows.Controls.Label;
                        lblFileName.Content    = version.fileName;
                        lblFileName.Visibility = Visibility.Visible;

                        //Finding and assigning modifiedDate
                        System.Windows.Controls.Label lblModifiedDate = this.FindName("lblfileDate_" + count) as System.Windows.Controls.Label;
                        lblModifiedDate.Content    = version.modifiedDate;
                        lblModifiedDate.Visibility = Visibility.Visible;

                        //Finding and assigning modifiedBy
                        System.Windows.Controls.Label lblModifiedBy = this.FindName("lblModifiedBy_" + count) as System.Windows.Controls.Label;
                        lblModifiedBy.Content    = version.modifiedBy;
                        lblModifiedBy.Visibility = Visibility.Visible;

                        //Finding and assigning commitMessage
                        System.Windows.Controls.RichTextBox lblCommitMessage = this.FindName("lblCommitMessage_" + count) as System.Windows.Controls.RichTextBox;
                        lblCommitMessage.AppendText(version.commitMessage);
                        lblCommitMessage.Visibility = Visibility.Visible;
                    }
                    count++;
                }

                //Finding and assigning count
                System.Windows.Controls.Label lblCountNumber = this.FindName("countNumber") as System.Windows.Controls.Label;
                lblCountNumber.Content    = (count - 1).ToString("00");
                lblCountNumber.Visibility = Visibility.Visible;

                //Search all labels and set horizontal allignement center for version info labels only
                try
                {
                    UIElementCollection uiFileInfoLabels = fileInfoLabels.Children;
                    foreach (System.Windows.Controls.Label lbl in uiFileInfoLabels)
                    {
                        lbl.HorizontalContentAlignment = HorizontalAlignment.Center;
                    }
                }
                catch
                {
                }
            }catch (Exception err)
            {
                MessageBox.Show(err.ToString());
            }
        }
 //---------------------------------------------------------------------------------------------------------
 //do wyswietlania informacji dla bierzacego uzytkownika o jego stanie
 public void show_info(RichTextBox info, string tekst_info)
 {
     info.AppendText(tekst_info);
     log_info.ScrollToEnd();
 }
Example #19
0
        private void Button_Click(object sender, RoutedEventArgs e)
        {
            System.Windows.Controls.RichTextBox richText = new System.Windows.Controls.RichTextBox();
            richText.FontSize = 12;

            richText.AppendText("This program comes with no warranty.");
            richText.AppendText("\r\r");
            richText.AppendText("It doesn't offer much in the way of help.");
            richText.AppendText("\r\r");
            richText.AppendText("It will not stop you doing stupid things.");
            richText.AppendText("\r\r");
            richText.AppendText("It will happily rename whatever you tell it to, without warnings or errors.");
            richText.AppendText("\r\r");
            richText.AppendText("There is no undo option.");
            richText.AppendText("\r\r");
            richText.AppendText("Use entirely at your own risk.");
            richText.AppendText("\r\r");
            richText.AppendText("Doesn't yet handle file/folder rename clashes. Check the error logs!");
            richText.AppendText("\r\r");

            Window window = new Window
            {
                Title  = "USE AT YOUR OWN RISK",
                Width  = 420,
                Height = 255,
                WindowStartupLocation = WindowStartupLocation.CenterScreen,
                Content = richText
            };

            window.ShowDialog();
        }