Skip to content

Commit

Permalink
Code example for As & fix avaloneditor wheeling scroll
Browse files Browse the repository at this point in the history
  • Loading branch information
NotYoojun committed Oct 30, 2024
1 parent f636e80 commit 933f034
Show file tree
Hide file tree
Showing 11 changed files with 320 additions and 241 deletions.
25 changes: 0 additions & 25 deletions source/iNKORE.UI.WPF.Modern.Gallery/ControlPages/AcrylicPage.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -62,11 +62,6 @@
TintOpacity="0.8" />
</Grid>
</local:ControlExample.Example>
<local:ControlExample.Xaml>
<sys:String>
&lt;Rectangle Fill=&quot;{ThemeResource AcrylicInAppFillColorDefaultBrush}&quot; /&gt;
</sys:String>
</local:ControlExample.Xaml>
</local:ControlExample>
<local:ControlExample x:Name="Example3" HeaderText="Custom acrylic in-app brush.">
<local:ControlExample.Example>
Expand Down Expand Up @@ -130,16 +125,6 @@
</ComboBox>
</StackPanel>
</local:ControlExample.Options>
<local:ControlExample.Xaml>
<sys:String xml:space="preserve">
&lt;Rectangle Fill=&quot;{ThemeResource CustomAcrylicInAppBrush}&quot; /&gt;

&lt;ResourceDictionary x:Key=&quot;Default&quot;&gt;
&lt;media:AcrylicBrush x:Key=&quot;CustomAcrylicBrush&quot;
TintOpacity=&quot;$(OpacitySlider)&quot; TintColor=&quot;$(TintColor)&quot; FallbackColor=&quot;$(FallbackColor)&quot; /&gt;
&lt;/ResourceDictionary&gt;
</sys:String>
</local:ControlExample.Xaml>
</local:ControlExample>
<local:ControlExample x:Name="Example4" HeaderText="Luminosity with in-app Acrylic.">
<local:ControlExample.Example>
Expand Down Expand Up @@ -201,16 +186,6 @@
Value="{Binding Amount, ElementName=CustomAcrylicShapeLumin, Mode=TwoWay}" />
</StackPanel>
</local:ControlExample.Options>
<local:ControlExample.Xaml>
<sys:String xml:space="preserve">
&lt;Rectangle Fill=&quot;{ThemeResource CustomAcrylicInAppLuminosity}&quot; /&gt;

&lt;ResourceDictionary x:Key=&quot;Default&quot;&gt;
&lt;media:AcrylicBrush x:Key=&quot;CustomAcrylicInAppLuminosity&quot;
TintOpacity=&quot;$(OpacitySlider)&quot; TintLuminosityOpacity=&quot;$(TintLuminositySlider)&quot; TintColor=&quot;SkyBlue&quot; FallbackColor=&quot;SkyBlue&quot; /&gt;
&lt;/ResourceDictionary&gt;
</sys:String>
</local:ControlExample.Xaml>
</local:ControlExample>
</StackPanel>
</ui:Page>
Original file line number Diff line number Diff line change
Expand Up @@ -58,15 +58,6 @@
VerticalAlignment="Center" />
</StackPanel>
</local:ControlExample.Example>
<local:ControlExample.Xaml>
<sys:String xml:space="preserve">
&lt;ui:AppBarButton Label=&quot;FontIcon&quot; Click=&quot;AppBarButton_Click&quot;&gt;
&lt;ui:AppBarButton.Icon&gt;
&lt;ui:FontIcon FontFamily=&quot;Candara&quot; Glyph=&quot;&#x03A3;&quot;/&gt;
&lt;/ui:AppBarButton.Icon&gt;
&lt;/ui:AppBarButton&gt;
</sys:String>
</local:ControlExample.Xaml>
</local:ControlExample>
<local:ControlExample x:Name="Example4" HeaderText="An AppBarButton with a path icon.">
<local:ControlExample.Example>
Expand All @@ -86,15 +77,6 @@
VerticalAlignment="Center" />
</StackPanel>
</local:ControlExample.Example>
<local:ControlExample.Xaml>
<sys:String xml:space="preserve">
&lt;ui:AppBarButton Label=&quot;PathIcon&quot; Click=&quot;AppBarButton_Click&quot;&gt;
&lt;ui:AppBarButton.Icon&gt;
&lt;ui:PathIcon Data=&quot;F1 M 20,20L 24,10L 24,24L 5,24&quot;/&gt;
&lt;/ui:AppBarButton.Icon&gt;
&lt;/ui:AppBarButton&gt;
</sys:String>
</local:ControlExample.Xaml>
</local:ControlExample>

<local:ControlExample x:Name="Example5" HeaderText="An AppBarButton with an InputGesture">
Expand All @@ -119,15 +101,6 @@
VerticalAlignment="Center" />
</StackPanel>
</local:ControlExample.Example>
<local:ControlExample.Xaml>
<sys:String xml:space="preserve">
&lt;ui:AppBarButton Icon=&quot;Save&quot; Label=&quot;Save&quot; Command=&quot;Save&quot; Click=&quot;AppBarButton_Click&quot;&gt;
&lt;ui:AppBarButton.CommandBindings&gt;
&lt;CommandBinding Command=&quot;Save&quot; CanExecute=&quot;Save_CanExecute&quot;/&gt;
&lt;ui:AppBarButton.CommandBindings/&gt;
&lt;/ui:AppBarButton&gt;
</sys:String>
</local:ControlExample.Xaml>
</local:ControlExample>
</StackPanel>
</ui:Page>
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,8 @@ void AppBarButtonPage_Loaded(object sender, RoutedEventArgs e)
};
compactButton.Click += CompactButton_Click;
appBar.PrimaryCommands.Insert(0, compactButton);

UpdateExampleCode();
}

private void CompactButton_Click(object sender, RoutedEventArgs e)
Expand All @@ -54,6 +56,8 @@ private void CompactButton_Click(object sender, RoutedEventArgs e)
//Button2.IsCompact =
Button3.IsCompact =
Button4.IsCompact = (bool)toggle.IsChecked;

UpdateExampleCode();
}
}

Expand Down Expand Up @@ -85,18 +89,47 @@ private void Save_CanExecute(object sender, CanExecuteRoutedEventArgs e)

#region Example Code

public string Example3Xaml => @"
<ui:AppBarButton
x:Name=""Button3""
Click=""AppBarButton_Click""
Label=""FontIcon"">
public void UpdateExampleCode()
{
Example3.Xaml = Example3Xaml;
Example4.Xaml = Example4Xaml;
Example5.Xaml = Example5Xaml;
}

private string isCompactProp => compactButton.IsChecked == true
? @"IsCompact=""True""" : "";

public string Example3Xaml => $@"
<ui:AppBarButton x:Name=""Button3"" {isCompactProp}
Label=""FontIcon"" Click=""AppBarButton_Click"">
<ui:AppBarButton.Icon>
<ui:FontIcon Icon=""{x:Static ui:SegoeFluentIcons.Home}""/>
<ui:FontIcon Icon=""{{x:Static ui:SegoeFluentIcons.Home}}""/>
</ui:AppBarButton.Icon>
</ui:AppBarButton>
";
public string Example4Xaml => $@"
<ui:AppBarButton x:Name=""Button4"" {isCompactProp}
Label=""PathIcon"" Click=""AppBarButton_Click"" >
<ui:AppBarButton.Icon>
<ui:PathIcon Data=""F1 M 20,20L 24,10L 24,24L 5,24"" />
</ui:AppBarButton.Icon>
</ui:AppBarButton>
";


public string Example5Xaml => $@"
<ui:AppBarButton x:Name=""Button5"" {isCompactProp}
Click=""AppBarButton_Click""
Command=""Save"" Label=""Save"">
<ui:AppBarButton.CommandBindings>
<CommandBinding CanExecute=""Save_CanExecute"" Command=""Save"" />
</ui:AppBarButton.CommandBindings>
<ui:AppBarButton.Icon>
<ui:FontIcon Icon=""{{x:Static ui:SegoeFluentIcons.Save}}""/>
</ui:AppBarButton.Icon>
</ui:AppBarButton>
";

#endregion
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,56 +11,42 @@
d:DesignWidth="800"
mc:Ignorable="d">
<StackPanel>
<local:ControlExample HeaderText="AppBarButtons separated by AppBarSeparators.">
<local:ControlExample x:Name="Example1" HeaderText="AppBarButtons separated by AppBarSeparators.">
<local:ControlExample.Example>
<ui:ScrollViewerEx HorizontalScrollBarVisibility="Hidden" VerticalScrollBarVisibility="Hidden">
<ui:CommandBar x:Name="Control1">
<ui:CommandBar.PrimaryCommands>
<ui:AppBarButton Label="Attach Camera" >
<ui:AppBarButton.Icon>
<ui:SymbolIcon Symbol="AttachCamera"/>
<ui:FontIcon Icon="{x:Static ui:SegoeFluentIcons.AttachCamera}"/>
</ui:AppBarButton.Icon>
</ui:AppBarButton>

<ui:AppBarSeparator />

<ui:AppBarButton Label="Like" >
<ui:AppBarButton.Icon>
<ui:SymbolIcon Symbol="Like"/>
<ui:FontIcon Icon="{x:Static ui:SegoeFluentIcons.Like}"/>
</ui:AppBarButton.Icon>
</ui:AppBarButton>

<ui:AppBarButton Label="Dislike" >
<ui:AppBarButton.Icon>
<ui:SymbolIcon Symbol="Dislike"/>
<ui:FontIcon Icon="{x:Static ui:SegoeFluentIcons.Dislike}"/>
</ui:AppBarButton.Icon>
</ui:AppBarButton>

<ui:AppBarSeparator />

<ui:AppBarButton Label="Orientation" >
<ui:AppBarButton.Icon>
<ui:SymbolIcon Symbol="Orientation"/>
<ui:FontIcon Icon="{x:Static ui:SegoeFluentIcons.Orientation}"/>
</ui:AppBarButton.Icon>
</ui:AppBarButton>
</ui:CommandBar.PrimaryCommands>
</ui:CommandBar>
</ui:ScrollViewerEx>
</local:ControlExample.Example>
<local:ControlExample.Xaml>
<sys:String xml:space="preserve">
&lt;ui:CommandBar&gt;
&lt;ui:CommandBar.PrimaryCommands&gt;
&lt;ui:AppBarButton Icon=&quot;AttachCamera&quot; Label=&quot;Attach Camera&quot;/&gt;
&lt;ui:AppBarSeparator /&gt;
&lt;ui:AppBarButton Icon=&quot;Like&quot; Label=&quot;Like&quot;/&gt;
&lt;ui:AppBarButton Icon=&quot;Dislike&quot; Label=&quot;Dislike&quot;/&gt;
&lt;ui:AppBarSeparator /&gt;
&lt;ui:AppBarButton Icon=&quot;Orientation&quot; Label=&quot;Orientation&quot;/&gt;
&lt;/ui:CommandBar.PrimaryCommands&gt;
&lt;/ui:CommandBar&gt;
</sys:String>
</local:ControlExample.Xaml>
</local:ControlExample>
</StackPanel>
</ui:Page>
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,8 @@ void AppBarButtonPage_Loaded(object sender, RoutedEventArgs e)
};
compactButton.Click += CompactButton_Click;
appBar.PrimaryCommands.Insert(0, compactButton);

UpdateExampleCode();
}

private void CompactButton_Click(object sender, RoutedEventArgs e)
Expand All @@ -53,8 +55,55 @@ private void CompactButton_Click(object sender, RoutedEventArgs e)
}
else
{
Control1.DefaultLabelPosition = CommandBarDefaultLabelPosition.Bottom;
Control1.DefaultLabelPosition = CommandBarDefaultLabelPosition.Right;
}

UpdateExampleCode();
}


#region Example Code

public void UpdateExampleCode()
{
Example1.Xaml = Example1Xaml;
}

public string Example1Xaml => $@"
<ui:CommandBar x:Name=""Control1""
DefaultLabelPosition=""{Control1.DefaultLabelPosition.ToString()}"">
<ui:CommandBar.PrimaryCommands>
<ui:AppBarButton Label=""Attach Camera"" >
<ui:AppBarButton.Icon>
<ui:FontIcon Icon=""{{x:Static ui:SegoeFluentIcons.AttachCamera}}""/>
</ui:AppBarButton.Icon>
</ui:AppBarButton>
<ui:AppBarSeparator />
<ui:AppBarButton Label=""Like"" >
<ui:AppBarButton.Icon>
<ui:FontIcon Icon=""{{x:Static ui:SegoeFluentIcons.Like}}""/>
</ui:AppBarButton.Icon>
</ui:AppBarButton>
<ui:AppBarButton Label=""Dislike"" >
<ui:AppBarButton.Icon>
<ui:FontIcon Icon=""{{x:Static ui:SegoeFluentIcons.Dislike}}""/>
</ui:AppBarButton.Icon>
</ui:AppBarButton>
<ui:AppBarSeparator />
<ui:AppBarButton Label=""Orientation"" >
<ui:AppBarButton.Icon>
<ui:FontIcon Icon=""{{x:Static ui:SegoeFluentIcons.Orientation}}""/>
</ui:AppBarButton.Icon>
</ui:AppBarButton>
</ui:CommandBar.PrimaryCommands>
</ui:CommandBar>
";

#endregion
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -11,59 +11,6 @@
d:DesignWidth="800"
mc:Ignorable="d">
<StackPanel>
<local:ControlExample x:Name="Example1" HeaderText="An AppBarToggleButton with a symbol icon.">
<local:ControlExample.Example>
<StackPanel Orientation="Horizontal">
<!-- App bar button with symbol icon. -->
<ui:AppBarToggleButton
x:Name="Button1"
Click="AppBarButton_Click"

Label="SymbolIcon" >
<ui:AppBarToggleButton.Icon>
<ui:SymbolIcon Symbol="Shuffle"/>
</ui:AppBarToggleButton.Icon>
</ui:AppBarToggleButton>
<TextBlock
x:Name="Control1Output"
Margin="8,0,0,0"
VerticalAlignment="Center" />
</StackPanel>
</local:ControlExample.Example>
<local:ControlExample.Xaml>
<sys:String>
&lt;ui:AppBarToggleButton Icon=&quot;Shuffle&quot; Label=&quot;SymbolIcon&quot; Click=&quot;AppBarButton_Click&quot;/&gt;
</sys:String>
</local:ControlExample.Xaml>
</local:ControlExample>
<local:ControlExample x:Name="Example2" HeaderText="An AppBarToggleButton with a bitmap icon.">
<local:ControlExample.Example>
<StackPanel Orientation="Horizontal">
<!-- App bar button with bitmap icon. -->
<ui:AppBarToggleButton
x:Name="Button2"
Click="AppBarButton_Click"
Label="BitmapIcon">
<!--<ui:AppBarToggleButton.Icon>
<ui:BitmapIcon UriSource="/Assets/Slices2.png" />
</ui:AppBarToggleButton.Icon>-->
</ui:AppBarToggleButton>
<TextBlock
x:Name="Control2Output"
Margin="8,0,0,0"
VerticalAlignment="Center" />
</StackPanel>
</local:ControlExample.Example>
<local:ControlExample.Xaml>
<sys:String xml:space="preserve">
&lt;ui:AppBarToggleButton Label=&quot;BitmapIcon&quot; Click=&quot;AppBarButton_Click&quot;&gt;
&lt;ui:AppBarToggleButton.Icon&gt;
&lt;ui:BitmapIcon UriSource=&quot;/Assets/Slices2.png&quot;/&gt;
&lt;/ui:AppBarToggleButton.Icon&gt;
&lt;/ui:AppBarToggleButton&gt;
</sys:String>
</local:ControlExample.Xaml>
</local:ControlExample>
<local:ControlExample x:Name="Example3" HeaderText="An AppBarToggleButton with a font icon.">
<local:ControlExample.Example>
<StackPanel Orientation="Horizontal">
Expand All @@ -73,7 +20,7 @@
Click="AppBarButton_Click"
Label="FontIcon">
<ui:AppBarToggleButton.Icon>
<ui:FontIcon FontFamily="Candara" Glyph="&#x03A3;" />
<ui:FontIcon Icon="{x:Static ui:SegoeFluentIcons.Home}" />
</ui:AppBarToggleButton.Icon>
</ui:AppBarToggleButton>
<TextBlock
Expand All @@ -82,15 +29,6 @@
VerticalAlignment="Center" />
</StackPanel>
</local:ControlExample.Example>
<local:ControlExample.Xaml>
<sys:String xml:space="preserve">
&lt;ui:AppBarToggleButton Label=&quot;FontIcon&quot; Click=&quot;AppBarButton_Click&quot;&gt;
&lt;ui:AppBarToggleButton.Icon&gt;
&lt;ui:FontIcon FontFamily=&quot;Candara&quot; Glyph=&quot;&#x03A3;&quot;/&gt;
&lt;/ui:AppBarToggleButton.Icon&gt;
&lt;/ui:AppBarToggleButton&gt;
</sys:String>
</local:ControlExample.Xaml>
</local:ControlExample>

<local:ControlExample x:Name="Example4" HeaderText="A three-state AppBarToggleButton with a path icon.">
Expand All @@ -112,15 +50,6 @@
VerticalAlignment="Center" />
</StackPanel>
</local:ControlExample.Example>
<local:ControlExample.Xaml>
<sys:String xml:space="preserve">
&lt;ui:AppBarToggleButton Label=&quot;PathIcon&quot; Click=&quot;AppBarButton_Click&quot; IsThreeState=&quot;True&quot;&gt;
&lt;ui:AppBarToggleButton.Icon&gt;
&lt;ui:PathIcon Data=&quot;F1 M 20,20L 24,10L 24,24L 5,24&quot;/&gt;
&lt;/ui:AppBarToggleButton.Icon&gt;
&lt;/ui:AppBarToggleButton&gt;
</sys:String>
</local:ControlExample.Xaml>
</local:ControlExample>
</StackPanel>
</ui:Page>
Loading

0 comments on commit 933f034

Please sign in to comment.