Пример #1
0
        /// <summary>
        /// Release the deferral for a type if it is held
        /// </summary>
        /// <param name="type"></param>
        private void ReleaseDeferral(UpdateTypes type)
        {
            lock (this)
            {
                switch (type)
                {
                case UpdateTypes.LockScreen:
                    _lockScreenRefDeferral?.ReleaseRef();
                    _lockScreenRefDeferral = null;
                    break;

                case UpdateTypes.Band:
                    _mBandRefDeferral?.ReleaseRef();
                    _mBandRefDeferral = null;
                    break;

                case UpdateTypes.All:
                    break;

                case UpdateTypes.Desktop:
                    break;

                default:
                    _mDesktopRefDeferral?.ReleaseRef();
                    _mDesktopRefDeferral = null;
                    break;
                }
            }
        }
Пример #2
0
        /// <summary>
        /// Returns the image cache folder for desktop images
        /// </summary>
        /// <returns></returns>
        private async Task <StorageFolder> GetImageCacheFolder(UpdateTypes type)
        {
            switch (type)
            {
            case UpdateTypes.LockScreen:
            {
                return(_mLockScreenImageCacheFolder ?? (_mLockScreenImageCacheFolder =
                                                            await ApplicationData.Current.LocalFolder.CreateFolderAsync(
                                                                CImageLockScreenCacheFolderPath, CreationCollisionOption.OpenIfExists)));
            }

            case UpdateTypes.Band:
            {
                return(_mBandImageCacheFolder ?? (_mBandImageCacheFolder =
                                                      await ApplicationData.Current.LocalFolder.CreateFolderAsync(CImageBandCacheFolderPath,
                                                                                                                  CreationCollisionOption.OpenIfExists)));
            }

            case UpdateTypes.All:
                break;

            case UpdateTypes.Desktop:
                break;

            default:
                throw new ArgumentOutOfRangeException(nameof(type), type, null);
            }

            return(_mDesktopImageCacheFolder ?? (_mDesktopImageCacheFolder =
                                                     await ApplicationData.Current.LocalFolder.CreateFolderAsync(CImageDesktopCacheFolderPath,
                                                                                                                 CreationCollisionOption.OpenIfExists)));
        }
Пример #3
0
        public override void ReadPacket()
        {
            SequenceNumber = ReadUShort();

            // Read the byte flag representing update types and reconstruct it
            var updateTypeFlag = ReadByte();
            // Keep track of value of current bit
            var currentTypeValue = 1;

            for (var i = 0; i < (int)UpdateType.Count; i++)
            {
                // If this bit was set in our flag, we add the type to the list
                if ((updateTypeFlag & currentTypeValue) != 0)
                {
                    UpdateTypes.Add((UpdateType)currentTypeValue);
                }

                // Increase the value of current bit
                currentTypeValue *= 2;
            }

            // Based on the update types, we read the corresponding values
            if (UpdateTypes.Contains(UpdateType.PlayerUpdate))
            {
                // First we read the length of the player update list
                var numPlayerUpdates = ReadByte();

                // Then we read all the values into PlayerUpdate instances
                for (var i = 0; i < numPlayerUpdates; i++)
                {
                    // We create a new instance
                    var playerUpdate = new PlayerUpdate();

                    // Read the information into the new instance
                    ReadPlayerUpdate(playerUpdate);

                    // Add the instance to the list
                    PlayerUpdates.Add(playerUpdate);
                }
            }

            if (UpdateTypes.Contains(UpdateType.EntityUpdate))
            {
                // First we read the length of the entity update list
                var numEntityUpdates = ReadByte();

                // Then we read all the values into the EntityUpdates dictionary
                for (var i = 0; i < numEntityUpdates; i++)
                {
                    // Create a new EntityUpdate instance
                    var entityUpdate = new EntityUpdate();

                    // Read the values into the instance
                    ReadEntityUpdate(entityUpdate);

                    // Add it to the list
                    EntityUpdates.Add(entityUpdate);
                }
            }
        }
Пример #4
0
 public void UpdateScene(UpdateTypes type, UpdateHint hint)
 {
     foreach (WorldObjectCollection objCol in this.worldCollections)
     {
         objCol.UpdateScene(type, hint);
     }
 }
Пример #5
0
        /// <summary>
        /// Rotate a single image type.
        /// </summary>
        /// <param name="type"></param>
        /// <returns></returns>
        private async Task <bool> DoSingleImageRotation(UpdateTypes type)
        {
            // Make sure we should do the update.
            if ((IsLockScreenEnabled && type == UpdateTypes.LockScreen) || (IsDeskopEnabled && type == UpdateTypes.Desktop) || (IsBandWallpaperEnabled && type == UpdateTypes.Band))
            {
                // If the lock screen and desktop are the same subreddit use the same files.
                UpdateTypes fileCacheType = type;
                // If this is a desktop update, and lock is enabled, and they are the same subreddit...
                if (type == UpdateTypes.Desktop && IsLockScreenEnabled && LockScreenSubredditName.Equals(DesktopSubredditName))
                {
                    // If they are all the same use the lock screen cache for the desktop.
                    fileCacheType = UpdateTypes.LockScreen;
                }

                // Get the current files..
                IReadOnlyList <StorageFile> files = await GetCurrentCacheImages(fileCacheType);

                if (files != null && files.Count != 0)
                {
                    int currentIndex = 0;
                    if (type == UpdateTypes.LockScreen)
                    {
                        // Update the index
                        CurrentLockScreenRotationIndex++;
                        if (CurrentLockScreenRotationIndex >= files.Count)
                        {
                            CurrentLockScreenRotationIndex = 0;
                        }
                        currentIndex = CurrentLockScreenRotationIndex;
                    }
                    else if (type == UpdateTypes.Band)
                    {
                        // Update the index
                        CurrentBandRotationIndex++;
                        if (CurrentBandRotationIndex >= files.Count)
                        {
                            CurrentBandRotationIndex = 0;
                        }
                        currentIndex = CurrentBandRotationIndex;
                    }
                    else
                    {
                        // Update the index
                        CurrentDesktopRotationIndex++;
                        if (CurrentDesktopRotationIndex >= files.Count)
                        {
                            CurrentDesktopRotationIndex = 0;
                        }
                        currentIndex = CurrentDesktopRotationIndex;
                    }

                    // Set the image
                    bool wasSuccess = await SetBackgroundImage(type, files[currentIndex]);

                    return(wasSuccess);
                }
            }
            // Return true if we are disabled
            return(true);
        }
Пример #6
0
 public PlayerBuffUpdateRequest(int clientId, int buffId, UpdateTypes updateType, SideEffectExecute buffSEE)
 {
     this.clientId   = clientId;
     this.buffId     = buffId;
     this.updateType = updateType;
     this.buffSEE    = buffSEE;
 }
Пример #7
0
 public void UpdateScene(UpdateTypes type, UpdateHint hint)
 {
     foreach (IWorldObject child in plantList)
     {
         child.UpdateScene(type, hint);
     }
 }
 public void UpdateScene(UpdateTypes type, UpdateHint hint)
 {
     foreach (IWorldObject obj in Children)
     {
         obj.UpdateScene(type, hint);
     }
 }
Пример #9
0
        /// <summary>
        /// This will kick off the process of getting the stories for a subreddit.
        /// </summary>
        /// <param name="name"></param>
        /// <returns></returns>
        private void GetSubredditStories(string name, UpdateTypes type)
        {
            // Create a fake subreddit, the ID needs to be unique
            Subreddit subreddit = new Subreddit()
            {
                Id = DateTime.Now.Ticks.ToString(), DisplayName = name
            };

            // Get the collector for the subreddit
            PostCollector collector = PostCollector.GetCollector(subreddit, m_baconMan);

            // Sub to the collector callback
            if (type == UpdateTypes.LockScreen)
            {
                collector.OnCollectionUpdated    += Collector_OnCollectionUpdatedLockScreen;
                collector.OnCollectorStateChange += Collector_OnCollectorStateChangeLockScreen;
            }
            else if (type == UpdateTypes.Band)
            {
                collector.OnCollectionUpdated    += Collector_OnCollectionUpdatedBand;
                collector.OnCollectorStateChange += Collector_OnCollectorStateChangeBand;
            }
            else
            {
                collector.OnCollectionUpdated    += Collector_OnCollectionUpdatedDesktop;
                collector.OnCollectorStateChange += Collector_OnCollectorStateChangeDesktop;
            }

            // Kick off the update
            collector.Update(true);
        }
Пример #10
0
        public override PacketWriter BuildUpdate(UpdateTypes type = UpdateTypes.UPDATE_PARTIAL, bool self = false)
        {
            PacketWriter packet = CreateObject(false);
            UpdateClass  uc     = new UpdateClass();

            uc.UpdateValue <ulong>(ObjectFields.OBJECT_FIELD_GUID, this.Guid);
            uc.UpdateValue <uint>(ObjectFields.OBJECT_FIELD_TYPE, (uint)this.ObjectType);
            uc.UpdateValue <uint>(ObjectFields.OBJECT_FIELD_ENTRY, this.Entry);
            uc.UpdateValue <float>(ObjectFields.OBJECT_FIELD_SCALE_X, this.Scale);
            uc.UpdateValue <uint>(ObjectFields.OBJECT_FIELD_PADDING, 0);
            uc.UpdateValue <uint>(GameObjectFields.GAMEOBJECT_DISPLAYID, Template.DisplayId);
            uc.UpdateValue <uint>(GameObjectFields.GAMEOBJECT_FLAGS, Template.Flags);
            uc.UpdateValue <uint>(GameObjectFields.GAMEOBJECT_FACTION, Template.Faction);
            uc.UpdateValue <uint>(GameObjectFields.GAMEOBJECT_STATE, (uint)State);

            for (int i = 0; i < 4; i++)
            {
                uc.UpdateValue <float>(GameObjectFields.GAMEOBJECT_ROTATION, Rotation[i], i);
            }

            uc.UpdateValue <float>(GameObjectFields.GAMEOBJECT_POS_X, this.Location.X);
            uc.UpdateValue <float>(GameObjectFields.GAMEOBJECT_POS_Y, this.Location.Y);
            uc.UpdateValue <float>(GameObjectFields.GAMEOBJECT_POS_Z, this.Location.Z);
            uc.UpdateValue <float>(GameObjectFields.GAMEOBJECT_FACING, this.Orientation);
            uc.BuildPacket(ref packet, true);
            return(packet);
        }
Пример #11
0
 /// <summary>
 /// Release the deferral for a type if it is held
 /// </summary>
 /// <param name="type"></param>
 private void ReleaseDeferral(UpdateTypes type)
 {
     lock (this)
     {
         if (type == UpdateTypes.LockScreen)
         {
             if (m_lockScreenRefDeferral != null)
             {
                 m_lockScreenRefDeferral.ReleaseRef();
             }
             m_lockScreenRefDeferral = null;
         }
         else if (type == UpdateTypes.Band)
         {
             if (m_bandRefDeferral != null)
             {
                 m_bandRefDeferral.ReleaseRef();
             }
             m_bandRefDeferral = null;
         }
         else
         {
             if (m_desktopRefDeferral != null)
             {
                 m_desktopRefDeferral.ReleaseRef();
             }
             m_desktopRefDeferral = null;
         }
     }
 }
 public void UpdateScene(UpdateTypes type, UpdateHint hint)
 {
     foreach (IWorldObject child in children)
     {
         child.UpdateScene(type, hint);
     }
     if ((type == UpdateTypes.Markers || type == UpdateTypes.All) && hint == UpdateHint.DisplayMarker)
     {
         if (inScene == app.DisplayMarkerPoints)
         {
             return;
         }
         else
         {
             if (inScene)
             {
                 this.updating = true;
                 this.RemoveFromScene();
                 this.updating = false;
             }
             else
             {
                 this.AddToScene();
             }
         }
     }
     if ((type == UpdateTypes.All || type == UpdateTypes.Markers) && hint == UpdateHint.TerrainUpdate && allowAdjustHeightOffTerrain)
     {
         this.position.y = app.GetTerrainHeight(position.x, position.z) + terrainOffset;
     }
 }
Пример #13
0
        private void SetSize()
        {
            if (this.Owner == null)
            {
                return;
            }

            Thickness oldSize = this.oldThickness;
            Thickness newSize = this.Style.Thickness;

            if (this.Sprite != null)
            {
                Size  screenRes = this.ViewportSize;
                Point pos       = this.Owner.Location;

                PointF oldPos = new Point(pos.X + oldSize.Left, pos.Y + oldSize.Top).ToScreenCoordinates(screenRes);
                PointF newPos = new Point(pos.X + newSize.Left, pos.Y + newSize.Top).ToScreenCoordinates(screenRes);
                this.borderSpritesTopLeftDelta = newPos - oldPos;

                oldPos = new Point(pos.X + oldSize.Right, pos.Y + oldSize.Bottom).ToScreenCoordinates(screenRes);
                newPos = new Point(pos.X + newSize.Right, pos.Y + newSize.Bottom).ToScreenCoordinates(screenRes);
                this.borderSpritesBottomRightDelta = newPos - oldPos;

                this.UpdateType |= UpdateTypes.Size;
            }

            if (this.ThicknessChangedCallback != null)
            {
                this.ThicknessChangedCallback(oldSize, newSize);
            }
        }
Пример #14
0
        /// <summary>
        /// Updates terms / translations by uploading a file.
        /// </summary>
        /// <remarks>No more than one request every 30 seconds.</remarks>
        /// <param name="id">The id of project</param>
        /// <param name="updating">What to update</param>
        /// <param name="stream"></param>
        /// <param name="overwriteTranslations">Set to true if you want to overwrite translations</param>
        /// <param name="syncTerms">Set to true if you want to sync your terms (terms that are not found in the uploaded file will be deleted from project and the new ones added). Ignored if updating = Translations</param>
        /// <param name="language">The language code. Required only if updating is terms_translations or translations.</param>
        /// <returns>Summary of terms and translations that were added or removed.</returns>
        public Task <UploadResponse> Upload(int id, UpdateTypes updating, Stream stream, bool overwriteTranslations = false, bool syncTerms = false, string language = null)
        {
            var typeLookup = new Dictionary <UpdateTypes, string>
            {
                { UpdateTypes.Terms, "terms" },
                {
                    UpdateTypes.TermsAndTranslations,
                    "terms_translations"
                },
                { UpdateTypes.Translations, "translations" }
            };

            var parameters = new Dictionary <string, string>();

            parameters.Add("updating", typeLookup[updating]);
            parameters.Add("id", id.ToString(CultureInfo.InvariantCulture));
            if (overwriteTranslations)
            {
                parameters.Add("overwrite", "1");
            }

            if (syncTerms)
            {
                parameters.Add("sync_terms", "1");
            }

            if (!string.IsNullOrWhiteSpace(language))
            {
                parameters.Add("language", language);
            }

            return(this._apiCaller.Upload <UploadResponse>("/v2/projects/upload", parameters, stream));
        }
Пример #15
0
 /// <summary>
 /// Returns the image cache folder for desktop images
 /// </summary>
 /// <returns></returns>
 private async Task <StorageFolder> GetImageCacheFolder(UpdateTypes type)
 {
     if (type == UpdateTypes.LockScreen)
     {
         if (m_lockScreenImageCacheFolder == null)
         {
             m_lockScreenImageCacheFolder = await ApplicationData.Current.LocalFolder.CreateFolderAsync(c_imageLockScreenCacheFolderPath, CreationCollisionOption.OpenIfExists);
         }
         return(m_lockScreenImageCacheFolder);
     }
     else if (type == UpdateTypes.Band)
     {
         if (m_bandImageCacheFolder == null)
         {
             m_bandImageCacheFolder = await ApplicationData.Current.LocalFolder.CreateFolderAsync(c_imageBandCacheFolderPath, CreationCollisionOption.OpenIfExists);
         }
         return(m_bandImageCacheFolder);
     }
     else
     {
         if (m_desktopImageCacheFolder == null)
         {
             m_desktopImageCacheFolder = await ApplicationData.Current.LocalFolder.CreateFolderAsync(c_imageDesktopCacheFolderPath, CreationCollisionOption.OpenIfExists);
         }
         return(m_desktopImageCacheFolder);
     }
 }
Пример #16
0
        /// <summary>
        /// Returns the current contents of the cache folder
        /// </summary>
        /// <returns></returns>
        private async Task <bool> SetBackgroundImage(UpdateTypes type, StorageFile file)
        {
            bool wasSuccess = false;

            if (type == UpdateTypes.Band)
            {
                wasSuccess = await m_baconMan.BackgroundMan.BandMan.UpdateBandWallpaper(file);

                // The band can fail quite a lot, if so don't count this as a fail.
                wasSuccess = true;
            }
            // Make sure we can do it
            else if (UserProfilePersonalizationSettings.IsSupported())
            {
                // Try to set the image
                UserProfilePersonalizationSettings profileSettings = UserProfilePersonalizationSettings.Current;
                if (type == UpdateTypes.LockScreen)
                {
                    wasSuccess = await profileSettings.TrySetLockScreenImageAsync(file);
                }
                else
                {
                    wasSuccess = await profileSettings.TrySetWallpaperImageAsync(file);
                }
            }
            return(wasSuccess);
        }
Пример #17
0
        protected virtual void Processing(UpdateTypes updateType)
        {
            if (!active || CurrentState == null)
            {
                return;
            }

            if (Time.time - _lastActionTime > frequencyActions)
            {
                if (updateType == UpdateTypes.Update)
                {
                    CurrentState.ProccessActionsInUpdate();
                }
                else
                {
                    CurrentState.ProccessActionsInFixedUpdate();
                }

                _lastActionTime = Time.time;
            }

            if (Time.time - _lastDecisionTime > frequencyDecision)
            {
                CurrentState.ProcessDecisions();

                _lastDecisionTime = Time.time;
            }
        }
Пример #18
0
 public bool UpsertItem(string itemId, object withPayload, UpdateTypes updateTypes, string source)
 {
     try
     {
         if (updateTypes == UpdateTypes.Unchanged)
         {
             return(true);
         }
         ICoordinatedItemContainer item;
         if (!Repository.TryGetValue(itemId, out item))
         {
             item = new CoordiantionItemContainer {
                 Sources = new Dictionary <string, object>()
             };
             Repository.Add(itemId, item);
         }
         object data;
         if (item.Sources.TryGetValue(source, out data))
         {
             item.Sources.Remove(itemId);
         }
         item.Sources.Add(source, withPayload);
         item.LastUpdated = DateTime.UtcNow;
         return(true);
     }
     catch
     {
         return(false);
     }
 }
Пример #19
0
 /// <summary>
 /// Fired when the stories come in for a type
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 private void Collector_OnCollectionUpdated(UpdateTypes type, OnCollectionUpdatedArgs <Post> e)
 {
     if (e.ChangedItems.Count > 0)
     {
         // If we successfully got the post now get the images
         GetImagesFromPosts(e.ChangedItems, type);
     }
 }
Пример #20
0
 /// <summary>
 /// Create a send local list request.
 /// </summary>
 /// <param name="ListVersion">In case of a full update this is the version number of the full list. In case of a differential update it is the version number of the list after the update has been applied.</param>
 /// <param name="UpdateType">The type of update (full or differential).</param>
 /// <param name="LocalAuthorizationList">In case of a full update this contains the list of values that form the new local authorization list. In case of a differential update it contains the changes to be applied to the local authorization list in the charge point. Maximum number of AuthorizationData elements is available in the configuration key: SendLocalListMaxLength.</param>
 public SendLocalListRequest(UInt64 ListVersion,
                             UpdateTypes UpdateType,
                             IEnumerable <AuthorizationData> LocalAuthorizationList = null)
 {
     this.ListVersion            = ListVersion;
     this.UpdateType             = UpdateType;
     this.LocalAuthorizationList = LocalAuthorizationList ?? new AuthorizationData[0];
 }
Пример #21
0
        public void ResetValues()
        {
            UpdateTypes.Clear();

            PlayerUpdate.UpdateTypes.Clear();
            PlayerUpdate.AnimationInfos.Clear();

            EntityUpdates.Clear();
        }
Пример #22
0
 internal void UpdateItem(DiffItem item, UpdateTypes type)
 {
     if (type == UpdateTypes.Delete)
     {
         var list = Items.ToList();
         list.Remove(item);
         Items = list.AsReadOnly();
     }
     ItemUpdated?.Invoke(item, type);
 }
Пример #23
0
        private async Task DeleteAllCacheImages(UpdateTypes type)
        {
            var localFolder = await GetImageCacheFolder(type);

            var files = await localFolder.GetFilesAsync();

            foreach (var file in files)
            {
                await file.DeleteAsync();
            }
        }
Пример #24
0
        /// <summary>
        /// Fired when the collector state changed for the either
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void Collector_OnCollectorStateChange(UpdateTypes type, OnCollectorStateChangeArgs e)
        {
            if (e.State == CollectorState.Error)
            {
                // We had an error. This is the end of the line, kill the deferral
                ReleaseDeferral(type);

                // And try to set isRunning
                UnSetIsRunningIfDone();
            }
        }
Пример #25
0
 public void UpdateScene(UpdateTypes type, UpdateHint hint)
 {
     foreach (IWorldObject child in children)
     {
         child.UpdateScene(type, hint);
     }
     if ((type == UpdateTypes.All || type == UpdateTypes.Object) && hint == UpdateHint.TerrainUpdate && allowAdjustHeightOffTerrain)
     {
         this.location.y = app.GetTerrainHeight(location.x, location.z) + terrainOffset;
     }
 }
Пример #26
0
        private async Task DeleteAllCacheImages(UpdateTypes type)
        {
            StorageFolder localFolder = await GetImageCacheFolder(type);

            IReadOnlyList <StorageFile> files = await localFolder.GetFilesAsync();

            foreach (StorageFile file in files)
            {
                await file.DeleteAsync();
            }
        }
Пример #27
0
        private async Task WriteImageToFile(InMemoryRandomAccessStream stream, UpdateTypes type)
        {
            StorageFolder localFolder = await GetImageCacheFolder(type);

            StorageFile file = await localFolder.CreateFileAsync("cachedImage.jpg", CreationCollisionOption.GenerateUniqueName);

            using (var fileStream = await file.OpenAsync(FileAccessMode.ReadWrite))
            {
                await RandomAccessStream.CopyAndCloseAsync(stream.GetInputStreamAt(0), fileStream.GetOutputStreamAt(0));
            }
        }
Пример #28
0
 public void UpdateScene(UpdateTypes type, UpdateHint hint)
 {
     if ((type == UpdateTypes.PointLight || type == UpdateTypes.All) && hint == UpdateHint.DisplayMarker)
     {
         if (displayObject != null && app.DisplayPointLightMarker)
         {
             return;
         }
         else
         {
             if (displayObject != null)
             {
                 this.RemovePointLightMarker();
             }
             else
             {
                 this.DisplayPointLightMarker();
             }
         }
     }
     if ((type == UpdateTypes.All || type == UpdateTypes.PointLight) && hint == UpdateHint.TerrainUpdate && allowAdjustHeightOffTerrain)
     {
         this.position.y = app.GetTerrainHeight(position.x, position.z) + terrainOffset;
     }
     if ((type == UpdateTypes.All || type == UpdateTypes.PointLight) && hint == UpdateHint.DisplayLight)
     {
         if (pLight.IsVisible && app.DisplayLights)
         {
             return;
         }
         else
         {
             if (pLight.IsVisible)
             {
                 this.RemoveLightFromScene();
             }
             else
             {
                 this.AddLightToScene();
             }
         }
     }
     if (type == UpdateTypes.PointLight && hint == UpdateHint.DisplayPointLightCircles)
     {
         if (this.showCircles && app.DisplayPointLightCircles)
         {
             return;
         }
         else
         {
             UpdateShowCircles();
         }
     }
 }
Пример #29
0
 public void Update(UpdateTypes type)
 {
     if (type == UpdateTypes.AToB)
     {
         ContentsB = ContentsA;
     }
     else if (type == UpdateTypes.BToA)
     {
         ContentsA = ContentsB;
     }
     Parent.UpdateItem(this, type);
 }
Пример #30
0
        public void SetTask(object updateObject, UpdateTypes type)
        {
            if (lastTimer != null)
            {
                lastTimer.Stop();
                lastTimer.Close();
                lastTimer = null;
            }

            taskUpdate?.TrySetResult(new UpdateObject(updateObject, type));
            taskUpdate = null;
        }
Пример #31
0
 public bool UpsertItem(string itemId, object withPayload, UpdateTypes updateTypes, string source)
 {
     try
     {
         if (updateTypes == UpdateTypes.Unchanged)
             return true;
         ICoordinatedItemContainer item;
         if (!Repository.TryGetValue(itemId, out item))
         {
             item = new CoordiantionItemContainer { Sources = new Dictionary<string, object>() };
             Repository.Add(itemId, item);
         }
         object data;
         if (item.Sources.TryGetValue(source, out data))
             item.Sources.Remove(itemId);
         item.Sources.Add(source, withPayload);
         item.LastUpdated = DateTime.UtcNow;
         return true;
     }
     catch
     {
         return false;
     }
 }
 /// <summary>
 /// Fired when the stories come in for a type
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 private void Collector_OnCollectionUpdated(UpdateTypes type, OnCollectionUpdatedArgs<Post> e)
 {
     if(e.ChangedItems.Count > 0)
     {
         // If we successfully got the post now get the images
         GetImagesFromPosts(e.ChangedItems, type);
     }
 }
        /// <summary>
        /// Fired when the collector state changed for the either
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void Collector_OnCollectorStateChange(UpdateTypes type, OnCollectorStateChangeArgs e)
        {
            if(e.State == CollectorState.Error)
            {
                // We had an error. This is the end of the line, kill the deferral
                ReleaseDeferral(type);

                // And try to set isRunning
                UnSetIsRunningIfDone();
            }
        }
 private async Task DeleteAllCacheImages(UpdateTypes type)
 {
     StorageFolder localFolder = await GetImageCacheFolder(type);
     IReadOnlyList<StorageFile> files = await localFolder.GetFilesAsync();
     foreach (StorageFile file in files)
     {
         await file.DeleteAsync();
     }
 }
        /// <summary>
        /// Given a list of post this gets the images and puts them into file cache.
        /// </summary>
        /// <param name="posts"></param>
        /// <param name="isLockScreen"></param>
        /// <returns></returns>
        private async void GetImagesFromPosts(List<Post> posts, UpdateTypes type)
        {
            // First, remove all of the existing images
            try
            {
                await DeleteAllCacheImages(type);
            }
            catch(Exception e)
            {
                m_baconMan.TelemetryMan.ReportUnExpectedEvent(this, "FailedToDeleteCacheImages", e);
            }

            // Setup the vars
            if(type == UpdateTypes.LockScreen)
            {
                m_lockScreenRequestCount = 0;
                m_lockScreenDoneCount = 0;
            }
            else if(type == UpdateTypes.Band)
            {
                m_bandRequestCount = 0;
                m_bandDoneCount = 0;
            }
            else
            {
                m_desktopRequestCount = 0;
                m_desktopDoneCount = 0;
            }

            // Figure out all of the images we need to request.
            List<Tuple<string, string>> imageRequestList = new List<Tuple<string, string>>();
            foreach (Post post in posts)
            {
                string imageUrl = ImageManager.GetImageUrl(post.Url);
                if (!String.IsNullOrWhiteSpace(imageUrl))
                {
                    imageRequestList.Add(new Tuple<string, string>(imageUrl, post.Id));
                }

                if(imageRequestList.Count > c_maxImageCacheCount)
                {
                    break;
                }
            }

            // Now set our request counts before we start requesting. We must do this to ensure
            // the numbers are correct when the request come back.
            if(type == UpdateTypes.LockScreen)
            {
                m_lockScreenRequestCount = imageRequestList.Count;
            }
            else if(type == UpdateTypes.Band)
            {
                m_bandRequestCount = imageRequestList.Count;
            }
            else
            {
                m_desktopRequestCount = imageRequestList.Count;
            }

            // Now make all of the request.
            foreach(Tuple<string, string> request in imageRequestList)
            {
                // Make the request
                ImageManager.ImageManagerRequest imageRequst = new ImageManager.ImageManagerRequest()
                {
                    Url = request.Item1,
                    ImageId = request.Item2,
                    Context = type
                };
                imageRequst.OnRequestComplete += OnRequestComplete;
                m_baconMan.ImageMan.QueueImageRequest(imageRequst);
            }  

            // If we have nothing to request this is the end of the line for this type.
            if(imageRequestList.Count == 0)
            {
                // And kill the deferral
                ReleaseDeferral(type);

                // And set us to stopped.
                UnSetIsRunningIfDone();
            }
        }
 /// <summary>
 /// Returns the image cache folder for desktop images
 /// </summary>
 /// <returns></returns>
 private async Task<StorageFolder> GetImageCacheFolder(UpdateTypes type)
 {
     if(type == UpdateTypes.LockScreen)
     {
         if (m_lockScreenImageCacheFolder == null)
         {
             m_lockScreenImageCacheFolder = await ApplicationData.Current.LocalFolder.CreateFolderAsync(c_imageLockScreenCacheFolderPath, CreationCollisionOption.OpenIfExists);
         }
         return m_lockScreenImageCacheFolder;
     }
     else if(type == UpdateTypes.Band)
     {
         if (m_bandImageCacheFolder == null)
         {
             m_bandImageCacheFolder = await ApplicationData.Current.LocalFolder.CreateFolderAsync(c_imageBandCacheFolderPath, CreationCollisionOption.OpenIfExists);
         }
         return m_bandImageCacheFolder;
     }
     else
     {
         if (m_desktopImageCacheFolder == null)
         {
             m_desktopImageCacheFolder = await ApplicationData.Current.LocalFolder.CreateFolderAsync(c_imageDesktopCacheFolderPath, CreationCollisionOption.OpenIfExists);
         }
         return m_desktopImageCacheFolder;
     }
 }
Пример #37
0
        private static bool ParseValuesUpdateBlock(GenericReader gr, StringBuilder sb, StreamWriter swe, StreamWriter data, ObjectTypes objectTypeId, UpdateTypes updatetype, WoWObject obj)
        {
            sb.AppendLine("=== values_update_block_start ===");

            byte blocks_count = gr.ReadByte(); // count of update blocks (4 bytes for each update block)
            sb.AppendLine("Bit mask blocks count: " + blocks_count);

            int[] updatemask = new int[blocks_count]; // create array of update blocks
            for (int j = 0; j < blocks_count; j++)
                updatemask[j] = gr.ReadInt32(); // populate array of update blocks with data

            Mask = new BitArray(updatemask);

            int reallength = Mask.Count; // bitmask size (bits)

            int bitmask_max_size = 0;
            uint values_end = 0;

            switch (objectTypeId)
            {
                case ObjectTypes.TYPEID_ITEM:
                    bitmask_max_size = 64;
                    values_end = UpdateFieldsLoader.ITEM_END;
                    break;
                case ObjectTypes.TYPEID_CONTAINER:
                    bitmask_max_size = 160;
                    values_end = UpdateFieldsLoader.CONTAINER_END;
                    break;
                case ObjectTypes.TYPEID_UNIT:
                    bitmask_max_size = 256;
                    values_end = UpdateFieldsLoader.UNIT_END;
                    break;
                case ObjectTypes.TYPEID_PLAYER:
                    bitmask_max_size = 1536; // 2.3.2 - 1472
                    values_end = UpdateFieldsLoader.PLAYER_END;
                    break;
                case ObjectTypes.TYPEID_GAMEOBJECT:
                    bitmask_max_size = 32;
                    values_end = UpdateFieldsLoader.GO_END;
                    break;
                case ObjectTypes.TYPEID_DYNAMICOBJECT:
                    bitmask_max_size = 32;
                    values_end = UpdateFieldsLoader.DO_END;
                    break;
                case ObjectTypes.TYPEID_CORPSE:
                    bitmask_max_size = 64;
                    values_end = UpdateFieldsLoader.CORPSE_END;
                    break;
            }

            if (reallength > bitmask_max_size)
            {
                long pos = gr.BaseStream.Position;
                swe.WriteLine("error position {0}", pos.ToString("X2"));

                swe.WriteLine("error while parsing {0} values update block, count {1}", objectTypeId, reallength);
                return false;
            }

            for (int index = 0; index < reallength; index++)
            {
                if (index > values_end)
                    break;

                if (Mask[index])
                {
                    UpdateField uf = new UpdateField();
                    switch (objectTypeId)
                    {
                        case ObjectTypes.TYPEID_ITEM:
                        case ObjectTypes.TYPEID_CONTAINER:
                            uf = UpdateFieldsLoader.item_uf[index];
                            break;
                        case ObjectTypes.TYPEID_UNIT:
                        case ObjectTypes.TYPEID_PLAYER:
                            uf = UpdateFieldsLoader.unit_uf[index];
                            break;
                        case ObjectTypes.TYPEID_GAMEOBJECT:
                            uf = UpdateFieldsLoader.go_uf[index];
                            break;
                        case ObjectTypes.TYPEID_DYNAMICOBJECT:
                            uf = UpdateFieldsLoader.do_uf[index];
                            break;
                        case ObjectTypes.TYPEID_CORPSE:
                            uf = UpdateFieldsLoader.corpse_uf[index];
                            break;
                    }
                    ReadAndDumpField(uf, sb, gr, updatetype, data, obj);
                }
            }

            if ((objectTypeId == ObjectTypes.TYPEID_GAMEOBJECT || objectTypeId == ObjectTypes.TYPEID_UNIT) && (updatetype == UpdateTypes.UPDATETYPE_CREATE_OBJECT || updatetype == UpdateTypes.UPDATETYPE_CREATE_OBJECT2) && obj.IsNew)
                obj.Save();

            sb.AppendLine("=== values_update_block_end ===");
            return true;
        }
 public void UpdateScene(UpdateTypes type, UpdateHint hint)
 {
 }
Пример #39
0
 public void AddUpdateType(UpdateTypes updateType)
 {
     this.updateFlag |= (uint)updateType;
 }
Пример #40
0
        private bool ParseValuesUpdateBlock(GenericReader gr, StringBuilder sb, StreamWriter swe, StreamWriter data, ObjectTypes objectTypeId, UpdateTypes updatetype)
        {
            // may be we can reduce size of code there...

            sb.AppendLine("=== values_update_block_start ===");

            byte blocks_count = gr.ReadByte(); // count of update blocks (4 bytes for each update block)
            sb.AppendLine("Bit mask blocks count: " + blocks_count);

            uint[] updatemask = new uint[blocks_count]; // create array of update blocks
            for (int j = 0; j < blocks_count; j++)
                updatemask[j] = gr.ReadUInt32(); // populate array of update blocks with data

            Mask = (BitArr)updatemask; // convert array of update blocks to bitmask array

            int reallength = Mask.RealLength; // bitmask size (bits)

            // item/container values update block
            if (objectTypeId == ObjectTypes.TYPEID_ITEM || objectTypeId == ObjectTypes.TYPEID_CONTAINER)
            {
                if (reallength > 160) // 5*32, ??
                {
                    long pos = gr.BaseStream.Position;
                    swe.WriteLine("error position " + pos.ToString("X2"));

                    swe.WriteLine("error while parsing ITEM values update block, count " + reallength);
                    return false;
                }

                for (uint index = 0; index < reallength; index++)
                {
                    if (index > UpdateFields.ITEM_END)
                        break;

                    if (Mask[index])
                    {
                        switch (UpdateFields.item_updatefields[index].type)
                        {
                            case 1:
                                sb.AppendLine(UpdateFields.item_updatefields[index].name + " (" + index + "): " + gr.ReadSingle().ToString().Replace(",", "."));
                                break;
                            default:
                                sb.AppendLine(UpdateFields.item_updatefields[index].name + " (" + index + "): " + gr.ReadUInt32());
                                break;
                        }
                    }
                }
            }

            // unit values update block
            if (objectTypeId == ObjectTypes.TYPEID_UNIT)
            {
                if (reallength > 256) // 32*8 (for units bitmask = 8)
                {
                    long pos = gr.BaseStream.Position;
                    swe.WriteLine("error position " + pos.ToString("X2"));

                    swe.WriteLine("error while parsing UNIT values update block, count " + reallength);
                    return false;
                }

                for (uint index = 0; index < reallength; index++)
                {
                    if (index > UpdateFields.UNIT_END)
                        break;

                    if (Mask[index])
                    {
                        switch (UpdateFields.unit_updatefields[index].type)
                        {
                            case 1:
                                string val1 = gr.ReadSingle().ToString().Replace(",", ".");
                                if(updatetype == UpdateTypes.UPDATETYPE_CREATE_OBJECT || updatetype == UpdateTypes.UPDATETYPE_CREATE_OBJECT2)
                                    data.WriteLine(UpdateFields.unit_updatefields[index].name + " (" + index + "): " + val1);
                                sb.AppendLine(UpdateFields.unit_updatefields[index].name + " (" + index + "): " + val1);
                                break;
                            default:
                                uint val2 = gr.ReadUInt32();
                                if (updatetype == UpdateTypes.UPDATETYPE_CREATE_OBJECT || updatetype == UpdateTypes.UPDATETYPE_CREATE_OBJECT2)
                                    data.WriteLine(UpdateFields.unit_updatefields[index].name + " (" + index + "): " + val2);
                                sb.AppendLine(UpdateFields.unit_updatefields[index].name + " (" + index + "): " + val2);
                                break;
                        }
                    }
                }
            }

            // player values update block
            if (objectTypeId == ObjectTypes.TYPEID_PLAYER)
            {
                if (reallength > 1440) // 32*45 (for player bitmask = 45)
                {
                    long pos = gr.BaseStream.Position;
                    swe.WriteLine("error position " + pos.ToString("X2"));

                    swe.WriteLine("error while parsing PLAYER values update block, count " + reallength);
                    return false;
                }

                for (uint index = 0; index < reallength; index++)
                {
                    if (index > UpdateFields.PLAYER_END)
                        break;

                    if (Mask[index])
                    {
                        switch (UpdateFields.unit_updatefields[index].type)
                        {
                            case 1:
                                string val1 = gr.ReadSingle().ToString().Replace(",", ".");
                                sb.AppendLine(UpdateFields.unit_updatefields[index].name + " (" + index + "): " + val1);
                                break;
                            default:
                                uint val2 = gr.ReadUInt32();
                                sb.AppendLine(UpdateFields.unit_updatefields[index].name + " (" + index + "): " + val2);
                                break;
                        }
                    }
                }
            }

            // gameobject values update block
            if (objectTypeId == ObjectTypes.TYPEID_GAMEOBJECT)
            {
                if (reallength > 32) // 1*32
                {
                    long pos = gr.BaseStream.Position;
                    swe.WriteLine("error position " + pos.ToString("X2"));

                    swe.WriteLine("error while parsing GO values update block, count " + reallength);
                    return false;
                }

                for (uint index = 0; index < reallength; index++)
                {
                    if (index > UpdateFields.GO_END)
                        break;

                    if (Mask[index])
                    {
                        switch (UpdateFields.go_updatefields[index].type)
                        {
                            case 1:
                                string val1 = gr.ReadSingle().ToString().Replace(",", ".");
                                if (updatetype == UpdateTypes.UPDATETYPE_CREATE_OBJECT || updatetype == UpdateTypes.UPDATETYPE_CREATE_OBJECT2)
                                    data.WriteLine(UpdateFields.go_updatefields[index].name + " (" + index + "): " + val1);
                                sb.AppendLine(UpdateFields.go_updatefields[index].name + " (" + index + "): " + val1);
                                break;
                            default:
                                uint val2 = gr.ReadUInt32();
                                if (updatetype == UpdateTypes.UPDATETYPE_CREATE_OBJECT || updatetype == UpdateTypes.UPDATETYPE_CREATE_OBJECT2)
                                    data.WriteLine(UpdateFields.go_updatefields[index].name + " (" + index + "): " + val2);
                                sb.AppendLine(UpdateFields.go_updatefields[index].name + " (" + index + "): " + val2);
                                break;
                        }
                    }
                }
            }

            // dynamicobject values update block
            if (objectTypeId == ObjectTypes.TYPEID_DYNAMICOBJECT)
            {
                if (reallength > 32) // 1*32
                {
                    long pos = gr.BaseStream.Position;
                    swe.WriteLine("error position " + pos.ToString("X2"));

                    swe.WriteLine("error while parsing DO values update block, count " + reallength);
                    return false;
                }

                for (uint index = 0; index < reallength; index++)
                {
                    if (index > UpdateFields.DO_END)
                        break;

                    if (Mask[index])
                    {
                        switch (UpdateFields.do_updatefields[index].type)
                        {
                            case 1:
                                sb.AppendLine(UpdateFields.do_updatefields[index].name + " (" + index + "): " + gr.ReadSingle().ToString().Replace(",", "."));
                                break;
                            default:
                                sb.AppendLine(UpdateFields.do_updatefields[index].name + " (" + index + "): " + gr.ReadUInt32());
                                break;
                        }
                    }
                }
            }

            // corpse values update block
            if (objectTypeId == ObjectTypes.TYPEID_CORPSE)
            {
                if (reallength > 64) // 2*32
                {
                    long pos = gr.BaseStream.Position;
                    swe.WriteLine("error position " + pos.ToString("X2"));

                    swe.WriteLine("error while parsing CORPSE values update block, count " + reallength);
                    return false;
                }

                for (uint index = 0; index < reallength; index++)
                {
                    if (index > UpdateFields.CORPSE_END)
                        break;

                    if (Mask[index])
                    {
                        switch (UpdateFields.corpse_updatefields[index].type)
                        {
                            case 1:
                                sb.AppendLine(UpdateFields.corpse_updatefields[index].name + " (" + index + "): " + gr.ReadSingle().ToString().Replace(",", "."));
                                break;
                            default:
                                sb.AppendLine(UpdateFields.corpse_updatefields[index].name + " (" + index + "): " + gr.ReadUInt32());
                                break;
                        }
                    }
                }
            }

            //swe.WriteLine("ok...");
            sb.AppendLine("=== values_update_block_end ===");
            return true;
        }
 public void UpdateScene(UpdateTypes type, UpdateHint hint)
 {
     foreach (IWorldObject child in children)
     {
         child.UpdateScene(type, hint);
     }
     if ((type == UpdateTypes.All || type == UpdateTypes.Object) && hint == UpdateHint.TerrainUpdate && allowAdjustHeightOffTerrain)
     {
         this.location.y = app.GetTerrainHeight(location.x, location.z) + terrainOffset;
     }
 }
 public void UpdateScene(UpdateTypes type, UpdateHint hint)
 {
     if ((type == UpdateTypes.TerrainDecal || type == UpdateTypes.All) && hint == UpdateHint.DisplayDecal)
     {
         if (inScene == app.DisplayTerrainDecals)
         {
             return;
         }
         else
         {
             if (inScene)
             {
                 this.RemoveFromScene();
             }
             else
             {
                 this.AddToScene();
             }
         }
     }
 }
 public void UpdateScene(UpdateTypes type, UpdateHint hint)
 {
     if ((type == UpdateTypes.ParticleEffect || type == UpdateTypes.All) && hint == UpdateHint.Display)
     {
         if (inScene == app.DisplayParticleEffects)
         {
             return;
         }
         else
         {
             if (inScene)
             {
                 this.RemoveFromScene();
             }
             else
             {
                 this.AddToScene();
             }
         }
     }
 }
        /// <summary>
        /// Returns the current contents of the cache folder
        /// </summary>
        /// <returns></returns>
        private async Task<bool> SetBackgroundImage(UpdateTypes type, StorageFile file)
        {
            bool wasSuccess = false;

            if(type == UpdateTypes.Band)
            {
                wasSuccess = await m_baconMan.BackgroundMan.BandMan.UpdateBandWallpaper(file);
                // The band can fail quite a lot, if so don't count this as a fail.
                wasSuccess = true;
            }
            // Make sure we can do it
            else if (UserProfilePersonalizationSettings.IsSupported())
            {
                // Try to set the image
                UserProfilePersonalizationSettings profileSettings = UserProfilePersonalizationSettings.Current;
                if (type == UpdateTypes.LockScreen)
                {
                    wasSuccess = await profileSettings.TrySetLockScreenImageAsync(file);
                }
                else
                {
                    wasSuccess = await profileSettings.TrySetWallpaperImageAsync(file);
                }
            }
            return wasSuccess;
        }
        /// <summary>
        /// This will kick off the process of getting the stories for a subreddit.
        /// </summary>
        /// <param name="name"></param>
        /// <returns></returns>
        private void GetSubredditStories(string name, UpdateTypes type)
        {
            // Create a fake subreddit, the ID needs to be unique
            Subreddit subreddit = new Subreddit() { Id = DateTime.Now.Ticks.ToString(), DisplayName = name };

            // Get the collector for the subreddit
            PostCollector collector = PostCollector.GetCollector(subreddit, m_baconMan);

            // Sub to the collector callback
            if(type == UpdateTypes.LockScreen)
            {
                collector.OnCollectionUpdated += Collector_OnCollectionUpdatedLockScreen;
                collector.OnCollectorStateChange += Collector_OnCollectorStateChangeLockScreen;
            }
            else if(type == UpdateTypes.Band)
            {
                collector.OnCollectionUpdated += Collector_OnCollectionUpdatedBand;
                collector.OnCollectorStateChange += Collector_OnCollectorStateChangeBand;
            }
            else
            {
                collector.OnCollectionUpdated += Collector_OnCollectionUpdatedDesktop;
                collector.OnCollectorStateChange += Collector_OnCollectorStateChangeDesktop;
            }

            // Kick off the update
            collector.Update(true);
        }
Пример #46
0
 public void UpdateScene(UpdateTypes type, UpdateHint hint)
 {
     if ((type == UpdateTypes.Regions || type == UpdateTypes.All) && hint == UpdateHint.DisplayMarker)
     {
         if (inScene == app.DisplayBoundaryMarkers)
         {
             return;
         }
         else
         {
             if (inScene)
             {
                 this.RemoveFromScene();
             }
             else
             {
                 this.AddToScene();
             }
         }
     }
     if ((type == UpdateTypes.Road || type == UpdateTypes.All) && hint == UpdateHint.DisplayMarker)
     {
         if (inScene == app.DisplayRoadMarkers)
         {
             return;
         }
         else
         {
             if (inScene)
             {
                 this.RemoveFromScene();
             }
             else
             {
                 this.AddToScene();
             }
         }
     }
     if ((type == UpdateTypes.All || type == UpdateTypes.Point) && hint == UpdateHint.TerrainUpdate)
     {
         this.position.y = app.GetTerrainHeight(position.x, position.z) + terrainOffset;
     }
 }
Пример #47
0
 public void RemoveUpdateType(UpdateTypes updateType)
 {
     this.updateFlag &= ~(uint)updateType;
 }
        /// <summary>
        /// Rotate a single image type.
        /// </summary>
        /// <param name="type"></param>
        /// <returns></returns>
        private async Task<bool> DoSingleImageRotation(UpdateTypes type)
        {
            // Make sure we should do the update.
            if ((IsLockScreenEnabled && type == UpdateTypes.LockScreen) || (IsDeskopEnabled && type == UpdateTypes.Desktop) || (IsBandWallpaperEnabled && type == UpdateTypes.Band))
            {
                // If the lock screen and desktop are the same subreddit use the same files.
                UpdateTypes fileCacheType = type;    
                // If this is a desktop update, and lock is enabled, and they are the same subreddit...
                if (type == UpdateTypes.Desktop && IsLockScreenEnabled && LockScreenSubredditName.Equals(DesktopSubredditName))
                {
                    // If they are all the same use the lock screen cache for the desktop.
                    fileCacheType = UpdateTypes.LockScreen;
                }

                // Get the current files..
                IReadOnlyList<StorageFile> files = await GetCurrentCacheImages(fileCacheType);

                m_baconMan.TelemetryMan.ReportLog(this, "Current images in cache :" + files.Count);

                if (files != null && files.Count != 0)
                {
                    int currentIndex = 0;
                    if(type == UpdateTypes.LockScreen)
                    {
                        // Update the index
                        CurrentLockScreenRotationIndex++;
                        if (CurrentLockScreenRotationIndex >= files.Count)
                        {
                            CurrentLockScreenRotationIndex = 0;
                        }
                        currentIndex = CurrentLockScreenRotationIndex;
                    }
                    else if(type == UpdateTypes.Band)
                    {
                        // Update the index
                        CurrentBandRotationIndex++;
                        if (CurrentBandRotationIndex >= files.Count)
                        {
                            CurrentBandRotationIndex = 0;
                        }
                        currentIndex = CurrentBandRotationIndex;
                    }
                    else
                    {
                        // Update the index
                        CurrentDesktopRotationIndex++;
                        if (CurrentDesktopRotationIndex >= files.Count)
                        {
                            CurrentDesktopRotationIndex = 0;
                        }
                        currentIndex = CurrentDesktopRotationIndex;
                    }

                    m_baconMan.TelemetryMan.ReportLog(this, "Current index used to set image :" + currentIndex);

                    // Set the image
                    bool wasSuccess = await SetBackgroundImage(type, files[currentIndex]);

                    if (!wasSuccess)
                    {
                        m_baconMan.TelemetryMan.ReportLog(this, "Image update failed", SeverityLevel.Error);
                        m_baconMan.TelemetryMan.ReportUnExpectedEvent(this, type == UpdateTypes.LockScreen ? "LockscreenImageUpdateFailed" : "DesktopImageUpdateFailed");
                    }
                    else
                    {
                        m_baconMan.TelemetryMan.ReportLog(this, "Image update success");
                    }

                    return wasSuccess;
                }
            }
            // Return true if we are disabled
            return true;
        }
Пример #49
0
        private static void ReadAndDumpField(UpdateField uf, StringBuilder sb, GenericReader gr, UpdateTypes updatetype, StreamWriter data, WoWObject obj)
        {
            MemoryStream ms = new MemoryStream(gr.ReadBytes(4));
            GenericReader gr2 = new GenericReader(ms);

            if (updatetype == UpdateTypes.UPDATETYPE_CREATE_OBJECT || updatetype == UpdateTypes.UPDATETYPE_CREATE_OBJECT2)
            {
                obj.SetUInt32Value(uf.Identifier, gr2.ReadUInt32());
                gr2.BaseStream.Position -= 4;
            }

            switch (uf.Type)
            {
                // TODO: add data writing
                /*case 3:
                    string val1 = gr.ReadSingle().ToString().Replace(",", ".");
                    if (updatetype == UpdateTypes.UPDATETYPE_CREATE_OBJECT || updatetype == UpdateTypes.UPDATETYPE_CREATE_OBJECT2)
                        data.WriteLine(uf.Name + " (" + uf.Identifier + "): " + val1);
                    sb.AppendLine(uf.Name + " (" + index + "): " + val1);
                    break;
                default:
                    uint val2 = gr.ReadUInt32();
                    if (updatetype == UpdateTypes.UPDATETYPE_CREATE_OBJECT || updatetype == UpdateTypes.UPDATETYPE_CREATE_OBJECT2)
                        data.WriteLine(uf.Name + " (" + uf.Identifier + "): " + val2);
                    sb.AppendLine(uf.Name + " (" + uf.Identifier + "): " + val2);
                    break;*/
                case 1: // uint32
                    sb.AppendLine(uf.Name + " (" + uf.Identifier + "): " + gr2.ReadUInt32().ToString("X8"));
                    break;
                case 2: // uint16+uint16
                    ushort value1 = gr2.ReadUInt16();
                    ushort value2 = gr2.ReadUInt16();

                    sb.AppendLine(uf.Name + " (" + uf.Identifier + "): " + "first " + value1.ToString("X4") + ", second " + value2.ToString("X4"));
                    if (uf.Name.StartsWith("PLAYER_SKILL_INFO_1_"))
                    {
                        int num = uf.Identifier - 858;
                        if ((num % 3) == 0)
                        {
                            ushort skill = value1;
                            ushort flag = value2;

                            string str = String.Format("skill {0}, flag {1}", skill, (ProfessionFlags)flag);
                            sb.AppendLine(str);
                        }
                        else if (((num - 1) % 3) == 0)
                        {
                            ushort minskill = value1;
                            ushort maxskill = value2;

                            string str = String.Format("minskill {0}, maxskill {1}", minskill, maxskill);
                            sb.AppendLine(str);
                        }
                        else
                        {
                            ushort minbonus = value1;
                            ushort maxbonus = value2;

                            string str = String.Format("minbonus {0}, maxbonus {1}", minbonus, maxbonus);
                            sb.AppendLine(str);
                        }
                    }
                    break;
                case 3: // float
                    sb.AppendLine(uf.Name + " (" + uf.Identifier + "): " + gr2.ReadSingle());
                    //sb.AppendLine(uf.Name + " (" + uf.Identifier + "): " + gr.ReadSingle().ToString().Replace(",", "."));
                    break;
                case 4: // uint64 (can be only low part)
                    sb.AppendLine(uf.Name + " (" + uf.Identifier + "): " + gr2.ReadUInt32().ToString("X8"));
                    break;
                case 5: // bytes
                    uint value = gr2.ReadUInt32();
                    sb.AppendLine(uf.Name + " (" + uf.Identifier + "): " + value.ToString("X8"));
                    if (uf.Identifier == 36) // UNIT_FIELD_BYTES_0
                    {
                        byte[] bytes = BitConverter.GetBytes(value);
                        Races race = (Races)bytes[0];
                        Class class_ = (Class)bytes[1];
                        Gender gender = (Gender)bytes[2];
                        Powers powertype = (Powers)bytes[3];

                        string str = String.Format("Race: {0}, class: {1}, gender: {2}, powertype: {3}", race, class_, gender, powertype);
                        sb.AppendLine(str);
                    }
                    break;
                default:
                    sb.AppendLine(uf.Name + " (" + uf.Identifier + "): " + "unknown type " + gr2.ReadUInt32().ToString("X8"));
                    break;
            }

            gr2.Close();
        }
 /// <summary>
 /// Returns the current contents of the cache folder
 /// </summary>
 /// <returns></returns>
 private async Task<IReadOnlyList<StorageFile>> GetCurrentCacheImages(UpdateTypes type)
 {
     StorageFolder localFolder = await GetImageCacheFolder(type);
     return await localFolder.GetFilesAsync();
 }
Пример #51
0
 public void UpdateScene(UpdateTypes type, UpdateHint hint)
 {
     foreach (WorldObjectCollection objCol in this.worldCollections)
     {
         objCol.UpdateScene(type, hint);
     }
 }
Пример #52
0
 public void UpdateScene(UpdateTypes type, UpdateHint hint)
 {
     foreach (IWorldObject child in treeTypes)
     {
         child.UpdateScene(type, hint);
     }
 }
Пример #53
0
 public RowUpdate()
 {
     UpdateValues = new Dictionary<string, object>();
     UpdateType = UpdateTypes.Update;
 }
Пример #54
0
 public void AddUpdateType(UpdateTypes billboardUpdate)
 {
     updateFlag |= (uint)billboardUpdate;
 }
Пример #55
0
 public void RemoveUpdateType(UpdateTypes billboardUpdate)
 {
     updateFlag &= ~(uint)billboardUpdate;
 }
 public void UpdateScene(UpdateTypes type, UpdateHint hint)
 {
     foreach (IWorldObject obj in objectList)
     {
         obj.UpdateScene(type, hint);
     }
 }
        private async Task WriteImageToFile(InMemoryRandomAccessStream stream, UpdateTypes type)
        {
            StorageFolder localFolder = await GetImageCacheFolder(type);
            StorageFile file = await localFolder.CreateFileAsync("cachedImage.jpg", CreationCollisionOption.GenerateUniqueName);

            using (var fileStream = await file.OpenAsync(FileAccessMode.ReadWrite))
            {
                await RandomAccessStream.CopyAndCloseAsync(stream.GetInputStreamAt(0), fileStream.GetOutputStreamAt(0));
            }
        }
 /// <summary>
 /// Assuming there are images, this does the rotation of the lock screen images.
 /// </summary>
 /// <returns></returns>
 private async Task DoImageRotation(UpdateTypes type)
 {
     try
     {
         bool wasSuccess = false;
         if(type == UpdateTypes.LockScreen)
         {
             wasSuccess = await DoSingleImageRotation(UpdateTypes.LockScreen);
         }
         else if(type == UpdateTypes.Desktop)
         {
             wasSuccess = await DoSingleImageRotation(UpdateTypes.Desktop);
         }
         else if(type == UpdateTypes.Band)
         {
             wasSuccess = await DoSingleImageRotation(UpdateTypes.Band);
         }
         else
         {
             bool firstSuccess = await DoSingleImageRotation(UpdateTypes.LockScreen);
             bool secondSuccess = await DoSingleImageRotation(UpdateTypes.Desktop);
             bool thirdSuccess = await DoSingleImageRotation(UpdateTypes.Band);
             wasSuccess = firstSuccess && secondSuccess && thirdSuccess;
         }      
         
         // If we successfully updated set the time.
         if(wasSuccess)
         {
             LastImageUpdate = DateTime.Now;
         }       
     }
     catch (Exception e)
     {
         m_baconMan.MessageMan.DebugDia("Failed to set background image", e);
         m_baconMan.TelemetryMan.ReportUnExpectedEvent(this, "Failed to set background image", e);
     }
 }
Пример #59
0
 public BPExcelWorker(UpdateTypes updateType, SystemTypes systemType)
     : base(updateType, systemType)
 {
     ColorKeep = keep;
     ColorUpdate = update;
 }
 /// <summary>
 /// Release the deferral for a type if it is held
 /// </summary>
 /// <param name="type"></param>
 private void ReleaseDeferral(UpdateTypes type)
 {
     lock(this)
     {
         if (type == UpdateTypes.LockScreen)
         {
             if (m_lockScreenRefDeferral != null)
             {
                 m_lockScreenRefDeferral.ReleaseRef();
             }
             m_lockScreenRefDeferral = null;
         }
         else if(type == UpdateTypes.Band)
         {
             if (m_bandRefDeferral != null)
             {
                 m_bandRefDeferral.ReleaseRef();
             }
             m_bandRefDeferral = null;
         }
         else
         {
             if (m_desktopRefDeferral != null)
             {
                 m_desktopRefDeferral.ReleaseRef();
             }
             m_desktopRefDeferral = null;
         }
     }  
 }