mgpk-politex-zadania

Форк
0
1
using Microsoft.Toolkit.Uwp.UI.Controls;
2
using System;
3
using System.Collections.Generic;
4
using System.Collections.ObjectModel;
5
using System.Configuration;
6
using System.Data;
7
using System.Data.SqlClient;
8
using System.IO;
9
using System.Linq;
10
using System.Runtime.InteropServices.WindowsRuntime;
11
using Windows.ApplicationModel.Core;
12
using Windows.Foundation;
13
using Windows.Foundation.Collections;
14
using Windows.UI;
15
using Windows.UI.ViewManagement;
16
using Windows.UI.Xaml;
17
using Windows.UI.Xaml.Controls;
18
using Windows.UI.Xaml.Controls.Primitives;
19
using Windows.UI.Xaml.Data;
20
using Windows.UI.Xaml.Input;
21
using Windows.UI.Xaml.Media;
22
using Windows.UI.Xaml.Navigation;
23

24
// The Blank Page item template is documented at https://go.microsoft.com/fwlink/?LinkId=402352&clcid=0x409
25

26
namespace UWPKursovayaAvtobus
27
{
28
    /// <summary>
29
    /// An empty page that can be used on its own or navigated to within a Frame.
30
    /// </summary>
31
    public sealed partial class MainPage : Page
32
    {
33
        public MainPage()
34
        {
35
            this.InitializeComponent();
36
            var titleBar = ApplicationView.GetForCurrentView().TitleBar;
37

38
            titleBar.ButtonBackgroundColor = Colors.Transparent;
39
            titleBar.ButtonInactiveBackgroundColor = Colors.Transparent;
40

41
            // Hide default title bar.
42
            var coreTitleBar = CoreApplication.GetCurrentView().TitleBar;
43
            coreTitleBar.ExtendViewIntoTitleBar = true;
44
            UpdateTitleBarLayout(coreTitleBar);
45

46
            // Set XAML element as a draggable region.
47
            Window.Current.SetTitleBar(AppTitleBar);
48

49
            // Register a handler for when the size of the overlaid caption control changes.
50
            // For example, when the app moves to a screen with a different DPI.
51
            coreTitleBar.LayoutMetricsChanged += CoreTitleBar_LayoutMetricsChanged;
52

53
            // Register a handler for when the title bar visibility changes.
54
            // For example, when the title bar is invoked in full screen mode.
55
            coreTitleBar.IsVisibleChanged += CoreTitleBar_IsVisibleChanged;
56

57
            //Register a handler for when the window changes focus
58
            Window.Current.Activated += Current_Activated;
59
        }
60

61
        private void CoreTitleBar_LayoutMetricsChanged(CoreApplicationViewTitleBar sender, object args)
62
        {
63
            UpdateTitleBarLayout(sender);
64
        }
65

66
        private void UpdateTitleBarLayout(CoreApplicationViewTitleBar coreTitleBar)
67
        {
68
            // Update title bar control size as needed to account for system size changes.
69
            AppTitleBar.Height = coreTitleBar.Height;
70

71
            // Ensure the custom title bar does not overlap window caption controls
72
            Thickness currMargin = AppTitleBar.Margin;
73
            AppTitleBar.Margin = new Thickness(currMargin.Left, currMargin.Top, coreTitleBar.SystemOverlayRightInset, currMargin.Bottom);
74
        }
75

76
        private void CoreTitleBar_IsVisibleChanged(CoreApplicationViewTitleBar sender, object args)
77
        {
78
            if (sender.IsVisible)
79
            {
80
                AppTitleBar.Visibility = Visibility.Visible;
81
            }
82
            else
83
            {
84
                AppTitleBar.Visibility = Visibility.Collapsed;
85
            }
86
        }
87

88
        // Update the TitleBar based on the inactive/active state of the app
89
        private void Current_Activated(object sender, Windows.UI.Core.WindowActivatedEventArgs e)
90
        {
91
            SolidColorBrush defaultForegroundBrush = Resources.ThemeDictionaries["DefaultTextForegroundThemeBrush"] as SolidColorBrush;
92
            SolidColorBrush inactiveForegroundBrush = Resources.ThemeDictionaries["DefaultTextForegroundThemeBrush"] as SolidColorBrush;
93

94
            if (e.WindowActivationState == Windows.UI.Core.CoreWindowActivationState.Deactivated)
95
            {
96
                AppTitle.Foreground = inactiveForegroundBrush;
97
            }
98
            else
99
            {
100
                AppTitle.Foreground = defaultForegroundBrush;
101
            }
102
        }
103

104
        // Update the TitleBar content layout depending on NavigationView DisplayMode
105
        
106

107
        private void NavigationView_ItemInvoked(NavigationView sender, NavigationViewItemInvokedEventArgs args)
108
        {
109
            var ItemContent = args.InvokedItemContainer;
110
            if (ItemContent != null)
111
            {
112
                switch (ItemContent.Tag)
113
                {
114
                    case "Home_Page":
115
                        contentFrame.Navigate(typeof(BlankPage1));
116
                        break;
117
                    case "sotr":
118
                        contentFrame.Navigate(typeof(Nav_Sotrudniks));
119
                        break;
120
                    case "obsluger":
121
                        contentFrame.Navigate(typeof(Nav_Obslugers));
122
                        break;
123
                    case "saler":
124
                        contentFrame.Navigate(typeof(Nav_salers));
125
                        break;
126
                    case "deleter":
127
                        contentFrame.Navigate(typeof(Nav_deleters));
128
                        break;
129
                }
130
            }
131
        }
132

133
        private void NavigationView_Loaded(object sender, RoutedEventArgs e)
134
        {
135
            foreach (NavigationViewItemBase item in nvTopLevelNav.MenuItems)
136
            {
137
                if (item is NavigationViewItem && item.Tag.ToString() == "Home_Page")
138
                {
139
                    nvTopLevelNav.SelectedItem = item;
140
                    break;
141
                }
142
            }
143
            contentFrame.Navigate(typeof(BlankPage1));
144
        }
145

146
        private void NavigationViewControl_DisplayModeChanged(NavigationView sender, NavigationViewDisplayModeChangedEventArgs args)
147
        {
148
            const int topIndent = 16;
149
            const int expandedIndent = 48;
150
            int minimalIndent = 104;
151

152
            // If the back button is not visible, reduce the TitleBar content indent.
153
            if (nvTopLevelNav.IsBackButtonVisible.Equals(Microsoft.UI.Xaml.Controls.NavigationViewBackButtonVisible.Collapsed))
154
            {
155
                minimalIndent = 48;
156
            }
157

158
            Thickness currMargin = AppTitleBar.Margin;
159

160
            // Set the TitleBar margin dependent on NavigationView display mode
161
            if (sender.PaneDisplayMode == NavigationViewPaneDisplayMode.Top)
162
            {
163
                AppTitleBar.Margin = new Thickness(topIndent, currMargin.Top, currMargin.Right, currMargin.Bottom);
164
            }
165
            else if (sender.DisplayMode == NavigationViewDisplayMode.Minimal)
166
            {
167
                AppTitleBar.Margin = new Thickness(minimalIndent, currMargin.Top, currMargin.Right, currMargin.Bottom);
168
            }
169
            else
170
            {
171
                AppTitleBar.Margin = new Thickness(expandedIndent, currMargin.Top, currMargin.Right, currMargin.Bottom);
172
            }
173
        }
174
    }
175
}
176

Использование cookies

Мы используем файлы cookie в соответствии с Политикой конфиденциальности и Политикой использования cookies.

Нажимая кнопку «Принимаю», Вы даете АО «СберТех» согласие на обработку Ваших персональных данных в целях совершенствования нашего веб-сайта и Сервиса GitVerse, а также повышения удобства их использования.

Запретить использование cookies Вы можете самостоятельно в настройках Вашего браузера.