Skip to content

Commit

Permalink
Cleanup unnecessary code (microsoft#1299)
Browse files Browse the repository at this point in the history
  • Loading branch information
marcelwgn committed Oct 11, 2023
1 parent 20cd457 commit 1d23724
Show file tree
Hide file tree
Showing 32 changed files with 219 additions and 612 deletions.
5 changes: 0 additions & 5 deletions WinUIGallery/App.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -116,11 +116,6 @@ protected override void OnLaunched(Microsoft.UI.Xaml.LaunchActivatedEventArgs ar
startupWindow = WindowHelper.CreateWindow();
startupWindow.ExtendsContentIntoTitleBar = true;
#if DEBUG
//if (System.Diagnostics.Debugger.IsAttached)
//{
// this.DebugSettings.EnableFrameRateCounter = true;
//}

if (System.Diagnostics.Debugger.IsAttached)
{
this.DebugSettings.BindingFailed += DebugSettings_BindingFailed;
Expand Down
6 changes: 2 additions & 4 deletions WinUIGallery/Common/ActivityFeedLayout.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
using System;
using System;
using System.Collections.Generic;
using Windows.Foundation;
using Microsoft.UI.Xaml;
Expand Down Expand Up @@ -95,8 +95,7 @@ private static void OnPropertyChanged(DependencyObject obj, DependencyPropertyCh
protected override void InitializeForContextCore(VirtualizingLayoutContext context)
{
base.InitializeForContextCore(context);

if (!(context.LayoutState is ActivityFeedLayoutState state))
if (!(context.LayoutState is ActivityFeedLayoutState))
{
// Store any state we might need since (in theory) the layout could be in use by multiple
// elements simultaneously
Expand Down Expand Up @@ -169,7 +168,6 @@ protected override Size MeasureOverride(VirtualizingLayoutContext context, Size
for (int columnIndex = 0; columnIndex < 3; columnIndex++)
{
var index = firstItemIndex + columnIndex;
var rect = boundsForCurrentRow[index % 3];
var container = context.GetOrCreateElementAt(index);

container.Measure(
Expand Down
3 changes: 1 addition & 2 deletions WinUIGallery/Common/Category.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
using System;
using System;
using Microsoft.UI.Xaml.Controls;

namespace AppUIBasics.Common
Expand All @@ -11,7 +11,6 @@ public class Category : CategoryBase
public string Name { get; set; }
public string Tooltip { get; set; }
public Symbol Glyph { get; set; }
//public Type TargetType { get; set; }
}

public class Separator : CategoryBase { }
Expand Down
7 changes: 1 addition & 6 deletions WinUIGallery/Common/ColorSlideTransitionHelper.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
//*********************************************************
//*********************************************************
//
// Copyright (c) Microsoft. All rights reserved.
// This code is licensed under the MIT License (MIT).
Expand All @@ -25,7 +25,6 @@ public class ColorSlideTransitionHelper
{
#region Member variables

UIElement hostForVisual;
Compositor _compositor;
ContainerVisual _containerForVisuals;
ScalarKeyFrameAnimation _slideAnimation;
Expand All @@ -42,10 +41,6 @@ public class ColorSlideTransitionHelper
/// </summary>
public ColorSlideTransitionHelper(UIElement hostForVisual)
{


this.hostForVisual = hostForVisual;

// we have an element in the XAML tree that will host our Visuals
var visual = ElementCompositionPreview.GetElementVisual(hostForVisual);
_compositor = visual.Compositor;
Expand Down
4 changes: 1 addition & 3 deletions WinUIGallery/Common/MenuItemTemplateSelector.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
using Microsoft.UI.Xaml;
using Microsoft.UI.Xaml;
using Microsoft.UI.Xaml.Controls;
using Microsoft.UI.Xaml.Markup;
using System;
Expand All @@ -11,8 +11,6 @@ class MenuItemTemplateSelector : DataTemplateSelector
{
public DataTemplate ItemTemplate { get; set; }

//public string PaneTitle { get; set; }

protected override DataTemplate SelectTemplateCore(object item)
{
return item is Separator ? SeparatorTemplate : item is Header ? HeaderTemplate : ItemTemplate;
Expand Down
1 change: 0 additions & 1 deletion WinUIGallery/Common/Win32.cs
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ internal static class Win32

public const int WM_ACTIVATE = 0x0006;
public const int WA_ACTIVE = 0x01;
//static int WA_CLICKACTIVE = 0x02;
public const int WA_INACTIVE = 0x00;

public const int WM_SETICON = 0x0080;
Expand Down
4 changes: 1 addition & 3 deletions WinUIGallery/Common/WrapPanel.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
using System;
using System;
using System.Collections.Generic;
using System.Diagnostics.CodeAnalysis;
using System.Globalization;
Expand Down Expand Up @@ -38,7 +38,6 @@ public class WrapPanel : Panel
/// within a <see cref="T:WinRTXamlToolkit.Controls.WrapPanel" />. The
/// default value is <see cref="F:System.Double.NaN" />.
/// </value>
//[TypeConverter(typeof(LengthConverter))]
public double ItemHeight
{
get { return (double)GetValue(ItemHeightProperty); }
Expand Down Expand Up @@ -73,7 +72,6 @@ public double ItemHeight
/// contained in a <see cref="T:WinRTXamlToolkit.Controls.WrapPanel" />.
/// The default value is <see cref="F:System.Double.NaN" />.
/// </value>
//[TypeConverter(typeof(LengthConverter))]
public double ItemWidth
{
get { return (double)GetValue(ItemWidthProperty); }
Expand Down
5 changes: 2 additions & 3 deletions WinUIGallery/ConnectedAnimationPages/CollectionPage.xaml.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
using System;
using System;
using Microsoft.UI.Xaml;
using Microsoft.UI.Xaml.Controls;
using Microsoft.UI.Xaml.Media.Animation;
Expand Down Expand Up @@ -59,8 +59,7 @@ private void collection_ItemClick(object sender, ItemClickEventArgs e)
// Prepare the connected animation.
// Notice that the stored item is passed in, as well as the name of the connected element.
// The animation will actually start on the Detailed info page.
var animation = collection.PrepareConnectedAnimation("ForwardConnectedAnimation", _storeditem, "connectedElement");

collection.PrepareConnectedAnimation("ForwardConnectedAnimation", _storeditem, "connectedElement");
}

// Navigate to the DetailedInfoPage.
Expand Down
11 changes: 0 additions & 11 deletions WinUIGallery/ControlPages/AppBarSeparatorPage.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -20,16 +20,5 @@ public AppBarSeparatorPage()
{
this.InitializeComponent();
}
private void CompactButton_Click(object sender, RoutedEventArgs e)
{
if ((sender as AppBarToggleButton).IsChecked == true)
{
Control1.DefaultLabelPosition = CommandBarDefaultLabelPosition.Collapsed;
}
else
{
Control1.DefaultLabelPosition = CommandBarDefaultLabelPosition.Bottom;
}
}
}
}
11 changes: 0 additions & 11 deletions WinUIGallery/ControlPages/AppBarToggleButtonPage.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -21,17 +21,6 @@ public AppBarToggleButtonPage()
this.InitializeComponent();
}

private void CompactButton_Click(object sender, RoutedEventArgs e)
{
if (sender is ToggleButton toggle && toggle.IsChecked != null)
{
Button1.IsCompact =
Button2.IsCompact =
Button3.IsCompact =
Button4.IsCompact = (bool)toggle.IsChecked;
}
}

private void AppBarButton_Click(object sender, RoutedEventArgs e)
{
if (sender is AppBarToggleButton b)
Expand Down
2 changes: 1 addition & 1 deletion WinUIGallery/ControlPages/ComboBoxPage.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ private void Combo3_TextSubmitted(ComboBox sender, ComboBoxTextSubmittedEventArg
dialog.CloseButtonText = "Close";
dialog.DefaultButton = ContentDialogButton.Close;
dialog.XamlRoot = sender.XamlRoot;
var task = dialog.ShowAsync();
_ = dialog.ShowAsync();
}

// Mark the event as handled so the framework doesn’t update the selected item automatically.
Expand Down
1 change: 0 additions & 1 deletion WinUIGallery/ControlPages/CommandBarPage.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,6 @@ private void CloseButton_Click(object sender, RoutedEventArgs e)

private void OnElementClicked(object sender, Microsoft.UI.Xaml.RoutedEventArgs e)
{
var selectedFlyoutItem = sender as AppBarButton;
SelectedOptionText.Text = "You clicked: " + (sender as AppBarButton).Label;
}

Expand Down
7 changes: 1 addition & 6 deletions WinUIGallery/ControlPages/CreateMultipleWindowsPage.xaml.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
//*********************************************************
//*********************************************************
//
// Copyright (c) Microsoft. All rights reserved.
// THIS CODE IS PROVIDED *AS IS* WITHOUT WARRANTY OF
Expand All @@ -23,11 +23,6 @@ public CreateMultipleWindowsPage()
this.InitializeComponent();
}

private void List_GotFocus(object sender, RoutedEventArgs e)
{
Control1.StartBringIntoView();
}

private void createNewWindow_Click(object sender, RoutedEventArgs e)
{
var newWindow = WindowHelper.CreateWindow();
Expand Down
1 change: 0 additions & 1 deletion WinUIGallery/ControlPages/ItemsRepeaterPage.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -293,7 +293,6 @@ private void InitializeData()
Click="OnAnimatedItemClicked"
GotFocus="OnAnimatedItemGotFocus"
HorizontalAlignment="Stretch"
Loaded="GetButtonSize"
Foreground="{ThemeResource TextFillColorInverseBrush}">
</Button>
</DataTemplate>
Expand Down
30 changes: 0 additions & 30 deletions WinUIGallery/ControlPages/ItemsRepeaterPage.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,6 @@ public sealed partial class ItemsRepeaterPage : ItemsPageBase
public List<Recipe> staticRecipeData;
private bool IsSortDescending = false;

private double AnimatedBtnHeight;
private Thickness AnimatedBtnMargin;
private Button LastSelectedColorButton;
private int PreviouslyFocusedAnimatedScrollRepeaterIndex = -1;

Expand Down Expand Up @@ -316,13 +314,6 @@ private void OnElementPrepared(Microsoft.UI.Xaml.Controls.ItemsRepeater sender,
item.StartAnimation("CenterPoint", centerPointExpression);
}

private void GetButtonSize(object sender, RoutedEventArgs e)
{
Button AnimatedBtn = sender as Button;
AnimatedBtnHeight = AnimatedBtn.ActualHeight;
AnimatedBtnMargin = AnimatedBtn.Margin;
}

private void SetUIANamesForSelectedEntry(Button selectedItem)
{
if (LastSelectedColorButton != null && LastSelectedColorButton.Content is string content)
Expand All @@ -334,27 +325,6 @@ private void SetUIANamesForSelectedEntry(Button selectedItem)
LastSelectedColorButton = selectedItem;
}

// Find centerpoint of ScrollViewer
private double CenterPointOfViewportInExtent()
{
return Animated_ScrollViewer.VerticalOffset + Animated_ScrollViewer.ViewportHeight / 2;
}

// Find index of the item that's at the center of the viewport
private int GetSelectedIndexFromViewport()
{
int selectedItemIndex = (int)Math.Floor(CenterPointOfViewportInExtent() / ((double)AnimatedBtnMargin.Top + AnimatedBtnHeight));
selectedItemIndex %= animatedScrollRepeater.ItemsSourceView.Count;
return selectedItemIndex;
}

// Return item that's currently in center of viewport
private object GetSelectedItemFromViewport()
{
var selectedIndex = GetSelectedIndexFromViewport();
var selectedElement = animatedScrollRepeater.TryGetElement(selectedIndex) as Button;
return selectedElement;
}

// ==========================================================================
// VariedImageSize Layout with Filtering/Sorting
Expand Down
31 changes: 0 additions & 31 deletions WinUIGallery/ControlPages/NavigationViewPage.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -198,37 +198,6 @@ private void NavigationView_SelectionChanged9(Microsoft.UI.Xaml.Controls.Navigat
contentFrame9.Navigate(pageType, null, args.RecommendedNavigationTransitionInfo);
}

private void databindHeader_Checked(object sender, RoutedEventArgs e)
{
Categories = new ObservableCollection<CategoryBase>()
{
new Header { Name = "Header1 "},
new Category { Name = "Category 1", Glyph = Symbol.Home, Tooltip = "This is category 1" },
new Category { Name = "Category 2", Glyph = Symbol.Keyboard, Tooltip = "This is category 2" },
new Separator(),
new Header { Name = "Header2 "},
new Category {Name = "Category 3", Glyph = Symbol.Library, Tooltip = "This is category 3" },
new Category {Name = "Category 4", Glyph = Symbol.Mail, Tooltip = "This is category 3" }
};
}

private void databindHeader_Checked_Unchecked(object sender, RoutedEventArgs e)
{
Categories = new ObservableCollection<CategoryBase>()
{
new Category { Name = "Category 1", Glyph = Symbol.Home, Tooltip = "This is category 1" },
new Category { Name = "Category 2", Glyph = Symbol.Keyboard, Tooltip = "This is category 2" },
new Category {Name = "Category 3", Glyph = Symbol.Library, Tooltip = "This is category 3" },
new Category {Name = "Category 4", Glyph = Symbol.Mail, Tooltip = "This is category 3" }
};
}

private void Grid_ManipulationDelta1(object sender, Microsoft.UI.Xaml.Input.ManipulationDeltaRoutedEventArgs e)
{
var grid = sender as Grid;
grid.Width = grid.ActualWidth + e.Delta.Translation.X;
}

private void headerCheck_Click(object sender, RoutedEventArgs e)
{
nvSample.AlwaysShowHeader = (sender as CheckBox).IsChecked == true ? true : false;
Expand Down
3 changes: 1 addition & 2 deletions WinUIGallery/ControlPages/PullToRefreshPage.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,6 @@ public PullToRefreshPage()
private void PullToRefreshPage_Loaded(object sender, RoutedEventArgs e)
{
visualizerContentVisual = ElementCompositionPreview.GetElementVisual(rv2.Content);

this.Loaded -= PullToRefreshPage_Loaded;
}

Expand Down Expand Up @@ -200,7 +199,7 @@ private void rc2_RefreshRequested(RefreshContainer sender, RefreshRequestedEvent

private void rv2_RefreshStateChanged(RefreshVisualizer sender, RefreshStateChangedEventArgs args)
{
//visualizerContentVisual.StopAnimation("RotationAngle");
visualizerContentVisual.StopAnimation("RotationAngle");
}
}
}
16 changes: 2 additions & 14 deletions WinUIGallery/ControlPages/RichEditBoxPage.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -188,7 +188,7 @@ private void FindBoxRemoveHighlights()

private void Editor_GotFocus(object sender, RoutedEventArgs e)
{
editor.Document.GetText(TextGetOptions.UseCrlf, out string currentRawText);
editor.Document.GetText(TextGetOptions.UseCrlf, out _);

// reset colors to correct defaults for Focused state
ITextRange documentRange = editor.Document.GetRange(0, TextConstants.MaxUnitCount);
Expand All @@ -200,18 +200,6 @@ private void Editor_GotFocus(object sender, RoutedEventArgs e)
}
}

private void Page_SizeChanged(object sender, SizeChangedEventArgs e)
{
if (e.NewSize.Width <= 768)
{
editor.Width = e.NewSize.Width - 20;
}
else
{
editor.Width = e.NewSize.Width - 100;
}
}

private void REBCustom_Loaded(object sender, RoutedEventArgs e)
{
// Prior to UniversalApiContract 7, RichEditBox did not have a default ContextFlyout set.
Expand Down Expand Up @@ -243,4 +231,4 @@ private void Editor_TextChanged(object sender, RoutedEventArgs e)
}
}
}
}
}

0 comments on commit 1d23724

Please sign in to comment.