I am working with printing in WPF. I implement a class which inherit from DocumentPaginator class  public class ReportPaginator : DocumentPaginator {     private double pageUpperLimit;      private double pageDownLimit;      private Model.Report printedReport;      private int pageCount;      public override IDocumentPaginatorSource Source     {         get         {             return null;         }     }      public override bool IsPageCountValid     {         get { return true; }     }      public override int PageCount     {         get { return pageCount; }     }      public override Size PageSize     {         get         {             return new Size(printedReport.PageSize.Width, printedReport.PageSize.Height);         }         set         {             // validate the value.             if (value != null)             {                 throw new ArgumentException("page size can not be null");             }              // TODO: here we have to validate if the page is A3, A4, A5. this is to set the SizeName.             // if you did not set the sizeName here we will get an exception.             printedReport.PageSize = new Model.PageSize { Height = value.Height, Width = value.Width };             CalculatesPage();             // if we have to set the PageSize (I do not think so), do not forget to call the PaginateData method.         }     }      public ReportPaginator( Model.Report report)     {         printedReport = report;         CalculatesPage();     }      public override DocumentPage GetPage(int pageNumber)     {         // validate the argument.         if (pageNumber &lt; 0)         {             throw new ArgumentException("pageNumber parameter could not be negative number", "pageNumber");         }          // if the argument is outside of the available pages, return          if (pageNumber &gt; pageCount - 1)         {             return DocumentPage.Missing;         }          // specify the start pixel and end pixel of the page according to the height of the report.         pageUpperLimit = pageNumber * PageSize.Height;         pageDownLimit = (pageNumber + 1) * PageSize.Height;          // create DrawingVisual for this DocumentPage         DrawingVisual visual = new DrawingVisual();          // get the DrawingContext for this DrawingVisual for this page.         using (DrawingContext pageContext = visual.RenderOpen())         {             // drawing operations for elements and sections go here.              // we will use the for loop instead of the foreach loop to enumerate the sections             // because we will need the know in which section we draw.             for (int sectionIndex = 0; sectionIndex &lt; printedReport.Sections.Count; sectionIndex++)             {                 PrintSection(pageContext, sectionIndex);                  foreach (Model.BaseReportControl control in printedReport.Sections[sectionIndex].Controls)                 {                     PrintControl(pageContext, sectionIndex, control);                 }             }         }  // close the DrawingContext.          return new DocumentPage(visual);     } }   there is more helper methods to do the jobs.  I want to create FixedDocument object to return it from the Source property using DocumentPage object that returned from GetPage Method.  I need a FixedDocument to be returned from the source Property Because I want to make a preview to the File before printing  ReportPreviewerWindow window = new ReportPreviewerWindow(); window.previewer.Document = new ReportPaginator(printedSurface.ModelReport).Source; window.ShowDialog();   the previewer is DocumentViewer Object exists in the ReportPreviewerWindow  &lt;Window x:Class="TanmiaGrp.Report.Designer.ReportPreviewerWindow"     xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"     xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"     Title="Report Previewer" &gt;    &lt;Grid&gt;       &lt;DocumentViewer x:Name="previewer"/&gt;    &lt;/Grid&gt; &lt;/Window&gt;
I'm using a class I've derived from DocumentPaginator (see below) to print simple (text only) reports from a WPF application. I've got it so that everything prints correctly, But how do I get it to do a print preview before printing? I have a feeling I need to use a DocumentViewer but I can't figure out how.  Here's my Paginator Class:  public class RowPaginator : DocumentPaginator {     private int rows;     private Size pageSize;     private int rowsPerPage;      public RowPaginator(int rows)     {         this.rows = rows;     }      public override DocumentPage GetPage(int pageNumber)     {         int currentRow = rowsPerPage * pageNumber;         int rowsToPrint = Math.Min(rowsPerPage, rows - (rowsPerPage * pageNumber - 1));         var page = new PageElementRenderer(pageNumber + 1, PageCount, currentRow, rowsToPrint)                        {                            Width = PageSize.Width,                            Height = PageSize.Height                        };         page.Measure(PageSize);         page.Arrange(new Rect(new Point(0, 0), PageSize));         return new DocumentPage(page);     }      public override bool IsPageCountValid { get { return true; } }      public override int PageCount { get { return (int)Math.Ceiling(this.rows / (double)this.rowsPerPage); } }      public override Size PageSize     {         get { return this.pageSize; }         set         {             this.pageSize = value;             this.rowsPerPage = PageElementRenderer.RowsPerPage(this.pageSize.Height);             if (rowsPerPage &lt;= 0)                 throw new InvalidOperationException("Page can't fit any rows!");         }     }      public override IDocumentPaginatorSource Source { get { return null; } } }   The PageElementRenderer is just a simple UserControl that displays the data (at the moment just a list of rows).  Here's how I use my Row Paginator  PrintDialog dialog = new PrintDialog(); if (dialog.ShowDialog() == true) {     var paginator = new RowPaginator(rowsToPrint) { PageSize = new Size(dialog.PrintableAreaWidth, dialog.PrintableAreaHeight) };      dialog.PrintDocument(paginator, "Rows Document"); }   Sorry for the code dump, but I didn't want to miss something relevant.
How to setup Windows from an external hard drive? Is it possible to install Windows from an external hard drive?  I have Windows XP installed on my laptop, and I want to remove it and install Windows 7.  My Windows 7 installation is in an .iso format on an external USB hard drive.  Is it possible to install it or will I need to put in a DVD before I start installing? I want to ask how to get id of element which was clicked by right clicking in open menu. I must know ID of this element to show only that history the element what was clicked fom open menu: Do commuting matrices share the same eigenvectors? In one of my exams I'm asked to prove the following      Suppose $A,B\in \mathbb R^{n\times n}$, and $AB=BA$, then $A,B$ share the same eigenvectors.    My attempt is let $\xi$ be an eigenvector corresponding to $\lambda$ of $A$, then $A\xi=\lambda\xi$, then I want to show $\xi$ is also some eigenvector of $B$ but I get stuck. Inverse elements in the absence of identities/associativity. Where can I get a clean ISO of a specific build of Windows 10? I need to repair my Windows 10 installation. Where can I get a clean ISO (with install.wim, no Install.ESD, so that I can run DISM against the WIM) of the specific Windows 10 build required for this?  In my case, I need the Anniversary update (Build 14393), Creators Update (Build 15063) or Fall Creators Update (Build 16299.15). Show that $\cot \frac{\pi}{2m}\cot \frac{2\pi}{2m}\cot \frac{3\pi}{2m}...\cot \frac{(m-1)\pi}{2m}=1$ Dirac Delta or Dirac delta function? Can I install Android on my non-Android device? Many people want to try/use Android without buying a new Android phone.  How can I install Android on my current phone or device running Nokia Symbian, Maemo, or MeeGo; Microsoft Windows Mobile or Windows Phone 7/8/10; Apple iOS (iPhone); RIM's BlackBerry OS; Palm's WebOS; Samsung's Bada; HP's WebOS; Mozilla's Firefox OS; or other phone / operating system? Prove that if $V$ is an inner product space, then $|\langle x,y\rangle| = \Vert x \Vert\Vert y\Vert$ if and only if one of the vectors $x$ or $y$ is a multiple of the other.  I am given a hint to let $a= \frac{\langle x,y\rangle}{\|y\|^2}$, and let $z = x - ay$, then prove $y$ and $z$ are orthogonal and $|a|= \frac{\|x\|}{\|y\|}$. I don't know how they come up with this, what was the original idea? Top Bar background does not persist when scrolling horizontally Update  A month Several months later, a new top bar, and the bug still exists. An answer has already been posted that would fix the bug, so is this something that the dev team plans on fixing?  There are also a host of other problems caused by this, especially on the  and . Again, this would be fixed with  html{min-width:1000px;}   There is a slight bug with small windows on both the new meta and main site(s)?, shown here. The problem is that the top bar coloring doesn't stretch across when you resize and scroll left or right.        On Meta, when a horizontal scroll bar is needed, the black background will only be as wide as the width of the viewport, but when you scroll the coloring will not shift.  To reproduce:   Make screen as large as possible, or wait until the menu bar starts expanding Make it smaller and smaller until horizontal scrollbar appears, then scroll left and right. I posted a question and a couple of respondents asked for the source code. I could only post portions of the code.  If attachments were allowed I could have uploaded a .zip file with the whole application.  Will this be a feature in SO? Python is quite cool, but unfortunately, its debugger is not as good as perl -d.    One thing that I do very commonly when experimenting with code is to call a function from within the debugger, and step into that function, like so:  # NOTE THAT THIS PROGRAM EXITS IMMEDIATELY WITHOUT CALLING FOO() ~&gt; cat -n /tmp/show_perl.pl 1  #!/usr/local/bin/perl 2 3  sub foo { 4      print "hi\n"; 5      print "bye\n"; 6  } 7 8  exit 0;  ~&gt; perl -d /tmp/show_perl.pl  Loading DB routines from perl5db.pl version 1.28 Editor support available.  Enter h or `h h' for help, or `man perldebug' for more help.  main::(/tmp/show_perl.pl:8):    exit 0;  # MAGIC HAPPENS HERE -- I AM STEPPING INTO A FUNCTION THAT I AM CALLING INTERACTIVELY   DB&lt;1&gt; s foo()  main::((eval 6)[/usr/local/lib/perl5/5.8.6/perl5db.pl:628]:3): 3:      foo();     DB&lt;&lt;2&gt;&gt; s main::foo(/tmp/show_perl.pl:4):     print "hi\n";     DB&lt;&lt;2&gt;&gt; n hi main::foo(/tmp/show_perl.pl:5):     print "bye\n";     DB&lt;&lt;2&gt;&gt; n bye     DB&lt;2&gt; n Debugged program terminated.  Use q to quit or R to restart,   use O inhibit_exit to avoid stopping after program termination,   h q, h R or h O to get additional info.      DB&lt;2&gt; q   This is incredibly useful when trying to step through a function's handling of various different inputs to figure out why it fails.  However, it does not seem to work in either pdb or pydb (I'd show an equivalent python example to the one above but it results in a large exception stack dump).  So my question is twofold:   Am I missing something? Is there a python debugger that would indeed let me do this?   Obviously I could put the calls in the code myself, but I love working interactively, eg. not having to start from scratch when I want to try calling with a slightly different set of arguments. I am new to Linux and Ubuntu. When I don't know how to do something with this OS I search on the web and Ask Ubuntu and always find the answer.  But sometimes it's not a great answer nor complete tutorial. I follow the instructions anyway, but I don't know what all the commands mean.  So my question is:   When I follow a tutorial, am I 100% safe? If not, then how can I tell I am in danger? I am having a lot of trouble with these series questions. Up until this point, I had relatively little trouble with all the questions in the book. These seem to require knowledge about approximations of functions and other external experience-based knowledge, which I just don't have yet.  Determine convergence or divergence of the given series. In the case of convergence, determine whether the series converges absolutely or conditionally.  $$\sum_{n=1}^\infty (-1)^n\left[e-\left(1+\frac 1 n \right)^n\right]$$  It's easy to see that  $$\lim_{n\to\infty}\left[e-\left(1+\frac 1 n\right)^n\right]=0$$  however, in order to apply Leibniz's Rule and show conditional convergence I need to show that the sequence is monotonically decreasing. This doesn't seem doable with straight inequalities, so I tried taking the derivative, which just resulted in an uninterpretable mess. This doesn't even begin to address the question of absolute convergence/divergence.  There are 54 of these questions... I must be missing something really fundamental if they all take this long. How can I read off the fact that gravity is associated with spin-2 particles from the Einstein-Hilbert action? I have often heard that the gravitational field has spin $2$. How can I read the spin of the field from the Einstein-Hilbert action  $$S=\int \! \mathrm{d}^4x \,\sqrt{|g|} \, \mathcal{R} \, \, \, ?$$ Adding a Method to an Existing Object Instance I've read that it is possible to add a method to an existing object (i.e., not in the class definition) in Python.   I understand that it's not always good to do so. But how might one do this? When I run  mkdir ../../bin/Release_Linux/Resources   Im getting an error  $ mkdir ../../bin/Release_Linux/Resources mkdir: cannot create directory ‘../../bin/Release_Linux/Resources’: No such file or directory   Or just   mkdir Release_Linux/Resources mkdir: cannot create directory ‘Release_Linux/Resources’: No such file or directory Nautilus doesn't launch on Ubuntu Editing LaTeX generated PDF Is there an application (in Windows, Unix, or Mac) that allows you to edit the LaTeX generated PDF. I know there is pdfsync, but it only gives you the line, and then you have to search where in the line you want to make the change. This is OK sometimes, for a couple of changes, but when there are lots of changes it becomes really tedious.  I would really like to accelerate this process of correcting mistakes (mostly grammar, missing commas etc.). in my document, without going through all the markup. I've lost my original power adapter, and I can't find the proper one in any of the stores currently available.  I've HP Compaq 6730b, and as per  it outputs 18.5V 3.5A. However, I've found an older power adapter I have which outputs 19.5V 4.62 A.  So, my question is: how much of a difference between those two it really is, and more importantly, how much of a risk would it be if I tried the power adapter I already have.  P.S. I know pretty much nothing about electricity/electronics.