|
you say good but i must do it at the end of this weekend,i did some animations in expression blend,but i stoped in the c# codes,i didnt do the card sharing
|
|
|
|
|
I'm sorry, but that's your problem. If you can't write the code for yourself, why do you think we will help you cheat? Your homework isn't a test to see if we can write code, it's to see if you can. When I used to do my homework, I did it myself - I didn't expect somebody else to do it for me.
|
|
|
|
|
Hi,
I want to cal my event handler when my custom wpf control is deleted from the designer. I want to know which event I need to override? or for which event I should attach my event handler?
Please give some input.
Regards,
Bharath
modified on Monday, December 22, 2008 2:25 AM
|
|
|
|
|
*maybe* the dispose event if you check in there that the control is being run inside the designer. I wouldn't hold my breath tho.
Christian Graus
Driven to the arms of OSX by Vista.
|
|
|
|
|
It could almost defitely be checked that way with WinForms, however WPF designers load controls in a much different way (hence Expression Blend), so I don't believe it will work.
Regards,
Thomas Stockwell
Programming today is a race between software engineers striving to build bigger and better idiot-proof programs, and the Universe trying to produce bigger and better idiots. So far, the Universe is winning.
Visit my Blog
|
|
|
|
|
|
The first event that comes to my mind is Unloaded.
Don't know about that getting raised from the designer(s) though....try it
and let us know!
Mark
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|
|
Hi,
Unloaded will be called in 2 cases in design time.
1. when window is closed
2. when we delete the control in designer.
But in both the cases the even argument values are same. this will not help me to identify which event is occurred, is it deletion or closing of the window.
So I want to know is there any event handler is called when we delete a control from desinger
Thanks and Regards,
Bharath
|
|
|
|
|
Hello,
I recently got a project and I need help how to crop an image, i got all the way where you get the image from browsing to your local disk, and it comes up on the image viewer, but now I need help on this part, I want the user to click on the button to start cropping it, after the user has made a rectangle around the part of the image he wants to crop, click on the button below the start cropping where i guess the button can say "crop it", or just change the start cropping and it turns into "crop it" which i think would be nice. But anyways, after the user clicks on the "crop it" it is now displayed on the imageviewer. How can this be done? hopefully I explained myself clearly, again, just need help on how to do a basic crop image, i looked at a couple of examples:
http://www.codeproject.com/KB/WPF/ImageCropper.aspx#HowItWorks
and
http://www.codeproject.com/KB/WPF/CropAdorner.aspx
but they are no help, they say in there examples its easier... YA right!!! there code doesnt look easy, can anyone give me an easier example and explain in jr. programming terms : )
also I guess a good example about the croping would be like windows paint, how the user presses the button to start cropping then they can save it. etc.
Thank you
|
|
|
|
|
siten0308 wrote: and explain in jr. programming terms : )
Well, some tasks are just more complex than can be explained in 'jr programming terms'. Having said that, all you need to do, is work out where the user clicked on the image and create a new image to that size, doesn't seem that hard to me ?
Christian Graus
Driven to the arms of OSX by Vista.
|
|
|
|
|
Hey chris,
Ok i guess that shed some light, but I am wondering how microsoft paint did it, how when you click on the zoom button, the rectangle box appears and when you click on the image with that rectangle box, it zooms in or enhances that part of the image, I am putting it together in my mind that it creates a new image with that size, is that right? if so, just getting it how to do it is a little hard, but correct me if I am wrong, do I figure out how to get that rectangle box to appear, then when the user clicks on that part of the imgae, which i called the image a variable called imageviewed, i just declare a new image or a new instance of the image that will replace the original with the zoom in one correct?
|
|
|
|
|
It doesn't look like Paint creates a new zoomed image, although that is
a possible approach.
It looks like Paint just stretches the "area-of-interest" designated by the rectangle
to a larger area of the window. There's no interpolation either - looks pretty pixelated.
Mark
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|
|
Sorry,
UPDATE:
Got somewhat the image to expand, but I made a button to do that, which is below, problem is, I want the user to be able to click on the button and it zooms in closer and closer and closer etc until its a spec, same with zoom out. I am doing something wrong because everytime i press the button, it stays that size and doesnt go smaller or bigger. what am i doing wrong : (
buttonzoomin
{
photoviewer1.height = +200;
photoviewer1.width = +200;
}
buttonzoomout
{
photoviewer1.height = 100;
photoviewer1.width = 100;
}
I know i am close but if someone can tell me what am i doing wrong that would be great and save me from pulling any more hair!!
Thank you
|
|
|
|
|
siten0308 wrote: photoviewer1.height = +200;
photoviewer1.width = +200;
What is photoviewer1?
Is that the actual way you coded it?
Mark
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|
|
If you are wanting to increment the size of the image, you need to put the + before the =, i.e. += . What you have said here is that you want the width and height to be 200.
|
|
|
|
|
Hey guys,
Thanks for the information, Below is the code that is finally working, i decided to throw some stuff out such as the buttons and use the slider instead. But i have one problem, when you browse for the image and it uploads to the image object, for some strange reason it looks like it is already zoomed in, i want it to capture exactly how the image looks whenopening it in paint etc. I have the code below including the XAML to see if there is something i am doing wrong, thanks again and merry christmas eve everyone : )
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 WPFcropimage
{
/// <summary>
/// Interaction logic for Window1.xaml
/// </summary>
public partial class Window1 : Window
{
public Window1()
{
InitializeComponent();
}
private void Window_Loaded(object sender, RoutedEventArgs e)
{
}
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)
{
}
}
}
XAML:
<br />
<Window x:Class="WPFcropimage.Window1" <br />
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" <br />
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" <br />
Title="Window1" Height="370" Width="591"><br />
<Grid Height="341" Width="579.942"><br />
<DockPanel Margin="23,33,181,29"><br />
<Slider x:Name="Zoom" DockPanel.Dock="Left" Value="1" Minimum="0.1" Maximum="5" Width="25" Orientation="Vertical" ValueChanged="Zoom_ValueChanged" /><br />
<ScrollViewer HorizontalScrollBarVisibility="Auto" VerticalScrollBarVisibility="Auto" Height="270" Width="356"><br />
<Image Stretch="None" Height="262" Width="349" Name="_viewedPhoto1" HorizontalAlignment="Center" Opacity="0" StretchDirection="UpOnly" VerticalAlignment="Center"><br />
<Image.LayoutTransform><br />
<ScaleTransform ScaleX="{Binding ElementName=Zoom,Path=Value}" <br />
ScaleY="{Binding ElementName=Zoom,Path=Value}"/><br />
</Image.LayoutTransform><br />
</Image><br />
</ScrollViewer><br />
</DockPanel><br />
<Button Height="38" HorizontalAlignment="Right" Margin="0,33,41,0" Name="_btnbrowse" VerticalAlignment="Top" Width="104" Click="_btnbrowse_Click">Browse for Picture</Button><br />
<Button Height="38" HorizontalAlignment="Right" Margin="0,89,41,0" Name="_btnCrop" VerticalAlignment="Top" Width="104">Crop Picture</Button><br />
<Button Height="37" HorizontalAlignment="Right" Margin="0,0,41,33.5" Name="_btnClose" VerticalAlignment="Bottom" Width="104" Click="_btnClose_Click">Close</Button><br />
<Border Margin="53,37.5,175.942,33.5" Name="_border1" BorderBrush="Black" BorderThickness="2" /><br />
</Grid><br />
indow><br />
|
|
|
|
|
<Grid x:Name = "LayoutRoot">
<Grid.BackGround>
<ImageBrush ImageSource = "Mypic.jgp"/>
</Grid.BackGround>
</Grid>
i have made a image on mspain named Mypic.jpg and added it to my porject but things are going wrong visual studio not responding when ImageSource = "Mypic.jgp"
Any solution
|
|
|
|
|
Here[^] is a pretty good blog post about the best way to include images and videos in Silverlight
Hope it helps!
|
|
|
|
|
I am using VS2008 SP1.
I have a solution with two projects.
Project A is a class library, and has a markup extension.
public class BadExtension : MarkupExtension
{
public string A { get; set; }
public string B { get; set; }
public BadExtension() { }
public BadExtension(string a) { this.A = a; }
public BadExtension(string a, string b) { this.A = a; this.B = b; }
public override object ProvideValue(IServiceProvider serviceProvider) { return A + B; }
}
Project B is a wpf project. Part of the code of a window is
<button grid.row="0" content="{l:Bad ItemA}" />
<button grid.row="1" content="{l:Bad ItemA, ItemB}" />
Now, the WPF designer refuses to load, saying that no constructor for BadExtension has 1 parameter.
However, when I run the app, it loads perfectly and both button texts display perfectly.
This is the kicker: In the BadExtension.cs file, if I switch the (string) and (string, string) constructors, the designer now complains about no constructor having 2 parameters.
p.s. Or should this be in the Visual Studio forum?
|
|
|
|
|
Looks like a bug in the VS designer.
jamie550 wrote: when I run the app, it loads perfectly and both button texts display perfectly.
It works fine in Expression Blend as well.
Mark
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|
|
I have no idea why I didn't begin using Blend a long time ago, for it is so much better in many cases. I think I'll never use the vs wpf designer again, except for editing xaml.
|
|
|
|
|
I generally use both VS and blend at the same time....I'm getting more and more used to
which stuff works better on one or the other.
It's frustrating though - I hate having to leave something out or do something different
because something doesn't work in and/or crashes the designer(s).
Mark
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|
|
BTW, have you submitted this as a bug on Microsoft Connect?
If not, I'll do it....
Cheers,
Mark
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|
|
It looks like someone has already done it here.[^]
|
|
|
|
|
Cool. Marked as fixed too.
Thank you
Mark
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|
|