コード例 #1
0
 private void ItemSelectedHandler(TrackedItem i)
 {
     if (OnItemSelected != null)
     {
         OnItemSelected(i);
     }
 }
コード例 #2
0
        public async Task <IActionResult> PutTrackedItem(int id, TrackedItem trackedItem)
        {
            if (id != trackedItem.Id)
            {
                return(BadRequest());
            }

            _context.Entry(trackedItem).State = EntityState.Modified;

            try
            {
                await _context.SaveChangesAsync();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!TrackedItemExists(id))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            return(NoContent());
        }
コード例 #3
0
            private void AcceptChanges(TrackedItem item)
            {
                switch (item.State)
                {
                case SubmitAction.Delete:
                    this.RemoveFromCache((T)item.Instance);
                    this.AssignAction((T)item.Instance, SubmitAction.None);
                    break;

                case SubmitAction.Insert:
                    this.AddToCache((T)item.Instance);
                    this.AssignAction((T)item.Instance, SubmitAction.PossibleUpdate);
                    break;

                case SubmitAction.InsertOrUpdate:
                    this.AddToCache((T)item.Instance);
                    this.AssignAction((T)item.Instance, SubmitAction.PossibleUpdate);
                    break;

                case SubmitAction.PossibleUpdate:
                case SubmitAction.Update:
                    this.AssignAction((T)item.Instance, SubmitAction.PossibleUpdate);
                    break;

                default:
                    break;     // do nothing
                }
            }
コード例 #4
0
            /// <summary>
            /// Gets the update expression.
            /// </summary>
            /// <param name="item">The item.</param>
            /// <param name="concurrencyValues">The concurrency values.</param>
            /// <returns></returns>
            private Expression <Func <T, bool> > GetUpdateExpression(TrackedItem item, IEnumerable <KeyValuePair <string, object> > concurrencyValues)
            {
                if (concurrencyValues == null)
                {
                    return(null);
                }

                ParameterExpression p    = Expression.Parameter(typeof(T), "p");
                Expression          pred = null;

                List <string> concurrencyMembers = concurrencyValues.Select(m => m.Key).ToList();

                foreach (var mi in this.Mapping.GetMappedMembers(item.Entity))
                {
                    if (concurrencyMembers.Contains(mi.Name))
                    {
                        Expression eq = Expression.MakeMemberAccess(p, mi).Equal(Expression.Constant(mi.GetValue(item.Original)));
                        pred = (pred == null) ? eq : pred.And(eq);
                    }
                }

                if (pred == null)
                {
                    return(null);
                }

                return(Expression.Lambda <Func <T, bool> >(pred, p));
            }
コード例 #5
0
        private IEnumerable <TrackedItem> GetOrderedItems()
        {
            List <TrackedItem> items = (from tab in this.GetTables()
                                        from ti in ((ITrackedTable)tab).TrackedItems
                                        where ti.State != SubmitAction.None
                                        select ti).ToList <TrackedItem>();
            List <Edge> source = this.GetEdges(items).Distinct <Edge>().ToList <Edge>();
            ILookup <TrackedItem, TrackedItem> stLookup = source.ToLookup <Edge, TrackedItem, TrackedItem>(e => e.Source, e => e.Target);
            ILookup <TrackedItem, TrackedItem> tsLookup = source.ToLookup <Edge, TrackedItem, TrackedItem>(e => e.Target, e => e.Source);

            return(items.Sort <TrackedItem>(delegate(TrackedItem item) {
                switch (item.State)
                {
                case SubmitAction.Insert:
                case SubmitAction.InsertOrUpdate:
                    {
                        IEnumerable <TrackedItem> first = stLookup[item];
                        object instance = item.Table.GetFromCacheById(this.provider.Mapping.GetPrimaryKey(item.Entity, item.Instance));
                        if ((instance != null) && (instance != item.Instance))
                        {
                            TrackedItem trackedItem = item.Table.GetTrackedItem(instance);
                            if ((trackedItem != null) && (trackedItem.State == SubmitAction.Delete))
                            {
                                first = first.Concat <TrackedItem>(new TrackedItem[] { trackedItem });
                            }
                        }
                        return first;
                    }

                case SubmitAction.Delete:
                    return tsLookup[item];
                }
                return TrackedItem.EmptyList;
            }));
        }
コード例 #6
0
            private bool SubmitChanges(TrackedItem item)
            {
                switch (item.State)
                {
                case SubmitAction.Delete:
                    this.ProviderTable.Delete(item.Instance);
                    return(true);

                case SubmitAction.Insert:
                    this.ProviderTable.Insert(item.Instance);
                    return(true);

                case SubmitAction.InsertOrUpdate:
                    this.ProviderTable.InsertOrUpdate(item.Instance);
                    return(true);

                case SubmitAction.PossibleUpdate:
                    if (item.Original != null &&
                        this.Mapping.IsModified(item.Entity, item.Instance, item.Original))
                    {
                        this.ProviderTable.Update(item.Instance);
                        return(true);
                    }
                    break;

                case SubmitAction.Update:
                    this.ProviderTable.Update(item.Instance);
                    return(true);

                default:
                    break;     // do nothing
                }
                return(false);
            }
コード例 #7
0
            public Edge(TrackedItem source, TrackedItem target)
            {
                this.Source = source;
                this.Target = target;

                this.hash = this.Source.GetHashCode() + this.Target.GetHashCode();
            }
コード例 #8
0
        public async Task <ActionResult <TrackedItem> > PostTrackedItem(TrackedItem trackedItem)
        {
            _context.TrackedItems.Add(trackedItem);
            await _context.SaveChangesAsync();

            return(CreatedAtAction("GetTrackedItem", new { id = trackedItem.Id }, trackedItem));
        }
コード例 #9
0
 protected override void ClearItems()
 {
     if (!_suspendTracking)
     {
         _trackedItems.AddLast(new LinkedListNode <TrackedItem>(TrackedItem.Clear()));
     }
     base.ClearItems();
 }
コード例 #10
0
 protected override void SetItem(int index, T item)
 {
     if (!_suspendTracking)
     {
         _trackedItems.AddLast(new LinkedListNode <TrackedItem>(TrackedItem.Replace(Items[index], item, index)));
     }
     base.SetItem(index, item);
 }
コード例 #11
0
 protected override void InsertItem(int index, T item)
 {
     if (!_suspendTracking)
     {
         _trackedItems.AddLast(new LinkedListNode <TrackedItem>(TrackedItem.Insert(item, index)));
     }
     base.InsertItem(index, item);
 }
コード例 #12
0
 protected override void RemoveItem(int index)
 {
     if (!_suspendTracking)
     {
         _trackedItems.AddLast(new LinkedListNode <TrackedItem>(TrackedItem.Remove(Items[index], index)));
     }
     base.RemoveItem(index);
 }
コード例 #13
0
        // --- public ---

        public IPromise Track(Func <bool> condition)
        {
            var deferred = new Deferred();
            var item     = new TrackedItem(deferred, condition);

            Items.Add(item);

            return(deferred);
        }
コード例 #14
0
            protected virtual void OnPropertyChanging(object sender, PropertyChangingEventArgs args)
            {
                TrackedItem ti;

                if (tracked.TryGetValue((T)sender, out ti) && ti.State == SubmitAction.PossibleUpdate)
                {
                    object clone = Mapping.CloneEntity(ti.Entity, ti.Instance);
                    tracked[(T)sender] = new TrackedItem(this, ti.Instance, clone, SubmitAction.Update, true);
                }
            }
コード例 #15
0
 public void AddRange(IEnumerable <T> items)
 {
     _suspendTracking = true;
     _trackedItems.AddLast(new LinkedListNode <TrackedItem>(TrackedItem.Insert(items.ToArray(), Count)));
     foreach (var item in items)
     {
         Items.Add(item);
     }
     _suspendTracking = false;
 }
コード例 #16
0
ファイル: Tracker.cs プロジェクト: 2mas/EpisodeTracker
        public void UnTrack(long seriesId)
        {
            if (this.GetTrackedItems().Exists(d => d.SeriesId == seriesId))
            {
                TrackedItem item = this.Storage.GetStoreModel().TrackedItems.First(d => d.SeriesId == seriesId);
                this.Storage.GetStoreModel().TrackedItems.Remove(item);
            }

            SaveStoreModel();
        }
コード例 #17
0
        private void InventoryControl_MouseClick(object sender, MouseEventArgs e)
        {
            int row = e.Y / height_size;
            int col = e.X / width_size;

            if (row < 0)
            {
                row = 0;
            }
            if (col < 0)
            {
                col = 0;
            }
            if (col > 9)
            {
                col = 9;
            }
            int index = (row * 10) + col;

            if (ItemInventory.ContainsKey(index))
            {
                TrackedItem item = ItemInventory[index];
                if (LastSelectedItem == null || item != LastSelectedItem)
                {
                    LastSelectedItem = item;

                    //Clear our Highlighted Rectangles
                    HighlightedSquares.Clear();

                    //Add new Rectangle to Highlighted Collection
                    Rectangle r = new Rectangle(item.invCol * width_size, (item.invRow - row_reduction) * height_size, width_size, item.DetermineIsTwoSlot() ? height_size * 2 : height_size);
                    HighlightedSquares.Add(r);

                    //Raise Event!
                    if (OnItemSelected != null)
                    {
                        OnItemSelected(item);
                    }

                    //Invalidate (force repaint)
                    Invalidate();
                }



                if (e.Button == MouseButtons.Right)
                {
                    itemMenu.Show(MousePosition);
                }
            }
        }
コード例 #18
0
        /// <summary>
        /// Marks a series as seen, or all series
        /// </summary>
        /// <param name="seen"></param>
        internal static void SeenSeries(string seen)
        {
            int         number     = 0;
            List <long> episodeIds = new List <long>();

            if (seen.ToLower() != "all" && !Int32.TryParse(seen, out number))
            {
                Program.Output.WriteLine("Possible seen-arguments: 'all'/number");
                Program.Output.WriteLine();
                return;
            }

            var trackedItems = Program.episodeTracker.GetTrackedItems();

            if (trackedItems.Count > 0)
            {
                if (seen.ToLower() == "all")
                {
                    trackedItems.ForEach(x => episodeIds.AddRange(x.UnSeenEpisodes.Select(d => d.Id)));

                    Program.episodeTracker.MarkEpisodesAsSeen(episodeIds.ToArray());

                    Program.Output.WriteLine("Unseen episodes cleared for all series");
                    Program.Output.WriteLine();
                }
                else
                {
                    if (number > 0 && trackedItems.Count >= number)
                    {
                        TrackedItem trackedItem = trackedItems[--number];
                        episodeIds.AddRange(trackedItem.UnSeenEpisodes.Select(x => x.Id));

                        Program.episodeTracker.MarkEpisodesAsSeen(episodeIds.ToArray());

                        Program.Output.WriteLine($"Unseen episodes cleared for series: {trackedItem.Name }");
                        Program.Output.WriteLine();
                    }
                    else
                    {
                        Program.Output.WriteLine("Number out of range");
                        Program.Output.WriteLine();
                        return;
                    }
                }
            }
            else
            {
                Program.Output.WriteLine("Nothing tracked");
                Program.Output.WriteLine();
            }
        }
コード例 #19
0
            public async Task <bool> SubmitChangesAsync(TrackedItem item, CancellationToken cancellationToken)
            {
                switch (item.State)
                {
                case SubmitAction.Delete:
                {
                    await this.ProviderTable.DeleteAsync((T)item.Instance, cancellationToken).ConfigureAwait(false);

                    return(true);
                }

                case SubmitAction.Insert:
                {
                    await this.ProviderTable.InsertAsync((T)item.Instance, cancellationToken).ConfigureAwait(false);

                    return(true);
                }

                case SubmitAction.InsertOrUpdate:
                {
                    await this.ProviderTable.InsertOrUpdateAsync((T)item.Instance, cancellationToken).ConfigureAwait(false);

                    return(true);
                }

                case SubmitAction.PossibleUpdate:
                {
                    if (item.Original != null && this.Mapping.IsModified(item.Entity, item.Instance, item.Original))
                    {
                        await this.ProviderTable.UpdateAsync((T)item.Instance, cancellationToken).ConfigureAwait(false);

                        return(true);
                    }
                    break;
                }

                case SubmitAction.Update:
                {
                    await this.ProviderTable.UpdateAsync((T)item.Instance, cancellationToken).ConfigureAwait(false);

                    return(true);
                }

                default:
                {
                    break;         // do nothing
                }
                }

                return(false);
            }
コード例 #20
0
        public void DeleteTrackedItem(TrackedItem trackedItemToDelete)
        {
            //This maintains the cascase delete.
            var foundTrackedItem = _context.TrackedItems.Where(e => e.Id == trackedItemToDelete.Id)
                                   .Include(y => y.ProgressRecords)
                                   .FirstOrDefault();

            if (foundTrackedItem == null)
            {
                return;
            }

            _context.TrackedItems.Remove(foundTrackedItem);
        }
コード例 #21
0
        public Tracking(User user)
        {
            baseUser = user;

            for (int i = 0; i < 20; i++)
            {
                TrackableItem item = (TrackableItem)i;
                if (Database.HasTrackedItem(user.Id, item))
                {
                    TrackedItem trackedItem = new TrackedItem(baseUser, item, Database.GetTrackedCount(user.Id, item));
                    trackingItems.Add(trackedItem);
                }
            }
        }
コード例 #22
0
 private void EquipmentControl_MouseClick(object sender, MouseEventArgs e)
 {
     foreach (var rect in rectTrackedItems.Keys)
     {
         if (rect.Contains(e.Location))
         {
             LastSelectedItem = rectTrackedItems[rect];
             if (OnItemSelected != null)
             {
                 OnItemSelected(LastSelectedItem);
             }
         }
     }
 }
コード例 #23
0
        public TrackedItem GetTrackedItem(int trackedItemId)
        {
            var result = _context.TrackedItems.Where(ti => ti.Id == trackedItemId)
                         .Include(y => y.ProgressRecords)
                         .FirstOrDefault();

            if (result == null)
            {
                return(TrackedItem.GetNullObject());
            }
            else
            {
                return(result);
            }
        }
コード例 #24
0
            private void ApplyGeneratedKeyValues(TrackedItem item, object[] keyValues)
            {
                // remove from tracked item
                this.tracked.Remove((T)item.Instance);

                var generatedKeys = GetGeneratedKeys();

                for (int i = 0; i < generatedKeys.Length; i++)
                {
                    generatedKeys[i].SetValue((T)item.Instance, keyValues[i]);
                }

                // re-add tracked item to update its key
                this.tracked[(T)item.Instance] = item;
            }
コード例 #25
0
    void UpdateTrackedItems()
    {
        if (myCamera == null)
        {
            return;                           // Can't do anything without a camera
        }
        if (player == null)
        {
            ItemToTrack target;
            if (target = myCamera.GetComponentInParent <ItemToTrack>())
            {
                player = target.gameObject;
            }
            else
            {
                player = myCamera.gameObject;
            }
        }
        foreach (ItemToTrack item in GameObject.FindObjectsOfType <ItemToTrack>())
        {
            if (trackedItems.Contains(item) || item.gameObject == player)
            {
                // Ignore
            }
            else
            {
                // Add to list
                trackedItems.Add(item);
                switch (item.trackType)
                {
                case ItemToTrack.ItemTrackType.Generic:
                    GameObject  instancedObjectTracker = GameObject.Instantiate(trackedPlayerPrefab, trackedPlayerParent);
                    TrackedItem trackedObject          = instancedObjectTracker.GetComponent <TrackedItem>();
                    trackedObject.StartTracker(item.transform, myCamera);
                    break;

                case ItemToTrack.ItemTrackType.Player:
                    GameObject    instancedPlayerTracker = GameObject.Instantiate(trackedPlayerPrefab, trackedPlayerParent);
                    TrackedPlayer trackedPlayer          = instancedPlayerTracker.GetComponent <TrackedPlayer>();
                    trackedPlayer.StartTracker(item.transform, myCamera);
                    break;

                default:
                    break;
                }
            }
        }
    }
コード例 #26
0
        /// <summary>
        /// Occurs when a tracked item changes.
        /// </summary>
        /// <param name="sender">
        /// The sender.
        /// </param>
        /// <param name="e">
        /// The <see cref="System.ComponentModel.PropertyChangedEventArgs"/> instance containing the event data.
        /// </param>
        private void TrackedItemPropertyChanged(object sender, PropertyChangedEventArgs e)
        {
            TrackedItem <T> trackedItem = this.trackedItems.Find(t => t.Item.Equals(sender));

            switch (trackedItem.TrackingState)
            {
            case TrackingState.Unchanged:
                trackedItem.TrackingState = TrackingState.Changed;

                this.OnTrackingObservableCollectionChanged(new TrackingObservableCollectionChangedEventArgs(TrackingObservableCollectionChangedAction.ItemChanged));
                break;

            default:
                break;
            }
        }
コード例 #27
0
        /**
         * Returns a list of all players that has the item.
         */
        List <TrackedItem> findPlayerItems(String item, int min_amount)
        {
            var players     = UnityEngine.Object.FindObjectsOfType <BasePlayer>();
            var items_found = new List <TrackedItem>();

            if (players.Length == 0)
            {
                return(items_found);
            }

            List <Item> items = new List <Item>();
            TrackedItem t;

            foreach (BasePlayer player in players)
            {
                if (player != null)
                {
                    items.Clear();

                    items.AddRange(player.inventory.containerMain.itemList);
                    items.AddRange(player.inventory.containerBelt.itemList);
                    items.AddRange(player.inventory.containerWear.itemList);
                    t = new TrackedItem();

                    if (items.ToArray().Length > 0)
                    {
                        foreach (Item i in items)
                        {
                            if (i != null && i.info.displayName.english.ToLower().Equals(item.ToLower()))
                            {
                                t.container_name = player.displayName + (player.IsSleeping() ? "(Sleeping)" : "(Online)");
                                t.location       = (int)player.transform.position.x + " " + (int)player.transform.position.y + " " + (int)player.transform.position.z;
                                t.count         += i.amount;
                            }
                        }
                    }

                    if (t != null && t.count > 0 && t.count >= min_amount)
                    {
                        items_found.Add(t);
                    }
                }
            }

            return(items_found);
        }
コード例 #28
0
        public TrackedItem GetTrackedItem(TrackableItem what)
        {
            foreach (TrackedItem trackedItem in TrackingItems)
            {
                if (trackedItem.What == what)
                {
                    return(trackedItem);
                }
            }

            // if it doesnt exist- create it
            TrackedItem item = new TrackedItem(baseUser, what, 0);

            Database.AddTrackedItem(baseUser.Id, what, 0);
            trackingItems.Add(item);
            return(item);
        }
コード例 #29
0
            private bool SubmitChanges(TrackedItem item)
            {
                switch (item.State)
                {
                case SubmitAction.Delete:
                    this.Table.Delete(item.Instance);
                    return(true);

                case SubmitAction.Insert:
                    var generatedKeySelector = this.GetGeneratedKeySelector();

                    if (generatedKeySelector != null)
                    {
                        var keyValues = this.Table.Insert((T)item.Instance, generatedKeySelector);
                        ApplyGeneratedKeyValues(item, keyValues);
                    }
                    else
                    {
                        this.Table.Insert((T)item.Instance);
                    }

                    return(true);

                case SubmitAction.InsertOrUpdate:
                    this.Table.InsertOrUpdate(item.Instance);
                    return(true);

                case SubmitAction.PossibleUpdate:
                    if (item.Original != null &&
                        this.Mapping.IsModified(item.Entity, item.Instance, item.Original))
                    {
                        this.Table.Update(item.Instance);
                        return(true);
                    }
                    break;

                case SubmitAction.Update:
                    this.Table.Update(item.Instance);
                    return(true);

                default:
                    break;     // do nothing
                }

                return(false);
            }
コード例 #30
0
        /// <summary>
        /// Returns a list of Chests that have the item
        /// </summary>
        /// <param name="item">Item that is searched for</param>
        /// <param name="min_amount">Minimum amount searched for</param>
        /// <returns></returns>
        List <TrackedItem> findChestItems(String item, int min_amount, ConsoleSystem.Arg arg)
        {
            var containers  = UnityEngine.Object.FindObjectsOfType <StorageContainer>();
            var items_found = new List <TrackedItem>();

            if (containers.Length == 0)
            {
                SendReply(arg, lang.GetMessage("NO_CONTAINERS", this));
                return(items_found);
            }

            TrackedItem t;

            foreach (StorageContainer container in containers)
            {
                if (container != null && container.inventory != null)
                {
                    t = new TrackedItem();

                    if (container.inventory.itemList.ToArray().Length > 0)
                    {
                        foreach (Item i in container.inventory.itemList)
                        {
                            if (i != null && i.info.displayName.english.ToLower().Equals(item.ToLower()))
                            {
                                t.container_name = container.ShortPrefabName + " (Owner: " + container.OwnerID.ToString() + ")";
                                t.location       = (int)container.transform.position.x + " " + (int)container.transform.position.y + " " + (int)container.transform.position.z;
                                t.count         += i.amount;
                            }
                        }
                    }

                    if (t != null && t.count > 0 && t.count >= min_amount)
                    {
                        items_found.Add(t);
                    }
                }
            }

            return(items_found);
        }