0

I have an application that run on different screens. I have prepared forms in a4 size in my window. when i run on my pc there are no problems as well as on a 42 inch TV. I tried installing the application on another 22-inch pc and screen cuts my window both visually and in print. it follows my xaml and c # code for printing

<StackPanel Background="White" Height="29.7cm" Width="19.5cm" >
 <StackPanel Name="StackFoglioA4Pag1" HorizontalAlignment="Center" Margin="20" Background="White">
                            <!--<TextBox HorizontalContentAlignment="Center" BorderBrush="Black" Text="ciane S.p.A." VerticalContentAlignment="Center" IsReadOnly="True" FontWeight="Bold" FontFamily="Times New Roman" FontSize="14"></TextBox>
                            <TextBox Padding="2" HorizontalContentAlignment="Center" BorderBrush="Black" BorderThickness="1,0,1,1"  Text="Main "-  VerticalContentAlignment="Center" IsReadOnly="True" FontFamily="Times New Roman" FontSize="9"></TextBox>
                            <TextBox Padding="2" HorizontalContentAlignment="Center" BorderThickness="1,0,1,1"  BorderBrush="Black" Text="textggggggg  " VerticalContentAlignment="Center" IsReadOnly="True" FontFamily="Times New Roman" FontSize="9"></TextBox>-->
                            <DockPanel Margin="0,5,0,0">
                     <!--etc etc   

public static void StampaStackPanel(StackPanel StackPanel,string message)
    {
        PrintDialog stampa = new PrintDialog();
        if (stampa.ShowDialog() != true) return;

        stampa.PrintVisual(StackPanel,message);
    }

edit:

in my pc i see the image full while in the other monitor (bigger) i see it cut

enter image description here

update: enter image description here

Disaji
  • 89
  • 2
  • 11
  • Its a bit unclear, what are you trying to do? Open the print dialog in another windows screen?? –  Sep 24 '17 at 10:08
  • sorry. I have a button that just prints the stack panel(a4 size) on a4 sheet. the problem is that on my pc there are no problems. while in another pc it cuts the stackpanel on both the screen and the print – Disaji Sep 24 '17 at 10:37
  • Check out this answer it may help: https://stackoverflow.com/questions/6606750/show-dialog-box-at-center-of-its-parent –  Sep 24 '17 at 10:39
  • thanks but I don't understand how the link can help me. i forget to say that the window that is the parent of stackpanel(a4 size) is in maximized – Disaji Sep 24 '17 at 10:57
  • 1
    If you want to reproduce the issue on your dev machine, then change the DPI settings of your system, instead of the resolution. – Maciek Świszczowski Sep 25 '17 at 09:26
  • thanks now I understand. in my machine however I can set from 100 to 500. to play the screen where I have the problem I should set to about 80. how do you do it? I updated my question with a screenshot – Disaji Sep 25 '17 at 11:07

2 Answers2

0

Try

stampa.Location = new Point(//WhereYouWanX, //WhereYouWantY);
0

Windows.Forms.Screen

var view= new YourView();
var screens = System.Windows.Forms.Screen.AllScreens[1].WorkingArea;
view.Location = new Point(rectMonitor.Left, rectMonitor.Top);
  • maybe the fault is mine which I did not explain well. if I change my screen resolution in my pc, my application runs ok for each resolution. however when I install it on another computer it gives me a different view from the one that gave me on my pc with the same resolution – Disaji Sep 24 '17 at 16:42
  • this is sample, and you can use 'foreach' on 'System.Windows.Forms.Screen.AllScreens' – Mohammad Bigdeli Sep 25 '17 at 11:42