public static void AddChangedEvent <TModel>(
            this IEvents events, params string[] changedPropertyNames) where TModel : Aggregate
        {
            var @event = new ModelChanged <TModel>(changedPropertyNames);

            events.Add(@event);
        }
Ejemplo n.º 2
0
        public void RestoreModel()
        {
            if (OriginalModel == null || Model == OriginalModel)
            {
                return;
            }

            var wasVisible = Model.IsVisible;

            Model.Hide();

            // Wait until floating combat text destroys.
            Destroy(Model.gameObject, 5);

            Model = OriginalModel;

            if (wasVisible)
            {
                Model.Show();
            }
            else
            {
                Model.Hide();
            }

            PlayAnimation(this.lastPlayedAnimation);

            ModelChanged?.Invoke(this);
        }
Ejemplo n.º 3
0
 /// <summary>
 /// Raises event 'ModelChanged'
 /// </summary>
 protected virtual void OnModelChanged()
 {
     if (ModelChanged != null)
     {
         ModelChanged.Invoke(this, System.EventArgs.Empty);
     }
 }
Ejemplo n.º 4
0
        private async void Query_ContentsChanged(IStorageQueryResultBase sender, object args)
        {
            try
            {
                var configFile = await StorageFile.GetFileFromApplicationUriAsync(new Uri("ms-appdata:///local/settings/terminal.json"));

                var content = await FileIO.ReadTextAsync(configFile);

                if (configContent != content)
                {
                    configContent = content;
                }
                else
                {
                    return;
                }

                await LoadAsync();
                await GetInstalledTerminalsAsync();

                ModelChanged?.Invoke(this);
            }
            catch
            {
                // ignored
            }
        }
Ejemplo n.º 5
0
        public void RaiseModelChangedEvent()
        {
            ModelChanged?.Invoke(this, new EditChangesEventArgs {
            });

            RaisePendingChangesEvent();
        }
Ejemplo n.º 6
0
 private void RaiseEvents([NotNull][ItemNotNull] IEnumerable <ModelEventBase> events)
 {
     foreach (var @event in events)
     {
         ModelChanged?.Invoke(@event);
     }
 }
Ejemplo n.º 7
0
    protected void cmbMakeModel_SelectedIndexChanged(object sender, EventArgs e)
    {
        int modelID = SelectedModelID;

        UpdateAttributesForModel(modelID == MakeModel.UnknownModel ? null : MakeModel.GetModel(modelID));
        ModelChanged?.Invoke(this, new MakeSelectedEventArgs(modelID));
    }
Ejemplo n.º 8
0
        public void Step()
        {
            var newGen = Stepper.GetNextGeneration(Data);

            Debug.Assert(newGen.GetLength(0) == Data.GetLength(0));
            Debug.Assert(newGen.GetLength(1) == Data.GetLength(1));

            bool changed = false;

            for (int row = 0; row < RowCount; row++)
            {
                for (int col = 0; col < ColCount; col++)
                {
                    if (Data[row, col] != newGen[row, col])
                    {
                        changed        = true;
                        Data[row, col] = newGen[row, col];
                    }
                }
            }

            if (changed)
            {
                var e = new ModelChangedEventArgs(EModelChangeType.Reset);
                ModelChanged?.Invoke(e);
            }
        }
Ejemplo n.º 9
0
 void Changed()
 {
     if (ModelChanged != null)
     {
         ModelChanged.Invoke();
     }
 }
Ejemplo n.º 10
0
        public void UpdateItem(int clientHandle, Dictionary <string, string> properties)
        {
            if (!properties.ContainsKey(ItemPropValueKey) ||
                !properties.ContainsKey(ItemPropQualityKey) ||
                !properties.ContainsKey(ItemPropTimestampKey))
            {
                throw new OpcItemException("The item can't be updated.", clientHandle.ToString());
            }

            if (!m_ClientHandleToItemDictionary.TryGetValue(clientHandle, out var item))
            {
                return;
            }

            properties.TryGetValue(ItemPropValueKey, out var value);
            properties.TryGetValue(ItemPropQualityKey, out var quality);
            properties.TryGetValue(ItemPropTimestampKey, out var timestamp);

            item.Value     = value;
            item.Quality   = quality;
            item.Timestamp = timestamp;

            var eventArgs = new ModelChangeEventArgs(ModelChangeEventType.Update,
                                                     item.ID, item.Type, value, quality, timestamp);

            ModelChanged?.Invoke(this, eventArgs);
        }
Ejemplo n.º 11
0
        public async Task InitializeAsync()
        {
            await LoadAsync();
            await GetInstalledTerminalsAsync();
            await StartWatchConfigChangeAsync();

            ModelChanged?.Invoke(this);
        }
Ejemplo n.º 12
0
 protected virtual void OnModelChanged(EventArgs e)
 {
     this.cursorPos = new TextPointer(model.CurrentPosition, 0, 0);
     this.anchorPos = cursorPos;
     ChangeLayout();
     UpdateScrollbar();
     ModelChanged.Fire(this);
 }
Ejemplo n.º 13
0
 public void ClearModel()
 {
     lock (ModelUpdateLockObject)
     {
         Model = Model.Clear();
         ModelChanged?.Invoke(new ModelClearedEvent(Model));
     }
 }
Ejemplo n.º 14
0
 public void AddRelationship(IModelRelationship relationship)
 {
     lock (ModelUpdateLockObject)
     {
         Model = Model.AddRelationship(relationship);
         ModelChanged?.Invoke(new ModelRelationshipAddedEvent(Model, relationship));
     }
 }
Ejemplo n.º 15
0
 protected void RaiseEvents([NotNull][ItemNotNull] IEnumerable <ModelEventBase> events)
 {
     // It is important to materialize the collection with ToList() to allow releasing ModelUpdateLockObject as soon as possible.
     foreach (var @event in events.ToList())
     {
         ModelChanged?.Invoke(@event);
     }
 }
Ejemplo n.º 16
0
 public void AddNode(IModelNode node)
 {
     lock (ModelUpdateLockObject)
     {
         Model = Model.AddNode(node);
         ModelChanged?.Invoke(new ModelNodeAddedEvent(Model, node));
     }
 }
Ejemplo n.º 17
0
 public void RemoveNode(ModelNodeId nodeId)
 {
     lock (ModelUpdateLockObject)
     {
         var oldNode = Model.GetNode(nodeId);
         Model = Model.RemoveNode(nodeId);
         ModelChanged?.Invoke(new ModelNodeRemovedEvent(Model, oldNode));
     }
 }
Ejemplo n.º 18
0
 public void UpdateNode(IModelNode newNode)
 {
     lock (ModelUpdateLockObject)
     {
         var oldNode = Model.GetNode(newNode.Id);
         Model = Model.ReplaceNode(newNode);
         ModelChanged?.Invoke(new ModelNodeUpdatedEvent(Model, oldNode, newNode));
     }
 }
Ejemplo n.º 19
0
 public void RemoveRelationship(ModelRelationshipId relationshipId)
 {
     lock (ModelUpdateLockObject)
     {
         var oldRelationship = Model.GetRelationship(relationshipId);
         Model = Model.RemoveRelationship(relationshipId);
         ModelChanged?.Invoke(new ModelRelationshipRemovedEvent(Model, oldRelationship));
     }
 }
        protected virtual void OnModelChanged()
        {
            foreach (Cell cell in Root.SelectMany(r => r))
            {
                cell.Parent = this;
            }

            ModelChanged?.Invoke(this, EventArgs.Empty);
        }
Ejemplo n.º 21
0
        internal void EmitModelChangeInfo(ModelChangeInfo changInfo)
        {
            Fx.Assert(changInfo != null, "changInfo should not be null");

            if (ModelChanged != null)
            {
                ModelChanged.Invoke(this, new ModelChangedEventArgsImpl(null, null, null, changInfo));
                modelTreeManager.SyncModelAndText();
            }
        }
Ejemplo n.º 22
0
 internal void OnModelItemsRemoved(IEnumerable <ModelItem> modelItems)
 {
     Fx.Assert(modelItems != null, "modelItem should not be null");
     if (ModelChanged != null)
     {
         List <ModelItem> modelItemsRemoved = new List <ModelItem>();
         modelItemsRemoved.AddRange(modelItems);
         ModelChanged.Invoke(this, new ModelChangedEventArgsImpl(null, modelItemsRemoved, null));
         modelTreeManager.SyncModelAndText();
     }
 }
Ejemplo n.º 23
0
 internal void OnModelItemRemoved(ModelItem modelItem, ModelChangeInfo changInfo)
 {
     Fx.Assert(modelItem != null, "modelItem should not be null");
     if (ModelChanged != null)
     {
         List <ModelItem> modelItemsRemoved = new List <ModelItem>(1);
         modelItemsRemoved.Add(modelItem);
         ModelChanged.Invoke(this, new ModelChangedEventArgsImpl(null, modelItemsRemoved, null, changInfo));
         modelTreeManager.SyncModelAndText();
     }
 }
Ejemplo n.º 24
0
        public async Task InitializeAsync()
        {
            await LoadAsync();
            await GetInstalledTerminalsAsync();
            await StartWatchConfigChangeAsync();

            CoreApplication.MainView.DispatcherQueue.TryEnqueue(() =>
            {
                ModelChanged?.Invoke(this);
            });
        }
Ejemplo n.º 25
0
        public void AddItem(int clientHandle, int serverHandle, Dictionary <string, string> properties)
        {
            if (!properties.ContainsKey(ItemPropIdKey) || !properties.ContainsKey(ItemPropTypeKey))
            {
                throw new OpcItemException("The item can't be added to the model.", clientHandle.ToString());
            }

            string value, quality, timestamp;

            properties.TryGetValue(ItemPropIdKey, out var id);
            properties.TryGetValue(ItemPropTypeKey, out var type);

            if (!properties.ContainsKey(ItemPropValueKey))
            {
                value = OpcUtility.ITEM_UNKNOWN;
            }
            else
            {
                properties.TryGetValue(ItemPropValueKey, out value);
            }

            if (!properties.ContainsKey(ItemPropQualityKey))
            {
                quality = OpcUtility.ITEM_UNKNOWN;
            }
            else
            {
                properties.TryGetValue(ItemPropQualityKey, out quality);
            }

            if (!properties.ContainsKey(ItemPropTimestampKey))
            {
                timestamp = OpcUtility.ITEM_UNKNOWN;
            }
            else
            {
                properties.TryGetValue(ItemPropTimestampKey, out timestamp);
            }

            IOPCItem item = new OPCItem(id, type)
            {
                Value     = value,
                Quality   = quality,
                Timestamp = timestamp
            };

            m_ItemIdToServerHandleDictionary.Add(item.ID, serverHandle);
            m_ClientHandleToItemDictionary.Add(clientHandle, item);
            m_ServerHandleToClientHandleDictionary.Add(serverHandle, clientHandle);

            var args = new ModelChangeEventArgs(ModelChangeEventType.Add, id, type, value, quality, timestamp);

            ModelChanged?.Invoke(this, args);
        }
        public bool TryUpdateModel(out string message)
        {
            if (ValidateFields(out message))
            {
                UpdateModel();
                ModelChanged?.Invoke(this, EventArgs.Empty);

                return(true);
            }

            return(false);
        }
Ejemplo n.º 27
0
    protected void cmbManufacturers_SelectedIndexChanged(object sender, EventArgs e)
    {
        int newManId = Convert.ToInt32(cmbManufacturers.SelectedValue, CultureInfo.InvariantCulture);

        if (newManId != LastSelectedManufacturer)
        {
            UpdateAttributesForModel(null);
            UpdateModelList(newManId);
            LastSelectedManufacturer = newManId;
            ModelChanged?.Invoke(this, new MakeSelectedEventArgs(SelectedModelID));
        }
    }
Ejemplo n.º 28
0
 internal void OnModelItemAdded(ModelItem modelItem, ModelChangeInfo changeInfo)
 {
     Fx.Assert(modelItem != null, "modelItem should not be null");
     if (ModelChanged != null)
     {
         Fx.Assert(modelItem != null, "trying to add empty model item");
         List <ModelItem> modelItemsAdded = new List <ModelItem>(1);
         modelItemsAdded.Add(modelItem);
         ModelChanged.Invoke(this, new ModelChangedEventArgsImpl(modelItemsAdded, null, null, changeInfo));
         modelTreeManager.SyncModelAndText();
     }
 }
        private RenderFragment BuildLink(ElementConstructModel model)
        {
            if (!(model is LinkConstructModel))
            {
                throw new ArgumentException(model.GetType().FullName);
            }

            RenderFragment RenderFragment(LinkConstructModel internalModel)
            {
                return(builder =>
                {
                    var index = 0;
                    builder.OpenElement(index++, "div");
                    builder.AddAttribute(index++, "class", "mat-elevation-z24");

                    builder.AddContent(index++, BuildFallback(internalModel, "Link"));
                    builder.OpenElement(index, "p");
                    builder.AddAttribute(index++, "class", "mat-subtitle2");
                    builder.AddContent(index++, "Link Content");
                    builder.CloseElement();

                    builder.OpenElement(index++, "input");
                    builder.AddAttribute(index++, "type", "input");
                    builder.AddAttribute(index++, "value", internalModel.Content);

                    builder.AddAttribute(index++, "onchange",
                                         EventCallback.Factory.CreateBinder(internalModel, value =>
                    {
                        internalModel.Content = value;
                        ModelChanged?.Invoke(this, internalModel);
                    },
                                                                            internalModel.Content));
                    builder.SetUpdatesAttributeName("value");

                    builder.AddAttribute(index++, "oninput",
                                         EventCallback.Factory.CreateBinder(internalModel, value =>
                    {
                        internalModel.Content = value;
                        ModelChanged?.Invoke(this, internalModel);
                    },
                                                                            internalModel.Content));
                    builder.SetUpdatesAttributeName("value");

                    builder.CloseElement();
                    builder.CloseElement();

                    builder.AddMarkupContent(index, "<hr />");
                });
            }

            return(RenderFragment((LinkConstructModel)model));
        }
Ejemplo n.º 30
0
 protected virtual void OnModelChanged(EventArgs e)
 {
     this.cursorPos = new TextPointer
     {
         Line      = model.StartPosition,
         Span      = 0,
         Character = 0
     };
     this.anchorPos = cursorPos;
     vScroll.Value  = 0;
     ChangeLayout();
     ModelChanged.Fire(this);
 }