committed by
GitHub
481 changed files with 14576 additions and 2939 deletions
@ -0,0 +1,5 @@ |
|||
<ProjectConfiguration> |
|||
<Settings> |
|||
<IgnoreThisComponentCompletely>True</IgnoreThisComponentCompletely> |
|||
</Settings> |
|||
</ProjectConfiguration> |
|||
@ -0,0 +1,5 @@ |
|||
<ProjectConfiguration> |
|||
<Settings> |
|||
<IgnoreThisComponentCompletely>True</IgnoreThisComponentCompletely> |
|||
</Settings> |
|||
</ProjectConfiguration> |
|||
@ -0,0 +1,5 @@ |
|||
<ProjectConfiguration> |
|||
<Settings> |
|||
<IgnoreThisComponentCompletely>True</IgnoreThisComponentCompletely> |
|||
</Settings> |
|||
</ProjectConfiguration> |
|||
@ -1,7 +1,7 @@ |
|||
<Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> |
|||
<ItemGroup> |
|||
<PackageReference Include="HarfBuzzSharp" Version="2.8.2-preview.178" /> |
|||
<PackageReference Condition="'$(IncludeLinuxSkia)' == 'true'" Include="HarfBuzzSharp.NativeAssets.Linux" Version="2.8.2-preview.178" /> |
|||
<PackageReference Condition="'$(IncludeWasmSkia)' == 'true'" Include="HarfBuzzSharp.NativeAssets.WebAssembly" Version="2.8.2-preview.178"/> |
|||
<PackageReference Include="HarfBuzzSharp" Version="2.8.2-preview.209" /> |
|||
<PackageReference Condition="'$(IncludeLinuxSkia)' == 'true'" Include="HarfBuzzSharp.NativeAssets.Linux" Version="2.8.2-preview.209" /> |
|||
<PackageReference Condition="'$(IncludeWasmSkia)' == 'true'" Include="HarfBuzzSharp.NativeAssets.WebAssembly" Version="2.8.2-preview.209"/> |
|||
</ItemGroup> |
|||
</Project> |
|||
|
|||
@ -1,7 +1,7 @@ |
|||
<Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> |
|||
<ItemGroup> |
|||
<PackageReference Include="SkiaSharp" Version="2.88.0-preview.178" /> |
|||
<PackageReference Condition="'$(IncludeLinuxSkia)' == 'true'" Include="SkiaSharp.NativeAssets.Linux" Version="2.88.0-preview.178" /> |
|||
<PackageReference Condition="'$(IncludeWasmSkia)' == 'true'" Include="SkiaSharp.NativeAssets.WebAssembly" Version="2.88.0-preview.178"/> |
|||
<PackageReference Include="SkiaSharp" Version="2.88.0-preview.209" /> |
|||
<PackageReference Condition="'$(IncludeLinuxSkia)' == 'true'" Include="SkiaSharp.NativeAssets.Linux" Version="2.88.0-preview.209" /> |
|||
<PackageReference Condition="'$(IncludeWasmSkia)' == 'true'" Include="SkiaSharp.NativeAssets.WebAssembly" Version="2.88.0-preview.209"/> |
|||
</ItemGroup> |
|||
</Project> |
|||
|
|||
@ -0,0 +1,12 @@ |
|||
#import <Cocoa/Cocoa.h> |
|||
#include "window.h" |
|||
|
|||
NS_ASSUME_NONNULL_BEGIN |
|||
|
|||
class IAvnAutomationPeer; |
|||
|
|||
@interface AvnAccessibilityElement : NSAccessibilityElement |
|||
+ (AvnAccessibilityElement *) acquire:(IAvnAutomationPeer *) peer; |
|||
@end |
|||
|
|||
NS_ASSUME_NONNULL_END |
|||
@ -0,0 +1,496 @@ |
|||
#include "common.h" |
|||
#include "automation.h" |
|||
#include "AvnString.h" |
|||
#include "window.h" |
|||
|
|||
@interface AvnAccessibilityElement (Events) |
|||
- (void) raiseChildrenChanged; |
|||
@end |
|||
|
|||
@interface AvnRootAccessibilityElement : AvnAccessibilityElement |
|||
- (AvnView *) ownerView; |
|||
- (AvnRootAccessibilityElement *) initWithPeer:(IAvnAutomationPeer *) peer owner:(AvnView*) owner; |
|||
- (void) raiseFocusChanged; |
|||
@end |
|||
|
|||
class AutomationNode : public ComSingleObject<IAvnAutomationNode, &IID_IAvnAutomationNode> |
|||
{ |
|||
public: |
|||
FORWARD_IUNKNOWN() |
|||
|
|||
AutomationNode(AvnAccessibilityElement* owner) |
|||
{ |
|||
_owner = owner; |
|||
} |
|||
|
|||
AvnAccessibilityElement* GetOwner() |
|||
{ |
|||
return _owner; |
|||
} |
|||
|
|||
virtual void Dispose() override |
|||
{ |
|||
_owner = nil; |
|||
} |
|||
|
|||
virtual void ChildrenChanged () override |
|||
{ |
|||
[_owner raiseChildrenChanged]; |
|||
} |
|||
|
|||
virtual void PropertyChanged (AvnAutomationProperty property) override |
|||
{ |
|||
|
|||
} |
|||
|
|||
virtual void FocusChanged () override |
|||
{ |
|||
[(AvnRootAccessibilityElement*)_owner raiseFocusChanged]; |
|||
} |
|||
|
|||
private: |
|||
__strong AvnAccessibilityElement* _owner; |
|||
}; |
|||
|
|||
@implementation AvnAccessibilityElement |
|||
{ |
|||
IAvnAutomationPeer* _peer; |
|||
AutomationNode* _node; |
|||
NSMutableArray* _children; |
|||
} |
|||
|
|||
+ (AvnAccessibilityElement *)acquire:(IAvnAutomationPeer *)peer |
|||
{ |
|||
if (peer == nullptr) |
|||
return nil; |
|||
|
|||
auto instance = peer->GetNode(); |
|||
|
|||
if (instance != nullptr) |
|||
return dynamic_cast<AutomationNode*>(instance)->GetOwner(); |
|||
|
|||
if (peer->IsRootProvider()) |
|||
{ |
|||
auto window = peer->RootProvider_GetWindow(); |
|||
auto holder = dynamic_cast<INSWindowHolder*>(window); |
|||
auto view = holder->GetNSView(); |
|||
return [[AvnRootAccessibilityElement alloc] initWithPeer:peer owner:view]; |
|||
} |
|||
else |
|||
{ |
|||
return [[AvnAccessibilityElement alloc] initWithPeer:peer]; |
|||
} |
|||
} |
|||
|
|||
- (AvnAccessibilityElement *)initWithPeer:(IAvnAutomationPeer *)peer |
|||
{ |
|||
self = [super init]; |
|||
_peer = peer; |
|||
_node = new AutomationNode(self); |
|||
_peer->SetNode(_node); |
|||
return self; |
|||
} |
|||
|
|||
- (void)dealloc |
|||
{ |
|||
if (_node) |
|||
delete _node; |
|||
_node = nullptr; |
|||
} |
|||
|
|||
- (NSString *)description |
|||
{ |
|||
return [NSString stringWithFormat:@"%@ '%@' (%p)", |
|||
GetNSStringAndRelease(_peer->GetClassName()), |
|||
GetNSStringAndRelease(_peer->GetName()), |
|||
_peer]; |
|||
} |
|||
|
|||
- (IAvnAutomationPeer *)peer |
|||
{ |
|||
return _peer; |
|||
} |
|||
|
|||
- (BOOL)isAccessibilityElement |
|||
{ |
|||
return _peer->IsControlElement(); |
|||
} |
|||
|
|||
- (NSAccessibilityRole)accessibilityRole |
|||
{ |
|||
auto controlType = _peer->GetAutomationControlType(); |
|||
|
|||
switch (controlType) { |
|||
case AutomationButton: return NSAccessibilityButtonRole; |
|||
case AutomationCalendar: return NSAccessibilityGridRole; |
|||
case AutomationCheckBox: return NSAccessibilityCheckBoxRole; |
|||
case AutomationComboBox: return NSAccessibilityPopUpButtonRole; |
|||
case AutomationComboBoxItem: return NSAccessibilityMenuItemRole; |
|||
case AutomationEdit: return NSAccessibilityTextFieldRole; |
|||
case AutomationHyperlink: return NSAccessibilityLinkRole; |
|||
case AutomationImage: return NSAccessibilityImageRole; |
|||
case AutomationListItem: return NSAccessibilityRowRole; |
|||
case AutomationList: return NSAccessibilityTableRole; |
|||
case AutomationMenu: return NSAccessibilityMenuBarRole; |
|||
case AutomationMenuBar: return NSAccessibilityMenuBarRole; |
|||
case AutomationMenuItem: return NSAccessibilityMenuItemRole; |
|||
case AutomationProgressBar: return NSAccessibilityProgressIndicatorRole; |
|||
case AutomationRadioButton: return NSAccessibilityRadioButtonRole; |
|||
case AutomationScrollBar: return NSAccessibilityScrollBarRole; |
|||
case AutomationSlider: return NSAccessibilitySliderRole; |
|||
case AutomationSpinner: return NSAccessibilityIncrementorRole; |
|||
case AutomationStatusBar: return NSAccessibilityTableRole; |
|||
case AutomationTab: return NSAccessibilityTabGroupRole; |
|||
case AutomationTabItem: return NSAccessibilityRadioButtonRole; |
|||
case AutomationText: return NSAccessibilityStaticTextRole; |
|||
case AutomationToolBar: return NSAccessibilityToolbarRole; |
|||
case AutomationToolTip: return NSAccessibilityPopoverRole; |
|||
case AutomationTree: return NSAccessibilityOutlineRole; |
|||
case AutomationTreeItem: return NSAccessibilityCellRole; |
|||
case AutomationCustom: return NSAccessibilityUnknownRole; |
|||
case AutomationGroup: return NSAccessibilityGroupRole; |
|||
case AutomationThumb: return NSAccessibilityHandleRole; |
|||
case AutomationDataGrid: return NSAccessibilityGridRole; |
|||
case AutomationDataItem: return NSAccessibilityCellRole; |
|||
case AutomationDocument: return NSAccessibilityStaticTextRole; |
|||
case AutomationSplitButton: return NSAccessibilityPopUpButtonRole; |
|||
case AutomationWindow: return NSAccessibilityWindowRole; |
|||
case AutomationPane: return NSAccessibilityGroupRole; |
|||
case AutomationHeader: return NSAccessibilityGroupRole; |
|||
case AutomationHeaderItem: return NSAccessibilityButtonRole; |
|||
case AutomationTable: return NSAccessibilityTableRole; |
|||
case AutomationTitleBar: return NSAccessibilityGroupRole; |
|||
// Treat unknown roles as generic group container items. Returning |
|||
// NSAccessibilityUnknownRole is also possible but makes the screen |
|||
// reader focus on the item instead of passing focus to child items. |
|||
default: return NSAccessibilityGroupRole; |
|||
} |
|||
} |
|||
|
|||
- (NSString *)accessibilityIdentifier |
|||
{ |
|||
return GetNSStringAndRelease(_peer->GetAutomationId()); |
|||
} |
|||
|
|||
- (NSString *)accessibilityTitle |
|||
{ |
|||
// StaticText exposes its text via the value property. |
|||
if (_peer->GetAutomationControlType() != AutomationText) |
|||
{ |
|||
return GetNSStringAndRelease(_peer->GetName()); |
|||
} |
|||
|
|||
return [super accessibilityTitle]; |
|||
} |
|||
|
|||
- (id)accessibilityValue |
|||
{ |
|||
if (_peer->IsRangeValueProvider()) |
|||
{ |
|||
return [NSNumber numberWithDouble:_peer->RangeValueProvider_GetValue()]; |
|||
} |
|||
else if (_peer->IsToggleProvider()) |
|||
{ |
|||
switch (_peer->ToggleProvider_GetToggleState()) { |
|||
case 0: return [NSNumber numberWithBool:NO]; |
|||
case 1: return [NSNumber numberWithBool:YES]; |
|||
default: return [NSNumber numberWithInt:2]; |
|||
} |
|||
} |
|||
else if (_peer->IsValueProvider()) |
|||
{ |
|||
return GetNSStringAndRelease(_peer->ValueProvider_GetValue()); |
|||
} |
|||
else if (_peer->GetAutomationControlType() == AutomationText) |
|||
{ |
|||
return GetNSStringAndRelease(_peer->GetName()); |
|||
} |
|||
|
|||
return [super accessibilityValue]; |
|||
} |
|||
|
|||
- (id)accessibilityMinValue |
|||
{ |
|||
if (_peer->IsRangeValueProvider()) |
|||
{ |
|||
return [NSNumber numberWithDouble:_peer->RangeValueProvider_GetMinimum()]; |
|||
} |
|||
|
|||
return [super accessibilityMinValue]; |
|||
} |
|||
|
|||
- (id)accessibilityMaxValue |
|||
{ |
|||
if (_peer->IsRangeValueProvider()) |
|||
{ |
|||
return [NSNumber numberWithDouble:_peer->RangeValueProvider_GetMaximum()]; |
|||
} |
|||
|
|||
return [super accessibilityMaxValue]; |
|||
} |
|||
|
|||
- (BOOL)isAccessibilityEnabled |
|||
{ |
|||
return _peer->IsEnabled(); |
|||
} |
|||
|
|||
- (BOOL)isAccessibilityFocused |
|||
{ |
|||
return _peer->HasKeyboardFocus(); |
|||
} |
|||
|
|||
- (NSArray *)accessibilityChildren |
|||
{ |
|||
if (_children == nullptr && _peer != nullptr) |
|||
[self recalculateChildren]; |
|||
return _children; |
|||
} |
|||
|
|||
- (NSRect)accessibilityFrame |
|||
{ |
|||
id topLevel = [self accessibilityTopLevelUIElement]; |
|||
auto result = NSZeroRect; |
|||
|
|||
if ([topLevel isKindOfClass:[AvnRootAccessibilityElement class]]) |
|||
{ |
|||
auto root = (AvnRootAccessibilityElement*)topLevel; |
|||
auto view = [root ownerView]; |
|||
|
|||
if (view) |
|||
{ |
|||
auto window = [view window]; |
|||
auto bounds = ToNSRect(_peer->GetBoundingRectangle()); |
|||
auto windowBounds = [view convertRect:bounds toView:nil]; |
|||
auto screenBounds = [window convertRectToScreen:windowBounds]; |
|||
result = screenBounds; |
|||
} |
|||
} |
|||
|
|||
return result; |
|||
} |
|||
|
|||
- (id)accessibilityParent |
|||
{ |
|||
auto parentPeer = _peer->GetParent(); |
|||
return parentPeer ? [AvnAccessibilityElement acquire:parentPeer] : [NSApplication sharedApplication]; |
|||
} |
|||
|
|||
- (id)accessibilityTopLevelUIElement |
|||
{ |
|||
auto rootPeer = _peer->GetRootPeer(); |
|||
return [AvnAccessibilityElement acquire:rootPeer]; |
|||
} |
|||
|
|||
- (id)accessibilityWindow |
|||
{ |
|||
id topLevel = [self accessibilityTopLevelUIElement]; |
|||
return [topLevel isKindOfClass:[NSWindow class]] ? topLevel : nil; |
|||
} |
|||
|
|||
- (BOOL)isAccessibilityExpanded |
|||
{ |
|||
if (!_peer->IsExpandCollapseProvider()) |
|||
return NO; |
|||
return _peer->ExpandCollapseProvider_GetIsExpanded(); |
|||
} |
|||
|
|||
- (void)setAccessibilityExpanded:(BOOL)accessibilityExpanded |
|||
{ |
|||
if (!_peer->IsExpandCollapseProvider()) |
|||
return; |
|||
if (accessibilityExpanded) |
|||
_peer->ExpandCollapseProvider_Expand(); |
|||
else |
|||
_peer->ExpandCollapseProvider_Collapse(); |
|||
} |
|||
|
|||
- (BOOL)accessibilityPerformPress |
|||
{ |
|||
if (_peer->IsInvokeProvider()) |
|||
{ |
|||
_peer->InvokeProvider_Invoke(); |
|||
} |
|||
else if (_peer->IsExpandCollapseProvider()) |
|||
{ |
|||
_peer->ExpandCollapseProvider_Expand(); |
|||
} |
|||
else if (_peer->IsToggleProvider()) |
|||
{ |
|||
_peer->ToggleProvider_Toggle(); |
|||
} |
|||
return YES; |
|||
} |
|||
|
|||
- (BOOL)accessibilityPerformIncrement |
|||
{ |
|||
if (!_peer->IsRangeValueProvider()) |
|||
return NO; |
|||
auto value = _peer->RangeValueProvider_GetValue(); |
|||
value += _peer->RangeValueProvider_GetSmallChange(); |
|||
_peer->RangeValueProvider_SetValue(value); |
|||
return YES; |
|||
} |
|||
|
|||
- (BOOL)accessibilityPerformDecrement |
|||
{ |
|||
if (!_peer->IsRangeValueProvider()) |
|||
return NO; |
|||
auto value = _peer->RangeValueProvider_GetValue(); |
|||
value -= _peer->RangeValueProvider_GetSmallChange(); |
|||
_peer->RangeValueProvider_SetValue(value); |
|||
return YES; |
|||
} |
|||
|
|||
- (BOOL)accessibilityPerformShowMenu |
|||
{ |
|||
if (!_peer->IsExpandCollapseProvider()) |
|||
return NO; |
|||
_peer->ExpandCollapseProvider_Expand(); |
|||
return YES; |
|||
} |
|||
|
|||
- (BOOL)isAccessibilitySelected |
|||
{ |
|||
if (_peer->IsSelectionItemProvider()) |
|||
return _peer->SelectionItemProvider_IsSelected(); |
|||
return NO; |
|||
} |
|||
|
|||
- (BOOL)isAccessibilitySelectorAllowed:(SEL)selector |
|||
{ |
|||
if (selector == @selector(accessibilityPerformShowMenu)) |
|||
{ |
|||
return _peer->IsExpandCollapseProvider() && _peer->ExpandCollapseProvider_GetShowsMenu(); |
|||
} |
|||
else if (selector == @selector(isAccessibilityExpanded)) |
|||
{ |
|||
return _peer->IsExpandCollapseProvider(); |
|||
} |
|||
else if (selector == @selector(accessibilityPerformPress)) |
|||
{ |
|||
return _peer->IsInvokeProvider() || _peer->IsExpandCollapseProvider() || _peer->IsToggleProvider(); |
|||
} |
|||
else if (selector == @selector(accessibilityPerformIncrement) || |
|||
selector == @selector(accessibilityPerformDecrement) || |
|||
selector == @selector(accessibilityMinValue) || |
|||
selector == @selector(accessibilityMaxValue)) |
|||
{ |
|||
return _peer->IsRangeValueProvider(); |
|||
} |
|||
|
|||
return [super isAccessibilitySelectorAllowed:selector]; |
|||
} |
|||
|
|||
- (void)raiseChildrenChanged |
|||
{ |
|||
auto changed = _children ? [NSMutableSet setWithArray:_children] : [NSMutableSet set]; |
|||
|
|||
[self recalculateChildren]; |
|||
|
|||
if (_children) |
|||
[changed addObjectsFromArray:_children]; |
|||
|
|||
NSAccessibilityPostNotificationWithUserInfo( |
|||
self, |
|||
NSAccessibilityLayoutChangedNotification, |
|||
@{ NSAccessibilityUIElementsKey: [changed allObjects]}); |
|||
} |
|||
|
|||
- (void)raisePropertyChanged |
|||
{ |
|||
} |
|||
|
|||
- (void)setAccessibilityFocused:(BOOL)accessibilityFocused |
|||
{ |
|||
if (accessibilityFocused) |
|||
_peer->SetFocus(); |
|||
} |
|||
|
|||
- (void)recalculateChildren |
|||
{ |
|||
auto childPeers = _peer->GetChildren(); |
|||
auto childCount = childPeers != nullptr ? childPeers->GetCount() : 0; |
|||
|
|||
if (childCount > 0) |
|||
{ |
|||
_children = [[NSMutableArray alloc] initWithCapacity:childCount]; |
|||
|
|||
for (int i = 0; i < childCount; ++i) |
|||
{ |
|||
IAvnAutomationPeer* child; |
|||
|
|||
if (childPeers->Get(i, &child) == S_OK) |
|||
{ |
|||
auto element = [AvnAccessibilityElement acquire:child]; |
|||
[_children addObject:element]; |
|||
} |
|||
} |
|||
} |
|||
else |
|||
{ |
|||
_children = nil; |
|||
} |
|||
} |
|||
|
|||
@end |
|||
|
|||
@implementation AvnRootAccessibilityElement |
|||
{ |
|||
AvnView* _owner; |
|||
} |
|||
|
|||
- (AvnRootAccessibilityElement *)initWithPeer:(IAvnAutomationPeer *)peer owner:(AvnView *)owner |
|||
{ |
|||
self = [super initWithPeer:peer]; |
|||
_owner = owner; |
|||
|
|||
// Seems we need to raise a focus changed notification here if we have focus |
|||
auto focusedPeer = [self peer]->RootProvider_GetFocus(); |
|||
id focused = [AvnAccessibilityElement acquire:focusedPeer]; |
|||
|
|||
if (focused) |
|||
NSAccessibilityPostNotification(focused, NSAccessibilityFocusedUIElementChangedNotification); |
|||
|
|||
return self; |
|||
} |
|||
|
|||
- (AvnView *)ownerView |
|||
{ |
|||
return _owner; |
|||
} |
|||
|
|||
- (id)accessibilityFocusedUIElement |
|||
{ |
|||
auto focusedPeer = [self peer]->RootProvider_GetFocus(); |
|||
return [AvnAccessibilityElement acquire:focusedPeer]; |
|||
} |
|||
|
|||
- (id)accessibilityHitTest:(NSPoint)point |
|||
{ |
|||
auto clientPoint = [[_owner window] convertPointFromScreen:point]; |
|||
auto localPoint = [_owner translateLocalPoint:ToAvnPoint(clientPoint)]; |
|||
auto hit = [self peer]->RootProvider_GetPeerFromPoint(localPoint); |
|||
return [AvnAccessibilityElement acquire:hit]; |
|||
} |
|||
|
|||
- (id)accessibilityParent |
|||
{ |
|||
return _owner; |
|||
} |
|||
|
|||
- (void)raiseFocusChanged |
|||
{ |
|||
id focused = [self accessibilityFocusedUIElement]; |
|||
NSAccessibilityPostNotification(focused, NSAccessibilityFocusedUIElementChangedNotification); |
|||
} |
|||
|
|||
// Although this method is marked as deprecated we get runtime warnings if we don't handle it. |
|||
#pragma clang diagnostic push |
|||
#pragma clang diagnostic ignored "-Wdeprecated-implementations" |
|||
- (void)accessibilityPerformAction:(NSAccessibilityActionName)action |
|||
{ |
|||
[_owner accessibilityPerformAction:action]; |
|||
} |
|||
#pragma clang diagnostic pop |
|||
|
|||
@end |
|||
@ -0,0 +1,7 @@ |
|||
<Directives> |
|||
<Application> |
|||
<Assembly Name="ControlCatalog" Dynamic="Required All"></Assembly> |
|||
<Assembly Name="Avalonia.Themes.Default" Dynamic="Required All"></Assembly> |
|||
<Assembly Name="Avalonia.Themes.Fluent" Dynamic="Required All"></Assembly> |
|||
</Application> |
|||
</Directives> |
|||
@ -1,186 +1,16 @@ |
|||
<?xml version="1.0" encoding="utf-8"?> |
|||
<Project ToolsVersion="4.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> |
|||
<Project Sdk="Microsoft.NET.Sdk"> |
|||
<PropertyGroup> |
|||
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration> |
|||
<Platform Condition=" '$(Platform)' == '' ">iPhoneSimulator</Platform> |
|||
<ProjectGuid>{57E0455D-D565-44BB-B069-EE1AA20F8337}</ProjectGuid> |
|||
<ProjectTypeGuids>{FEACFBD2-3405-455C-9665-78FE426C6842};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids> |
|||
<OutputType>Exe</OutputType> |
|||
<RootNamespace>ControlCatalog.iOS</RootNamespace> |
|||
<IPhoneResourcePrefix>Resources</IPhoneResourcePrefix> |
|||
<AssemblyName>ControlCatalogiOS</AssemblyName> |
|||
<MtouchEnableSGenConc>true</MtouchEnableSGenConc> |
|||
<MtouchHttpClientHandler>NSUrlSessionHandler</MtouchHttpClientHandler> |
|||
<RestoreProjectStyle>PackageReference</RestoreProjectStyle> |
|||
<ProvisioningType>automatic</ProvisioningType> |
|||
<ProvisioningType>manual</ProvisioningType> |
|||
<TargetFramework>net6.0-ios</TargetFramework> |
|||
<SupportedOSPlatformVersion>10.0</SupportedOSPlatformVersion> |
|||
<!-- temporal workaround for our GL interface backend --> |
|||
<UseInterpreter>True</UseInterpreter> |
|||
<RuntimeIdentifier>iossimulator-x64</RuntimeIdentifier> |
|||
<!-- <RuntimeIdentifier>ios-arm64</RuntimeIdentifier>--> |
|||
</PropertyGroup> |
|||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|iPhoneSimulator' "> |
|||
<DebugSymbols>true</DebugSymbols> |
|||
<DebugType>full</DebugType> |
|||
<Optimize>false</Optimize> |
|||
<OutputPath>bin\iPhoneSimulator\Debug</OutputPath> |
|||
<DefineConstants>DEBUG</DefineConstants> |
|||
<ErrorReport>prompt</ErrorReport> |
|||
<WarningLevel>4</WarningLevel> |
|||
<ConsolePause>false</ConsolePause> |
|||
<MtouchArch>x86_64</MtouchArch> |
|||
<MtouchLink>None</MtouchLink> |
|||
<MtouchDebug>True</MtouchDebug> |
|||
<MtouchSdkVersion>9.1</MtouchSdkVersion> |
|||
<MtouchProfiling>False</MtouchProfiling> |
|||
<MtouchFastDev>False</MtouchFastDev> |
|||
<MtouchNoSymbolStrip>False</MtouchNoSymbolStrip> |
|||
<MtouchUseLlvm>False</MtouchUseLlvm> |
|||
<MtouchUseThumb>False</MtouchUseThumb> |
|||
<MtouchEnableBitcode>False</MtouchEnableBitcode> |
|||
<MtouchUseSGen>False</MtouchUseSGen> |
|||
<MtouchUseRefCounting>False</MtouchUseRefCounting> |
|||
<OptimizePNGs>True</OptimizePNGs> |
|||
<MtouchTlsProvider>Default</MtouchTlsProvider> |
|||
<MtouchHttpClientHandler>HttpClientHandler</MtouchHttpClientHandler> |
|||
<MtouchFloat32>False</MtouchFloat32> |
|||
</PropertyGroup> |
|||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|iPhoneSimulator' "> |
|||
<DebugType>none</DebugType> |
|||
<Optimize>true</Optimize> |
|||
<OutputPath>bin\iPhoneSimulator\Release</OutputPath> |
|||
<ErrorReport>prompt</ErrorReport> |
|||
<WarningLevel>4</WarningLevel> |
|||
<MtouchLink>None</MtouchLink> |
|||
<MtouchArch>x86_64</MtouchArch> |
|||
<ConsolePause>false</ConsolePause> |
|||
</PropertyGroup> |
|||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|iPhone' "> |
|||
<DebugSymbols>true</DebugSymbols> |
|||
<DebugType>full</DebugType> |
|||
<Optimize>false</Optimize> |
|||
<OutputPath>bin\iPhone\Debug</OutputPath> |
|||
<DefineConstants>DEBUG</DefineConstants> |
|||
<ErrorReport>prompt</ErrorReport> |
|||
<WarningLevel>4</WarningLevel> |
|||
<ConsolePause>false</ConsolePause> |
|||
<MtouchArch>ARMv7, ARM64</MtouchArch> |
|||
<CodesignEntitlements>Entitlements.plist</CodesignEntitlements> |
|||
<CodesignKey>iPhone Developer</CodesignKey> |
|||
<MtouchDebug>true</MtouchDebug> |
|||
</PropertyGroup> |
|||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|iPhone' "> |
|||
<DebugType>none</DebugType> |
|||
<Optimize>true</Optimize> |
|||
<OutputPath>bin\iPhone\Release</OutputPath> |
|||
<ErrorReport>prompt</ErrorReport> |
|||
<WarningLevel>4</WarningLevel> |
|||
<CodesignEntitlements>Entitlements.plist</CodesignEntitlements> |
|||
<MtouchArch>ARMv7, ARM64</MtouchArch> |
|||
<ConsolePause>false</ConsolePause> |
|||
<CodesignKey>iPhone Developer</CodesignKey> |
|||
</PropertyGroup> |
|||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Ad-Hoc|iPhone' "> |
|||
<DebugType>none</DebugType> |
|||
<Optimize>True</Optimize> |
|||
<OutputPath>bin\iPhone\Ad-Hoc</OutputPath> |
|||
<ErrorReport>prompt</ErrorReport> |
|||
<WarningLevel>4</WarningLevel> |
|||
<ConsolePause>False</ConsolePause> |
|||
<MtouchArch>ARMv7, ARM64</MtouchArch> |
|||
<CodesignEntitlements>Entitlements.plist</CodesignEntitlements> |
|||
<BuildIpa>True</BuildIpa> |
|||
<CodesignProvision>Automatic:AdHoc</CodesignProvision> |
|||
<CodesignKey>iPhone Distribution</CodesignKey> |
|||
</PropertyGroup> |
|||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'AppStore|iPhone' "> |
|||
<DebugType>none</DebugType> |
|||
<Optimize>True</Optimize> |
|||
<OutputPath>bin\iPhone\AppStore</OutputPath> |
|||
<ErrorReport>prompt</ErrorReport> |
|||
<WarningLevel>4</WarningLevel> |
|||
<ConsolePause>False</ConsolePause> |
|||
<MtouchArch>ARMv7, ARM64</MtouchArch> |
|||
<CodesignEntitlements>Entitlements.plist</CodesignEntitlements> |
|||
<CodesignProvision>Automatic:AppStore</CodesignProvision> |
|||
<CodesignKey>iPhone Distribution</CodesignKey> |
|||
</PropertyGroup> |
|||
<ItemGroup> |
|||
<Compile Include="Main.cs" /> |
|||
<Compile Include="AppDelegate.cs" /> |
|||
<None Include="Info.plist" /> |
|||
<Compile Include="Properties\AssemblyInfo.cs" /> |
|||
<InterfaceDefinition Include="Resources\LaunchScreen.xib" /> |
|||
<Content Include="Entitlements.plist" /> |
|||
</ItemGroup> |
|||
<ItemGroup> |
|||
<Reference Include="System" /> |
|||
<Reference Include="System.Xml" /> |
|||
<Reference Include="System.Core" /> |
|||
<Reference Include="Xamarin.iOS" /> |
|||
</ItemGroup> |
|||
<ItemGroup> |
|||
<ProjectReference Include="..\..\src\iOS\Avalonia.iOS\Avalonia.iOS.csproj"> |
|||
<Project>{4488AD85-1495-4809-9AA4-DDFE0A48527E}</Project> |
|||
<Name>Avalonia.iOS</Name> |
|||
<IsAppExtension>false</IsAppExtension> |
|||
<IsWatchApp>false</IsWatchApp> |
|||
</ProjectReference> |
|||
<ProjectReference Include="..\..\src\Markup\Avalonia.Markup.Xaml\Avalonia.Markup.Xaml.csproj"> |
|||
<Project>{3E53A01A-B331-47F3-B828-4A5717E77A24}</Project> |
|||
<Name>Avalonia.Markup.Xaml</Name> |
|||
</ProjectReference> |
|||
<ProjectReference Include="..\..\src\Markup\Avalonia.Markup\Avalonia.Markup.csproj"> |
|||
<Project>{6417E941-21BC-467B-A771-0DE389353CE6}</Project> |
|||
<Name>Avalonia.Markup</Name> |
|||
</ProjectReference> |
|||
<ProjectReference Include="..\..\src\Avalonia.Animation\Avalonia.Animation.csproj"> |
|||
<Project>{D211E587-D8BC-45B9-95A4-F297C8FA5200}</Project> |
|||
<Name>Avalonia.Animation</Name> |
|||
</ProjectReference> |
|||
<ProjectReference Include="..\..\src\Avalonia.Base\Avalonia.Base.csproj"> |
|||
<Project>{B09B78D8-9B26-48B0-9149-D64A2F120F3F}</Project> |
|||
<Name>Avalonia.Base</Name> |
|||
</ProjectReference> |
|||
<ProjectReference Include="..\..\src\Avalonia.Controls\Avalonia.Controls.csproj"> |
|||
<Project>{D2221C82-4A25-4583-9B43-D791E3F6820C}</Project> |
|||
<Name>Avalonia.Controls</Name> |
|||
</ProjectReference> |
|||
<ProjectReference Include="..\..\src\Avalonia.Diagnostics\Avalonia.Diagnostics.csproj"> |
|||
<Project>{7062AE20-5DCC-4442-9645-8195BDECE63E}</Project> |
|||
<Name>Avalonia.Diagnostics</Name> |
|||
</ProjectReference> |
|||
<ProjectReference Include="..\..\src\Avalonia.Input\Avalonia.Input.csproj"> |
|||
<Project>{62024B2D-53EB-4638-B26B-85EEAA54866E}</Project> |
|||
<Name>Avalonia.Input</Name> |
|||
</ProjectReference> |
|||
<ProjectReference Include="..\..\src\Avalonia.Interactivity\Avalonia.Interactivity.csproj"> |
|||
<Project>{6B0ED19D-A08B-461C-A9D9-A9EE40B0C06B}</Project> |
|||
<Name>Avalonia.Interactivity</Name> |
|||
</ProjectReference> |
|||
<ProjectReference Include="..\..\src\Avalonia.Layout\Avalonia.Layout.csproj"> |
|||
<Project>{42472427-4774-4C81-8AFF-9F27B8E31721}</Project> |
|||
<Name>Avalonia.Layout</Name> |
|||
</ProjectReference> |
|||
<ProjectReference Include="..\..\src\Avalonia.Visuals\Avalonia.Visuals.csproj"> |
|||
<Project>{EB582467-6ABB-43A1-B052-E981BA910E3A}</Project> |
|||
<Name>Avalonia.Visuals</Name> |
|||
</ProjectReference> |
|||
<ProjectReference Include="..\..\src\Avalonia.Styling\Avalonia.Styling.csproj"> |
|||
<Project>{F1BAA01A-F176-4C6A-B39D-5B40BB1B148F}</Project> |
|||
<Name>Avalonia.Styling</Name> |
|||
</ProjectReference> |
|||
<ProjectReference Include="..\..\src\Avalonia.Themes.Default\Avalonia.Themes.Default.csproj"> |
|||
<Project>{3E10A5FA-E8DA-48B1-AD44-6A5B6CB7750F}</Project> |
|||
<Name>Avalonia.Themes.Default</Name> |
|||
</ProjectReference> |
|||
<ProjectReference Include="..\..\src\Skia\Avalonia.Skia\Avalonia.Skia.csproj"> |
|||
<Project>{7d2d3083-71dd-4cc9-8907-39a0d86fb322}</Project> |
|||
<Name>Avalonia.Skia</Name> |
|||
</ProjectReference> |
|||
<ProjectReference Include="..\ControlCatalog\ControlCatalog.csproj"> |
|||
<Project>{d0a739b9-3c68-4ba6-a328-41606954b6bd}</Project> |
|||
<Name>ControlCatalog</Name> |
|||
</ProjectReference> |
|||
<PackageReference Include="SkiaSharp.HarfBuzz" Version="2.80.2-preview.33" /> |
|||
<ProjectReference Include="..\..\src\iOS\Avalonia.iOS\Avalonia.iOS.csproj" /> |
|||
<ProjectReference Include="..\ControlCatalog\ControlCatalog.csproj" /> |
|||
</ItemGroup> |
|||
<Import Project="$(MSBuildExtensionsPath)\Xamarin\iOS\Xamarin.iOS.CSharp.targets" /> |
|||
<Import Project="..\..\build\LegacyProject.targets" /> |
|||
<Import Project="..\..\build\SkiaSharp.props" /> |
|||
<Import Project="..\..\build\HarfBuzzSharp.props" /> |
|||
</Project> |
|||
|
|||
@ -1,36 +0,0 @@ |
|||
using System.Reflection; |
|||
using System.Runtime.CompilerServices; |
|||
using System.Runtime.InteropServices; |
|||
|
|||
// General Information about an assembly is controlled through the following
|
|||
// set of attributes. Change these attribute values to modify the information
|
|||
// associated with an assembly.
|
|||
[assembly: AssemblyTitle("ControlCatalog.iOS")] |
|||
[assembly: AssemblyDescription("")] |
|||
[assembly: AssemblyConfiguration("")] |
|||
[assembly: AssemblyCompany("")] |
|||
[assembly: AssemblyProduct("ControlCatalog.iOS")] |
|||
[assembly: AssemblyCopyright("Copyright © 2016")] |
|||
[assembly: AssemblyTrademark("")] |
|||
[assembly: AssemblyCulture("")] |
|||
|
|||
// Setting ComVisible to false makes the types in this assembly not visible
|
|||
// to COM components. If you need to access a type in this assembly from
|
|||
// COM, set the ComVisible attribute to true on that type.
|
|||
[assembly: ComVisible(false)] |
|||
|
|||
// The following GUID is for the ID of the typelib if this project is exposed to COM
|
|||
[assembly: Guid("57e0455d-d565-44bb-b069-ee1aa20f8337")] |
|||
|
|||
// Version information for an assembly consists of the following four values:
|
|||
//
|
|||
// Major Version
|
|||
// Minor Version
|
|||
// Build Number
|
|||
// Revision
|
|||
//
|
|||
// You can specify all the values or you can default the Build and Revision Numbers
|
|||
// by using the '*' as shown below:
|
|||
// [assembly: AssemblyVersion("1.0.*")]
|
|||
[assembly: AssemblyVersion("1.0.0.0")] |
|||
[assembly: AssemblyFileVersion("1.0.0.0")] |
|||
@ -0,0 +1,18 @@ |
|||
using System; |
|||
using System.Globalization; |
|||
using Avalonia.Data.Converters; |
|||
|
|||
namespace ControlCatalog.Converter; |
|||
|
|||
public class MathSubtractConverter : IValueConverter |
|||
{ |
|||
public object Convert(object value, Type targetType, object parameter, CultureInfo culture) |
|||
{ |
|||
return (double)value - (double)parameter; |
|||
} |
|||
|
|||
public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture) |
|||
{ |
|||
throw new NotSupportedException(); |
|||
} |
|||
} |
|||
@ -0,0 +1,23 @@ |
|||
<UserControl x:Class="ControlCatalog.Pages.ClipboardPage" |
|||
xmlns="https://github.com/avaloniaui" |
|||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"> |
|||
<StackPanel Orientation="Vertical" Spacing="4"> |
|||
<TextBlock Classes="h2">Example of ClipboardPage capabilities</TextBlock> |
|||
|
|||
<Button Click="CopyText" Content="Copy text to clipboard" /> |
|||
<Button Click="PasteText" Content="Paste text from clipboard" /> |
|||
<Button Click="CopyTextDataObject" Content="Copy text to clipboard (data object)" /> |
|||
<Button Click="PasteTextDataObject" Content="Paste text from clipboard (data object)" /> |
|||
|
|||
<Button Click="CopyFilesDataObject" Content="Copy files to clipboard (data object)" /> |
|||
<Button Click="PasteFilesDataObject" Content="Paste files from clipboard (data object)" /> |
|||
|
|||
<Button Click="GetFormats" Content="Get clipboard formats" /> |
|||
<Button Click="Clear" Content="Clear clipboard" /> |
|||
|
|||
<TextBox x:Name="ClipboardContent" |
|||
MinHeight="100" |
|||
AcceptsReturn="True" |
|||
Watermark="Text to copy of file names per line" /> |
|||
</StackPanel> |
|||
</UserControl> |
|||
@ -0,0 +1,77 @@ |
|||
using System; |
|||
using System.Collections.Generic; |
|||
|
|||
using Avalonia; |
|||
using Avalonia.Controls; |
|||
using Avalonia.Input; |
|||
using Avalonia.Interactivity; |
|||
using Avalonia.Markup.Xaml; |
|||
|
|||
namespace ControlCatalog.Pages |
|||
{ |
|||
public partial class ClipboardPage : UserControl |
|||
{ |
|||
public ClipboardPage() |
|||
{ |
|||
InitializeComponent(); |
|||
} |
|||
|
|||
private TextBox ClipboardContent => this.Get<TextBox>("ClipboardContent"); |
|||
|
|||
private void InitializeComponent() |
|||
{ |
|||
AvaloniaXamlLoader.Load(this); |
|||
} |
|||
|
|||
private async void CopyText(object sender, RoutedEventArgs args) |
|||
{ |
|||
await Application.Current.Clipboard.SetTextAsync(ClipboardContent.Text); |
|||
} |
|||
|
|||
private async void PasteText(object sender, RoutedEventArgs args) |
|||
{ |
|||
ClipboardContent.Text = await Application.Current.Clipboard.GetTextAsync(); |
|||
} |
|||
|
|||
private async void CopyTextDataObject(object sender, RoutedEventArgs args) |
|||
{ |
|||
var dataObject = new DataObject(); |
|||
dataObject.Set(DataFormats.Text, ClipboardContent.Text ?? string.Empty); |
|||
await Application.Current.Clipboard.SetDataObjectAsync(dataObject); |
|||
} |
|||
|
|||
private async void PasteTextDataObject(object sender, RoutedEventArgs args) |
|||
{ |
|||
ClipboardContent.Text = await Application.Current.Clipboard.GetDataAsync(DataFormats.Text) as string ?? string.Empty; |
|||
} |
|||
|
|||
private async void CopyFilesDataObject(object sender, RoutedEventArgs args) |
|||
{ |
|||
var files = ClipboardContent.Text.Split(new[] { Environment.NewLine }, StringSplitOptions.RemoveEmptyEntries); |
|||
if (files.Length == 0) |
|||
{ |
|||
return; |
|||
} |
|||
var dataObject = new DataObject(); |
|||
dataObject.Set(DataFormats.FileNames, files); |
|||
await Application.Current.Clipboard.SetDataObjectAsync(dataObject); |
|||
} |
|||
|
|||
private async void PasteFilesDataObject(object sender, RoutedEventArgs args) |
|||
{ |
|||
var fiels = await Application.Current.Clipboard.GetDataAsync(DataFormats.FileNames) as IEnumerable<string>; |
|||
ClipboardContent.Text = fiels != null ? string.Join(Environment.NewLine, fiels) : string.Empty; |
|||
} |
|||
|
|||
private async void GetFormats(object sender, RoutedEventArgs args) |
|||
{ |
|||
var formats = await Application.Current.Clipboard.GetFormatsAsync(); |
|||
ClipboardContent.Text = string.Join(Environment.NewLine, formats); |
|||
} |
|||
|
|||
private async void Clear(object sender, RoutedEventArgs args) |
|||
{ |
|||
await Application.Current.Clipboard.ClearAsync(); |
|||
} |
|||
} |
|||
} |
|||
@ -0,0 +1,82 @@ |
|||
<UserControl xmlns="https://github.com/avaloniaui" |
|||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" |
|||
xmlns:d="http://schemas.microsoft.com/expression/blend/2008" |
|||
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" |
|||
xmlns:vm="using:ControlCatalog.ViewModels" |
|||
xmlns:converter="clr-namespace:ControlCatalog.Converter" |
|||
xmlns:system="using:System" |
|||
mc:Ignorable="d" d:DesignWidth="800" d:DesignHeight="450" |
|||
x:DataType="vm:TransitioningContentControlPageViewModel" |
|||
x:CompileBindings="True" |
|||
x:Class="ControlCatalog.Pages.TransitioningContentControlPage"> |
|||
|
|||
<UserControl.DataContext> |
|||
<vm:TransitioningContentControlPageViewModel /> |
|||
</UserControl.DataContext> |
|||
|
|||
<UserControl.Styles> |
|||
<Style Selector="HeaderedContentControl"> |
|||
<Setter Property="Template"> |
|||
<Setter.Value> |
|||
<ControlTemplate> |
|||
<Grid> |
|||
<Grid.ColumnDefinitions> |
|||
<ColumnDefinition Width="Auto" SharedSizeGroup="HeaderCol" /> |
|||
<ColumnDefinition Width="*" /> |
|||
</Grid.ColumnDefinitions> |
|||
<ContentPresenter Content="{TemplateBinding Header}" |
|||
Grid.Column="0" |
|||
VerticalAlignment="Center" /> |
|||
<ContentPresenter Content="{TemplateBinding Content}" |
|||
Grid.Column="1" |
|||
VerticalAlignment="Center" /> |
|||
</Grid> |
|||
</ControlTemplate> |
|||
</Setter.Value> |
|||
</Setter> |
|||
</Style> |
|||
</UserControl.Styles> |
|||
|
|||
<UserControl.Resources> |
|||
<converter:MathSubtractConverter x:Key="MathSubtractConverter" /> |
|||
<system:Double x:Key="TopMargin">8</system:Double> |
|||
</UserControl.Resources> |
|||
|
|||
<DockPanel LastChildFill="True" |
|||
Height="{Binding Path=Bounds.Height, RelativeSource={RelativeSource Mode=FindAncestor, AncestorType=Grid}, Converter={StaticResource MathSubtractConverter},ConverterParameter={StaticResource TopMargin}}"> |
|||
|
|||
<TextBlock DockPanel.Dock="Top" Classes="h2">The TransitioningContentControl control allows you to show a page transition whenever the Content changes.</TextBlock> |
|||
|
|||
<ExperimentalAcrylicBorder DockPanel.Dock="Bottom" Margin="10" CornerRadius="5" > |
|||
<ExperimentalAcrylicBorder.Material> |
|||
<ExperimentalAcrylicMaterial BackgroundSource="Digger" TintColor="White" /> |
|||
</ExperimentalAcrylicBorder.Material> |
|||
|
|||
<StackPanel Margin="5" Spacing="5" Grid.IsSharedSizeScope="True"> |
|||
<HeaderedContentControl Header="Select a transition"> |
|||
<ComboBox Items="{Binding PageTransitions}" SelectedItem="{Binding SelectedTransition}" /> |
|||
</HeaderedContentControl> |
|||
<HeaderedContentControl Header="Duration"> |
|||
<NumericUpDown Value="{Binding Duration}" Increment="250" Minimum="100" /> |
|||
</HeaderedContentControl> |
|||
<HeaderedContentControl Header="Clip to Bounds"> |
|||
<ToggleSwitch IsChecked="{Binding ClipToBounds}" /> |
|||
</HeaderedContentControl> |
|||
</StackPanel> |
|||
</ExperimentalAcrylicBorder> |
|||
|
|||
<Button DockPanel.Dock="Left" Command="{Binding PrevImage}" Content="<" /> |
|||
<Button DockPanel.Dock="Right" Command="{Binding NextImage}" Content=">" /> |
|||
|
|||
<Border ClipToBounds="{Binding ClipToBounds}" Margin="5"> |
|||
<TransitioningContentControl Content="{Binding SelectedImage}" |
|||
PageTransition="{Binding SelectedTransition.Transition}" > |
|||
<TransitioningContentControl.ContentTemplate> |
|||
<DataTemplate DataType="Bitmap"> |
|||
<Image Source="{Binding}" /> |
|||
</DataTemplate> |
|||
</TransitioningContentControl.ContentTemplate> |
|||
</TransitioningContentControl> |
|||
</Border> |
|||
</DockPanel> |
|||
</UserControl> |
|||
@ -0,0 +1,19 @@ |
|||
using Avalonia; |
|||
using Avalonia.Controls; |
|||
using Avalonia.Markup.Xaml; |
|||
|
|||
namespace ControlCatalog.Pages |
|||
{ |
|||
public partial class TransitioningContentControlPage : UserControl |
|||
{ |
|||
public TransitioningContentControlPage() |
|||
{ |
|||
InitializeComponent(); |
|||
} |
|||
|
|||
private void InitializeComponent() |
|||
{ |
|||
AvaloniaXamlLoader.Load(this); |
|||
} |
|||
} |
|||
} |
|||
@ -0,0 +1,309 @@ |
|||
using System; |
|||
using System.Collections.Generic; |
|||
using System.IO; |
|||
using System.Text; |
|||
using System.Threading; |
|||
using System.Threading.Tasks; |
|||
using Avalonia; |
|||
using Avalonia.Animation; |
|||
using Avalonia.Media; |
|||
using Avalonia.Media.Imaging; |
|||
using Avalonia.Platform; |
|||
using Avalonia.Styling; |
|||
using Avalonia.VisualTree; |
|||
using MiniMvvm; |
|||
|
|||
namespace ControlCatalog.ViewModels |
|||
{ |
|||
public class TransitioningContentControlPageViewModel : ViewModelBase |
|||
{ |
|||
public TransitioningContentControlPageViewModel() |
|||
{ |
|||
var assetLoader = AvaloniaLocator.Current.GetService<IAssetLoader>(); |
|||
|
|||
var images = new string[] |
|||
{ |
|||
"delicate-arch-896885_640.jpg", |
|||
"hirsch-899118_640.jpg", |
|||
"maple-leaf-888807_640.jpg" |
|||
}; |
|||
|
|||
foreach (var image in images) |
|||
{ |
|||
var path = $"avares://ControlCatalog/Assets/{image}"; |
|||
Images.Add(new Bitmap(assetLoader.Open(new Uri(path)))); |
|||
} |
|||
|
|||
SetupTransitions(); |
|||
|
|||
SelectedTransition = PageTransitions[1]; |
|||
SelectedImage = Images[0]; |
|||
} |
|||
|
|||
public List<PageTransition> PageTransitions { get; } = new List<PageTransition>(); |
|||
|
|||
public List<Bitmap> Images { get; } = new List<Bitmap>(); |
|||
|
|||
|
|||
private Bitmap? _SelectedImage; |
|||
|
|||
/// <summary>
|
|||
/// Gets or Sets the selected image
|
|||
/// </summary>
|
|||
public Bitmap? SelectedImage |
|||
{ |
|||
get { return _SelectedImage; } |
|||
set { this.RaiseAndSetIfChanged(ref _SelectedImage, value); } |
|||
} |
|||
|
|||
|
|||
private PageTransition _SelectedTransition; |
|||
|
|||
/// <summary>
|
|||
/// Gets or sets the transition to play
|
|||
/// </summary>
|
|||
public PageTransition SelectedTransition |
|||
{ |
|||
get { return _SelectedTransition; } |
|||
set { this.RaiseAndSetIfChanged(ref _SelectedTransition, value); } |
|||
} |
|||
|
|||
|
|||
|
|||
private bool _ClipToBounds; |
|||
|
|||
/// <summary>
|
|||
/// Gets or sets if the content should be clipped to bounds
|
|||
/// </summary>
|
|||
public bool ClipToBounds |
|||
{ |
|||
get { return _ClipToBounds; } |
|||
set { this.RaiseAndSetIfChanged(ref _ClipToBounds, value); } |
|||
} |
|||
|
|||
|
|||
private int _Duration = 500; |
|||
|
|||
/// <summary>
|
|||
/// Gets or Sets the duration
|
|||
/// </summary>
|
|||
public int Duration |
|||
{ |
|||
get { return _Duration; } |
|||
set |
|||
{ |
|||
this.RaiseAndSetIfChanged(ref _Duration , value); |
|||
SetupTransitions(); |
|||
} |
|||
} |
|||
|
|||
private void SetupTransitions() |
|||
{ |
|||
if (PageTransitions.Count == 0) |
|||
{ |
|||
PageTransitions.AddRange(new[] |
|||
{ |
|||
new PageTransition("None"), |
|||
new PageTransition("CrossFade"), |
|||
new PageTransition("Slide horizontally"), |
|||
new PageTransition("Slide vertically"), |
|||
new PageTransition("Composite"), |
|||
new PageTransition("Custom") |
|||
}); |
|||
} |
|||
|
|||
PageTransitions[1].Transition = new CrossFade(TimeSpan.FromMilliseconds(Duration)); |
|||
PageTransitions[2].Transition = new PageSlide(TimeSpan.FromMilliseconds(Duration), PageSlide.SlideAxis.Horizontal); |
|||
PageTransitions[3].Transition = new PageSlide(TimeSpan.FromMilliseconds(Duration), PageSlide.SlideAxis.Vertical); |
|||
|
|||
var compositeTransition = new CompositePageTransition(); |
|||
compositeTransition.PageTransitions.Add(PageTransitions[1].Transition); |
|||
compositeTransition.PageTransitions.Add(PageTransitions[2].Transition); |
|||
compositeTransition.PageTransitions.Add(PageTransitions[3].Transition); |
|||
PageTransitions[4].Transition = compositeTransition; |
|||
|
|||
PageTransitions[5].Transition = new CustomTransition(TimeSpan.FromMilliseconds(Duration)); |
|||
} |
|||
|
|||
public void NextImage() |
|||
{ |
|||
var index = Images.IndexOf(SelectedImage) + 1; |
|||
|
|||
if (index >= Images.Count) |
|||
{ |
|||
index = 0; |
|||
} |
|||
|
|||
SelectedImage = Images[index]; |
|||
} |
|||
|
|||
public void PrevImage() |
|||
{ |
|||
var index = Images.IndexOf(SelectedImage) - 1; |
|||
|
|||
if (index < 0) |
|||
{ |
|||
index = Images.Count-1; |
|||
} |
|||
|
|||
SelectedImage = Images[index]; |
|||
} |
|||
} |
|||
|
|||
public class PageTransition : ViewModelBase |
|||
{ |
|||
public PageTransition(string displayTitle) |
|||
{ |
|||
DisplayTitle = displayTitle; |
|||
} |
|||
|
|||
public string DisplayTitle { get; } |
|||
|
|||
|
|||
private IPageTransition _Transition; |
|||
|
|||
/// <summary>
|
|||
/// Gets or sets the transition
|
|||
/// </summary>
|
|||
public IPageTransition Transition |
|||
{ |
|||
get { return _Transition; } |
|||
set { this.RaiseAndSetIfChanged(ref _Transition, value); } |
|||
} |
|||
|
|||
public override string ToString() |
|||
{ |
|||
return DisplayTitle; |
|||
} |
|||
|
|||
} |
|||
|
|||
public class CustomTransition : IPageTransition |
|||
{ |
|||
/// <summary>
|
|||
/// Initializes a new instance of the <see cref="CustomTransition"/> class.
|
|||
/// </summary>
|
|||
public CustomTransition() |
|||
{ |
|||
} |
|||
|
|||
/// <summary>
|
|||
/// Initializes a new instance of the <see cref="CustomTransition"/> class.
|
|||
/// </summary>
|
|||
/// <param name="duration">The duration of the animation.</param>
|
|||
public CustomTransition(TimeSpan duration) |
|||
{ |
|||
Duration = duration; |
|||
} |
|||
|
|||
/// <summary>
|
|||
/// Gets the duration of the animation.
|
|||
/// </summary>
|
|||
public TimeSpan Duration { get; set; } |
|||
|
|||
public async Task Start(Visual from, Visual to, bool forward, CancellationToken cancellationToken) |
|||
{ |
|||
if (cancellationToken.IsCancellationRequested) |
|||
{ |
|||
return; |
|||
} |
|||
|
|||
var tasks = new List<Task>(); |
|||
var parent = GetVisualParent(from, to); |
|||
var scaleProperty = ScaleTransform.ScaleYProperty; |
|||
|
|||
if (from != null) |
|||
{ |
|||
var animation = new Animation |
|||
{ |
|||
FillMode = FillMode.Forward, |
|||
Children = |
|||
{ |
|||
new KeyFrame |
|||
{ |
|||
Setters = { new Setter { Property = scaleProperty, Value = 1d } }, |
|||
Cue = new Cue(0d) |
|||
}, |
|||
new KeyFrame |
|||
{ |
|||
Setters = |
|||
{ |
|||
new Setter |
|||
{ |
|||
Property = scaleProperty, |
|||
Value = 0d |
|||
} |
|||
}, |
|||
Cue = new Cue(1d) |
|||
} |
|||
}, |
|||
Duration = Duration |
|||
}; |
|||
tasks.Add(animation.RunAsync(from, null, cancellationToken)); |
|||
} |
|||
|
|||
if (to != null) |
|||
{ |
|||
to.IsVisible = true; |
|||
var animation = new Animation |
|||
{ |
|||
FillMode = FillMode.Forward, |
|||
Children = |
|||
{ |
|||
new KeyFrame |
|||
{ |
|||
Setters = |
|||
{ |
|||
new Setter |
|||
{ |
|||
Property = scaleProperty, |
|||
Value = 0d |
|||
} |
|||
}, |
|||
Cue = new Cue(0d) |
|||
}, |
|||
new KeyFrame |
|||
{ |
|||
Setters = { new Setter { Property = scaleProperty, Value = 1d } }, |
|||
Cue = new Cue(1d) |
|||
} |
|||
}, |
|||
Duration = Duration |
|||
}; |
|||
tasks.Add(animation.RunAsync(to, null, cancellationToken)); |
|||
} |
|||
|
|||
await Task.WhenAll(tasks); |
|||
|
|||
if (from != null && !cancellationToken.IsCancellationRequested) |
|||
{ |
|||
from.IsVisible = false; |
|||
} |
|||
} |
|||
|
|||
/// <summary>
|
|||
/// Gets the common visual parent of the two control.
|
|||
/// </summary>
|
|||
/// <param name="from">The from control.</param>
|
|||
/// <param name="to">The to control.</param>
|
|||
/// <returns>The common parent.</returns>
|
|||
/// <exception cref="ArgumentException">
|
|||
/// The two controls do not share a common parent.
|
|||
/// </exception>
|
|||
/// <remarks>
|
|||
/// Any one of the parameters may be null, but not both.
|
|||
/// </remarks>
|
|||
private static IVisual GetVisualParent(IVisual? from, IVisual? to) |
|||
{ |
|||
var p1 = (from ?? to)!.VisualParent; |
|||
var p2 = (to ?? from)!.VisualParent; |
|||
|
|||
if (p1 != null && p2 != null && p1 != p2) |
|||
{ |
|||
throw new ArgumentException("Controls for PageSlide must have same parent."); |
|||
} |
|||
|
|||
return p1 ?? throw new InvalidOperationException("Cannot determine visual parent."); |
|||
} |
|||
} |
|||
} |
|||
@ -0,0 +1,7 @@ |
|||
<Application xmlns="https://github.com/avaloniaui" |
|||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" |
|||
x:Class="IntegrationTestApp.App"> |
|||
<Application.Styles> |
|||
<FluentTheme Mode="Light"/> |
|||
</Application.Styles> |
|||
</Application> |
|||
@ -0,0 +1,24 @@ |
|||
using Avalonia; |
|||
using Avalonia.Controls.ApplicationLifetimes; |
|||
using Avalonia.Markup.Xaml; |
|||
|
|||
namespace IntegrationTestApp |
|||
{ |
|||
public class App : Application |
|||
{ |
|||
public override void Initialize() |
|||
{ |
|||
AvaloniaXamlLoader.Load(this); |
|||
} |
|||
|
|||
public override void OnFrameworkInitializationCompleted() |
|||
{ |
|||
if (ApplicationLifetime is IClassicDesktopStyleApplicationLifetime desktop) |
|||
{ |
|||
desktop.MainWindow = new MainWindow(); |
|||
} |
|||
|
|||
base.OnFrameworkInitializationCompleted(); |
|||
} |
|||
} |
|||
} |
|||
@ -0,0 +1,27 @@ |
|||
<Project Sdk="Microsoft.NET.Sdk"> |
|||
<PropertyGroup> |
|||
<OutputType>WinExe</OutputType> |
|||
<TargetFramework>net6.0</TargetFramework> |
|||
<Nullable>enable</Nullable> |
|||
</PropertyGroup> |
|||
|
|||
<PropertyGroup> |
|||
<CFBundleName>IntegrationTestApp</CFBundleName> |
|||
<CFBundleIdentifier>net.avaloniaui.avalonia.integrationtestapp</CFBundleIdentifier> |
|||
<NSHighResolutionCapable>true</NSHighResolutionCapable> |
|||
<CFBundleShortVersionString>1.0.0</CFBundleShortVersionString> |
|||
</PropertyGroup> |
|||
|
|||
<ItemGroup> |
|||
<PackageReference Include="Dotnet.Bundle" Version="0.9.13" /> |
|||
</ItemGroup> |
|||
|
|||
<ItemGroup> |
|||
<ProjectReference Include="..\..\src\Avalonia.Diagnostics\Avalonia.Diagnostics.csproj" /> |
|||
</ItemGroup> |
|||
|
|||
<Import Project="..\..\build\BuildTargets.targets" /> |
|||
<Import Project="..\..\build\SampleApp.props" /> |
|||
<Import Project="..\..\build\ReferenceCoreLibraries.props" /> |
|||
|
|||
</Project> |
|||
@ -0,0 +1,95 @@ |
|||
<Window xmlns="https://github.com/avaloniaui" |
|||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" |
|||
xmlns:d="http://schemas.microsoft.com/expression/blend/2008" |
|||
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" |
|||
mc:Ignorable="d" d:DesignWidth="800" d:DesignHeight="450" |
|||
x:Class="IntegrationTestApp.MainWindow" |
|||
Title="IntegrationTestApp"> |
|||
<NativeMenu.Menu> |
|||
<NativeMenu> |
|||
<NativeMenuItem Header="File"> |
|||
<NativeMenu> |
|||
<NativeMenuItem Header="Open..."/> |
|||
</NativeMenu> |
|||
</NativeMenuItem> |
|||
<NativeMenuItem Header="View"> |
|||
<NativeMenu/> |
|||
</NativeMenuItem> |
|||
</NativeMenu> |
|||
</NativeMenu.Menu> |
|||
<DockPanel> |
|||
<NativeMenuBar DockPanel.Dock="Top"/> |
|||
|
|||
<TabControl TabStripPlacement="Left" Name="MainTabs"> |
|||
<TabItem Header="Automation"> |
|||
<StackPanel> |
|||
<TextBlock Name="TextBlockWithName">TextBlockWithName</TextBlock> |
|||
<TextBlock Name="NotTheAutomationId" AutomationProperties.AutomationId="TextBlockWithNameAndAutomationId"> |
|||
TextBlockWithNameAndAutomationId |
|||
</TextBlock> |
|||
<TextBlock Name="TextBlockAsLabel">Label for TextBox</TextBlock> |
|||
<TextBox Name="LabeledByTextBox" AutomationProperties.LabeledBy="{Binding #TextBlockAsLabel}"> |
|||
Foo |
|||
</TextBox> |
|||
</StackPanel> |
|||
</TabItem> |
|||
|
|||
<TabItem Header="Button"> |
|||
<StackPanel> |
|||
<Button Name="DisabledButton" IsEnabled="False"> |
|||
Disabled Button |
|||
</Button> |
|||
<Button Name="BasicButton"> |
|||
Basic Button |
|||
</Button> |
|||
<Button Name="ButtonWithTextBlock"> |
|||
<TextBlock>Button with TextBlock</TextBlock> |
|||
</Button> |
|||
<Button Name="ButtonWithAcceleratorKey" HotKey="Ctrl+B">Button with Accelerator Key</Button> |
|||
</StackPanel> |
|||
</TabItem> |
|||
|
|||
<TabItem Header="CheckBox"> |
|||
<StackPanel> |
|||
<CheckBox Name="UncheckedCheckBox">Unchecked</CheckBox> |
|||
<CheckBox Name="CheckedCheckBox" IsChecked="True">Checked</CheckBox> |
|||
<CheckBox Name="ThreeStateCheckBox" IsThreeState="True" IsChecked="{x:Null}">ThreeState</CheckBox> |
|||
</StackPanel> |
|||
</TabItem> |
|||
|
|||
<TabItem Header="ComboBox"> |
|||
<StackPanel> |
|||
<ComboBox Name="BasicComboBox"> |
|||
<ComboBoxItem>Item 0</ComboBoxItem> |
|||
<ComboBoxItem>Item 1</ComboBoxItem> |
|||
</ComboBox> |
|||
<Button Name="ComboBoxSelectionClear">Clear Selection</Button> |
|||
<Button Name="ComboBoxSelectFirst">Select First</Button> |
|||
</StackPanel> |
|||
</TabItem> |
|||
|
|||
<TabItem Header="ListBox"> |
|||
<DockPanel> |
|||
<StackPanel DockPanel.Dock="Bottom"> |
|||
<Button Name="ListBoxSelectionClear">Clear Selection</Button> |
|||
</StackPanel> |
|||
<ListBox Name="BasicListBox" Items="{Binding ListBoxItems}" SelectionMode="Multiple"/> |
|||
</DockPanel> |
|||
</TabItem> |
|||
|
|||
<TabItem Header="Menu"> |
|||
<DockPanel> |
|||
<Menu DockPanel.Dock="Top"> |
|||
<MenuItem Name="RootMenuItem" Header="_Root"> |
|||
<MenuItem Name="Child1MenuItem" Header="_Child 1" InputGesture="Ctrl+O" Click="MenuClicked"/> |
|||
<MenuItem Name="Child2MenuItem" Header="_Child 1"> |
|||
<MenuItem Name="GrandchildMenuItem" Header="_Grandchild" Click="MenuClicked"/> |
|||
</MenuItem> |
|||
</MenuItem> |
|||
</Menu> |
|||
<TextBlock Name="ClickedMenuItem">None</TextBlock> |
|||
</DockPanel> |
|||
</TabItem> |
|||
</TabControl> |
|||
</DockPanel> |
|||
</Window> |
|||
@ -0,0 +1,67 @@ |
|||
using System; |
|||
using System.Collections.Generic; |
|||
using System.Linq; |
|||
using Avalonia; |
|||
using Avalonia.Controls; |
|||
using Avalonia.Interactivity; |
|||
using Avalonia.Markup.Xaml; |
|||
|
|||
namespace IntegrationTestApp |
|||
{ |
|||
public class MainWindow : Window |
|||
{ |
|||
public MainWindow() |
|||
{ |
|||
InitializeComponent(); |
|||
InitializeViewMenu(); |
|||
this.AttachDevTools(); |
|||
AddHandler(Button.ClickEvent, OnButtonClick); |
|||
ListBoxItems = Enumerable.Range(0, 100).Select(x => "Item " + x).ToList(); |
|||
DataContext = this; |
|||
} |
|||
|
|||
public List<string> ListBoxItems { get; } |
|||
|
|||
private void InitializeComponent() |
|||
{ |
|||
AvaloniaXamlLoader.Load(this); |
|||
} |
|||
|
|||
private void InitializeViewMenu() |
|||
{ |
|||
var mainTabs = this.FindControl<TabControl>("MainTabs"); |
|||
var viewMenu = (NativeMenuItem)NativeMenu.GetMenu(this).Items[1]; |
|||
|
|||
foreach (TabItem tabItem in mainTabs.Items) |
|||
{ |
|||
var menuItem = new NativeMenuItem |
|||
{ |
|||
Header = (string)tabItem.Header!, |
|||
IsChecked = tabItem.IsSelected, |
|||
ToggleType = NativeMenuItemToggleType.Radio, |
|||
}; |
|||
|
|||
menuItem.Click += (s, e) => tabItem.IsSelected = true; |
|||
viewMenu.Menu.Items.Add(menuItem); |
|||
} |
|||
} |
|||
|
|||
private void MenuClicked(object? sender, RoutedEventArgs e) |
|||
{ |
|||
var clickedMenuItemTextBlock = this.FindControl<TextBlock>("ClickedMenuItem"); |
|||
clickedMenuItemTextBlock.Text = ((MenuItem)sender!).Header.ToString(); |
|||
} |
|||
|
|||
private void OnButtonClick(object? sender, RoutedEventArgs e) |
|||
{ |
|||
var source = e.Source as Button; |
|||
|
|||
if (source?.Name == "ComboBoxSelectionClear") |
|||
this.FindControl<ComboBox>("BasicComboBox").SelectedIndex = -1; |
|||
if (source?.Name == "ComboBoxSelectFirst") |
|||
this.FindControl<ComboBox>("BasicComboBox").SelectedIndex = 0; |
|||
if (source?.Name == "ListBoxSelectionClear") |
|||
this.FindControl<ListBox>("BasicListBox").SelectedIndex = -1; |
|||
} |
|||
} |
|||
} |
|||
@ -0,0 +1,22 @@ |
|||
using System; |
|||
using Avalonia; |
|||
using Avalonia.Controls; |
|||
using Avalonia.Controls.ApplicationLifetimes; |
|||
|
|||
namespace IntegrationTestApp |
|||
{ |
|||
class Program |
|||
{ |
|||
// Initialization code. Don't use any Avalonia, third-party APIs or any
|
|||
// SynchronizationContext-reliant code before AppMain is called: things aren't initialized
|
|||
// yet and stuff might break.
|
|||
public static void Main(string[] args) => BuildAvaloniaApp() |
|||
.StartWithClassicDesktopLifetime(args); |
|||
|
|||
// Avalonia configuration, don't remove; also used by visual designer.
|
|||
public static AppBuilder BuildAvaloniaApp() |
|||
=> AppBuilder.Configure<App>() |
|||
.UsePlatformDetect() |
|||
.LogToTrace(); |
|||
} |
|||
} |
|||
@ -0,0 +1,5 @@ |
|||
#!/usr/bin/env bash |
|||
|
|||
cd $(cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd) |
|||
dotnet restore -r osx-arm64 |
|||
dotnet msbuild -t:BundleApp -p:RuntimeIdentifier=osx-arm64 -p:_AvaloniaUseExternalMSBuild=false |
|||
@ -0,0 +1,11 @@ |
|||
<?xml version="1.0" encoding="utf-8"?> |
|||
|
|||
<!-- |
|||
To use the Avalonia CI feed to get unstable packages, move this file to the root of your solution. |
|||
--> |
|||
|
|||
<configuration> |
|||
<packageSources> |
|||
<add key="AvaloniaCI" value="https://www.myget.org/F/avalonia-ci/api/v2" /> |
|||
</packageSources> |
|||
</configuration> |
|||
@ -0,0 +1,71 @@ |
|||
<UserControl xmlns="https://github.com/avaloniaui" |
|||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" |
|||
xmlns:d="http://schemas.microsoft.com/expression/blend/2008" |
|||
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" |
|||
mc:Ignorable="d" d:DesignWidth="800" d:DesignHeight="450" |
|||
x:Class="RenderDemo.Pages.BrushesPage"> |
|||
<Canvas Background="White" Width="480" Height="360"> |
|||
<Rectangle Canvas.Left="20" Canvas.Top="20" Width="440" Height="50"> |
|||
<Rectangle.Fill> |
|||
<LinearGradientBrush StartPoint="0,0" EndPoint="410,0"> |
|||
<LinearGradientBrush.Transform> |
|||
<TransformGroup> |
|||
<ScaleTransform ScaleX="0.5" /> |
|||
<SkewTransform /> |
|||
<RotateTransform /> |
|||
<TranslateTransform X="5" Y="15" /> |
|||
</TransformGroup> |
|||
</LinearGradientBrush.Transform> |
|||
<LinearGradientBrush.GradientStops> |
|||
<GradientStop Color="Blue" Offset="0" /> |
|||
<GradientStop Color="Green" Offset="0.5" /> |
|||
<GradientStop Color="Lime" Offset="1" /> |
|||
</LinearGradientBrush.GradientStops> |
|||
</LinearGradientBrush> |
|||
</Rectangle.Fill> |
|||
</Rectangle> |
|||
<TextBlock Canvas.Left="20" Canvas.Top="70" FontSize="30" Text="scale(0.5) on gradient" /> |
|||
<Rectangle Canvas.Left="20" Canvas.Top="110" Width="440" Height="50"> |
|||
<Rectangle.Fill> |
|||
<RadialGradientBrush Center="0.0,0.0" GradientOrigin="0.0,0.0" Radius="0.13636364"> |
|||
<RadialGradientBrush.Transform> |
|||
<TransformGroup> |
|||
<ScaleTransform /> |
|||
<SkewTransform AngleX="45" /> |
|||
<RotateTransform /> |
|||
<TranslateTransform X="240" Y="45" /> |
|||
</TransformGroup> |
|||
</RadialGradientBrush.Transform> |
|||
<RadialGradientBrush.GradientStops> |
|||
<GradientStop Color="Black" Offset="0" /> |
|||
<GradientStop Color="#FFFFA500" Offset="1" /> |
|||
</RadialGradientBrush.GradientStops> |
|||
</RadialGradientBrush> |
|||
</Rectangle.Fill> |
|||
</Rectangle> |
|||
<TextBlock Canvas.Left="20" Canvas.Top="160" FontSize="30" Text="skewX(45) on gradient" /> |
|||
<Rectangle Canvas.Left="20" Canvas.Top="210" Width="440" Height="50"> |
|||
<Rectangle.Fill> |
|||
<VisualBrush TileMode="Tile" SourceRect="0,0,20,20" DestinationRect="0,0,20,20" Stretch="None"> |
|||
<VisualBrush.Transform> |
|||
<TransformGroup> |
|||
<ScaleTransform ScaleX="2" ScaleY="2" /> |
|||
<SkewTransform AngleX="45" /> |
|||
<RotateTransform /> |
|||
<TranslateTransform X="5" Y="5" /> |
|||
</TransformGroup> |
|||
</VisualBrush.Transform> |
|||
<VisualBrush.Visual> |
|||
<Canvas Width="20" Height="20"> |
|||
<Rectangle Canvas.Left="0" Canvas.Top="0" Width="10" Height="10" Fill="Maroon" /> |
|||
<Rectangle Canvas.Left="10" Canvas.Top="0" Width="10" Height="10" Fill="Green" /> |
|||
<Rectangle Canvas.Left="0" Canvas.Top="10" Width="10" Height="10" Fill="Blue" /> |
|||
<Rectangle Canvas.Left="10" Canvas.Top="10" Width="10" Height="10" Fill="Yellow" /> |
|||
</Canvas> |
|||
</VisualBrush.Visual> |
|||
</VisualBrush> |
|||
</Rectangle.Fill> |
|||
</Rectangle> |
|||
<TextBlock Canvas.Left="20" Canvas.Top="260" FontSize="30" Text="scale(2), skewX(45) on pattern" /> |
|||
</Canvas> |
|||
</UserControl> |
|||
@ -0,0 +1,18 @@ |
|||
using Avalonia.Controls; |
|||
using Avalonia.Markup.Xaml; |
|||
|
|||
namespace RenderDemo.Pages; |
|||
|
|||
public class BrushesPage : UserControl |
|||
{ |
|||
public BrushesPage() |
|||
{ |
|||
InitializeComponent(); |
|||
} |
|||
|
|||
private void InitializeComponent() |
|||
{ |
|||
AvaloniaXamlLoader.Load(this); |
|||
} |
|||
} |
|||
|
|||
@ -1,12 +1,19 @@ |
|||
<Project Sdk="Xamarin.Legacy.Sdk"> |
|||
<PropertyGroup> |
|||
<TargetFrameworks>net6.0-android;monoandroid11.0</TargetFrameworks> |
|||
<TargetFrameworks>net6.0-android</TargetFrameworks> |
|||
<TargetFrameworks Condition="'$(MSBuildRuntimeType)' != 'Core'">$(TargetFrameworks);monoandroid11.0</TargetFrameworks> |
|||
<SupportedOSPlatformVersion>21</SupportedOSPlatformVersion> |
|||
<AllowUnsafeBlocks>true</AllowUnsafeBlocks> |
|||
<MSBuildEnableWorkloadResolver>true</MSBuildEnableWorkloadResolver> |
|||
<DebugType>portable</DebugType> |
|||
</PropertyGroup> |
|||
<ItemGroup> |
|||
<ProjectReference Include="..\..\..\packages\Avalonia\Avalonia.csproj" /> |
|||
<PackageReference Include="Xamarin.AndroidX.AppCompat" Version="1.3.1.3" /> |
|||
<PackageReference Include="Xamarin.AndroidX.Lifecycle.ViewModel" Version="2.3.1.3" /> |
|||
</ItemGroup> |
|||
<ItemGroup> |
|||
<ProjectReference Include="..\..\Avalonia.Base\Avalonia.Base.csproj" /> |
|||
<ProjectReference Include="..\..\Skia\Avalonia.Skia\Avalonia.Skia.csproj" /> |
|||
</ItemGroup> |
|||
</Project> |
|||
|
|||
@ -1,35 +1,82 @@ |
|||
using Android.App; |
|||
using Android.OS; |
|||
using Android.Views; |
|||
using AndroidX.AppCompat.App; |
|||
using Android.Content.Res; |
|||
using AndroidX.Lifecycle; |
|||
using Avalonia.Controls.ApplicationLifetimes; |
|||
using Avalonia.Controls; |
|||
|
|||
namespace Avalonia.Android |
|||
{ |
|||
public abstract class AvaloniaActivity : Activity |
|||
public abstract class AvaloniaActivity<TApp> : AppCompatActivity where TApp : Application, new() |
|||
{ |
|||
internal class SingleViewLifetime : ISingleViewApplicationLifetime |
|||
{ |
|||
public AvaloniaView View { get; internal set; } |
|||
|
|||
public Control MainView |
|||
{ |
|||
get => (Control)View.Content; |
|||
set => View.Content = value; |
|||
} |
|||
} |
|||
|
|||
internal AvaloniaView View; |
|||
object _content; |
|||
internal AvaloniaViewModel _viewModel; |
|||
|
|||
protected virtual AppBuilder CustomizeAppBuilder(AppBuilder builder) => builder.UseAndroid(); |
|||
|
|||
protected override void OnCreate(Bundle savedInstanceState) |
|||
{ |
|||
var builder = AppBuilder.Configure<TApp>(); |
|||
|
|||
CustomizeAppBuilder(builder); |
|||
|
|||
View = new AvaloniaView(this); |
|||
if (_content != null) |
|||
View.Content = _content; |
|||
SetContentView(View); |
|||
|
|||
var lifetime = new SingleViewLifetime(); |
|||
lifetime.View = View; |
|||
|
|||
builder.AfterSetup(x => |
|||
{ |
|||
_viewModel = new ViewModelProvider(this).Get(Java.Lang.Class.FromType(typeof(AvaloniaViewModel))) as AvaloniaViewModel; |
|||
|
|||
if (_viewModel.Content != null) |
|||
{ |
|||
View.Content = _viewModel.Content; |
|||
} |
|||
|
|||
View.Prepare(); |
|||
}); |
|||
|
|||
builder.SetupWithLifetime(lifetime); |
|||
|
|||
base.OnCreate(savedInstanceState); |
|||
} |
|||
|
|||
public object Content |
|||
{ |
|||
get |
|||
{ |
|||
return _content; |
|||
return _viewModel.Content; |
|||
} |
|||
set |
|||
{ |
|||
_content = value; |
|||
_viewModel.Content = value; |
|||
if (View != null) |
|||
View.Content = value; |
|||
} |
|||
} |
|||
|
|||
public override void OnConfigurationChanged(Configuration newConfig) |
|||
{ |
|||
base.OnConfigurationChanged(newConfig); |
|||
} |
|||
|
|||
protected override void OnDestroy() |
|||
{ |
|||
View.Content = null; |
|||
|
|||
base.OnDestroy(); |
|||
} |
|||
} |
|||
} |
|||
|
|||
@ -0,0 +1,11 @@ |
|||
using System; |
|||
using System.Collections.Generic; |
|||
using System.Text; |
|||
|
|||
namespace Avalonia.Android |
|||
{ |
|||
internal class AvaloniaViewModel : AndroidX.Lifecycle.ViewModel |
|||
{ |
|||
public object Content { get; set; } |
|||
} |
|||
} |
|||
@ -1,50 +0,0 @@ |
|||
Images, layout descriptions, binary blobs and string dictionaries can be included |
|||
in your application as resource files. Various Android APIs are designed to |
|||
operate on the resource IDs instead of dealing with images, strings or binary blobs |
|||
directly. |
|||
|
|||
For example, a sample Android app that contains a user interface layout (main.xml), |
|||
an internationalization string table (strings.xml) and some icons (drawable-XXX/icon.png) |
|||
would keep its resources in the "Resources" directory of the application: |
|||
|
|||
Resources/ |
|||
drawable-hdpi/ |
|||
icon.png |
|||
|
|||
drawable-ldpi/ |
|||
icon.png |
|||
|
|||
drawable-mdpi/ |
|||
icon.png |
|||
|
|||
layout/ |
|||
main.xml |
|||
|
|||
values/ |
|||
strings.xml |
|||
|
|||
In order to get the build system to recognize Android resources, set the build action to |
|||
"AndroidResource". The native Android APIs do not operate directly with filenames, but |
|||
instead operate on resource IDs. When you compile an Android application that uses resources, |
|||
the build system will package the resources for distribution and generate a class called |
|||
"Resource" that contains the tokens for each one of the resources included. For example, |
|||
for the above Resources layout, this is what the Resource class would expose: |
|||
|
|||
public class Resource { |
|||
public class drawable { |
|||
public const int icon = 0x123; |
|||
} |
|||
|
|||
public class layout { |
|||
public const int main = 0x456; |
|||
} |
|||
|
|||
public class strings { |
|||
public const int first_string = 0xabc; |
|||
public const int second_string = 0xbcd; |
|||
} |
|||
} |
|||
|
|||
You would then use R.drawable.icon to reference the drawable/icon.png file, or Resource.layout.main |
|||
to reference the layout/main.xml file, or Resource.strings.first_string to reference the first |
|||
string in the dictionary file values/strings.xml. |
|||
@ -1,6 +0,0 @@ |
|||
<?xml version="1.0" encoding="utf-8"?> |
|||
|
|||
<resources> |
|||
<string name="Hello">Hello World, Click Me!</string> |
|||
<string name="ApplicationName">$projectname$</string> |
|||
</resources> |
|||
@ -0,0 +1,10 @@ |
|||
using System; |
|||
|
|||
namespace Avalonia.Metadata |
|||
{ |
|||
[AttributeUsage(AttributeTargets.Class, AllowMultiple = false, Inherited = true)] |
|||
public class TrimSurroundingWhitespaceAttribute : Attribute |
|||
{ |
|||
|
|||
} |
|||
} |
|||
@ -0,0 +1,12 @@ |
|||
using System; |
|||
|
|||
namespace Avalonia.Metadata |
|||
{ |
|||
/// <summary>
|
|||
/// Indicates that a collection type should be processed as being whitespace significant by a XAML processor.
|
|||
/// </summary>
|
|||
[AttributeUsage(AttributeTargets.Class, AllowMultiple = false, Inherited = true)] |
|||
public class WhitespaceSignificantCollectionAttribute : Attribute |
|||
{ |
|||
} |
|||
} |
|||
@ -0,0 +1,70 @@ |
|||
using System; |
|||
|
|||
namespace Avalonia.Utilities; |
|||
|
|||
internal static class UriExtensions |
|||
{ |
|||
public static bool IsAbsoluteResm(this Uri uri) => |
|||
uri.IsAbsoluteUri && uri.IsResm(); |
|||
|
|||
public static bool IsResm(this Uri uri) => uri.Scheme == "resm"; |
|||
|
|||
public static bool IsAvares(this Uri uri) => uri.Scheme == "avares"; |
|||
|
|||
public static Uri EnsureAbsolute(this Uri uri, Uri? baseUri) |
|||
{ |
|||
if (uri.IsAbsoluteUri) |
|||
return uri; |
|||
if(baseUri == null) |
|||
throw new ArgumentException($"Relative uri {uri} without base url"); |
|||
if (!baseUri.IsAbsoluteUri) |
|||
throw new ArgumentException($"Base uri {baseUri} is relative"); |
|||
if (baseUri.IsResm()) |
|||
throw new ArgumentException( |
|||
$"Relative uris for 'resm' scheme aren't supported; {baseUri} uses resm"); |
|||
return new Uri(baseUri, uri); |
|||
} |
|||
|
|||
public static string GetUnescapeAbsolutePath(this Uri uri) => |
|||
Uri.UnescapeDataString(uri.AbsolutePath); |
|||
|
|||
public static string GetUnescapeAbsoluteUri(this Uri uri) => |
|||
Uri.UnescapeDataString(uri.AbsoluteUri); |
|||
|
|||
public static string GetAssemblyNameFromQuery(this Uri uri) |
|||
{ |
|||
const string assembly = "assembly"; |
|||
|
|||
var query = Uri.UnescapeDataString(uri.Query); |
|||
|
|||
// Skip the '?'
|
|||
var currentIndex = 1; |
|||
while (currentIndex < query.Length) |
|||
{ |
|||
var isFind = false; |
|||
for (var i = 0; i < assembly.Length; ++currentIndex, ++i) |
|||
if (query[currentIndex] == assembly[i]) |
|||
{ |
|||
isFind = i == assembly.Length - 1; |
|||
} |
|||
else |
|||
{ |
|||
break; |
|||
} |
|||
|
|||
// Skip the '='
|
|||
++currentIndex; |
|||
|
|||
var beginIndex = currentIndex; |
|||
while (currentIndex < query.Length && query[currentIndex] != '&') |
|||
++currentIndex; |
|||
|
|||
if (isFind) |
|||
return query.Substring(beginIndex, currentIndex - beginIndex); |
|||
|
|||
++currentIndex; |
|||
} |
|||
|
|||
return ""; |
|||
} |
|||
} |
|||
@ -0,0 +1 @@ |
|||
Total Issues: 0 |
|||
@ -0,0 +1,28 @@ |
|||
using Avalonia.Automation.Peers; |
|||
|
|||
namespace Avalonia.Automation |
|||
{ |
|||
/// <summary>
|
|||
/// Contains values used as automation property identifiers by UI Automation providers.
|
|||
/// </summary>
|
|||
public static class AutomationElementIdentifiers |
|||
{ |
|||
/// <summary>
|
|||
/// Identifies the bounding rectangle automation property. The bounding rectangle property
|
|||
/// value is returned by the <see cref="AutomationPeer.GetBoundingRectangle"/> method.
|
|||
/// </summary>
|
|||
public static AutomationProperty BoundingRectangleProperty { get; } = new AutomationProperty(); |
|||
|
|||
/// <summary>
|
|||
/// Identifies the class name automation property. The class name property value is returned
|
|||
/// by the <see cref="AutomationPeer.GetClassName"/> method.
|
|||
/// </summary>
|
|||
public static AutomationProperty ClassNameProperty { get; } = new AutomationProperty(); |
|||
|
|||
/// <summary>
|
|||
/// Identifies the name automation property. The class name property value is returned
|
|||
/// by the <see cref="AutomationPeer.GetName"/> method.
|
|||
/// </summary>
|
|||
public static AutomationProperty NameProperty { get; } = new AutomationProperty(); |
|||
} |
|||
} |
|||
@ -0,0 +1,28 @@ |
|||
namespace Avalonia.Automation |
|||
{ |
|||
/// <summary>
|
|||
/// Describes the notification characteristics of a particular live region
|
|||
/// </summary>
|
|||
public enum AutomationLiveSetting |
|||
{ |
|||
/// <summary>
|
|||
/// The element does not send notifications if the content of the live region has changed.
|
|||
/// </summary>
|
|||
Off = 0, |
|||
|
|||
/// <summary>
|
|||
/// The element sends non-interruptive notifications if the content of the live region has
|
|||
/// changed. With this setting, UI Automation clients and assistive technologies are expected
|
|||
/// to not interrupt the user to inform of changes to the live region.
|
|||
/// </summary>
|
|||
Polite = 1, |
|||
|
|||
/// <summary>
|
|||
/// The element sends interruptive notifications if the content of the live region has changed.
|
|||
/// With this setting, UI Automation clients and assistive technologies are expected to interrupt
|
|||
/// the user to inform of changes to the live region.
|
|||
/// </summary>
|
|||
Assertive = 2, |
|||
} |
|||
} |
|||
|
|||
@ -0,0 +1,630 @@ |
|||
using System; |
|||
using Avalonia.Automation.Peers; |
|||
using Avalonia.Controls; |
|||
|
|||
namespace Avalonia.Automation |
|||
{ |
|||
/// <summary>
|
|||
/// Declares how a control should included in different views of the automation tree.
|
|||
/// </summary>
|
|||
public enum AccessibilityView |
|||
{ |
|||
/// <summary>
|
|||
/// The control is included in the Raw view of the automation tree.
|
|||
/// </summary>
|
|||
Raw, |
|||
|
|||
/// <summary>
|
|||
/// The control is included in the Control view of the automation tree.
|
|||
/// </summary>
|
|||
Control, |
|||
|
|||
/// <summary>
|
|||
/// The control is included in the Content view of the automation tree.
|
|||
/// </summary>
|
|||
Content, |
|||
} |
|||
|
|||
public static class AutomationProperties |
|||
{ |
|||
internal const int AutomationPositionInSetDefault = -1; |
|||
internal const int AutomationSizeOfSetDefault = -1; |
|||
|
|||
/// <summary>
|
|||
/// Defines the AutomationProperties.AcceleratorKey attached property.
|
|||
/// </summary>
|
|||
public static readonly AttachedProperty<string> AcceleratorKeyProperty = |
|||
AvaloniaProperty.RegisterAttached<StyledElement, string>( |
|||
"AcceleratorKey", |
|||
typeof(AutomationProperties)); |
|||
|
|||
/// <summary>
|
|||
/// Defines the AutomationProperties.AccessibilityView attached property.
|
|||
/// </summary>
|
|||
public static readonly AttachedProperty<AccessibilityView> AccessibilityViewProperty = |
|||
AvaloniaProperty.RegisterAttached<StyledElement, AccessibilityView>( |
|||
"AccessibilityView", |
|||
typeof(AutomationProperties), |
|||
defaultValue: AccessibilityView.Content); |
|||
|
|||
/// <summary>
|
|||
/// Defines the AutomationProperties.AccessKey attached property
|
|||
/// </summary>
|
|||
public static readonly AttachedProperty<string> AccessKeyProperty = |
|||
AvaloniaProperty.RegisterAttached<StyledElement, string>( |
|||
"AccessKey", |
|||
typeof(AutomationProperties)); |
|||
|
|||
/// <summary>
|
|||
/// Defines the AutomationProperties.AutomationId attached property.
|
|||
/// </summary>
|
|||
public static readonly AttachedProperty<string> AutomationIdProperty = |
|||
AvaloniaProperty.RegisterAttached<StyledElement, string>( |
|||
"AutomationId", |
|||
typeof(AutomationProperties)); |
|||
|
|||
/// <summary>
|
|||
/// Defines the AutomationProperties.ControlTypeOverride attached property.
|
|||
/// </summary>
|
|||
public static readonly AttachedProperty<AutomationControlType?> ControlTypeOverrideProperty = |
|||
AvaloniaProperty.RegisterAttached<StyledElement, AutomationControlType?>( |
|||
"ControlTypeOverride", |
|||
typeof(AutomationProperties)); |
|||
|
|||
/// <summary>
|
|||
/// Defines the AutomationProperties.HelpText attached property.
|
|||
/// </summary>
|
|||
public static readonly AttachedProperty<string> HelpTextProperty = |
|||
AvaloniaProperty.RegisterAttached<StyledElement, string>( |
|||
"HelpText", |
|||
typeof(AutomationProperties)); |
|||
|
|||
/// <summary>
|
|||
/// Defines the AutomationProperties.IsColumnHeader attached property.
|
|||
/// </summary>
|
|||
public static readonly AttachedProperty<bool> IsColumnHeaderProperty = |
|||
AvaloniaProperty.RegisterAttached<StyledElement, bool>( |
|||
"IsColumnHeader", |
|||
typeof(AutomationProperties), |
|||
false); |
|||
|
|||
/// <summary>
|
|||
/// Defines the AutomationProperties.IsRequiredForForm attached property.
|
|||
/// </summary>
|
|||
public static readonly AttachedProperty<bool> IsRequiredForFormProperty = |
|||
AvaloniaProperty.RegisterAttached<StyledElement, bool>( |
|||
"IsRequiredForForm", |
|||
typeof(AutomationProperties), |
|||
false); |
|||
|
|||
/// <summary>
|
|||
/// Defines the AutomationProperties.IsRowHeader attached property.
|
|||
/// </summary>
|
|||
public static readonly AttachedProperty<bool> IsRowHeaderProperty = |
|||
AvaloniaProperty.RegisterAttached<StyledElement, bool>( |
|||
"IsRowHeader", |
|||
typeof(AutomationProperties), |
|||
false); |
|||
|
|||
/// <summary>
|
|||
/// Defines the AutomationProperties.IsOffscreenBehavior attached property.
|
|||
/// </summary>
|
|||
public static readonly AttachedProperty<IsOffscreenBehavior> IsOffscreenBehaviorProperty = |
|||
AvaloniaProperty.RegisterAttached<StyledElement, IsOffscreenBehavior>( |
|||
"IsOffscreenBehavior", |
|||
typeof(AutomationProperties), |
|||
IsOffscreenBehavior.Default); |
|||
|
|||
/// <summary>
|
|||
/// Defines the AutomationProperties.ItemStatus attached property.
|
|||
/// </summary>
|
|||
public static readonly AttachedProperty<string> ItemStatusProperty = |
|||
AvaloniaProperty.RegisterAttached<StyledElement, string>( |
|||
"ItemStatus", |
|||
typeof(AutomationProperties)); |
|||
|
|||
/// <summary>
|
|||
/// Defines the AutomationProperties.ItemType attached property.
|
|||
/// </summary>
|
|||
public static readonly AttachedProperty<string> ItemTypeProperty = |
|||
AvaloniaProperty.RegisterAttached<StyledElement, string>( |
|||
"ItemType", |
|||
typeof(AutomationProperties)); |
|||
|
|||
/// <summary>
|
|||
/// Defines the AutomationProperties.LabeledBy attached property.
|
|||
/// </summary>
|
|||
public static readonly AttachedProperty<IControl> LabeledByProperty = |
|||
AvaloniaProperty.RegisterAttached<StyledElement, IControl>( |
|||
"LabeledBy", |
|||
typeof(AutomationProperties)); |
|||
|
|||
/// <summary>
|
|||
/// Defines the AutomationProperties.LiveSetting attached property.
|
|||
/// </summary>
|
|||
public static readonly AttachedProperty<AutomationLiveSetting> LiveSettingProperty = |
|||
AvaloniaProperty.RegisterAttached<StyledElement, AutomationLiveSetting>( |
|||
"LiveSetting", |
|||
typeof(AutomationProperties), |
|||
AutomationLiveSetting.Off); |
|||
|
|||
/// <summary>
|
|||
/// Defines the AutomationProperties.Name attached attached property.
|
|||
/// </summary>
|
|||
public static readonly AttachedProperty<string> NameProperty = |
|||
AvaloniaProperty.RegisterAttached<StyledElement, string>( |
|||
"Name", |
|||
typeof(AutomationProperties)); |
|||
|
|||
/// <summary>
|
|||
/// Defines the AutomationProperties.PositionInSet attached property.
|
|||
/// </summary>
|
|||
/// <remarks>
|
|||
/// The PositionInSet property describes the ordinal location of the element within a set
|
|||
/// of elements which are considered to be siblings. PositionInSet works in coordination
|
|||
/// with the SizeOfSet property to describe the ordinal location in the set.
|
|||
/// </remarks>
|
|||
public static readonly AttachedProperty<int> PositionInSetProperty = |
|||
AvaloniaProperty.RegisterAttached<StyledElement, int>( |
|||
"PositionInSet", |
|||
typeof(AutomationProperties), |
|||
AutomationPositionInSetDefault); |
|||
|
|||
/// <summary>
|
|||
/// Defines the AutomationProperties.SizeOfSet attached property.
|
|||
/// </summary>
|
|||
/// <remarks>
|
|||
/// The SizeOfSet property describes the count of automation elements in a group or set
|
|||
/// that are considered to be siblings. SizeOfSet works in coordination with the PositionInSet
|
|||
/// property to describe the count of items in the set.
|
|||
/// </remarks>
|
|||
public static readonly AttachedProperty<int> SizeOfSetProperty = |
|||
AvaloniaProperty.RegisterAttached<StyledElement, int>( |
|||
"SizeOfSet", |
|||
typeof(AutomationProperties), |
|||
AutomationSizeOfSetDefault); |
|||
|
|||
/// <summary>
|
|||
/// Helper for setting AcceleratorKey property on a StyledElement.
|
|||
/// </summary>
|
|||
public static void SetAcceleratorKey(StyledElement element, string value) |
|||
{ |
|||
if (element == null) |
|||
{ |
|||
throw new ArgumentNullException(nameof(element)); |
|||
} |
|||
|
|||
element.SetValue(AcceleratorKeyProperty, value); |
|||
} |
|||
|
|||
/// <summary>
|
|||
/// Helper for reading AcceleratorKey property from a StyledElement.
|
|||
/// </summary>
|
|||
public static string GetAcceleratorKey(StyledElement element) |
|||
{ |
|||
if (element == null) |
|||
{ |
|||
throw new ArgumentNullException(nameof(element)); |
|||
} |
|||
|
|||
return ((string)element.GetValue(AcceleratorKeyProperty)); |
|||
} |
|||
|
|||
/// <summary>
|
|||
/// Helper for setting AccessibilityView property on a StyledElement.
|
|||
/// </summary>
|
|||
public static void SetAccessibilityView(StyledElement element, AccessibilityView value) |
|||
{ |
|||
if (element == null) |
|||
{ |
|||
throw new ArgumentNullException(nameof(element)); |
|||
} |
|||
|
|||
element.SetValue(AccessibilityViewProperty, value); |
|||
} |
|||
|
|||
/// <summary>
|
|||
/// Helper for reading AccessibilityView property from a StyledElement.
|
|||
/// </summary>
|
|||
public static AccessibilityView GetAccessibilityView(StyledElement element) |
|||
{ |
|||
if (element == null) |
|||
{ |
|||
throw new ArgumentNullException(nameof(element)); |
|||
} |
|||
|
|||
return element.GetValue(AccessibilityViewProperty); |
|||
} |
|||
|
|||
/// <summary>
|
|||
/// Helper for setting AccessKey property on a StyledElement.
|
|||
/// </summary>
|
|||
public static void SetAccessKey(StyledElement element, string value) |
|||
{ |
|||
if (element == null) |
|||
{ |
|||
throw new ArgumentNullException(nameof(element)); |
|||
} |
|||
|
|||
element.SetValue(AccessKeyProperty, value); |
|||
} |
|||
|
|||
/// <summary>
|
|||
/// Helper for reading AccessKey property from a StyledElement.
|
|||
/// </summary>
|
|||
public static string GetAccessKey(StyledElement element) |
|||
{ |
|||
if (element == null) |
|||
{ |
|||
throw new ArgumentNullException(nameof(element)); |
|||
} |
|||
|
|||
return ((string)element.GetValue(AccessKeyProperty)); |
|||
} |
|||
|
|||
/// <summary>
|
|||
/// Helper for setting AutomationId property on a StyledElement.
|
|||
/// </summary>
|
|||
public static void SetAutomationId(StyledElement element, string value) |
|||
{ |
|||
if (element == null) |
|||
{ |
|||
throw new ArgumentNullException(nameof(element)); |
|||
} |
|||
|
|||
element.SetValue(AutomationIdProperty, value); |
|||
} |
|||
|
|||
/// <summary>
|
|||
/// Helper for reading AutomationId property from a StyledElement.
|
|||
/// </summary>
|
|||
public static string GetAutomationId(StyledElement element) |
|||
{ |
|||
if (element == null) |
|||
{ |
|||
throw new ArgumentNullException(nameof(element)); |
|||
} |
|||
|
|||
return element.GetValue(AutomationIdProperty); |
|||
} |
|||
|
|||
/// <summary>
|
|||
/// Helper for setting ControlTypeOverride property on a StyledElement.
|
|||
/// </summary>
|
|||
public static void SetControlTypeOverride(StyledElement element, AutomationControlType? value) |
|||
{ |
|||
if (element == null) |
|||
{ |
|||
throw new ArgumentNullException(nameof(element)); |
|||
} |
|||
|
|||
element.SetValue(ControlTypeOverrideProperty, value); |
|||
} |
|||
|
|||
/// <summary>
|
|||
/// Helper for reading ControlTypeOverride property from a StyledElement.
|
|||
/// </summary>
|
|||
public static AutomationControlType? GetControlTypeOverride(StyledElement element) |
|||
{ |
|||
if (element == null) |
|||
{ |
|||
throw new ArgumentNullException(nameof(element)); |
|||
} |
|||
|
|||
return element.GetValue(ControlTypeOverrideProperty); |
|||
} |
|||
|
|||
/// <summary>
|
|||
/// Helper for setting HelpText property on a StyledElement.
|
|||
/// </summary>
|
|||
public static void SetHelpText(StyledElement element, string value) |
|||
{ |
|||
if (element == null) |
|||
{ |
|||
throw new ArgumentNullException(nameof(element)); |
|||
} |
|||
|
|||
element.SetValue(HelpTextProperty, value); |
|||
} |
|||
|
|||
/// <summary>
|
|||
/// Helper for reading HelpText property from a StyledElement.
|
|||
/// </summary>
|
|||
public static string GetHelpText(StyledElement element) |
|||
{ |
|||
if (element == null) |
|||
{ |
|||
throw new ArgumentNullException(nameof(element)); |
|||
} |
|||
|
|||
return ((string)element.GetValue(HelpTextProperty)); |
|||
} |
|||
|
|||
/// <summary>
|
|||
/// Helper for setting IsColumnHeader property on a StyledElement.
|
|||
/// </summary>
|
|||
public static void SetIsColumnHeader(StyledElement element, bool value) |
|||
{ |
|||
if (element == null) |
|||
{ |
|||
throw new ArgumentNullException(nameof(element)); |
|||
} |
|||
|
|||
element.SetValue(IsColumnHeaderProperty, value); |
|||
} |
|||
|
|||
/// <summary>
|
|||
/// Helper for reading IsColumnHeader property from a StyledElement.
|
|||
/// </summary>
|
|||
public static bool GetIsColumnHeader(StyledElement element) |
|||
{ |
|||
if (element == null) |
|||
{ |
|||
throw new ArgumentNullException(nameof(element)); |
|||
} |
|||
|
|||
return ((bool)element.GetValue(IsColumnHeaderProperty)); |
|||
} |
|||
|
|||
/// <summary>
|
|||
/// Helper for setting IsRequiredForForm property on a StyledElement.
|
|||
/// </summary>
|
|||
public static void SetIsRequiredForForm(StyledElement element, bool value) |
|||
{ |
|||
if (element == null) |
|||
{ |
|||
throw new ArgumentNullException(nameof(element)); |
|||
} |
|||
|
|||
element.SetValue(IsRequiredForFormProperty, value); |
|||
} |
|||
|
|||
/// <summary>
|
|||
/// Helper for reading IsRequiredForForm property from a StyledElement.
|
|||
/// </summary>
|
|||
public static bool GetIsRequiredForForm(StyledElement element) |
|||
{ |
|||
if (element == null) |
|||
{ |
|||
throw new ArgumentNullException(nameof(element)); |
|||
} |
|||
|
|||
return ((bool)element.GetValue(IsRequiredForFormProperty)); |
|||
} |
|||
|
|||
/// <summary>
|
|||
/// Helper for reading IsRowHeader property from a StyledElement.
|
|||
/// </summary>
|
|||
public static bool GetIsRowHeader(StyledElement element) |
|||
{ |
|||
if (element == null) |
|||
{ |
|||
throw new ArgumentNullException(nameof(element)); |
|||
} |
|||
|
|||
return ((bool)element.GetValue(IsRowHeaderProperty)); |
|||
} |
|||
|
|||
/// <summary>
|
|||
/// Helper for setting IsRowHeader property on a StyledElement.
|
|||
/// </summary>
|
|||
public static void SetIsRowHeader(StyledElement element, bool value) |
|||
{ |
|||
if (element == null) |
|||
{ |
|||
throw new ArgumentNullException(nameof(element)); |
|||
} |
|||
|
|||
element.SetValue(IsRowHeaderProperty, value); |
|||
} |
|||
|
|||
/// <summary>
|
|||
/// Helper for setting IsOffscreenBehavior property on a StyledElement.
|
|||
/// </summary>
|
|||
public static void SetIsOffscreenBehavior(StyledElement element, IsOffscreenBehavior value) |
|||
{ |
|||
if (element == null) |
|||
{ |
|||
throw new ArgumentNullException(nameof(element)); |
|||
} |
|||
|
|||
element.SetValue(IsOffscreenBehaviorProperty, value); |
|||
} |
|||
|
|||
/// <summary>
|
|||
/// Helper for reading IsOffscreenBehavior property from a StyledElement.
|
|||
/// </summary>
|
|||
public static IsOffscreenBehavior GetIsOffscreenBehavior(StyledElement element) |
|||
{ |
|||
if (element == null) |
|||
{ |
|||
throw new ArgumentNullException(nameof(element)); |
|||
} |
|||
|
|||
return ((IsOffscreenBehavior)element.GetValue(IsOffscreenBehaviorProperty)); |
|||
} |
|||
|
|||
/// <summary>
|
|||
/// Helper for setting ItemStatus property on a StyledElement.
|
|||
/// </summary>
|
|||
public static void SetItemStatus(StyledElement element, string value) |
|||
{ |
|||
if (element == null) |
|||
{ |
|||
throw new ArgumentNullException(nameof(element)); |
|||
} |
|||
|
|||
element.SetValue(ItemStatusProperty, value); |
|||
} |
|||
|
|||
/// <summary>
|
|||
/// Helper for reading ItemStatus property from a StyledElement.
|
|||
/// </summary>
|
|||
public static string GetItemStatus(StyledElement element) |
|||
{ |
|||
if (element == null) |
|||
{ |
|||
throw new ArgumentNullException(nameof(element)); |
|||
} |
|||
|
|||
return ((string)element.GetValue(ItemStatusProperty)); |
|||
} |
|||
|
|||
/// <summary>
|
|||
/// Helper for setting ItemType property on a StyledElement.
|
|||
/// </summary>
|
|||
public static void SetItemType(StyledElement element, string value) |
|||
{ |
|||
if (element == null) |
|||
{ |
|||
throw new ArgumentNullException(nameof(element)); |
|||
} |
|||
|
|||
element.SetValue(ItemTypeProperty, value); |
|||
} |
|||
|
|||
/// <summary>
|
|||
/// Helper for reading ItemType property from a StyledElement.
|
|||
/// </summary>
|
|||
public static string GetItemType(StyledElement element) |
|||
{ |
|||
if (element == null) |
|||
{ |
|||
throw new ArgumentNullException(nameof(element)); |
|||
} |
|||
|
|||
return ((string)element.GetValue(ItemTypeProperty)); |
|||
} |
|||
|
|||
/// <summary>
|
|||
/// Helper for setting LabeledBy property on a StyledElement.
|
|||
/// </summary>
|
|||
public static void SetLabeledBy(StyledElement element, IControl value) |
|||
{ |
|||
if (element == null) |
|||
{ |
|||
throw new ArgumentNullException(nameof(element)); |
|||
} |
|||
|
|||
element.SetValue(LabeledByProperty, value); |
|||
} |
|||
|
|||
/// <summary>
|
|||
/// Helper for reading LabeledBy property from a StyledElement.
|
|||
/// </summary>
|
|||
public static IControl GetLabeledBy(StyledElement element) |
|||
{ |
|||
if (element == null) |
|||
{ |
|||
throw new ArgumentNullException(nameof(element)); |
|||
} |
|||
|
|||
return element.GetValue(LabeledByProperty); |
|||
} |
|||
|
|||
/// <summary>
|
|||
/// Helper for setting LiveSetting property on a StyledElement.
|
|||
/// </summary>
|
|||
public static void SetLiveSetting(StyledElement element, AutomationLiveSetting value) |
|||
{ |
|||
if (element == null) |
|||
{ |
|||
throw new ArgumentNullException(nameof(element)); |
|||
} |
|||
|
|||
element.SetValue(LiveSettingProperty, value); |
|||
} |
|||
|
|||
/// <summary>
|
|||
/// Helper for reading LiveSetting property from a StyledElement.
|
|||
/// </summary>
|
|||
public static AutomationLiveSetting GetLiveSetting(StyledElement element) |
|||
{ |
|||
if (element == null) |
|||
{ |
|||
throw new ArgumentNullException(nameof(element)); |
|||
} |
|||
|
|||
return ((AutomationLiveSetting)element.GetValue(LiveSettingProperty)); |
|||
} |
|||
|
|||
/// <summary>
|
|||
/// Helper for setting Name property on a StyledElement.
|
|||
/// </summary>
|
|||
public static void SetName(StyledElement element, string value) |
|||
{ |
|||
if (element == null) |
|||
{ |
|||
throw new ArgumentNullException(nameof(element)); |
|||
} |
|||
|
|||
element.SetValue(NameProperty, value); |
|||
} |
|||
|
|||
/// <summary>
|
|||
/// Helper for reading Name property from a StyledElement.
|
|||
/// </summary>
|
|||
public static string GetName(StyledElement element) |
|||
{ |
|||
if (element == null) |
|||
{ |
|||
throw new ArgumentNullException(nameof(element)); |
|||
} |
|||
|
|||
return ((string)element.GetValue(NameProperty)); |
|||
} |
|||
|
|||
/// <summary>
|
|||
/// Helper for setting PositionInSet property on a StyledElement.
|
|||
/// </summary>
|
|||
public static void SetPositionInSet(StyledElement element, int value) |
|||
{ |
|||
if (element == null) |
|||
{ |
|||
throw new ArgumentNullException(nameof(element)); |
|||
} |
|||
|
|||
element.SetValue(PositionInSetProperty, value); |
|||
} |
|||
|
|||
/// <summary>
|
|||
/// Helper for reading PositionInSet property from a StyledElement.
|
|||
/// </summary>
|
|||
public static int GetPositionInSet(StyledElement element) |
|||
{ |
|||
if (element == null) |
|||
{ |
|||
throw new ArgumentNullException(nameof(element)); |
|||
} |
|||
|
|||
return ((int)element.GetValue(PositionInSetProperty)); |
|||
} |
|||
|
|||
/// <summary>
|
|||
/// Helper for setting SizeOfSet property on a StyledElement.
|
|||
/// </summary>
|
|||
public static void SetSizeOfSet(StyledElement element, int value) |
|||
{ |
|||
if (element == null) |
|||
{ |
|||
throw new ArgumentNullException(nameof(element)); |
|||
} |
|||
|
|||
element.SetValue(SizeOfSetProperty, value); |
|||
} |
|||
|
|||
/// <summary>
|
|||
/// Helper for reading SizeOfSet property from a StyledElement.
|
|||
/// </summary>
|
|||
public static int GetSizeOfSet(StyledElement element) |
|||
{ |
|||
if (element == null) |
|||
{ |
|||
throw new ArgumentNullException(nameof(element)); |
|||
} |
|||
|
|||
return ((int)element.GetValue(SizeOfSetProperty)); |
|||
} |
|||
} |
|||
} |
|||
|
|||
@ -0,0 +1,11 @@ |
|||
namespace Avalonia.Automation |
|||
{ |
|||
/// <summary>
|
|||
/// Identifies a property of <see cref="AutomationElementIdentifiers"/> or of a specific
|
|||
/// control pattern.
|
|||
/// </summary>
|
|||
public sealed class AutomationProperty |
|||
{ |
|||
internal AutomationProperty() { } |
|||
} |
|||
} |
|||
@ -0,0 +1,21 @@ |
|||
using System; |
|||
|
|||
namespace Avalonia.Automation |
|||
{ |
|||
public class AutomationPropertyChangedEventArgs : EventArgs |
|||
{ |
|||
public AutomationPropertyChangedEventArgs( |
|||
AutomationProperty property, |
|||
object? oldValue, |
|||
object? newValue) |
|||
{ |
|||
Property = property; |
|||
OldValue = oldValue; |
|||
NewValue = newValue; |
|||
} |
|||
|
|||
public AutomationProperty Property { get; } |
|||
public object? OldValue { get; } |
|||
public object? NewValue { get; } |
|||
} |
|||
} |
|||
@ -0,0 +1,10 @@ |
|||
using System; |
|||
|
|||
namespace Avalonia.Automation |
|||
{ |
|||
public class ElementNotEnabledException : Exception |
|||
{ |
|||
public ElementNotEnabledException() : base("Element not enabled.") { } |
|||
public ElementNotEnabledException(string message) : base(message) { } |
|||
} |
|||
} |
|||
@ -0,0 +1,15 @@ |
|||
using Avalonia.Automation.Provider; |
|||
|
|||
namespace Avalonia.Automation |
|||
{ |
|||
/// <summary>
|
|||
/// Contains values used as identifiers by <see cref="IExpandCollapseProvider"/>.
|
|||
/// </summary>
|
|||
public static class ExpandCollapsePatternIdentifiers |
|||
{ |
|||
/// <summary>
|
|||
/// Identifies <see cref="IExpandCollapseProvider.ExpandCollapseState"/> automation property.
|
|||
/// </summary>
|
|||
public static AutomationProperty ExpandCollapseStateProperty { get; } = new AutomationProperty(); |
|||
} |
|||
} |
|||
@ -0,0 +1,29 @@ |
|||
namespace Avalonia.Automation |
|||
{ |
|||
/// <summary>
|
|||
/// Contains values that specify the <see cref="ExpandCollapseState"/> of a UI Automation element.
|
|||
/// </summary>
|
|||
public enum ExpandCollapseState |
|||
{ |
|||
/// <summary>
|
|||
/// No child nodes, controls, or content of the UI Automation element are displayed.
|
|||
/// </summary>
|
|||
Collapsed, |
|||
|
|||
/// <summary>
|
|||
/// All child nodes, controls or content of the UI Automation element are displayed.
|
|||
/// </summary>
|
|||
Expanded, |
|||
|
|||
/// <summary>
|
|||
/// The UI Automation element has no child nodes, controls, or content to display.
|
|||
/// </summary>
|
|||
LeafNode, |
|||
|
|||
/// <summary>
|
|||
/// Some, but not all, child nodes, controls, or content of the UI Automation element are
|
|||
/// displayed.
|
|||
/// </summary>
|
|||
PartiallyExpanded |
|||
} |
|||
} |
|||
Some files were not shown because too many files changed in this diff
Loading…
Reference in new issue