private async void Page_Loaded(object sender, RoutedEventArgs e) { try { App.Discord.MessageCreated += Notification_MessageCreated; UpdateTitleBar(); CheckSettingsPane(); _loaded = true; this.FindParent <MainPage>().HideConnectingOverlay(); var service = DiscordNavigationService.GetForCurrentView(); if (_args != null && _args.ChannelId != 0) { var channel = await App.Discord.GetChannelAsync(_args.ChannelId); await service.NavigateAsync(channel); } else { Model.IsFriendsSelected = true; SidebarFrame.Navigate(typeof(DMChannelsPage)); MainFrame.Navigate(typeof(FriendsPage)); } if (_args?.ThemeLoadException != null) { var message = App.Discord.CreateMockMessage( $"We had some trouble loading your selected themes, so we disabled them for this launch. For more information, see settings.", App.Discord.CreateMockUser("Unicord", "CORD")); ShowNotification(message); } var possibleConnection = await VoiceConnectionModel.FindExistingConnectionAsync(); if (possibleConnection != null) { (DataContext as DiscordPageModel).VoiceModel = possibleConnection; } await ContactListManager.UpdateContactsListAsync(); } catch (Exception ex) { await UIUtilities.ShowErrorDialogAsync("An error has occured.", ex.Message); } }
private void SettingsButton_Click(object sender, RoutedEventArgs e) { SidebarFrame.BackStack.Clear(); SidebarHeader.ShowBackButton = false; if (!(SidebarFrame.Content is SettingsView)) { SidebarFrame.Navigate(typeof(SettingsView)); var settingsView = (SettingsView)SidebarFrame.Content; if (settingsView != null) { settingsView.Header = SidebarHeader; } } SidebarHeader.Title = "Settings"; ToggleSidebar(); }
private void HeaderBlock_BackButtonClicked(object sender, EventArgs e) { if (SidebarFrame.CanGoBack) { SidebarFrame.GoBack(); } if (SidebarFrame.Content is SettingsView) { var settingsView = (SettingsView)SidebarFrame.Content; if (settingsView != null) { SidebarHeader.Title = "Settings"; settingsView.Header = SidebarHeader; } } SidebarHeader.ShowBackButton = false; }
public MainWindow() { // Ensure only one USurvive is running Process proc = Process.GetCurrentProcess(); int count = Process.GetProcesses().Where(p => p.ProcessName == proc.ProcessName).Count(); if (count > 1) { MessageBox.Show("Only one instance of USurvive can run at a time."); App.Current.Shutdown(); } InitializeComponent(); Globals.tempClasses = new ObservableCollection <Class>(); Globals.tempAssignments = new List <Assignment>(); //NavigationService service = NavigationService.GetNavigationService(NavigationFrame); //Set up dataDir varaiable Globals.dataDir = Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData); Globals.dataDir += "\\USurvive"; //Set up data directory if (!Directory.Exists(Globals.dataDir)) { //Create data dir in AppData Directory.CreateDirectory(Globals.dataDir); //Create default database directory Directory.CreateDirectory(Globals.dataDir + "\\default"); } //Add final '\' to place path inside %AppData%/USurvive Globals.dataDir += "\\"; Globals.databaseName = "default"; //Check for different database setting if (File.Exists(Globals.dataDir + "databaseSetting")) { string[] databaseName = File.ReadAllLines(Globals.dataDir + "databaseSetting"); if (databaseName.Length == 1)//Ensure database file is somewhat correct { string databaseString = databaseName[0]; if (Directory.Exists(Globals.dataDir + databaseString)) { Globals.databaseName = databaseString; } } } //Add final '\' to path Globals.databaseName += "\\"; //Ensure a directory exists if (!Directory.Exists(Globals.dataDir + Globals.databaseName)) { //Display message saying database is corrupt //TODO: Display message saying database is corrupt //Ask user to choose new database file //Create new folder if none exist Directory.CreateDirectory(Globals.dataDir + Globals.databaseName); } //Make sure temporary directory doesn't exist if (Directory.Exists(Globals.dataDir + "\\tempDir")) { Directory.Delete(Globals.dataDir + "\\tempDir", true); } //Set up working dir variable Globals.workingDir = Globals.dataDir + Globals.databaseName; //Ensure syllabus folder exists if (!Directory.Exists(Globals.workingDir + "syllabus")) { Directory.CreateDirectory(Globals.workingDir + "syllabus"); } Globals.clList = new ClassList(); Globals.cwList = new ClassworkList(); Globals.gradebook = new GradeList(); //Load databases DatabaseLoad.LoadDatabase();//Load the database if (Globals.cwList == null) { Globals.cwList = new ClassworkList(); } //Set up sidebar Globals.SidebarWidth = 200; SidebarColumn.Width = new GridLength(Globals.SidebarWidth); sidebar = new Sidebar(); SidebarFrame.Navigate(sidebar); //Timer that calls tick every 200ms DispatcherTimer dispatcherTimer = new DispatcherTimer(); dispatcherTimer.Tick += new EventHandler(tick); dispatcherTimer.Interval = new TimeSpan(0, 0, 0, 0, 200); dispatcherTimer.Start(); //Determine what color to paint the buttons //https://stackoverflow.com/a/58528170 var uiSettings = new UISettings(); var accentColor = uiSettings.GetColorValue(UIColorType.Accent); accent = new SolidColorBrush(Color.FromArgb(accentColor.A, accentColor.R, accentColor.G, accentColor.B)); //Check if accent color is dark. If it is, we don't want to use it since it won't be easy to see if (accentColor.R <= 100 && accentColor.G <= 100 && accentColor.B <= 100) { accent = new SolidColorBrush(Color.FromArgb(accentColor.A, 0, 120, 215)); } //Now opens to the Home View HomeView homeView = new HomeView(); Select(Selection.Home); NavigationFrame.Navigate(homeView); DatabaseSave.SaveDatabase(); }
private async void Page_Loaded(object sender, RoutedEventArgs e) { if (App.Discord == null) { return; // im not 100% sure why this gets called on logout but it does so } Analytics.TrackEvent("DiscordPage_Loaded"); try { App.Discord.MessageCreated += Notification_MessageCreated; UpdateTitleBar(); CheckSettingsPane(); _loaded = true; this.FindParent <MainPage>().HideConnectingOverlay(); var service = DiscordNavigationService.GetForCurrentView(); if (_args != null && _args.ChannelId != 0 && App.Discord.TryGetCachedChannel(_args.ChannelId, out var channel)) { Analytics.TrackEvent("DiscordPage_NavigateToSpecifiedChannel"); await service.NavigateAsync(channel); } else { Analytics.TrackEvent("DiscordPage_NavigateToFriendsPage"); Model.IsFriendsSelected = true; SidebarFrame.Navigate(typeof(DMChannelsPage)); MainFrame.Navigate(typeof(FriendsPage)); } if (_args?.ThemeLoadException != null) { Analytics.TrackEvent("DiscordPage_ThemeErrorMessageShown"); var message = App.Discord.CreateMockMessage( $"We had some trouble loading your selected themes, so we disabled them for this launch. For more information, see settings.", App.Discord.CreateMockUser("Unicord", "CORD")); ShowNotification(message); } //var helper = SwipeOpenService.GetForCurrentView(); //helper.AddAdditionalElement(SwipeHelper); var notificationService = BackgroundNotificationService.GetForCurrentView(); await notificationService.StartupAsync(); var possibleConnection = await VoiceConnectionModel.FindExistingConnectionAsync(); if (possibleConnection != null) { (DataContext as DiscordPageModel).VoiceModel = possibleConnection; } await ContactListManager.UpdateContactsListAsync(); } catch (Exception ex) { Logger.LogError(ex); await UIUtilities.ShowErrorDialogAsync("An error has occured.", ex.Message); } }