private void TryDownloading() { if (_haveTried) { return; } _haveTried = true; if (XamlUri != null) { IWebRequestFactory iwrf = Application.Current as IWebRequestFactory; if (iwrf != null) { _loadingToken = CentralStatusManager.Instance.BeginShowEllipsisMessage("Downloading"); var f = iwrf.CreateWebRequestClient(); f.DownloadStringCompleted += OnDownloadStringCompleted; var wr = f.CreateSimpleWebRequest(XamlUri); f.DownloadStringAsync(wr); } else { OnError(); } } }
private CentralStatusManager() { _tokenStack = new List<StatusToken>(); DefaultMessageDisplayTime = DefaultMessageDisplayTimeValue; // For legacy loading scenarios. _singleLegacyStatusToken = new StatusToken(); Push(_singleLegacyStatusToken); }
private CentralStatusManager() { _tokenStack = new List <StatusToken>(); DefaultMessageDisplayTime = DefaultMessageDisplayTimeValue; // For legacy loading scenarios. _singleLegacyStatusToken = new StatusToken(); Push(_singleLegacyStatusToken); }
// Will return true if it did delete and clear the reference, false if // it was already null. public static bool TryComplete(ref StatusToken token) { if (token != null) { token.Complete(); token = null; return(true); } return(false); }
// Will return true if it did delete and clear the reference, false if // it was already null. public static bool TryComplete(ref StatusToken token) { if (token != null) { token.Complete(); token = null; return true; } return false; }
internal void DeleteToken(StatusToken token) { token.IsLoadingChanged -= OnTokenIsLoadingChanged; token.MessageChanged -= OnTokenMessageChanged; lock (_tokenStack) { var res = _tokenStack.Remove(token); #if DEBUG //DebugStack("Removing " + token.GetType().ToString() + " " + res.ToString()); #endif } Recalculate(); }
public StatusToken Push(StatusToken token) { token.IsLoadingChanged += OnTokenIsLoadingChanged; token.MessageChanged += OnTokenMessageChanged; lock (_tokenStack) { _tokenStack.Add(token); #if DEBUG //DebugStack("Adding " + token.GetType().ToString()); #endif } Recalculate(); return(token); }
private void Recalculate() { /*if (_mangoIndicator == null) * { * return; * }*/ bool isLoading = false; string message = null; lock (_tokenStack) { #if DEBUG //DebugStack("Recalculating..."); #endif for (int i = 0; i < _tokenStack.Count; i++) { var token = _tokenStack[i]; if (token != null) { if (token.IsLoading) { isLoading = true; } if (token.Message != null) { message = token.Message; _activeMessageToken = token; } } } _message = message; _loading = isLoading; if (_message == null) { _activeMessageToken = null; } } NotifyValueChanged(); }
private void Recalculate() { /*if (_mangoIndicator == null) { return; }*/ bool isLoading = false; string message = null; lock (_tokenStack) { #if DEBUG //DebugStack("Recalculating..."); #endif for (int i = 0; i < _tokenStack.Count; i++) { var token = _tokenStack[i]; if (token != null) { if (token.IsLoading) { isLoading = true; } if (token.Message != null) { message = token.Message; _activeMessageToken = token; } } } _message = message; _loading = isLoading; if (_message == null) { _activeMessageToken = null; } } NotifyValueChanged(); }
public StatusToken Push(StatusToken token) { token.IsLoadingChanged += OnTokenIsLoadingChanged; token.MessageChanged += OnTokenMessageChanged; lock (_tokenStack) { _tokenStack.Add(token); #if DEBUG //DebugStack("Adding " + token.GetType().ToString()); #endif } Recalculate(); return token; }
public void UpdateOrPin(AppTileSettings.TileSettings tileSettings) { Uri navigationUri = tileSettings.NavigationUri; AppTileSettings.TileSettings knownTileSettings = null; AppTileSettings.Instance.Tiles.TryGetValue(navigationUri, out knownTileSettings); var tile = ShellTile.ActiveTiles.Where( st => st.NavigationUri == navigationUri) .SingleOrDefault(); if (tile != null && knownTileSettings == null) { // This tile needs to be deleted and then re-pinned, it's old. tile.Delete(); tile = null; } // If there isn't an available shell path... Note a potential bug // here, if you want to change an existing pin and the shell path // is set, this code path won't run and the pin won't actually // update. So clear it if you want to really change the front // photo path. For now I am not putting that into the data model // for the settings type. Ick. if (tileSettings.FrontPhoto != null && tileSettings.ShellFrontPhotoPath == null && tileSettings.FrontPhoto.IsAbsoluteUri) { if (tileSettings.FrontPhoto.Scheme == "http" || tileSettings.FrontPhoto.Scheme == "https") { string expectedExtension = null; var asString = tileSettings.FrontPhoto.ToString(); if (asString.Contains(".jpg")) { expectedExtension = ".jpg"; } else if (asString.Contains(".png")) { expectedExtension = ".png"; } StatusToken updateToken = null; // Need to do some work to store it in the local isolated // storage instead. WebClient wc = new WebClient(); wc.OpenReadCompleted += (s, e) => { if (updateToken != null) { StatusToken.TryComplete(ref updateToken); } var tt = tileSettings; if (e != null) { if (e.Error != null) { PriorityQueue.AddUiWorkItem(() => { MessageBox.Show("The network connection was not available to download the image needed to create the tile. Please try again later."); }); return; } else if (e.Result != null) { byte[] bytes = null; using (var stream = e.Result) { bytes = new byte[stream.Length]; stream.Read(bytes, 0, (int)stream.Length); } // GUID for this page. var path = Guid.NewGuid().ToString() + expectedExtension; var store = IsolatedStorageFile.GetUserStoreForApplication(); string file = "Shared\\ShellContent\\" + path; Stream st = null; bool ok = false; try { store.EnsurePath(file); st = store.OpenFile(file, FileMode.Create, FileAccess.Write, FileShare.Read); st.Write(bytes, 0, bytes.Length); st.Flush(); ok = true; } catch (IsolatedStorageException) { Debug.WriteLine("Exception writing file: Name={0}, Length={1}", file, bytes.Length); } catch (ObjectDisposedException) { } finally { if (s != null) { st.Close(); } } if (ok) { Uri isoPath = new Uri("isostore:/Shared/ShellContent/" + path, UriKind.RelativeOrAbsolute); tt.ShellFrontPhotoPath = isoPath; UpdateOrPinForRealz(tile, navigationUri, tt); } } } }; updateToken = CentralStatusManager.Instance.BeginShowEllipsisMessage("Preparing tile graphics"); wc.OpenReadAsync(tileSettings.FrontPhoto); return; } } UpdateOrPinForRealz(tile, navigationUri, tileSettings); }