private void FileFolderLogic(string text, Action <string> editLogic, TextBlock errorTbl, bool lookingAtFolder, bool needsToBeExe = false) { if (text.Length == 0) { editLogic(text); errorTbl.Visibility = Visibility.Collapsed; MasterCustomPage.SaveProfiles(); return; } if (needsToBeExe || !lookingAtFolder && File.Exists(text) || lookingAtFolder && Directory.Exists(text)) { if (needsToBeExe && text.Split('.').Last() != "exe") { errorTbl.Visibility = Visibility.Visible; } else { if (needsToBeExe) { text = text.Remove(0, text.LastIndexOf("\\") + 1); } editLogic(text); errorTbl.Visibility = Visibility.Collapsed; MasterCustomPage.SaveProfiles(); } } else { errorTbl.Visibility = Visibility.Visible; } }
private void TimespanLogic(string time, Action <TimeSpan> editLogic, TextBlock errorTbl) { if (MasterCustomPage.CurrentButton == null) { return; } if (time.Length == 0) { editLogic(TimeSpan.Zero); errorTbl.Visibility = Visibility.Collapsed; MasterCustomPage.SaveProfiles(); return; } if (TimeSpan.TryParseExact(time, "h\\:mm\\:ss", new NumberFormatInfo(), out var span)) { editLogic(span); errorTbl.Visibility = Visibility.Collapsed; MasterCustomPage.SaveProfiles(); } else { errorTbl.Visibility = Visibility.Visible; } }
private void DayButton_OnClick(object sender, RoutedEventArgs e) { if (((Button)sender).Background == App.Current.Resources["AccentColour1SCBrush"]) { MasterCustomPage.Profiles[MasterCustomPage.CurrentButton.Content.ToString()].Triggers.Time.Days.Add((DayOfWeek)((Button)sender).Tag); ((Button)sender).SetResourceReference(ButtonBase.BackgroundProperty, "AccentColour2SCBrush"); } else { MasterCustomPage.Profiles[MasterCustomPage.CurrentButton.Content.ToString()].Triggers.Time.Days.Remove((DayOfWeek)((Button)sender).Tag); ((Button)sender).SetResourceReference(ButtonBase.BackgroundProperty, "AccentColour1SCBrush"); } MasterCustomPage.SaveProfiles(); }
private Task UpdateProfile(string profileName, string text1, string text2, string largeKey, string largeText, string smallKey, string smallText, string clientID, bool showTime) { var oldProfile = MasterCustomPage.Profiles[profileName]; MasterCustomPage.Profiles[profileName] = new CustomProfile { LargeKey = largeKey, Text1 = text1, Text2 = text2, LargeText = largeText, SmallKey = smallKey, SmallText = smallText, ShowTime = showTime, ClientID = clientID, Name = profileName, Triggers = oldProfile.Triggers }; MasterCustomPage.SaveProfiles(); return(Task.CompletedTask); }
private Task UpdateProfile(string profileName, string text1 = null, string text2 = null, string largeKey = null, string largeText = null, string smallKey = null, string smallText = null, string clientID = null, bool?showTime = null) { if (!IsLoaded) { return(Task.CompletedTask); } var profile = MasterCustomPage.Profiles[profileName]; profile.LargeKey = largeKey ?? profile.LargeKey; profile.Text1 = text1 ?? profile.Text1; profile.Text2 = text2 ?? profile.Text2; profile.LargeText = largeText ?? profile.LargeText; profile.SmallKey = smallKey ?? profile.SmallKey; profile.SmallText = smallText ?? profile.SmallText; profile.ShowTime = showTime ?? profile.ShowTime; profile.ClientID = clientID ?? profile.ClientID; MasterCustomPage.SaveProfiles(); return(Task.CompletedTask); }