Enable use of new VS extension with ControlCatalog by compiling XAML files as AvaloniaXaml (#19971)
Removed manual InitializeComponent definitions Replaced uses of Get, FindControl, etc. with generated fields
This commit is contained in:
@@ -9,9 +9,9 @@
|
||||
<Compile Update="**\*.xaml.cs">
|
||||
<DependentUpon>%(Filename)</DependentUpon>
|
||||
</Compile>
|
||||
<AvaloniaResource Include="**\*.xaml">
|
||||
<AvaloniaXaml Include="**\*.xaml">
|
||||
<SubType>Designer</SubType>
|
||||
</AvaloniaResource>
|
||||
</AvaloniaXaml>
|
||||
<AvaloniaResource Include="Assets\*" />
|
||||
<AvaloniaResource Include="Assets\Fonts\*" />
|
||||
</ItemGroup>
|
||||
|
||||
@@ -1,21 +1,39 @@
|
||||
using Avalonia;
|
||||
using Avalonia.Controls;
|
||||
using Avalonia.Markup.Xaml;
|
||||
using System;
|
||||
using Avalonia.Input;
|
||||
|
||||
namespace ControlCatalog
|
||||
{
|
||||
public class DecoratedWindow : Window
|
||||
public partial class DecoratedWindow : Window
|
||||
{
|
||||
public DecoratedWindow()
|
||||
{
|
||||
this.InitializeComponent();
|
||||
InitializeComponent();
|
||||
TitleBar.PointerPressed += (i, e) =>
|
||||
{
|
||||
BeginMoveDrag(e);
|
||||
};
|
||||
SetupSide(Left, StandardCursorType.LeftSide, WindowEdge.West);
|
||||
SetupSide(Right, StandardCursorType.RightSide, WindowEdge.East);
|
||||
SetupSide(Top, StandardCursorType.TopSide, WindowEdge.North);
|
||||
SetupSide(Bottom, StandardCursorType.BottomSide, WindowEdge.South);
|
||||
SetupSide(TopLeft, StandardCursorType.TopLeftCorner, WindowEdge.NorthWest);
|
||||
SetupSide(TopRight, StandardCursorType.TopRightCorner, WindowEdge.NorthEast);
|
||||
SetupSide(BottomLeft, StandardCursorType.BottomLeftCorner, WindowEdge.SouthWest);
|
||||
SetupSide(BottomRight, StandardCursorType.BottomRightCorner, WindowEdge.SouthEast);
|
||||
MinimizeButton.Click += delegate
|
||||
{ this.WindowState = WindowState.Minimized; };
|
||||
MaximizeButton.Click += delegate
|
||||
{
|
||||
WindowState = WindowState == WindowState.Maximized ? WindowState.Normal : WindowState.Maximized;
|
||||
};
|
||||
CloseButton.Click += delegate
|
||||
{
|
||||
Close();
|
||||
};
|
||||
}
|
||||
|
||||
void SetupSide(string name, StandardCursorType cursor, WindowEdge edge)
|
||||
private void SetupSide(Control ctl, StandardCursorType cursor, WindowEdge edge)
|
||||
{
|
||||
var ctl = this.Get<Control>(name);
|
||||
ctl.Cursor = new Cursor(cursor);
|
||||
ctl.PointerPressed += (i, e) =>
|
||||
{
|
||||
@@ -23,31 +41,5 @@ namespace ControlCatalog
|
||||
BeginResizeDrag(edge, e);
|
||||
};
|
||||
}
|
||||
|
||||
private void InitializeComponent()
|
||||
{
|
||||
AvaloniaXamlLoader.Load(this);
|
||||
this.Get<Control>("TitleBar").PointerPressed += (i, e) =>
|
||||
{
|
||||
BeginMoveDrag(e);
|
||||
};
|
||||
SetupSide("Left", StandardCursorType.LeftSide, WindowEdge.West);
|
||||
SetupSide("Right", StandardCursorType.RightSide, WindowEdge.East);
|
||||
SetupSide("Top", StandardCursorType.TopSide, WindowEdge.North);
|
||||
SetupSide("Bottom", StandardCursorType.BottomSide, WindowEdge.South);
|
||||
SetupSide("TopLeft", StandardCursorType.TopLeftCorner, WindowEdge.NorthWest);
|
||||
SetupSide("TopRight", StandardCursorType.TopRightCorner, WindowEdge.NorthEast);
|
||||
SetupSide("BottomLeft", StandardCursorType.BottomLeftCorner, WindowEdge.SouthWest);
|
||||
SetupSide("BottomRight", StandardCursorType.BottomRightCorner, WindowEdge.SouthEast);
|
||||
this.Get<Button>("MinimizeButton").Click += delegate { this.WindowState = WindowState.Minimized; };
|
||||
this.Get<Button>("MaximizeButton").Click += delegate
|
||||
{
|
||||
WindowState = WindowState == WindowState.Maximized ? WindowState.Normal : WindowState.Maximized;
|
||||
};
|
||||
this.Get<Button>("CloseButton").Click += delegate
|
||||
{
|
||||
Close();
|
||||
};
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
<UserControl x:Class="ControlCatalog.MainView"
|
||||
xmlns="https://github.com/avaloniaui"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||
xmlns:local="using:ControlCatalog"
|
||||
xmlns:controls="using:ControlSamples"
|
||||
xmlns:models="using:ControlCatalog.Models"
|
||||
xmlns:pages="using:ControlCatalog.Pages"
|
||||
@@ -210,33 +211,35 @@
|
||||
<StackPanel Width="152" Spacing="8">
|
||||
<ComboBox x:Name="Decorations"
|
||||
HorizontalAlignment="Stretch"
|
||||
SelectedIndex="0">
|
||||
SelectedIndex="0"
|
||||
SelectionChanged="Decorations_SelectionChanged">
|
||||
<ComboBox.Items>
|
||||
<SystemDecorations>None</SystemDecorations>
|
||||
<SystemDecorations>BorderOnly</SystemDecorations>
|
||||
<SystemDecorations>Full</SystemDecorations>
|
||||
</ComboBox.Items>
|
||||
</ComboBox>
|
||||
<ComboBox x:Name="ThemeVariants"
|
||||
HorizontalAlignment="Stretch"
|
||||
<ComboBox HorizontalAlignment="Stretch"
|
||||
DisplayMemberBinding="{Binding Key, x:DataType=ThemeVariant}"
|
||||
SelectedIndex="0">
|
||||
SelectedIndex="0"
|
||||
SelectionChanged="ThemeVariants_SelectionChanged">
|
||||
<ComboBox.Items>
|
||||
<ThemeVariant>Default</ThemeVariant>
|
||||
<ThemeVariant>Light</ThemeVariant>
|
||||
<ThemeVariant>Dark</ThemeVariant>
|
||||
</ComboBox.Items>
|
||||
</ComboBox>
|
||||
<ComboBox x:Name="Themes"
|
||||
HorizontalAlignment="Stretch"
|
||||
SelectedIndex="0">
|
||||
<ComboBox HorizontalAlignment="Stretch"
|
||||
SelectedItem="{x:Static local:App.CurrentTheme}"
|
||||
SelectionChanged="Themes_SelectionChanged">
|
||||
<ComboBox.Items>
|
||||
<models:CatalogTheme>Fluent</models:CatalogTheme>
|
||||
<models:CatalogTheme>Simple</models:CatalogTheme>
|
||||
</ComboBox.Items>
|
||||
</ComboBox>
|
||||
<ComboBox x:Name="TransparencyLevels"
|
||||
HorizontalAlignment="Stretch">
|
||||
<ComboBox HorizontalAlignment="Stretch"
|
||||
SelectedIndex="0"
|
||||
SelectionChanged="TransparencyLevels_SelectionChanged">
|
||||
<ComboBox.Items>
|
||||
<WindowTransparencyLevel>None</WindowTransparencyLevel>
|
||||
<WindowTransparencyLevel>Transparent</WindowTransparencyLevel>
|
||||
@@ -245,9 +248,9 @@
|
||||
<WindowTransparencyLevel>Mica</WindowTransparencyLevel>
|
||||
</ComboBox.Items>
|
||||
</ComboBox>
|
||||
<ComboBox x:Name="FlowDirection"
|
||||
HorizontalAlignment="Stretch"
|
||||
SelectedIndex="0">
|
||||
<ComboBox HorizontalAlignment="Stretch"
|
||||
SelectedIndex="0"
|
||||
SelectionChanged="FlowDirection_SelectionChanged">
|
||||
<ComboBox.Items>
|
||||
<FlowDirection>LeftToRight</FlowDirection>
|
||||
<FlowDirection>RightToLeft</FlowDirection>
|
||||
|
||||
@@ -1,102 +1,85 @@
|
||||
using System;
|
||||
using System.Collections;
|
||||
using System.Threading.Tasks;
|
||||
using Avalonia;
|
||||
using Avalonia.Controls;
|
||||
using Avalonia.Controls.ApplicationLifetimes;
|
||||
using Avalonia.LogicalTree;
|
||||
using Avalonia.Markup.Xaml;
|
||||
using Avalonia.Media;
|
||||
using Avalonia.Media.Immutable;
|
||||
using Avalonia.Platform;
|
||||
using Avalonia.VisualTree;
|
||||
using Avalonia.Styling;
|
||||
using ControlCatalog.Models;
|
||||
using ControlCatalog.Pages;
|
||||
using ControlCatalog.ViewModels;
|
||||
|
||||
namespace ControlCatalog
|
||||
{
|
||||
public class MainView : UserControl
|
||||
public partial class MainView : UserControl
|
||||
{
|
||||
private Action? _disposeTransparencySetters;
|
||||
|
||||
public MainView()
|
||||
{
|
||||
AvaloniaXamlLoader.Load(this);
|
||||
|
||||
var sideBar = this.Get<TabControl>("Sidebar");
|
||||
InitializeComponent();
|
||||
}
|
||||
|
||||
var themes = this.Get<ComboBox>("Themes");
|
||||
themes.SelectedItem = App.CurrentTheme;
|
||||
themes.SelectionChanged += (sender, e) =>
|
||||
private void Themes_SelectionChanged(object? sender, SelectionChangedEventArgs e)
|
||||
{
|
||||
if (e.AddedItems.Count > 0 && e.AddedItems[0] is CatalogTheme theme)
|
||||
{
|
||||
if (themes.SelectedItem is CatalogTheme theme)
|
||||
{
|
||||
App.SetCatalogThemes(theme);
|
||||
}
|
||||
};
|
||||
var themeVariants = this.Get<ComboBox>("ThemeVariants");
|
||||
themeVariants.SelectedItem = Application.Current!.RequestedThemeVariant;
|
||||
themeVariants.SelectionChanged += (sender, e) =>
|
||||
{
|
||||
if (themeVariants.SelectedItem is ThemeVariant themeVariant)
|
||||
{
|
||||
Application.Current!.RequestedThemeVariant = themeVariant;
|
||||
}
|
||||
};
|
||||
App.SetCatalogThemes(theme);
|
||||
}
|
||||
}
|
||||
|
||||
var flowDirections = this.Get<ComboBox>("FlowDirection");
|
||||
flowDirections.SelectionChanged += (sender, e) =>
|
||||
private void ThemeVariants_SelectionChanged(object? sender, SelectionChangedEventArgs e)
|
||||
{
|
||||
if (Application.Current is { } app && e.AddedItems.Count > 0 && e.AddedItems[0] is ThemeVariant themeVariant)
|
||||
{
|
||||
if (flowDirections.SelectedItem is FlowDirection flowDirection)
|
||||
{
|
||||
TopLevel.GetTopLevel(this)!.FlowDirection = flowDirection;
|
||||
}
|
||||
};
|
||||
app.RequestedThemeVariant = themeVariant;
|
||||
}
|
||||
}
|
||||
|
||||
var decorations = this.Get<ComboBox>("Decorations");
|
||||
decorations.SelectionChanged += (sender, e) =>
|
||||
private void FlowDirection_SelectionChanged(object? sender, SelectionChangedEventArgs e)
|
||||
{
|
||||
if (TopLevel.GetTopLevel(this) is { } topLevel && e.AddedItems.Count > 0 && e.AddedItems[0] is FlowDirection flowDirection)
|
||||
{
|
||||
if (VisualRoot is Window window
|
||||
&& decorations.SelectedItem is SystemDecorations systemDecorations)
|
||||
{
|
||||
window.SystemDecorations = systemDecorations;
|
||||
}
|
||||
};
|
||||
topLevel.FlowDirection = flowDirection;
|
||||
}
|
||||
}
|
||||
|
||||
var transparencyLevels = this.Get<ComboBox>("TransparencyLevels");
|
||||
IDisposable? topLevelBackgroundSideSetter = null, sideBarBackgroundSetter = null, paneBackgroundSetter = null;
|
||||
transparencyLevels.SelectionChanged += (sender, e) =>
|
||||
private void Decorations_SelectionChanged(object? sender, SelectionChangedEventArgs e)
|
||||
{
|
||||
if (VisualRoot is Window window && e.AddedItems.Count > 0 && e.AddedItems[0] is SystemDecorations systemDecorations)
|
||||
{
|
||||
topLevelBackgroundSideSetter?.Dispose();
|
||||
sideBarBackgroundSetter?.Dispose();
|
||||
paneBackgroundSetter?.Dispose();
|
||||
if (transparencyLevels.SelectedItem is WindowTransparencyLevel selected)
|
||||
{
|
||||
var topLevel = (TopLevel)this.GetVisualRoot()!;
|
||||
topLevel.TransparencyLevelHint = new[] { selected };
|
||||
window.SystemDecorations = systemDecorations;
|
||||
}
|
||||
}
|
||||
|
||||
if (topLevel.ActualTransparencyLevel != WindowTransparencyLevel.None &&
|
||||
topLevel.ActualTransparencyLevel == selected)
|
||||
{
|
||||
var transparentBrush = new ImmutableSolidColorBrush(Colors.White, 0);
|
||||
var semiTransparentBrush = new ImmutableSolidColorBrush(Colors.Gray, 0.2);
|
||||
topLevelBackgroundSideSetter = topLevel.SetValue(BackgroundProperty, transparentBrush, Avalonia.Data.BindingPriority.Style);
|
||||
sideBarBackgroundSetter = sideBar.SetValue(BackgroundProperty, semiTransparentBrush, Avalonia.Data.BindingPriority.Style);
|
||||
paneBackgroundSetter = sideBar.SetValue(SplitView.PaneBackgroundProperty, semiTransparentBrush, Avalonia.Data.BindingPriority.Style);
|
||||
}
|
||||
private void TransparencyLevels_SelectionChanged(object? sender, SelectionChangedEventArgs e)
|
||||
{
|
||||
_disposeTransparencySetters?.Invoke();
|
||||
|
||||
if (TopLevel.GetTopLevel(this) is { } topLevel && e.AddedItems.Count > 0 && e.AddedItems[0] is WindowTransparencyLevel transparencyLevel)
|
||||
{
|
||||
topLevel.TransparencyLevelHint = [transparencyLevel];
|
||||
|
||||
if (topLevel.ActualTransparencyLevel != WindowTransparencyLevel.None &&
|
||||
topLevel.ActualTransparencyLevel == transparencyLevel)
|
||||
{
|
||||
var transparentBrush = new ImmutableSolidColorBrush(Colors.White, 0);
|
||||
var semiTransparentBrush = new ImmutableSolidColorBrush(Colors.Gray, 0.2);
|
||||
_disposeTransparencySetters =
|
||||
(Action)topLevel.SetValue(BackgroundProperty, transparentBrush, Avalonia.Data.BindingPriority.Style)!.Dispose +
|
||||
Sidebar.SetValue(BackgroundProperty, semiTransparentBrush, Avalonia.Data.BindingPriority.Style)!.Dispose +
|
||||
Sidebar.SetValue(SplitView.PaneBackgroundProperty, semiTransparentBrush, Avalonia.Data.BindingPriority.Style)!.Dispose;
|
||||
}
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
internal MainWindowViewModel ViewModel => (MainWindowViewModel)DataContext!;
|
||||
|
||||
|
||||
protected override void OnAttachedToVisualTree(VisualTreeAttachmentEventArgs e)
|
||||
{
|
||||
base.OnAttachedToVisualTree(e);
|
||||
|
||||
var decorations = this.Get<ComboBox>("Decorations");
|
||||
if (VisualRoot is Window window)
|
||||
decorations.SelectedIndex = (int)window.SystemDecorations;
|
||||
Decorations.SelectedIndex = (int)window.SystemDecorations;
|
||||
|
||||
var insets = TopLevel.GetTopLevel(this)!.InsetsManager;
|
||||
if (insets != null)
|
||||
|
||||
@@ -13,7 +13,6 @@
|
||||
CanResize="{Binding CanResize}"
|
||||
CanMinimize="{Binding CanMinimize}"
|
||||
CanMaximize="{Binding CanMaximize}"
|
||||
x:Name="MainWindow"
|
||||
Background="Transparent"
|
||||
x:Class="ControlCatalog.MainWindow" WindowState="{Binding WindowState, Mode=TwoWay}"
|
||||
x:DataType="vm:MainWindowViewModel">
|
||||
@@ -59,8 +58,8 @@
|
||||
</DataTemplate>
|
||||
</Window.DataTemplates>
|
||||
<Panel>
|
||||
<Panel Margin="{Binding #MainWindow.OffScreenMargin}">
|
||||
<local:MainView Margin="{Binding #MainWindow.WindowDecorationMargin}" />
|
||||
<Panel Margin="{Binding $parent[local:MainWindow].OffScreenMargin}">
|
||||
<local:MainView Margin="{Binding $parent[local:MainWindow].WindowDecorationMargin}" />
|
||||
</Panel>
|
||||
<Border IsVisible="{Binding ExtendClientAreaEnabled}" BorderThickness="1 1 1 0" CornerRadius="4 4 0 0" BorderBrush="#55000000" Height="22" VerticalAlignment="Top" HorizontalAlignment="Left" Margin="250 8 0 0">
|
||||
<Border.Background>
|
||||
|
||||
@@ -1,21 +1,17 @@
|
||||
using System;
|
||||
using System.Runtime.InteropServices;
|
||||
using Avalonia;
|
||||
using Avalonia.Controls;
|
||||
using Avalonia.Controls.Notifications;
|
||||
using Avalonia.Input;
|
||||
using Avalonia.Markup.Xaml;
|
||||
using ControlCatalog.ViewModels;
|
||||
|
||||
namespace ControlCatalog
|
||||
{
|
||||
public class MainWindow : Window
|
||||
public partial class MainWindow : Window
|
||||
{
|
||||
private NativeMenu? _recentMenu;
|
||||
|
||||
public MainWindow()
|
||||
{
|
||||
this.InitializeComponent();
|
||||
InitializeComponent();
|
||||
|
||||
_recentMenu = ((NativeMenu.GetMenu(this)?.Items[0] as NativeMenuItem)?.Menu?.Items[2] as NativeMenuItem)?.Menu;
|
||||
}
|
||||
@@ -35,10 +31,5 @@ namespace ControlCatalog
|
||||
{
|
||||
Close();
|
||||
}
|
||||
|
||||
private void InitializeComponent()
|
||||
{
|
||||
AvaloniaXamlLoader.Load(this);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,18 +1,12 @@
|
||||
using Avalonia.Controls;
|
||||
using Avalonia.Markup.Xaml;
|
||||
|
||||
namespace ControlCatalog.Pages
|
||||
{
|
||||
public class AcceleratorPage : UserControl
|
||||
public partial class AcceleratorPage : UserControl
|
||||
{
|
||||
public AcceleratorPage()
|
||||
{
|
||||
this.InitializeComponent();
|
||||
}
|
||||
|
||||
private void InitializeComponent()
|
||||
{
|
||||
AvaloniaXamlLoader.Load(this);
|
||||
InitializeComponent();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,19 +1,12 @@
|
||||
using Avalonia;
|
||||
using Avalonia.Controls;
|
||||
using Avalonia.Markup.Xaml;
|
||||
using Avalonia.Controls;
|
||||
|
||||
namespace ControlCatalog.Pages
|
||||
{
|
||||
public class AcrylicPage : UserControl
|
||||
public partial class AcrylicPage : UserControl
|
||||
{
|
||||
public AcrylicPage()
|
||||
{
|
||||
this.InitializeComponent();
|
||||
}
|
||||
|
||||
private void InitializeComponent()
|
||||
{
|
||||
AvaloniaXamlLoader.Load(this);
|
||||
InitializeComponent();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,47 +1,33 @@
|
||||
using Avalonia.Controls;
|
||||
using Avalonia.Controls.Primitives;
|
||||
using Avalonia.Interactivity;
|
||||
using Avalonia.Markup.Xaml;
|
||||
|
||||
namespace ControlCatalog.Pages
|
||||
{
|
||||
public class AdornerLayerPage : UserControl
|
||||
public partial class AdornerLayerPage : UserControl
|
||||
{
|
||||
private Control? _adorner;
|
||||
|
||||
public AdornerLayerPage()
|
||||
{
|
||||
this.InitializeComponent();
|
||||
}
|
||||
|
||||
private void InitializeComponent()
|
||||
{
|
||||
AvaloniaXamlLoader.Load(this);
|
||||
InitializeComponent();
|
||||
}
|
||||
|
||||
private void RemoveAdorner_OnClick(object? sender, RoutedEventArgs e)
|
||||
{
|
||||
var adornerButton = this.FindControl<Button>("AdornerButton");
|
||||
if (adornerButton is { })
|
||||
var adorner = AdornerLayer.GetAdorner(AdornerButton);
|
||||
if (adorner is { })
|
||||
{
|
||||
var adorner = AdornerLayer.GetAdorner(adornerButton);
|
||||
if (adorner is { })
|
||||
{
|
||||
_adorner = adorner;
|
||||
}
|
||||
AdornerLayer.SetAdorner(adornerButton, null);
|
||||
_adorner = adorner;
|
||||
}
|
||||
AdornerLayer.SetAdorner(AdornerButton, null);
|
||||
}
|
||||
|
||||
private void AddAdorner_OnClick(object? sender, RoutedEventArgs e)
|
||||
{
|
||||
var adornerButton = this.FindControl<Button>("AdornerButton");
|
||||
if (adornerButton is { })
|
||||
if (_adorner is { })
|
||||
{
|
||||
if (_adorner is { })
|
||||
{
|
||||
AdornerLayer.SetAdorner(adornerButton, _adorner);
|
||||
}
|
||||
AdornerLayer.SetAdorner(AdornerButton, _adorner);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,18 +1,16 @@
|
||||
using Avalonia.Controls;
|
||||
using Avalonia.LogicalTree;
|
||||
using Avalonia.Markup.Xaml;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
using Avalonia.Data.Converters;
|
||||
using Avalonia.Controls;
|
||||
using Avalonia.Data;
|
||||
using ControlCatalog.Models;
|
||||
using Avalonia.Data.Converters;
|
||||
using Avalonia.LogicalTree;
|
||||
|
||||
namespace ControlCatalog.Pages
|
||||
{
|
||||
public class AutoCompleteBoxPage : UserControl
|
||||
public partial class AutoCompleteBoxPage : UserControl
|
||||
{
|
||||
public class StateData
|
||||
{
|
||||
@@ -90,7 +88,7 @@ namespace ControlCatalog.Pages
|
||||
};
|
||||
}
|
||||
public StateData[] States { get; private set; }
|
||||
|
||||
|
||||
private static LinkedList<string>[] BuildAllSentences()
|
||||
{
|
||||
return new string[]
|
||||
@@ -107,7 +105,7 @@ namespace ControlCatalog.Pages
|
||||
|
||||
public AutoCompleteBoxPage()
|
||||
{
|
||||
this.InitializeComponent();
|
||||
InitializeComponent();
|
||||
|
||||
States = BuildAllStates();
|
||||
Sentences = BuildAllSentences();
|
||||
@@ -125,16 +123,13 @@ namespace ControlCatalog.Pages
|
||||
binding.Bindings.Add(new Binding("Name"));
|
||||
binding.Bindings.Add(new Binding("Abbreviation"));
|
||||
|
||||
var multibindingBox = this.Get<AutoCompleteBox>("MultiBindingBox");
|
||||
multibindingBox.ValueMemberBinding = binding;
|
||||
MultiBindingBox.ValueMemberBinding = binding;
|
||||
|
||||
var asyncBox = this.Get<AutoCompleteBox>("AsyncBox");
|
||||
asyncBox.AsyncPopulator = PopulateAsync;
|
||||
AsyncBox.AsyncPopulator = PopulateAsync;
|
||||
|
||||
var customAutocompleteBox = this.Get<AutoCompleteBox>("CustomAutocompleteBox");
|
||||
customAutocompleteBox.ItemsSource = Sentences.SelectMany(x => x);
|
||||
customAutocompleteBox.TextFilter = LastWordContains;
|
||||
customAutocompleteBox.TextSelector = AppendWord;
|
||||
CustomAutocompleteBox.ItemsSource = Sentences.SelectMany(x => x);
|
||||
CustomAutocompleteBox.TextFilter = LastWordContains;
|
||||
CustomAutocompleteBox.TextSelector = AppendWord;
|
||||
}
|
||||
private IEnumerable<AutoCompleteBox> GetAllAutoCompleteBox()
|
||||
{
|
||||
@@ -145,7 +140,8 @@ namespace ControlCatalog.Pages
|
||||
|
||||
private static bool StringContains(string str, string? query)
|
||||
{
|
||||
if (query == null) return false;
|
||||
if (query == null)
|
||||
return false;
|
||||
return str.IndexOf(query, StringComparison.OrdinalIgnoreCase) >= 0;
|
||||
}
|
||||
private async Task<IEnumerable<object>> PopulateAsync(string? searchText, CancellationToken cancellationToken)
|
||||
@@ -196,10 +192,5 @@ namespace ControlCatalog.Pages
|
||||
}
|
||||
return string.Empty;
|
||||
}
|
||||
|
||||
private void InitializeComponent()
|
||||
{
|
||||
AvaloniaXamlLoader.Load(this);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,18 +1,12 @@
|
||||
using Avalonia.Controls;
|
||||
using Avalonia.Markup.Xaml;
|
||||
|
||||
namespace ControlCatalog.Pages
|
||||
{
|
||||
public class BorderPage : UserControl
|
||||
public partial class BorderPage : UserControl
|
||||
{
|
||||
public BorderPage()
|
||||
{
|
||||
this.InitializeComponent();
|
||||
}
|
||||
|
||||
private void InitializeComponent()
|
||||
{
|
||||
AvaloniaXamlLoader.Load(this);
|
||||
InitializeComponent();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,21 +1,13 @@
|
||||
using System;
|
||||
using Avalonia;
|
||||
using Avalonia.Controls;
|
||||
using Avalonia.Interactivity;
|
||||
using Avalonia.Markup.Xaml;
|
||||
|
||||
namespace ControlCatalog.Pages
|
||||
{
|
||||
public class ButtonSpinnerPage : UserControl
|
||||
public partial class ButtonSpinnerPage : UserControl
|
||||
{
|
||||
public ButtonSpinnerPage()
|
||||
{
|
||||
this.InitializeComponent();
|
||||
}
|
||||
|
||||
private void InitializeComponent()
|
||||
{
|
||||
AvaloniaXamlLoader.Load(this);
|
||||
InitializeComponent();
|
||||
}
|
||||
|
||||
public void OnSpin(object sender, SpinEventArgs e)
|
||||
|
||||
@@ -141,7 +141,7 @@
|
||||
Padding="15">
|
||||
<StackPanel Orientation="Vertical"
|
||||
Spacing="8">
|
||||
<RepeatButton Name="RepeatButton">
|
||||
<RepeatButton Name="RepeatButton" Click="OnRepeatButtonClick">
|
||||
<TextBlock Name="RepeatButtonTextBlock"
|
||||
Text="Repeat Button: 0" />
|
||||
</RepeatButton>
|
||||
|
||||
@@ -1,29 +1,21 @@
|
||||
using Avalonia.Controls;
|
||||
using Avalonia.Markup.Xaml;
|
||||
using Avalonia.Interactivity;
|
||||
|
||||
namespace ControlCatalog.Pages
|
||||
{
|
||||
public class ButtonsPage : UserControl
|
||||
public partial class ButtonsPage : UserControl
|
||||
{
|
||||
private int repeatButtonClickCount = 0;
|
||||
|
||||
public ButtonsPage()
|
||||
{
|
||||
InitializeComponent();
|
||||
|
||||
this.Get<RepeatButton>("RepeatButton").Click += OnRepeatButtonClick;
|
||||
}
|
||||
|
||||
private void InitializeComponent()
|
||||
{
|
||||
AvaloniaXamlLoader.Load(this);
|
||||
}
|
||||
|
||||
public void OnRepeatButtonClick(object? sender, object args)
|
||||
public void OnRepeatButtonClick(object? sender, RoutedEventArgs args)
|
||||
{
|
||||
repeatButtonClickCount++;
|
||||
var textBlock = this.Get<TextBlock>("RepeatButtonTextBlock");
|
||||
textBlock.Text = $"Repeat Button: {repeatButtonClickCount}";
|
||||
RepeatButtonTextBlock.Text = $"Repeat Button: {repeatButtonClickCount}";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,36 +1,23 @@
|
||||
using Avalonia.Controls;
|
||||
using Avalonia.Markup.Xaml;
|
||||
using System;
|
||||
using Avalonia.Controls;
|
||||
|
||||
namespace ControlCatalog.Pages
|
||||
{
|
||||
public class CalendarDatePickerPage : UserControl
|
||||
public partial class CalendarDatePickerPage : UserControl
|
||||
{
|
||||
public CalendarDatePickerPage()
|
||||
{
|
||||
InitializeComponent();
|
||||
|
||||
var dp1 = this.Get<CalendarDatePicker>("DatePicker1");
|
||||
var dp2 = this.Get<CalendarDatePicker>("DatePicker2");
|
||||
var dp3 = this.Get<CalendarDatePicker>("DatePicker3");
|
||||
var dp4 = this.Get<CalendarDatePicker>("DatePicker4");
|
||||
var dp5 = this.Get<CalendarDatePicker>("DatePicker5");
|
||||
|
||||
dp1.SelectedDate = DateTime.Today;
|
||||
dp2.SelectedDate = DateTime.Today.AddDays(10);
|
||||
dp3.SelectedDate = DateTime.Today.AddDays(20);
|
||||
dp5.SelectedDate = DateTime.Today;
|
||||
DatePicker1.SelectedDate = DateTime.Today;
|
||||
DatePicker2.SelectedDate = DateTime.Today.AddDays(10);
|
||||
DatePicker3.SelectedDate = DateTime.Today.AddDays(20);
|
||||
DatePicker5.SelectedDate = DateTime.Today;
|
||||
|
||||
dp4.TemplateApplied += (s, e) =>
|
||||
DatePicker4.TemplateApplied += (s, e) =>
|
||||
{
|
||||
dp4.BlackoutDates?.AddDatesInPast();
|
||||
DatePicker4.BlackoutDates?.AddDatesInPast();
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
private void InitializeComponent()
|
||||
{
|
||||
AvaloniaXamlLoader.Load(this);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,28 +1,20 @@
|
||||
using Avalonia.Controls;
|
||||
using Avalonia.Markup.Xaml;
|
||||
using System;
|
||||
using Avalonia.Controls;
|
||||
|
||||
namespace ControlCatalog.Pages
|
||||
{
|
||||
public class CalendarPage : UserControl
|
||||
public partial class CalendarPage : UserControl
|
||||
{
|
||||
public CalendarPage()
|
||||
{
|
||||
this.InitializeComponent();
|
||||
InitializeComponent();
|
||||
|
||||
var today = DateTime.Today;
|
||||
var cal1 = this.Get<Calendar>("DisplayDatesCalendar");
|
||||
cal1.DisplayDateStart = today.AddDays(-25);
|
||||
cal1.DisplayDateEnd = today.AddDays(25);
|
||||
var today = DateTime.Today;
|
||||
DisplayDatesCalendar.DisplayDateStart = today.AddDays(-25);
|
||||
DisplayDatesCalendar.DisplayDateEnd = today.AddDays(25);
|
||||
|
||||
var cal2 = this.Get<Calendar>("BlackoutDatesCalendar");
|
||||
cal2.BlackoutDates.AddDatesInPast();
|
||||
cal2.BlackoutDates.Add(new CalendarDateRange(today.AddDays(6)));
|
||||
}
|
||||
|
||||
private void InitializeComponent()
|
||||
{
|
||||
AvaloniaXamlLoader.Load(this);
|
||||
BlackoutDatesCalendar.BlackoutDates.AddDatesInPast();
|
||||
BlackoutDatesCalendar.BlackoutDates.Add(new CalendarDateRange(today.AddDays(6)));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,18 +1,12 @@
|
||||
using Avalonia.Controls;
|
||||
using Avalonia.Markup.Xaml;
|
||||
|
||||
namespace ControlCatalog.Pages
|
||||
{
|
||||
public class CanvasPage : UserControl
|
||||
public partial class CanvasPage : UserControl
|
||||
{
|
||||
public CanvasPage()
|
||||
{
|
||||
this.InitializeComponent();
|
||||
}
|
||||
|
||||
private void InitializeComponent()
|
||||
{
|
||||
AvaloniaXamlLoader.Load(this);
|
||||
InitializeComponent();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,53 +1,35 @@
|
||||
using System;
|
||||
using Avalonia.Animation;
|
||||
using Avalonia.Controls;
|
||||
using Avalonia.Markup.Xaml;
|
||||
|
||||
namespace ControlCatalog.Pages
|
||||
{
|
||||
public class CarouselPage : UserControl
|
||||
public partial class CarouselPage : UserControl
|
||||
{
|
||||
private Carousel _carousel;
|
||||
private Button _left;
|
||||
private Button _right;
|
||||
private ComboBox _transition;
|
||||
private ComboBox _orientation;
|
||||
|
||||
public CarouselPage()
|
||||
{
|
||||
this.InitializeComponent();
|
||||
_carousel = this.Get<Carousel>("carousel");
|
||||
_left = this.Get<Button>("left");
|
||||
_right = this.Get<Button>("right");
|
||||
_transition = this.Get<ComboBox>("transition");
|
||||
_orientation = this.Get<ComboBox>("orientation");
|
||||
_left.Click += (s, e) => _carousel.Previous();
|
||||
_right.Click += (s, e) => _carousel.Next();
|
||||
_transition.SelectionChanged += TransitionChanged;
|
||||
_orientation.SelectionChanged += TransitionChanged;
|
||||
}
|
||||
|
||||
private void InitializeComponent()
|
||||
{
|
||||
AvaloniaXamlLoader.Load(this);
|
||||
|
||||
InitializeComponent();
|
||||
left.Click += (s, e) => carousel.Previous();
|
||||
right.Click += (s, e) => carousel.Next();
|
||||
transition.SelectionChanged += TransitionChanged;
|
||||
orientation.SelectionChanged += TransitionChanged;
|
||||
}
|
||||
|
||||
private void TransitionChanged(object? sender, SelectionChangedEventArgs e)
|
||||
{
|
||||
switch (_transition.SelectedIndex)
|
||||
switch (transition.SelectedIndex)
|
||||
{
|
||||
case 0:
|
||||
_carousel.PageTransition = null;
|
||||
carousel.PageTransition = null;
|
||||
break;
|
||||
case 1:
|
||||
_carousel.PageTransition = new PageSlide(TimeSpan.FromSeconds(0.25), _orientation.SelectedIndex == 0 ? PageSlide.SlideAxis.Horizontal : PageSlide.SlideAxis.Vertical);
|
||||
carousel.PageTransition = new PageSlide(TimeSpan.FromSeconds(0.25), orientation.SelectedIndex == 0 ? PageSlide.SlideAxis.Horizontal : PageSlide.SlideAxis.Vertical);
|
||||
break;
|
||||
case 2:
|
||||
_carousel.PageTransition = new CrossFade(TimeSpan.FromSeconds(0.25));
|
||||
carousel.PageTransition = new CrossFade(TimeSpan.FromSeconds(0.25));
|
||||
break;
|
||||
case 3:
|
||||
_carousel.PageTransition = new Rotate3DTransition(TimeSpan.FromSeconds(0.5), _orientation.SelectedIndex == 0 ? PageSlide.SlideAxis.Horizontal : PageSlide.SlideAxis.Vertical);
|
||||
carousel.PageTransition = new Rotate3DTransition(TimeSpan.FromSeconds(0.5), orientation.SelectedIndex == 0 ? PageSlide.SlideAxis.Horizontal : PageSlide.SlideAxis.Vertical);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,18 +1,12 @@
|
||||
using Avalonia.Controls;
|
||||
using Avalonia.Markup.Xaml;
|
||||
|
||||
namespace ControlCatalog.Pages
|
||||
{
|
||||
public class CheckBoxPage : UserControl
|
||||
public partial class CheckBoxPage : UserControl
|
||||
{
|
||||
public CheckBoxPage()
|
||||
{
|
||||
this.InitializeComponent();
|
||||
}
|
||||
|
||||
private void InitializeComponent()
|
||||
{
|
||||
AvaloniaXamlLoader.Load(this);
|
||||
InitializeComponent();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3,12 +3,10 @@ using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using Avalonia;
|
||||
using Avalonia.Controls;
|
||||
using Avalonia.Controls.Documents;
|
||||
using Avalonia.Controls.Notifications;
|
||||
using Avalonia.Input;
|
||||
using Avalonia.Input.Platform;
|
||||
using Avalonia.Interactivity;
|
||||
using Avalonia.Markup.Xaml;
|
||||
using Avalonia.Media;
|
||||
using Avalonia.Platform.Storage;
|
||||
using Avalonia.Threading;
|
||||
@@ -28,16 +26,9 @@ namespace ControlCatalog.Pages
|
||||
private DataTransfer? _storedDataTransfer;
|
||||
public ClipboardPage()
|
||||
{
|
||||
InitializeComponent();
|
||||
_clipboardLastDataObjectChecker =
|
||||
new DispatcherTimer(TimeSpan.FromSeconds(0.5), default, CheckLastDataObject);
|
||||
InitializeComponent();
|
||||
}
|
||||
|
||||
private TextBox ClipboardContent => this.Get<TextBox>("ClipboardContent");
|
||||
|
||||
private void InitializeComponent()
|
||||
{
|
||||
AvaloniaXamlLoader.Load(this);
|
||||
}
|
||||
|
||||
private async void CopyText(object? sender, RoutedEventArgs args)
|
||||
@@ -163,11 +154,10 @@ namespace ControlCatalog.Pages
|
||||
base.OnDetachedFromVisualTree(e);
|
||||
}
|
||||
|
||||
private Run OwnsClipboardDataObject => this.Get<Run>("OwnsClipboardDataObject");
|
||||
private bool _checkingClipboardDataTransfer;
|
||||
private async void CheckLastDataObject(object? sender, EventArgs e)
|
||||
{
|
||||
if(_checkingClipboardDataTransfer)
|
||||
if (_checkingClipboardDataTransfer)
|
||||
return;
|
||||
try
|
||||
{
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
using Avalonia;
|
||||
using Avalonia.Controls;
|
||||
using Avalonia.Layout;
|
||||
using Avalonia.Markup.Xaml;
|
||||
using Avalonia.Media;
|
||||
|
||||
namespace ControlCatalog.Pages
|
||||
@@ -12,8 +11,6 @@ namespace ControlCatalog.Pages
|
||||
{
|
||||
InitializeComponent();
|
||||
|
||||
var layoutRoot = this.GetControl<Grid>("LayoutRoot");
|
||||
|
||||
// ColorPicker added from code-behind
|
||||
var colorPicker = new ColorPicker()
|
||||
{
|
||||
@@ -24,13 +21,8 @@ namespace ControlCatalog.Pages
|
||||
};
|
||||
Grid.SetColumn(colorPicker, 2);
|
||||
Grid.SetRow(colorPicker, 1);
|
||||
|
||||
layoutRoot.Children.Add(colorPicker);
|
||||
}
|
||||
|
||||
private void InitializeComponent()
|
||||
{
|
||||
AvaloniaXamlLoader.Load(this);
|
||||
LayoutRoot.Children.Add(colorPicker);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,25 +1,17 @@
|
||||
using System.Linq;
|
||||
using Avalonia.Controls;
|
||||
using Avalonia.Markup.Xaml;
|
||||
using Avalonia.Media;
|
||||
using ControlCatalog.ViewModels;
|
||||
|
||||
namespace ControlCatalog.Pages
|
||||
{
|
||||
public class ComboBoxPage : UserControl
|
||||
public partial class ComboBoxPage : UserControl
|
||||
{
|
||||
public ComboBoxPage()
|
||||
{
|
||||
this.InitializeComponent();
|
||||
DataContext = new ComboBoxPageViewModel();
|
||||
}
|
||||
|
||||
private void InitializeComponent()
|
||||
{
|
||||
AvaloniaXamlLoader.Load(this);
|
||||
var fontComboBox = this.Get<ComboBox>("fontComboBox");
|
||||
InitializeComponent();
|
||||
fontComboBox.ItemsSource = FontManager.Current.SystemFonts;
|
||||
fontComboBox.SelectedIndex = 0;
|
||||
DataContext = new ComboBoxPageViewModel();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -6,7 +6,6 @@ using Avalonia;
|
||||
using Avalonia.Animation;
|
||||
using Avalonia.Controls;
|
||||
using Avalonia.Interactivity;
|
||||
using Avalonia.Markup.Xaml;
|
||||
using Avalonia.Media;
|
||||
using Avalonia.Media.Immutable;
|
||||
using Avalonia.Rendering.Composition;
|
||||
@@ -25,15 +24,14 @@ public partial class CompositionPage : UserControl
|
||||
public CompositionPage()
|
||||
{
|
||||
InitializeComponent();
|
||||
AttachAnimatedSolidVisual(this.FindControl<Control>("SolidVisualHost")!);
|
||||
AttachCustomVisual(this.FindControl<Control>("CustomVisualHost")!);
|
||||
AttachAnimatedSolidVisual(SolidVisualHost);
|
||||
AttachCustomVisual(CustomVisualHost);
|
||||
}
|
||||
|
||||
protected override void OnAttachedToVisualTree(VisualTreeAttachmentEventArgs e)
|
||||
{
|
||||
base.OnAttachedToVisualTree(e);
|
||||
this.Get<ItemsControl>("Items").ItemsSource = CreateColorItems();
|
||||
|
||||
Items.ItemsSource = CreateColorItems();
|
||||
}
|
||||
|
||||
private static List<CompositionPageColorItem> CreateColorItems()
|
||||
|
||||
@@ -1,18 +1,12 @@
|
||||
using Avalonia.Controls;
|
||||
using Avalonia.Markup.Xaml;
|
||||
|
||||
namespace ControlCatalog.Pages
|
||||
{
|
||||
public class ContainerQueryPage : UserControl
|
||||
public partial class ContainerQueryPage : UserControl
|
||||
{
|
||||
public ContainerQueryPage()
|
||||
{
|
||||
this.InitializeComponent();
|
||||
}
|
||||
|
||||
private void InitializeComponent()
|
||||
{
|
||||
AvaloniaXamlLoader.Load(this);
|
||||
InitializeComponent();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -72,16 +72,17 @@
|
||||
<TextBlock Text="Dynamically Generated"/>
|
||||
</Border>
|
||||
<Border x:Name="CustomContextRequestedBorder"
|
||||
Classes="context-target">
|
||||
Classes="context-target"
|
||||
ContextRequested="CustomContextRequested">
|
||||
<Border.ContextFlyout>
|
||||
<Flyout Content="Should never be visible" />
|
||||
</Border.ContextFlyout>
|
||||
<TextBlock Text="Custom ContextRequested handler" TextWrapping="Wrap" />
|
||||
</Border>
|
||||
<Border x:Name="CancellableContextBorder"
|
||||
Classes="context-target">
|
||||
Classes="context-target">
|
||||
<Border.ContextFlyout>
|
||||
<Flyout>
|
||||
<Flyout Opening="ContextFlyoutPage_Opening" Closing="ContextFlyoutPage_Closing">
|
||||
<CheckBox x:Name="CancelCloseCheckBox" Content="Cancel close" />
|
||||
</Flyout>
|
||||
</Border.ContextFlyout>
|
||||
@@ -114,28 +115,28 @@
|
||||
<Setter Property="Opacity" Value="0.5" />
|
||||
</Style>
|
||||
</StackPanel.Styles>
|
||||
<Button Name="CutButton"
|
||||
<Button Click="CloseFlyout"
|
||||
Command="{Binding $parent[TextBox].Cut}"
|
||||
IsEnabled="{Binding $parent[TextBox].CanCut}">
|
||||
<PathIcon Width="14"
|
||||
Height="14"
|
||||
Data="M5.22774,2.08072 C5.43359778,1.94704 5.7011484,1.98419259 5.86368634,2.15675215 L5.91939,2.22774 L12.5191,12.3904 C12.956,12.1419 13.4614,12.0000019 14,12.0000019 C15.6569,12.0000019 17,13.3431 17,15.0000019 C17,16.6569 15.6569,18.0000019 14,18.0000019 C12.3431,18.0000019 11,16.6569 11,15.0000019 C11,14.3201402 11.226152,13.693011 11.6073785,13.1899092 L11.7401,13.0269 L10,10.3474 L8.25991,13.0269 C8.72078,13.5543 9,14.2446 9,15.0000019 C9,16.6569 7.65685,18.0000019 6,18.0000019 C4.34315,18.0000019 3,16.6569 3,15.0000019 C3,13.3431 4.34315,12.0000019 6,12.0000019 C6.46163143,12.0000019 6.89890041,12.1042536 7.28955831,12.2905296 L7.4809,12.3904 L9.40382,9.42936 L5.08072,2.77238 C4.93033,2.54079 4.99615,2.23112 5.22774,2.08072 Z M14,13 C12.8954,13 12,13.8954 12,15 C12,16.1046 12.8954,17 14,17 C15.1046,17 16,16.1046 16,15 C16,13.8954 15.1046,13 14,13 Z M6,13 C4.89543,13 4,13.8954 4,15 C4,16.1046 4.89543,17 6,17 C7.10457,17 8,16.1046 8,15 C8,13.8954 7.10457,13 6,13 Z M14.7723,2.08072 C15.0039,2.23112 15.0697,2.54079 14.9193,2.77238 L11.1924,8.51133 L10.5962,7.59329 L14.0806,2.22774 C14.231,1.99615 14.5407,1.93033 14.7723,2.08072 Z" />
|
||||
</Button>
|
||||
<Button Name="CopyButton"
|
||||
<Button Click="CloseFlyout"
|
||||
Command="{Binding $parent[TextBox].Copy}"
|
||||
IsEnabled="{Binding $parent[TextBox].CanCopy}">
|
||||
<PathIcon Width="14"
|
||||
Height="14"
|
||||
Data="M5.50280381,4.62704038 L5.5,6.75 L5.5,17.2542087 C5.5,19.0491342 6.95507456,20.5042087 8.75,20.5042087 L17.3662868,20.5044622 C17.057338,21.3782241 16.2239751,22.0042087 15.2444057,22.0042087 L8.75,22.0042087 C6.12664744,22.0042087 4,19.8775613 4,17.2542087 L4,6.75 C4,5.76928848 4.62744523,4.93512464 5.50280381,4.62704038 Z M17.75,2 C18.9926407,2 20,3.00735931 20,4.25 L20,17.25 C20,18.4926407 18.9926407,19.5 17.75,19.5 L8.75,19.5 C7.50735931,19.5 6.5,18.4926407 6.5,17.25 L6.5,4.25 C6.5,3.00735931 7.50735931,2 8.75,2 L17.75,2 Z M17.75,3.5 L8.75,3.5 C8.33578644,3.5 8,3.83578644 8,4.25 L8,17.25 C8,17.6642136 8.33578644,18 8.75,18 L17.75,18 C18.1642136,18 18.5,17.6642136 18.5,17.25 L18.5,4.25 C18.5,3.83578644 18.1642136,3.5 17.75,3.5 Z" />
|
||||
</Button>
|
||||
<Button Name="PasteButton"
|
||||
<Button Click="CloseFlyout"
|
||||
Command="{Binding $parent[TextBox].Paste}"
|
||||
IsEnabled="{Binding $parent[TextBox].CanPaste}">
|
||||
<PathIcon Width="14"
|
||||
Height="14"
|
||||
Data="M13.75,2 C14.940864,2 15.9156449,2.92516159 15.9948092,4.09595119 L16,4.25 L16,4.25 C16,4.16530567 15.9953205,4.0817043 15.9862059,3.99944035 L17.75,4 C18.9926407,4 20,5.00735931 20,6.25 L20,19.75 C20,20.9926407 18.9926407,22 17.75,22 L6.25,22 C5.00735931,22 4,20.9926407 4,19.75 L4,6.25 C4,5.00735931 5.00735931,4 6.25,4 L8.01379413,3.99944035 C8.00733496,4.05773764 8.00310309,4.11670658 8.00118552,4.17626017 L8,4.25 C8,3.00735931 9.00735931,2 10.25,2 L13.75,2 Z M13.75,6.5 L10.25,6.5 C9.45594921,6.5 8.75796956,6.08867052 8.357512,5.4674625 L8.37902077,5.50019943 L8.37902077,5.50019943 L6.25,5.5 C5.83578644,5.5 5.5,5.83578644 5.5,6.25 L5.5,19.75 C5.5,20.1642136 5.83578644,20.5 6.25,20.5 L17.75,20.5 C18.1642136,20.5 18.5,20.1642136 18.5,19.75 L18.5,6.25 C18.5,5.83578644 18.1642136,5.5 17.75,5.5 L15.6209792,5.50019943 L15.642488,5.4674625 C15.2420304,6.08867052 14.5440508,6.5 13.75,6.5 Z M13.75,3.5 L10.25,3.5 C9.83578644,3.5 9.5,3.83578644 9.5,4.25 C9.5,4.66421356 9.83578644,5 10.25,5 L13.75,5 C14.1642136,5 14.5,4.66421356 14.5,4.25 C14.5,3.83578644 14.1642136,3.5 13.75,3.5 Z" />
|
||||
</Button>
|
||||
<Button Name="ClearButton" Command="{Binding $parent[TextBox].Clear}">
|
||||
<Button Click="CloseFlyout" Command="{Binding $parent[TextBox].Clear}">
|
||||
<PathIcon Width="14"
|
||||
Height="14"
|
||||
Data="M3.52499419,3.71761187 L3.61611652,3.61611652 C4.0717282,3.16050485 4.79154862,3.13013074 5.28238813,3.52499419 L5.38388348,3.61611652 L14,12.233 L22.6161165,3.61611652 C23.1042719,3.12796116 23.8957281,3.12796116 24.3838835,3.61611652 C24.8720388,4.10427189 24.8720388,4.89572811 24.3838835,5.38388348 L15.767,14 L24.3838835,22.6161165 C24.8394952,23.0717282 24.8698693,23.7915486 24.4750058,24.2823881 L24.3838835,24.3838835 C23.9282718,24.8394952 23.2084514,24.8698693 22.7176119,24.4750058 L22.6161165,24.3838835 L14,15.767 L5.38388348,24.3838835 C4.89572811,24.8720388 4.10427189,24.8720388 3.61611652,24.3838835 C3.12796116,23.8957281 3.12796116,23.1042719 3.61611652,22.6161165 L12.233,14 L3.61611652,5.38388348 C3.16050485,4.9282718 3.13013074,4.20845138 3.52499419,3.71761187 L3.61611652,3.61611652 L3.52499419,3.71761187 Z" />
|
||||
|
||||
@@ -1,44 +1,17 @@
|
||||
using Avalonia;
|
||||
using Avalonia.Controls;
|
||||
using Avalonia.Markup.Xaml;
|
||||
using ControlCatalog.ViewModels;
|
||||
using Avalonia.Interactivity;
|
||||
using System;
|
||||
using System.ComponentModel;
|
||||
using Avalonia.Controls;
|
||||
using Avalonia.Interactivity;
|
||||
using ControlCatalog.ViewModels;
|
||||
|
||||
namespace ControlCatalog.Pages
|
||||
{
|
||||
public class ContextFlyoutPage : UserControl
|
||||
public partial class ContextFlyoutPage : UserControl
|
||||
{
|
||||
private TextBox _textBox;
|
||||
|
||||
public ContextFlyoutPage()
|
||||
{
|
||||
InitializeComponent();
|
||||
|
||||
DataContext = new ContextPageViewModel();
|
||||
|
||||
_textBox = this.Get<TextBox>("TextBox");
|
||||
|
||||
var cutButton = this.Get<Button>("CutButton");
|
||||
cutButton.Click += CloseFlyout;
|
||||
|
||||
var copyButton = this.Get<Button>("CopyButton");
|
||||
copyButton.Click += CloseFlyout;
|
||||
|
||||
var pasteButton = this.Get<Button>("PasteButton");
|
||||
pasteButton.Click += CloseFlyout;
|
||||
|
||||
var clearButton = this.Get<Button>("ClearButton");
|
||||
clearButton.Click += CloseFlyout;
|
||||
|
||||
var customContextRequestedBorder = this.Get<Border>("CustomContextRequestedBorder");
|
||||
customContextRequestedBorder.AddHandler(ContextRequestedEvent, CustomContextRequested, RoutingStrategies.Tunnel);
|
||||
|
||||
var cancellableContextBorder = this.Get<Border>("CancellableContextBorder");
|
||||
var flyout = (Flyout)cancellableContextBorder.ContextFlyout!;
|
||||
flyout.Closing += ContextFlyoutPage_Closing;
|
||||
flyout.Opening += ContextFlyoutPage_Opening;
|
||||
}
|
||||
|
||||
private ContextPageViewModel? _model;
|
||||
@@ -55,22 +28,20 @@ namespace ControlCatalog.Pages
|
||||
|
||||
private void ContextFlyoutPage_Closing(object? sender, CancelEventArgs e)
|
||||
{
|
||||
var cancelCloseCheckBox = this.FindControl<CheckBox>("CancelCloseCheckBox");
|
||||
e.Cancel = cancelCloseCheckBox?.IsChecked ?? false;
|
||||
e.Cancel = CancelCloseCheckBox?.IsChecked ?? false;
|
||||
}
|
||||
|
||||
private void ContextFlyoutPage_Opening(object? sender, EventArgs e)
|
||||
{
|
||||
if (e is CancelEventArgs cancelArgs)
|
||||
{
|
||||
var cancelCloseCheckBox = this.FindControl<CheckBox>("CancelOpenCheckBox");
|
||||
cancelArgs.Cancel = cancelCloseCheckBox?.IsChecked ?? false;
|
||||
cancelArgs.Cancel = CancelCloseCheckBox?.IsChecked ?? false;
|
||||
}
|
||||
}
|
||||
|
||||
private void CloseFlyout(object? sender, RoutedEventArgs e)
|
||||
{
|
||||
_textBox.ContextFlyout?.Hide();
|
||||
TextBox.ContextFlyout?.Hide();
|
||||
}
|
||||
|
||||
public void CustomContextRequested(object? sender, ContextRequestedEventArgs e)
|
||||
@@ -83,10 +54,5 @@ namespace ControlCatalog.Pages
|
||||
e.Handled = true;
|
||||
}
|
||||
}
|
||||
|
||||
private void InitializeComponent()
|
||||
{
|
||||
AvaloniaXamlLoader.Load(this);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -61,7 +61,7 @@
|
||||
</Border.ContextMenu>
|
||||
<TextBlock Text="Dynamically Generated"/>
|
||||
</Border>
|
||||
<Border x:Name="CustomContextRequestedBorder">
|
||||
<Border x:Name="CustomContextRequestedBorder" ContextRequested="CustomContextRequested">
|
||||
<Border.ContextMenu>
|
||||
<ContextMenu>
|
||||
<MenuItem Header="Should never be visible" />
|
||||
@@ -71,7 +71,7 @@
|
||||
</Border>
|
||||
<Border x:Name="CancellableContextBorder">
|
||||
<Border.ContextMenu>
|
||||
<ContextMenu>
|
||||
<ContextMenu Opening="ContextFlyoutPage_Opening" Closing="ContextFlyoutPage_Closing">
|
||||
<MenuItem>
|
||||
<MenuItem.Header>
|
||||
<CheckBox x:Name="CancelCloseCheckBox" Content="Cancel close" />
|
||||
|
||||
@@ -1,26 +1,16 @@
|
||||
using System;
|
||||
using System.ComponentModel;
|
||||
|
||||
using Avalonia.Controls;
|
||||
using Avalonia.Interactivity;
|
||||
using Avalonia.Markup.Xaml;
|
||||
using ControlCatalog.ViewModels;
|
||||
|
||||
namespace ControlCatalog.Pages
|
||||
{
|
||||
public class ContextMenuPage : UserControl
|
||||
public partial class ContextMenuPage : UserControl
|
||||
{
|
||||
public ContextMenuPage()
|
||||
{
|
||||
this.InitializeComponent();
|
||||
InitializeComponent();
|
||||
DataContext = new ContextPageViewModel();
|
||||
|
||||
var customContextRequestedBorder = this.Get<Border>("CustomContextRequestedBorder");
|
||||
customContextRequestedBorder.AddHandler(ContextRequestedEvent, CustomContextRequested, RoutingStrategies.Tunnel);
|
||||
|
||||
var cancellableContextBorder = this.Get<Border>("CancellableContextBorder");
|
||||
cancellableContextBorder.ContextMenu!.Closing += ContextFlyoutPage_Closing;
|
||||
cancellableContextBorder.ContextMenu!.Opening += ContextFlyoutPage_Opening;
|
||||
}
|
||||
|
||||
private ContextPageViewModel? _model;
|
||||
@@ -28,7 +18,7 @@ namespace ControlCatalog.Pages
|
||||
{
|
||||
if (_model != null)
|
||||
_model.View = null;
|
||||
_model = DataContext as ContextPageViewModel;
|
||||
_model = DataContext as ContextPageViewModel;
|
||||
if (_model != null)
|
||||
_model.View = this;
|
||||
|
||||
@@ -37,17 +27,12 @@ namespace ControlCatalog.Pages
|
||||
|
||||
private void ContextFlyoutPage_Closing(object? sender, CancelEventArgs e)
|
||||
{
|
||||
var cancelCloseCheckBox = this.FindControl<CheckBox>("CancelCloseCheckBox");
|
||||
e.Cancel = cancelCloseCheckBox?.IsChecked ?? false;
|
||||
e.Cancel = CancelCloseCheckBox?.IsChecked ?? false;
|
||||
}
|
||||
|
||||
private void ContextFlyoutPage_Opening(object? sender, EventArgs e)
|
||||
private void ContextFlyoutPage_Opening(object? sender, CancelEventArgs e)
|
||||
{
|
||||
if (e is CancelEventArgs cancelArgs)
|
||||
{
|
||||
var cancelCloseCheckBox = this.FindControl<CheckBox>("CancelOpenCheckBox");
|
||||
cancelArgs.Cancel = cancelCloseCheckBox?.IsChecked ?? false;
|
||||
}
|
||||
e.Cancel = CancelOpenCheckBox?.IsChecked ?? false;
|
||||
}
|
||||
|
||||
public void CustomContextRequested(object? sender, ContextRequestedEventArgs e)
|
||||
@@ -61,10 +46,5 @@ namespace ControlCatalog.Pages
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private void InitializeComponent()
|
||||
{
|
||||
AvaloniaXamlLoader.Load(this);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,20 +1,14 @@
|
||||
using Avalonia.Controls;
|
||||
using Avalonia.Markup.Xaml;
|
||||
using ControlCatalog.ViewModels;
|
||||
|
||||
namespace ControlCatalog.Pages
|
||||
{
|
||||
public class CursorPage : UserControl
|
||||
public partial class CursorPage : UserControl
|
||||
{
|
||||
public CursorPage()
|
||||
{
|
||||
this.InitializeComponent();
|
||||
InitializeComponent();
|
||||
DataContext = new CursorPageViewModel();
|
||||
}
|
||||
|
||||
private void InitializeComponent()
|
||||
{
|
||||
AvaloniaXamlLoader.Load(this);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
using System;
|
||||
using Avalonia.Controls;
|
||||
using Avalonia.Interactivity;
|
||||
using Avalonia.Markup.Xaml;
|
||||
|
||||
namespace ControlCatalog.Pages
|
||||
{
|
||||
@@ -12,56 +11,30 @@ namespace ControlCatalog.Pages
|
||||
InitializeComponent();
|
||||
}
|
||||
|
||||
private CustomDrawingExampleControl? _customControl;
|
||||
public CustomDrawingExampleControl CustomDrawingControl
|
||||
private void RotateMinus(object? sender, RoutedEventArgs e)
|
||||
{
|
||||
get
|
||||
{
|
||||
if (_customControl is not null)
|
||||
return _customControl;
|
||||
throw new System.Exception("Control did not get initialized");
|
||||
}
|
||||
}
|
||||
|
||||
private void InitializeComponent()
|
||||
{
|
||||
AvaloniaXamlLoader.Load(this);
|
||||
var cntrl = this.FindControl<CustomDrawingExampleControl>("CustomDrawingControl");
|
||||
if (cntrl != null)
|
||||
{
|
||||
_customControl = cntrl;
|
||||
}
|
||||
else
|
||||
{
|
||||
// be sad about it
|
||||
}
|
||||
}
|
||||
|
||||
private void RotateMinus (object? sender, RoutedEventArgs e)
|
||||
{
|
||||
if (_customControl is null) return;
|
||||
_customControl.Rotation -= Math.PI / 20.0d;
|
||||
CustomDrawingControl.Rotation -= Math.PI / 20.0d;
|
||||
}
|
||||
|
||||
private void RotatePlus(object? sender, RoutedEventArgs e)
|
||||
{
|
||||
if (_customControl is null)
|
||||
if (CustomDrawingControl is null)
|
||||
return;
|
||||
_customControl.Rotation += Math.PI / 20.0d;
|
||||
CustomDrawingControl.Rotation += Math.PI / 20.0d;
|
||||
}
|
||||
|
||||
private void ZoomIn(object? sender, RoutedEventArgs e)
|
||||
{
|
||||
if (_customControl is null)
|
||||
if (CustomDrawingControl is null)
|
||||
return;
|
||||
_customControl.Scale *= 1.2d;
|
||||
CustomDrawingControl.Scale *= 1.2d;
|
||||
}
|
||||
|
||||
private void ZoomOut(object? sender, RoutedEventArgs e)
|
||||
{
|
||||
if (_customControl is null)
|
||||
if (CustomDrawingControl is null)
|
||||
return;
|
||||
_customControl.Scale /= 1.2d;
|
||||
CustomDrawingControl.Scale /= 1.2d;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -4,8 +4,13 @@ using Avalonia.Interactivity;
|
||||
|
||||
namespace ControlCatalog.Pages;
|
||||
|
||||
public class DataGridPage : UserControl
|
||||
public partial class DataGridPage : UserControl
|
||||
{
|
||||
public DataGridPage()
|
||||
{
|
||||
InitializeComponent();
|
||||
}
|
||||
|
||||
private void OnLinkClicked(object? sender, RoutedEventArgs e)
|
||||
{
|
||||
Process.Start(new ProcessStartInfo
|
||||
|
||||
@@ -1,30 +1,23 @@
|
||||
using Avalonia;
|
||||
using Avalonia.Controls;
|
||||
using Avalonia.Markup.Xaml;
|
||||
using Avalonia.Controls;
|
||||
|
||||
namespace ControlCatalog.Pages
|
||||
{
|
||||
public class DateTimePickerPage : UserControl
|
||||
public partial class DateTimePickerPage : UserControl
|
||||
{
|
||||
public DateTimePickerPage()
|
||||
{
|
||||
this.InitializeComponent();
|
||||
this.Get<TextBlock>("DatePickerDesc").Text = "Use a DatePicker to let users set a date in your app, " +
|
||||
InitializeComponent();
|
||||
DatePickerDesc.Text = "Use a DatePicker to let users set a date in your app, " +
|
||||
"for example to schedule an appointment. The DatePicker displays three controls for month, day, and year. " +
|
||||
"These controls are easy to use with touch or mouse, and they can be styled and configured in several different ways. " +
|
||||
"Order of month, day, and year is dynamically set based on user date settings";
|
||||
|
||||
this.Get<TextBlock>("TimePickerDesc").Text = "Use a TimePicker to let users set a time in your app, for example " +
|
||||
TimePickerDesc.Text = "Use a TimePicker to let users set a time in your app, for example " +
|
||||
"to set a reminder. The TimePicker displays four controls for hour, minute, seconds(optional), and AM / PM(if necessary).These controls " +
|
||||
"are easy to use with touch or mouse, and they can be styled and configured in several different ways. " +
|
||||
"12 - hour or 24 - hour clock and visibility of AM / PM is dynamically set based on user time settings, or can be overridden.";
|
||||
|
||||
|
||||
}
|
||||
|
||||
private void InitializeComponent()
|
||||
{
|
||||
AvaloniaXamlLoader.Load(this);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -21,22 +21,22 @@ using Avalonia.Platform.Storage.FileIO;
|
||||
|
||||
namespace ControlCatalog.Pages
|
||||
{
|
||||
public class DialogsPage : UserControl
|
||||
public partial class DialogsPage : UserControl
|
||||
{
|
||||
public DialogsPage()
|
||||
{
|
||||
this.InitializeComponent();
|
||||
InitializeComponent();
|
||||
|
||||
IStorageFolder? lastSelectedDirectory = null;
|
||||
IStorageItem? lastSelectedItem = null;
|
||||
bool ignoreTextChanged = false;
|
||||
|
||||
var results = this.Get<ItemsControl>("PickerLastResults");
|
||||
var resultsVisible = this.Get<TextBlock>("PickerLastResultsVisible");
|
||||
var bookmarkContainer = this.Get<TextBox>("BookmarkContainer");
|
||||
var openedFileContent = this.Get<TextBox>("OpenedFileContent");
|
||||
var openMultiple = this.Get<CheckBox>("OpenMultiple");
|
||||
var currentFolderBox = this.Get<AutoCompleteBox>("CurrentFolderBox");
|
||||
var results = PickerLastResults;
|
||||
var resultsVisible = PickerLastResultsVisible;
|
||||
var bookmarkContainer = BookmarkContainer;
|
||||
var openedFileContent = OpenedFileContent;
|
||||
var openMultiple = OpenMultiple;
|
||||
var currentFolderBox = CurrentFolderBox;
|
||||
|
||||
currentFolderBox.TextChanged += async (sender, args) =>
|
||||
{
|
||||
@@ -61,7 +61,7 @@ namespace ControlCatalog.Pages
|
||||
}
|
||||
catch (SecurityException)
|
||||
{
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -78,7 +78,7 @@ namespace ControlCatalog.Pages
|
||||
|
||||
List<FilePickerFileType>? GetFileTypes()
|
||||
{
|
||||
var selectedItem = (this.Get<ComboBox>("FilterSelector").SelectedItem as ComboBoxItem)?.Content
|
||||
var selectedItem = (FilterSelector.SelectedItem as ComboBoxItem)?.Content
|
||||
?? "None";
|
||||
|
||||
var binLogType = new FilePickerFileType("Binary Log")
|
||||
@@ -115,7 +115,7 @@ namespace ControlCatalog.Pages
|
||||
};
|
||||
}
|
||||
|
||||
this.Get<Button>("OpenFile").Click += async delegate
|
||||
OpenFile.Click += async delegate
|
||||
{
|
||||
// Almost guaranteed to exist
|
||||
var uri = Assembly.GetEntryAssembly()?.GetModules().FirstOrDefault()?.FullyQualifiedName;
|
||||
@@ -132,7 +132,7 @@ namespace ControlCatalog.Pages
|
||||
results.ItemsSource = result;
|
||||
resultsVisible.IsVisible = result?.Any() == true;
|
||||
};
|
||||
this.Get<Button>("OpenMultipleFiles").Click += async delegate
|
||||
OpenMultipleFiles.Click += async delegate
|
||||
{
|
||||
var result = await new OpenFileDialog()
|
||||
{
|
||||
@@ -144,7 +144,7 @@ namespace ControlCatalog.Pages
|
||||
results.ItemsSource = result;
|
||||
resultsVisible.IsVisible = result?.Any() == true;
|
||||
};
|
||||
this.Get<Button>("SaveFile").Click += async delegate
|
||||
SaveFile.Click += async delegate
|
||||
{
|
||||
var filters = GetFilters();
|
||||
var result = await new SaveFileDialog()
|
||||
@@ -158,7 +158,7 @@ namespace ControlCatalog.Pages
|
||||
results.ItemsSource = new[] { result };
|
||||
resultsVisible.IsVisible = result != null;
|
||||
};
|
||||
this.Get<Button>("SelectFolder").Click += async delegate
|
||||
SelectFolder.Click += async delegate
|
||||
{
|
||||
var result = await new OpenFolderDialog()
|
||||
{
|
||||
@@ -176,7 +176,7 @@ namespace ControlCatalog.Pages
|
||||
resultsVisible.IsVisible = true;
|
||||
}
|
||||
};
|
||||
this.Get<Button>("OpenBoth").Click += async delegate
|
||||
OpenBoth.Click += async delegate
|
||||
{
|
||||
var result = await new OpenFileDialog()
|
||||
{
|
||||
@@ -190,35 +190,35 @@ namespace ControlCatalog.Pages
|
||||
results.ItemsSource = result;
|
||||
resultsVisible.IsVisible = result?.Any() == true;
|
||||
};
|
||||
this.Get<Button>("DecoratedWindow").Click += delegate
|
||||
DecoratedWindow.Click += delegate
|
||||
{
|
||||
new DecoratedWindow().Show();
|
||||
};
|
||||
this.Get<Button>("DecoratedWindowDialog").Click += delegate
|
||||
DecoratedWindowDialog.Click += delegate
|
||||
{
|
||||
_ = new DecoratedWindow().ShowDialog(GetWindow());
|
||||
};
|
||||
this.Get<Button>("Dialog").Click += delegate
|
||||
Dialog.Click += delegate
|
||||
{
|
||||
var window = CreateSampleWindow();
|
||||
window.Height = 200;
|
||||
_ = window.ShowDialog(GetWindow());
|
||||
};
|
||||
this.Get<Button>("DialogNoTaskbar").Click += delegate
|
||||
DialogNoTaskbar.Click += delegate
|
||||
{
|
||||
var window = CreateSampleWindow();
|
||||
window.Height = 200;
|
||||
window.ShowInTaskbar = false;
|
||||
_ = window.ShowDialog(GetWindow());
|
||||
};
|
||||
this.Get<Button>("OwnedWindow").Click += delegate
|
||||
OwnedWindow.Click += delegate
|
||||
{
|
||||
var window = CreateSampleWindow();
|
||||
|
||||
window.Show(GetWindow());
|
||||
};
|
||||
|
||||
this.Get<Button>("OwnedWindowNoTaskbar").Click += delegate
|
||||
OwnedWindowNoTaskbar.Click += delegate
|
||||
{
|
||||
var window = CreateSampleWindow();
|
||||
|
||||
@@ -227,7 +227,7 @@ namespace ControlCatalog.Pages
|
||||
window.Show(GetWindow());
|
||||
};
|
||||
|
||||
this.Get<Button>("OpenFilePicker").Click += async delegate
|
||||
OpenFilePicker.Click += async delegate
|
||||
{
|
||||
var result = await GetStorageProvider().OpenFilePickerAsync(new FilePickerOpenOptions()
|
||||
{
|
||||
@@ -240,7 +240,7 @@ namespace ControlCatalog.Pages
|
||||
|
||||
await SetPickerResult(result);
|
||||
};
|
||||
this.Get<Button>("SaveFilePicker").Click += async delegate
|
||||
SaveFilePicker.Click += async delegate
|
||||
{
|
||||
var fileTypes = GetFileTypes();
|
||||
var file = await GetStorageProvider().SaveFilePickerAsync(new FilePickerSaveOptions()
|
||||
@@ -276,7 +276,7 @@ namespace ControlCatalog.Pages
|
||||
|
||||
await SetPickerResult(file is null ? null : new[] { file });
|
||||
};
|
||||
this.Get<Button>("SaveFilePickerWithResult").Click += async delegate
|
||||
SaveFilePickerWithResult.Click += async delegate
|
||||
{
|
||||
var result = await GetStorageProvider().SaveFilePickerWithResultAsync(new FilePickerSaveOptions()
|
||||
{
|
||||
@@ -318,7 +318,7 @@ namespace ControlCatalog.Pages
|
||||
|
||||
await SetPickerResult(result.File is null ? null : new[] { result.File }, result.SelectedFileType);
|
||||
};
|
||||
this.Get<Button>("OpenFolderPicker").Click += async delegate
|
||||
OpenFolderPicker.Click += async delegate
|
||||
{
|
||||
var folders = await GetStorageProvider().OpenFolderPickerAsync(new FolderPickerOpenOptions()
|
||||
{
|
||||
@@ -330,7 +330,7 @@ namespace ControlCatalog.Pages
|
||||
|
||||
await SetPickerResult(folders);
|
||||
};
|
||||
this.Get<Button>("OpenFileFromBookmark").Click += async delegate
|
||||
OpenFileFromBookmark.Click += async delegate
|
||||
{
|
||||
var file = bookmarkContainer.Text is not null
|
||||
? await GetStorageProvider().OpenFileBookmarkAsync(bookmarkContainer.Text)
|
||||
@@ -338,7 +338,7 @@ namespace ControlCatalog.Pages
|
||||
|
||||
await SetPickerResult(file is null ? null : new[] { file });
|
||||
};
|
||||
this.Get<Button>("OpenFolderFromBookmark").Click += async delegate
|
||||
OpenFolderFromBookmark.Click += async delegate
|
||||
{
|
||||
var folder = bookmarkContainer.Text is not null
|
||||
? await GetStorageProvider().OpenFolderBookmarkAsync(bookmarkContainer.Text)
|
||||
@@ -346,11 +346,11 @@ namespace ControlCatalog.Pages
|
||||
|
||||
await SetPickerResult(folder is null ? null : new[] { folder });
|
||||
};
|
||||
|
||||
this.Get<Button>("LaunchUri").Click += async delegate
|
||||
|
||||
LaunchUri.Click += async delegate
|
||||
{
|
||||
var statusBlock = this.Get<TextBlock>("LaunchStatus");
|
||||
if (Uri.TryCreate(this.Get<TextBox>("UriToLaunch").Text, UriKind.Absolute, out var uri))
|
||||
var statusBlock = LaunchStatus;
|
||||
if (Uri.TryCreate(UriToLaunch.Text, UriKind.Absolute, out var uri))
|
||||
{
|
||||
var result = await TopLevel.GetTopLevel(this)!.Launcher.LaunchUriAsync(uri);
|
||||
statusBlock.Text = "LaunchUriAsync returned " + result;
|
||||
@@ -361,9 +361,9 @@ namespace ControlCatalog.Pages
|
||||
}
|
||||
};
|
||||
|
||||
this.Get<Button>("LaunchFile").Click += async delegate
|
||||
LaunchFile.Click += async delegate
|
||||
{
|
||||
var statusBlock = this.Get<TextBlock>("LaunchStatus");
|
||||
var statusBlock = LaunchStatus;
|
||||
if (lastSelectedItem is not null)
|
||||
{
|
||||
var result = await TopLevel.GetTopLevel(this)!.Launcher.LaunchFileAsync(lastSelectedItem);
|
||||
@@ -482,7 +482,7 @@ namespace ControlCatalog.Pages
|
||||
{
|
||||
base.OnAttachedToVisualTree(e);
|
||||
|
||||
var openedFileContent = this.Get<TextBox>("OpenedFileContent");
|
||||
var openedFileContent = OpenedFileContent;
|
||||
try
|
||||
{
|
||||
var storageProvider = GetStorageProvider();
|
||||
@@ -541,7 +541,7 @@ CanPickFolder: {storageProvider.CanPickFolder}";
|
||||
|
||||
private IStorageProvider GetStorageProvider()
|
||||
{
|
||||
var forceManaged = this.Get<CheckBox>("ForceManaged").IsChecked ?? false;
|
||||
var forceManaged = ForceManaged.IsChecked ?? false;
|
||||
return forceManaged
|
||||
? new ManagedStorageProvider(GetWindow()) // NOTE: In your production App use 'AppBuilder.UseManagedSystemDialogs()'
|
||||
: GetTopLevel().StorageProvider;
|
||||
@@ -555,11 +555,6 @@ CanPickFolder: {storageProvider.CanPickFolder}";
|
||||
|
||||
Window GetWindow() => TopLevel.GetTopLevel(this) as Window ?? throw new NullReferenceException("Invalid Owner");
|
||||
TopLevel GetTopLevel() => TopLevel.GetTopLevel(this) ?? throw new NullReferenceException("Invalid Owner");
|
||||
|
||||
private void InitializeComponent()
|
||||
{
|
||||
AvaloniaXamlLoader.Load(this);
|
||||
}
|
||||
}
|
||||
}
|
||||
#pragma warning restore CS0618 // Type or member is obsolete
|
||||
}
|
||||
|
||||
@@ -1,27 +1,21 @@
|
||||
using System;
|
||||
using System.Linq;
|
||||
using System.Reflection;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using Avalonia.Controls;
|
||||
using Avalonia.Input;
|
||||
using Avalonia.Input.Platform;
|
||||
using Avalonia.Markup.Xaml;
|
||||
using Avalonia.Platform.Storage;
|
||||
|
||||
namespace ControlCatalog.Pages
|
||||
{
|
||||
public class DragAndDropPage : UserControl
|
||||
public partial class DragAndDropPage : UserControl
|
||||
{
|
||||
private readonly TextBlock _dropState;
|
||||
|
||||
private readonly DataFormat<string> _customFormat =
|
||||
DataFormat.CreateStringApplicationFormat("xxx-avalonia-controlcatalog-custom");
|
||||
|
||||
public DragAndDropPage()
|
||||
{
|
||||
InitializeComponent();
|
||||
_dropState = this.Get<TextBlock>("DropState");
|
||||
|
||||
int textCount = 0;
|
||||
|
||||
@@ -121,7 +115,7 @@ namespace ControlCatalog.Pages
|
||||
|
||||
if (e.DataTransfer.Contains(DataFormat.Text))
|
||||
{
|
||||
_dropState.Text = e.DataTransfer.TryGetText();
|
||||
DropState.Text = e.DataTransfer.TryGetText();
|
||||
}
|
||||
else if (e.DataTransfer.Contains(DataFormat.File))
|
||||
{
|
||||
@@ -146,11 +140,11 @@ namespace ControlCatalog.Pages
|
||||
}
|
||||
}
|
||||
|
||||
_dropState.Text = contentStr;
|
||||
DropState.Text = contentStr;
|
||||
}
|
||||
else if (e.DataTransfer.Contains(_customFormat))
|
||||
{
|
||||
_dropState.Text = "Custom: " + e.DataTransfer.TryGetValue(_customFormat);
|
||||
DropState.Text = "Custom: " + e.DataTransfer.TryGetValue(_customFormat);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -159,10 +153,5 @@ namespace ControlCatalog.Pages
|
||||
AddHandler(DragDrop.DropEvent, Drop);
|
||||
AddHandler(DragDrop.DragOverEvent, DragOver);
|
||||
}
|
||||
|
||||
private void InitializeComponent()
|
||||
{
|
||||
AvaloniaXamlLoader.Load(this);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,26 +1,17 @@
|
||||
using Avalonia.Controls;
|
||||
using Avalonia.Markup.Xaml;
|
||||
using ControlCatalog.ViewModels;
|
||||
|
||||
namespace ControlCatalog.Pages
|
||||
{
|
||||
public class ExpanderPage : UserControl
|
||||
public partial class ExpanderPage : UserControl
|
||||
{
|
||||
public ExpanderPage()
|
||||
{
|
||||
this.InitializeComponent();
|
||||
InitializeComponent();
|
||||
DataContext = new ExpanderPageViewModel();
|
||||
|
||||
var CollapsingDisabledExpander = this.Get<Expander>("CollapsingDisabledExpander");
|
||||
var ExpandingDisabledExpander = this.Get<Expander>("ExpandingDisabledExpander");
|
||||
|
||||
CollapsingDisabledExpander.Collapsing += (s, e) => { e.Cancel = true; };
|
||||
ExpandingDisabledExpander.Expanding += (s, e) => { e.Cancel = true; };
|
||||
}
|
||||
|
||||
private void InitializeComponent()
|
||||
{
|
||||
AvaloniaXamlLoader.Load(this);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -13,11 +13,7 @@ namespace ControlCatalog.Pages
|
||||
{
|
||||
InitializeComponent();
|
||||
|
||||
var afp = this.FindControl<Panel>("AttachedFlyoutPanel");
|
||||
if (afp != null)
|
||||
{
|
||||
afp.DoubleTapped += Afp_DoubleTapped;
|
||||
}
|
||||
AttachedFlyoutPanel.DoubleTapped += Afp_DoubleTapped;
|
||||
|
||||
SetXamlTexts();
|
||||
}
|
||||
@@ -32,7 +28,7 @@ namespace ControlCatalog.Pages
|
||||
|
||||
private void SetXamlTexts()
|
||||
{
|
||||
var bfxt = this.Get<TextBlock>("ButtonFlyoutXamlText");
|
||||
var bfxt = ButtonFlyoutXamlText;
|
||||
bfxt.Text = "<Button Content=\"Click me!\">\n" +
|
||||
" <Button.Flyout>\n" +
|
||||
" <Flyout>\n" +
|
||||
@@ -42,7 +38,7 @@ namespace ControlCatalog.Pages
|
||||
" </Flyout>\n" +
|
||||
" </Button.Flyout>\n</Button>";
|
||||
|
||||
var mfxt = this.Get<TextBlock>("MenuFlyoutXamlText");
|
||||
var mfxt = this.MenuFlyoutXamlText;
|
||||
mfxt.Text = "<Button Content=\"Click me!\">\n" +
|
||||
" <Button.Flyout>\n" +
|
||||
" <MenuFlyout>\n" +
|
||||
@@ -51,7 +47,7 @@ namespace ControlCatalog.Pages
|
||||
" </MenuFlyout>\n" +
|
||||
" </Button.Flyout>\n</Button>";
|
||||
|
||||
var afxt = this.Get<TextBlock>("AttachedFlyoutXamlText");
|
||||
var afxt = this.AttachedFlyoutXamlText;
|
||||
afxt.Text = "<Panel Name=\"AttachedFlyoutPanel\">\n" +
|
||||
" <FlyoutBase.AttachedFlyout>\n" +
|
||||
" <Flyout>\n" +
|
||||
@@ -63,7 +59,7 @@ namespace ControlCatalog.Pages
|
||||
"\n\n In DoubleTapped handler:\n" +
|
||||
"FlyoutBase.ShowAttachedFlyout(AttachedFlyoutPanel);";
|
||||
|
||||
var sfxt = this.Get<TextBlock>("SharedFlyoutXamlText");
|
||||
var sfxt = this.SharedFlyoutXamlText;
|
||||
sfxt.Text = "Declare a flyout in Resources:\n" +
|
||||
"<Window.Resources>\n" +
|
||||
" <Flyout x:Key=\"SharedFlyout\">\n" +
|
||||
|
||||
@@ -1,75 +1,61 @@
|
||||
using System;
|
||||
using System.Numerics;
|
||||
using Avalonia;
|
||||
using Avalonia.Controls;
|
||||
using Avalonia.Input;
|
||||
using Avalonia.LogicalTree;
|
||||
using Avalonia.Markup.Xaml;
|
||||
using Avalonia.Rendering.Composition;
|
||||
using Avalonia.Utilities;
|
||||
|
||||
namespace ControlCatalog.Pages
|
||||
{
|
||||
public class GesturePage : UserControl
|
||||
public partial class GesturePage : UserControl
|
||||
{
|
||||
private bool _isInit;
|
||||
private double _currentScale;
|
||||
|
||||
public GesturePage()
|
||||
{
|
||||
this.InitializeComponent();
|
||||
}
|
||||
|
||||
private void InitializeComponent()
|
||||
{
|
||||
AvaloniaXamlLoader.Load(this);
|
||||
InitializeComponent();
|
||||
}
|
||||
|
||||
protected override void OnAttachedToVisualTree(VisualTreeAttachmentEventArgs e)
|
||||
{
|
||||
base.OnAttachedToVisualTree(e);
|
||||
|
||||
if(_isInit)
|
||||
if (_isInit)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
_isInit = true;
|
||||
|
||||
SetPullHandlers(this.Find<Border>("TopPullZone"), false);
|
||||
SetPullHandlers(this.Find<Border>("BottomPullZone"), true);
|
||||
SetPullHandlers(this.Find<Border>("RightPullZone"), true);
|
||||
SetPullHandlers(this.Find<Border>("LeftPullZone"), false);
|
||||
SetPullHandlers(TopPullZone, false);
|
||||
SetPullHandlers(BottomPullZone, true);
|
||||
SetPullHandlers(RightPullZone, true);
|
||||
SetPullHandlers(LeftPullZone, false);
|
||||
|
||||
var image = this.Get<Image>("PinchImage");
|
||||
var image = PinchImage;
|
||||
SetPinchHandlers(image);
|
||||
|
||||
var reset = this.Get<Button>("ResetButton");
|
||||
var reset = ResetButton;
|
||||
|
||||
reset.Click += (_, _) =>
|
||||
{
|
||||
var compositionVisual = ElementComposition.GetElementVisual(image);
|
||||
|
||||
if(compositionVisual!= null)
|
||||
if (compositionVisual != null)
|
||||
{
|
||||
_currentScale = 1;
|
||||
compositionVisual.Scale = new (1,1,1);
|
||||
compositionVisual.Scale = new(1, 1, 1);
|
||||
compositionVisual.Offset = default;
|
||||
image.InvalidateMeasure();
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
|
||||
if (this.Find<Slider>("AngleSlider") is { } slider &&
|
||||
this.Find<Panel>("RotationGesture") is { } rotationGesture
|
||||
)
|
||||
RotationGesture.AddHandler(Gestures.PinchEvent, (s, e) =>
|
||||
{
|
||||
rotationGesture.AddHandler(Gestures.PinchEvent, (s, e) =>
|
||||
{
|
||||
slider.Value = e.Angle;
|
||||
});
|
||||
}
|
||||
AngleSlider.Value = e.Angle;
|
||||
});
|
||||
}
|
||||
|
||||
private void SetPinchHandlers(Control? control)
|
||||
@@ -101,7 +87,7 @@ namespace ControlCatalog.Pages
|
||||
{
|
||||
compositionVisual.Scale = new(_currentScale, _currentScale, 1);
|
||||
|
||||
if(currentOffset == default)
|
||||
if (currentOffset == default)
|
||||
{
|
||||
currentOffset = compositionVisual.Offset;
|
||||
}
|
||||
@@ -112,7 +98,7 @@ namespace ControlCatalog.Pages
|
||||
{
|
||||
InitComposition(control!);
|
||||
|
||||
if(compositionVisual != null)
|
||||
if (compositionVisual != null)
|
||||
{
|
||||
var scale = _currentScale * (float)e.Scale;
|
||||
|
||||
@@ -159,13 +145,8 @@ namespace ControlCatalog.Pages
|
||||
});
|
||||
}
|
||||
|
||||
private void SetPullHandlers(Control? control, bool inverse)
|
||||
private void SetPullHandlers(Control control, bool inverse)
|
||||
{
|
||||
if (control == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
var ball = control.FindLogicalDescendantOfType<Border>();
|
||||
|
||||
Vector3D defaultOffset = default;
|
||||
|
||||
@@ -1,60 +1,45 @@
|
||||
using System;
|
||||
using Avalonia;
|
||||
using Avalonia.Controls;
|
||||
using Avalonia.Markup.Xaml;
|
||||
using Avalonia.Media;
|
||||
using Avalonia.Media.Imaging;
|
||||
using Avalonia.Platform;
|
||||
|
||||
namespace ControlCatalog.Pages
|
||||
{
|
||||
public class ImagePage : UserControl
|
||||
public partial class ImagePage : UserControl
|
||||
{
|
||||
private readonly Image _bitmapImage;
|
||||
private readonly Image _drawingImage;
|
||||
private readonly Image _croppedImage;
|
||||
|
||||
public ImagePage()
|
||||
{
|
||||
InitializeComponent();
|
||||
_bitmapImage = this.Get<Image>("bitmapImage");
|
||||
_drawingImage = this.Get<Image>("drawingImage");
|
||||
_croppedImage = this.Get<Image>("croppedImage");
|
||||
}
|
||||
|
||||
private void InitializeComponent()
|
||||
{
|
||||
AvaloniaXamlLoader.Load(this);
|
||||
}
|
||||
|
||||
public void BitmapStretchChanged(object sender, SelectionChangedEventArgs e)
|
||||
{
|
||||
if (_bitmapImage != null)
|
||||
if (bitmapImage != null)
|
||||
{
|
||||
var comboxBox = (ComboBox)sender;
|
||||
_bitmapImage.Stretch = (Stretch)comboxBox.SelectedIndex;
|
||||
bitmapImage.Stretch = (Stretch)comboxBox.SelectedIndex;
|
||||
}
|
||||
}
|
||||
|
||||
public void DrawingStretchChanged(object sender, SelectionChangedEventArgs e)
|
||||
{
|
||||
if (_drawingImage != null)
|
||||
if (drawingImage != null)
|
||||
{
|
||||
var comboxBox = (ComboBox)sender;
|
||||
_drawingImage.Stretch = (Stretch)comboxBox.SelectedIndex;
|
||||
drawingImage.Stretch = (Stretch)comboxBox.SelectedIndex;
|
||||
}
|
||||
}
|
||||
|
||||
public void BitmapCropChanged(object sender, SelectionChangedEventArgs e)
|
||||
{
|
||||
if (_croppedImage != null)
|
||||
if (croppedImage != null)
|
||||
{
|
||||
var comboxBox = (ComboBox)sender;
|
||||
if (_croppedImage.Source is CroppedBitmap croppedBitmap)
|
||||
if (croppedImage.Source is CroppedBitmap croppedBitmap)
|
||||
{
|
||||
croppedBitmap.SourceRect = GetCropRect(comboxBox.SelectedIndex);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -72,7 +57,7 @@ namespace ControlCatalog.Pages
|
||||
5 => new PixelRect(new PixelPoint(bitmapWidth - cropSize.Width, bitmapHeight - cropSize.Height), cropSize),
|
||||
_ => default
|
||||
};
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,18 +1,12 @@
|
||||
using Avalonia.Controls;
|
||||
using Avalonia.Markup.Xaml;
|
||||
|
||||
namespace ControlCatalog.Pages
|
||||
{
|
||||
public class LayoutTransformControlPage : UserControl
|
||||
public partial class LayoutTransformControlPage : UserControl
|
||||
{
|
||||
public LayoutTransformControlPage()
|
||||
{
|
||||
this.InitializeComponent();
|
||||
}
|
||||
|
||||
private void InitializeComponent()
|
||||
{
|
||||
AvaloniaXamlLoader.Load(this);
|
||||
InitializeComponent();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,20 +1,14 @@
|
||||
using Avalonia.Controls;
|
||||
using Avalonia.Markup.Xaml;
|
||||
using ControlCatalog.ViewModels;
|
||||
|
||||
namespace ControlCatalog.Pages
|
||||
{
|
||||
public class ListBoxPage : UserControl
|
||||
public partial class ListBoxPage : UserControl
|
||||
{
|
||||
public ListBoxPage()
|
||||
{
|
||||
InitializeComponent();
|
||||
DataContext = new ListBoxPageViewModel();
|
||||
}
|
||||
|
||||
private void InitializeComponent()
|
||||
{
|
||||
AvaloniaXamlLoader.Load(this);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,37 +1,28 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Threading.Tasks;
|
||||
using System.Windows.Input;
|
||||
using Avalonia.Controls;
|
||||
using Avalonia.Markup.Xaml;
|
||||
using ControlCatalog.ViewModels;
|
||||
|
||||
namespace ControlCatalog.Pages
|
||||
{
|
||||
public class MenuPage : UserControl
|
||||
public partial class MenuPage : UserControl
|
||||
{
|
||||
public MenuPage()
|
||||
{
|
||||
this.InitializeComponent();
|
||||
InitializeComponent();
|
||||
DataContext = new MenuPageViewModel();
|
||||
}
|
||||
|
||||
private void InitializeComponent()
|
||||
{
|
||||
AvaloniaXamlLoader.Load(this);
|
||||
}
|
||||
|
||||
private MenuPageViewModel? _model;
|
||||
protected override void OnDataContextChanged(EventArgs e)
|
||||
{
|
||||
if (_model != null)
|
||||
_model.View = null;
|
||||
_model = DataContext as MenuPageViewModel;
|
||||
_model = DataContext as MenuPageViewModel;
|
||||
if (_model != null)
|
||||
_model.View = this;
|
||||
|
||||
base.OnDataContextChanged(e);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,26 +1,17 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
using Avalonia.Platform;
|
||||
using Avalonia.Interactivity;
|
||||
using Avalonia.Controls;
|
||||
using Avalonia.Controls.Platform;
|
||||
using Avalonia.Markup.Xaml;
|
||||
using Avalonia;
|
||||
using Avalonia.Controls;
|
||||
using Avalonia.Interactivity;
|
||||
using Avalonia.Platform;
|
||||
|
||||
namespace ControlCatalog.Pages
|
||||
{
|
||||
public class NativeEmbedPage : UserControl
|
||||
public partial class NativeEmbedPage : UserControl
|
||||
{
|
||||
public NativeEmbedPage()
|
||||
{
|
||||
this.InitializeComponent();
|
||||
}
|
||||
|
||||
private void InitializeComponent()
|
||||
{
|
||||
AvaloniaXamlLoader.Load(this);
|
||||
InitializeComponent();
|
||||
}
|
||||
|
||||
public async void ShowPopupDelay(object sender, RoutedEventArgs args)
|
||||
@@ -47,8 +38,8 @@ namespace ControlCatalog.Pages
|
||||
if (change.Property == BoundsProperty)
|
||||
{
|
||||
var isMobile = change.GetNewValue<Rect>().Width < 1200;
|
||||
this.Find<DockPanel>("FirstPanel")!.Classes.Set("mobile", isMobile);
|
||||
this.Find<DockPanel>("SecondPanel")!.Classes.Set("mobile", isMobile);
|
||||
FirstPanel.Classes.Set("mobile", isMobile);
|
||||
SecondPanel.Classes.Set("mobile", isMobile);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,29 +1,23 @@
|
||||
using Avalonia;
|
||||
using Avalonia.Controls;
|
||||
using Avalonia.Controls.Notifications;
|
||||
using Avalonia.Markup.Xaml;
|
||||
using ControlCatalog.ViewModels;
|
||||
|
||||
namespace ControlCatalog.Pages
|
||||
{
|
||||
public class NotificationsPage : UserControl
|
||||
public partial class NotificationsPage : UserControl
|
||||
{
|
||||
private NotificationViewModel _viewModel;
|
||||
|
||||
public NotificationsPage()
|
||||
{
|
||||
this.InitializeComponent();
|
||||
InitializeComponent();
|
||||
|
||||
_viewModel = new NotificationViewModel();
|
||||
|
||||
DataContext = _viewModel;
|
||||
}
|
||||
|
||||
private void InitializeComponent()
|
||||
{
|
||||
AvaloniaXamlLoader.Load(this);
|
||||
}
|
||||
|
||||
protected override void OnAttachedToVisualTree(VisualTreeAttachmentEventArgs e)
|
||||
{
|
||||
base.OnAttachedToVisualTree(e);
|
||||
@@ -33,7 +27,7 @@ namespace ControlCatalog.Pages
|
||||
|
||||
public void NotificationOnClick()
|
||||
{
|
||||
this.Get<WindowNotificationManager>("ControlNotifications").Show("Notification clicked");
|
||||
ControlNotifications.Show("Notification clicked");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -9,20 +9,15 @@ using MiniMvvm;
|
||||
|
||||
namespace ControlCatalog.Pages
|
||||
{
|
||||
public class NumericUpDownPage : UserControl
|
||||
public partial class NumericUpDownPage : UserControl
|
||||
{
|
||||
public NumericUpDownPage()
|
||||
{
|
||||
this.InitializeComponent();
|
||||
InitializeComponent();
|
||||
var viewModel = new NumbersPageViewModel();
|
||||
DataContext = viewModel;
|
||||
}
|
||||
|
||||
private void InitializeComponent()
|
||||
{
|
||||
AvaloniaXamlLoader.Load(this);
|
||||
}
|
||||
|
||||
public static IValueConverter CultureConverter =
|
||||
new FuncValueConverter<CultureInfo, NumberFormatInfo>(c => (c ?? CultureInfo.CurrentCulture).NumberFormat);
|
||||
}
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
xmlns:pages="using:ControlCatalog.Pages"
|
||||
xmlns:openGl="clr-namespace:ControlCatalog.Pages.OpenGl">
|
||||
<Grid>
|
||||
<Control x:Name="Viewport" />
|
||||
<openGl:GlPageKnobs x:Name="Knobs" />
|
||||
<Control x:Name="Viewport" AttachedToVisualTree="ViewportAttachedToVisualTree" DetachedFromVisualTree="ViewportDetachedFromVisualTree"/>
|
||||
<openGl:GlPageKnobs x:Name="Knobs" PropertyChanged="KnobsPropertyChanged" />
|
||||
</Grid>
|
||||
</UserControl>
|
||||
</UserControl>
|
||||
|
||||
@@ -1,8 +1,6 @@
|
||||
using System;
|
||||
using Avalonia;
|
||||
using Avalonia.Controls;
|
||||
using Avalonia.LogicalTree;
|
||||
using Avalonia.Markup.Xaml;
|
||||
using Avalonia.Media;
|
||||
using Avalonia.OpenGL;
|
||||
using Avalonia.Platform;
|
||||
@@ -14,10 +12,8 @@ using static Avalonia.OpenGL.GlConsts;
|
||||
|
||||
namespace ControlCatalog.Pages;
|
||||
|
||||
public class OpenGlLeasePage : UserControl
|
||||
public partial class OpenGlLeasePage : UserControl
|
||||
{
|
||||
private readonly Control _viewport;
|
||||
private readonly GlPageKnobs _knobs;
|
||||
private CompositionCustomVisual? _visual;
|
||||
|
||||
class GlVisual : CompositionCustomVisualHandler
|
||||
@@ -161,12 +157,7 @@ public class OpenGlLeasePage : UserControl
|
||||
|
||||
public OpenGlLeasePage()
|
||||
{
|
||||
AvaloniaXamlLoader.Load(this);
|
||||
_viewport = this.FindControl<Control>("Viewport")!;
|
||||
_viewport.AttachedToVisualTree += ViewportAttachedToVisualTree;
|
||||
_viewport.DetachedFromVisualTree += ViewportDetachedFromVisualTree;
|
||||
_knobs = this.FindControl<GlPageKnobs>("Knobs")!;
|
||||
_knobs.PropertyChanged += KnobsPropertyChanged;
|
||||
InitializeComponent();
|
||||
}
|
||||
|
||||
private void KnobsPropertyChanged(object? sender, AvaloniaPropertyChangedEventArgs change)
|
||||
@@ -180,16 +171,16 @@ public class OpenGlLeasePage : UserControl
|
||||
|
||||
Parameters GetParameters() => new()
|
||||
{
|
||||
Yaw = _knobs!.Yaw, Pitch = _knobs.Pitch, Roll = _knobs.Roll, Disco = _knobs.Disco
|
||||
Yaw = Knobs!.Yaw, Pitch = Knobs.Pitch, Roll = Knobs.Roll, Disco = Knobs.Disco
|
||||
};
|
||||
|
||||
private void ViewportAttachedToVisualTree(object? sender, VisualTreeAttachmentEventArgs e)
|
||||
{
|
||||
var visual = ElementComposition.GetElementVisual(_viewport!);
|
||||
var visual = ElementComposition.GetElementVisual(Viewport);
|
||||
if(visual == null)
|
||||
return;
|
||||
_visual = visual.Compositor.CreateCustomVisual(new GlVisual(new OpenGlContent(), GetParameters()));
|
||||
ElementComposition.SetElementChildVisual(_viewport, _visual);
|
||||
ElementComposition.SetElementChildVisual(Viewport, _visual);
|
||||
UpdateSize(Bounds.Size);
|
||||
}
|
||||
|
||||
@@ -210,7 +201,7 @@ public class OpenGlLeasePage : UserControl
|
||||
{
|
||||
_visual?.SendHandlerMessage(new DisposeMessage());
|
||||
_visual = null;
|
||||
ElementComposition.SetElementChildVisual(_viewport, null);
|
||||
ElementComposition.SetElementChildVisual(Viewport, null);
|
||||
base.OnDetachedFromVisualTree(e);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,9 +1,7 @@
|
||||
using System.Runtime.InteropServices;
|
||||
using Avalonia;
|
||||
using Avalonia.Controls;
|
||||
using Avalonia.Controls.Primitives;
|
||||
using Avalonia.Interactivity;
|
||||
using Avalonia.Markup.Xaml;
|
||||
using Avalonia.OpenGL;
|
||||
using Avalonia.OpenGL.Controls;
|
||||
using Avalonia.Rendering.Composition;
|
||||
@@ -13,21 +11,20 @@ using ControlCatalog.Pages.OpenGl;
|
||||
|
||||
namespace ControlCatalog.Pages
|
||||
{
|
||||
public class OpenGlPage : UserControl
|
||||
public partial class OpenGlPage : UserControl
|
||||
{
|
||||
public OpenGlPage()
|
||||
{
|
||||
AvaloniaXamlLoader.Load(this);
|
||||
this.FindControl<OpenGlPageControl>("GL")
|
||||
!.Init(this.FindControl<GlPageKnobs>("Knobs")!);
|
||||
|
||||
InitializeComponent();
|
||||
GL.Init(Knobs);
|
||||
|
||||
AttachedToVisualTree += delegate
|
||||
{
|
||||
if (TopLevel.GetTopLevel(this) is Window)
|
||||
this.FindControl<Button>("Snapshot")!.IsVisible = true;
|
||||
Snapshot.IsVisible = true;
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
private async void SnapshotClick(object sender, RoutedEventArgs e)
|
||||
{
|
||||
var v = ElementComposition.GetElementVisual(this)!;
|
||||
@@ -66,7 +63,7 @@ namespace ControlCatalog.Pages
|
||||
|| change.Property == GlPageKnobs.DiscoProperty)
|
||||
RequestNextFrameRendering();
|
||||
}
|
||||
|
||||
|
||||
protected override unsafe void OnOpenGlInit(GlInterface GL) => _content.Init(GL, GlVersion);
|
||||
|
||||
protected override void OnOpenGlDeinit(GlInterface GL) => _content.Deinit(GL);
|
||||
|
||||
@@ -1,23 +1,14 @@
|
||||
using System;
|
||||
using Avalonia.Controls;
|
||||
using Avalonia.Markup.Xaml;
|
||||
using Avalonia.Markup.Xaml.MarkupExtensions;
|
||||
using Avalonia.Media.Immutable;
|
||||
using Avalonia.Controls;
|
||||
using ControlCatalog.ViewModels;
|
||||
|
||||
namespace ControlCatalog.Pages
|
||||
{
|
||||
public class PlatformInfoPage : UserControl
|
||||
public partial class PlatformInfoPage : UserControl
|
||||
{
|
||||
public PlatformInfoPage()
|
||||
{
|
||||
this.InitializeComponent();
|
||||
InitializeComponent();
|
||||
DataContext = new PlatformInformationViewModel();
|
||||
}
|
||||
|
||||
private void InitializeComponent()
|
||||
{
|
||||
AvaloniaXamlLoader.Load(this);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -48,6 +48,8 @@
|
||||
Margin="5"
|
||||
Padding="50"
|
||||
Background="{DynamicResource SystemAccentColor}"
|
||||
PointerPressed="Border_PointerPressed" PointerReleased="Border_PointerReleased" PointerCaptureLost="Border_PointerCaptureLost"
|
||||
PointerMoved="Border_PointerUpdated" PointerEntered="Border_PointerUpdated" PointerExited="Border_PointerUpdated"
|
||||
ToolTip.Placement="Bottom">
|
||||
<TextBlock>Capture 1</TextBlock>
|
||||
</Border>
|
||||
@@ -57,6 +59,8 @@
|
||||
Margin="5"
|
||||
Padding="50"
|
||||
Background="{DynamicResource SystemAccentColor}"
|
||||
PointerPressed="Border_PointerPressed" PointerReleased="Border_PointerReleased" PointerCaptureLost="Border_PointerCaptureLost"
|
||||
PointerMoved="Border_PointerUpdated" PointerEntered="Border_PointerUpdated" PointerExited="Border_PointerUpdated"
|
||||
ToolTip.Placement="Bottom">
|
||||
<TextBlock>Capture 2</TextBlock>
|
||||
</Border>
|
||||
|
||||
@@ -1,32 +1,14 @@
|
||||
using System;
|
||||
using Avalonia.Controls;
|
||||
using Avalonia.Input;
|
||||
using Avalonia.Markup.Xaml;
|
||||
|
||||
namespace ControlCatalog.Pages;
|
||||
|
||||
public class PointersPage : UserControl
|
||||
public partial class PointersPage : UserControl
|
||||
{
|
||||
public PointersPage()
|
||||
{
|
||||
this.InitializeComponent();
|
||||
|
||||
var border1 = this.Get<Border>("BorderCapture1");
|
||||
var border2 = this.Get<Border>("BorderCapture2");
|
||||
|
||||
border1.PointerPressed += Border_PointerPressed;
|
||||
border1.PointerReleased += Border_PointerReleased;
|
||||
border1.PointerCaptureLost += Border_PointerCaptureLost;
|
||||
border1.PointerMoved += Border_PointerUpdated;
|
||||
border1.PointerEntered += Border_PointerUpdated;
|
||||
border1.PointerExited += Border_PointerUpdated;
|
||||
|
||||
border2.PointerPressed += Border_PointerPressed;
|
||||
border2.PointerReleased += Border_PointerReleased;
|
||||
border2.PointerCaptureLost += Border_PointerCaptureLost;
|
||||
border2.PointerMoved += Border_PointerUpdated;
|
||||
border2.PointerEntered += Border_PointerUpdated;
|
||||
border2.PointerExited += Border_PointerUpdated;
|
||||
InitializeComponent();
|
||||
}
|
||||
|
||||
private void Border_PointerUpdated(object? sender, PointerEventArgs e)
|
||||
@@ -74,9 +56,4 @@ Position: ??? ???";
|
||||
e.Handled = true;
|
||||
e.PreventGestureRecognition();
|
||||
}
|
||||
|
||||
private void InitializeComponent()
|
||||
{
|
||||
AvaloniaXamlLoader.Load(this);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,18 +1,12 @@
|
||||
using Avalonia.Controls;
|
||||
using Avalonia.Markup.Xaml;
|
||||
|
||||
namespace ControlCatalog.Pages
|
||||
{
|
||||
public class ProgressBarPage : UserControl
|
||||
public partial class ProgressBarPage : UserControl
|
||||
{
|
||||
public ProgressBarPage()
|
||||
{
|
||||
this.InitializeComponent();
|
||||
}
|
||||
|
||||
private void InitializeComponent()
|
||||
{
|
||||
AvaloniaXamlLoader.Load(this);
|
||||
InitializeComponent();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,18 +1,12 @@
|
||||
using Avalonia.Controls;
|
||||
using Avalonia.Markup.Xaml;
|
||||
|
||||
namespace ControlCatalog.Pages
|
||||
{
|
||||
public class RadioButtonPage : UserControl
|
||||
public partial class RadioButtonPage : UserControl
|
||||
{
|
||||
public RadioButtonPage()
|
||||
{
|
||||
this.InitializeComponent();
|
||||
}
|
||||
|
||||
private void InitializeComponent()
|
||||
{
|
||||
AvaloniaXamlLoader.Load(this);
|
||||
InitializeComponent();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
using System.Collections.Generic;
|
||||
using Avalonia.Controls;
|
||||
using Avalonia.Controls.Primitives;
|
||||
using Avalonia.Markup.Xaml;
|
||||
using MiniMvvm;
|
||||
|
||||
namespace ControlCatalog.Pages
|
||||
@@ -93,7 +92,7 @@ namespace ControlCatalog.Pages
|
||||
public List<SnapPointsAlignment> AvailableSnapPointsAlignment { get; }
|
||||
}
|
||||
|
||||
public class ScrollViewerPage : UserControl
|
||||
public partial class ScrollViewerPage : UserControl
|
||||
{
|
||||
public ScrollViewerPage()
|
||||
{
|
||||
@@ -101,10 +100,5 @@ namespace ControlCatalog.Pages
|
||||
|
||||
DataContext = new ScrollViewerPageViewModel();
|
||||
}
|
||||
|
||||
private void InitializeComponent()
|
||||
{
|
||||
AvaloniaXamlLoader.Load(this);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,18 +1,12 @@
|
||||
using Avalonia.Controls;
|
||||
using Avalonia.Markup.Xaml;
|
||||
|
||||
namespace ControlCatalog.Pages
|
||||
{
|
||||
public class SliderPage : UserControl
|
||||
public partial class SliderPage : UserControl
|
||||
{
|
||||
public SliderPage()
|
||||
{
|
||||
this.InitializeComponent();
|
||||
}
|
||||
|
||||
private void InitializeComponent()
|
||||
{
|
||||
AvaloniaXamlLoader.Load(this);
|
||||
InitializeComponent();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,21 +1,14 @@
|
||||
using Avalonia;
|
||||
using Avalonia.Controls;
|
||||
using Avalonia.Markup.Xaml;
|
||||
using Avalonia.Controls;
|
||||
using ControlCatalog.ViewModels;
|
||||
|
||||
namespace ControlCatalog.Pages
|
||||
{
|
||||
public class SplitViewPage : UserControl
|
||||
public partial class SplitViewPage : UserControl
|
||||
{
|
||||
public SplitViewPage()
|
||||
{
|
||||
this.InitializeComponent();
|
||||
InitializeComponent();
|
||||
DataContext = new SplitViewPageViewModel();
|
||||
}
|
||||
|
||||
private void InitializeComponent()
|
||||
{
|
||||
AvaloniaXamlLoader.Load(this);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,17 +1,12 @@
|
||||
using System;
|
||||
|
||||
using Avalonia;
|
||||
using Avalonia.Controls;
|
||||
using Avalonia.Markup.Xaml;
|
||||
using Avalonia.Media.Imaging;
|
||||
using Avalonia.Platform;
|
||||
using ControlCatalog.ViewModels;
|
||||
|
||||
namespace ControlCatalog.Pages
|
||||
{
|
||||
using System.Collections.Generic;
|
||||
|
||||
public class TabControlPage : UserControl
|
||||
public partial class TabControlPage : UserControl
|
||||
{
|
||||
public TabControlPage()
|
||||
{
|
||||
@@ -44,11 +39,6 @@ namespace ControlCatalog.Pages
|
||||
};
|
||||
}
|
||||
|
||||
private void InitializeComponent()
|
||||
{
|
||||
AvaloniaXamlLoader.Load(this);
|
||||
}
|
||||
|
||||
private static Bitmap LoadBitmap(string uri)
|
||||
{
|
||||
return new Bitmap(AssetLoader.Open(new Uri(uri)));
|
||||
|
||||
@@ -1,10 +1,9 @@
|
||||
using Avalonia.Controls;
|
||||
using Avalonia.Markup.Xaml;
|
||||
using ControlCatalog.ViewModels;
|
||||
|
||||
namespace ControlCatalog.Pages
|
||||
{
|
||||
public class TabStripPage : UserControl
|
||||
public partial class TabStripPage : UserControl
|
||||
{
|
||||
public TabStripPage()
|
||||
{
|
||||
@@ -12,7 +11,7 @@ namespace ControlCatalog.Pages
|
||||
|
||||
DataContext = new TabControlPageViewModel
|
||||
{
|
||||
Tabs = new []
|
||||
Tabs = new[]
|
||||
{
|
||||
new TabControlPageViewModelItem()
|
||||
{
|
||||
@@ -30,10 +29,5 @@ namespace ControlCatalog.Pages
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
private void InitializeComponent()
|
||||
{
|
||||
AvaloniaXamlLoader.Load(this);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,18 +1,12 @@
|
||||
using Avalonia.Controls;
|
||||
using Avalonia.Markup.Xaml;
|
||||
|
||||
namespace ControlCatalog.Pages
|
||||
{
|
||||
public class TextBlockPage : UserControl
|
||||
public partial class TextBlockPage : UserControl
|
||||
{
|
||||
public TextBlockPage()
|
||||
{
|
||||
this.InitializeComponent();
|
||||
}
|
||||
|
||||
private void InitializeComponent()
|
||||
{
|
||||
AvaloniaXamlLoader.Load(this);
|
||||
InitializeComponent();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,18 +1,12 @@
|
||||
using Avalonia.Controls;
|
||||
using Avalonia.Markup.Xaml;
|
||||
|
||||
namespace ControlCatalog.Pages
|
||||
{
|
||||
public class TextBoxPage : UserControl
|
||||
public partial class TextBoxPage : UserControl
|
||||
{
|
||||
public TextBoxPage()
|
||||
{
|
||||
this.InitializeComponent();
|
||||
}
|
||||
|
||||
private void InitializeComponent()
|
||||
{
|
||||
AvaloniaXamlLoader.Load(this);
|
||||
InitializeComponent();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,19 +1,12 @@
|
||||
using Avalonia;
|
||||
using Avalonia.Controls;
|
||||
using Avalonia.Markup.Xaml;
|
||||
using Avalonia.Controls;
|
||||
|
||||
namespace ControlCatalog.Pages
|
||||
{
|
||||
public class ToggleSwitchPage : UserControl
|
||||
public partial class ToggleSwitchPage : UserControl
|
||||
{
|
||||
public ToggleSwitchPage()
|
||||
{
|
||||
this.InitializeComponent();
|
||||
}
|
||||
|
||||
private void InitializeComponent()
|
||||
{
|
||||
AvaloniaXamlLoader.Load(this);
|
||||
InitializeComponent();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,22 +1,16 @@
|
||||
using System;
|
||||
using Avalonia;
|
||||
using Avalonia.Controls;
|
||||
using Avalonia.Interactivity;
|
||||
using Avalonia.Controls.Primitives.PopupPositioning;
|
||||
using Avalonia.Markup.Xaml;
|
||||
using Avalonia.Interactivity;
|
||||
|
||||
namespace ControlCatalog.Pages
|
||||
{
|
||||
public class ToolTipPage : UserControl
|
||||
public partial class ToolTipPage : UserControl
|
||||
{
|
||||
public ToolTipPage()
|
||||
{
|
||||
this.InitializeComponent();
|
||||
}
|
||||
|
||||
private void InitializeComponent()
|
||||
{
|
||||
AvaloniaXamlLoader.Load(this);
|
||||
InitializeComponent();
|
||||
}
|
||||
|
||||
private void ToolTipOpening(object? sender, CancelRoutedEventArgs args)
|
||||
|
||||
@@ -1,6 +1,4 @@
|
||||
using Avalonia;
|
||||
using Avalonia.Controls;
|
||||
using Avalonia.Markup.Xaml;
|
||||
|
||||
namespace ControlCatalog.Pages
|
||||
{
|
||||
@@ -10,10 +8,5 @@ namespace ControlCatalog.Pages
|
||||
{
|
||||
InitializeComponent();
|
||||
}
|
||||
|
||||
private void InitializeComponent()
|
||||
{
|
||||
AvaloniaXamlLoader.Load(this);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,20 +1,14 @@
|
||||
using Avalonia.Controls;
|
||||
using Avalonia.Markup.Xaml;
|
||||
using ControlCatalog.ViewModels;
|
||||
|
||||
namespace ControlCatalog.Pages
|
||||
{
|
||||
public class TreeViewPage : UserControl
|
||||
public partial class TreeViewPage : UserControl
|
||||
{
|
||||
public TreeViewPage()
|
||||
{
|
||||
InitializeComponent();
|
||||
DataContext = new TreeViewPageViewModel();
|
||||
}
|
||||
|
||||
private void InitializeComponent()
|
||||
{
|
||||
AvaloniaXamlLoader.Load(this);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,18 +1,12 @@
|
||||
using Avalonia.Controls;
|
||||
using Avalonia.Markup.Xaml;
|
||||
|
||||
namespace ControlCatalog.Pages
|
||||
{
|
||||
public class ViewboxPage : UserControl
|
||||
public partial class ViewboxPage : UserControl
|
||||
{
|
||||
public ViewboxPage()
|
||||
{
|
||||
InitializeComponent();
|
||||
}
|
||||
|
||||
private void InitializeComponent()
|
||||
{
|
||||
AvaloniaXamlLoader.Load(this);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,19 +1,12 @@
|
||||
using Avalonia;
|
||||
using Avalonia.Controls;
|
||||
using Avalonia.Markup.Xaml;
|
||||
using Avalonia.Controls;
|
||||
|
||||
namespace ControlCatalog.Pages
|
||||
{
|
||||
public class WindowCustomizationsPage : UserControl
|
||||
public partial class WindowCustomizationsPage : UserControl
|
||||
{
|
||||
public WindowCustomizationsPage()
|
||||
{
|
||||
this.InitializeComponent();
|
||||
}
|
||||
|
||||
private void InitializeComponent()
|
||||
{
|
||||
AvaloniaXamlLoader.Load(this);
|
||||
InitializeComponent();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,18 +1,12 @@
|
||||
using Avalonia.Controls;
|
||||
using Avalonia.Markup.Xaml;
|
||||
|
||||
namespace ControlCatalog.Views
|
||||
{
|
||||
public class CustomNotificationView : UserControl
|
||||
public partial class CustomNotificationView : UserControl
|
||||
{
|
||||
public CustomNotificationView()
|
||||
{
|
||||
this.InitializeComponent();
|
||||
}
|
||||
|
||||
private void InitializeComponent()
|
||||
{
|
||||
AvaloniaXamlLoader.Load(this);
|
||||
InitializeComponent();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user