Exemplo n.º 1
0
        public void Rename(int id, string name)
        {
            IHasResource res = this[id];

            res.Resource.Name = name;
            ResourceChanged?.Invoke(this, res);
        }
Exemplo n.º 2
0
 public void AddResource(ResourceDictionary resource)
 {
     ResourceChanged?.Invoke(this, new ResourcesChangedEventArgs()
     {
         NewResource = resource
     });
 }
Exemplo n.º 3
0
        /// <summary>
        /// <para>Creates and returns a new set of random data bytes.</para>
        /// <para>After this method returns, requests for the random data file
        /// should return the same bytes returned by this method.</para>
        /// </summary>
        /// <param name="newLength">The length of the new random data.</param>
        /// <returns>An array of bytes containing the new random data.</returns>
        /// <seealso cref="RandomDataUrlPath"/>
        /// <seealso cref="RandomDataLength"/>
        /// <seealso cref="GetRandomData"/>
        public byte[] ChangeRandomData(int newLength)
        {
            var data = CreateRandomData(newLength);

            _randomDataFile.SetData(data);
            ResourceChanged?.Invoke(RandomDataPath);
            return(data);
        }
Exemplo n.º 4
0
 public void AddResource(string path)
 {
     ResourceChanged?.Invoke(this, new ResourcesChangedEventArgs()
     {
         NewResource = new ResourceDictionary()
         {
             Source = new Uri(path)
         }
     });
 }
Exemplo n.º 5
0
        public bool Remove(int id)
        {
            if (!Resources.ContainsKey(id))
            {
                return(false);
            }

            Resources.Remove(id);
            ResourceChanged?.Invoke(this, null);
            return(true);
        }
Exemplo n.º 6
0
        public ushort Add(IHasResource res)
        {
            int id = NextResourceId;

            if (NextResourceId == 0 || NextResourceId > ushort.MaxValue)
            {
                throw new IndexOutOfRangeException($"Too many resources.");
            }

            res.Resource.ID = (ushort)id;
            Resources[id]   = res;

            ResourceChanged?.Invoke(this, res);
            return((ushort)id);
        }
Exemplo n.º 7
0
        public void AddResource(string path)
        {
            if (!File.Exists(path))
            {
                ToolbarLogger.GetLogger("EverythingToolbar").Error("Could not find resource file " + path);
                return;
            }

            ResourceChanged?.Invoke(this, new ResourcesChangedEventArgs()
            {
                NewResource = new ResourceDictionary()
                {
                    Source = new Uri(path)
                }
            });
        }
Exemplo n.º 8
0
        public void AddTrait(Trait item)
        {
            if (item == null)
            {
                throw new ArgumentNullException(nameof(item));
            }

            if (!traits.Contains(item))
            {
                traits.Add(item);
            }
            item.AttributeChanged += (sender, args) =>
            {
                AttributeChanged?.Invoke(this, args);
            };
            item.ResourceChanged += (sender, args) =>
            {
                ResourceChanged?.Invoke(this, args);
            };
            item.ValueChanged += (sender, args) =>
            {
                ValueChanged?.Invoke(this, args);
            };
            item.TaWChanged += (sender, args) =>
            {
                TaWChanged?.Invoke(this, args);
            };
            item.ATChanged += (sender, args) =>
            {
                ATChanged?.Invoke(this, args);
            };
            item.PAChanged += (sender, args) =>
            {
                PAChanged?.Invoke(this, args);
            };
            item.APInvestChanged += (sender, args) =>
            {
                APInvestChanged?.Invoke(this, GetAPInvested());
            };
            item.APEarnedChanged += (sender, args) =>
            {
                APEarnedChanged?.Invoke(this, GetAPEarned());
            };

            CallChangedAll(item);
        }
        public bool AddResource(string type, string name)
        {
            string assemblyFolder = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location);
            string path           = Path.Combine(assemblyFolder, type, name + ".xaml");

            if (!File.Exists(path))
            {
                ToolbarLogger.GetLogger("EverythingToolbar").Error("Could not find resource file " + path);
                return(false);
            }

            ResourceChanged?.Invoke(this, new ResourcesChangedEventArgs()
            {
                NewResource = new ResourceDictionary()
                {
                    Source = new Uri(path)
                }
            });
            return(true);
        }
Exemplo n.º 10
0
 /// <summary>
 /// AResource classes must use this to indicate the resource has changed.
 /// </summary>
 /// <param name="sender">The resource (or sub-class) that has changed.</param>
 /// <param name="e">(Empty) event data object.</param>
 protected virtual void OnResourceChanged(object sender, EventArgs e)
 {
     dirty = true;
     //Console.WriteLine(this.GetType().Name + " dirtied.");
     ResourceChanged?.Invoke(sender, e);
 }
Exemplo n.º 11
0
 public void UpdateIron(float amount)
 {
     IronOre.Value += amount;
     ResourceChanged?.Invoke(ResourceType.IRON, IronOre.Value);
     ConsoleManger.Instance.DisplayNotification($"Aquired x{amount} Iron!");
 }
Exemplo n.º 12
0
 private void Start()
 {
     ResourceChanged?.Invoke(ResourceType.WOOD, Wood.Value);
     ResourceChanged?.Invoke(ResourceType.STONE, Stone.Value);
     ResourceChanged?.Invoke(ResourceType.IRON, IronOre.Value);
 }
Exemplo n.º 13
0
 public void ReduceResource(ResourceType type, float amount)
 {
     dictionary[type].Value -= amount;
     ResourceChanged?.Invoke(type, GetResource(type));
 }
Exemplo n.º 14
0
 public void NotifyChange(Resource resource, string propertyName)
 {
     ResourceChanged?.Invoke(this, new ResourceChangedEventArgs(resource, propertyName));
 }
 private void OnResourceChanged(ResourceChangedEventArgs args)
 {
     ResourceChanged?.Invoke(this, args);
 }
Exemplo n.º 16
0
 protected virtual void OnResourceChanged(ResourceChangedEventArgs e)
 {
     ResourceChanged?.Invoke(this, e);
 }
Exemplo n.º 17
0
 public void UpdateWood(float amount)
 {
     Wood.Value += amount;
     ResourceChanged?.Invoke(ResourceType.WOOD, Wood.Value);
     ConsoleManger.Instance.DisplayNotification($"Aquired x{amount} Wood!");
 }
Exemplo n.º 18
0
 /// <summary>
 /// Appelé lorsque la valeur de le propriété <see cref="Resource"/> a changé.
 /// </summary>
 /// <param name="oldValue">L'ancienne valeur.</param>
 /// <param name="newValue">La nouvelle valeur.</param>
 protected virtual void OnResourceChanged(bool oldValue, bool newValue) =>
 ResourceChanged?.Invoke(this, new PropertyChangedEventArgs <bool>(oldValue, newValue));
Exemplo n.º 19
0
 public void UpdateStone(float amount)
 {
     Stone.Value += amount;
     ResourceChanged?.Invoke(ResourceType.STONE, Stone.Value);
     ConsoleManger.Instance.DisplayNotification($"Aquired x{amount} Stone!");
 }