Shorinji
Topic Author
Posts: 24
Joined: 16 Aug 2013, 19:45
Location: Shanghai

Noob questions about wether some things are possible or not

21 Aug 2013, 10:27

Hi,

I am a total noob in WPF, so before investing time in learning it, i would like to know if it is possible to do the following things with WPF and NoesisGUI.

-draggable/resizable panels

-i want have a panel containing buttons/controls, but i don't know in advance how many buttons there will
be, is it possible to create that panel and button list at runtime?

Thanks in advance.
 
User avatar
sfernandez
Site Admin
Posts: 1911
Joined: 22 Dec 2011, 19:20

Re: Noob questions about wether some things are possible or

21 Aug 2013, 18:52

Hi,

I am a total noob in WPF, so before investing time in learning it, i would like to know if it is possible to do the following things with WPF and NoesisGUI.
Welcome to our forums. I will try to shed some light on your questions...
-draggable/resizable panels
You can capture mouse events to apply transformations to UI elements: for dragging you would apply translate transforms, and for resizing you would modify panel dimensions (Width and Height properties).
-i want have a panel containing buttons/controls, but i don't know in advance how many buttons there will
be, is it possible to create that panel and button list at runtime?
It is perfectly possible to create UI elements dynamically and add them to any known container. For example, if you have a StackPanel panel in your interface named "ButtonContainer", you can do the following:
Ptr<FrameworkElement> xaml = LoadXaml<FrameworkElement>("Gui/Test/Panel.xaml");
Ptr<StackPanel> buttonContainer = xaml->FindName<StackPanel>("ButtonContainer");
Ptr<Button> button = *new Button();
button->SetContent("Dynamically Created!");
buttonContainer->GetChildren()->Add(button.GetPtr());
I hope this can dispel your doubts :)
 
Shorinji
Topic Author
Posts: 24
Joined: 16 Aug 2013, 19:45
Location: Shanghai

Re: Noob questions about wether some things are possible or

22 Aug 2013, 07:23

Hi,
Thanks for this information.
 
Shorinji
Topic Author
Posts: 24
Joined: 16 Aug 2013, 19:45
Location: Shanghai

Re: Noob questions about wether some things are possible or

26 Aug 2013, 22:41

Hi,
I have another question.

Is it possible to use the x:Class="MyClass" when using NoesisGUI in Unity with C#?
I get an error when i do so.

I think i saw in another thread that it was not supported but it would be supported in version 1.0, is it the case?

Thanks in advance.
 
User avatar
jsantos
Site Admin
Posts: 2900
Joined: 20 Jan 2012, 17:18
Contact:

Re: Noob questions about wether some things are possible or

26 Aug 2013, 23:35

Yes, x:Class is supported in Unity.

What error are you getting?

Could you paste the xaml here?
 
Shorinji
Topic Author
Posts: 24
Joined: 16 Aug 2013, 19:45
Location: Shanghai

Re: Noob questions about wether some things are possible or

27 Aug 2013, 02:01

Hi here is the XAMl in a file named Test.xaml :

<Grid
xmlns="http://schemas.microsoft.com/winfx/2006 ... esentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/marku ... ility/2006"
mc:Ignorable="d"
Margin="10"
x:Class="TestClass"
>
<Button>Test</Button>
</Grid>

Here is the C# code in a file named TestClass.cs :

using UnityEngine;
using System.Collections;

public class TestClass : Noesis.Grid
{
public void OnButtonClicked(Object sender, Noesis.RoutedEventArgs e)
{
Debug.Log("ButtonClicked");
}
}

The error i get is :

[DX9] Assets/GUI/TestClass.xaml
Parsing Grid (@1,0)
Unknown type 'TestClass'
UnityEngine.Debug:LogError(Object)
Noesis.BuildToolKernel:OnLog(Int32, String) (at Assets/Editor/NoesisGUI/NoesisBuildToolKernel.cs:161)
System.Object:wrapper_native_24424170()
Noesis.BuildToolKernel:Build() (at Assets/Editor/NoesisGUI/NoesisBuildToolKernel.cs:136)
NoesisPostProcessor:Build(String, Boolean, Boolean) (at Assets/Editor/NoesisGUI/NoesisPostProcessor.cs:207)
NoesisPostProcessor:OnPostprocessAllAssets(String[], String[], String[], String[]) (at Assets/Editor/NoesisGUI/NoesisPostProcessor.cs:170)
UnityEditor.AssetPostprocessingInternal:PostprocessAllAssets(String[], String[], String[], String[], String[])

the same error appear for GL

I'm still using the trial package.
 
User avatar
jsantos
Site Admin
Posts: 2900
Joined: 20 Jan 2012, 17:18
Contact:

Re: Noob questions about wether some things are possible or

27 Aug 2013, 02:11

Sorry for the confusion, x:Class is supported only for UserControls for now...

Yes, Code-Behind (what you are trying to achieve) is yet not implemented in Unity. You have to manually find the controls (marked wih x:Name) you are interested in and connect the delegates.
_button = grid.FindName<Button>("Button");
_button.Click += this.OnButtonClicked;
 
Shorinji
Topic Author
Posts: 24
Joined: 16 Aug 2013, 19:45
Location: Shanghai

Re: Noob questions about wether some things are possible or

27 Aug 2013, 02:31

Ok, i knew about the other method, but i preferred this one.
It will do for now but is this feature on the roadmap?
Thanks in advance.

Edit :
By the way, when i click play despite the error in PostProcess, Unity kind of bugs, it become impossible to stop the play mode by clicking on the button in the main panel. I found a way to unblock it, by using the Edit/Pause then clicking on play again to stop the play mode. I don't know if it comes from Unity or from NoesisGUI, but i thought i should report it to you.
 
User avatar
jsantos
Site Admin
Posts: 2900
Joined: 20 Jan 2012, 17:18
Contact:

Re: Noob questions about wether some things are possible or

27 Aug 2013, 03:19

Ok, i knew about the other method, but i preferred this one.
It will do for now but is this feature on the roadmap?
Main blocker from us is that code like this:
public class TestClass : Noesis.Grid
{
  public void OnButtonClicked(Object sender, Noesis.RoutedEventArgs e)
  {
    Debug.Log("ButtonClicked");
  }
}
Cannot be written in c# for NoesisGUI. The mechanism to extend Noesis classes in c# is quite awful and we are cleaning all that layer.

As soon as this work is finished incorporating Code-Behind is trivial. Apart from bugs reported by customers (that is the max priority) this is the next is our priority list.
By the way, when i click play despite the error in PostProcess, Unity kind of bugs, it become impossible to stop the play mode by clicking on the button in the main panel. I found a way to unblock it, by using the Edit/Pause then clicking on play again to stop the play mode. I don't know if it comes from Unity or from NoesisGUI, but i thought i should report it to you.
Strange that you don't get an error when clickin on Play beause TestClass.xaml didn't build and you have it referrenced inside a NoesisGUI Panel component, havent you?
 
Shorinji
Topic Author
Posts: 24
Joined: 16 Aug 2013, 19:45
Location: Shanghai

Re: Noob questions about wether some things are possible or

27 Aug 2013, 11:28

Hi,
Yes i understand bug correction is high priority.

About your question, i get an Exception thrown by the Noesis.Error class, which makes sense.

But, i have this behavior that i cannot exit play mode in the main Unity panel, i have to do it from the menu.
However, i just found out that it is not reproducible during some test before posting. I had this bug, and now i can't have it again. Anyway if i have new info i will update you.

By the way i just bought my license on Unity asset store. I will send a PM to you so that you can update my forum account.

Who is online

Users browsing this forum: No registered users and 0 guests