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
|
/* 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.
*/
#pragma once
//---------------------------------------------------------------------------
#include "DataGrid.g.h"
//---------------------------------------------------------------------------
namespace MediaInfo
{
//---------------------------------------------------------------------------
ref class DataGrid;
//---------------------------------------------------------------------------
public enum class SortMode
{
None,
Ascending,
Descending
};
//---------------------------------------------------------------------------
public ref class Sort sealed
{
public:
Sort(SortMode Mode, unsigned int Column) : _Mode(Mode), _Column(Column) {}
property SortMode Mode
{
SortMode get() { return _Mode; }
void set(SortMode Value) { _Mode=Value; }
}
property unsigned int Column
{
unsigned int get() { return _Column; }
void set(unsigned int Value) { _Column=Value; }
}
private:
SortMode _Mode;
unsigned int _Column;
};
//---------------------------------------------------------------------------
[Windows::Foundation::Metadata::WebHostHidden]
public ref class RightClickedEventArgs sealed
{
public:
RightClickedEventArgs(unsigned int Pos, Windows::UI::Xaml::Input::RightTappedRoutedEventArgs^ Event) : _Pos(Pos), _Event(Event) {}
property unsigned int Pos
{
unsigned int get() { return _Pos; };
}
property Windows::UI::Xaml::Input::RightTappedRoutedEventArgs^ Event
{
Windows::UI::Xaml::Input::RightTappedRoutedEventArgs^ get() { return _Event; }
}
private:
unsigned int _Pos;
Windows::UI::Xaml::Input::RightTappedRoutedEventArgs^ _Event;
};
//---------------------------------------------------------------------------
[Windows::Foundation::Metadata::WebHostHidden]
public delegate void SelectionChangedEventHandler(DataGrid^ Sender, unsigned int Pos);
public delegate void RightClickedEventHandler(DataGrid^ Sender, RightClickedEventArgs^ Event);
//---------------------------------------------------------------------------
[Windows::Foundation::Metadata::WebHostHidden]
public ref class DataGrid sealed
{
public:
DataGrid();
void Reset(); // Delete cell content and rows source
void Clear(); // Delete only cell content
void Add_Column(Windows::UI::Xaml::GridLength Width, Platform::String^ Header);
void Set_Content(unsigned int Row, unsigned int Column, Platform::String^ Content);
void Select(Windows::Foundation::Collections::IVectorView<Platform::String^>^ Row);
property Windows::Foundation::Collections::IObservableVector<Windows::Foundation::Collections::IVectorView<Platform::String^>^>^ Rows
{
Windows::Foundation::Collections::IObservableVector<Windows::Foundation::Collections::IVectorView<Platform::String^>^>^ get() { return _Rows; }
void set(Windows::Foundation::Collections::IObservableVector<Windows::Foundation::Collections::IVectorView<Platform::String^>^>^ Value);
}
property unsigned int SelectedRow {
unsigned int get();
}
event SelectionChangedEventHandler^ SelectionChangedEvent;
event RightClickedEventHandler^ RightClickedEvent;
private:
void Display();
void Sort_Rows();
Windows::UI::Xaml::Controls::RelativePanel^ Add_Cell(unsigned int Row, unsigned int Column, Platform::String^ Content);
void Cell_Clicked(Platform::Object^ Sender, Windows::UI::Xaml::Input::TappedRoutedEventArgs^ Event);
void Cell_RightClicked(Platform::Object^ Sender, Windows::UI::Xaml::Input::RightTappedRoutedEventArgs^ Event);
void ResizeHandle_PointerEntered(Platform::Object^ Sender, Windows::UI::Xaml::Input::PointerRoutedEventArgs^ Event);
void ResizeHandle_PointerPressed(Platform::Object^ Sender, Windows::UI::Xaml::Input::PointerRoutedEventArgs^ Event);
void ResizeHandle_PointerReleased(Platform::Object^ Sender, Windows::UI::Xaml::Input::PointerRoutedEventArgs^ Event);
void ResizeHandle_PointerMoved(Platform::Object^ Sender, Windows::UI::Xaml::Input::PointerRoutedEventArgs^ Event);
void ResizeHandle_PointerExited(Platform::Object^ Sender, Windows::UI::Xaml::Input::PointerRoutedEventArgs^ Event);
Sort^ _SortMode;
Platform::Collections::Vector<Windows::UI::Xaml::Controls::ColumnDefinition^>^ _Columns;
Platform::Collections::Vector<Platform::String^>^ _ColumnsTitles;
Platform::Collections::Vector<Windows::UI::Xaml::Shapes::Rectangle^>^ _RowsBackgrounds;
Windows::Foundation::Collections::IVectorView<Platform::String^>^ _SelectedRow;
Platform::Collections::Vector<Windows::Foundation::Collections::IVectorView<Platform::String^>^>^ _Rows;
Platform::Collections::Vector<Windows::Foundation::Collections::IVectorView<Platform::String^>^>^ _SortedRows;
Windows::Foundation::Collections::IObservableVector<Windows::Foundation::Collections::IVectorView<Platform::String^>^>^ _OriginalRows; // keep this reference to unregister the VectorChanged token later
bool _Resizing;
uint16 _Pointer_Count;
Windows::UI::Core::CoreCursor^ _Old_Pointer;
Windows::Foundation::EventRegistrationToken _RowsVectorChangedToken;
};
}
|