Page 1 of 4

Noob questions about wether some things are possible or not

Posted: 21 Aug 2013, 10:27
by Shorinji
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.

Re: Noob questions about wether some things are possible or

Posted: 21 Aug 2013, 18:52
by sfernandez
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 :)

Re: Noob questions about wether some things are possible or

Posted: 22 Aug 2013, 07:23
by Shorinji
Hi,
Thanks for this information.

Re: Noob questions about wether some things are possible or

Posted: 26 Aug 2013, 22:41
by Shorinji
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.

Re: Noob questions about wether some things are possible or

Posted: 26 Aug 2013, 23:35
by jsantos
Yes, x:Class is supported in Unity.

What error are you getting?

Could you paste the xaml here?

Re: Noob questions about wether some things are possible or

Posted: 27 Aug 2013, 02:01
by Shorinji
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.

Re: Noob questions about wether some things are possible or

Posted: 27 Aug 2013, 02:11
by jsantos
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;

Re: Noob questions about wether some things are possible or

Posted: 27 Aug 2013, 02:31
by Shorinji
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.

Re: Noob questions about wether some things are possible or

Posted: 27 Aug 2013, 03:19
by jsantos
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?

Re: Noob questions about wether some things are possible or

Posted: 27 Aug 2013, 11:28
by Shorinji
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.