• 1
  • 4
  • 5
  • 6
  • 7
  • 8
  • 10
 
User avatar
jsantos
Site Admin
Topic Author
Posts: 2416
Joined: 20 Jan 2012, 17:18
Contact:

Re: noesisGUI v1.2 BETA 6

17 Dec 2014, 16:24

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());
 
darthmaule2
Posts: 56
Joined: 23 Oct 2014, 19:54

Re: noesisGUI v1.2 BETA 6

17 Dec 2014, 19:09

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
 
User avatar
jsantos
Site Admin
Topic Author
Posts: 2416
Joined: 20 Jan 2012, 17:18
Contact:

Re: noesisGUI v1.2 BETA 6

17 Dec 2014, 19:49

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!
 
User avatar
jsantos
Site Admin
Topic Author
Posts: 2416
Joined: 20 Jan 2012, 17:18
Contact:

Re: noesisGUI v1.2 BETA 6

17 Dec 2014, 20:12

And yes, binding the TextureSource or its base class ImageSource is the correct way.
 
User avatar
sfernandez
Site Admin
Posts: 1502
Joined: 22 Dec 2011, 19:20

Re: noesisGUI v1.2 BETA 6

10 Jan 2015, 12:50

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);
    }
 
User avatar
jsantos
Site Admin
Topic Author
Posts: 2416
Joined: 20 Jan 2012, 17:18
Contact:

Re: noesisGUI v1.2 BETA 7

16 Jan 2015, 02:44

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.
 
User avatar
jsantos
Site Admin
Topic Author
Posts: 2416
Joined: 20 Jan 2012, 17:18
Contact:

Re: noesisGUI v1.2 BETA 6

16 Jan 2015, 02:45

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.
 
donjames
Posts: 25
Joined: 27 May 2013, 16:35

Re: noesisGUI v1.2 BETA 7

16 Jan 2015, 20:43

I get the following runtime error when I run
requires version 1.2.0 or later, but Noesis.dylib provides version 1.0.0
 
User avatar
jsantos
Site Admin
Topic Author
Posts: 2416
Joined: 20 Jan 2012, 17:18
Contact:

Re: noesisGUI v1.2 BETA 7

16 Jan 2015, 21:35

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)
 
clayzx
Posts: 7
Joined: 19 Jan 2015, 09:36

Re: noesisGUI v1.2 BETA 7

19 Jan 2015, 09:38

i want download this, but say:
You are not authorised to download this attachment.
  • 1
  • 4
  • 5
  • 6
  • 7
  • 8
  • 10

Who is online

Users browsing this forum: No registered users and 2 guests