~haowenl/vorg-windows

7663d7ac2fbee4f5ed9989b22aff534abcbcf91f — Haowen Liu 11 months ago 0e8f8d9
Fix ImportEditPage binding
M vorg-windows/ImportEditPage.idl => vorg-windows/ImportEditPage.idl +18 -26
@@ 1,33 1,25 @@
// Copyright (c) Microsoft Corporation and Contributors.
// Licensed under the MIT License.
import "ImportEditPageState.idl";

namespace vorg_windows
{
    [default_interface]
    runtimeclass ImportEditPage : Microsoft.UI.Xaml.Controls.Page
[default_interface] runtimeclass ImportEditPage : Microsoft.UI.Xaml.Controls.Page
{
    ImportEditPage();
    Windows.Foundation.Collections.IObservableVector<String> Actors
    {
        get;
    };
    Windows.Foundation.Collections.IObservableVector<String> Tags
    {
        get;
    };
    ImportEditPageState State
    {
        ImportEditPage();
        Windows.Foundation.Collections.IObservableVector<String> Actors
        {
            get;
        };
        Windows.Foundation.Collections.IObservableVector<String> Tags
        {
            get;
        };
        Windows.Media.Core.MediaSource MediaSource
        {
            get;
            set;
        };
        String FileName
        {
            get;
            set;
        };
        get;
    };

        void ClearState();
    void ClearState();

        event Windows.Foundation.TypedEventHandler<ImportEditPage, Object> EditFinished;
    }
    event Windows.Foundation.TypedEventHandler<ImportEditPage, Object> EditFinished;
}
} // namespace vorg_windows

M vorg-windows/ImportEditPage.xaml => vorg-windows/ImportEditPage.xaml +2 -2
@@ 16,13 16,13 @@
            VerticalAlignment="Center"
            FontSize="22"
            Style="{StaticResource SubtitleTextBlockStyle}"
            Text="{x:Bind FileName}" />
            Text="{x:Bind Path=State.FileName, Mode=OneWay}" />
        <MediaPlayerElement
            x:Name="MediaPlayer"
            AreTransportControlsEnabled="True"
            BorderThickness="0"
            CornerRadius="16"
            Source="{x:Bind MediaSource}" />
            Source="{x:Bind Path=State.MediaSource, Mode=OneWay}" />
        <Grid
            Margin="0,16,0,0"
            ColumnSpacing="16"

M vorg-windows/ImportEditPage.xaml.cpp => vorg-windows/ImportEditPage.xaml.cpp +2 -17
@@ 30,24 30,9 @@ Windows::Foundation::Collections::IObservableVector<hstring> ImportEditPage::Tag
    return mTags;
}

Windows::Media::Core::MediaSource ImportEditPage::MediaSource() const
vorg_windows::ImportEditPageState ImportEditPage::State() const
{
    return mMediaSource;
}

void ImportEditPage::MediaSource(const Windows::Media::Core::MediaSource &mediaSource)
{
    mMediaSource = mediaSource;
}

hstring ImportEditPage::FileName() const
{
    return mFileName;
}

void ImportEditPage::FileName(const hstring &fileName)
{
    mFileName = fileName;
    return mState;
}

void ImportEditPage::UserControl_PointerEntered(const Windows::Foundation::IInspectable &sender,

M vorg-windows/ImportEditPage.xaml.h => vorg-windows/ImportEditPage.xaml.h +2 -7
@@ 13,11 13,7 @@ struct ImportEditPage : ImportEditPageT<ImportEditPage>
    Windows::Foundation::Collections::IObservableVector<hstring> Actors() const;
    Windows::Foundation::Collections::IObservableVector<hstring> Tags() const;

    Windows::Media::Core::MediaSource MediaSource() const;
    void MediaSource(const Windows::Media::Core::MediaSource &mediaSource);

    hstring FileName() const;
    void FileName(const hstring &fileName);
    vorg_windows::ImportEditPageState State() const;

    void UserControl_PointerEntered(const Windows::Foundation::IInspectable &sender,
                                    const Microsoft::UI::Xaml::Input::PointerRoutedEventArgs &);


@@ 56,8 52,7 @@ struct ImportEditPage : ImportEditPageT<ImportEditPage>
  private:
    Windows::Foundation::Collections::IObservableVector<hstring> mActors;
    Windows::Foundation::Collections::IObservableVector<hstring> mTags;
    Windows::Media::Core::MediaSource mMediaSource{nullptr};
    hstring mFileName;
    vorg_windows::ImportEditPageState mState;
    com_ptr<vorg_windows::implementation::App> mApp;
    event<Windows::Foundation::TypedEventHandler<vorg_windows::ImportEditPage, Windows::Foundation::IInspectable>>
        mEditFinishedEvent;

A vorg-windows/ImportEditPageState.cpp => vorg-windows/ImportEditPageState.cpp +41 -0
@@ 0,0 1,41 @@
#include "pch.h"

#include "ImportEditPageState.h"
#if __has_include("ImportEditPageState.g.cpp")
#include "ImportEditPageState.g.cpp"
#endif

namespace winrt::vorg_windows::implementation
{
Windows::Media::Core::MediaSource ImportEditPageState::MediaSource() const
{
    return mMediaSource;
}

void ImportEditPageState::MediaSource(const Windows::Media::Core::MediaSource &mediaSource)
{
    mMediaSource = mediaSource;
    mPropertyChangedEvent(*this, Microsoft::UI::Xaml::Data::PropertyChangedEventArgs{L"MediaSource"});
}

hstring ImportEditPageState::FileName() const
{
    return mFileName;
}

void ImportEditPageState::FileName(const hstring &fileName)
{
    mFileName = fileName;
    mPropertyChangedEvent(*this, Microsoft::UI::Xaml::Data::PropertyChangedEventArgs{L"FileName"});
}

event_token ImportEditPageState::PropertyChanged(const Microsoft::UI::Xaml::Data::PropertyChangedEventHandler &handler)
{
    return mPropertyChangedEvent.add(handler);
}

void ImportEditPageState::PropertyChanged(const event_token &token)
{
    mPropertyChangedEvent.remove(token);
}
} // namespace winrt::vorg_windows::implementation
\ No newline at end of file

A vorg-windows/ImportEditPageState.h => vorg-windows/ImportEditPageState.h +33 -0
@@ 0,0 1,33 @@
#pragma once

#include "ImportEditPageState.g.h"

namespace winrt::vorg_windows::implementation
{
struct ImportEditPageState : ImportEditPageStateT<ImportEditPageState>
{
    ImportEditPageState() = default;

    Windows::Media::Core::MediaSource MediaSource() const;
    void MediaSource(const Windows::Media::Core::MediaSource &mediaSource);

    hstring FileName() const;
    void FileName(const hstring &fileName);

    event_token PropertyChanged(const Microsoft::UI::Xaml::Data::PropertyChangedEventHandler &handler);
    void PropertyChanged(const event_token &token);

  private:
    Windows::Media::Core::MediaSource mMediaSource{nullptr};
    hstring mFileName;

    event<Microsoft::UI::Xaml::Data::PropertyChangedEventHandler> mPropertyChangedEvent;
};
} // namespace winrt::vorg_windows::implementation

namespace winrt::vorg_windows::factory_implementation
{
struct ImportEditPageState : ImportEditPageStateT<ImportEditPageState, implementation::ImportEditPageState>
{
};
} // namespace winrt::vorg_windows::factory_implementation

A vorg-windows/ImportEditPageState.idl => vorg-windows/ImportEditPageState.idl +18 -0
@@ 0,0 1,18 @@
namespace vorg_windows
{
[default_interface] runtimeclass ImportEditPageState : Microsoft.UI.Xaml.Data.INotifyPropertyChanged
{
    ImportEditPageState();

    Windows.Media.Core.MediaSource MediaSource
    {
        get;
        set;
    };
    String FileName
    {
        get;
        set;
    };
}
} // namespace vorg_windows
\ No newline at end of file

M vorg-windows/ImportPage.xaml.cpp => vorg-windows/ImportPage.xaml.cpp +4 -4
@@ 43,10 43,10 @@ void ImportPage::ImportSelectionPage_SelectionFinished(const vorg_windows::Impor
    vorg_windows::ImportEditPage editPage = ContentFrame().Content().as<vorg_windows::ImportEditPage>();
    hstring filePath = mApp->GetNextFile();
    hstring fileName = mApp->GetNextFileName();
    editPage.FileName(fileName);
    editPage.State().FileName(fileName);
    Windows::Media::Core::MediaSource mediaSouce =
        Windows::Media::Core::MediaSource::CreateFromUri(Windows::Foundation::Uri{filePath});
    editPage.MediaSource(mediaSouce);
    editPage.State().MediaSource(mediaSouce);
    mEditFinishedToken =
        editPage.EditFinished([this](auto &sender, auto &args) { this->ImportEditPage_EditFinished(sender, args); });
}


@@ 80,10 80,10 @@ void ImportPage::ImportEditPage_EditFinished(const vorg_windows::ImportEditPage 
    {
        // Continue editing next file
        hstring fileName = mApp->GetNextFileName();
        editPage.FileName(fileName);
        editPage.State().FileName(fileName);
        Windows::Media::Core::MediaSource mediaSouce =
            Windows::Media::Core::MediaSource::CreateFromUri(Windows::Foundation::Uri{filePath});
        editPage.MediaSource(mediaSouce);
        editPage.State().MediaSource(mediaSouce);
    }
}


M vorg-windows/vorg-windows.vcxproj => vorg-windows/vorg-windows.vcxproj +3 -0
@@ 136,6 136,7 @@
      <DependentUpon>ImportEditPage.xaml</DependentUpon>
      <SubType>Code</SubType>
    </ClInclude>
    <ClInclude Include="ImportEditPageState.h" />
    <ClInclude Include="ImportPage.xaml.h">
      <DependentUpon>ImportPage.xaml</DependentUpon>
      <SubType>Code</SubType>


@@ 199,6 200,7 @@
      <DependentUpon>ImportEditPage.xaml</DependentUpon>
      <SubType>Code</SubType>
    </ClCompile>
    <ClCompile Include="ImportEditPageState.cpp" />
    <ClCompile Include="ImportPage.xaml.cpp">
      <DependentUpon>ImportPage.xaml</DependentUpon>
      <SubType>Code</SubType>


@@ 244,6 246,7 @@
      <DependentUpon>ImportEditPage.xaml</DependentUpon>
      <SubType>Code</SubType>
    </Midl>
    <Midl Include="ImportEditPageState.idl" />
    <Midl Include="ImportPage.idl">
      <DependentUpon>ImportPage.xaml</DependentUpon>
      <SubType>Code</SubType>

M vorg-windows/vorg-windows.vcxproj.filters => vorg-windows/vorg-windows.vcxproj.filters +21 -3
@@ 16,16 16,31 @@
  <ItemGroup>
    <Midl Include="App.idl" />
    <Midl Include="MainWindow.idl" />
    <Midl Include="BrowseVideoData.idl" />
    <Midl Include="BrowseVideoData.idl">
      <Filter>Data Types</Filter>
    </Midl>
    <Midl Include="ImportEditPageState.idl">
      <Filter>Data Types</Filter>
    </Midl>
  </ItemGroup>
  <ItemGroup>
    <ClCompile Include="pch.cpp" />
    <ClCompile Include="$(GeneratedFilesDir)module.g.cpp" />
    <ClCompile Include="BrowseVideoData.cpp" />
    <ClCompile Include="BrowseVideoData.cpp">
      <Filter>Data Types</Filter>
    </ClCompile>
    <ClCompile Include="ImportEditPageState.cpp">
      <Filter>Data Types</Filter>
    </ClCompile>
  </ItemGroup>
  <ItemGroup>
    <ClInclude Include="pch.h" />
    <ClInclude Include="BrowseVideoData.h" />
    <ClInclude Include="BrowseVideoData.h">
      <Filter>Data Types</Filter>
    </ClInclude>
    <ClInclude Include="ImportEditPageState.h">
      <Filter>Data Types</Filter>
    </ClInclude>
  </ItemGroup>
  <ItemGroup>
    <Image Include="Assets\Wide310x150Logo.scale-200.png">


@@ 54,6 69,9 @@
    <Filter Include="Assets">
      <UniqueIdentifier>{f873567e-c027-48f4-adca-b5a7c3ce8acc}</UniqueIdentifier>
    </Filter>
    <Filter Include="Data Types">
      <UniqueIdentifier>{1a7d8cec-2b9a-4b31-ac35-3c9e042a2a7a}</UniqueIdentifier>
    </Filter>
  </ItemGroup>
  <ItemGroup>
    <Text Include="readme.txt" />