示例#1
0
        protected override void OnEntitiesChanged(object key, Type changedType, EntityMessageType messageType, object sender)
        {
            if (sender == MainViewModel)
            {
                return;
            }

            if (loadPROJECT != null && changedType == typeof(BluePrints.Data.PROJECT) && loadPROJECT.GUID.ToString() == key.ToString())
            {
                if (messageType == EntityMessageType.Added)
                {
                    MessageBoxService.ShowMessage(string.Format(CommonResources.Notify_View_Restored, StringFormatUtils.GetEntityNameByType(changedType)));
                }
                else if (messageType == EntityMessageType.Deleted)
                {
                    MessageBoxService.ShowMessage(string.Format(CommonResources.Notify_View_Removed, StringFormatUtils.GetEntityNameByType(changedType)));
                }
            }

            if (loadPROJECT != null)
            {
                if (MainViewModel != null)
                {
                    mainThreadDispatcher.BeginInvoke(new Action(() => MainViewModel.Refresh()));
                }
                else if (loadPROJECT != null)
                {
                    mainThreadDispatcher.BeginInvoke(new Action(() => InitializeAndLoadEntitiesLoaderDescription()));
                }
            }
        }
示例#2
0
 /// <summary>
 /// Stores undo/redo property information
 /// </summary>
 /// <param name="entityHashCode">Hash code of the property instance</param>
 /// <param name="propertyName">Name of the property</param>
 /// <param name="oldValue">Old value of the property</param>
 /// <param name="newValue">New value of the property</param>
 /// <param name="actionId">Undo/Redo action id</param>
 /// <param name="messageType">Action to take when undoing/redoing</param>
 public UndoRedoEntityInfo(TEntity changedEntity, string propertyName, object oldValue, object newValue, int actionId, EntityMessageType messageType)
 {
     ChangedEntity = changedEntity;
     PropertyName  = propertyName;
     OldValue      = oldValue;
     NewValue      = newValue;
     ActionId      = actionId;
     MessageType   = messageType;
 }
示例#3
0
 public void HandleMessage(EntityMessageType msg, object data = null)
 {
     foreach (var tileEntityComponent in components)
     {
         tileEntityComponent.HandleMessage(msg, data);
     }
     if (this.OnEntityMessage != null)
     {
         this.OnEntityMessage(this, msg, data);
     }
 }
        protected override void OnEntitiesChanged(object key, Type changedType, EntityMessageType messageType, object sender)
        {
            if (sender == MainViewModel || sender == this)
            {
                return;
            }

            if (loadPROJECT != null)
            {
                mainThreadDispatcher.BeginInvoke(new Action(() => InitializeAndLoadEntitiesLoaderDescription()));
            }
        }
示例#5
0
 public override void HandleMessage(EntityMessageType msg, object data = null)
 {
     switch (msg)
     {
     case EntityMessageType.MakeDamage:
         float damage      = (float)data;
         int   stolenCount = CalcStealableCountForDamage(damage);
         if (stolenCount > 0)
         {
             BattleManager.Instance.StolenResource(new ResourceVO()
             {
                 resourceType = Entity.model.resourceType, resourceCount = stolenCount
             });
         }
         break;
     }
 }
示例#6
0
        protected override void OnEntitiesChanged(object key, Type changedType, EntityMessageType messageType, object sender)
        {
            //Map the changes from PROGRESS_ITEM to BASELINE_ITEM so undo/redo operation is valid
            if (changedType == typeof(PROGRESS_ITEM))
            {
                PROGRESS_ITEMProjection mappedEntity = MainViewModel.Entities.FirstOrDefault(x => x.PROGRESS_ITEMCurrent != null && x.PROGRESS_ITEMCurrent.GUID.ToString() == key.ToString());
                mainThreadDispatcher.BeginInvoke(new Action(() => Messenger.Default.Send(new EntityMessage <BASELINE_ITEM, Guid>(mappedEntity.GUID, EntityMessageType.Changed, this))));
                return;
            }

            if (sender == this)
            {
                return;
            }

            if (loadPROGRESS != null && changedType == typeof(PROGRESS) && loadPROGRESS.GUID.ToString() == key.ToString() ||
                loadBASELINE != null && changedType == typeof(BASELINE) && loadBASELINE.GUID.ToString() == key.ToString() ||
                loadPROJECT != null && changedType == typeof(BluePrints.Data.PROJECT) && loadPROJECT.GUID.ToString() == key.ToString())
            {
                if (messageType == EntityMessageType.Added)
                {
                    MessageBoxService.ShowMessage(string.Format(CommonResources.Notify_View_Restored, StringFormatUtils.GetEntityNameByType(changedType)));
                }
                else if (messageType == EntityMessageType.Deleted)
                {
                    MessageBoxService.ShowMessage(string.Format(CommonResources.Notify_View_Removed, StringFormatUtils.GetEntityNameByType(changedType)));
                }
            }

            if (loadPROJECT != null || loadBASELINE != null || loadPROGRESS != null)
            {
                if (MainViewModel != null)
                {
                    mainThreadDispatcher.BeginInvoke(new Action(() => MainViewModel.Refresh()));
                }
                else if (loadPROJECT != null || loadBASELINE != null)
                {
                    mainThreadDispatcher.BeginInvoke(new Action(() => InitializeAndLoadEntitiesLoaderDescription()));
                }
            }
        }
示例#7
0
 /// <summary>
 /// Initializes a new instance of the EntityMessage class.
 /// </summary>
 /// <param name="primaryKey">A primary key of an entity that has been added, removed or modified.</param>
 /// <param name="messageType">An entity state change notification type.</param>
 public EntityMessage(TPrimaryKey primaryKey, EntityMessageType messageType)
 {
     this.PrimaryKey  = primaryKey;
     this.MessageType = messageType;
 }
示例#8
0
 public virtual void HandleMessage(EntityMessageType msg, object data = null)
 {
 }
示例#9
0
 protected override void OnEntitiesChanged(object key, Type changedType, EntityMessageType messageType, object sender)
 {
 }
示例#10
0
 /// <summary>
 /// Initializes a new instance of the EntityMessage class.
 /// </summary>
 /// <param name="primaryKey">A primary key of an entity that has been added, removed or modified.</param>
 /// <param name="messageType">An entity state change notification type.</param>
 /// /// <param name="sender">The message sender.</param>
 public EntityMessage(TPrimaryKey primaryKey, EntityMessageType messageType, object sender = null)
 {
     this.PrimaryKey  = primaryKey;
     this.MessageType = messageType;
     this.Sender      = sender;
 }
示例#11
0
 /// <summary>
 /// Adds a property from the view to the undo list
 /// </summary>
 /// <param name="entityHashCode">Hash code of the property instance</param>
 /// <param name="propertyName">Name of the property</param>
 /// <param name="oldValue">Old value of the property</param>
 /// <param name="newValue">New value of the property</param>
 /// <param name="actionId">Undo/Redo action id</param>
 /// <param name="messageType">Action to take when undoing/redoing</param>
 public void AddUndo(TEntity changedEntity, string propertyName, object oldValue, object newValue, EntityMessageType messageType)
 {
     UndoList.Add(new UndoRedoEntityInfo <TEntity>(changedEntity, propertyName, oldValue, newValue, ActionId, messageType));
     RedoList.Clear();
 }
 protected virtual void OnEntitiesChanged(object key, Type changedType, EntityMessageType messageType, object sender)
 {
     throw new NotImplementedException("Override this method to reload or refresh the main view model.");
 }
 /// <summary>
 ///     Initializes a new instance of the EntityMessage class.
 /// </summary>
 /// <param name="entity">An entity that has been added, deleted or modified.</param>
 /// <param name="messageType">An entity state change notification type.</param>
 public EntityMessage(TEntity entity, EntityMessageType messageType)
 {
     Entity      = entity;
     MessageType = messageType;
 }
 public EntityMessage(TEntity entity, EntityMessageType messageType)
 {
     this.Entity      = entity;
     this.MessageType = messageType;
 }