Click here to Skip to main content
15,512,502 members
Home / Discussions / WPF
   

WPF

 
GeneralRe: How do I add more than 1 style to a TextBox? Pin
User 27100929-Dec-08 14:19
User 27100929-Dec-08 14:19 
GeneralRe: How do I add more than 1 style to a TextBox? Pin
Jammer5-Jan-09 7:14
Jammer5-Jan-09 7:14 
GeneralRe: How do I add more than 1 style to a TextBox? Pin
Pete O'Hanlon5-Jan-09 9:23
mvaPete O'Hanlon5-Jan-09 9:23 
GeneralRe: How do I add more than 1 style to a TextBox? Pin
Jammer5-Jan-09 9:48
Jammer5-Jan-09 9:48 
GeneralRe: How do I add more than 1 style to a TextBox? Pin
Pete O'Hanlon5-Jan-09 9:54
mvaPete O'Hanlon5-Jan-09 9:54 
GeneralRe: How do I add more than 1 style to a TextBox? Pin
Jammer5-Jan-09 10:07
Jammer5-Jan-09 10:07 
GeneralRe: How do I add more than 1 style to a TextBox? Pin
Pete O'Hanlon5-Jan-09 10:15
mvaPete O'Hanlon5-Jan-09 10:15 
QuestionWPF crop image Pin
siten030828-Dec-08 17:05
siten030828-Dec-08 17: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 18:51
siten030829-Dec-08 18:51 
QuestionWPF Sucks Pin
#realJSOP28-Dec-08 3:21
mva#realJSOP28-Dec-08 3:21 
AnswerRe: WPF Sucks Pin
ColinM12328-Dec-08 14:31
ColinM12328-Dec-08 14:31 
AnswerRe: WPF Sucks Pin
Not Active28-Dec-08 14:46
mentorNot Active28-Dec-08 14:46 
GeneralRe: WPF Sucks Pin
Mark Salsbery28-Dec-08 15:22
Mark Salsbery28-Dec-08 15:22 
QuestionFrame inside UserControl and wrong namespace Pin
Jammni+27-Dec-08 4:32
Jammni+27-Dec-08 4:32 
AnswerRe: Frame inside UserControl and wrong namespace Pin
Mark Salsbery27-Dec-08 7:48
Mark Salsbery27-Dec-08 7:48 
GeneralRe: Frame inside UserControl and wrong namespace Pin
Jammni+28-Dec-08 0:51
Jammni+28-Dec-08 0:51 
QuestionXAML and C# ! Pin
Mohammad Dayyan27-Dec-08 3:50
Mohammad Dayyan27-Dec-08 3:50 
QuestionRe: XAML and C# ! Pin
Mark Salsbery27-Dec-08 7:06
Mark Salsbery27-Dec-08 7:06 
AnswerRe: XAML and C# ! [modified] Pin
Mohammad Dayyan27-Dec-08 8:12
Mohammad Dayyan27-Dec-08 8:12 
AnswerRe: XAML and C# ! Pin
Snufflufugus27-Dec-08 9:04
Snufflufugus27-Dec-08 9:04 
GeneralRe: XAML and C# ! Pin
Mark Salsbery27-Dec-08 9:10
Mark Salsbery27-Dec-08 9:10 
AnswerRe: XAML and C# ! Pin
Snufflufugus27-Dec-08 9:23
Snufflufugus27-Dec-08 9:23 
GeneralRe: XAML and C# ! Pin
Mark Salsbery27-Dec-08 9:29
Mark Salsbery27-Dec-08 9:29 
AnswerRe: XAML and C# ! Pin
Snufflufugus27-Dec-08 9:36
Snufflufugus27-Dec-08 9:36 
QuestionUsing WPF In An Unmanaged Application Pin
xiaolin.lan24-Dec-08 22:36
xiaolin.lan24-Dec-08 22: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.