|
I have to go check this out!
Been waiting for the cool navigation stuff.
|
|
|
|
|
Make sure you don't get caught out by attempting to install the consumer version when you already have Silverlight 2 Tools installed. I ran into that. You need to install the v3 Tools and all will be OK.
Kevin
|
|
|
|
|
Thanks, I will watch for that.
|
|
|
|
|
I am glad that you pointed that out since I would have been googling for it to solve the issue. I am sure that others have had that happen too. Sad thing is that I have updated my Mac to Silverlight3 but not my PC yet
Steve Maier
|
|
|
|
|
No problem.
Kevin
|
|
|
|
|
I thought that if I didn't assign a key name to a style, that the style would be applied to all instances of the specified target type.
I put such a style into a resource dictionary that is merged in the app.xaml file, but *none* of the target controls are using the style.
If I put the style into a specific control/window xaml file, or if I give the style a key name and use it that way, it works as expected.
What am I doing wrong?
EDIT ---------------
Well, I need to move on, so I found an almost reasonably low-impact work-around. I left the style in the dictionary file, but I gave it a key name. I then created a derived style in the resources section of each applicable window/user control like so:
<Style TargetType="{x:Type TextBox}" BasedOn="{StaticResource TextBoxStyleBase}" />
This has the effect of applying to all of the textbox controls in the containing window/user control without me having to assign the style to each one.
I think what I've found is a bug in WPF, but I'm sure that Microsoft will claim that it's working as designed.
"Why don't you tie a kerosene-soaked rag around your ankles so the ants won't climb up and eat your candy ass..." - Dale Earnhardt, 1997 ----- "...the staggering layers of obscenity in your statement make it a work of art on so many levels." - Jason Jystad, 10/26/2001
modified on Friday, July 10, 2009 4:24 PM
|
|
|
|
|
I have a resource dictionary Dictionary1.xaml that looks like this:
<ResourceDictionary
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
>
<Style TargetType="Button" >
<Setter Property="Background" Value="#FFFF0000" />
</Style>
</ResourceDictionary>
I merge it into an app's resources in App.xaml like this:
<Application x:Class="WPFTester.App"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
StartupUri="Window1.xaml">
<Application.Resources>
<ResourceDictionary>
<ResourceDictionary.MergedDictionaries>
<ResourceDictionary Source="Dictionary1.xaml" />
<!-- Example importing resource dictionary from another assembly -->
<!--<ResourceDictionary Source="pack://application:,,,/WpfCustomControlLibrary;component/Dictionary1.xaml" />-->
</ResourceDictionary.MergedDictionaries>
</ResourceDictionary>
</Application.Resources>
</Application>
All the buttons in the app, unless otherwise styled, have red backgrounds.
What did you do different? Are there other styles earlier in the search order that are
overriding your app-level styles?
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|
|
|
You can use your user controls just like any other UI element.
What part are you having trouble with?
I'm not sure why your topic mentions converting XAML to PNG.....that certainly
has nothing to do with the example link you provided.
Mark
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|
|
I am thankful to your answer.
Actually, I want to create silverligt application same as mentioned in the above link which I had given. In that link When I see the view source then I find that they have used .png files.
Please advice me how to create/steps to silverligt application same as which I had mentioned.
|
|
|
|
|
There are two steps to take any part of the page and convert to a PNG.
First, get it into a bitmap. That's simple enough. Let's say your page looks like this:
<grid x:Name="mainGrid">
<component1/>
<component2>
<nestedcomponent3/>
</component2>
</grid>
To get this to a bitmap, just do an empty transform on the grid;
WriteableBitmap bitmap = new WriteableBitmap(mainGrid, new TranslateTransform());
Now you've got your bitmap (you can do an Image.source = bitmap for example and show it)
Next, getting it to a PNG - that's a little more complicated, but also has been addressed with some libraries, like this one:
http://blogs.msdn.com/jstegman/archive/2008/04/21/dynamic-image-generation-in-silverlight.aspx[^]
Best of success!
|
|
|
|
|
Hi,
I need to develop a WPF application using photoshop file.
I tried importing using blend , but it creates a Image control and loads the png image for the layers, is there any better option to use the psd file for developing WPF screens.
Thanks
|
|
|
|
|
You need a PSD to XAML converter, like this[^].
"WPF has many lovers. It's a veritable porn star!" - Josh Smith As Braveheart once said, "You can take our freedom but you'll never take our Hobnobs!" - Martin Hughes.
My blog | My articles | MoXAML PowerToys | Onyx
|
|
|
|
|
Thanks for the reply, but the link i snot working can u pls provide me the active link or if u have the exe can u pls share me.
|
|
|
|
|
I only used an old version a while back - I don't have a copy I'm afraid, and it seems to have been discontinued (which is a shame). Do you have Fireworks installed? If so, you can import your PSD into that, and use the Fireworks XAML exporter[^] from Infragistics.
"WPF has many lovers. It's a veritable porn star!" - Josh Smith As Braveheart once said, "You can take our freedom but you'll never take our Hobnobs!" - Martin Hughes.
My blog | My articles | MoXAML PowerToys | Onyx
|
|
|
|
|
We want to make it easy for the customer to adjust PNG-8 icons and controls, for a web-based app to match his own branding and color themes. Since PNG-8 uses a palette (ie, indexed colors) all I want to do is read in a PNG file, fiddle with the palette and write it out again. I can do this in any environment but Microsoft. How do we do it in Microsoft? (VS2008, .Net 3.5, WPF)
Just as a test I tried reading it a PNG-8 file, creating a screwy palette, and displaying it, but it didn't do a thing - the original image displayed perfectly:
Stream imageStreamSource = new FileStream(sPath, FileMode.Open, FileAccess.Read, FileShare.Read);
PngBitmapDecoder decoder = new PngBitmapDecoder(imageStreamSource, BitmapCreateOptions.PreservePixelFormat, BitmapCacheOption.Default);
BitmapSource OriginalImage = decoder.Frames[0];
FormatConvertedBitmap newFormatedBitmapSource = new FormatConvertedBitmap();
newFormatedBitmapSource.BeginInit();
newFormatedBitmapSource.DestinationFormat = PixelFormats.Indexed8;
newFormatedBitmapSource.Source = OriginalImage;
List<System.Windows.Media.Color> colors = new List<System.Windows.Media.Color>();
for (int i = 0; i < 127; i++)
{
colors.Add(System.Windows.Media.Colors.Red);
colors.Add(System.Windows.Media.Colors.Blue);
}
BitmapPalette myPalette = new BitmapPalette(colors);
newFormatedBitmapSource.DestinationPalette = myPalette;
newFormatedBitmapSource.EndInit();
image1.Source = newFormatedBitmapSource;
On the MSDN it says "Only Tagged Image File Format (TIFF) and Graphics Interchange Format (GIF) image formats support image palettes. However, other image types can be used to define a BitmapPalette. Attempting to define a BitmapPalette for an unsupported bitmap format does not result in an exception; the designated BitmapPalette is simply ignored. "
. . . so maybe that's what I'm seeing, but then what IS the way to manipulate PNG palettes?
Thanks in advance.
|
|
|
|
|
As far as I know, there's no support for encoding 8bpp PNG in either
the WPF imaging classes or GDI+ (System.Drawing). You'll probably need
a third-party encoder or roll your own.
Mark
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|
|
I don't mind rolling my own - I've written image-processing libraries in C++ using DirectX in the past.
But all the third-party libraries I've found are implemented OUTSIDE of .Net and just use C# wrappers for use in .Net. This makes me skeptical whether .Net is suitable for writing a graphics format class.
Does .Net provide enough fast, efficient rendering primitives to implement a good graphics library? Or does it make more sense to write a converter to/from some format .Net already knows about, like .BMP?
In other words, what it the correct "dot net" way to implement a class for a format that Microsoft doesn't support?
Or should I forget about .Net for this altogether?
|
|
|
|
|
Hi,
I have 3 different uploads from client to server, I want to show 3 different Progress bars for 3 uploads.
Finally I want to show one final progress bar showing the status of above uploads collectively.
Does that mean I have to use 4 background workers?
I am totally lost here. All the background worker examples show only one progress bar.
If anyone find an example with multiple progress bars, please send me the link.
Any clue or help will be appreciated,
|
|
|
|
|
Is this for a WPF app?
"WPF has many lovers. It's a veritable porn star!" - Josh Smith As Braveheart once said, "You can take our freedom but you'll never take our Hobnobs!" - Martin Hughes.
My blog | My articles | MoXAML PowerToys | Onyx
|
|
|
|
|
Welllll, setup three BackgroundWorkers - one for each progressbar.
"Why don't you tie a kerosene-soaked rag around your ankles so the ants won't climb up and eat your candy ass..." - Dale Earnhardt, 1997 ----- "...the staggering layers of obscenity in your statement make it a work of art on so many levels." - Jason Jystad, 10/26/2001
|
|
|
|
|
Thanks for your quick replies,
I am posting my code. This code is in code behind of WPF window. UI has four ProgressBars which I have to update.
public static List<photopost> allPhotosToUpload = null;
private BackgroundWorker serviceValuesWorker = null;
private BackgroundWorker signatureWorker = null;
private BackgroundWorker photoWorker = null;
private BackgroundWorker mainWorker = null;
public UploadProgressWithfourBars()
{
InitializeComponent();
UploadServiceValuesPhotosAndSignature();
}
private void UploadServiceValuesPhotosAndSignature()
{
bool finalSuccessMessage = false;
var context = new VersentiaMobileDataContext();
var serviceInstances = ServiceInstancesDataAccess.GetAll(context);
bool[] allResponses;
List<signature> signatures = null;
foreach (var serviceInstance in serviceInstances)
{
//Get All Signatures
var serviceValues = serviceInstance.ServiceValues.Where(sv => sv.ServiceProperty.Datatype == "Signature").Select(sv =>sv);
signatures = serviceValues.Select(sv => sv.Signature).Distinct().ToList();
//Get All Photos
allPhotosToUpload = PostPhotoCollection.GetPhotos(serviceInstance, context);
int count = allPhotosToUpload.Count + signatures.Count + 1;
allResponses = new bool[count];
int i = 0;
//Upload serviceValues
serviceValuesWorker = new BackgroundWorker();
serviceValuesWorker.WorkerReportsProgress = true;
serviceValuesWorker.WorkerSupportsCancellation = true;
serviceValuesWorker.DoWork += delegate(object s, DoWorkEventArgs args)
{
serviceValuesWorker.ReportProgress(10);
if (serviceValuesWorker.CancellationPending)
{
args.Cancel = true;
return;
}
serviceValuesWorker.ReportProgress(50);
var serializableValues = serviceInstance.ServiceValues.AsSerializable();
var serialisedValues = new Dictionary<string, object[]=""> { { "ValuesInfo", serializableValues } }.Serialize();
string responseFromServer = ServiceRequest.GetResponse("UpdateServiceInstanceMobile", "ServiceInstances", serialisedValues, serviceInstance.ServiceInstanceID.ToString());
var response = responseFromServer.Deserialize<<dictionary>string, object>>();
bool successServiceValues = (bool)response["success"];
if (successServiceValues)
{
serviceValuesWorker.ReportProgress(100);
}
args.Result = successServiceValues;
};
serviceValuesWorker.ProgressChanged += delegate(object s, ProgressChangedEventArgs args)
{
serviceValuesProgressBar.Value = args.ProgressPercentage;
};
serviceValuesWorker.RunWorkerCompleted += delegate(object s, RunWorkerCompletedEventArgs args)
{
try
{
allResponses[i++] = (bool) args.Result;
}
catch (Exception)
{
}
};
serviceValuesWorker.RunWorkerAsync();
//Upload Signatures
signatureWorker = new BackgroundWorker();
signatureWorker.WorkerReportsProgress = true;
signatureWorker.WorkerSupportsCancellation = true;
signatureWorker.DoWork += delegate(object s, DoWorkEventArgs args)
{
signatureWorker.ReportProgress(10);
if (signatureWorker.CancellationPending)
{
args.Cancel = true;
return;
}
signatureWorker.ReportProgress(50);
bool[] responseArray = new bool[signatures.Count];
int j = 0;
foreach (var signature in signatures)
{
string serviceValuesString = "";
var serviceValuesIDs = serviceValues.Where(sv => sv.SignatureID == signature.SignatureID).Select(sv => sv.ServiceValueID).ToList();
foreach (var ID in serviceValuesIDs)
{
if (ID != serviceValuesIDs.Last())
{
serviceValuesString = serviceValuesString + ID + ",";
}
else
{
serviceValuesString = serviceValuesString + ID;
}
string signaturePath = signature.SignaturePath;
byte[] signatureByteArray = SignatureFileConversion.SignatureFileToByteArray(signaturePath);
string signatureToUpload = signatureByteArray.Serialize();
var signatureResponseFromServer = ServiceRequest.GetSignatureResponse("AddSignature", "ServiceInstances", serviceValuesString, serviceInstance.ServiceInstanceID.ToString(), signatureToUpload);
var signatureResponse = signatureResponseFromServer.Deserialize<<dictionary>string, object>>();
responseArray[j++] = (bool)signatureResponse["success"];
}
}
if(!responseArray.Contains(false))
{
signatureWorker.ReportProgress(100);
}
args.Result = responseArray;
};
signatureWorker.ProgressChanged += delegate(object s, ProgressChangedEventArgs args)
{
signatureProgressBar.Value = args.ProgressPercentage;
};
signatureWorker.RunWorkerCompleted += delegate(object s, RunWorkerCompletedEventArgs args)
{
try
{
bool[] signatureResponses = (bool[]) args.Result;
foreach (var response in signatureResponses)
{
allResponses[i++] = response;
}
}
catch (Exception)
{
}
};
signatureWorker.RunWorkerAsync();
//Upload Photos
photoWorker = new BackgroundWorker();
photoWorker.WorkerReportsProgress = true;
photoWorker.WorkerSupportsCancellation = true;
photoWorker.DoWork += delegate(object s, DoWorkEventArgs args)
{
photoWorker.ReportProgress(10);
if (photoWorker.CancellationPending)
{
args.Cancel = true;
return;
}
photoWorker.ReportProgress(50);
bool[] photoResponseArray = new bool[allPhotosToUpload.Count];
int k = 0;
foreach (var photo in allPhotosToUpload)
{
photoResponseArray[k++] = PostPhotoCollection.SendPhoto(photo);
}
if(!photoResponseArray.Contains(false))
{
photoWorker.ReportProgress(100);
}
args.Result = photoResponseArray;
};
photoWorker.ProgressChanged += delegate(object s, ProgressChangedEventArgs args)
{
serviceValuesProgressBar.Value = args.ProgressPercentage;
};
photoWorker.RunWorkerCompleted += delegate(object s, RunWorkerCompletedEventArgs args)
{
try
{
bool[] photoResponses = (bool[]) args.Result;
foreach (var response in photoResponses)
{
allResponses[i++] = response;
}
}
catch (Exception)
{
}
};
photoWorker.RunWorkerAsync();
mainWorker = new BackgroundWorker();
mainWorker.WorkerReportsProgress = true;
mainWorker.WorkerSupportsCancellation = true;
mainWorker.DoWork += delegate(object s, DoWorkEventArgs args)
{
mainWorker.ReportProgress(10);
if (mainWorker.CancellationPending)
{
args.Cancel = true;
return;
}
mainWorker.ReportProgress(50);
if (!allResponses.Contains(false))
{
bool IsDone = true;
string finalResponseFromServer = ServiceRequest.GetFinalResponse("SubmitChanges", "ServiceInstances", IsDone.ToString(), serviceInstance.ServiceInstanceID.ToString(), allPhotosToUpload.Count.ToString(), signatures.Count().ToString());
var finalResponse = finalResponseFromServer.Deserialize<<dictionary>string, object>();
finalSuccessMessage = (bool)finalResponse["success"];
args.Result = finalSuccessMessage;
if (finalSuccessMessage)
{
mainWorker.ReportProgress(100);
}
}
};
mainWorker.ProgressChanged += delegate(object s, ProgressChangedEventArgs args)
{
mainProgressBar.Value = args.ProgressPercentage;
};
mainWorker.RunWorkerCompleted += delegate(object s, RunWorkerCompletedEventArgs args)
{
try
{
if((bool) args.Result)
{
btnClose.IsEnabled = true;
}
}
catch (Exception)
{
}
};
mainWorker.RunWorkerAsync();
btnCancel.Click += ((o, args) =>
{
serviceValuesWorker.CancelAsync();
serviceValuesProgressBar.Value = 0;
signatureWorker.CancelAsync();
signatureProgressBar.Value = 0;
photoWorker.CancelAsync();
photoProgressBar.Value = 0;
mainWorker.CancelAsync();
mainProgressBar.Value = 0;
bool IsDone = false;
string finalResponseFromServer = ServiceRequest.GetFinalResponse("SubmitChanges", "ServiceInstances", IsDone.ToString(), serviceInstance.ServiceInstanceID.ToString(), allPhotosToUpload.Count.ToString(), signatures.Count().ToString());
var finalResponse = finalResponseFromServer.Deserialize<dictionary<string, object="">>();
finalSuccessMessage = (bool)finalResponse["success"];
if (!finalSuccessMessage)
{
lblUploadCancelled.Visibility = Visibility.Visible;
btnClose.IsEnabled = true;
btnCancel.IsEnabled = false;
}
});
}
}
private void Click_Close(object sender, RoutedEventArgs e)
{
this.Close();
}
I am getting Accessviolation Exception. "allResponses" array is not modifying at all. The same procedure if I do without threads working fine, but no progress indication to the user.
Please help.
|
|
|
|
|
Nobody's going to help you until a) your code is properly formatted, and b) you can whittle it down to something that doesn't require more than one scrolled page.
Lastly, this is the WPF/WCF/WWF forum. How is your question related to any of these topics?
"Why don't you tie a kerosene-soaked rag around your ankles so the ants won't climb up and eat your candy ass..." - Dale Earnhardt, 1997 ----- "...the staggering layers of obscenity in your statement make it a work of art on so many levels." - Jason Jystad, 10/26/2001
|
|
|
|
|
vsaratkar wrote: I am getting Accessviolation Exception. "allResponses" array
I'm not going to put much effort into reading that big chunk of unformatted code,
but to start with, it looks like you have multiple threads accessing the "allResponses"
array and the "i" variable with no synchronization.
As for the exception - this should be easy to debug. Either the array is null or you're
trying to write past the end (i.e. the array is not large enough)...
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|
|
I am getting a eroor from my code, i cant trace the issue/bug . here is my code bit...
private void DoArrange()<br />
{<br />
Point center = new Point((this.Width - ItemSize) / 2, (this.Height - ItemSize) / 2);<br />
double radiusX = center.X;<br />
double radiusY = center.Y;<br />
double scale = ScalePerspective;<br />
<br />
for (int i = 0; i < Children.Count; i++)<br />
{<br />
UIElement item = Children[i];<br />
double radians = (double)item.GetValue(CarouselPanel.AngleProperty);<br />
<br />
Point p = new Point(<br />
(Math.Cos(radians) * radiusX) + center.X,<br />
(Math.Sin(radians) * radiusY) + center.Y<br />
);<br />
<br />
if (item.RenderTransform == null)<br />
{<br />
item.RenderTransform = new MatrixTransform();<br />
item.RenderTransformOrigin = new Point(0.5, 0.5);<br />
}<br />
MatrixTransform mt = item.RenderTransform as MatrixTransform;<br />
double scaleMinusRounding = p.Y / (center.Y + radiusY);<br />
double scaleX = Math.Min(scaleMinusRounding + scale, 1.0);<br />
double scaleY = Math.Min(scaleMinusRounding + scale, 1.0);<br />
Matrix mx = new Matrix(scaleX, 0.0, 0.0, scaleY, 0.0, 0.0);<br />
<br />
mt.Matrix = mx;<br />
item.RenderTransform = mt;<br />
<br />
int zIndex = (int)((p.Y / base.Height) * 50);<br />
item.SetValue(Canvas.ZIndexProperty, zIndex);<br />
Rect r = new Rect(p.X, p.Y, ItemSize, ItemSize);<br />
item.Arrange(r);<br />
}<br />
}
What could be the issue i am using a WPF(win) application.
modified on Thursday, July 9, 2009 9:48 AM
|
|
|
|
|