Migrate aurora-sharp-desktop
This commit is contained in:
@ -0,0 +1,7 @@
|
||||
Label {
|
||||
margin-left: 25;
|
||||
text-align: left;
|
||||
vertical-align: middle;
|
||||
word-wrap: break-word;
|
||||
font-size: 14;
|
||||
}
|
@ -0,0 +1,99 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<ContentView
|
||||
xmlns="http://xamarin.com/schemas/2014/forms"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
|
||||
xmlns:dg="clr-namespace:Aurora.Design.Components.DataGrid"
|
||||
x:Class="Aurora.Design.Components.Library.Library">
|
||||
<ContentView.Resources>
|
||||
<StyleSheet
|
||||
Source="Library.css"/>
|
||||
</ContentView.Resources>
|
||||
<ContentView.Content>
|
||||
<dg:DataGrid
|
||||
x:Name="LibraryDataGrid"
|
||||
SelectionEnabled="True"
|
||||
RowHeight="30"
|
||||
BorderColor="#181818"
|
||||
BorderThickness="0"
|
||||
HeaderHeight="45"
|
||||
HeaderBackground="#181818">
|
||||
<dg:DataGrid.HeaderLabelStyle>
|
||||
<Style
|
||||
TargetType="Label">
|
||||
<Setter
|
||||
Property="HorizontalOptions"
|
||||
Value="Start"/>
|
||||
<Setter
|
||||
Property="FontSize"
|
||||
Value="14"/>
|
||||
<Setter
|
||||
Property="TextColor"
|
||||
Value="White"/>
|
||||
</Style>
|
||||
</dg:DataGrid.HeaderLabelStyle>
|
||||
<dg:DataGrid.GestureRecognizers>
|
||||
<TapGestureRecognizer
|
||||
NumberOfTapsRequired="2"/>
|
||||
</dg:DataGrid.GestureRecognizers>
|
||||
<dg:DataGrid.Columns>
|
||||
<dg:DataGridColumn
|
||||
Title=""
|
||||
PropertyName="Icon"
|
||||
Width="15">
|
||||
<dg:DataGridColumn.CellTemplate>
|
||||
<DataTemplate>
|
||||
<Image
|
||||
Source="../../Resources/unselected.png"/>
|
||||
</DataTemplate>
|
||||
</dg:DataGridColumn.CellTemplate>
|
||||
</dg:DataGridColumn>
|
||||
<dg:DataGridColumn
|
||||
Title="Title"
|
||||
PropertyName="Metadata.Title"
|
||||
Width="2*">
|
||||
<dg:DataGridColumn.CellTemplate>
|
||||
<DataTemplate>
|
||||
<Label
|
||||
LineBreakMode="TailTruncation"
|
||||
Text="{Binding .}"/>
|
||||
</DataTemplate>
|
||||
</dg:DataGridColumn.CellTemplate>
|
||||
</dg:DataGridColumn>
|
||||
<dg:DataGridColumn
|
||||
Title="Album"
|
||||
PropertyName="Metadata.Album"
|
||||
Width="0.95*">
|
||||
<dg:DataGridColumn.CellTemplate>
|
||||
<DataTemplate>
|
||||
<Label
|
||||
LineBreakMode="TailTruncation"
|
||||
Text="{Binding .}"/>
|
||||
</DataTemplate>
|
||||
</dg:DataGridColumn.CellTemplate>
|
||||
</dg:DataGridColumn>
|
||||
<dg:DataGridColumn
|
||||
Title="Artist"
|
||||
PropertyName="Metadata.Artist"
|
||||
Width="1*">
|
||||
<dg:DataGridColumn.CellTemplate>
|
||||
<DataTemplate>
|
||||
<Label
|
||||
LineBreakMode="TailTruncation"
|
||||
Text="{Binding .}"/>
|
||||
</DataTemplate>
|
||||
</dg:DataGridColumn.CellTemplate>
|
||||
</dg:DataGridColumn>
|
||||
</dg:DataGrid.Columns>
|
||||
<dg:DataGrid.RowsTextColorPalette>
|
||||
<dg:PaletteCollection>
|
||||
<Color>White</Color>
|
||||
</dg:PaletteCollection>
|
||||
</dg:DataGrid.RowsTextColorPalette>
|
||||
<dg:DataGrid.RowsBackgroundColorPalette>
|
||||
<dg:PaletteCollection>
|
||||
<Color>Transparent</Color>
|
||||
</dg:PaletteCollection>
|
||||
</dg:DataGrid.RowsBackgroundColorPalette>
|
||||
</dg:DataGrid>
|
||||
</ContentView.Content>
|
||||
</ContentView>
|
@ -0,0 +1,139 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using Xamarin.Forms;
|
||||
|
||||
namespace Aurora.Design.Components.Library
|
||||
{
|
||||
public partial class Library : ContentView
|
||||
{
|
||||
public Library()
|
||||
{
|
||||
InitializeComponent();
|
||||
this.LibraryDataGrid.ItemSelected += (sender, e) =>
|
||||
{
|
||||
this.SelectedItem = e.SelectedItem;
|
||||
};
|
||||
}
|
||||
|
||||
#region ItemsSource Property
|
||||
/// <summary>
|
||||
/// Bindable Property for the ItemsSource of the datagrid.
|
||||
/// </summary>
|
||||
/// <param name=""ItemsSource""></param>
|
||||
/// <param name="typeof(IEnumerable<object>"></param>
|
||||
/// <returns></returns>
|
||||
public static readonly BindableProperty ItemsSourceProperty =
|
||||
BindableProperty.Create(propertyName: "ItemsSource",
|
||||
returnType: typeof(IEnumerable<object>),
|
||||
declaringType: typeof(Library),
|
||||
defaultBindingMode: BindingMode.Default,
|
||||
propertyChanged: (BindableObject bindable, object oldValue, object newValue) =>
|
||||
{
|
||||
Library control = bindable as Library;
|
||||
control.LibraryDataGrid.ItemsSource = (IEnumerable<object>)newValue;
|
||||
});
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Backing property for the ItemsSource property.
|
||||
/// </summary>
|
||||
/// <value></value>
|
||||
public IEnumerable<object> ItemsSource
|
||||
{
|
||||
get
|
||||
{
|
||||
return (IEnumerable<object>)GetValue(ItemsSourceProperty);
|
||||
}
|
||||
set
|
||||
{
|
||||
SetValue(ItemsSourceProperty, value);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
#endregion ItemsSource Property
|
||||
|
||||
/// <summary>
|
||||
/// Bindable property for the selected item field on the datagrid.
|
||||
/// </summary>
|
||||
/// <param name=""SelectedItem""></param>
|
||||
/// <param name="typeof(BaseMetadata"></param>
|
||||
/// <returns></returns>
|
||||
public static readonly BindableProperty SelectedItemProperty =
|
||||
BindableProperty.Create(propertyName: "SelectedItem",
|
||||
returnType: typeof(object),
|
||||
declaringType: typeof(Library),
|
||||
defaultBindingMode: BindingMode.TwoWay);
|
||||
|
||||
/// <summary>
|
||||
/// Backing property for the SelectedItem property.
|
||||
/// </summary>
|
||||
/// <value></value>
|
||||
public object SelectedItem
|
||||
{
|
||||
get
|
||||
{
|
||||
return ((object)GetValue(SelectedItemProperty));
|
||||
}
|
||||
set
|
||||
{
|
||||
SetValue(SelectedItemProperty, value);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Bindable property for the item double clicked command
|
||||
/// </summary>
|
||||
/// <param name=""SelectedItem""></param>
|
||||
/// <param name="typeof(BaseMetadata"></param>
|
||||
/// <returns></returns>
|
||||
public static readonly BindableProperty ItemDoubleClickedProperty =
|
||||
BindableProperty.Create(propertyName: "ItemDoubleClicked",
|
||||
returnType: typeof(Command),
|
||||
declaringType: typeof(Library),
|
||||
propertyChanged: OnDoubleClickPropertyChanged);
|
||||
|
||||
/// <summary>
|
||||
/// Public backing property
|
||||
/// </summary>
|
||||
/// <value></value>
|
||||
public Command ItemDoubleClicked
|
||||
{
|
||||
get
|
||||
{
|
||||
return (Command)GetValue(ItemDoubleClickedProperty);
|
||||
}
|
||||
set
|
||||
{
|
||||
SetValue(ItemDoubleClickedProperty, value);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Event handler for double click property. Adds command execute handler.
|
||||
/// </summary>
|
||||
/// <param name="bindable"></param>
|
||||
/// <param name="newValue"></param>
|
||||
/// <param name="oldValue"></param>
|
||||
private static void OnDoubleClickPropertyChanged(BindableObject bindable, object newValue, object oldValue)
|
||||
{
|
||||
Library control = bindable as Library;
|
||||
var dataGrid = control.LibraryDataGrid;
|
||||
if (dataGrid.GestureRecognizers.Count > 0)
|
||||
{
|
||||
var gestureRecognizer = dataGrid.GestureRecognizers.First();
|
||||
|
||||
if (gestureRecognizer is TapGestureRecognizer)
|
||||
{
|
||||
TapGestureRecognizer tap = gestureRecognizer as TapGestureRecognizer;
|
||||
tap.Tapped += (sender, e) =>
|
||||
{
|
||||
control.ItemDoubleClicked.Execute(null);
|
||||
};
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user