Ejemplo n.º 1
0
 /// <summary>
 /// Converts from a WPF FlowDocument to a XAML markup string.
 /// </summary>
 public object Convert(object value, System.Type targetType, object parameter, System.Globalization.CultureInfo culture)
 {
     if (value == null) return string.Empty;
     FlowDocument flowDocument = (FlowDocument)XamlReader.Parse((string)value);
     string text = new TextRange(flowDocument.ContentStart, flowDocument.ContentEnd).Text;
     text = text.Replace("\r\n", " ");
     return text;
 }
Ejemplo n.º 2
0
        private void Select_Click(object sender, RoutedEventArgs e)
        {
            //in one spot it says minimum of 3 images on slide, but final point in keeping from passing says UP TO 3 images ¯\_(ツ)_/¯
            if (Selection.Where(x => x.Value).Count() != 3)
            {
                return;
            }

            var presentation = new PresentationDocument();
            var slide        = presentation.Slides.AddNew(SlideLayoutType.Custom);
            var textBox      = slide.Content.AddTextBox(ShapeGeometryType.Rectangle, 10, 2, 5, 4, LengthUnit.Centimeter);

            var title = textBox.AddParagraph();

            title.AddRun(Title.Text);


            var bodyTextBox = slide.Content.AddTextBox(ShapeGeometryType.Rectangle, 20, 2, 5, 4, LengthUnit.Centimeter);

            var body = bodyTextBox.AddParagraph();

            var bodyText = new System.Windows.Documents.TextRange(SearchText.Document.ContentStart, SearchText.Document.ContentEnd).Text.Replace("\r", " ");

            bodyText = bodyText.Replace("\n", " ");

            body.AddRun(bodyText);

            double width = 0.0;

            foreach (var image in Selection)
            {
                if (image.Value)
                {
                    slide.Content.AddPicture(image.Key.Source.ToString(), width, 250, image.Key.Width, image.Key.Height);
                    width += image.Key.Width;
                }
            }

            presentation.Save($"Results_{Guid.NewGuid()}.pptx");
            Image_Panel.Children.Clear();
            Images.Clear();
            Selection.Clear();
        }
Ejemplo n.º 3
0
 private string GetTextFromRichTextBox(RichTextBox rtb)
 {
     string txtExpr = new TextRange(rtb.Document.ContentStart, rtb.Document.ContentEnd).Text;
     txtExpr = txtExpr.Replace("\r", "");
     txtExpr = txtExpr.Replace("\n", "");
     return txtExpr;
 }
        private void richTextBox1_PreviewKeyDown(object sender, KeyEventArgs e)
        {
            if (e.Key == Key.Space)
            {
                var command = new TextRange(richTextBox1.CaretPosition.GetLineStartPosition(0),
                   richTextBox1.CaretPosition).Text;
                command = command.Substring(command.IndexOf(">") + 1).Trim();
                ShowOptions(command);
                return;
            }
            else if (e.Key == Key.Tab || e.Key == Key.Down)
            {
                if (lstOptions.Visibility == Visibility.Visible)
                {
                    lstOptions.Focus();
                    return;
                }
            }
            else
            {
                lstOptions.Visibility = Visibility.Collapsed;
            }

            if (e.Key == Key.Enter)
            {
                var command = new TextRange(richTextBox1.CaretPosition.GetLineStartPosition(0),
                    richTextBox1.CaretPosition.GetLineStartPosition(1) ?? richTextBox1.CaretPosition.DocumentEnd).Text;
                command = command.Replace("\r", "").Replace("\n", "");
                RunCommand(command);
                e.Handled = true;
            }
            else if (e.Key == Key.Up)
            {
                GetCommand(--commandIdx);
                e.Handled = true;
            }
            else if (e.Key == Key.Down)
            {
                GetCommand(++commandIdx);
                e.Handled = true;
            }
            else if (e.Key == Key.Escape)
            {
                ChangePrompt("",  new SolidColorBrush(Colors.Black));
            }
            else if (e.Key == Key.Back)
            {
                var text = new TextRange(richTextBox1.CaretPosition.GetLineStartPosition(0),
                    richTextBox1.CaretPosition).Text;
                if (text.EndsWith(">")) e.Handled = true;
            }
            else
            {
                var text = new TextRange(richTextBox1.CaretPosition, richTextBox1.CaretPosition.DocumentEnd).Text;
                if (text.Contains(">")) //e.Handled = true;
                    this.richTextBox1.CaretPosition = this.richTextBox1.CaretPosition.DocumentEnd;
            }
        }
        private void btnExportcsv_Click(object sender, RoutedEventArgs e)
        {
            FieldsNotEmpty();

            string auditname = txtAuditorName.Text;
            string commentsString = new TextRange(rtxtComments.Document.ContentStart, rtxtComments.Document.ContentEnd).Text;

            // SAVING
            SaveFileDialog SaveCSV = new SaveFileDialog()
            {
                Filter = "csv file(*.csv)|*.csv|All files (*.*)|*.*"
            };

            Nullable<bool> result = SaveCSV.ShowDialog();
            if (result == true)
            {
                string filepath = SaveCSV.FileName;     //gets file path

                using (StreamWriter sw = File.CreateText(filepath))
                {
                    sw.WriteLine("$$$###**!!Hardware!!**###$$$," + "," + txtAuditDate.Text.Replace(',', '-') + "," + txtAuditorName.Text.Replace(',', '-') + "," + txtManufacturer.Text.Replace(',', '-') + "," + txtModel.Text.Replace(',', '-') + "," + txtComputerName.Text.Replace(',', '-') + "," + txtOS.Text.Replace(',', '-') + "," + txtOSArch.Text.Replace(',', '-') + "," + txtServicePack.Text.Replace(',', '-') + "," + txtSerialNumber.Text.Replace(',', '-') + "," + txtRam.Text.Replace(',', '-') + "," + txtProcessor.Text.Replace(',', '-') + "," + txtNoProcessors.Text.Replace(',', '-') + "," + txtHardDriveSize.Text.Replace(',', '-') + "," + txtFreeHardDrive.Text.Replace(',', '-') + "," + commentsString.Replace(',', '-'));

                    foreach (string ipAddressName in cbIPAddress.Items)
                    {
                        sw.WriteLine("$$$###*!!IPAddress!!**###$$$," + ipAddressName);
                    }

                    //Getting each Mac address and putting it into one line
                    foreach (string macAddressName in cbMacAddress.Items)
                    {
                        sw.WriteLine("$$$###**!!MACAddress!!**###$$$," + macAddressName);
                    }

                    //ADDING PERIPHERAL
                    foreach (string PeripheralItem in lbPeripherals.Items)
                    {
                        sw.WriteLine("$$$###**!!Peripherals!!**###$$$," + PeripheralItem);
                    }



                    //ADDING PRINTER
                    foreach (string PrinterItem in lbPrinters.Items)
                    {
                        sw.WriteLine("$$$###**!!Printers!!**###$$$," + PrinterItem);
                    }

                    sw.Flush();
                    sw.Close();
                    //ADDING SOFTWARE
                    if (dgSoftware.HasItems)
                    {
                        am.GetSoftwareInfoAndSaveCSV(filepath);
                    }
                }
            }
        }