Page 6 of 10

Re: noesisGUI v1.2 BETA 6

Posted: 17 Dec 2014, 16:24
by jsantos
Yes, you can create an image manually this way:
Ptr<TextureSource> source = *new TextureSource("Themes/Images/icon_MDD_blue1.png");
Ptr<Image> image = *new Image();
image->SetSource(source.GetPtr());

Re: noesisGUI v1.2 BETA 6

Posted: 17 Dec 2014, 19:09
by darthmaule2
Thanks, that works. But how do I bind to it? I've tried to expose a property in the code-behind and tried all of these types:
- TextureSource
- Image
- ImageSource

The problem is when I try to bind to that property from the xaml...
<Image HorizontalAlignment="Left" Width="32" Height="32" Margin="4,0,0,0" Source="{Binding ItemImage}"/>

I get this runtime error:
Can't create ComponentConverter<ImageSource>, it is not registered

Re: noesisGUI v1.2 BETA 6

Posted: 17 Dec 2014, 19:49
by jsantos
It seems that in the reorganization of classes we are doing in v1.2 we did something wrong and several components are missing.

Let us investigate it and fix it. We are going to release a new beta this week.

Thanks!

Re: noesisGUI v1.2 BETA 6

Posted: 17 Dec 2014, 20:12
by jsantos
And yes, binding the TextureSource or its base class ImageSource is the correct way.

Re: noesisGUI v1.2 BETA 6

Posted: 10 Jan 2015, 12:50
by sfernandez
Thanks, that works. But how do I bind to it? I've tried to expose a property in the code-behind and tried all of these types:
- TextureSource
- Image
- ImageSource

The problem is when I try to bind to that property from the xaml...
<Image HorizontalAlignment="Left" Width="32" Height="32" Margin="4,0,0,0" Source="{Binding ItemImage}"/>

I get this runtime error:
Can't create ComponentConverter<ImageSource>, it is not registered
I created the following sample that shows how to bind an ImageSource (or TextureSource) property to an Image element:
//////////////////////////////////////////////////
class ViewModel : public BaseComponent, public INotifyPropertyChanged
{
public:
    ViewModel() { }
    ~ViewModel() { mDestroyed(this); }

    ImageSource* GetImage() const { return mImage.GetPtr(); }
    void SetImage(ImageSource* image) { mImage.Reset(image); }

    PropertyChangedEventHandler& PropertyChanged() { return mPropertyChanged; }
    DestroyedEventHandler& Destroyed() { return mDestroyed; }

private:
    Ptr<ImageSource> mImage;
    PropertyChangedEventHandler mPropertyChanged;
    DestroyedEventHandler mDestroyed;

    NS_IMPLEMENT_INLINE_REFLECTION(ViewModel, BaseComponent)
    {
        NsMeta<TypeId>("ViewModel");
        NsImpl<INotifyPropertyChanged>();
        NsProp("Image", &ViewModel::mImage);
    }
};

//////////////////////////////////////////////////
class TestControl : public UserControl
{
public:
    TestControl() { }

    void OnPostInit()
    {
        Ptr<ViewModel> vm = *new ViewModel();

        Ptr<Render::ITexture2D> tex = NsDynamicCast< Ptr<Render::ITexture2D> >(
            NsGetSystem<Resource::IResourceSystem>()->Load("Data/XamlPlayer/test.jpg"));
        Ptr<TextureSource> img = *new TextureSource(tex.GetPtr());
        vm->SetImage(img.GetPtr());

        SetDataContext(vm.GetPtr());
    }

    NS_IMPLEMENT_INLINE_REFLECTION(TestControl, UserControl)
    {
        NsMeta<TypeId>("TestControl");
    }
};
<UserControl x:Class="TestControl"
  xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
  xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
    <Image Source="{Binding Image}" Width="200" Height="100" Stretch="Fill"/>
</UserControl>
There is only a restriction now (we are going to fix in the next release), the exposed property must be a Ptr type, you cannot use a Getter/Setter returning a pointer to the ImageSource:
    //...
    ImageSource* GetImage() const { return mImage.GetPtr(); }
    void SetImage(ImageSource* image) { mImage.Reset(image); }
    // ...
    Ptr<ImageSource> mImage;

    NS_IMPLEMENT_INLINE_REFLECTION(ViewModel, BaseComponent)
    {
        // This works now
        NsProp("Image", &ViewModel::mImage);

        // This does not work now (we will fix it in the next release)
        //NsProp("Image", &ViewModel::GetImage, &ViewModel::SetImage);
    }

Re: noesisGUI v1.2 BETA 7

Posted: 16 Jan 2015, 02:44
by jsantos
Beta7 available for downloading! Many improvements and bug fixes, the changelog is so big that we didn't find time to organize it. Will be updated in the next beta, before the final release.

Re: noesisGUI v1.2 BETA 6

Posted: 16 Jan 2015, 02:45
by jsantos
There is only a restriction now (we are going to fix in the next release), the exposed property must be a Ptr type, you cannot use a Getter/Setter returning a pointer to the ImageSource:
This was fixed in b7.

Re: noesisGUI v1.2 BETA 7

Posted: 16 Jan 2015, 20:43
by donjames
I get the following runtime error when I run
requires version 1.2.0 or later, but Noesis.dylib provides version 1.0.0

Re: noesisGUI v1.2 BETA 7

Posted: 16 Jan 2015, 21:35
by jsantos
I get the following runtime error when I run
requires version 1.2.0 or later, but Noesis.dylib provides version 1.0.0
This is probably because an older version of NoesisGUI is being loaded. The latest beta is versioned this way:
otool -L Noesis.dylib

Noesis.dylib:
	@rpath/Noesis.dylib (compatibility version 1.2.0, current version 1.2.0)

Re: noesisGUI v1.2 BETA 7

Posted: 19 Jan 2015, 09:38
by clayzx
i want download this, but say:
You are not authorised to download this attachment.