public BreadCrumbItem(App.Apps TargetPage, App.NavigationStates NavState, string BreadCrumbName, int Position, bool IsLast = false) { this.InitializeComponent(); this._isLast = IsLast; this._targetPage = TargetPage; this._navState = NavState; this.TextBlock.Text = BreadCrumbName; // if we need to use the logo image if (this._targetPage == App.Apps.MainPage || Position == 0) { RootGrid.Margin = new Thickness(-40, 0, 0, 0); this.BaseAppBar.Fill = Helpers.GetSnappedBrush(App.Apps.MainPage); this.BaseAppBar.Visibility = Windows.UI.Xaml.Visibility.Visible; this.InnerAppBar.Visibility = Windows.UI.Xaml.Visibility.Collapsed; this.Image.Source = Helpers.GetSnappedImage(Helpers.selectImage(App.Apps.MainPage)); } else { RootGrid.Margin = new Thickness(-40, 0, 0, 0); this.InnerAppBar.Fill = Helpers.GetSnappedBrush(this._targetPage); this.BaseAppBar.Visibility = Windows.UI.Xaml.Visibility.Collapsed; this.InnerAppBar.Visibility = Windows.UI.Xaml.Visibility.Visible; this.Image.Source = Helpers.GetSnappedImage(Helpers.selectImage(this._targetPage)); } }
private static string GetAppName(App.Apps app) { switch (app) { case App.Apps.Notepad: return("Notepad"); case App.Apps.Calculator: return("Calculator"); case App.Apps.UnitConverter: return("Converter"); case App.Apps.PCalendar: return("P.Calendar"); case App.Apps.MainPage: return("Gizmo"); case App.Apps.ToDo: return("ToDo List"); default: return(string.Empty); } }
private void MainScape_RightTapped(object o, RightTappedEventArgs e) { if (RightPanel != null) { // capture the app thats been selected into the global selectedAppObject = e.appObject; // create the button pinToAppBar = new Button(); // check if the app is already pinned then change the button based on that information ToggleAppBarButton(!SecondaryTile.Exists(selectedAppObject.ToString())); // add the event handler for click pinToAppBar.Click += new RoutedEventHandler(pinToAppBar_Click); // clear all the childredn first RightPanel.Children.Clear(); // add the button to the app bar RightPanel.Children.Add(pinToAppBar); SecondaryTileAppBar.IsOpen = true; } }
private void TextBlock_PointerReleased(object sender, PointerRoutedEventArgs e) { App.Apps currentApp = (Application.Current as App).CurrentApp; switch (currentApp) { case App.Apps.Notepad: Utilities.Common.ShowHelp.ShowHelpMessage(App.Apps.Notepad, true); break; case App.Apps.Calculator: case App.Apps.Programmer: case App.Apps.Scientific: case App.Apps.Statistics: Utilities.Common.ShowHelp.ShowHelpMessage(App.Apps.Calculator, true); break; case App.Apps.UnitConverter: case App.Apps.Area: case App.Apps.Distance: case App.Apps.Mass: case App.Apps.Speed: case App.Apps.Volume: case App.Apps.Stopwatch: case App.Apps.Timer: case App.Apps.Acceleration: case App.Apps.Angles: case App.Apps.Cooking: case App.Apps.Density: case App.Apps.Current: case App.Apps.Energy: case App.Apps.Flow: case App.Apps.Force: case App.Apps.Frequency: case App.Apps.Light: case App.Apps.Power: case App.Apps.Pressure: case App.Apps.Torque: case App.Apps.Viscosity: Utilities.Common.ShowHelp.ShowHelpMessage(App.Apps.UnitConverter, true); break; case App.Apps.PCalendar: Utilities.Common.ShowHelp.ShowHelpMessage(App.Apps.PCalendar, true); break; case App.Apps.ToDo: Utilities.Common.ShowHelp.ShowHelpMessage(App.Apps.ToDo, true); break; case App.Apps.MainPage: Utilities.Common.ShowHelp.ShowHelpMessage(App.Apps.MainPage, true); break; default: break; } // show help }
/// <summary> /// Saves data into the Windows.Storage.ApplicaitonDataContainer object with the App.Apps enum /// as the key. Note: this will fail if the state to be saved is larger than 8k /// </summary> /// <param name="app">The calling app's identity</param> /// <param name="key">A unique key for the type of memory being saved, handy if the app saves more than one type of state</param> /// <param name="value">The object which represents the state to be serialized and saved into roaming state</param> /// <returns>True if the save was successfull, false otherwise</returns> public static bool SaveRoamingState(App.Apps app, string key, object value) { // Because there are many "calc" views but we want the memory to be preserved in between // all of the views if (Calc_MainPage.IsCalculator(app)) { app = App.Apps.Calculator; } try { Windows.Storage.ApplicationDataContainer roamingSettings = Windows.Storage.ApplicationData.Current.RoamingSettings; string serialized = string.Empty; List <object> memoryItemsObj = new List <object>(); // Calc specific if (value is ObservableCollection <Calculator.MemoryItem> ) { foreach (Calculator.MemoryItem memItem in value as ObservableCollection <Calculator.MemoryItem> ) { memoryItemsObj.Add(memItem as object); } } else if (value is List <PCalender.Period> ) { foreach (PCalender.Period period in value as List <PCalender.Period> ) { memoryItemsObj.Add(period as object); } } // TODO other apps serialized = JSONCode.JSON.JsonEncode(memoryItemsObj); // add the value into the roaming state array if (roamingSettings.Values.ContainsKey(app.ToString() + key)) { roamingSettings.Values[app.ToString() + key] = serialized; } else { roamingSettings.Values.Add(app.ToString() + key, serialized); } } catch { return(false); } return(true); }
/// <summary> /// /// </summary> /// <param name="TitleText">The string to show on the breadcrumb bar</param> /// <param name="TargetPage">The App.Apps page to navigate to if this item is clicked. Should be App.Apps.NoPage if this is the last page in the breadcrumb series.</param> public Breadcrumb(App.Apps TargetPage, bool IsLast = false, string Title = "") { if (Title == string.Empty) { this.TitleText = Helpers.GetAppName(TargetPage); } else { this.TitleText = Title; } this.TargetPage = TargetPage; this.IsLast = IsLast; }
/// <summary> /// Clears the roaming state of a given application /// </summary> /// <param name="app">The calling app's identity</param> /// <returns>True if the clear was successfull, false otherwise</returns> public static bool ClearRoamingState(App.Apps app, string key) { try { Windows.Storage.ApplicationDataContainer roamingSettings = Windows.Storage.ApplicationData.Current.RoamingSettings; if (roamingSettings.Values.ContainsKey(app.ToString() + key)) { roamingSettings.Values.Remove(app.ToString() + key); } } catch { return(false); } return(true); }
private static string GetContent(App.Apps app) { switch (app) { case App.Apps.Notepad: return(@"1. Once you've made some changes, your most recently edited files will be shown 2. You can navigate between your recent files just by clicking on them, give it a try"); case App.Apps.Calculator: return(@"1. Calculator has 3 different views (Scientific, Programmer & Statistics) 2. You can change the 'mode' (e.g. Deg/Rad or Hex/Dec/Oct/Bin) by tapping on the value 3. Swipe from the bottom or right click to see values saved in memory. These are saved across views and your PCs"); case App.Apps.UnitConverter: return(@"1. Type in any value to convert the selected unit to all target units 2. You can change the selected unit by clicking on it and either typing or selecting a new one 3. You can change the target units by adjusting the Filter at the bottom of the screen, or by typing in a specific unit, give it a try! 4. The results are color-coded by their set. For example, you can quickly see which results are metric 5. Many more conversions are on the way!"); case App.Apps.PCalendar: return(@"1. Swipe from the bottom or right click to add or edit periods 2. Swipe or click the arrows to move between months 3. All of your period information is saved across all of your PCs"); case App.Apps.ToDo: return(@"1. Add new tasks and categories using the Add Task button. 2. Click any task to edit it. Your changes will be automaticlly saved. 3. Once you complete a task, check it off the list using the box to the left. Don't forget, you can switch views at any time by using the Date and Category buttons in the upper right."); case App.Apps.MainPage: return(@"These help dialogs will appear once for each Gizmo and give you tips on how to best use them! 1. You can pin any Gizmo to your start screen by right clicking on it 2. Every Gizmo functions while snapped, give it a try 3. Like the app? Give us a review! 4. Found a problem or want to give feedback? Use the Settings charm to report a bug or send mail to '*****@*****.**' More gizmos are on the way! The Gizmo Team"); default: return(string.Empty); } }
public MainPageItem(App.Apps app) { this.Title = Helpers.GetAppName(app); this.TitleColor = Helpers.GetBrush(Helpers.Colors.White); string imageFileName = Helpers.selectImage(app); this.ImageFile = Helpers.GetMainImage(imageFileName); this.SnappedImageFile = Helpers.GetSnappedImage(imageFileName); this.BackgroundColor = Helpers.GetSnappedBrush(app); this.App = app; if (this.App == Utilities.App.Apps.NoPage) { this._CommingSoon = true; } }
public static async void ShowHelpMessage(App.Apps app, bool ForceMessage = false) { // check if this app has already showed help if (StateManager.RoamingStateExists(app, StateManager.HELP_TEXT) && !ForceMessage) { return; } // if not show the message await new Windows.UI.Popups.MessageDialog(GetContent(app), "Welcome to " + GetAppName(app) + ", let's get you started!").ShowAsync(); // finally add it's state so it doesn't get to show again if (!StateManager.RoamingStateExists(app, StateManager.HELP_TEXT)) { StateManager.SaveRoamingState(app, StateManager.HELP_TEXT, string.Empty); } }
/// <summary> /// Saves data into the Windows.Storage.ApplicaitonDataContainer object with the App.Apps enum /// as the key. Note: this will fail if the state to be saved is larger than 8k /// </summary> /// <param name="app">The calling app's identity</param> /// <param name="state">The object which represents the state to be serialized and saved into roaming state</param> /// <returns>True if the save was successfull, false otherwise</returns> public static bool SaveRoamingState(App.Apps app, string key, string value) { try { Windows.Storage.ApplicationDataContainer roamingSettings = Windows.Storage.ApplicationData.Current.RoamingSettings; // add the value into the roaming state array if (roamingSettings.Values.ContainsKey(app.ToString() + key)) { roamingSettings.Values[app.ToString() + key] = value; } else { roamingSettings.Values.Add(app.ToString() + key, value); } } catch { return(false); } return(true); }
/// <summary> /// Deserializes the input string into a c# generic object /// </summary> /// <param name="app">The calling app's identity</param> /// <param name="success">True if the clear was successfull, false otherwise</param> /// <returns>The deserialized generic object. If the method fails the return is null</returns> public static object LoadRoamingState(App.Apps app, string key, ref bool success, Calc_MainPage page = null) { success = false; try { Windows.Storage.ApplicationDataContainer roamingSettings = Windows.Storage.ApplicationData.Current.RoamingSettings; string serialized = roamingSettings.Values[app.ToString() + key] as string; if (serialized.StartsWith("{") || serialized.StartsWith("[")) { object obj = JSONCode.JSON.JsonDecode(serialized, ref success); // Calculator specific if (app == App.Apps.Calculator) { return(ConvertToCalc(obj, ref success, page)); } // PCalendar specific else if (app == App.Apps.PCalendar) { return(ConvertToPCal(obj, ref success)); } // TODO other apps } else { return(serialized); } } catch { return(null); } return(null); }
public static string selectImage(App.Apps app, bool SmallTileRequested = false) { //All apps should be added here to appear on the main page. string suffix = ".png"; if (SmallTileRequested) { suffix = ".png"; } switch (app) { // Notepad case App.Apps.Notepad: return("Notepad" + suffix); // Calc case App.Apps.Calculator: return("Calculator" + suffix); case App.Apps.Scientific: return("Scientific.png"); case App.Apps.Programmer: return("Programmer.png"); case App.Apps.Statistics: return("Statistics.png"); // Todo case App.Apps.ToDo: return("ToDo.png"); // misc case App.Apps.Stopwatch: return("StopWatch.png"); case App.Apps.Timer: return("Timer.png"); // Pcal case App.Apps.PCalendar: return("PCalendar" + suffix); // Unit converter case App.Apps.UnitConverter: return("UnitConverter" + suffix); case App.Apps.Area: return("Area.png"); case App.Apps.Distance: return("Distance.png"); case App.Apps.Mass: return("Mass.png"); case App.Apps.Speed: return("Speed.png"); case App.Apps.Volume: return("Volume.png"); case App.Apps.Acceleration: return("Acceleration.png"); case App.Apps.Angles: return("Angles.png"); case App.Apps.Cooking: return("Cooking.png"); case App.Apps.Density: return("Density.png"); case App.Apps.Current: return("Current.png"); case App.Apps.Energy: return("Energy.png"); case App.Apps.Flow: return("Flow.png"); case App.Apps.Force: return("Force.png"); case App.Apps.Frequency: return("Frequency.png"); case App.Apps.Light: return("Light.png"); case App.Apps.Power: return("Power.png"); case App.Apps.Pressure: return("Pressure.png"); case App.Apps.Torque: return("Torque.png"); case App.Apps.Viscosity: return("Viscosity.png"); // Main Page case App.Apps.MainPage: return("Gizmo" + suffix); // this should never get called default: return(string.Empty); } }
public static object NavigateToPage(App.Apps app, NavigationStates navState = NavigationStates.Normal) { Windows.Graphics.Display.DisplayInformation.AutoRotationPreferences = Windows.Graphics.Display.DisplayOrientations.Landscape | Windows.Graphics.Display.DisplayOrientations.LandscapeFlipped | Windows.Graphics.Display.DisplayOrientations.Portrait | Windows.Graphics.Display.DisplayOrientations.PortraitFlipped; App curApp = Application.Current as App; string searchArgs = curApp.SearchArguments; curApp.lastNavState = navState; //check the navigation type for share/search/normal Frame rootFrame; bool newFrame = false; try { rootFrame = (curApp.CurrentPage as Page).Frame; if (rootFrame == null) { throw new Exception(); //passes it to the catch block which initializes the frame } } catch { rootFrame = new Frame(); newFrame = true; } Calculator.Calc_MainPage calcPageMain; Utilities.Apps.UnitConverter.UnitConverter uc; switch (app) { case Apps.MainPage: rootFrame.Navigate(typeof(MainPage)); MainPage mainPage = rootFrame.Content as MainPage; mainPage.SetNavigationState(navState); break; case App.Apps.Calculator: if (navState == NavigationStates.Search) { rootFrame.Navigate(typeof(Calculator.Calc_MainPage)); calcPageMain = rootFrame.Content as Calculator.Calc_MainPage; calcPageMain.Initialize(Apps.Scientific); //Do any work to set up Search on Calculator here calcPageMain.insertToWindow(searchArgs); PrevCalcSearch = true; } else if (PrevCalcSearch == true) { PrevCalcSearch = false; } else { rootFrame.Navigate(typeof(Calculator.Calc_LandingPage)); Calculator.Calc_LandingPage calcPageLand = rootFrame.Content as Calculator.Calc_LandingPage; } break; case App.Apps.Scientific: rootFrame.Navigate(typeof(Calculator.Calc_MainPage)); calcPageMain = rootFrame.Content as Calculator.Calc_MainPage; calcPageMain.Initialize(Apps.Scientific); break; case App.Apps.Programmer: rootFrame.Navigate(typeof(Calculator.Calc_MainPage)); calcPageMain = rootFrame.Content as Calculator.Calc_MainPage; calcPageMain.Initialize(Apps.Programmer); break; case App.Apps.Statistics: rootFrame.Navigate(typeof(Calculator.Calc_MainPage)); calcPageMain = rootFrame.Content as Calculator.Calc_MainPage; calcPageMain.Initialize(Apps.Statistics); break; case App.Apps.Notepad: rootFrame.Navigate(typeof(Notepad.Notepad_MainPage)); Notepad.Notepad_MainPage notepadPage = rootFrame.Content as Notepad.Notepad_MainPage; if (navState != NavigationStates.Share) { notepadPage.recentFilesTimer.Start(); } else { notepadPage.displaySharingText(curApp.ShareArguments); } break; //case App.Apps.ToDo: // rootFrame.Navigate(typeof(Utilities.Apps.ToDo.ToDo_MainPage)); // break; case App.Apps.PCalendar: rootFrame.Navigate(typeof(PCalender.PCal_MainPage)); //PCalender.PCal_MainPage pCalPage = rootFrame.Content as PCalender.PCal_MainPage; break; case App.Apps.UnitConverter: rootFrame.Navigate(typeof(Utilities.Apps.UnitConverter.UnitConverter_LandingPage)); break; //case App.Apps.Stopwatch: // rootFrame.Navigate(typeof(Utilities.Apps.Stopwatch.Stopwatch_MainPage)); // break; //case App.Apps.Timer: // rootFrame.Navigate(typeof(Utilities.Apps.Timer.Timer_MainPage)); // break; case App.Apps.Area: rootFrame.Navigate(typeof(Utilities.Apps.UnitConverter.UnitConverter)); uc = rootFrame.Content as Utilities.Apps.UnitConverter.UnitConverter; uc.Init(Utilities.Apps.UnitConverter.UnitConverter.ConversionTypes.area, "Area", Apps.Area); break; case Apps.Distance: rootFrame.Navigate(typeof(Utilities.Apps.UnitConverter.UnitConverter)); uc = rootFrame.Content as Utilities.Apps.UnitConverter.UnitConverter; uc.Init(Utilities.Apps.UnitConverter.UnitConverter.ConversionTypes.distance, "Distance", Apps.Distance); break; case Apps.Mass: rootFrame.Navigate(typeof(Utilities.Apps.UnitConverter.UnitConverter)); uc = rootFrame.Content as Utilities.Apps.UnitConverter.UnitConverter; uc.Init(Utilities.Apps.UnitConverter.UnitConverter.ConversionTypes.mass, "Mass", Apps.Mass); break; case Apps.Speed: rootFrame.Navigate(typeof(Utilities.Apps.UnitConverter.UnitConverter)); uc = rootFrame.Content as Utilities.Apps.UnitConverter.UnitConverter; uc.Init(Utilities.Apps.UnitConverter.UnitConverter.ConversionTypes.speed, "Speed", Apps.Speed); break; case Apps.Volume: rootFrame.Navigate(typeof(Utilities.Apps.UnitConverter.UnitConverter)); uc = rootFrame.Content as Utilities.Apps.UnitConverter.UnitConverter; uc.Init(Utilities.Apps.UnitConverter.UnitConverter.ConversionTypes.volume, "Volume", Apps.Volume); break; case Apps.Acceleration: rootFrame.Navigate(typeof(Utilities.Apps.UnitConverter.UnitConverter)); uc = rootFrame.Content as Utilities.Apps.UnitConverter.UnitConverter; uc.Init(Utilities.Apps.UnitConverter.UnitConverter.ConversionTypes.acceleration, "Acceleration", Apps.Acceleration); break; case Apps.Angles: rootFrame.Navigate(typeof(Utilities.Apps.UnitConverter.UnitConverter)); uc = rootFrame.Content as Utilities.Apps.UnitConverter.UnitConverter; uc.Init(Utilities.Apps.UnitConverter.UnitConverter.ConversionTypes.angles, "Angles", Apps.Angles); break; case Apps.Current: rootFrame.Navigate(typeof(Utilities.Apps.UnitConverter.UnitConverter)); uc = rootFrame.Content as Utilities.Apps.UnitConverter.UnitConverter; uc.Init(Utilities.Apps.UnitConverter.UnitConverter.ConversionTypes.current, "Current", Apps.Current); break; //case Apps.About: // rootFrame.Navigate(typeof(Utilities.Apps._About.AboutPage)); // break; default: break; } if (newFrame) { Window.Current.Content = rootFrame; Window.Current.Activate(); } // remember the current app ((App)Application.Current).CurrentApp = app; // static variable that holds the current page ((App)Application.Current).CurrentPage = rootFrame.Content; return(((App)Application.Current).CurrentPage); }
/// <summary> /// Determines if the roaming state manager has the selected value saved /// </summary> /// <param name="app">The calling app's identity</param> /// <param name="key">The key for the settings</param> /// <returns></returns> public static bool RoamingStateExists(App.Apps app, string key) { Windows.Storage.ApplicationDataContainer roamingSettings = Windows.Storage.ApplicationData.Current.RoamingSettings; return(roamingSettings.Values.ContainsKey(app.ToString() + key)); }
public RightTappedEventArgs(App.Apps AppObject) { appObject = AppObject; }
public static string GetAppName(App.Apps app) { switch (app) { // Notepad case App.Apps.Notepad: return("Notepad"); // Calc case App.Apps.Calculator: return("Calculator"); case App.Apps.Scientific: return("Scientific"); case App.Apps.Programmer: return("Programmer"); case App.Apps.Statistics: return("Statistics"); // Todo case App.Apps.ToDo: return("To Do"); // misc case App.Apps.Stopwatch: return("StopWatch"); case App.Apps.Timer: return("Timer"); // Pcal case App.Apps.PCalendar: return("P.Calendar"); // Unit converter case App.Apps.UnitConverter: return("Converter"); case App.Apps.Area: return("Area"); case App.Apps.Distance: return("Distance"); case App.Apps.Mass: return("Mass"); case App.Apps.Speed: return("Speed"); case App.Apps.Volume: return("Volume"); case App.Apps.Acceleration: return("Acceleration"); case App.Apps.Angles: return("Angles"); case App.Apps.Cooking: return("Cooking"); case App.Apps.Density: return("Density"); case App.Apps.Current: return("Current"); case App.Apps.Energy: return("Energy"); case App.Apps.Flow: return("Flow"); case App.Apps.Force: return("Force"); case App.Apps.Frequency: return("Frequency"); case App.Apps.Light: return("Light"); case App.Apps.Power: return("Power"); case App.Apps.Pressure: return("Pressure"); case App.Apps.Torque: return("Torque"); case App.Apps.Viscosity: return("Viscosity"); // Navigation States // Main Page case App.Apps.MainPage: return(App.AppName); // this should never get called default: return(string.Empty); } }
public static SolidColorBrush GetSnappedBrush(App.Apps app) { switch (app) { case App.Apps.MainPage: return(GetBrush(Colors.Gray)); // notepad case App.Apps.Notepad: return(GetBrush(Colors.SnapLightBlue)); // notepad case App.Apps.ToDo: return(GetBrush(Colors.Violet)); // unit converter case App.Apps.UnitConverter: return(GetBrush(Colors.SnapTurquoise)); case App.Apps.Area: return(GetBrush(Colors.SnapLightGreen)); case App.Apps.Distance: return(GetBrush(Colors.SnapPurple)); case App.Apps.Mass: return(GetBrush(Colors.SnapOrange)); case App.Apps.Speed: return(GetBrush(Colors.SnapLightRed)); case App.Apps.Volume: return(GetBrush(Colors.SnapTeal)); case App.Apps.Acceleration: return(GetBrush(Colors.Blue)); case App.Apps.Angles: return(GetBrush(Colors.DarkBlue)); case App.Apps.Current: return(GetBrush(Colors.DarkGreen)); case App.Apps.Cooking: return(GetBrush(Colors.DarkOrange)); case App.Apps.Density: return(GetBrush(Colors.DarkPurple)); case App.Apps.Energy: return(GetBrush(Colors.DarkRed)); case App.Apps.Flow: return(GetBrush(Colors.GreenBlue)); case App.Apps.Force: return(GetBrush(Colors.LightRed)); case App.Apps.Frequency: return(GetBrush(Colors.OrangeRed)); case App.Apps.Light: return(GetBrush(Colors.OrangeYellow)); case App.Apps.Power: return(GetBrush(Colors.Pink)); case App.Apps.Pressure: return(GetBrush(Colors.PrimeRed)); case App.Apps.Torque: return(GetBrush(Colors.SkyBlue)); case App.Apps.Viscosity: return(GetBrush(Colors.Violet)); // calculator case App.Apps.Calculator: return(GetBrush(Colors.Orange)); case App.Apps.Scientific: return(GetBrush(Colors.SnapBlue)); case App.Apps.Programmer: return(GetBrush(Colors.SnapGreen)); case App.Apps.Statistics: return(GetBrush(Colors.SnapRed)); // PCal case App.Apps.PCalendar: return(GetBrush(Colors.SnapPink)); default: return(GetBrush(Colors.None)); } }