Skip to content

Commit e2d9c8e

Browse files
authored
Yahoo update (#1)
Brings support for Yahoo among other features.
1 parent 74a937e commit e2d9c8e

File tree

71 files changed

+3572
-850
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

71 files changed

+3572
-850
lines changed

Email Inboxes/App.xaml

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,23 @@
1010
<XamlControlsResources xmlns="using:Microsoft.UI.Xaml.Controls" />
1111
<!-- Other merged dictionaries here -->
1212
</ResourceDictionary.MergedDictionaries>
13-
<FontFamily x:Key="CustomIcons">/Assets/Email-Inboxes-Icons.ttf#Email-Inboxes-Icons</FontFamily>
13+
<FontFamily x:Key="CustomIcons">/Assets/Email-Inboxes-Icons.otf#Email-Inboxes-Icons</FontFamily>
14+
<Style TargetType="local:InboxButton">
15+
<Setter Property="Template">
16+
<Setter.Value>
17+
<ControlTemplate TargetType="local:InboxButton">
18+
<Grid>
19+
<Rectangle Opacity="1" Fill="{ThemeResource LayerOnMicaBaseAltFillColorDefaultBrush}" Width="200" Height="225" HorizontalAlignment="Left" RadiusX="8" RadiusY="8" Margin="0,0,0,0" Stroke="{ThemeResource SystemControlBackgroundBaseLowRevealBorderBrush}" StrokeThickness="1"/>
20+
<FontIcon x:Name="HeaderIcon" Glyph="{TemplateBinding Icon}" FontSize="50" Margin="25,25,0,0" HorizontalAlignment="Left" VerticalAlignment="Top"/>
21+
<TextBlock Text="{TemplateBinding Header}" HorizontalAlignment="Left" FontFamily="Segoe UI Variable Display" FontWeight="Normal" FontSize="20" Margin="25,90,0,0"/>
22+
<TextBlock Text="{TemplateBinding Description}" HorizontalAlignment="Left" FontFamily="Segoe UI Variable" FontWeight="Normal" FontSize="12" Foreground="{ThemeResource TextFillColorSecondary}" Margin="25,120,0,0"/>
23+
<FontIcon Glyph="{TemplateBinding ActionIcon}" FontSize="16" Margin="155,180,0,0"/>
24+
<Button x:Name="ButtonControl" Height="225" Width="200" BorderBrush="Transparent" Background="Transparent" HorizontalAlignment="Left" CornerRadius="8" Margin="0,0,0,0"/>
25+
</Grid>
26+
</ControlTemplate>
27+
</Setter.Value>
28+
</Setter>
29+
</Style>
1430
</ResourceDictionary>
1531
</Application.Resources>
1632
</Application>

Email Inboxes/App.xaml.cs

Lines changed: 247 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
using Email_Inboxes;
2+
using Microsoft.UI.Windowing;
23
using Microsoft.UI.Xaml;
34
using Microsoft.UI.Xaml.Controls;
45
using Microsoft.UI.Xaml.Controls.Primitives;
@@ -9,22 +10,109 @@
910
using Microsoft.UI.Xaml.Shapes;
1011
using System;
1112
using System.Collections.Generic;
13+
using System.ComponentModel;
1214
using System.IO;
1315
using System.Linq;
16+
using System.Runtime.InteropServices;
1417
using System.Runtime.InteropServices.WindowsRuntime;
18+
using System.Text.Json;
1519
using Windows.ApplicationModel;
1620
using Windows.ApplicationModel.Activation;
21+
using Windows.ApplicationModel.Appointments;
1722
using Windows.Devices.Bluetooth.Advertisement;
1823
using Windows.Foundation;
1924
using Windows.Foundation.Collections;
25+
using Windows.Graphics;
2026
using Windows.Services.TargetedContent;
2127
using Windows.Storage;
28+
using WinRT;
2229

2330
// To learn more about WinUI, the WinUI project structure,
2431
// and more about our project templates, see: http://aka.ms/winui-project-info.
2532

2633
namespace Email_Inboxes
2734
{
35+
public sealed class InboxButton : Control
36+
{
37+
public InboxButton()
38+
{
39+
this.DefaultStyleKey = typeof(InboxButton);
40+
}
41+
42+
public event RoutedEventHandler Click;
43+
44+
private Button ButtonControl { get; set; }
45+
46+
private FontIcon HeaderIcon { get; set; }
47+
48+
protected override void OnApplyTemplate()
49+
{
50+
base.OnApplyTemplate();
51+
52+
if (ButtonControl is not null)
53+
{
54+
ButtonControl.Click -= ButtonControl_Click;
55+
}
56+
57+
if (GetTemplateChild(nameof(ButtonControl)) is Button button)
58+
{
59+
ButtonControl = button;
60+
ButtonControl.Click += ButtonControl_Click;
61+
}
62+
63+
if (GetTemplateChild(nameof(HeaderIcon)) is FontIcon fontIcon)
64+
{
65+
HeaderIcon = fontIcon;
66+
HeaderIcon.FontFamily = this.IconFontFamily;
67+
}
68+
}
69+
70+
private void ButtonControl_Click(object sender, RoutedEventArgs e)
71+
{
72+
Click?.Invoke(this, e);
73+
}
74+
75+
public string Header
76+
{
77+
get { return (string)GetValue(HeaderProperty); }
78+
set { SetValue(HeaderProperty, value); }
79+
}
80+
81+
public static readonly DependencyProperty HeaderProperty = DependencyProperty.Register("Header", typeof(string), typeof(InboxButton), new PropertyMetadata(string.Empty));
82+
83+
public string Icon
84+
{
85+
get { return (string)GetValue(IconProperty); }
86+
set { SetValue(IconProperty, value); }
87+
}
88+
89+
public static readonly DependencyProperty IconProperty = DependencyProperty.Register("Icon", typeof(string), typeof(InboxButton), new PropertyMetadata(string.Empty));
90+
91+
public FontFamily IconFontFamily
92+
{
93+
get { return (FontFamily)GetValue(IconFontFamilyProperty); }
94+
set { SetValue(IconFontFamilyProperty, value); }
95+
}
96+
97+
public static readonly DependencyProperty IconFontFamilyProperty = DependencyProperty.Register("IconFontFamily", typeof(FontFamily), typeof(InboxButton), new PropertyMetadata((FontFamily)App.Current.Resources["SymbolThemeFontFamily"]));
98+
99+
public string Description
100+
{
101+
get { return (string)GetValue(DescriptionProperty); }
102+
set { SetValue(DescriptionProperty, value); }
103+
}
104+
105+
public static readonly DependencyProperty DescriptionProperty = DependencyProperty.Register("Description", typeof(string), typeof(InboxButton), new PropertyMetadata(string.Empty));
106+
107+
public string ActionIcon
108+
{
109+
get { return (string)GetValue(ActionIconProperty); }
110+
set { SetValue(ActionIconProperty, value); }
111+
}
112+
113+
public static readonly DependencyProperty ActionIconProperty = DependencyProperty.Register("ActionIcon", typeof(string), typeof(InboxButton), new PropertyMetadata(string.Empty));
114+
}
115+
28116
/// <summary>
29117
/// Provides application-specific behavior to supplement the default Application class.
30118
/// </summary>
@@ -36,6 +124,31 @@ public partial class App : Application
36124
/// </summary>
37125
ApplicationDataContainer localSettings = Windows.Storage.ApplicationData.Current.LocalSettings;
38126

127+
//Class to store settings so they can be always spelled correctly
128+
public static class Settings
129+
{
130+
public const string StartupPage = "StartupPage";
131+
public const string HomeEnabled = "HomeEnabled";
132+
public const string OutlookEnabled = "OutlookEnabled";
133+
public const string ProtonEnabled = "ProtonEnabled";
134+
public const string iCloudEnabled = "iCloudEnabled";
135+
public const string GmailEnabled = "GmailEnabled";
136+
public const string YahooEnabled = "YahooEnabled";
137+
public const string CommandBarEnabled = "CommandBarEnabled";
138+
public const string OutlookAppType = "OutlookAppType";
139+
public const string ToDoServiceName = "ToDoServiceName";
140+
public const string CalendarServiceName = "CalendarServiceName";
141+
public const string ToDoServiceUrl = "ToDoServiceUrl";
142+
public const string CalendarServiceUrl = "CalendarServiceUrl";
143+
public const string OutlookExePath = "OutlookExePath";
144+
public const string Backdrop = "Backdrop";
145+
public const string PaneDisplayMode = "PaneDisplayMode";
146+
public const string FirstBootScreenPassed = "FirstBootScreenPassed";
147+
public const string VersionNumber = "VersionNumber";
148+
public const string WindowState = "WindowState";
149+
public static bool SettingsChangable { get; set; }
150+
}
151+
39152
public App()
40153
{
41154
this.InitializeComponent();
@@ -47,48 +160,151 @@ public App()
47160
/// <param name="args">Details about the launch request and process.</param>
48161
protected override void OnLaunched(Microsoft.UI.Xaml.LaunchActivatedEventArgs args)
49162
{
50-
m_window = new MainWindow();
51-
m_window.Activate();
163+
//Sets the value of SettingsChangable so that settings aren't changable within the application
164+
Settings.SettingsChangable = false;
52165

53-
string StartupPage = "Home";
166+
//Settings checkers to check if settings exist
167+
if (!localSettings.Values.ContainsKey(Settings.HomeEnabled))
168+
localSettings.Values[Settings.HomeEnabled] = true;
54169

55-
if (localSettings.Values.ContainsKey("StartupPage"))
56-
{
57-
StartupPage = localSettings.Values["StartupPage"].ToString();
58-
}
59-
else
170+
if (!localSettings.Values.ContainsKey(Settings.iCloudEnabled))
171+
localSettings.Values[Settings.iCloudEnabled] = false;
172+
173+
if (!localSettings.Values.ContainsKey(Settings.GmailEnabled))
174+
localSettings.Values[Settings.GmailEnabled] = false;
175+
176+
if (!localSettings.Values.ContainsKey(Settings.ProtonEnabled))
177+
localSettings.Values[Settings.ProtonEnabled] = false;
178+
179+
if (!localSettings.Values.ContainsKey(Settings.YahooEnabled))
180+
localSettings.Values[Settings.YahooEnabled] = false;
181+
182+
if (!localSettings.Values.ContainsKey(Settings.OutlookEnabled))
183+
localSettings.Values[Settings.OutlookEnabled] = false;
184+
185+
if (!localSettings.Values.ContainsKey(Settings.CommandBarEnabled))
186+
localSettings.Values[Settings.CommandBarEnabled] = true;
187+
188+
if (!localSettings.Values.ContainsKey(Settings.OutlookAppType))
189+
localSettings.Values[Settings.OutlookAppType] = "Website";
190+
191+
if (!localSettings.Values.ContainsKey(Settings.ToDoServiceUrl))
192+
localSettings.Values[Settings.ToDoServiceUrl] = "disabled";
193+
194+
if (!localSettings.Values.ContainsKey(Settings.ToDoServiceName))
195+
localSettings.Values[Settings.ToDoServiceName] = "Disabled";
196+
197+
if (!localSettings.Values.ContainsKey(Settings.CalendarServiceUrl))
198+
localSettings.Values[Settings.CalendarServiceUrl] = "disabled";
199+
200+
if (!localSettings.Values.ContainsKey(Settings.CalendarServiceName))
201+
localSettings.Values[Settings.CalendarServiceName] = "Disabled";
202+
203+
if (!localSettings.Values.ContainsKey(Settings.StartupPage))
204+
localSettings.Values[Settings.StartupPage] = "Home";
205+
206+
if (!localSettings.Values.ContainsKey(Settings.OutlookExePath))
207+
localSettings.Values[Settings.OutlookExePath] = @"C:\Program Files\Microsoft Office\root\Office16\OUTLOOK.EXE";
208+
209+
if (!localSettings.Values.ContainsKey(Settings.Backdrop))
210+
localSettings.Values[Settings.Backdrop] = "Mica";
211+
212+
if (!localSettings.Values.ContainsKey(Settings.FirstBootScreenPassed))
213+
localSettings.Values[Settings.FirstBootScreenPassed] = false;
214+
215+
if (!localSettings.Values.ContainsKey(Settings.PaneDisplayMode))
216+
localSettings.Values[Settings.PaneDisplayMode] = "Auto";
217+
218+
if (!localSettings.Values.ContainsKey(Settings.WindowState))
219+
localSettings.Values[Settings.WindowState] = OverlappedPresenterState.Restored.ToString();
220+
221+
//Backwards compatibility code that updates the values of Home, iCloud, Gmail, Proton, & Outlook Enabled from strings to booleans & sets YahooEnabled and FirstBootScreenPassed to true
222+
if (localSettings.Values[Settings.HomeEnabled] is string)
60223
{
61-
localSettings.Values["StartupPage"] = "Home";
62-
StartupPage = localSettings.Values["StartupPage"].ToString();
224+
localSettings.Values[Settings.HomeEnabled] = (string)localSettings.Values[Settings.HomeEnabled] == "True";
225+
localSettings.Values[Settings.iCloudEnabled] = (string)localSettings.Values[Settings.iCloudEnabled] == "True";
226+
localSettings.Values[Settings.GmailEnabled] = (string)localSettings.Values[Settings.GmailEnabled] == "True";
227+
localSettings.Values[Settings.ProtonEnabled] = (string)localSettings.Values[Settings.ProtonEnabled] == "True";
228+
localSettings.Values[Settings.OutlookEnabled] = (string)localSettings.Values[Settings.OutlookEnabled] == "True";
229+
localSettings.Values[Settings.FirstBootScreenPassed] = localSettings.Values[Settings.YahooEnabled] = true;
63230
}
64231

65-
string NavItem_StartupPage = "NavItem_Home";
66-
switch (StartupPage)
232+
if (!((string)localSettings.Values[Settings.VersionNumber] == "1.3"))
233+
localSettings.Values[Settings.VersionNumber] = "1.3";
234+
235+
//Checks for value of FirstBootScreenPassed
236+
if ((bool)localSettings.Values[Settings.FirstBootScreenPassed])
67237
{
68-
case "Home":
69-
NavItem_StartupPage = "NavItem_Home";
70-
break;
71-
case "Outlook":
72-
NavItem_StartupPage = "NavItem_Outlook";
73-
break;
74-
case "Gmail":
75-
NavItem_StartupPage = "NavItem_Gmail";
76-
break;
77-
case "iCloud Mail":
78-
NavItem_StartupPage = "NavItem_iCloud";
79-
break;
80-
case "Proton Mail":
81-
NavItem_StartupPage = "NavItem_Proton";
82-
break;
238+
//If true, it creates & activates the MainWindow
239+
m_window = new MainWindow();
240+
m_window.Activate();
83241
}
242+
else
243+
{
244+
//If not, it DllImports a method to get the window Dpi
245+
[DllImport("User32.dll", SetLastError = true, CharSet = CharSet.Unicode)]
246+
static extern uint GetDpiForWindow(IntPtr hwnd);
247+
248+
//Then it creates and activates FirstBootWindow
249+
firstBootWindow = new FirstBootWindow();
84250

85-
MainWindow mw = (MainWindow)((App)Application.Current).m_window;
86-
var item = mw.nvSample.MenuItems.First(i => ((NavigationViewItem)i).Name == NavItem_StartupPage);
87-
mw.nvSample.SelectedItem = item;
251+
var hWnd = WinRT.Interop.WindowNative.GetWindowHandle(firstBootWindow);
252+
Microsoft.UI.WindowId windowId = Microsoft.UI.Win32Interop.GetWindowIdFromWindow(hWnd);
253+
Microsoft.UI.Windowing.AppWindow appWindow = Microsoft.UI.Windowing.AppWindow.GetFromWindowId(windowId);
254+
if (appWindow is not null)
255+
{
256+
double scale;
257+
uint dpi = GetDpiForWindow(hWnd);
258+
switch (dpi)
259+
{
260+
case 90:
261+
scale = 1;
262+
break;
263+
case 120:
264+
scale = 1.25;
265+
break;
266+
case 144:
267+
scale = 1.5;
268+
break;
269+
case 168:
270+
scale = 1.75;
271+
break;
272+
case 192:
273+
scale = 2;
274+
break;
275+
case 216:
276+
scale = 2.25;
277+
break;
278+
case 240:
279+
scale = 2.5;
280+
break;
281+
case 288:
282+
scale = 3;
283+
break;
284+
default:
285+
scale = (double)dpi / 100;
286+
break;
287+
}
288+
var newSize = new SizeInt32();
289+
newSize.Width = (int)(960 * scale);
290+
newSize.Height = (int)(648 * scale);
291+
appWindow.Resize(newSize);
292+
293+
Microsoft.UI.Windowing.DisplayArea displayArea = Microsoft.UI.Windowing.DisplayArea.GetFromWindowId(windowId, Microsoft.UI.Windowing.DisplayAreaFallback.Nearest);
294+
if (displayArea is not null)
295+
{
296+
var CenteredPosition = appWindow.Position;
297+
CenteredPosition.X = ((displayArea.WorkArea.Width - appWindow.Size.Width) / 2);
298+
CenteredPosition.Y = ((displayArea.WorkArea.Height - appWindow.Size.Height) / 2);
299+
appWindow.Move(CenteredPosition);
300+
}
301+
}
302+
firstBootWindow.Activate();
303+
}
88304
}
89305

90306
public Window m_window;
91307

92-
public Frame contentFrame { get; private set; }
308+
public Window firstBootWindow;
93309
}
94310
}
5.57 KB
Binary file not shown.
-1.92 KB
Binary file not shown.
3.99 KB
Loading
17.8 KB
Loading
1.27 KB
Loading
1.57 KB
Loading
1.86 KB
Loading
4.62 KB
Loading

0 commit comments

Comments
 (0)