|
DavidRen23 wrote: Example have a printing state that when set fires a multi trigger defined for a textbox's style that will set any white foreground black????
Could you clarify this statement please? How have you implemented your print functionality?
|
|
|
|
|
The code for printing is below however the problem cannot be solved here can it? The canvas background is not white, therefore white text appears fine, when printing the content of the canvas is printed on to white paper therefore the text is not visible.
<code>
PrintDialog printDlg = new System.Windows.Controls.PrintDialog();
DesignerCanvas designerCanvas = BloggsSDK.Windows.VisualTreeHelper.FindChild<DesignerCanvas>(this);
if (designerCanvas != null)
{
try
{
System.Printing.PrintCapabilities capabilities = printDlg.PrintQueue.GetPrintCapabilities(printDlg.PrintTicket);
//get scale of the print wrt to screen of WPF visual
double scale = Math.Min(capabilities.PageImageableArea.ExtentWidth / designerCanvas.ActualWidth, capabilities.PageImageableArea.ExtentHeight / designerCanvas.ActualHeight);
Rect bounds = VisualTreeHelper.GetDescendantBounds(designerCanvas); // not extent bounds
bounds.Scale(scale, scale);
DrawingVisual visual = new DrawingVisual();
using (DrawingContext dc = visual.RenderOpen())
{
VisualBrush vb = new VisualBrush(designerCanvas);
vb.Transform = new ScaleTransform(designerCanvas.ActualWidth / (Zoom * designerCanvas.ActualWidth), designerCanvas.ActualHeight / (Zoom * designerCanvas.ActualHeight));
dc.DrawRectangle(vb, null, new Rect(new Point(), bounds.Size));
}
printDlg.PrintVisual(visual, "Workspace printout");
}
catch (Exception ex)
{
}
</code>;
|
|
|
|
|
Sorry, you got me there, I have not used these methods for printing. Anyone else any ideas out there?
|
|
|
|
|
Hello,
I have a problem writing a unit test for a algorithm that calculates the position of some controls. The problem is that some assertions fail because setting a property does not immediately update all other Properties that depend on its value.
For example the following assertion fails (Button.Width is a DependencyProperty):
button.Width = 123;
Assert.AreEqual(123, button.ActualWidth);
This assertion fails because the layout is not immediately updated by the WPF after setting the Width Property.
My concrete scenario looks like this:
1. Set up the test with a window with some child controls
2. Simulate moving a item by the user (done with an associated AutomationPeer and a Move Method). This affects the Center property and implicitly the ActualCenter property of the item.
3. Call the Layout Algorithm that I want to test. In order to calculate the bounds of the items the Layout Algorithm uses Properties like ActualWidth, ActualHeight and ActualCenter as well as the FrameworkElement.TransformToVisual() method.
4. execute assertions that test if the Layout Algorithm works correctly.
[TestMethod()]
public void LayoutTest()
{
ItemPeer1.Move(50, 100);
LayoutAlgorithm.Layout(TheScatterView);
Assert.AreEqual(new Point(50, 100), Item1.Center);
Assert.AreEqual(new Point(200, 100), Item2.Center);
}
The assertions in step 4 fail because the layout algorithm (step 3) gets obsolete information about the center of the moved item. May be the algorithm works correct but I cannot test it.
How can I get this Unit Test working? Do I have to force WPF to update the layout? How?
A solution for the first example with the button might be sufficient to help me:
button.Width = 123;
DoSomethingSoThatActualWidthGetsUpdated();
Assert.AreEqual(123, button.ActualWidth);
|
|
|
|
|
Hi,
I am working on a silverlight project in this I wrote a WCF service to upload images to the SQL database. For some images it is working and I am able to save the images in the database but for some images I am getting an exception like
"An exception occurred during the operation, making the result invalid. Check InnerException for exception details."
All the images I am trying to upload are .png or .jpeg. I But even these are not working.
If anyone have any idea to solve this please reply me.
Thanks in advance.
|
|
|
|
|
Nekkantidivya wrote:
"An exception occurred during the operation, making the result invalid. Check InnerException for exception details."
Whats the InnerException?
|
|
|
|
|
Give your web service method signature and exception details.
|
|
|
|
|
Hi,
I am working on silver light application. In this I converted an image into byte format and saved it in the database. Then I retrieved them from the server and tried to convert it to bitmap and display it in a image control. But during convertion process from byte[] to Bitmap I am getting this exception.
"Catastrophic failure (Exception from HRESULT: 0x8000FFFF (E_UNEXPECTED))"
List<AdImages> ImgList = new List<AdImages>();
ImgList = e.Result;
int i = 0;
foreach (AdImages img in ImgList)
{
try
{
BitmapImage image = new BitmapImage();
using (MemoryStream stream = new MemoryStream(img.ImgData))
{
image.SetSource(stream); // exception raised at this line
ImgSQL.Source = image;
}
Image img2 = new Image();
img2.Source = image;
LayoutRoot.Children.Add(img2);
posImage(img2, i, ImgList.Count);
_images.Add(img2);
i++;
}
catch (Exception ee)
{
}
}
If anyone any idea to solve this please reply me.
Thanks in advance.
|
|
|
|
|
try with dispatcher..
Dispatcher.BeginInvoke(delegate()
{
List<AdImages> ImgList = new List<AdImages>();
ImgList = e.Result;
int i = 0;
foreach (AdImages img in ImgList)
{
try
{
BitmapImage image = new BitmapImage();
using (MemoryStream stream = new MemoryStream(img.ImgData))
{
image.SetSource(stream); // exception raised at this line
ImgSQL.Source = image;
}
Image img2 = new Image();
img2.Source = image;
LayoutRoot.Children.Add(img2);
posImage(img2, i, ImgList.Count);
_images.Add(img2);
i++;
}
catch (Exception ee)
{
}
}
});
|
|
|
|
|
check that the image format is supported
|
|
|
|
|
i am facing the same problem in Silverlight 4 , did you resolve the Error ?
Vuyiswa Maseko,
Spoted in Daniweb-- Sorry to rant. I hate websites. They are just wierd. They don't behave like normal code.
C#/VB.NET/ASP.NET/SQL7/2000/2005/2008
http://www.vuyiswamaseko.com
vuyiswa@its.co.za
http://www.itsabacus.co.za/itsabacus/
|
|
|
|
|
I am trying to update a sql database using silverlight 3, I have added a proxy file and have a data model added to my project. I would like to use the savechanges() method but this does not show up as an option. I do have the beginsavechanges method available but I do not understand the asynccallback.
Can someone please explain how to use the beginsavechanges method or how I can get the savechanges method in my project?
Thanks.
|
|
|
|
|
Hi
I want to know if it is possible to make an AdonerLayer look exactly like a BalloonTip, if yes, has anyone done this before and would you be so kind as to post the style that you created? It's not that important for me to get this working, so I don't want to spend too much time on styling elements.
Thanks in advance
|
|
|
|
|
You can find more styling information on balloon tips in this article[^] from my fellow WPF Disciple Philipp Sumi.
"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
|
|
|
|
|
Hi
I have a 3D model that I want to use as my SplashScreen. I can easily put the model on a form, then make the form transparent so that you see only the 3d model, but what I want to do is display this form as my SplashScreen. Do you think using a transparent form with a 3D model is the way to go or is there another, possibly better way of achieving this? If not, could you give me some hints on how to use a WPF window as a SplashScreen?
|
|
|
|
|
I'd just use the SplashScreen that was introduced in 3.5 SP1. Here's[^] more information.
"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
|
|
|
|
|
It seems that the WPF ListView expands when the content height increases, but it does not contract when the content height decreases. Here is a simple example that demonstrates the issue:
<Window x:Class="TestShrinkListView.Window1"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
Title="Window1" Height="300" Width="300">
<Border BorderThickness="2" BorderBrush="Red" VerticalAlignment="Top">
<ListView Height="Auto" VerticalAlignment="Top">
<ListViewItem>
<TextBox AcceptsReturn="True">Type some text here.</TextBox>
</ListViewItem>
</ListView>
</Border>
</Window>
If you run that and press ENTER a few times, you'll make the TextBox increase it's height, and the ListView will expand to accommodate the new height. However, if you delete a few lines from the TextBox, the ListView remains at the same enlarged height.
Is there an easy way to make the ListView decrease its height when the content shrinks (e.g., a height property), or am I going to have to get clever with some special coding?
If I have to get clever, one thing I did notice is that removing a ListViewItem from the ListView causes the ListView to contract to the proper size. I suppose I could look into how that exactly happens, but I would really prefer a cleaner solution.
If you have any ideas, please run them by me. I'd love to hear your opinion. Thanks!
Visual Studio is an excellent GUIIDE.
|
|
|
|
|
I have today off, but after a full night's sleep, my mind is less clouded than it was yesterday when I ran out of programmer-fu. The problem we ran into yesterday is now bugging me to find a resolution.
We have a web service on an internal IIS server that is not on the company domain. This server has a number of WCF web services running on it so we can test our client application.
The endpoint defined in the application's app.config uses the server's IP address in the URL. However, when we try to connect via the application to the web service, the IP is changed (internally) to the machines name.
Does anybody know why it does it that?
.45 ACP - because shooting twice is just silly ----- "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." - J. Jystad, 2001
modified on Friday, September 4, 2009 9:48 AM
|
|
|
|
|
John Simmons / outlaw programmer wrote: WCF
there's your problem.
Personally, I love the idea that Raymond spends his nights posting bad regexs to mailing lists under the pseudonym of Jane Smith. He'd be like a super hero, only more nerdy and less useful. [Trevel] | FoldWithUs! | sighist
|
|
|
|
|
Yeah, that's one of the many "difficulties" we face. We're writing the application from hell:
- WPF
- WCF
- nHibernate
- RDB
As you can see, the further you get down the list, the more likely it is that you will exclaim, "WTF!?".
.45 ACP - because shooting twice is just silly ----- "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." - J. Jystad, 2001
|
|
|
|
|
John Simmons / outlaw programmer wrote: As you can see, the further you get down the list, the more likely it is that you will exclaim, "WTF!?".
So, let me guess. At the end of the list, there should be InstallShield - that you're using to create setup?
It is a crappy thing, but it's life -^ Carlo Pallini
|
|
|
|
|
No, the install shield part has been outsourced to another country; communication with them is done using Lotus Notes.
And on the top of it, John forgot to mention the legacy VB6 library used in a part of his code that has also to be maintained.
|
|
|
|
|
Thank god nobody has suggested that yet...
.45 ACP - because shooting twice is just silly ----- "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." - J. Jystad, 2001
|
|
|
|
|
2nd from the bottom - Crystal Reports.
Never underestimate the power of human stupidity
RAH
|
|
|
|
|
That's the problem with big frameworks. You get them to work but most of the times you don't fully understand why and how they are working. This produces, in the best scenario, a slow application, in the worst an application with many subtle reliability defects.
|
|
|
|