Click here to Skip to main content
15,891,529 members
Home / Discussions / WPF
   

WPF

 
GeneralRe: Cursor Position ? Pin
Mohammad Dayyan11-Dec-08 4:42
Mohammad Dayyan11-Dec-08 4:42 
GeneralRe: Cursor Position ? Pin
Mark Salsbery11-Dec-08 11:03
Mark Salsbery11-Dec-08 11:03 
AnswerRe: Cursor Position ? Pin
teejayem11-Dec-08 9:35
teejayem11-Dec-08 9:35 
GeneralRe: Cursor Position ? Pin
Mohammad Dayyan11-Dec-08 23:49
Mohammad Dayyan11-Dec-08 23:49 
QuestionWindow Location in WPF ! Pin
Mohammad Dayyan10-Dec-08 11:00
Mohammad Dayyan10-Dec-08 11:00 
AnswerRe: Window Location in WPF ! Pin
Jammer11-Dec-08 3:43
Jammer11-Dec-08 3:43 
AnswerRe: Window Location in WPF ! Pin
Mark Salsbery11-Dec-08 5:58
Mark Salsbery11-Dec-08 5:58 
QuestionWPF and printing Pin
siten030810-Dec-08 7:50
siten030810-Dec-08 7:50 
Hello,

So far i have posted my little problem on several forums, some help but resolution to my problem. On with the question: I have a program, i want the user to be able to print any size from the print dialog form under preferences when they choose to select 8x11 etc and it will print the picture that you see on the image viewer. So far my printing is not working, it only prints the size of the imageviewer which is small but i want the user to select whatever size they want and whatever or how many copies they want it. I have the code below including the XAML, please helpa

Thank you in advance:

code:

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;
using System.Windows.Forms;

namespace ImageViewer
{
/// <summary>
/// Interaction logic for Window1.xaml
/// </summary>
public partial class Window1 : Window
{
public Window1()
{
InitializeComponent();
}

private void BrowseButton_Click(object sender, RoutedEventArgs e)
{
try
{
OpenFileDialog dlg = new OpenFileDialog();
dlg.InitialDirectory = "c:\\";
dlg.Filter = "Image files (*.jpg)|*.jpg|(*.bmp)|*.bmp|All Files (*.*)|*.*";
dlg.RestoreDirectory = true;

if (dlg.ShowDialog() == System.Windows.Forms.DialogResult.OK)
{
string selectedFileName = dlg.FileName;
FileNameLabel.Content = selectedFileName;
BitmapImage bitmap = new BitmapImage();
bitmap.BeginInit();
bitmap.UriSource = new Uri(selectedFileName);
bitmap.EndInit();
ImageViewer1.Source = new BitmapImage(new Uri(selectedFileName, UriKind.Absolute));

}
}
catch (Exception)
{

}
}

private void btnclose_Click(object sender, RoutedEventArgs e)
{
this.Close();
}

System.Windows.Controls.PrintDialog dlg = new System.Windows.Controls.PrintDialog();

private void btnprint_Click(object sender, RoutedEventArgs e)
{
if ((bool)dlg.ShowDialog().GetValueOrDefault())
{
Size pageSize = new Size();

// sizing of the element.

ImageViewer1.Measure(pageSize);

dlg.PrintVisual(ImageViewer1, Title);

}
}
}
}

XAML:

<Window x:Class="ImageViewer.Window1"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
Title="Window1" Height="351" Width="486">
<Grid Height="310" Width="438">
<Button Margin="0,12,13,0" Name="BrowseButton" Click="BrowseButton_Click" HorizontalAlignment="Right" Width="102" Height="43" VerticalAlignment="Top">Browse</Button>
<Label Margin="86,0,13,19" Height="25" Name="FileNameLabel" VerticalAlignment="Bottom" />
<Label Margin="14.5,0,0,19" Height="23" Name="Label1" HorizontalAlignment="Left" VerticalAlignment="Bottom" Width="70.15">Current File:</Label>
<Image Margin="14.5,12,130,63" Name="ImageViewer1" Stretch="Fill" />
<Button HorizontalAlignment="Right" Margin="0,149,13,118" Name="btnprint" Width="102" Click="btnprint_Click">Print</Button>
<Button Height="41" HorizontalAlignment="Right" Margin="0,0,13,63" Name="btnclose" VerticalAlignment="Bottom" Width="102" Click="btnclose_Click">Close</Button>
<RadioButton HorizontalAlignment="Right" Margin="0,86,-5,0" Name="rdb4by6" Width="120" Height="15" VerticalAlignment="Top">4x6</RadioButton>
<RadioButton Height="16" HorizontalAlignment="Right" Margin="0,105,-5,0" Name="rdb5b7" VerticalAlignment="Top" Width="120">5x7</RadioButton>
<RadioButton Height="16" HorizontalAlignment="Right" Margin="0,126,-5,0" Name="rdb8x11" VerticalAlignment="Top" Width="120">8x11</RadioButton>
<Label Height="28" HorizontalAlignment="Right" Margin="0,54,-5,0" Name="label2" VerticalAlignment="Top" Width="120">Select Print Size</Label>
</Grid>
</Window>
Cry | :((
Questionregarding silver basic Pin
cpquest10-Dec-08 1:10
cpquest10-Dec-08 1:10 
AnswerRe: regarding silver basic Pin
Kevin McFarlane18-Dec-08 12:16
Kevin McFarlane18-Dec-08 12:16 
GeneralLate binding Pin
Mycroft Holmes9-Dec-08 21:12
professionalMycroft Holmes9-Dec-08 21:12 
GeneralRe: Late binding Pin
Pete O'Hanlon9-Dec-08 22:32
mvePete O'Hanlon9-Dec-08 22:32 
GeneralRe: Late binding Pin
Mycroft Holmes9-Dec-08 23:20
professionalMycroft Holmes9-Dec-08 23:20 
GeneralRe: Late binding Pin
Jammer10-Dec-08 0:23
Jammer10-Dec-08 0:23 
GeneralRe: Late binding Pin
Mycroft Holmes10-Dec-08 12:12
professionalMycroft Holmes10-Dec-08 12:12 
GeneralRe: Late binding Pin
Jammer12-Dec-08 8:00
Jammer12-Dec-08 8:00 
GeneralRe: Late binding Pin
Mycroft Holmes10-Dec-08 12:18
professionalMycroft Holmes10-Dec-08 12:18 
GeneralRe: Late binding Pin
Pete O'Hanlon11-Dec-08 2:26
mvePete O'Hanlon11-Dec-08 2:26 
GeneralRe: Late binding Pin
Mycroft Holmes11-Dec-08 3:59
professionalMycroft Holmes11-Dec-08 3:59 
GeneralRe: Late binding Pin
Jammer12-Dec-08 8:02
Jammer12-Dec-08 8:02 
Questioncontrol name in datatemplate Pin
sydney1239-Dec-08 19:23
sydney1239-Dec-08 19:23 
AnswerRe: control name in datatemplate Pin
Pete O'Hanlon9-Dec-08 22:34
mvePete O'Hanlon9-Dec-08 22:34 
QuestionListView Grouping W/Expander Help Pin
aaj239-Dec-08 8:51
aaj239-Dec-08 8:51 
AnswerRe: ListView Grouping W/Expander Help Pin
Insincere Dave9-Dec-08 13:44
Insincere Dave9-Dec-08 13:44 
GeneralRe: ListView Grouping W/Expander Help Pin
aaj239-Dec-08 15:59
aaj239-Dec-08 15:59 

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.