Run8stud
Topic Author
Posts: 10
Joined: 15 Jun 2018, 21:06

Noesis Questions

26 Jun 2018, 15:48

I program a simulation called Run8. We've used WPF for our menus for quite a long time, but of course one can't render WPF in true Fullscreen. SInce we really need to use true fullscreen and not the borderless-window method we've been using, I've been trying Noesis to see if it would suit our needs, and mostly it works great. This is a DotNet Windows application using DirectX11 via SharpDX, C#, and VisualStudio 2015/2017.

I have some issues though, and I don't know if it's me, Visual-Studio, or Noesis:

1) Visual Studio 2017 is constantly giving me "The type XYZ does not support direct content". 'XYZ' can be a Border, Trigger, UserControl, Storyboard, etc. I have searched and searched for a solution to no avail. The code compiles and runs just fine though, but my editor is spammed with blue squiggly underlines everywhere. This happens for any of the menus I've converted into Noesis, which all seem to compile and function perfectly fine in-game.

2) Using the sample NumericUpDown (I literally cut and pasted the code and changed the namespace where needed), I was once and only once able to place it into my menu and edit it. Ever since then, I'm plagued with "Invalid Markup" even though everything compiles and runs just fine, with the NumericUpDown showing and operating normally in the simulation. In VS2017, if I comment-out the NumericUpDown, I get my designer back, and when I uncomment, I'm right back to Invalid Markup and can't edit the menu.
-This also happens if I use Blend for 2017.
-I was getting a namespace error, even though I know for absolute certain the namespace was just fine in all the places it needed to be, and in-game, all runs fine
-I also get "The specified value cannot be assigned to in the collection. The following type was expected: "UIElement".
-And "The attached property "Left" or "Top" can only be applied to types that are derived from "UIElement"; relating to Canvas.Left and Canvas.Top in the NumericUpDown

3) The GroupBox that shows in VS2017 doesn't match what shows in the simulation, and I cannot figure out why nor how to remedy that.

4) Question: In our WPF menus, we had our own style for GroupBoxes that got rid of that ugly double-white border and allowed us to have the header along the top of the border. Unfortunately it uses a Multibinding entry to take care of the mask that blanks out the portion of the border under the header, which Noesis doesn't seem to like. How would I go about getting something like that to work in Noesis?

Thanks in advance, and overall I'm impressed! I just need to sort out these things before I can commit. I also have a licensing question, but that can wait till later.
John G.
 
mingingmingler
Posts: 23
Joined: 15 Jan 2018, 00:03

Re: Noesis Questions

26 Jun 2018, 20:33

One of the Noesis guys will likely respond in a bit but in the mean time...

1 + 2) Are you using Noesis types instead of WPF types? You'll get all sorts of problems if you try to use a WPF UserControl in Noesis, for example.
3) If it's a styling thing, Noesis has its own default styles for controls which are different to the default styles in WPF, so you'll need to fully override those.
4) Unfortunately Noesis doesn't support multibindings, your options are to either create a converter, or add a property in your VM for the result you're expecting.
 
Run8stud
Topic Author
Posts: 10
Joined: 15 Jun 2018, 21:06

Re: Noesis Questions

27 Jun 2018, 12:02

Thanks for the response!

I sorta figured out #3: for experimenting, I grabbed the NoesisTheme.xaml from one of the samples. In one of my menu, I use it as a Resource Dictionary (since that's what it is), so now in the WPF designer things look normal.

I'm just getting an exception now when the program runs and Noesis goes to load this menu, as it says it cannot find the NoesisTheme.xaml even though it's for-sure in the correct place...
 
Run8stud
Topic Author
Posts: 10
Joined: 15 Jun 2018, 21:06

Re: Noesis Questions

27 Jun 2018, 13:29

Yeah, no matter what I try, Noesis can't find the xaml. Here's the Exception thrown:
NoesisException: Xaml not found 'D:/Repo_Run8V3/Run8v2/bin/Release/Content/Menus_Noesis/NoesisTheme.xaml'
This path is flawless, that is exactly where this very file resides, so I'm at a total loss as to how I'm going wrong here.

The function throwing the exception is:
Noesis.GUI.LoadComponent(this, NoesisMenuManager.MenuPath + "TruckMenu.xaml");
TruckMenu.xaml loads fine, so long as I don't reference the ResourceDictionary "NoesisTheme.xaml". In TruckMenu.xaml, if I comment out the following, the above exception goes away:
<UserControl.Resources>
        <ResourceDictionary Source="../../Content/Menus_Noesis/NoesisTheme.xaml"/>
    </UserControl.Resources>
 
Run8stud
Topic Author
Posts: 10
Joined: 15 Jun 2018, 21:06

Re: Noesis Questions

27 Jun 2018, 14:29

After searching some more, I found if I do this early in the program...
ResourceDictionary style = (ResourceDictionary)Noesis.GUI.LoadXaml(MenuPath + "NoesisTheme.xaml");
Noesis.GUI.SetApplicationResources(style);
...I can simply comment out the reference to the ResourceDictionary in my XAML once I'm finished editing the menu. I'm still convinced I'm doing something wrong though, but at least it works and what I see is what I get.

Anyhow, on to my next hurdle: getting a TextBox to fire the MouseWheel event. :? For some reason, it doesn't.
 
User avatar
sfernandez
Site Admin
Posts: 1915
Joined: 22 Dec 2011, 19:20

Re: Noesis Questions

27 Jun 2018, 18:31

1 and 2) You cannot use Noesis classes in Visual Studio designer to edit xaml files. You should have a different Microsoft Blend project to edit and test xamls. To make code compatible between Blend and Noesis you should use #define blocks to include the correct namespaces and API that is not 100% WPF compatible. Then just compile the code in the Noesis project to run it.

3 and 4) As you now know we use our own default styles (NoesisTheme.xaml), you can use that dictionary in the App.Resources of the Blend project to design your UI with the same base styles. And then have your own ResourceDictionary with your application styles that you can set in Noesis to override our default styles, by calling Noesis.GUI.SetApplicationResources().

Exceptions about xamls not found should be related to the XamlProvider you set after initializing Noesis. We don't directly read files from disk, but ask the providers to return a Stream we then use to load the resource. You should investigate the providers code when getting that kind of errors.

MouseWheel is not handled by TextBox or its inner ScrollViewer, so if you add a handler to that event it should be called? Or do you mean anything else?
 
Run8stud
Topic Author
Posts: 10
Joined: 15 Jun 2018, 21:06

Re: Noesis Questions

28 Jun 2018, 08:56

Thanks for your reply! I'm sure most of my hurdles are simply me getting used to doing things a new way. This area of programming is also not my forte.
 
Run8stud
Topic Author
Posts: 10
Joined: 15 Jun 2018, 21:06

Re: Noesis Questions

28 Jun 2018, 09:36

Regarding the MouseWheel event, as far as I know I'm handling it correctly based on how other events are connected and handled. My only change is I tried a TextBox instead of a TextBlock, but same results either way.

From NumericUpDown.xaml:
<TextBox Name="TextBox" MouseWheel="MouseWheelDelta" Focusable="True" LostFocus="TextBoxLostFocus" Text="{Binding Value, ElementName=NumericUpDownControl}" Grid.RowSpan="2" VerticalAlignment="Center" Margin="3,2,3,2" />
From Code-Behind's override bool ConnectEvent() which works properly:
if (eventName == "MouseWheel" && handlerName == "MouseWheelDelta")
            {
                ((TextBox)source).MouseWheel += MouseWheel_Delta;
                return true;
            }
And the handler, which is never getting called:
void MouseWheel_Delta(object sender, MouseWheelEventArgs e)
        {
            if (e.Delta > 0)
                Value += ValueStep;
            else if (e.Delta < 0)
                Value -= ValueStep;
        }
The event gets connected (verified by Breakpoint), but never fires or something handles it prior to this point. Or I'm just doing something wrong, however this is how all other events are dealt with and it works great for them.
 
User avatar
sfernandez
Site Admin
Posts: 1915
Joined: 22 Dec 2011, 19:20

Re: Noesis Questions

02 Jul 2018, 19:52

Are you injecting the mouse wheel events to the Noesis View?
view.MouseWheel(x, y, deltaRotation); // delta values are usually -120 or 120
Otherwise mouse wheel events are not generated.

I tried both C++ and C# SDK and I'm correctly receiving MouseWheel event using a code like yours.
 
Run8stud
Topic Author
Posts: 10
Joined: 15 Jun 2018, 21:06

Re: Noesis Questions

03 Jul 2018, 12:16

Thank you thank you!!! Yes I had totally forgotten to call that part. Works beautifully! That also tied in with another problem I was having with text-boxes, but once I realized how to properly send the keyboard input to the control, all was fine. Muchas Gracias!

Who is online

Users browsing this forum: sfernandez and 1 guest