1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156
|
/* Copyright (c) MediaArea.net SARL. All Rights Reserved.
*
* Use of this source code is governed by a BSD-style license that can
* be found in the License.html file in the root of the source tree.
*/
//---------------------------------------------------------------------------
#include "pch.h"
#include "SheetEditDialog.xaml.h"
#include "ZenLib/Ztring.h"
#include "ZenLib/ZtringList.h"
#include "ZenLib/ZtringListList.h"
#include "MediaInfo/MediaInfo_Internal.h"
//---------------------------------------------------------------------------
using namespace ZenLib;
using namespace MediaInfo;
using namespace MediaInfoLib;
using namespace Platform;
using namespace Platform::Collections;
using namespace Windows::Foundation;
using namespace Windows::Foundation::Collections;
using namespace Windows::UI::Xaml;
using namespace Windows::UI::Xaml::Controls;
using namespace Windows::UI::Xaml::Controls::Primitives;
using namespace Windows::UI::Xaml::Data;
using namespace Windows::UI::Xaml::Input;
using namespace Windows::UI::Xaml::Media;
using namespace Windows::UI::Xaml::Interop;
using namespace Windows::UI::Xaml::Navigation;
//---------------------------------------------------------------------------
// Constructor/Destructor
//---------------------------------------------------------------------------
//---------------------------------------------------------------------------
SheetEditDialog::SheetEditDialog(Platform::String^ Title, Sheet^ Content) : _Sheet(Content)
{
InitializeComponent();
this->Title=Title;
SolidColorBrush^ TransparentBrush=ref new SolidColorBrush(Windows::UI::Colors::White);
TransparentBrush->Opacity=0;
SolidColorBrush^ GrayBrush=ref new SolidColorBrush(Windows::UI::Colors::Gray);
NameText->Text=Content->Name;
for (Field^ It:Content->Fields)
{
Add_Field(It->Title, It->Length, It->StreamKind, It->StreamPos, It->Parameter);
}
FontIcon^ AddIcon=ref new FontIcon();
AddIcon->FontFamily=ref new Windows::UI::Xaml::Media::FontFamily(L"Segoe MDL2 Assets");
AddIcon->Glyph=L"\uE710";
Button^ AddButton=ref new Button();
AddButton->Background=TransparentBrush;
AddButton->Foreground=GrayBrush;
AddButton->HorizontalAlignment=Windows::UI::Xaml::HorizontalAlignment::Stretch;
AddButton->Content=AddIcon;
FieldList->Footer=AddButton;
AddButton->Click+=ref new RoutedEventHandler([this](Object^, RoutedEventArgs^) {
Add_Field(L"New Field", 1, 0, 0, L"FileName");
});
}
//---------------------------------------------------------------------------
// Functions
//---------------------------------------------------------------------------
//---------------------------------------------------------------------------
void SheetEditDialog::Add_Field(Platform::String^ Name, size_t Width, size_t StreamKind, size_t StreamPos, Platform::String^ Parameter)
{
SolidColorBrush^ TransparentBrush=ref new SolidColorBrush(Windows::UI::Colors::White);
TransparentBrush->Opacity=0;
SolidColorBrush^ GrayBrush=ref new SolidColorBrush(Windows::UI::Colors::Gray);
RelativePanel^ FieldPanel=ref new RelativePanel();
FieldPanel->Margin=ThicknessHelper::FromLengths(0, 5, 0, 5);
FontIcon^ DeleteIcon=ref new FontIcon();
DeleteIcon->FontFamily=ref new Windows::UI::Xaml::Media::FontFamily(L"Segoe MDL2 Assets");
DeleteIcon->FontSize=18;
DeleteIcon->Glyph=L"\uE711";
Button^ DeleteButton=ref new Button();
DeleteButton->Background=TransparentBrush;
DeleteButton->Foreground=GrayBrush;
DeleteButton->VerticalAlignment=Windows::UI::Xaml::VerticalAlignment::Stretch;
DeleteButton->Content=DeleteIcon;
FieldPanel->Children->Append(DeleteButton);
FieldPanel->SetAlignRightWithPanel(DeleteButton, true);
FieldPanel->SetAlignTopWithPanel(DeleteButton, true);
FieldPanel->SetAlignBottomWithPanel(DeleteButton, true);
SheetEditFieldControl^ FieldControl=ref new SheetEditFieldControl(Name, Width, StreamKind, StreamPos, Parameter);
FieldPanel->Children->Append(FieldControl);
FieldPanel->SetLeftOf(FieldControl, DeleteButton);
FieldPanel->SetAlignLeftWithPanel(FieldControl, true);
FieldPanel->SetAlignTopWithPanel(FieldControl, true);
FieldPanel->SetAlignBottomWithPanel(FieldControl, true);
FieldList->Items->Append(FieldPanel);
DeleteButton->Click+=ref new RoutedEventHandler([this](Object^ Sender, RoutedEventArgs^ Event) {
Button^ Item=safe_cast<Button^>(Sender);
unsigned int Index=0;
if (FieldList->Items->IndexOf(Item->Parent, &Index))
FieldList->Items->RemoveAt(Index);
});
}
//---------------------------------------------------------------------------
void SheetEditDialog::ContentDialog_PrimaryButtonClick(ContentDialog^ Sender, ContentDialogButtonClickEventArgs^ Event)
{
if (NameText->Text->Length())
_Sheet->Name=NameText->Text;
Vector<Field^>^ Fields=ref new Vector<Field^>();
for (Object^ Obj : FieldList->Items)
{
if (Obj->GetType()->FullName!=TypeName(RelativePanel::typeid).Name)
continue;
RelativePanel^ Panel=safe_cast<RelativePanel^>(Obj);
SheetEditFieldControl^ FieldControl=nullptr;
for (Object^ Obj2 : Panel->Children)
{
if (Obj2->GetType()->FullName!=TypeName(SheetEditFieldControl::typeid).Name)
continue;
FieldControl=safe_cast<SheetEditFieldControl^>(Obj2);
}
if (!FieldControl)
continue;
Fields->Append(ref new Field(FieldControl->Get_Name(), FieldControl->Get_StreamKind(), FieldControl->Get_StreamPos(), FieldControl->Get_Parameter(), FieldControl->Get_Width()));
}
_Sheet->Fields=Fields;
}
//---------------------------------------------------------------------------
void SheetEditDialog::ContentDialog_SecondaryButtonClick(ContentDialog^ Sender, ContentDialogButtonClickEventArgs^ Event)
{
}
|