Esempio n. 1
0
        public void TestScavenging()
        {
            //RefreshAction refreshAction = new RefreshAction();
            //LocalCacheManager localCacheManager = LocalCacheManager.CreateDefault();
            //for (int i = 0; i < 110; ++i) 
            //{
            //    localCacheManager.Add("k" + i, "v" + i, CacheItemPriority.None, refreshAction, new AbsoluteTime(DateTime.Now.AddMinutes(100)));
            //}

            //System.Threading.Thread.Sleep(120000);

            //Assert.AreEqual<int>(10, refreshAction.ScavengedItemsCount);

            RefreshAction refreshAction2 = new RefreshAction();
            LocalCacheManager dynamicCacheManager = LocalCacheManager.GetInstance("CacheManagerDynamic");
            for (int i = 0; i < 100; ++i) 
            {
                dynamicCacheManager.Add("kk" + i, "vv" + i, CacheItemPriority.None, refreshAction2, new AbsoluteTime(DateTime.Now.AddMinutes(100)));
            }

            System.Threading.Thread.Sleep(70000);

            Assert.AreEqual<int>(20, refreshAction2.ScavengedItemsCount);

            Assert.AreEqual<int>(80, dynamicCacheManager.Count);
        }
Esempio n. 2
0
 private void CoerceRefreshAction()
 {
     if (this.ShortCut == "Delete" && this.RefreshAction == RefreshAction.SingleRow)
     {
         this.RefreshAction = RefreshAction.RemoveSingleRow;
     }
 }
Esempio n. 3
0
        public void CursorDown(Point location)
        {
            SelectionRectangle = new SelectionRectangle();
            location           = GetSnapped(location);
            SelectionRectangle.SetStart(location);
            SpriteRectangle = SelectionRectangle.GetRectangle();

            RefreshAction?.Invoke();
        }
Esempio n. 4
0
 public void Clear()
 {
     Bronze  = 0;
     Silver  = 0;
     Gold    = 0;
     Lumen   = 0;
     Warlock = 0;
     RefreshAction.SafeInvoke();
 }
Esempio n. 5
0
 private void RefreshLoadPanel_Loaded(object sender, RoutedEventArgs e)
 {
     _scrollViewer = GetScrollViewer(this);
     if (RefreshAction != null)
     {
         Children.Add(RefreshAction.RefreshMark);
         RefreshAction.OnInit();
     }
 }
Esempio n. 6
0
        internal void UpdateSpriteImage(SpriteVM sprite, Rectangle cutout)
        {
            var bytes           = BitmapHelper.ToBytes(SourceImage, cutout);
            var originalPalette = sprite.Image.Palette;

            sprite.UpdateBitmap(cutout.Width, cutout.Height, bytes);
            sprite.Image.Palette = originalPalette;

            RefreshAction?.Invoke();
        }
Esempio n. 7
0
        public void CanLoadOneItemWithNullExpirations()
        {
            RefreshAction refreshAction = new RefreshAction();
            CacheItem     addedItem     = new CacheItem("key", "value", CacheItemPriority.NotRemovable, refreshAction);

            backingStore.Add(addedItem);

            Hashtable retrievedData = backingStore.Load();

            Assert.AreEqual(1, retrievedData.Count);
        }
Esempio n. 8
0
        private void Restore(int spriteIndex)
        {
            if (spriteIndex < 0)
            {
                return;
            }

            SpriteRectangle = Parent.CurrentSprite.SourceRectangle;
            UpdateControls();
            RefreshAction?.Invoke();
        }
Esempio n. 9
0
 private void ThreadPoolRefreshActionInvoker(object notUsed)
 {
     try
     {
         RefreshAction.Refresh(KeyToRefresh, RemovedData, RemovalReason);
     }
     catch (Exception e)
     {
         InstrumentationProvider.FireCacheCallbackFailed(KeyToRefresh, e);
     }
 }
        /// <summary>
        /// Calls initial setup functions on this MenuRefresher, then calls Refresh.
        /// </summary>
        /// <param name="sourceArray">Source array.</param>
        /// <param name="toPerformOnItem">To perform on item.</param>
        /// <param name="sameParentAsPrototype">If set to <c>true</c> same parent as prototype.</param>
        /// <param name="keepWorldPosition">If set to <c>true</c> keep world position.</param>
        /// <param name="deactivatePrototype">If set to <c>true</c> deactivate prototype.</param>
        /// <typeparam name="T">The 1st type parameter.</typeparam>
        public List <GameObject> Setup <T>(T[] sourceArray, RefreshAction <T> toPerformOnItem = null, OnComplete onCompleteCallback = null, bool sameParentAsPrototype = true, bool keepWorldPosition = false, bool deactivatePrototype = true)
        {
            if (deactivatePrototype)
            {
                itemPrototype.SetActive(false);
            }

            ClearExistingItems();

            return(Refresh <T>(sourceArray, toPerformOnItem, onCompleteCallback, sameParentAsPrototype, keepWorldPosition));
        }
Esempio n. 11
0
        public void CursorMove(Point location)
        {
            if (SelectionRectangle == null)
            {
                return;
            }

            location = GetSnapped(location);
            SelectionRectangle.Update(location);
            SpriteRectangle = SelectionRectangle.GetRectangle();
            RefreshAction?.Invoke();
        }
        protected override void OnCreate(Bundle bundle)
        {
            try
            {
                RequestWindowFeature(WindowFeatures.NoTitle);

                base.OnCreate(bundle);
                LoggerMobile.Instance.logMessage("Opening GamesActivity", LoggerEnum.message);
                SetContentView(Resource.Layout.PublicGames);
                LegacyBar = FindViewById<LegacyBar.Library.Bar.LegacyBar>(Resource.Id.actionbar);
                LegacyBar.SeparatorColor = Color.Purple;

                AddHomeAction(typeof(Main), Resource.Drawable.icon);
                // Get our button from the layout resource,
                // and attach an event to it

                LegacyBar.ProgressBarVisibility = ViewStates.Visible;
                //currentGamesList = FindViewById<ListView>(Resource.Id.currentGamesList);
                pastGamesList = FindViewById<ListView>(Resource.Id.pastGamesList);
                LegacyBarAction loginAction = new RefreshAction(this, null, Resource.Drawable.ic_action_refresh, this);
                LegacyBar.AddAction(loginAction);

                initialPastArray = new GamesJson();
                //initialCurrentArray = new GamesJson();
                Action pullMorePast = new Action(PullMorePast);
                //Action pullCurrent = new Action(PullMorePast);

                PastGamesAdapter = new GamesAdapter(this, initialPastArray.Games, pullMorePast);
                //CurrentGamesAdapter = new GamesAdapter(this, initialCurrentArray.Games, null);

                //currentGamesList.Adapter = CurrentGamesAdapter;
                pastGamesList.Adapter = PastGamesAdapter;
                Game.PullCurrentGames(this, UpdateCurrentAdapter);
                Game.PullPastGames(PAGE_COUNT, lastPagePulled, this, UpdatePastAdapter);

                //currentGamesList.ItemClick += currentGamesList_ItemClick;
                pastGamesList.ItemClick += pastGamesList_ItemClick;
                var myString = new SpannableStringBuilder("lol");
                Selection.SelectAll(myString); // needs selection or Index Out of bounds

                LegacyBarAction infoAction = new DefaultLegacyBarAction(this, CreateInfoIntent(), Resource.Drawable.action_about);
                LegacyBar.AddAction(infoAction);

                m_AdView = FindViewById(Resource.Id.adView);
                if (SettingsMobile.Instance.User != null && SettingsMobile.Instance.User.IsValidSub)
                {
                }
            }
            catch (Exception exception)
            {
                ErrorHandler.Save(exception, MobileTypeEnum.Android, (Context)this);
            }
        }
 /// <summary>
 /// Create a new GameObject for each T item in sourceArray. Make sure Setup() has been called already.
 /// </summary>
 /// <param name="sourceArray">Source array.</param>
 /// <param name="toPerformOnItem">Action to perform after creating each item. The first parameter represents the GameObject created, the second
 /// represents the value in the sourceArray that triggers the GameObject's creation.</param>
 /// <param name="sameParentAsPrototype">If set to <c>true</c> same parent as prototype.</param>
 /// <param name="keepWorldPosition">If set to <c>true</c> keep world position.</param>
 /// <typeparam name="T">The 1st type parameter.</typeparam>
 public List <GameObject> Refresh <T>(T[] sourceArray, RefreshAction <T> toPerformOnItem = null, OnComplete onCompleteCallback = null, bool sameParentAsPrototype = true, bool keepWorldPosition = false)
 {
     ClearExistingItems();
     foreach (T t in sourceArray)
     {
         CreateNewItemFrom <T>(t, toPerformOnItem, sameParentAsPrototype, keepWorldPosition);
     }
     if (onCompleteCallback != null)
     {
         onCompleteCallback.Invoke();
     }
     return(allCreatedItems);
 }
Esempio n. 14
0
        public void CursorUp(Point location)
        {
            if (SelectionRectangle == null)
            {
                return;
            }

            location = GetSnapped(location);
            SelectionRectangle.SetFinish(location);
            SpriteRectangle    = SelectionRectangle.GetRectangle();
            SelectionRectangle = null;
            RefreshAction?.Invoke();
            UpdateControls();
        }
Esempio n. 15
0
 private void ThreadPoolRefreshActionInvoker(object notUsed)
 {
     try
     {
         RefreshAction.Refresh(KeyToRefresh, RemovedData, RemovalReason);
     }
     catch (Exception e)
     {
         CachingServiceInternalFailureEvent.Fire(SR.FailureWhileRunningUserSpecifiedRefreshAction, e);
     }
     catch
     {
         CachingServiceInternalFailureEvent.Fire(SR.FailureWhileRunningUserSpecifiedRefreshAction, new Exception(SR.UnknownFailureReason));
     }
 }
        /// <summary>
        /// Creates the new item from a source reference.
        /// </summary>
        /// <returns>The new item from.</returns>
        /// <param name="sourceReference">Source reference.</param>
        /// <param name="toPerformOnItem">To perform on item.</param>
        /// <param name="sameParentAsPrototype">If set to <c>true</c> same parent as prototype.</param>
        /// <param name="keepWorldPosition">If set to <c>true</c> keep world position.</param>
        /// <typeparam name="T">The 1st type parameter.</typeparam>
        public GameObject CreateNewItemFrom <T>(T sourceReference, RefreshAction <T> toPerformOnItem = null, bool sameParentAsPrototype = true, bool keepWorldPosition = false)
        {
            GameObject clonedItem = Instantiate(itemPrototype) as GameObject;

            clonedItem.SetActive(true);
            if (sameParentAsPrototype)
            {
                clonedItem.transform.SetParent(itemPrototype.transform.parent, keepWorldPosition);
            }
            if (toPerformOnItem != null)
            {
                toPerformOnItem.Invoke(clonedItem, sourceReference);
            }

            allCreatedItems.Add(clonedItem);
            return(clonedItem);
        }
        private void RefreshItem(FileItem item, RefreshAction action)
        {
            if (item.Refresh(action, out IDictionary <CommentTask, bool> itemChanges))
            {
                // We need to lock here since multiple threads can call this in parallel (e.g., from Parallel.ForEach).
                lock (this.changedItems)
                {
                    this.changedItems.Remove(item);
                }

                if (itemChanges != null && itemChanges.Count > 0)
                {
                    lock (this.changedTasks)
                    {
                        foreach (var pair in itemChanges)
                        {
                            this.changedTasks[pair.Key] = pair.Value;
                        }
                    }
                }
            }
        }
Esempio n. 18
0
        public void CanLoadOneItemFromTable()
        {
            RefreshAction refreshAction = new RefreshAction();
            CacheItem     addedItem     = new CacheItem("key", "value", CacheItemPriority.NotRemovable,
                                                        refreshAction,
                                                        new SlidingTime(TimeSpan.FromHours(1)), new AbsoluteTime(TimeSpan.FromHours(1.0)));

            backingStore.Add(addedItem);

            Hashtable retrievedData = backingStore.Load();

            Assert.AreEqual(1, retrievedData.Count);

            CacheItem item = (CacheItem)retrievedData["key"];

            Assert.AreEqual("key", item.Key);
            Assert.AreEqual("value", item.Value);
            Assert.AreEqual(CacheItemPriority.NotRemovable, item.ScavengingPriority);
            Assert.AreEqual(typeof(RefreshAction), item.RefreshAction.GetType());
            Assert.IsFalse(Object.ReferenceEquals(refreshAction, item.RefreshAction));
            Assert.AreEqual(2, item.Expirations.Length);
            Assert.AreEqual(typeof(SlidingTime), item.Expirations[0].GetType());
            Assert.AreEqual(typeof(AbsoluteTime), item.Expirations[1].GetType());
        }
Esempio n. 19
0
        public bool Refresh(RefreshAction action, out IDictionary <CommentTask, bool> itemChanges)
        {
            bool isScannable = action != RefreshAction.Remove && this.scanInfo.IsScannable;

            if (isScannable)
            {
                this.fileInfo.Refresh();
                isScannable = this.fileInfo.Exists;
            }

            bool result = false;

            itemChanges = null;

            if (!isScannable)
            {
                if (this.tasks != null)
                {
                    itemChanges = this.tasks.ToDictionary(t => t, t => false);
                    this.tasks  = null;
                }

                // Reset to min time so if the file shows up again we'll re-scan it.
                this.lastModifiedTimeScannedUtc = MinDateTimeUtc;
                result = true;
            }
            else
            {
                bool forceRefresh = action == RefreshAction.Always || !this.AreTaskProjectsCurrent;

                // Make sure that the file has been modified since we last scanned it.
                // Note: lastModifiedUtc can go backward to before lastModifiedTimeScannedUtc
                // due to Undo, so we have to check != instead of just >.
                DateTime lastModifiedUtc = this.Document != null && this.Document.HasTextDocument
                                        ? this.Document.LastModifiedUtc.Value : this.fileInfo.LastWriteTimeUtc;
                if (forceRefresh || lastModifiedUtc != this.lastModifiedTimeScannedUtc)
                {
                    // Make sure that it's been at least N seconds since the file was last modified.
                    // If someone is making a long sequence of continual edits, then there's no point
                    // in wasting scanning overhead while they're actively changing the file.
                    DateTime latestAllowedTimeUtc = DateTime.UtcNow - this.provider.ScanDelay;
                    if (forceRefresh || latestAllowedTimeUtc >= lastModifiedUtc)
                    {
                        itemChanges = this.Refresh();
                        result      = true;
                        this.lastModifiedTimeScannedUtc = lastModifiedUtc;
                    }
                }
                else
                {
                    // We should only get into this branch of the Refresh method if we got a new file, a document change event,
                    // or a file change event.  It's possible to get a "document change" event when a document within the solution
                    // is first opened even though we've already scanned it (from the solution reference).  When that happens the
                    // lastModifiedUtc should equal the lastModifiedTimeScannedUtc, so we'll just return true since the file scan
                    // results should already be up-to-date.
                    result = lastModifiedUtc == this.lastModifiedTimeScannedUtc;
                    Debug.Assert(result, "The file's modified time should have changed or been the same as the last modified scanned time.");
                }
            }

            CommentTaskProvider.Debug("FileItem.Refresh: {0}, Result={1}  ItemChanges={2}", this.FileName, result, itemChanges != null);
            return(result);
        }
Esempio n. 20
0
        public void CanLoadOneItemWithNullExpirations()
        {
            RefreshAction refreshAction = new RefreshAction();
            CacheItem addedItem = new CacheItem("key", "value", CacheItemPriority.NotRemovable, refreshAction);
            backingStore.Add(addedItem);

            Hashtable retrievedData = backingStore.Load();
            Assert.AreEqual(1, retrievedData.Count);
        }
Esempio n. 21
0
        public void CanLoadOneItemFromTable()
        {
            RefreshAction refreshAction = new RefreshAction();
            CacheItem addedItem = new CacheItem("key", "value", CacheItemPriority.NotRemovable,
                                                refreshAction,
                                                new SlidingTime(TimeSpan.FromHours(1)), new AbsoluteTime(TimeSpan.FromHours(1.0)));
            backingStore.Add(addedItem);

            Hashtable retrievedData = backingStore.Load();
            Assert.AreEqual(1, retrievedData.Count);

            CacheItem item = (CacheItem)retrievedData["key"];
            Assert.AreEqual("key", item.Key);
            Assert.AreEqual("value", item.Value);
            Assert.AreEqual(CacheItemPriority.NotRemovable, item.ScavengingPriority);
            Assert.AreEqual(typeof(RefreshAction), item.RefreshAction.GetType());
            Assert.IsFalse(Object.ReferenceEquals(refreshAction, item.RefreshAction));
            Assert.AreEqual(2, item.GetExpirations().Length);
            Assert.AreEqual(typeof(SlidingTime), item.GetExpirations()[0].GetType());
            Assert.AreEqual(typeof(AbsoluteTime), item.GetExpirations()[1].GetType());
        }
Esempio n. 22
0
        public async Task CreateJob(JobType jobType, Stream jobStream)
        {
            WorkerResult  result;
            RefreshAction refreshAction = null;

            switch (jobType)
            {
            case JobType.CopyLog:
                var copyLogJob = await jobStream.Deserialize <CopyLogJob>();

                (result, refreshAction) = await copyLogWorker.Execute(copyLogJob);

                break;

            case JobType.CopyLogData:
                var copyLogDataJob = await jobStream.Deserialize <CopyLogDataJob>();

                (result, refreshAction) = await copyLogDataWorker.Execute(copyLogDataJob);

                break;

            case JobType.CopyTrajectory:
                var copyTrajectoryJob = await jobStream.Deserialize <CopyTrajectoryJob>();

                (result, refreshAction) = await copyTrajectoryWorker.Execute(copyTrajectoryJob);

                break;

            case JobType.TrimLogObject:
                var trimLogObjectJob = await jobStream.Deserialize <TrimLogDataJob>();

                (result, refreshAction) = await trimLogObjectWorker.Execute(trimLogObjectJob);

                break;

            case JobType.ModifyLogObject:
                var modifyLogObjectJob = await jobStream.Deserialize <ModifyLogObjectJob>();

                (result, refreshAction) = await modifyLogObjectWorker.Execute(modifyLogObjectJob);

                break;

            case JobType.DeleteCurveValues:
                var deleteCurveValuesJob = await jobStream.Deserialize <DeleteCurveValuesJob>();

                (result, refreshAction) = await deleteCurveValuesWorker.Execute(deleteCurveValuesJob);

                break;

            case JobType.DeleteLogObjects:
                var deleteLogObjectsJob = await jobStream.Deserialize <DeleteLogObjectsJob>();

                (result, refreshAction) = await deleteLogObjectsWorker.Execute(deleteLogObjectsJob);

                break;

            case JobType.DeleteMnemonics:
                var deleteMnemonicsJob = await jobStream.Deserialize <DeleteMnemonicsJob>();

                (result, refreshAction) = await deleteMnemonicsWorker.Execute(deleteMnemonicsJob);

                break;

            case JobType.DeleteWell:
                var deleteWellJob = await jobStream.Deserialize <DeleteWellJob>();

                (result, refreshAction) = await deleteWellWorker.Execute(deleteWellJob);

                break;

            case JobType.DeleteWellbore:
                var deleteWellboreJob = await jobStream.Deserialize <DeleteWellboreJob>();

                (result, refreshAction) = await deleteWellboreWorker.Execute(deleteWellboreJob);

                break;

            case JobType.RenameMnemonic:
                var modifyLogCurveInfoJob = await jobStream.Deserialize <RenameMnemonicJob>();

                (result, refreshAction) = await renameMnemonicWorker.Execute(modifyLogCurveInfoJob);

                break;

            case JobType.ModifyWell:
                var modifyWellJob = await jobStream.Deserialize <ModifyWellJob>();

                (result, refreshAction) = await modifyWellWorker.Execute(modifyWellJob);

                break;

            case JobType.ModifyWellbore:
                var modifyWellboreJob = await jobStream.Deserialize <ModifyWellboreJob>();

                (result, refreshAction) = await modifyWellboreWorker.Execute(modifyWellboreJob);

                break;

            case JobType.DeleteTrajectory:
                var deleteTrajectoryJob = await jobStream.Deserialize <DeleteTrajectoryJob>();

                result = await deleteTrajectoryWorker.Execute(deleteTrajectoryJob);

                break;

            case JobType.CreateLogObject:
                var createLogObject = await jobStream.Deserialize <CreateLogJob>();

                (result, refreshAction) = await createLogWorker.Execute(createLogObject);

                break;

            case JobType.CreateWell:
                var createWellJob = await jobStream.Deserialize <CreateWellJob>();

                (result, refreshAction) = await createWellWorker.Execute(createWellJob);

                break;

            case JobType.CreateWellbore:
                var createWellboreJob = await jobStream.Deserialize <CreateWellboreJob>();

                (result, refreshAction) = await createWellboreWorker.Execute(createWellboreJob);

                break;

            default:
                throw new ArgumentOutOfRangeException(nameof(jobType), jobType, $"No worker setup to execute {jobType.GetDisplayName()}");
            }

            if (hubContext != null)
            {
                await hubContext.Clients.All.SendCoreAsync("jobFinished", new object[] { result });

                if (refreshAction != null)
                {
                    await hubContext.Clients.All.SendCoreAsync("refresh", new object[] { refreshAction });
                }
            }
        }
Esempio n. 23
0
        internal void RenderSelection(bool invalidateRegardless)
        {
            //This is our refresh action
            RefreshAction action = new RefreshAction(() => 
            {
                if (HasSelection())
                {
                    this.IsBusy = true;
                    UpdateSelectionRenderingOptions();
                    renderWorker.RunWorkerAsync(new RenderWorkArgs()
                    {
                        SelectionRenderingOptions = _selectionRenderOpts,
                        RaiseEvents = false,
                        InvalidateRegardless = invalidateRegardless
                    });
                }
                else
                {
                    if (invalidateRegardless)
                        this.Invalidate();
                }
            });

            //If an existing rendering operation is in progress queue it if 
            //there isn't one queued. Because there is no point in doing the
            //same thing more than once
            if (this.IsBusy)
            {
                if (_queuedRefresh == null) //No refresh operations currently queued
                    _queuedRefresh = action;
            }
            else //Otherwise execute it immediately
            {
                action();
            }
        }
Esempio n. 24
0
        internal void RefreshMap(bool raiseEvents)
        {
            //This is our refresh action
            RefreshAction action = new RefreshAction(() => 
            {
                var args = new RenderWorkArgs()
                {
                    UseRenderMap = this.UseRenderMapIfTiledLayersExist && this.HasTiledLayers,
                    MapRenderingOptions = _overlayRenderOpts,
                    RaiseEvents = raiseEvents
                };
                if (HasSelection())
                {
                    UpdateSelectionRenderingOptions();
                    args.SelectionRenderingOptions = _selectionRenderOpts;
                }
                this.IsBusy = true;
                renderWorker.RunWorkerAsync(args);
            });

            //If an existing rendering operation is in progress queue it if 
            //there isn't one queued. Because there is no point in doing the
            //same thing more than once
            if (this.IsBusy)
            {
                if (_queuedRefresh == null) //No refresh operations currently queued
                    _queuedRefresh = action;
            }
            else //Otherwise execute it immediately
            {
                action();   
            }
        }
Esempio n. 25
0
        private void renderWorker_RunWorkerCompleted(object sender, RunWorkerCompletedEventArgs e)
        {
            this.IsBusy = AreWorkersBusy();
            if (e.Error != null)
            {
                MessageBox.Show(e.Error.Message, Strings.TitleError); //NOXLATE
            }
            else
            {
                var res = (RenderResult)e.Result;
                //reset translation
                translate = new System.Drawing.Point();

                bool bInvalidate = false;
                //set the image
                if (res.Image != null)
                {
                    if (this.Image != null)
                    {
                        this.Image.Dispose();
                        this.Image = null;
                    }
                    //Trace.TraceInformation("Set map image"); //NOXLATE
                    this.Image = res.Image;
                    bInvalidate = true;
                }
                if (res.SelectionImage != null)
                {
                    if (_selectionImage != null)
                    {
                        _selectionImage.Dispose();
                        _selectionImage = null;
                    }
                    //Trace.TraceInformation("Set selection image"); //NOXLATE
                    _selectionImage = res.SelectionImage;
                    bInvalidate = true;
                }

                //If there is a queued refresh action, execute it now
                if (_queuedRefresh != null)
                {
                    //Trace.TraceInformation("Executing queued rendering operation"); //NOXLATE
                    _queuedRefresh();
                    _queuedRefresh = null;
                }
                else 
                {
                    if (bInvalidate || res.InvalidateRegardless)
                        Invalidate(true);

                    /*
                    var center = _map.ViewCenter;
                    var ext = _map.DataExtent;
                    System.Diagnostics.Trace.TraceInformation(
                        "**POST-RENDER**{2}Map Center: {0}, {1}{2}Lower left: {3}, {4}{2}Upper Right: {5}, {6}", //NOXLATE
                        center.Coordinate.X,
                        center.Coordinate.Y,
                        Environment.NewLine,
                        ext.LowerLeftCoordinate.X,
                        ext.LowerLeftCoordinate.Y,
                        ext.UpperRightCoordinate.X,
                        ext.UpperRightCoordinate.Y);
                    */
                    if (res.RaiseEvents)
                    {
                        var handler = this.MapRefreshed;
                        if (handler != null)
                            handler(this, EventArgs.Empty);
                    }
                }
            }
        }
        public void UpdateTasks(bool updateAll)
        {
            IEnumerable <FileItem> items;

            lock (this.changedItems)
            {
                items = this.changedItems.ToList();
            }

            if (updateAll)
            {
                // We have to include any changedItems to make sure we remove existing tasks
                // from files that no longer exist in this.files.
                items = items.Concat(this.files.Select(pair => pair.Value)).Distinct();
            }

            if (items.Any())
            {
                List <Regex> localExcludePatterns;
                lock (this.backgroundExcludePatterns)
                {
                    localExcludePatterns = new List <Regex>(this.backgroundExcludePatterns);
                }

                // Try to use a fourth of the processors, but stay in the 1 to 8 range.
                const int MinParallelism       = 1;
                const int MaxParallelism       = 8;
                const int ProcessorScaleFactor = 4;
                int       maxParallelism       = Math.Max(MinParallelism, Math.Min(Environment.ProcessorCount / ProcessorScaleFactor, MaxParallelism));
                try
                {
                    RefreshAction generalAction = updateAll ? RefreshAction.Always : RefreshAction.IfNeeded;
                    Parallel.ForEach(
                        items.ToArray(),                         // Copy before iterating through it.
                        new ParallelOptions()
                    {
                        MaxDegreeOfParallelism = maxParallelism
                    },
                        item =>
                    {
                        RefreshAction itemAction;
                        if (localExcludePatterns.Any(pattern => pattern.IsMatch(item.FileName)))
                        {
                            itemAction = RefreshAction.Remove;
                        }
                        else
                        {
                            itemAction = generalAction;
                        }

                        this.RefreshItem(item, itemAction);
                    });
                }
                catch (Exception ex)
                {
                    MainPackage.LogException(ex);
                    if (!(ex is AggregateException))
                    {
                        throw;
                    }
                }
            }
        }
Esempio n. 27
0
 private void NativeControl_Refreshing(object sender, EventArgs e)
 {
     RefreshAction?.Invoke();
 }
Esempio n. 28
0
 public void Undo()
 {
     SpriteRectangle = Parent.CurrentSprite.SourceRectangle;
     UpdateControls();
     RefreshAction?.Invoke();
 }
Esempio n. 29
0
        public void ExecuteAction(ActionSet actionSet, BlockBase sourceBlock, Node sourceNode, long sourceViewID)
        {
            foreach (ActionBase action in actionSet.Actions)
            {
                switch (action.ActionType)
                {
                case ActionType.GotoNodeStable:
                {
                    GotoNodeStableAction gns = action as GotoNodeStableAction;

                    if (gns != null)
                    {
                        GoToNodeByURI(gns.URI, gns.Transition, gns.IsPopup, sourceViewID);
                    }

                    break;
                }

                case ActionType.GotoNodeStableSSP:
                {
                    GotoNodeStableSSPAction gns = action as GotoNodeStableSSPAction;

                    if ((gns != null) && (gns.Signpost >= 0))
                    {
                        DisplayData dd = Core.UIFactory.FindSignpostedData(gns.Signpost, sourceViewID);

                        if ((dd != null) && (dd.DisplayType == DisplayType.String))
                        {
                            string uri = dd.Data as string;

                            if (!String.IsNullOrEmpty(uri))
                            {
                                GoToNodeByURI(uri, gns.Transition, gns.IsPopup, sourceViewID);
                            }
                        }
                    }

                    break;
                }

                case ActionType.GotoNodeInFrame:
                {
                    GotoNodeInFrameAction gnif = action as GotoNodeInFrameAction;

                    if (gnif != null)
                    {
                        View target = ResolveFrameID(gnif.FrameID, sourceBlock);

                        if (target != null)
                        {
                            GoToNodeByURI(gnif.URI, gnif.Transition, gnif.IsPopup, target.ID);
                        }
                    }

                    break;
                }

                case ActionType.GotoBack:
                {
                    GotoBackAction gb = action as GotoBackAction;

                    if (gb != null)
                    {
                        View view = Core.UI[sourceViewID];

                        if (view != null)
                        {
                            view.GoBack();
                        }
                    }

                    break;
                }

                case ActionType.Refresh:
                {
                    RefreshAction rfr = action as RefreshAction;

                    if (rfr != null)
                    {
                        View target = ResolveFrameID(rfr.FrameID, sourceBlock);

                        if (target != null)
                        {
                            GoToNodeByURI(target.CurrentNode.URI, NodeTransition.None, false, target.ID, true);
                        }
                    }

                    break;
                }

                case ActionType.ClearBackStack:
                {
                    ClearBackstackAction cbs = action as ClearBackstackAction;

                    if (cbs != null)
                    {
                        View target = ResolveFrameID(cbs.FrameID, sourceBlock);

                        if (target != null)
                        {
                            target.ClearBackstack();
                        }
                    }

                    break;
                }

                case ActionType.SubmitForm:
                {
                    SubmitFormAction sf = action as SubmitFormAction;

                    if (sf != null)
                    {
                        SendForm(sf, actionSet, sourceNode, sourceBlock, sourceViewID);
                    }

                    break;
                }

                case ActionType.SubmitFormToFrame:
                {
                    SubmitFormToFrameAction sftf = action as SubmitFormToFrameAction;

                    if (sftf != null)
                    {
                        View target = ResolveFrameID(sftf.FrameID, sourceBlock);

                        if (target != null)
                        {
                            SendForm(sftf, actionSet, sourceNode, sourceBlock, sourceViewID, true);
                        }
                    }

                    break;
                }

                case ActionType.GotoApplicationHome:
                {
                    GotoApplicationHomeAction gah = action as GotoApplicationHomeAction;

                    if (gah != null)
                    {
                        GoToApplication(gah.URI, null, gah.Transition, gah.IsPopup, sourceViewID);
                    }

                    break;
                }

                case ActionType.GotoApplicationNode:
                {
                    GotoApplicationNodeAction gan = action as GotoApplicationNodeAction;

                    if (gan != null)
                    {
                        GoToApplication(gan.ApplicationURN, gan.ItemURI, gan.Transition, gan.IsPopup, sourceViewID);
                    }

                    break;
                }

                case ActionType.GotoNodeVolatile:
                case ActionType.SaveApplicationToFavourites:
                case ActionType.EPGSubmitForm:
                case ActionType.EPGViewportUp:
                case ActionType.EPGViewportDown:
                case ActionType.EPGViewportForward:
                case ActionType.EPGViewportBackward:
                case ActionType.EPGViewportForward24Hours:
                case ActionType.EPGViewportBackward24Hours:
                case ActionType.EPGViewportGotoChannel:
                case ActionType.UploadContentAndSubmitForm:
                case ActionType.SetStateSSP:
                case ActionType.ToggleStateSSP:
                    //IMPLEMENT: other actions
                    break;

                default:
                    Core.UIFactory.ExecuteAction(action, sourceBlock, sourceNode, sourceViewID);
                    break;
                }
            }
        }
Esempio n. 30
0
 public void Refresh()
 {
     RefreshAction?.Invoke();
 }