|
|
Nice! I'll blog it up when I get home ...
|
|
|
|
|
Karl - if we have an add in to add to this, could we send it to you for inclusion (assuming the code meets your standards)?
|
|
|
|
|
Pete,
If it's VB.NET no problem.
If it's C# and not a huge amount of code, OK, I'll translate.
I'm working though an issue right now, should have it resolved soon.
modified 27-Feb-21 21:01pm.
|
|
|
|
|
Thanks mate. Tell you what, I'm putting together a C# addin which I'll let you have a look at - any bits that you like, I'll convert over to VB.NET, it'll be good practice for me. The first toy takes a property and converts it into a notifiable property, so it converts:
public string MyProperty { get; set; } into
private string _myProperty;
public string MyProperty
{
get
{
return _myProperty;
}
set
{
if (_myProperty != value)
{
PropertyChanged("MyProperty");
_myProperty = value;
}
}
}
|
|
|
|
|
Pete,
I already have writen a very comprehensive add-in that does all this and much more.
After Ocean, I'll write up an article on it.
XAML Power Toys will be released again tonight. I corrected all the file locking issues and wrote a way out there designer and added some very cool stuff.
I've been off-line and will be the rest of the day.
Cheers,
Karl
modified 27-Feb-21 21:01pm.
|
|
|
|
|
Cool - looking forward to seeing it. You inspired me to write some "cool stuff" of my own as an add in. I've written one to add the property notification (as shown) and I'm busy writing one to add command bindings for the common commands automatically. I'm thinking that I don't want to corrupt yours, so I'll launch a separate power toy.
It's as much a learning exercise for me as it is about coding up something useful. The things I'm knocking together are intended to get around the little irritants I have when coding WPF apps. Anyhoo, I'll let you know when I'm ready to release it and I hope you'll like it.
|
|
|
|
|
Cool, I'll have to check it out
"The clue train passed his station without stopping." - John Simmons / outlaw programmer
"Real programmers just throw a bunch of 1s and 0s at the computer to see what sticks" - Pete O'Hanlon
"Not only do you continue to babble nonsense, you can't even correctly remember the nonsense you babbled just minutes ago." - Rob Graham
|
|
|
|
|
|
Sorry if it seems I'm treading on Karl's toes here, but he's taken the code down to fix a problem and add new features, but due to an internet connectivity issue at the moment, he's been unable to upload the new version of code. We're assured that all will be sorted over the next couple of days.
|
|
|
|
|
Also if Karl,
perhaps, could allow us to download his webcast in a zip, as bandwith is not cheap where I'm from.
I would be gratefull.
Thanks
Sk8tZ
|
|
|
|
|
That's one to post to Karl, possibly on his blog as he may not read a reply to an answer I gave.
|
|
|
|
|
|
Hi,
I'm building a simple application in which I want to render a "thumbnail" of the clipboard data if that data is an Image. I've managed to do everything right (as far as I know) but the Image control of the Window doesn't render correctly the contents of the BitmapSource.
Here is the XAML of the Window:
<Window x:Class="ClipboardTest.Window1"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
Title="Window1" SizeToContent="WidthAndHeight">
<StackPanel Margin="10">
<Image MaxHeight="200" MaxWidth="300" x:Name="ImagePreview" Margin="10"></Image>
<Button x:Name="ButtonCapture" Click="ButtonCapture_Click" MinWidth="75" Margin="10">Capture Clipboard Data</Button>
</StackPanel>
</Window>
And here is the code of the code behind file:
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;
namespace ClipboardTest
{
/// <summary>
/// Interaction logic for Window1.xaml
/// </summary>
public partial class Window1 : Window
{
public Window1()
{
InitializeComponent();
}
private void ButtonCapture_Click(object sender, RoutedEventArgs e)
{
if (Clipboard.ContainsImage())
{
BitmapSource source = Clipboard.GetImage();
ImagePreview.Source = source;
}
}
}
}
To test it just run the program, then press Print Screen (or copy just any image from paint) and then click on the button. As you'll see, the image gets actually rendered because the Image control resizes accordingly (note the maximum values so if you Print Screen it will just resize to 300x200). BUT the actual contents of the image are not rendered, the image is simply blank. I don't know what I'm doing wrong. I've noticed that altough the documentation states that Clipboard.GetImage(); returns a BitmapSource, the actual object I get when debugging is an InteropBitmap. I don't know if this has anything to do with it.
Any ideas on how to get the source of the ClipboardData (and actually any bitmapsource/interopbitmap) get rendered well on a default WPF Image control?
Many thanks!
|
|
|
|
|
Its a bug, some workarounds are using WindowsForms Clipboard class or PInvoke.
I encountered this a while back and seem to recall that copying the data to a new bitmap fixed it. I couldn't seem to find all of the posts that were helpful then, when searching google your question was near the top of the results .
I found that the problem was with the alpha values not being set try this method which ignores them.
if (Clipboard.ContainsImage())
{
BitmapSource source = Clipboard.GetImage();
FormatConvertedBitmap fb = new FormatConvertedBitmap(source, PixelFormats.Bgr32, null, 0);
ImagePreview.Source = fb;
}
Another method is at http://shevaspace.spaces.live.com/blog/cns!FD9A0F1F8DD06954!441.entry
|
|
|
|
|
Hi,
Thanks for the reply, it worked. Now I'm having another problem, related to an Image control and it's caching.
I have this image from the clipboard, tha can be very large, and want to show it in a WPF Image control. The Image size is fixed, so the image is thumbnailed as expected, but the Image control keeps the memory for the entire image instead of the thumbnailed one. I read that you must set the property DecodePixelHeight (or width) of the BitmapImage used as the source of the Image control.
The problem is that I'm using the FormatConvertedBitmap as the source, and it doesn't have those properties.
Any clue on how to build a BitmapImage object using the FormatConvertedBitmap as the source? All the examples I've seen use the Uri of the image as the source.
Thanks!
|
|
|
|
|
Hi Guys,
Im using Xaml textbox,now i want to validate the textbox,like accepting only numbers or accepting only alphabets,i have referred some some site theres no clear solution.if anyone knows help me..
Regrds
Kanna..
|
|
|
|
|
Do you want to validate it, or do you want to prevent the user from being able to enter invalid information? If it's prevention, you can use the PreviewKeyDown event to prevent unwanted keypresses (by setting the Handled to true).
|
|
|
|
|
I followed the msdn d3dimage walkthrough on
msdn[^].
I used the August 2008 DirectX SDK, .NET 3.5 SP1, with Vista64SP1.
I made x86 and x64 binaries.
I set it up to have transparency (I need that).
It runs fine, with about 3% CPU on WinXP (x86). It's SP2, so I have WindowsXP-KB937106-x86-ENU installed to get the transparency to work.
On Vista however (what theoratically should run faster), I get 50% CPU, on both x64 and x86 binaries.
Bug in the platform?
One difference, is that the example uses Direct3DCreate9Ex on Vista and Direct3DCreate9 on XP (since Direct3DCreate9Ex should give better performance). Changing the code to always use Direct3DCreate9 didn't improve a thing.
Any help appreciated, Dave
The project (94kB zip, I left the binaries but cleaned up the rest) is over here: http://rapidshare.de/files/40349833/D3DWpfSprite.zip.html[^]
modified on Friday, August 29, 2008 1:54 PM
|
|
|
|
|
Hi All,
Couple of things really ... obfuscation for WPF, this has been really problematic since its been largely impossible to do this on a XAML application without bascially breaking it. An application called SmartAssembly has made some headway but I've just had an email from the Xenocode folks to say that Postbuild2008 now FULLY support Obfuscating XAML/.NET3.5 applications !!!!
http://www.xenocode.com/Products/Postbuild/[^]
Also, I've just found this on the Microsoft site that is making for some really interesting reading ...
Composite Application Guidance for WPF
http://msdn.microsoft.com/en-us/library/cc707819.aspx[^]
We're adopting this type of development for our WPF applications at the moment and its proving extremely effective.
|
|
|
|
|
|
Isn't it! Even though obfuscation is little more than a hurdle in the way of someone that wants the code real bad, its pretty much a requirement from manager types in terms of protecting IP.
|
|
|
|
|
Hi,
I will get a Set of results in a listbox. How can i enable a item by right clicking on it.. I would like to show a menu when user right clicks on the listbox item.
Santhapur
|
|
|
|
|
You can create your Context Menu in code or XAML and simply add it the ListBoxItem.ContextMenu property for each item.
Another way would be to add a Context Menu for the ListBox and perform hit testing for which ListBoxItem you are over.
modified 27-Feb-21 21:01pm.
|
|
|
|
|
IF uou have any code snippet that would be helpful for me...
|
|
|
|