public void Activate(object parameter, Dictionary <string, object> state) { noBGForThisView = false; index = 0; albumParam = null; artistParam = null; Cover = new BitmapImage(); if (state != null) { if (state.ContainsKey("index")) { index = (int)state["index"]; } } if (parameter != null) { if (parameter.GetType() == typeof(string)) { String[] s = ParamConvert.ToStringArray(parameter as string); if (s.Length >= 2 && s[0].Equals("album")) { albumParam = s[1]; } if (s.Length >= 4 && s[2].Equals("artist")) { artistParam = s[3]; } } } }
public async void PinPlaylist(PlaylistItem p) { //string tileId = p.IsSmart ? AppConstants.TileId + p.Id + "smart": AppConstants.TileId + p.Id + "plain"; int id = ApplicationSettingsHelper.ReadTileIdValue() + 1; string tileId = AppConstants.TileId + id.ToString(); ApplicationSettingsHelper.SaveTileIdValue(id); if (!SecondaryTile.Exists(tileId)) { string displayName = "Next Player"; string tileActivationArguments = ParamConvert.ToString(new string[] { "playlist", p.Id.ToString(), p.IsSmart.ToString() }); Uri square150x150Logo = new Uri("ms-appx:///Assets/AppImages/Logo/Logo.png"); SecondaryTile secondaryTile = new SecondaryTile(tileId, displayName, tileActivationArguments, square150x150Logo, TileSize.Wide310x150); secondaryTile.VisualElements.Wide310x150Logo = new Uri("ms-appx:///Assets/AppImages/WideLogo/WideLogo.png"); secondaryTile.VisualElements.Square71x71Logo = new Uri("ms-appx:///Assets/AppImages/Square71x71Logo/Square71x71LogoTr.png"); ApplicationSettingsHelper.SaveSettingsValue(AppConstants.TileId, tileId); ApplicationSettingsHelper.SaveSettingsValue(AppConstants.TileName, p.Name); ResourceLoader loader = new ResourceLoader(); ApplicationSettingsHelper.SaveSettingsValue(AppConstants.TileType, loader.GetString("Playlist")); App.OnNewTilePinned = UpdateNewSecondaryTile; await secondaryTile.RequestCreateAsync(); } }
/// <summary> /// Populates the page with content passed during navigation. Any saved state is also /// provided when recreating a page from a prior session. /// </summary> /// <param name="sender"> /// The source of the event; typically <see cref="NavigationHelper"/> /// </param> /// <param name="e">Event data that provides both the navigation parameter passed to /// <see cref="Frame.Navigate(Type, Object)"/> when this page was initially requested and /// a dictionary of state preserved by this page during an earlier /// session. The state will be null the first time a page is visited.</param> private void NavigationHelper_LoadState(object sender, LoadStateEventArgs e) { if (e.NavigationParameter != null) { List <PlaylistItem> list = DatabaseManager.SelectPlainPlaylists(); collection = new ObservableCollection <PlaylistItem>(list); DataContext = collection; String[] s = ParamConvert.ToStringArray(e.NavigationParameter as string); if (s[0] == "genre") { genre = s[1]; } else if (s[0] == "folder") { directory = s[2]; } else if (s[0] == "song") { songId = Int32.Parse(s[1]); } else if (s[0] == "artist") { artist = s[1]; } else if (s[0] == "album") { album = s[1]; artist = s[3]; } else if (s[0] == "nowPlaying") { nowPlaying = s[0]; } } }
public static TResult Evals <TResult>(string expressionStr, string name, Expression expression, object data = null) { if (string.IsNullOrEmpty(expressionStr)) { throw new ArgumentNullException(nameof(expressionStr)); } var infos = Analyse(expressionStr); var format = expressionStr; if (infos.Any(i => i.Mode != ParamMode.Param)) { var parser = UtilContainer.Resolve <ParamParser.Interface.IParamRegular>(); format = parser.Regular(format, infos, expression, GLOBAL_STATIC_TYPES); } IPrecompilter precompilter = UtilContainer.Resolve <IPrecompilter>(); if (precompilter.KeyWords.Any()) { format = precompilter.Regular(format); } var excuterCreator = UtilContainer.Resolve <IExcuterCreator>(); var context = excuterCreator.BuildExcuter(); RegisterBasicType(context, expression); return(context.Execute <TResult>(name, format, data, ParamConvert.GetParamInfos(data))); }
public async void Pin(GenreItem genre) { int id = ApplicationSettingsHelper.ReadTileIdValue() + 1; string tileId = AppConstants.TileId + id.ToString(); ApplicationSettingsHelper.SaveTileIdValue(id); string displayName = "Next Player"; string tileActivationArguments = ParamConvert.ToString(new string[] { "genre", genre.GenreParam }); Uri square150x150Logo = new Uri("ms-appx:///Assets/AppImages/Logo/Logo.png"); SecondaryTile secondaryTile = new SecondaryTile(tileId, displayName, tileActivationArguments, square150x150Logo, TileSize.Wide310x150); secondaryTile.VisualElements.Wide310x150Logo = new Uri("ms-appx:///Assets/AppImages/WideLogo/WideLogo.png"); secondaryTile.VisualElements.Square71x71Logo = new Uri("ms-appx:///Assets/AppImages/Square71x71Logo/Square71x71LogoTr.png"); ApplicationSettingsHelper.SaveSettingsValue(AppConstants.TileId, tileId); ApplicationSettingsHelper.SaveSettingsValue(AppConstants.TileName, genre.Genre); ResourceLoader loader = new ResourceLoader(); ApplicationSettingsHelper.SaveSettingsValue(AppConstants.TileType, loader.GetString("Genre")); App.OnNewTilePinned = UpdateNewSecondaryTile; await secondaryTile.RequestCreateAsync(); }
public void Activate(object parameter, Dictionary <string, object> state) { ascending = true; Playlist.Clear(); genre = null; directory = null; folderName = null; isSmart = false; IsNowPlaying = true; IsDeletable = true; id = 0; name = ""; index = 0; if (parameter != null) { if (parameter.GetType() == typeof(string)) { String[] s = ParamConvert.ToStringArray(parameter as string); if (s.Length >= 2 && s[0].Equals("genre")) { genre = s[1]; IsDeletable = false; } else if (s.Length >= 3 && s[0].Equals("folder")) { folderName = s[1]; directory = s[2]; IsDeletable = false; } else { if (s.Length >= 2 && s[0].Equals("smart")) { isSmart = true; IsDeletable = false; } if (s.Length >= 3 && (s[0].Equals("smart") || s[0].Equals("plain"))) { id = Int32.Parse(s[1]); name = s[2]; } } IsNowPlaying = false; } } if (isNowPlaying) { index = ApplicationSettingsHelper.ReadSongIndex(); } if (state != null) { if (state.ContainsKey("index")) { index = (int)state["index"]; } } }
/// <summary> /// Populates the page with content passed during navigation. Any saved state is also /// provided when recreating a page from a prior session. /// </summary> /// <param name="sender"> /// The source of the event; typically <see cref="NavigationHelper"/> /// </param> /// <param name="e">Event data that provides both the navigation parameter passed to /// <see cref="Frame.Navigate(Type, Object)"/> when this page was initially requested and /// a dictionary of state preserved by this page during an earlier /// session. The state will be null the first time a page is visited.</param> private void NavigationHelper_LoadState(object sender, LoadStateEventArgs e) { statusTextBlock.Text = loader.GetString("Connecting") + "..."; webView1.ContentLoading += webView1_ContentLoading; webView1.NavigationStarting += webView1_NavigationStarting; webView1.DOMContentLoaded += webView1_DOMContentLoaded; string[] array = ParamConvert.ToStringArray((string)e.NavigationParameter); artist = array[0]; title = array[1]; songId = Int32.Parse(array[2]); original = true; appBarSave.Visibility = Windows.UI.Xaml.Visibility.Collapsed; LoadLyrics(); }
public void RegisterGlobalVariable(string name, object val) { if (globalVariables.Any(gv => gv.Name == name)) { return; } globalVariables.Add(new ParamInfo { Name = name, Data = val, Type = val.GetType() }); ParamConvert.SetParamTypeName(globalVariables); }
public void Share(PlaylistItem item) { String[] s = new String[3]; s[0] = "playlist"; if (item.IsSmart) { s[1] = "smart"; } else { s[1] = "plain"; } s[2] = item.Id.ToString(); navigationService.NavigateTo(ViewNames.BluetoothShare, ParamConvert.ToString(s)); }
public async void UpdateNewSecondaryTile() { string name = ApplicationSettingsHelper.ReadResetSettingsValue(AppConstants.TileName) as string; string[] s = ParamConvert.ToStringArray(name); string id = ApplicationSettingsHelper.ReadResetSettingsValue(AppConstants.TileId) as string; string type = ApplicationSettingsHelper.ReadResetSettingsValue(AppConstants.TileType) as string; string hasImage = ApplicationSettingsHelper.ReadResetSettingsValue(AppConstants.TileImage) as string; XmlDocument tileXml; //XmlDocument tileXml = TileUpdateManager.GetTemplateContent(TileTemplateType.TileSquare150x150Text02); //string imagePath = "ms-appx:///Assets/AppImages/Logo/Logo.png"; if (hasImage == "no") { tileXml = TileUpdateManager.GetTemplateContent(TileTemplateType.TileSquare150x150Text02); } else { tileXml = TileUpdateManager.GetTemplateContent(TileTemplateType.TileSquare150x150PeekImageAndText02); var tileImageAttributes = tileXml.GetElementsByTagName("image"); tileImageAttributes[0].Attributes.GetNamedItem("src").NodeValue = "ms-appdata:///local/" + id + ".jpg"; //tileImageAttributes[0].Attributes.GetNamedItem("alt").NodeValue = "album cover"; } XmlNodeList tileTextAttributes = tileXml.GetElementsByTagName("text"); tileTextAttributes[0].InnerText = type; tileTextAttributes[1].InnerText = s[0] + "\n" + s[1]; XmlDocument wideTile = TileUpdateManager.GetTemplateContent(TileTemplateType.TileWide310x150Text09); XmlNodeList textAttr = wideTile.GetElementsByTagName("text"); textAttr[0].InnerText = type; textAttr[1].InnerText = s[0] + "\n" + s[1]; IXmlNode node = tileXml.ImportNode(wideTile.GetElementsByTagName("binding").Item(0), true); tileXml.GetElementsByTagName("visual").Item(0).AppendChild(node); TileNotification tileNotification = new TileNotification(tileXml); TileUpdateManager.CreateTileUpdaterForSecondaryTile(id).Update(tileNotification); }
public async void Pin(AlbumItem p) { int id = ApplicationSettingsHelper.ReadTileIdValue() + 1; string tileId = AppConstants.TileId + id.ToString(); ApplicationSettingsHelper.SaveTileIdValue(id); if (!SecondaryTile.Exists(tileId)) { string imageName = await Library.Current.SaveAlbumCover(p.AlbumParam, p.ArtistParam, tileId); string displayName = "Next Player"; string tileActivationArguments = ParamConvert.ToString(new string[] { "album", p.AlbumParam, p.ArtistParam }); Uri square150x150Logo = new Uri("ms-appx:///Assets/AppImages/Logo/Logo.png"); SecondaryTile secondaryTile = new SecondaryTile(tileId, displayName, tileActivationArguments, square150x150Logo, TileSize.Square150x150); secondaryTile.VisualElements.Wide310x150Logo = new Uri("ms-appx:///Assets/AppImages/WideLogo/WideLogo.png"); secondaryTile.VisualElements.Square71x71Logo = new Uri("ms-appx:///Assets/AppImages/Square71x71Logo/Square71x71LogoTr.png"); ApplicationSettingsHelper.SaveSettingsValue(AppConstants.TileId, tileId); ApplicationSettingsHelper.SaveSettingsValue(AppConstants.TileName, ParamConvert.ToString(new string[] { p.Album, p.AlbumArtist })); ResourceLoader loader = new ResourceLoader(); ApplicationSettingsHelper.SaveSettingsValue(AppConstants.TileType, loader.GetString("Album")); if (imageName.Contains(tileId)) { ApplicationSettingsHelper.SaveSettingsValue(AppConstants.TileImage, "yes"); } else { ApplicationSettingsHelper.SaveSettingsValue(AppConstants.TileImage, "no"); } App.OnNewTilePinned = UpdateNewSecondaryTile; await secondaryTile.RequestCreateAsync(); } }
public void Activate(object parameter, Dictionary <string, object> state) { DeviceListVisibility = true; FileListVisibility = false; obexService = null; BtDevice = null; if (parameter != null) { if (parameter.GetType() == typeof(string)) { s = ParamConvert.ToStringArray(parameter as string); } } Start(); BluetoothManager.FailedHandler += BluetoothManager_FailedHandler; BluetoothManager.ChangeProgressHandler += BluetoothManager_ChangeProgressHandler; BluetoothManager.ChangeStatusHandler += BluetoothManager_ChangeStatusHandler; BluetoothManager.RemoveFirstFileHandler += BluetoothManager_RemoveFirstFileHandler; BluetoothManager.SetDevicesListHandler += BluetoothManager_SetDevicesListHandler; BluetoothManager.TransferCompletedHandler += BluetoothManager_TransferCompletedHandler; }
public void Activate(object parameter, Dictionary <string, object> state) { index = 0; if (state != null) { if (state.ContainsKey("index")) { index = (int)state["index"]; } } genre = null; if (parameter != null) { if (parameter.GetType() == typeof(string)) { String[] s = ParamConvert.ToStringArray(parameter as string); if (s[0].Equals("genre")) { genre = s[1]; } } } }
/// <summary> /// Invoked when the application is launched normally by the end user. Other entry points /// will be used when the application is launched to open a specific file, to display /// search results, and so forth. /// </summary> /// <param name="e">Details about the launch request and process.</param> protected override async void OnLaunched(LaunchActivatedEventArgs e) { #if DEBUG if (System.Diagnostics.Debugger.IsAttached) { this.DebugSettings.EnableFrameRateCounter = true; } #endif var statusBar = Windows.UI.ViewManagement.StatusBar.GetForCurrentView(); string theme = ApplicationSettingsHelper.ReadSettingsValue(AppConstants.AppTheme) as string; if (theme.Equals(AppThemeEnum.Dark.ToString())) { statusBar.BackgroundColor = Windows.UI.Colors.Black; statusBar.ForegroundColor = Windows.UI.Colors.White; } else if (theme.Equals(AppThemeEnum.Light.ToString())) { statusBar.BackgroundColor = Windows.UI.Colors.White; statusBar.ForegroundColor = Windows.UI.Colors.Black; } bool isPhoneAccent = (bool)ApplicationSettingsHelper.ReadSettingsValue(AppConstants.IsPhoneAccentSet); try { if (isPhoneAccent) { Windows.UI.Color color = ((SolidColorBrush)Application.Current.Resources["PhoneAccentBrush"]).Color; ((SolidColorBrush)App.Current.Resources["UserAccentBrush"]).Color = color; } else { string hexColor = ApplicationSettingsHelper.ReadSettingsValue(AppConstants.AppAccent) as string; byte a = byte.Parse(hexColor.Substring(1, 2), System.Globalization.NumberStyles.HexNumber); byte r = byte.Parse(hexColor.Substring(3, 2), System.Globalization.NumberStyles.HexNumber); byte g = byte.Parse(hexColor.Substring(5, 2), System.Globalization.NumberStyles.HexNumber); byte b = byte.Parse(hexColor.Substring(7, 2), System.Globalization.NumberStyles.HexNumber); Windows.UI.Color color = Windows.UI.Color.FromArgb(a, r, g, b); ((SolidColorBrush)App.Current.Resources["UserAccentBrush"]).Color = color; } } catch (Exception ex) { DiagnosticHelper.TrackTrace("User accent set" + Environment.NewLine + ex.Message, SeverityLevel.Information); } if ((bool)ApplicationSettingsHelper.ReadSettingsValue(AppConstants.IsBGImageSet)) { Helpers.StyleHelper.EnableBGImage(); } Helpers.StyleHelper.ChangeMainPageButtonsBackground(); Helpers.StyleHelper.ChangeAlbumViewTransparency(); ApplicationSettingsHelper.SaveSettingsValue(AppConstants.AppState, AppConstants.ForegroundAppActive); Frame rootFrame = Window.Current.Content as Frame; bool fromTile = false; if (e.TileId.Contains(AppConstants.TileId)) { string[] s = ParamConvert.ToStringArray(e.Arguments); if (s[0].Equals("album")) { var a = DatabaseManager.GetSongItemsFromAlbum(s[1], s[2]); Library.Current.SetNowPlayingList(a); } else if (s[0].Equals("playlist")) { if (s[2].Equals(true.ToString())) { Library.Current.SetNowPlayingList(DatabaseManager.GetSongItemsFromSmartPlaylist(Int32.Parse(s[1]))); } else { Library.Current.SetNowPlayingList(DatabaseManager.GetSongItemsFromPlainPlaylist(Int32.Parse(s[1]))); } } else if (s[0].Equals("artist")) { Library.Current.SetNowPlayingList(DatabaseManager.GetSongItemsFromArtist(s[1])); } else if (s[0].Equals("genre")) { Library.Current.SetNowPlayingList(DatabaseManager.GetSongItemsFromGenre(s[1])); } else if (s[0].Equals("folder")) { Library.Current.SetNowPlayingList(DatabaseManager.GetSongItemsFromFolder(s[1])); } ApplicationSettingsHelper.SaveSongIndex(0); ApplicationSettingsHelper.SaveSettingsValue(AppConstants.TilePlay, true); rootFrame = null; fromTile = true; } // Do not repeat app initialization when the Window already has content, // just ensure that the window is active if (rootFrame == null) { // Create a Frame to act as the navigation context and navigate to the first page rootFrame = new Frame(); // Associate the frame with a SuspensionManager key. if (fromTile) { SuspensionManager.SessionState.Clear(); } SuspensionManager.RegisterFrame(rootFrame, "AppFrame"); // TODO: change this value to a cache size that is appropriate for your application rootFrame.CacheSize = 1; if (e.PreviousExecutionState == ApplicationExecutionState.Terminated) { // Restore the saved session state only when appropriate. if (!fromTile) { try { //Logger.Save("resumed terminate app"); //Logger.SaveToFile(); ApplicationSettingsHelper.SaveSettingsValue(AppConstants.ResumePlayback, ""); await SuspensionManager.RestoreAsync(); } catch (SuspensionManagerException ex) { // Something went wrong restoring state. // Assume there is no state and continue. Logger.Save("App OnLaunched() SuspensionManagerException" + "\n" + ex.Message); Logger.SaveToFileBG(); } } } // Place the frame in the current Window Window.Current.Content = rootFrame; } if (rootFrame.Content == null) { // Removes the turnstile navigation for startup. if (rootFrame.ContentTransitions != null) { this.transitions = new TransitionCollection(); foreach (var c in rootFrame.ContentTransitions) { this.transitions.Add(c); } } rootFrame.ContentTransitions = null; rootFrame.Navigated += this.RootFrame_FirstNavigated; // When the navigation stack isn't restored navigate to the first page, // configuring the new page by passing required information as a navigation // parameter if (!rootFrame.Navigate(typeof(View.MainPage), e.Arguments)) { throw new Exception("Failed to create initial page"); } } //rootFrame.Background = (ImageBrush)Resources["BgImage"]; // Ensure the current window is active Window.Current.Activate(); //SetDimensions(); DispatcherHelper.Initialize(); await HockeyClient.Current.SendCrashesAsync(true); }