private void LoadClipboardData(string format, ref FlowDocumentReader fdr)
        {
            object obj = GetClipboardData(format);

            if (obj == null)
            {
                TextBlock tb = (ActiveTab.Header as StackPanel).Children[0] as TextBlock;
                tb.Text = app.Language.Unknown;
                SetInformation(app.Language.Unknown, app.Language.Unknown);
                return;
            }
            switch (format)
            {
            case "Rich Text Format": LoadText(obj as string, ref fdr, format); break;

            case "UnicodeText":
            case "Text":
            case "OEMText": LoadText(obj as string, ref fdr); break;

            case "FileDrop":
            case "FileNameW":
            case "FileName": LoadText(obj as string[], ref fdr); break;

            case "Bitmap": LoadImage(obj as BitmapSource, ref fdr); break;

            case "DeviceIndependentBitmap":
            case "Format17":
            {
                MemoryStream ms = obj as MemoryStream;
                LoadImage(DibImageV5.ConvertDibToImageSource(ref ms), ref fdr);
            }
            break;
            }
        }
        private void SaveCmdExecuted(object sender, ExecutedRoutedEventArgs e)
        {
            switch
            (
                ((ActiveTab.Header as StackPanel).Children[0] as TextBlock).Text
            )
            {
            case "Rich Text Format":
            case "UnicodeText":
            case "Text":
            case "OEMText":
            case "FileDrop":
            case "FileNameW":
            case "FileName":
            {
                FlowDocumentReader FlowDocReader = ActiveTab.Content as FlowDocumentReader;
                SaveText(ref FlowDocReader);
                return;
            }

            case "Bitmap":
            case "DeviceIndependentBitmap":
            case "Format17":
            {
                FlowDocumentReader FlowDocReader = ActiveTab.Content as FlowDocumentReader;
                SaveImage(ref FlowDocReader);
                return;
            }
            }
        }
Esempio n. 3
0
        public void SaveReport(string FileName)
        {
            FlowDocumentReader.Refresh();
            var DocContent = new TextRange(FlowDocumentReader.Document.ContentStart, FlowDocumentReader.Document.ContentEnd);

            if (DocContent.CanSave(DataFormats.Rtf))
            {
                using (var stream = new FileStream(FileName, FileMode.Create, FileAccess.Write))
                {
                    DocContent.Save(stream, DataFormats.Rtf, true);
                }
            }
            //TODO: add saving in different formats

            // DO NOT DELETE will be used later !!!!!!!!!!!!!!!!!!!!!!!
            // if (content2.CanSave(DataFormats.))
            //{
            //    using (var stream = new FileStream(@"c:\temp\2.xaml", FileMode.Create))
            //    {
            //        content2.Save(stream, DataFormats.Xaml, true);
            //    }
            //}

            // Saving with pic and smaller footprint
            //if (DocContent.CanSave(DataFormats.XamlPackage))
            //{
            //    using (var stream = new FileStream(@"c:\temp\2.xaml", FileMode.Create))
            //    {
            //        DocContent.Save(stream, DataFormats.XamlPackage, true);
            //    }
            //}

            ////Save to XPS
            //Attachment xps = new Attachment(FlowDocumentToXPS(), "FileName.xps", "application/vnd.ms-xpsdocument");
        }
Esempio n. 4
0
		// This function handles the article switching
		private void ButtonClick(object sender, RoutedEventArgs e)
		{
			switch (((Button)sender).Name)
			{
				case "galaxiesButton":
					// Remove the FlowDocumentReader that's in view now and add in the desired one
					dockPanel.Children.Remove(currentFlowDocumentReader);
					dockPanel.Children.Add(galaxiesFlowDocumentReader);
					currentFlowDocumentReader = galaxiesFlowDocumentReader;
					currentAnnotService = galaxiesAnnotService;
					break;

				case "carsButton":
					// Remove the FlowDocumentReader that's in view now and add in the desired one
					dockPanel.Children.Remove(currentFlowDocumentReader);
					dockPanel.Children.Add(carsFlowDocumentReader);
					currentFlowDocumentReader = carsFlowDocumentReader;
					currentAnnotService = carsAnnotService;
					break;

				default:
					// Remove the FlowDocumentReader that's in view now and add in the desired one
					dockPanel.Children.Remove(currentFlowDocumentReader);
					dockPanel.Children.Add(greekFlowDocumentReader);
					currentFlowDocumentReader = greekFlowDocumentReader;
					currentAnnotService = greekAnnotService;
					break;
			}
		}
Esempio n. 5
0
        public MainWindow()
        {
            InitializeComponent();

            fdr = new FlowDocumentReader();
            contentGrid.Children.Add(fdr);

            currentNameSpace =
                this.GetType().Namespace;


            FlowDocument doc = new FlowDocument();
            Paragraph    p1  = new Paragraph(new Run("Hello Document 1!"));

            doc.Blocks.Add(p1);

            FlowDocument doc2 = new FlowDocument();
            Paragraph    p2   = new Paragraph(new Run("Hello Document 2!"));

            doc2.Blocks.Add(p2);

            docs = new List <FlowDocument> {
                doc, doc2
            };
        }
Esempio n. 6
0
        private void SaveText(ref FlowDocumentReader fdr)
        {
            string         mask = "Rich Text Format (*.rtf)|*.rtf|" + app.Language.TextDocument + " (*.txt)|*.txt|" + app.Language.AllFiles + " (*.*)|*.*";
            SaveFileDialog Save = CreateSaveDialog(mask, app.Language.Save);

            if (Save.ShowDialog(this).GetValueOrDefault())
            {
                FileStream file = SafeFileMethods.CreateFile(Save.FileName);
                if (file == null)
                {
                    ShowNotification(app.Language.SaveTextError, Title, System.Windows.Forms.ToolTipIcon.Error);
                    return;
                }
                TextRange tr = new TextRange(fdr.Document.ContentStart, fdr.Document.ContentEnd);
                tr.Select(fdr.Document.ContentStart, fdr.Document.ContentEnd);
                if (Save.FilterIndex > 1)
                {
                    tr.Save(file, DataFormats.Text);
                }
                else
                {
                    tr.Save(file, DataFormats.Rtf);
                }
                tr.Select(fdr.Document.ContentStart, fdr.Document.ContentStart);
                file.Close();
            }
        }
 public MyAnnotationStore(FlowDocumentReader myDocumentReader)
 {
     // Create the AnnotationService object that works
     // with our FlowDocumentReader.
     _anoService = new AnnotationService(myDocumentReader);
     // Create a MemoryStream which will hold the annotations.
     _storeMemory = new MemoryStream();
 }
Esempio n. 8
0
            //        <paragraph
            //    context = "introduction"

            //    index="a" [list]
            ///>

            //<heading
            //    level = "1"

            //    index="8"
            //	index="a"
            ///>

            //<list
            //    type = "LETTER"

            //    type="NUMBER"
            //	design="FULLSTOP"
            //	design="DOUBLEBRACKET"
            ///>

        public SimpleFlow(XmlDocument note)
        {
            FlowDocument flowDocument = new FlowDocument();
            List list = new List();
            Paragraph paragraph;

            foreach (XmlNode node in note.ChildNodes)
            {
                XmlAttributeCollection attribs = node.Attributes;

                if (attribs != null)
                {
                    string attribName = ""; //= attribs.Name;
                    switch (attribName)
                    {
                        case "paragraph":
                            paragraph = formatParagraph();
                            flowDocument.Blocks.Add(paragraph);
                            break;
                        case "heading":
                            formatHeading();
                            break;
                        case "list":
                            formatList();
                            break;
                        default:
                            break;
                    }

                    foreach (XmlAttribute attrib in attribs)
                    {
                        if (attrib.ToString() == "paragraph")
                            formatParagraph()
                        //paragraph = new Paragraph(new Run(attrib.ToString()));
                        //list.ListItems.Add(new ListItem(paragraph));
                    }
                }
                else
                {
                    paragraph = new Paragraph(new Run("this is a new run"));
                    list.ListItems.Add(new ListItem(paragraph));
                }
            }

            //Paragraph paragraph = new Paragraph();
            //paragraph.Inlines.Add(new Bold(new Run("Some bold text")));                      

            
            //flowDocument.Blocks.Add(paragraph);
            flowDocument.Blocks.Add(list);

            FlowDocumentReader flowDocumentReader = new FlowDocumentReader();
            flowDocumentReader.Document = flowDocument;

            this.Content = flowDocumentReader;
        }
        private TabItem CreateTabItem(StackPanel header, FlowDocumentReader content)
        {
            TabItem tab = new TabItem()
            {
                Header  = header,
                Content = content
            };

            return(tab);
        }
        private void LoadText(string text, ref FlowDocumentReader fdr)
        {
            fdr.Document.PageWidth = 816;
            TextRange tr = new TextRange(fdr.Document.ContentStart, fdr.Document.ContentEnd)
            {
                Text = text
            };

            SetInformation(app.Language.Text, text.Length.ToString());
            tr.Select(fdr.Document.ContentStart, fdr.Document.ContentStart);
        }
Esempio n. 11
0
		// Used to track the FlowDocumentReader currently being viewed.

        public Window1()
        {
            InitializeComponent();

			// Creates a FlowDocument from the XML files and assigns the FlowDocument to the proper FlowDocumentReader
			galaxiesFlowDocumentReader.Document = ConvertXmlToFlowDocument("Galaxies.xml");
			carsFlowDocumentReader.Document = ConvertXmlToFlowDocument("Cars.xml");

			// App starts off with the greek article, so set the currentFlowDocumentReader and currentAnnotService to reflect this.
			currentFlowDocumentReader = greekFlowDocumentReader;
        }
        private void LoadText(string[] text, ref FlowDocumentReader fdr)
        {
            fdr.Document.PageWidth = 816;
            TextRange tr = new TextRange(fdr.Document.ContentStart, fdr.Document.ContentEnd);

            foreach (string str in text)
            {
                tr.Text += str + Environment.NewLine;
            }
            SetInformation(app.Language.Files, text.Length.ToString());
            tr.Select(fdr.Document.ContentStart, fdr.Document.ContentStart);
        }
Esempio n. 13
0
/// <summary>
/// This method deletes content of the TabItem
/// </summary>
/// <param name="tab"></param>
        private void DeleteTabContent(TabItem tab)
        {
            if (tab == null)
            {
                throw new ArgumentNullException("TabItem tab");
            }
            FlowDocumentReader fdr = tab.Content as FlowDocumentReader;

            fdr.Background = null;
            fdr.Document.Blocks.Clear();
            tab.Content = null;
        }
Esempio n. 14
0
        public static TextPointer GetPositionFromPoint(FlowDocumentReader thiz, Point searchForPoint)
        {
            foreach (Run curRun in WpfTreeHelper.GetChildren <Run>(thiz, true))
            {
                TextPointer ptr = RunExtensions.GetPositionFromPoint(curRun, searchForPoint);

                if (ptr != null)
                {
                    return(ptr);
                }
            }
            return(null);
        }
Esempio n. 15
0
 public static void AppendMessage(string message, FlowDocumentReader reader)
 {
     DispatcherHelper.Invoke(
         () => {
         Paragraph paragraph = new Paragraph();
         paragraph.Inlines.Add(new Span(new Run(message)));
         reader.Document.Blocks.Add(paragraph);
         if (reader.Document.Blocks.LastBlock != null)
         {
             reader.Document.Blocks.LastBlock.Loaded += MessageAdded;
         }
     });
 }
        // Token: 0x060062DD RID: 25309 RVA: 0x001BC160 File Offset: 0x001BA360
        private static ITextSelection GetTextSelection(FrameworkElement viewer)
        {
            FlowDocumentReader flowDocumentReader = viewer as FlowDocumentReader;

            if (flowDocumentReader != null)
            {
                viewer = (AnnotationHelper.GetFdrHost(flowDocumentReader) as FrameworkElement);
            }
            if (viewer != null)
            {
                return(TextEditor.GetTextSelection(viewer));
            }
            return(null);
        }
Esempio n. 17
0
        public void SaveReport(string FileName)
        {
            FlowDocumentReader.Refresh();
            var DocContent = new TextRange(FlowDocumentReader.Document.ContentStart,
                                           FlowDocumentReader.Document.ContentEnd);

            if (DocContent.CanSave(DataFormats.Rtf))
            {
                using (var stream = new FileStream(FileName, FileMode.Create, FileAccess.Write))
                {
                    DocContent.Save(stream, DataFormats.Rtf, true);
                }
            }
        }
        // Token: 0x060062D2 RID: 25298 RVA: 0x001BB87C File Offset: 0x001B9A7C
        internal static object GetFdrHost(FlowDocumentReader fdr)
        {
            Invariant.Assert(fdr != null, "Null FDR");
            Decorator decorator = null;

            if (fdr.TemplateInternal != null)
            {
                decorator = (StyleHelper.FindNameInTemplateContent(fdr, "PART_ContentHost", fdr.TemplateInternal) as Decorator);
            }
            if (decorator == null)
            {
                return(null);
            }
            return(decorator.Child);
        }
Esempio n. 19
0
        public void openBook(string path)
        {
            this.rightPannel.Children.Clear();
            StreamReader sr   = new StreamReader(path);
            string       book = sr.ReadToEnd();
            Paragraph    p    = new Paragraph();

            p.Inlines.Add(new Run(book));
            FlowDocument doc = new FlowDocument();

            doc.Blocks.Add(p);
            FlowDocumentReader read = new FlowDocumentReader();

            read.Document = doc;
            this.rightPannel.Children.Add(read);
        }
Esempio n. 20
0
        private FlowDocumentReader CreateFlowDocReader()
        {
            ContextMenu menu = new ContextMenu();

            Image image =
                new Image()
            {
                Source = ImageConverter.IconToBitmapFrame(Properties.Resources.Copy)
            };

            MenuItem item =
                new MenuItem()
            {
                Header  = app.Language.Copy,
                Command = ApplicationCommands.Copy,
                ToolTip =
                    new TextBlock()
                {
                    Text = app.Language.CopyDescription
                },
                Icon = image
            };

            menu.Items.Add(item);

            FlowDocument FlowDoc =
                new FlowDocument()
            {
                AllowDrop   = false,
                FontSize    = 12,
                FontFamily  = new FontFamily("Segoe UI"),
                ContextMenu = menu
            };

            FlowDocumentReader flow =
                new FlowDocumentReader()
            {
                Background           = app.Resources["BackgroungBrush"] as Brush,
                ViewingMode          = FlowDocumentReaderViewingMode.Scroll,
                IsTwoPageViewEnabled = false,
                IsPageViewEnabled    = false,
                MinZoom  = 100,
                Document = FlowDoc
            };

            return(flow);
        }
Esempio n. 21
0
        private object GetParagraphImage(ref FlowDocumentReader FlowDocReader)
        {
            object obj = null;

            try
            {
                Paragraph         p     = FlowDocReader.Document.Blocks.FirstBlock as Paragraph;
                InlineUIContainer iui   = p.Inlines.FirstInline as InlineUIContainer;
                Image             image = iui.Child as Image;
                obj = image.Source as BitmapSource;
            }
            catch (Exception e)
            {
                obj = null;
                ShowNotification(e.Message, Title, System.Windows.Forms.ToolTipIcon.Error);
            }
            return(obj);
        }
Esempio n. 22
0
        private void SelectorSelectionChanged(object sender, SelectionChangedEventArgs e)
        {
            if (sender is Selector)
            {
                Selector selector = sender as Selector;
                if (selector.SelectedIndex > -1)
                {
                    switch (selector.Name)
                    {
                    case "ListView1":
                        if (selector.SelectedIndex != 0)
                        {
                            string f = cl.AvailableFormats[selector.SelectedIndex];
                            if (!IsTabOpen(f))
                            {
                                FlowDocumentReader FlowDocReader = CreateFlowDocReader();
                                TabItem            tab           = CreateTabItem
                                                                   (
                                    CreateTabHeader
                                    (
                                        f,
                                        true
                                    ),
                                    FlowDocReader
                                                                   );
                                TabControl1.Items.Add(tab);
                                LoadClipboardData(f, ref FlowDocReader);
                                TabControl1.SelectedIndex++;
                            }
                        }
                        break;

                    case "TabControl1":
                    {
                        if (ActiveTab.Content != null)
                        {
                            (ActiveTab.Content as UIElement).Focus();
                        }
                    }
                    break;
                    }
                }
            }
        }
Esempio n. 23
0
        void FDRProps()
        {
            // <Snippet_FlowDocumentReader>
            FlowDocumentReader flowDocRdr = new FlowDocumentReader();

            // Enable find...
            flowDocRdr.IsFindEnabled = true;
            // Enable printing...
            flowDocRdr.IsPrintEnabled = true;
            // Set zoom between 50% and 1000%.
            flowDocRdr.MinZoom = 50;
            flowDocRdr.MaxZoom = 1000;
            // Set the zoom increment to 5%.
            flowDocRdr.ZoomIncrement = 5;
            // Set the initial zoom to 120%.
            flowDocRdr.Zoom = 120;

            FlowDocument flowDoc = new FlowDocument(new Paragraph(new Run("Flow content...")));

            flowDocRdr.Document = flowDoc;
            // </Snippet_FlowDocumentReader>
        }
Esempio n. 24
0
        public Window1()
        {
            InitializeComponent();

			// Creates a FlowDocument from the XML files and assigns the FlowDocument to the proper FlowDocumentReader
			galaxiesFlowDocumentReader.Document = ConvertXmlToFlowDocument("Galaxies.xml");
			carsFlowDocumentReader.Document = ConvertXmlToFlowDocument("Cars.xml");

			// Initialize the AnnotationServices and point them to their respective FlowDocumentReaders
			greekAnnotService = new AnnotationService(greekFlowDocumentReader);
			galaxiesAnnotService = new AnnotationService(galaxiesFlowDocumentReader);
			carsAnnotService = new AnnotationService(carsFlowDocumentReader);

			// Enable the AnnotationServices and point them to their respective FileStreams
			greekAnnotService.Enable(new XmlStreamStore(greekFileStream));
			galaxiesAnnotService.Enable(new XmlStreamStore(galaxiesFileStream));
			carsAnnotService.Enable(new XmlStreamStore(carsFileStream));

			// App starts off with the greek article, so set the currentFlowDocumentReader and currentAnnotService to reflect this.
			currentFlowDocumentReader = greekFlowDocumentReader;
			currentAnnotService = greekAnnotService;
        }
Esempio n. 25
0
        private void SaveImage(ref FlowDocumentReader fdr)
        {
            string         mask = app.Language.BitmapImage + " (*.bmp)|*.bmp|JPEG (*.jpg)|*.jpg|Portable Network Graphics (*.png)|*.png|Graphics Interchange Format (*.gif)|*.gif|Tagged Image File Format (*.tiff)|*.tiff";
            SaveFileDialog Save = CreateSaveDialog(mask, app.Language.Save);

            if (Save.ShowDialog(this).GetValueOrDefault())
            {
                FileStream file = SafeFileMethods.CreateFile(Save.FileName);
                if (file == null)
                {
                    ShowNotification(app.Language.SaveImageError, Title, System.Windows.Forms.ToolTipIcon.Error);
                    return;
                }
                FlowDocumentReader FlowDocReader = ActiveTab.Content as FlowDocumentReader;
                object             obj           = GetParagraphImage(ref FlowDocReader);
                if (obj == null)
                {
                    goto CloseStream;
                }
                BitmapFrame frame = BitmapFrame.Create(obj as BitmapSource);
                ImageType   imgtype;
                switch (Save.FilterIndex)
                {
                case 1: imgtype = ImageType.Bmp; break;

                case 2: imgtype = ImageType.Jpg; break;

                case 3: imgtype = ImageType.Png; break;

                case 4: imgtype = ImageType.Gif; break;

                case 5: imgtype = ImageType.Tiff; break;

                default: imgtype = ImageType.Bmp; break;
                }
                CreateImageFile(file, frame, imgtype);
                CloseStream : file.Close();
            }
        }
        private void LoadText(string text, ref FlowDocumentReader fdr, string format)
        {
            fdr.Document.PageWidth = 816;
            TextRange    tr = new TextRange(fdr.Document.ContentStart, fdr.Document.ContentEnd);
            MemoryStream ms = new MemoryStream(Encoding.Default.GetBytes(text));

            try
            {
                tr.Load(ms, format);
            }
            catch (ArgumentException)
            {
                tr.Text = String.Empty;
                ShowNotification(app.Language.LoadTextError, Title, System.Windows.Forms.ToolTipIcon.Error);
            }
            catch (Exception e)
            {
                tr.Text = String.Empty;
                ShowNotification(e.Message, Title, System.Windows.Forms.ToolTipIcon.Error);
            }
            SetInformation(app.Language.Text, tr.Text.Length.ToString());
            tr.Select(fdr.Document.ContentStart, fdr.Document.ContentStart);
        }
 private void LoadImage(BitmapSource bitmap, ref FlowDocumentReader fdr)
 {
     fdr.Document.PageWidth = bitmap.Width + 33;
     fdr.Document.Blocks.Add
     (
         new Paragraph
         (
             new InlineUIContainer()
     {
         Child = new Image()
         {
             HorizontalAlignment = HorizontalAlignment.Left,
             VerticalAlignment   = VerticalAlignment.Top,
             Stretch             = Stretch.None, Source = bitmap
         }
     }
         )
     );
     SetInformation(app.Language.Image, "1");
     fdr.IsFindEnabled = false;
     fdr.MaxZoom       = 1000;
     fdr.MinZoom       = 80;
 }
Esempio n. 28
0
        public SimpleFlowExample()
        {
            Paragraph myParagraph = new Paragraph();

            // Add some Bold text to the paragraph
            myParagraph.Inlines.Add(new Bold(new Run("Some bold text in the paragraph.")));

            // Add some plain text to the paragraph
            myParagraph.Inlines.Add(new Run(" Some text that is not bold."));

            // Create a List and populate with three list items.
            List myList = new List();

            // First create paragraphs to go into the list item.
            Paragraph paragraphListItem1 = new Paragraph(new Run("ListItem 1"));
            Paragraph paragraphListItem2 = new Paragraph(new Run("ListItem 2"));
            Paragraph paragraphListItem3 = new Paragraph(new Run("ListItem 3"));

            // Add ListItems with paragraphs in them.
            myList.ListItems.Add(new ListItem(paragraphListItem1));
            myList.ListItems.Add(new ListItem(paragraphListItem2));
            myList.ListItems.Add(new ListItem(paragraphListItem3));

            // Create a FlowDocument with the paragraph and list.
            FlowDocument myFlowDocument = new FlowDocument();

            myFlowDocument.Blocks.Add(myParagraph);
            myFlowDocument.Blocks.Add(myList);

            // Add the FlowDocument to a FlowDocumentReader Control
            FlowDocumentReader myFlowDocumentReader = new FlowDocumentReader();

            myFlowDocumentReader.Document = myFlowDocument;

            this.Content = myFlowDocumentReader;
        }
        // Token: 0x060062DF RID: 25311 RVA: 0x001BC234 File Offset: 0x001BA434
        private static void CheckInputs(AnnotationService service)
        {
            if (service == null)
            {
                throw new ArgumentNullException("service");
            }
            if (!service.IsEnabled)
            {
                throw new ArgumentException(SR.Get("AnnotationServiceNotEnabled"), "service");
            }
            DocumentViewerBase documentViewerBase = service.Root as DocumentViewerBase;

            if (documentViewerBase == null)
            {
                FlowDocumentScrollViewer flowDocumentScrollViewer = service.Root as FlowDocumentScrollViewer;
                FlowDocumentReader       flowDocumentReader       = service.Root as FlowDocumentReader;
                Invariant.Assert(flowDocumentScrollViewer != null || flowDocumentReader != null, "Service's Root must be either a FlowDocumentReader, DocumentViewerBase or a FlowDocumentScrollViewer.");
                return;
            }
            if (documentViewerBase.Document == null)
            {
                throw new InvalidOperationException(SR.Get("OnlyFlowFixedSupported"));
            }
        }
        private FlowDocument SimpleFlowExample()
        {
            try
            {
                // Add some Bold text to the paragraph
                Paragraph myParagraph = new Paragraph();
                myParagraph.FontSize = 33;//hn
                // myParagraph.FontSize = 11;//asr,kp

                myParagraph.FontFamily = new FontFamily("Arial");
                myParagraph.Inlines.Add(new Bold(new Run("\t\tHimayath Nagar" + "\r\n\b")));//hn
                //  myParagraph.Inlines.Add(new Bold(new Run("\t\tA.S.Rao Nagar" + "\r\n\b"))); //asrao
                //   myParagraph.Inlines.Add(new Bold(new Run("\t\tKukatpally" + "\r\n\b"))); //kp
                myParagraph.Inlines.Add(new Run("\r\n"));
                myParagraph.Inlines.Add(new Run("Order ID : " + lblOrderID.Content.ToString().PadRight(5) + "\r\n"));
                myParagraph.Inlines.Add(new Bold(new Run(lblCustName.Content.ToString().PadRight(5) + "\r\n")));
                myParagraph.Inlines.Add(new Run("Phone : " + lblCustPhone.Content.ToString().PadRight(5) + "  " + lblAddress.Content.ToString() + "\r\n"));
                myParagraph.Inlines.Add(new Run("Items " + lblItems.Content.ToString().PadRight(5) + "  Total Amount : Rs." + lblactamount.Content.ToString() + "\r\n"));

                // Create a FlowDocument and add the paragraph to it.
                FlowDocument myFlowDocument = new FlowDocument();
                myFlowDocument.Blocks.Add(myParagraph);

                Line pLine = new Line();
                pLine.Stretch         = Stretch.Fill;
                pLine.Stroke          = Brushes.Black;
                pLine.X2              = 1;
                pLine.StrokeThickness = 1;
                myParagraph.Inlines.Add(pLine);
                // Add some plain text to the paragraph

                // Create a List and populate with three list items.

                //   myParagraph.Inlines.Add(new Run(" Customer Name : " + lblCustName.Content.ToString()));
                myParagraph.Inlines.Add(new Run("Code".PadLeft(2) + string.Format("{0}", "\t") + "Dish".PadLeft(5) + string.Format("{0}", "\t") + string.Format("{0}", "\t") + "Qty".PadLeft(5) + string.Format("{0}", "\t") + "Price".PadLeft(5) + string.Format("{0}", "\t") + "Total".PadLeft(5) + "\r\n"));
                // myParagraph.Inlines.Add(pLine);
                int ordercount = lvOrders.Items.Count;
                for (int i = 0; i < ordercount; i++)
                {
                    TableRow  tblRow   = new TableRow();
                    TableCell tblCell1 = new TableCell();
                    TableCell tblCell2 = new TableCell();
                    //     myParagraph.Inlines.Add(new Run("Cell ID1" + i + "\r\n"));

                    tblRow.Cells.Add(tblCell1);
                    tblRow.Cells.Add(tblCell2);
                    string pname;

                    pname = dSet.Rows[i]["ProductName"].ToString();
                    if (pname.Length > 13)
                    {
                        pname = pname.Substring(0, 13).PadRight(23);
                    }
                    else
                    {
                        int pLen = pname.Length;
                        pname = pname.PadRight(23 - pLen);
                    }
                    string Pid   = dSet.Rows[i]["ProductId"].ToString();
                    string qty   = dSet.Rows[i]["Quantity"].ToString();
                    string Price = dSet.Rows[i]["Price"].ToString();
                    string Total = dSet.Rows[i]["Total"].ToString();


                    myParagraph.Inlines.Add(new Run(Pid.PadLeft(2) + (pname.PadLeft(2)) + string.Format("{0}", "\t") + qty.PadLeft(2) + string.Format("{0}", "\t") + Price.PadLeft(2) + string.Format("{0}", "\t") + Total.PadLeft(2) + "\r\n"));

                    //  myFlowDocument.Blocks.Add(myParagraph + "\n");
                }
                //myParagraph.Inlines.Add(new Run("\r\r\n\n"));
                //myParagraph.Inlines.Add(new Run("  Total Amount : Rs." + lblactamount.Content.ToString() + "\r\n"));
                //myParagraph.Inlines.Add(new Run("\r\n"));
                //myParagraph.Inlines.Add(new Run("  GST 12% :" + lblgst.Content.ToString() + "\r\n"));
                //myParagraph.Inlines.Add(new Run("\r\n"));
                //myParagraph.Inlines.Add(new Run("  Delivery Charge : Rs." + lbldelcharges.Content.ToString() + "\r\n"));
                //myParagraph.Inlines.Add(new Run("\r\n"));
                //myParagraph.Inlines.Add(new Run("  Grand Total : Rs." + lblGrandTotal.Content.ToString() + "\r\n"));
                //myParagraph.Inlines.Add(new Run("\r\n"));
                //myParagraph.Inlines.Add(new Run("Thank You visit again  040-69006900"));
                myParagraph.Inlines.Add(new Run("\r\n"));

                myParagraph.Inlines.Add(new Bold(new Run("  Total Amount " + lblactamount.Content.ToString().PadLeft(48) + "\r\n")));
                // myParagraph.Inlines.Add(new Run("\r\n"));
                //  myParagraph.Inlines.Add((new Run("  CGST " + lblcgst.Content.ToString().PadLeft(56) + "\r\n")));
                // myParagraph.Inlines.Add(new Run("\r\n"));
                //  myParagraph.Inlines.Add((new Run("  SGST " + lblsgst.Content.ToString().PadLeft(56) + "\r\n")));
                // myParagraph.Inlines.Add(new Run("\r\n"));
                myParagraph.Inlines.Add(new Bold(new Run("  Delivery Charge " + lbldelcharges.Content.ToString().PadLeft(45) + "\r\n")));
                //myParagraph.Inlines.Add(new Run("\r\n"));
                myParagraph.Inlines.Add(new Bold(new Run("  Grand Total" + lblGrandTotal.Content.ToString().PadLeft(52) + "\r\n")));

                myParagraph.Inlines.Add(new Bold(new Run("\r\n")));
                myParagraph.Inlines.Add(new Bold(new Run("  (GST Inclusive) \r\n")));

                myParagraph.Inlines.Add(new Bold(new Run("\r\n")));
                myParagraph.Inlines.Add(new Bold(new Run("  GSTIN:" + lblGSTIN.Content.ToString().PadLeft(15) + "\r\n")));
                myParagraph.Inlines.Add(new Bold(new Run("\r\n")));
                myParagraph.Inlines.Add(new Bold(new Run("Thank You visit again 7306544444")));
                //  myParagraph.Inlines.Add(pLine);
                myFlowDocument.ColumnWidth = 999999;
                myFlowDocument.PagePadding = new Thickness(10);
                // Padding is 5 pixels on the right and left, and 10 pixels on the top and botton.
                myFlowDocument.PagePadding = new Thickness(40, 10, 5, 10);

                //  myParagraph.Inlines.Add(image);


                BlockUIContainer uiCont = new BlockUIContainer();

                Label myButton = new Label
                {
                    //Width = 350,
                    //Height = 250,
                    Width  = 200,
                    Height = 100,
                    //  HorizontalAlignment = HorizontalAlignment.Left,//kp,an
                    HorizontalAlignment = HorizontalAlignment.Center,//hn
                    Background          = new SolidColorBrush(Colors.White),
                    Content             = new Image
                    {
                        Source = new BitmapImage(new Uri(@"C:\Users\user\Downloads\AC.png", UriKind.Relative)),//hn
                        //  Source = new BitmapImage(new Uri(@"C:\Users\Public\Pictures\Sample Pictures\AC.png", UriKind.Relative)),//asr
                        //  Source = new BitmapImage(new Uri(@"D:\AC.png", UriKind.Relative)),//kp

                        VerticalAlignment = VerticalAlignment.Center
                    }
                };

                //  b.Content = "Click me";
                uiCont.Child = (myButton);
                myFlowDocument.Blocks.Add(uiCont);
                myFlowDocument.Blocks.Add(myParagraph);
                // myFlowDocument.Blocks.Add(myList);



                // Add the FlowDocument to a FlowDocumentReader Control
                FlowDocumentReader myFlowDocumentReader = new FlowDocumentReader();

                myFlowDocumentReader.Document = myFlowDocument;
                //FlowDocument fp = new FlowDocument();

                this.Content = myFlowDocumentReader;

                return(myFlowDocument);
            }
            catch (Exception ex)
            { throw ex; }

            //    SqlConnection connection;
            //    connection = new SqlConnection(connStr);
            //    if (connection.State.ToString() == "open") { connection.Close(); }
            //    connection.Open();
            //    SqlCommand cmd = new SqlCommand("[PrintorderStatusByOrderId]", connection);
            //    cmd.Parameters.Add(new SqlParameter("OrderId", orderID));
            //    cmd.CommandType = CommandType.StoredProcedure;

            //    //  @Categorytype = N'Break Fast'

            //    SqlDataAdapter dAd = new SqlDataAdapter(cmd);

            //    dAd.Fill(dSet);
            //    // sda.Fill(dt);

            //    int ItemsCount = 0;
            //    lvOrders.Items.Clear();
            //    if (dSet.Rows.Count > 0) {
            //        lvOrders.ItemsSource = dSet.DefaultView;
            //        lblOrderID.Content = dSet.Rows[0][0].ToString();
            //        lblCustName.Content= dSet.Rows[0][2].ToString() +" "+ dSet.Rows[0][3].ToString();
            //        lblAddress.Content= dSet.Rows[0][4].ToString();
            //        lblCustPhone.Content= dSet.Rows[0][1].ToString();
            //        lblOrderDate.Content =     dSet.Rows[0]["OrderDate"].ToString().Substring(0,10) ;



            //        lblOrderTime.Content = dSet.Rows[0]["OrderTime"].ToString();
            //        ItemsCount = int.Parse(dSet.Rows.Count.ToString());
            //        int sum = Convert.ToInt32(dSet.Compute("SUM(Total)", string.Empty));
            //        lblItems.Content = ItemsCount;
            //        lblGrandTotal.Content = sum.ToString();
            //        lblStatus.Content="Order Status: " + dSet.Rows[0]["StatusDescription"].ToString();
            //    }

            //    if (connection.State.ToString() == "open") { connection.Close(); }

            //}

            //private void Button_Click(object sender, RoutedEventArgs e)
            //{
            //    if (lvOrders.Items.Count > 0)
            //    {
            //        PrintDialog printDlg = new PrintDialog();

            //        // Create a FlowDocument dynamically.
            //        //   FlowDocument doc = CreateFlowDocument();
            //        FlowDocument doc = SimpleFlowExample();
            //        doc.Name = "FlowDoc";

            //        // Create IDocumentPaginatorSource from FlowDocument
            //        IDocumentPaginatorSource idpSource = doc;

            //        // Call PrintDocument method to send document to printer
            //        printDlg.PrintDocument(idpSource.DocumentPaginator, "Hello WPF Printing.");
            //       // printDlg.ShowDialog = false;
            //    }

            //    else { MessageBox.Show("Nothing to print !!!"); }
            //}



            //private FlowDocument SimpleFlowExample()
            //{



            //    // Add some Bold text to the paragraph
            //    Paragraph myParagraph = new Paragraph();

            //    myParagraph.FontSize = 33;
            //    myParagraph.FontFamily = new FontFamily("Arial");
            //    myParagraph.Inlines.Add(new Bold(new Run("\t\tHimayath Nagar" + "\r\n\b")));
            //    myParagraph.Inlines.Add(new Run("Order ID : " + lblOrderID.Content.ToString().PadLeft(0) + "\r\n"));
            //    myParagraph.Inlines.Add(new Bold(new Run(lblCustName.Content.ToString().PadLeft(0) + "\r\n")));
            //    myParagraph.Inlines.Add(new Run("Phone : " + lblCustPhone.Content.ToString().PadLeft(0) + "  " + lblAddress.Content.ToString() + "\r\n"));
            //    myParagraph.Inlines.Add(new Run("Items " + lblItems.Content.ToString().PadLeft(0) + "  Total Amount : Rs." + lblGrandTotal.Content.ToString() + "\r\n"));

            //    // Create a FlowDocument and add the paragraph to it.
            //    FlowDocument myFlowDocument = new FlowDocument();
            //    myFlowDocument.Blocks.Add(myParagraph);

            //    Line pLine = new Line();
            //    pLine.Stretch = Stretch.Fill;
            //    pLine.Stroke = Brushes.Black;
            //    pLine.X2 = 1;
            //    pLine.StrokeThickness = 1;
            //    myParagraph.Inlines.Add(pLine);
            //    // Add some plain text to the paragraph

            //    // Create a List and populate with three list items.

            //    //   myParagraph.Inlines.Add(new Run(" Customer Name : " + lblCustName.Content.ToString()));
            //    myParagraph.Inlines.Add(new Run("Code".PadLeft(0) + string.Format("{0}", "\t") + "Dish".PadLeft(3) + string.Format("{0}", "\t") + string.Format("{0}", "\t") + "Qty".PadLeft(3) + string.Format("{0}", "\t") + "Price".PadLeft(3) + string.Format("{0}", "\t") + "Total".PadLeft(3) + "\r\n"));
            //    // myParagraph.Inlines.Add(pLine);
            //    int ordercount = lvOrders.Items.Count;
            //    for (int i = 0; i < ordercount; i++)
            //    {
            //        TableRow tblRow = new TableRow();
            //        TableCell tblCell1 = new TableCell();
            //        TableCell tblCell2 = new TableCell();
            //        //     myParagraph.Inlines.Add(new Run("Cell ID1" + i + "\r\n"));

            //        tblRow.Cells.Add(tblCell1);
            //        tblRow.Cells.Add(tblCell2);
            //        string pname;

            //        pname = dSet.Rows[i]["ProductName"].ToString();
            //        if (pname.Length > 10) { pname = pname.Substring(0, 10).PadRight(20); }
            //        else
            //        {
            //            int pLen = pname.Length;
            //            pname = pname.PadRight(20 - pLen);
            //        }
            //        string Pid = dSet.Rows[i]["ProductId"].ToString();
            //        string qty = dSet.Rows[i]["Quantity"].ToString();
            //        string Price = dSet.Rows[i]["Price"].ToString();
            //        string Total = dSet.Rows[i]["Total"].ToString();


            //        myParagraph.Inlines.Add(new Run(Pid.PadLeft(1) + (pname.PadLeft(1)) + string.Format("{0}", "\t") + qty.PadLeft(1) + string.Format("{0}", "\t") + Price.PadLeft(1) + string.Format("{0}", "\t") + Total.PadLeft(1) + "\r\n"));

            //        //  myFlowDocument.Blocks.Add(myParagraph + "\n");
            //    }
            //    //  myParagraph.Inlines.Add(pLine);
            //    myFlowDocument.ColumnWidth = 999999;


            //    //  myParagraph.Inlines.Add(image);


            //    BlockUIContainer uiCont = new BlockUIContainer();

            //    Label myButton = new Label
            //    {
            //        Width = 400,
            //        Height = 300,
            //        HorizontalAlignment = HorizontalAlignment.Center,
            //        Background = new SolidColorBrush(Colors.White),
            //        Content = new Image
            //        {
            //            Source = new BitmapImage(new Uri(@"C:\Users\venkat\Documents\Visual Studio 2015\Projects\Project3\AnkapurProject\Anakapur\Images\AC.jpg", UriKind.Relative)),
            //            VerticalAlignment = VerticalAlignment.Center
            //        }
            //    };

            //    //  b.Content = "Click me";
            //    uiCont.Child = (myButton);
            //    myFlowDocument.Blocks.Add(uiCont);
            //    myFlowDocument.Blocks.Add(myParagraph);
            //    // myFlowDocument.Blocks.Add(myList);



            //    // Add the FlowDocument to a FlowDocumentReader Control
            //    FlowDocumentReader myFlowDocumentReader = new FlowDocumentReader();
            //    myFlowDocumentReader.Document = myFlowDocument;

            //    this.Content = myFlowDocumentReader;

            //    return myFlowDocument;
        }