示例#1
0
 void Changed()
 {
     if (ModelChanged != null)
     {
         ModelChanged.Invoke();
     }
 }
示例#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);
        }
示例#3
0
 private void RaiseEvents([NotNull][ItemNotNull] IEnumerable <ModelEventBase> events)
 {
     foreach (var @event in events)
     {
         ModelChanged?.Invoke(@event);
     }
 }
示例#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
            }
        }
示例#5
0
        public void RaiseModelChangedEvent()
        {
            ModelChanged?.Invoke(this, new EditChangesEventArgs {
            });

            RaisePendingChangesEvent();
        }
示例#6
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);
        }
示例#7
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);
            }
        }
示例#8
0
 /// <summary>
 /// Raises event 'ModelChanged'
 /// </summary>
 protected virtual void OnModelChanged()
 {
     if (ModelChanged != null)
     {
         ModelChanged.Invoke(this, System.EventArgs.Empty);
     }
 }
示例#9
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));
    }
示例#10
0
        public async Task InitializeAsync()
        {
            await LoadAsync();
            await GetInstalledTerminalsAsync();
            await StartWatchConfigChangeAsync();

            ModelChanged?.Invoke(this);
        }
示例#11
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);
     }
 }
示例#12
0
 public void ClearModel()
 {
     lock (ModelUpdateLockObject)
     {
         Model = Model.Clear();
         ModelChanged?.Invoke(new ModelClearedEvent(Model));
     }
 }
示例#13
0
 public void AddRelationship(IModelRelationship relationship)
 {
     lock (ModelUpdateLockObject)
     {
         Model = Model.AddRelationship(relationship);
         ModelChanged?.Invoke(new ModelRelationshipAddedEvent(Model, relationship));
     }
 }
示例#14
0
 public void AddNode(IModelNode node)
 {
     lock (ModelUpdateLockObject)
     {
         Model = Model.AddNode(node);
         ModelChanged?.Invoke(new ModelNodeAddedEvent(Model, node));
     }
 }
示例#15
0
 public void RemoveNode(ModelNodeId nodeId)
 {
     lock (ModelUpdateLockObject)
     {
         var oldNode = Model.GetNode(nodeId);
         Model = Model.RemoveNode(nodeId);
         ModelChanged?.Invoke(new ModelNodeRemovedEvent(Model, oldNode));
     }
 }
示例#16
0
 public void RemoveRelationship(ModelRelationshipId relationshipId)
 {
     lock (ModelUpdateLockObject)
     {
         var oldRelationship = Model.GetRelationship(relationshipId);
         Model = Model.RemoveRelationship(relationshipId);
         ModelChanged?.Invoke(new ModelRelationshipRemovedEvent(Model, oldRelationship));
     }
 }
示例#17
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));
     }
 }
        protected virtual void OnModelChanged()
        {
            foreach (Cell cell in Root.SelectMany(r => r))
            {
                cell.Parent = this;
            }

            ModelChanged?.Invoke(this, EventArgs.Empty);
        }
示例#19
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();
            }
        }
示例#20
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();
     }
 }
示例#21
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();
     }
 }
示例#22
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);
        }
示例#23
0
        public async Task InitializeAsync()
        {
            await LoadAsync();
            await GetInstalledTerminalsAsync();
            await StartWatchConfigChangeAsync();

            CoreApplication.MainView.DispatcherQueue.TryEnqueue(() =>
            {
                ModelChanged?.Invoke(this);
            });
        }
        public bool TryUpdateModel(out string message)
        {
            if (ValidateFields(out message))
            {
                UpdateModel();
                ModelChanged?.Invoke(this, EventArgs.Empty);

                return(true);
            }

            return(false);
        }
示例#25
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));
        }
    }
示例#26
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));
        }
示例#28
0
        internal void OnModelPropertyChanged(ModelProperty property, ModelChangeInfo changeInfo)
        {
            Fx.Assert(property != null, "property cannot be null");
            Fx.Assert(changeInfo != null, "changeInfo cannot be null");

            if (ModelChanged != null)
            {
                List <ModelProperty> propertiesChanged = new List <ModelProperty>(1);
                propertiesChanged.Add(property);
                ModelChanged.Invoke(this, new ModelChangedEventArgsImpl(null, null, propertiesChanged, changeInfo));
                modelTreeManager.SyncModelAndText();
            }
        }
示例#29
0
        protected virtual void OnModelChanged()
        {
            if (_logicalChildrenReadOnly != null)
            {
                _logicalChildrenReadOnly = null;
            }

            foreach (Cell cell in Root.SelectMany(r => r))
            {
                cell.Parent = this;
            }

            ModelChanged?.Invoke(this, EventArgs.Empty);
        }
示例#30
0
        public virtual void SetModel(IListModel <T> value, double vpos)
        {
            if (model == value)
            {
                return;
            }

            if (model != null)
            {
                model.Cleared  -= OnModelClearedHandler;
                model.Reloaded -= OnModelReloadedHandler;
            }

            model = value;

            if (model != null)
            {
                model.Cleared           += OnModelClearedHandler;
                model.Reloaded          += OnModelReloadedHandler;
                SelectionProxy.Selection = model.Selection;
                IsEverReorderable        = model.CanReorder;
            }

            if (ViewLayout != null)
            {
                ViewLayout.Model = Model;
            }

            var sortable = model as ISortable;

            if (sortable != null && ColumnController != null)
            {
                var sort_column = ColumnController.SortColumn ?? ColumnController.DefaultSortColumn;
                if (sort_column != null)
                {
                    if (sortable.Sort(sort_column))
                    {
                        model.Reload();
                    }
                    RecalculateColumnSizes();
                    RegenerateColumnCache();
                    InvalidateHeader();
                    IsReorderable = sortable.SortColumn == null || sortable.SortColumn.SortType == SortType.None;
                }
            }

            RefreshViewForModel(vpos);

            ModelChanged?.Invoke(this, EventArgs.Empty);
        }