Click here to Skip to main content
15,887,477 members
Home / Discussions / C#
   

C#

 
Questionlogs window with a lot of lines Pin
IWannaTalk13-Sep-10 1:56
IWannaTalk13-Sep-10 1:56 
AnswerRe: logs window with a lot of lines Pin
Luc Pattyn13-Sep-10 2:25
sitebuilderLuc Pattyn13-Sep-10 2:25 
GeneralRe: logs window with a lot of lines Pin
IWannaTalk13-Sep-10 3:02
IWannaTalk13-Sep-10 3:02 
GeneralRe: logs window with a lot of lines Pin
Luc Pattyn13-Sep-10 3:10
sitebuilderLuc Pattyn13-Sep-10 3:10 
GeneralRe: logs window with a lot of lines Pin
IWannaTalk13-Sep-10 21:48
IWannaTalk13-Sep-10 21:48 
GeneralRe: logs window with a lot of lines Pin
Luc Pattyn13-Sep-10 23:44
sitebuilderLuc Pattyn13-Sep-10 23:44 
QuestionCreating a p7m file. Pin
shadowzz12345613-Sep-10 1:08
shadowzz12345613-Sep-10 1:08 
QuestionPrinting: Slow access to PaperSize Pin
OriginalGriff12-Sep-10 23:57
mveOriginalGriff12-Sep-10 23:57 
I have been doing some playing with a generic print class to add header/footer/lefter/righter support, so have been implementing my own print preview. But for some reason, it seemed really sluggish. When I switch orientation from Landscape to Portrait, it could take a noticeable time - maybe half a second, or more. So, I filled the routine with Stopwatch tests, and got some odd results. Create a new C# Winforms project and drop a button on, hook up this code:
C#
using System;
using System.Windows.Forms;
using System.Drawing.Printing;
using System.Diagnostics;

namespace PrintTest
    {
    public partial class Form1 : Form
        {
        public Form1()
            {
            InitializeComponent();
            TimeIt();
            }

        private static void TimeIt()
            {
            PrintDocument pd = new PrintDocument();
            Stopwatch sw = new Stopwatch();
            TimeSpan ts1 = new TimeSpan(0);
            TimeSpan ts2 = new TimeSpan(0);
            TimeSpan ts3 = new TimeSpan(0);
            sw.Start();
            int Width;
            PageSettings pageSettings = pd.DefaultPageSettings;
            ts1 = sw.Elapsed;
            PaperSize ps = pageSettings.PaperSize;
            ts2 = sw.Elapsed;
            Width = ps.Width;
            ts3 = sw.Elapsed;
            sw.Stop();
            MessageBox.Show(sw.Elapsed +
                            "\n   ts1: " + ts1 +
                            "\n   ts2: " + ts2 +
                            "\n   ts3: " + ts3);
            }

        private void button1_Click(object sender, EventArgs e)
            {
            TimeIt();
            }
        }
    }
The first time the message appears, it is slow as I expect - assemblies loading, etc. But it remains consistant after that.
I get numbers such as:
00:00:00.2231302
   ts1: 00:00:00.0000010
   ts2: 00:00:00.2231289
   ts3: 00:00:00.2231297
Which means that this line of code takes 0.2 seconds:
PaperSize ps = pageSettings.PaperSize;

And testing show that it is 0.2 seconds each and every time you use it. So if your code looks like:
Width = page.Document.DefaultPageSettings.PaperSize.Width;
Height = page.Document.DefaultPageSettings.PaperSize.Height;

That takes 0.4 seconds.
But here's the rub: It only takes time if it is a networked printer. Local, or PDF printers don't take any significant time.
Is this just me?
Real men don't use instructions. They are only the manufacturers opinion on how to put the thing together.

AnswerRe: Printing: Slow access to PaperSize Pin
Luc Pattyn13-Sep-10 2:10
sitebuilderLuc Pattyn13-Sep-10 2:10 
GeneralRe: Printing: Slow access to PaperSize Pin
OriginalGriff13-Sep-10 3:58
mveOriginalGriff13-Sep-10 3:58 
GeneralRe: Printing: Slow access to PaperSize Pin
Luc Pattyn13-Sep-10 4:10
sitebuilderLuc Pattyn13-Sep-10 4:10 
AnswerRe: Printing: Slow access to PaperSize Pin
Bernhard Hiller13-Sep-10 2:43
Bernhard Hiller13-Sep-10 2:43 
QuestionControl in front of another one at all times Pin
fdsfsa76f7sa612-Sep-10 22:19
fdsfsa76f7sa612-Sep-10 22:19 
AnswerRe: Control in front of another one at all times Pin
#realJSOP13-Sep-10 0:16
mve#realJSOP13-Sep-10 0:16 
GeneralRe: Control in front of another one at all times Pin
fdsfsa76f7sa613-Sep-10 0:48
fdsfsa76f7sa613-Sep-10 0:48 
GeneralRe: Control in front of another one at all times Pin
#realJSOP13-Sep-10 4:58
mve#realJSOP13-Sep-10 4:58 
AnswerRe: Control in front of another one at all times Pin
Luc Pattyn13-Sep-10 2:16
sitebuilderLuc Pattyn13-Sep-10 2:16 
GeneralRe: Control in front of another one at all times Pin
fdsfsa76f7sa613-Sep-10 2:39
fdsfsa76f7sa613-Sep-10 2:39 
GeneralRe: Control in front of another one at all times Pin
Luc Pattyn13-Sep-10 3:18
sitebuilderLuc Pattyn13-Sep-10 3:18 
GeneralRe: Control in front of another one at all times Pin
fdsfsa76f7sa613-Sep-10 9:20
fdsfsa76f7sa613-Sep-10 9:20 
GeneralRe: Control in front of another one at all times Pin
Luc Pattyn13-Sep-10 9:25
sitebuilderLuc Pattyn13-Sep-10 9:25 
GeneralRe: Control in front of another one at all times Pin
fdsfsa76f7sa613-Sep-10 10:56
fdsfsa76f7sa613-Sep-10 10:56 
GeneralRe: Control in front of another one at all times Pin
Luc Pattyn13-Sep-10 11:20
sitebuilderLuc Pattyn13-Sep-10 11:20 
Questionhow to list all the form name except mdi name Pin
Tridip Bhattacharjee12-Sep-10 22:10
professionalTridip Bhattacharjee12-Sep-10 22:10 
AnswerRe: how to list all the form name except mdi name Pin
Pete O'Hanlon12-Sep-10 22:15
mvePete O'Hanlon12-Sep-10 22:15 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.