Click here to Skip to main content
15,912,897 members
Home / Discussions / WPF
   

WPF

 
GeneralRe: How do I add more than 1 style to a TextBox? Pin
User 27100929-Dec-08 13:19
User 27100929-Dec-08 13:19 
GeneralRe: How do I add more than 1 style to a TextBox? Pin
Jammer5-Jan-09 6:14
Jammer5-Jan-09 6:14 
GeneralRe: How do I add more than 1 style to a TextBox? Pin
Pete O'Hanlon5-Jan-09 8:23
mvePete O'Hanlon5-Jan-09 8:23 
GeneralRe: How do I add more than 1 style to a TextBox? Pin
Jammer5-Jan-09 8:48
Jammer5-Jan-09 8:48 
GeneralRe: How do I add more than 1 style to a TextBox? Pin
Pete O'Hanlon5-Jan-09 8:54
mvePete O'Hanlon5-Jan-09 8:54 
GeneralRe: How do I add more than 1 style to a TextBox? Pin
Jammer5-Jan-09 9:07
Jammer5-Jan-09 9:07 
GeneralRe: How do I add more than 1 style to a TextBox? Pin
Pete O'Hanlon5-Jan-09 9:15
mvePete O'Hanlon5-Jan-09 9:15 
QuestionWPF crop image Pin
siten030828-Dec-08 16:05
siten030828-Dec-08 16:05 
Hello,

I am still having a trouble cropping with my project I am trying to create, which I have included the code and the XAML code below. For my project, i am trying to have the user click on the button "crop image" then they are given the ability to highlight the area to crop, and right click and save the crop image as jpg or bmp, so far i have looked at several examples including jim's input (thank you jim again) but still is a little confusing to me, if someone can help me out with this by completing the missing piece (or finishing the project), and/or explain that would be great. I am willing to go even as far as talking over the phone or email just to help me because i feel this is an essential thing to learn using WPF/C# image object/bitmap. If anyone can help me out with this one i would be very very grateful. So again, the code is below so you can see what i got so far, which i like because you can zoom in and out of the image object called viewerphoto1 using the slider. Anyways here is the code below:

XAML:


<Window x:Class="WPFcropimage.Window1"

xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"

xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"

Title="Window1" Height="370" Width="591">

<Grid Height="341" Width="595">

<DockPanel Margin="23,33,181,29">

<Slider x:Name="Zoom" DockPanel.Dock="Left" Value="1" Minimum="0.1" Maximum="5" Width="25" Orientation="Vertical" ValueChanged="Zoom_ValueChanged" />

<ScrollViewer HorizontalScrollBarVisibility="Auto" VerticalScrollBarVisibility="Auto" Height="270" Width="356">


<Image Stretch="Uniform" Height="262" Width="349" Name="_viewedPhoto1">

<Image.LayoutTransform>

<ScaleTransform ScaleX="{Binding ElementName=Zoom,Path=Value}" ScaleY="{Binding ElementName=Zoom,Path=Value}"/>

</Image.LayoutTransform>

</Image>

</ScrollViewer>

</DockPanel>

<Button Height="38" HorizontalAlignment="Right" Margin="0,33,41,0" Name="_btnbrowse" VerticalAlignment="Top" Width="104" Click="_btnbrowse_Click">Browse for Picture</Button>

<Button Height="38" HorizontalAlignment="Right" Margin="0,89,41,0" Name="_btnCrop" VerticalAlignment="Top" Width="104" Click="_btnCrop_Click">Crop Picture</Button>

<Button Height="37" HorizontalAlignment="Right" Margin="0,0,41,33.5" Name="_btnClose" VerticalAlignment="Bottom" Width="104" Click="_btnClose_Click">Close</Button>

<Border Margin="53,37.5,187,33.5" Name="_border1" BorderBrush="Black" BorderThickness="2">


</Border>

</Grid>

</Window>

C# 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;


using System.Drawing.Imaging;


using System.Drawing;


namespace WPFcropimage

{

/// <summary>


/// Interaction logic for Window1.xaml


/// </summary>


public partial class Window1 : Window


{

public Window1()

{

InitializeComponent();

}


private void _btnbrowse_Click(object sender, RoutedEventArgs e)

{

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;

BitmapImage bitmap = new BitmapImage();

bitmap.BeginInit();

bitmap.UriSource =

new Uri(selectedFileName);

bitmap.EndInit();

_viewedPhoto1.Source = bitmap;

}

}

private void _btnClose_Click(object sender, RoutedEventArgs e)

{

this.Close();

}

private void Zoom_ValueChanged(object sender, RoutedPropertyChangedEventArgs<double> e)

{

}

private void _btnCrop_Click(object sender, RoutedEventArgs e)

{


}

}

}
Cry | :((
AnswerRe: WPF crop image Pin
siten030829-Dec-08 17:51
siten030829-Dec-08 17:51 
QuestionWPF Sucks Pin
#realJSOP28-Dec-08 2:21
professional#realJSOP28-Dec-08 2:21 
AnswerRe: WPF Sucks Pin
ColinM12328-Dec-08 13:31
ColinM12328-Dec-08 13:31 
AnswerRe: WPF Sucks Pin
Not Active28-Dec-08 13:46
mentorNot Active28-Dec-08 13:46 
GeneralRe: WPF Sucks Pin
Mark Salsbery28-Dec-08 14:22
Mark Salsbery28-Dec-08 14:22 
QuestionFrame inside UserControl and wrong namespace Pin
Jammni+27-Dec-08 3:32
Jammni+27-Dec-08 3:32 
AnswerRe: Frame inside UserControl and wrong namespace Pin
Mark Salsbery27-Dec-08 6:48
Mark Salsbery27-Dec-08 6:48 
GeneralRe: Frame inside UserControl and wrong namespace Pin
Jammni+27-Dec-08 23:51
Jammni+27-Dec-08 23:51 
QuestionXAML and C# ! Pin
Mohammad Dayyan27-Dec-08 2:50
Mohammad Dayyan27-Dec-08 2:50 
QuestionRe: XAML and C# ! Pin
Mark Salsbery27-Dec-08 6:06
Mark Salsbery27-Dec-08 6:06 
AnswerRe: XAML and C# ! [modified] Pin
Mohammad Dayyan27-Dec-08 7:12
Mohammad Dayyan27-Dec-08 7:12 
AnswerRe: XAML and C# ! Pin
Snufflufugus27-Dec-08 8:04
Snufflufugus27-Dec-08 8:04 
GeneralRe: XAML and C# ! Pin
Mark Salsbery27-Dec-08 8:10
Mark Salsbery27-Dec-08 8:10 
AnswerRe: XAML and C# ! Pin
Snufflufugus27-Dec-08 8:23
Snufflufugus27-Dec-08 8:23 
GeneralRe: XAML and C# ! Pin
Mark Salsbery27-Dec-08 8:29
Mark Salsbery27-Dec-08 8:29 
AnswerRe: XAML and C# ! Pin
Snufflufugus27-Dec-08 8:36
Snufflufugus27-Dec-08 8:36 
QuestionUsing WPF In An Unmanaged Application Pin
xiaolin.lan24-Dec-08 21:36
xiaolin.lan24-Dec-08 21:36 

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.