|
Hi all.
Can we use XNA physic engines in WPF (2D) ? Is it possible ?
Thanks.
|
|
|
|
|
I almost never write strongly worded posts, but I feel this one is warranted. So I'll go out on a limb and say:
VS2008's ability to reliably update service references in a Silverlight class library project is little more than a crap shoot. The feature is hopelessly broken and has all the appeal of a steaming pile of horse manure. It's a waste of my time to have to exit Visual Studio, reboot, pray or do all of the above in the hope that the reference will actually be imported correctly this time.
Microsoft, if you want developers to seriously consider using Silverlight, I urge you to release a hotfix that addesses this problem. It would be faster to rearchitect our enterprise application's front end in Flash than continue wasting valuable time trying (in vain) to get this to work.
/ravi
Update: Bug 439157[^] filed.
modified on Saturday, May 2, 2009 5:01 PM
|
|
|
|
|
Thanks for filing a bug on Connect!!
I was going to recommend you do that
Also, this is a Visual Studio issue, not a Silverlight issue, so this was
the wrong board to post on
Cheers,
Mark
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|
|
Mark Salsbery wrote: Also, this is a Visual Studio issue, not a Silverlight issue,
OK, but it only affects adding a service reference to a Silverlight assembly.
/ravi
|
|
|
|
|
FYI, I've managed to repro the badness and have tracked down what I believe is the offending situation. I'll update the bug report when I have cycles.
/ravi
|
|
|
|
|
Can anyone tell me how to fill a TreeView with items from an Access database in WPF? I've already added my data source; Data >> Add New Data Source in Visual Studio 2008. So my dataset and table adapters are all set up already, just need to get the data into the TreeView. Here's an example of what my tree structure looks like:
>Parts
>Tables
>Top
>Leg
>Chairs
>Seat
>Leg
>Backrest
Table Top, Leg, etc are stored in a 'Parts' table, from which I want to read data.
|
|
|
|
|
This[^] should help.
"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
|
|
|
|
|
How do I create a UserControl which can host other controls? For example, say I wanted to create a UserControl which showed an orange border but could have other controls hosted inside it so:
<my:OrangeBorderThing>
<TextBlock>hello</TextBlock>
</my:OrangeBorderThing>
would show the word "hello" surrounded by an orange border - currentlly I just get the word hello - I have spent a couple of hours reading the usual conflicting things google brings up, messed about with ControlTemplate and ContentPresenter etc but have gotten nowhere.
|
|
|
|
|
<Window x:Class="Wpf2.Window1"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:local="clr-namespace:Wpf2"
Title="Window1" Height="300" Width="300">
<Grid>
<local:UserControl1 />
</Grid>
</Window>
<UserControl x:Class="Wpf2.UserControl1"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
Height="100" Width="200">
<Grid>
<Border BorderBrush="red" BorderThickness="2">
<TextBlock Text="Hello" />
</Border>
</Grid>
</UserControl>
It woks for me.
Best regards
Agha Khan
|
|
|
|
|
That's not the way it works. What you want is a Style that has your border settings in it, like this:
<Style TargetType="{x:Type Border}" x:Key="MyBorder">
<Setter Property="Background" Value="#E7E3ED" />
<Setter Property="BorderBrush" Value="Black" />
<Setter Property="BorderThickness" Value="1" />
<Setter Property="CornerRadius" Value="8,8,8,8" />
</Style>
and then do this in your UserControl:
<Border Margin="0,31,0,0" Width="222" Height="32" HorizontalAlignment="Left"
VerticalAlignment="Top" Style="{DynamicResource UDPBorder}">
<TextBlock>Hello</TextBlock>
</Border>
"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
|
|
|
|
|
The TextBlock with the content=Hello is just as an example - it could be a grid with lots of other controls inside it. Basicaly I want to write a control that can host other controls. Maybe I am not explaining myself very well - having spent a while on this, tapping random stuff into Google, any sense of what it is I wanted and how to express it has probably been lost.
I think a lot of the problem with this stuff is years ago if you wanted to know what a keyword did in a programming language and how to use it you would look it up in the manual. These days programming language keywords are of little consequence, it's all about the libraries but if you don't know what to look for where exactly do you look?
|
|
|
|
|
Dear John Simmons / outlaw programmer:
Would you please kind enough to look a problem which I posted? All necessary code is there to build the application.
Is this bug is in animation?
Best regards
Agha 
|
|
|
|
|
A better question would be if you even need to make a UserControl. The built in Border control is capable of holding a control as is. If all you are trying to do is have a way to make orange borders, you should just define a style like John suggested and apply it to any borders you want to be orange.
<StackPanel>
<Border Style="{StaticResource OrangeBorderStyle}">
<TextBlock>Hello</TextBlock>
</Border>
<Border Style="{StaticResource OrangeBorderStyle}">
<Grid>
<!-- your controls here -->
</Grid>
</Border>
</StackPanel>
|
|
|
|
|
Would you please kind enough to look "Is this bug in animation?" my problem?
All necessary code is there to build application.
Many thanks
Agha Khan
|
|
|
|
|
Don't post in other threads to try to get people to answer your question.
|
|
|
|
|
You are correct. Thank you to put me in right direction.
Best regards
Agha Khan
|
|
|
|
|
The orange border is of no consequence, it was just as an example. I want a user control which can also host other controls - an item container.
|
|
|
|
|
Try looking at ContentControl (or derived class) along with a style or control template first to see if can meet your needs. If that doesn't work, just create something that derives from ContentControl.
|
|
|
|
|
I just got through accomplishing this very thing, building a spin control out of a TextBox and vertical ScrollBar, wrapped in a StackPanel. I needed to have spin controls all over the place in my application so I needed a first class UserControl. I just followed the description given in Mathew MacDonald's excellent book, Pro WPF in C# 2008, pp. 858-866. Sure, I wound up with a source file that is over 400 lines long, but considering the payback, the effort was more than worthwhile. Once you've gone through an exercise like this, the rocket science is transformed into the routine and the sky is the limit.
|
|
|
|
|
Hi,
I've got a simple ServiceContract as follows:
[ServiceContract]
public interface ITestContractCallback
{
[OperationContract(IsOneWay = true)]
void CallBackFunc();
}
[ServiceContract(CallbackContract=typeof(ITestContractCallback))]
public interface ITestContract
{
[OperationContract(IsOneWay = false)]
ulong GetValue();
}
My server code looks like this:
[ServiceBehavior(InstanceContextMode = InstanceContextMode.PerSession)]
public class Server : ITestContract
{
public static ITestContractCallback _callback;
public Thread _callbackHammererThread;
public Server()
{
_callback = OperationContext.Current.GetCallbackChannel<ITestContractCallback>();
_callbackHammererThread = new Thread(CallbackHammererThread);
_callbackHammererThread.Start();
}
public static void CallbackHammererThread()
{
while (true)
{
if (_callback != null)
{
_callback.CallBackFunc();
}
Thread.Sleep(1);
}
}
#region ITestContract Members
public ulong GetValue()
{
return 100000;
}
#endregion
}
class Program
{
static void Main(string[] args)
{
NetTcpBinding binding = new NetTcpBinding();
ServiceHost host = new ServiceHost(typeof(Server));
Uri BaseAddressString = new Uri("net.tcp://localhost:1337/test");
host.AddServiceEndpoint(typeof(ITestContract), new NetTcpBinding(), BaseAddressString);
host.Open();
Application.Run();
host.Close();
}
}
And I've written a noddy WPF Application which connects to this server and, when a button is pressed displays the value of 'GetValue()' in a field. This works fine if I disable the CallbackHammererThread in the server but when it's continually hitting the callback on the client, my call to 'GetValue()' just freezes the whole GUI until the WCF TCP connection times out and throws an exception.
Debugging and using wireshark I can see that the server gets the call and returns the response but I can't figure out how to fix the deadlocking that appears to be caused in the client thread.
Can anyone help? This is occuring in a larger WPF + WCF appliction I'm currently working on and I'm finding it impossible to work out.
Thanks
Richard
|
|
|
|
|
I`ve got some problems with understanding how dependecy properties work so for sure smbd can explain it to me little better.
Let`s imagine simple GUI hierarchy Button:UIElement
class UIElement
{
public (DependecyProperty)static Font font;
}
I especially simplified this,but for me the keyword here is STATIC.
class Button:UIElement
{
private Font buttonfont;
public Button()
{
buttonfont=UIElement.font;
}
public Font GetFont()
{
return buttonfont;
}
public SetFont(Font font)
{
buttonfont=font;
}
}
So i`ve read somewhere that dependecy properties needed for performance and resource managment.
And the example was Form with Buttons
So let`s imagine Form with 10 Buttons
1.If no explicit SetFont invoked then 1 Font object needed.
Totally the same thing could be done with WindowsForms declaring global Font object(probably static)
2.If someone invokes,for example SetFont(Color.Random) then numberOfObjects=SetFontInvocations+1(for example)
{if we use ONLY Color.SomeColor to set colors, then no new objects created in any part of code,because Color enumeration exists and all colors automaticaly created)
And again the same situations with WindowsForms
So if it`s possible could you pls show where WPF can improve resource managment in this simple situation.
Thank you all for helping. 
|
|
|
|
|
It seems that you have some misconceptions about dependency properties. They are definitely not needed for performance (as regular properties backed by regular fields would probably be better than that), but they do have several advantages that make them useful on UI objects. I refer you to the MSDN Documentation on the subject:
MSDN wrote: The purpose of dependency properties is to provide a way to compute the value of a property based on the value of other inputs. These other inputs might include system properties such as themes and user preference, just-in-time property determination mechanisms such as data binding and animations/storyboards, multiple-use templates such as resources and styles, or values known through parent-child relationships with other elements in the element tree.
I would suggest reading the whole article (and perhaps some of the linked to articles) to get a good sense of what dependency properties are for and how they are used.
|
|
|
|
|
This is probably embarrassingly simple to accomplish but in researching and researching I can't find the answer.
I've captured the BitmapMetadata from the image file I'm transforming. Then I have successfully used TransformBitmap and ScaleTransform to scale from and to any of the six image formats supported by WPF, all without a hitch -- except one hitch which I knew I would have to deal with after getting the basic scaling mechanism working. The problem is getting the metadata transferred from the source image files to the destination image files.
There are Metadata properties in all six encoders but when I try to assign the metadata from the original image I get an exception complaining, "The designated BitmapEncoder does not support global metadata." Is "non-global metadata" a BitmapFrame? That only has a "get" property, no "set". That's the problem with all the speculations I've come up with to solve this problem: you can't assign a BitmapMetadata object to the Metadata property of any BitmapSource-derived class that I've been able to find. Looking for a solution in that direction just leads me up blind alleys.
A related issue is that I've read that when creating a new image from existing bitmap data, if you want metadata in the image, it has to be added before the bitmap data. But I haven't been able to figure out how to do that, either.
I have several books on WPF. None of them get remotely near to dealing with these issues, as fundamental as they are.
So what is the solution? It's got to be embarrassingly simple and I'm going to kick myself when I see it, but I'll be eternally grateful to anyone who supplies me with the answer.
|
|
|
|
|
I thought I finally came up with the solution very elegantly, but was shocked to find out that what seemed like the obvious answer simply does not work. As I mentioned, I am correctly capturing the metadata from the original image. Then in doggedly perusing the MSDN documentation, I slapped myself aside the head when I noticed an additional signature to BitmapFrame.Create() that seemed to supply the answer. Originally I was using this signature:
public static BitmapFrame Create(BitmapSource source)
After looking over the additional signatures for Create, I noticed this one:
public static BitmapFrame Create(
BitmapSource source,
BitmapSource thumbnail,
BitmapMetadata metadata,
ReadOnlyCollection<ColorContext> colorContexts
)
Eureka! I thought. But after enhancing my call to the latter, the destination files still have no metadata, as if the metadata parameter is just being ignored.
I am just stunned. The source parameter isn't being ignored: the original image is correctly scaled in the new file. At least I'm not getting an exception anymore, but now I am more baffled than ever. Here is my code, expanded more than is needed if the code worked, but parameters exposed so I could trace into the code to see if anything looked wrong (destinationPath and metadata are input parameters to the function):
WmpBitmapEncoder encoderWmp = new WmpBitmapEncoder();
FileStream stream = new FileStream(destinationPath, FileMode.Create);
BitmapMetadata bm = (BitmapMetadata)metadata;
encoderWmp.Frames.Add(BitmapFrame.Create(scaledBitmap, null, bm, null));
BitmapFrame bf = encoderWmp.Frames[0];
encoderWmp.Save(stream);
I wanted to see if bf still contained my original bitmap metadata. Tracing into the code indicates that it does! How could anything be set up more perfectly? Yet the metadata does not get into the image when the Save in the last statement is executed.
What seemed like an obvious oversight on my part is just another dead end. This would have been a supremely elegant solution to the problem, but it doesn't work.
|
|
|
|
|
Either nobody cares about image processing in WPF or everyone thinks the answer to the question is so obvious that it doesn't deserve an answer. Well, I have beaten my head against the wall for 10 hours today on this one and gotten nowhere. I have also had a fellow programmer working on this for about five hours and he must be just as brain-damaged as I am because he isn't getting anywhere, either.
The BitmapFrame I create has my metadata in it. When I add it to the BitmapEncoder its Metadata property is null. bf in my previous code snip above has my metadata in it intact, but a lot of good it does because it disappears once the BitmapEncoder is saved. Not that anyone really cares apparently.
|
|
|
|