Beispiel #1
0
        public void Can_execute_attribute_changed()
        {
            var entity = new Entity("entity")
            {
                Id = Guid.NewGuid(),
                ["xts_attribute"] = new Money(200m)
            };

            var txEntity = new TransactionContextEntity <Entity>(entity);

            Entity senderEntity          = null;
            AttributeChangedEventArgs ev = null;
            Money value = null;

            txEntity.AttributeChanged += (sender, e) =>
            {
                senderEntity = (Entity)sender;
                ev           = e;
                value        = ((Entity)sender).GetAttributeValue <Money>(e.AttributeName);
            };

            txEntity["xts_attribute"] = new Money(450m);

            Assert.Equal(entity, senderEntity);
            Assert.Null(ev.PropertyName);
            Assert.Equal("xts_attribute", ev.AttributeName);
            Assert.Equal(450m, value.Value);
        }
Beispiel #2
0
        public void Can_execute_attribute_changed()
        {
            var entity = new MsGenerated.Account
            {
                Id          = Guid.NewGuid(),
                CreditLimit = new Money(200m)
            };

            var txEntity = new TransactionContextEntity <MsGenerated.Account>(entity);

            Entity senderEntity          = null;
            AttributeChangedEventArgs ev = null;
            Money value = null;

            txEntity.AttributeChanged += (sender, e) =>
            {
                senderEntity = (Entity)sender;
                ev           = e;
                value        = ((Entity)sender).GetAttributeValue <Money>(e.AttributeName);
            };

            txEntity.Entity.CreditLimit = new Money(450m);

            Assert.Equal(entity, senderEntity);
            Assert.Equal("CreditLimit", ev.PropertyName);
            Assert.Equal("creditlimit", ev.AttributeName);
            Assert.Equal(450m, value.Value);
        }
Beispiel #3
0
        private void Core_AttributeChanged(object sender, AttributeChangedEventArgs e)
        {
            // Show some debug info with attribute changes.
            string name = e.Object is Thing ? ((Thing)e.Object).Name : e.Object.ToString();

            System.Diagnostics.Debug.WriteLine("AttributeChanged: " + name + "." + e.PropertyName);
        }
Beispiel #4
0
        } // end RenameFiles

        #endregion

        #region Event Handlers

        #region SendRenamedFileToLog

        /// <summary>
        /// Sends a file renamed message inorder to log it.
        /// </summary>
        /// <param name="sender">Object throwing the event</param>
        /// <param name="e">Event arguements relating to a the File renaming operation</param>
        private void SendRenamedFileToLog(object sender, AttributeChangedEventArgs e)
        {
            if (FileRenamed != null)
            {
                FileRenamed.Invoke(sender, e);
            }
        } // end SendRenamedFileToLog
 public void AttributeChanged(AttributeChangedEventArgs e)
 {
     this.output.Clear();
     this.output.Append("Attribute Changed: " + e.XPath);
     this.output.Append(e.LeftAttribute.Value + " " + e.LeftLineNumber);
     this.output.Append(Environment.NewLine);
     this.writeToFile(this.output.ToString());
 }
Beispiel #6
0
        public void AttributeChanged(AttributeChangedEventArgs e)
        {
            Console.WriteLine("<>A: {0}", e.XPath);
            Console.WriteLine("  o: {0,-8}: {1}", e.LeftLineNumber, e.LeftAttribute.Value);
            Console.WriteLine("  n: {0,-8}: {1}", e.RightLineNumber, e.RightAttribute.Value);

            Console.WriteLine();
        }
        public void AttributeChanged(AttributeChangedEventArgs e)
        {
            Console.WriteLine("<>A: {0}", e.XPath);
            Console.WriteLine("  o: {0,-8}: {1}", e.LeftLineNumber, e.LeftAttribute.Value);
            Console.WriteLine("  n: {0,-8}: {1}", e.RightLineNumber, e.RightAttribute.Value);

            Console.WriteLine();
        }
Beispiel #8
0
 /// <summary>
 /// 序列化
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 public void SerializeObject(object sender, AttributeChangedEventArgs e)
 {
     if (Directory.Exists(jsonFile) == false) //如果不存在就创建文件夹
     {
         Directory.CreateDirectory(jsonFile);
     }
     File.WriteAllText(jsonFile + this.name + ".json", JsonConvert.SerializeObject((sender as Scanner)));
 }
Beispiel #9
0
 /// <summary>
 /// Is called, when an attribute changed event of an objecty occures.
 /// </summary>
 /// <param name="sender">Sender.</param>
 /// <param name="e">Event arguments.</param>
 private void OnAttributeChanged(Object sender, AttributeChangedEventArgs e)
 {
     // The easiest way is to redraw all screens
     if (engine != null)
     {
         Refresh();
     }
 }
Beispiel #10
0
 public void OnAttributeChanged(object sender, AttributeChangedEventArgs e)
 {
     if (properties.Contains(e.PropertyName))
     {
         if (e.Object is Zone)
         {
             CreateZone(e.Object as Zone);
         }
     }
 }
Beispiel #11
0
        private static void UpdateFormattedValue(object entity, AttributeChangedEventArgs e)
        {
            var source = (Entity)entity;
            var value  = source[e.AttributeName];

            if (value is EntityReference reference && reference.Name != null)
            {
                source.FormattedValues[e.AttributeName] = reference.Name;
            }
        }
Beispiel #12
0
        private void attrValue_Changed(object sender, AttributeChangedEventArgs e)
        {
            var time = Parent?.GetCurrentClockTime();

            if (time != null)
            {
                System.Diagnostics.Debug.WriteLine("Value time: " + time.Value);
            }
            TimeValue = new TimeLocatedValue <double>(_attrValue.TypedGet(), time ?? TimeStamp.Zero);
        }
Beispiel #13
0
        private void MapShapeLayer_AttributeChanged(object sender, AttributeChangedEventArgs e)
        {
            var col = this.colorizerCache as ChoroplethColorizer;

            if (col != null && col.AttributeName == e.AttributeName)
            {
                this.EvaluateShapeStyles();
            }

            if (e.AttributeName == this.labelAttributeNameCache)
            {
                this.OnLabelAttributeChanged(sender as MapShapeModel);
            }
        }
Beispiel #14
0
        /// <summary>
        /// Recalculating plan and summary page after change of a <see cref="AttributesOptimizerControl"/>.
        /// </summary>
        /// <param name="sender">The source of the event.</param>
        /// <param name="e">The <see cref="AttributeChangedEventArgs"/> instance containing the event data.</param>
        private void AttributesOptimizationControl_AttributeChanged(object sender, AttributeChangedEventArgs e)
        {
            AttributesOptimizerControl control = (AttributesOptimizerControl)sender;

            if (m_strategy == AttributeOptimizationStrategy.RemappingPoints)
            {
                m_remappingDictionary[control] = e.Remapping;
                UpdateSummaryInformation(m_remappingDictionary.Values);
            }

            m_statisticsScratchpad = e.Remapping.BestScratchpad.Clone();
            m_remapping            = e.Remapping;

            // Update the plan order's column
            m_planEditor.ShowWithPluggable(this);
        }
 public void AttributeChanged(AttributeChangedEventArgs e)
 {
     Console.WriteLine("<>A: {0}", e.XPath);
     Console.WriteLine("  o: {0,-8}: {1}", e.LeftLineNumber, e.LeftAttribute.Value);
     Console.WriteLine("  n: {0,-8}: {1}", e.RightLineNumber, e.RightAttribute.Value);
     Console.WriteLine();
     Differences.Add(new ReportData()
     {
         DifferenceType  = DifferenceType.AttributeChange,
         Xpath           = e.XPath,
         LeftLineNumber  = e.LeftLineNumber,
         RightLineNumber = e.RightLineNumber,
         OldValue        = e.LeftAttribute.Value,
         NewValue        = e.RightAttribute.Value
     });
 }
        } // end ShowRenamingPropertiesForm

        #endregion

        #region AddRenamedFileToLog

        /// <summary>
        /// Adds the renamed file to the log textbox for informative purposes.
        /// </summary>
        /// <param name="sender">Object throwing the event</param>
        /// <param name="e">Event arguements relating to a the File renaming operation</param>
        private void AddRenamedFileToLog(object sender, AttributeChangedEventArgs e)
        {
            if (InvokeRequired)
            {
                Invoke(new FileRenamedEventHandler(AddRenamedFileToLog), sender, e);
            }
            else
            {
                _txtLog.AppendText(e.ToString() + Environment.NewLine);
                _txtLog.SelectionLength = 0;
                _txtLog.ScrollToCaret();

                if (!e.LogOnly)
                {
                    _prgRenaming.Value = (++_iFilesRenamed * 100) / _sFileNames.Length;
                }
            }
        } // end AddRenamedFileToLog
Beispiel #17
0
        private void _numOfLines1D_Changed(object sender, AttributeChangedEventArgs e)
        {
            var countShouldBe = _attrNumOfLines1D.TypedGet();
            var countIs       = _lines.Count(line => line.Port.DataType == PortDataTypes.TypeIdSignal1D);

            if (countIs < countShouldBe)
            {
                for (int i = countIs; i < countShouldBe; i++)
                {
                    CreateLine(PortDataTypes.TypeIdSignal1D);
                }
            }
            else if (countIs > countShouldBe)
            {
                for (int i = countShouldBe; i < countIs; i++)
                {
                    RemoveLine(_lines.Last(line => line.Port.DataType == PortDataTypes.TypeIdSignal1D));
                }
            }

            BuildDataLineView();
        }
Beispiel #18
0
        private void ctlAttributes_AttributeChanged(object sender, AttributeChangedEventArgs e)
        {
            switch (e.Name)
            {
            case "Strength":
                this.Avatar.Strength = e.NewValue;
                break;

            case "Dexterity":
                this.Avatar.Dexterity = e.NewValue;
                break;

            case "Stamina":
                this.Avatar.Stamina = e.NewValue;
                break;

            case "Beauty":
                this.Avatar.Beauty = e.NewValue;
                break;

            case "Intelligence":
                this.Avatar.Intelligence = e.NewValue;
                break;

            case "Perception":
                this.Avatar.Perception = e.NewValue;
                break;

            case "Endurance":
                this.Avatar.Endurance = e.NewValue;
                break;

            case "Affinity":
                this.Avatar.Affinity = e.NewValue;
                break;
            }
            this.SetAvatar();
        }
Beispiel #19
0
 void Fields_AttributeChanged(object sender, AttributeChangedEventArgs e)
 {
     if (Changed != null) Changed(this, new EventArgs());
 }
		private void Core_AttributeChanged(object sender, AttributeChangedEventArgs e)
		{
			// Show some debug info with attribute changes.
			string name = e.Object is Thing ? ((Thing)e.Object).Name : e.Object.ToString();
			System.Diagnostics.Debug.WriteLine("AttributeChanged: " + name + "." + e.PropertyName);
		}
Beispiel #21
0
 protected virtual void OnAttributeChanged(AttributeChangedEventArgs e)
 {
     AttributeChanged?.Invoke(this, e);
 }
Beispiel #22
0
 void MetaFields_AttributeChangedSilent(object sender, AttributeChangedEventArgs e)
 {
     m_worldModel.NotifyElementMetaFieldUpdate(this, e.Property, e.Value, true);
 }
Beispiel #23
0
 void Fields_AttributeChangedSilent(object sender, AttributeChangedEventArgs e)
 {
     // used by the Editor to receive notifications of updates when undoing
     if (e.InheritedTypesSet)
     {
         m_worldModel.NotifyElementRefreshed(this);
     }
     else
     {
         m_worldModel.NotifyElementFieldUpdate(this, e.Property, e.Value, true);
     }
 }
Beispiel #24
0
        private void _attrFuncName_Changed(object sender, AttributeChangedEventArgs e)
        {
            for (int i = InputPorts.Count - 1; i >= 0; i--)
            {
                RemovePort(InputPorts[i]);
            }
            for (int i = OutputPorts.Count - 1; i >= 0; i--)
            {
                RemovePort(OutputPorts[i]);
            }

            if (string.IsNullOrEmpty(_attrFuncName.TypedGet()))
            {
                return;
            }

            if (_matlab == null)
            {
                if (!TryFindMatlab())
                {
                    Parent.Context.Notify(new GraphNotification(GraphNotification.NotificationType.Warning, "No matlab instance found. Make sure to enable the automation server:\nenableservice('AutomationServer', true)"));
                    return;
                }
            }

            var funcHeader = FindFunction();

            if (funcHeader == null)
            {
                Parent.Context.Notify(new GraphNotification(GraphNotification.NotificationType.Warning, $"Function {_attrFuncName.TypedGet()} not found or uses unsupported syntax in function header"));
                return;
            }

            foreach (var param in funcHeader.Parameters)
            {
                if (param.StartsWith("data"))
                {
                    var port = new NodeSystemLib2.FormatData1D.InputPortData1D(this, param.Substring("data".Length));
                    port.SamplerateChanged += Port_SamplerateChanged;
                }
                else if (param.StartsWith("value"))
                {
                    new NodeSystemLib2.FormatValue.InputPortValueDouble(this, param.Substring("value".Length));
                }
                else
                {
                    Parent.Context.Notify(new GraphNotification(GraphNotification.NotificationType.Warning, $"Unknown type of port: {param}"));
                }
            }

            foreach (var param in funcHeader.ReturnValues)
            {
                if (param.StartsWith("data"))
                {
                    new NodeSystemLib2.FormatData1D.OutputPortData1D(this, param.Substring("data".Length));
                }
                else if (param.StartsWith("value"))
                {
                    new NodeSystemLib2.FormatValue.OutputPortValueDouble(this, param.Substring("value".Length));
                }
                else if (param.StartsWith("used_"))
                {
                    // used count
                }
                else
                {
                    Parent.Context.Notify(new GraphNotification(GraphNotification.NotificationType.Warning, $"Unknown type of return value: {param}"));
                }
            }
        }
Beispiel #25
0
		public void OnAttributeChanged(object sender,  AttributeChangedEventArgs e)
		{
			if (properties.Contains(e.PropertyName)) {
				if (e.Object is Zone)
					CreateZone(e.Object as Zone);
			}
		}
		/// <summary>
		/// Is called, when an attribute changed event of an objecty occures.
		/// </summary>
		/// <param name="sender">Sender.</param>
		/// <param name="e">Event arguments.</param>
		private void OnAttributeChanged(Object sender, AttributeChangedEventArgs e)
		{
			// The easiest way is to redraw all screens
			if (engine != null)
				Refresh ();
		}
Beispiel #27
0
 void Fields_AttributeChanged(object sender, AttributeChangedEventArgs e)
 {
     m_worldModel.NotifyElementFieldUpdate(this, e.Property, e.Value, false);
     if (!m_worldModel.EditMode)
     {
         string changedScript = "changed" + e.Property;
         if (Fields.HasType<IScript>(changedScript))
         {
             m_worldModel.RunScript(Fields.GetAsType<IScript>(changedScript));
         }
     }
 }
 private void _attr_Changed(object sender, AttributeChangedEventArgs e)
 {
     Changed?.Invoke(this, new PropertyGridRowChangedEventArgs());
 }
Beispiel #29
0
		/// <summary>
		/// Raises the attribute changed event.
		/// </summary>
		/// <param name="sender">Sender of event.</param>
		/// <param name="e">Attribute changed event arguments.</param>
		public void OnAttributeChanged(object sender, AttributeChangedEventArgs e)
		{
			if (e.Object is UIObject)
			{
				this.RaiseDisplayChanged("Property", (UIObject)e.Object, e.PropertyName);
			}
		}
		void Core_AttributeChanged(object sender, AttributeChangedEventArgs e)
		{
			string name = e.Object is Thing ? ((Thing)e.Object).Name : e.Object.ToString();
			System.Diagnostics.Debug.WriteLine("AttributeChanged: " + name + "." + e.PropertyName);
		}