protected override void WndProc(ref Message m) { switch (m.Msg) { case 0x308: { ChangedEventHandler changedEvent = this.ChangedEvent; if (changedEvent != null) { changedEvent(this); } SendMessage(this.ID, m.Msg, m.WParam, m.LParam); break; } case 0x30d: if (!(m.WParam == this.ID)) { SendMessage(this.ID, m.Msg, m.WParam, m.LParam); break; } this.ID = m.LParam; break; } base.WndProc(ref m); }
protected virtual void Dispose(bool disposing) { if (!disposedValue) { if (disposing) { try { } finally { comunicator.OnRequest -= onServerRequest; comunicator?.Dispose(); if (event55Wtch?.Dependancy != null) { event55Wtch.Dependancy.OnChanged -= onChangedEvent55EventHandler; event55Wtch.Dependancy.OnStatusChanged -= onStatusChanged; event55Wtch.Dependancy.OnError -= onError; event55Wtch.Dispose(); event55Wtch = null; } eventService?.Dispose(); eventService = null; onChangedEvent55EventHandler = null; } } Log.Trace($"Disposed: {ToString()}"); disposedValue = true; } }
public ServerForm() { IPAddress[] localIPs = Dns.GetHostAddresses(Dns.GetHostName()); foreach (var ip in localIPs) { if (ip.ToString().IndexOf('.') > 0) { Variable.IP = ip.ToString(); } } //Variable.IP = "127.0.0.1"; InitializeComponent(); this.Text = "Trọng tài chính: " + Variable.IP + ":" + Variable.PORT; tcpServers = new TcpServers(this); Variable.SERVERSERVICES = new List<ServerService>(); Variable.THREADS = new List<Thread>(); // Add Event to handle when a client is connected Changed += new ChangedEventHandler(tcpServers.ClientAdded); tcpServers.StartServer(); //tmrServer.Enabled = true; }
public GUIQuestion(QLMemory memory, string identifier, string label, bool isComputed, ExpressionBase showCondition, ChangedEventHandler changeHandler) { _hideConditions = new List<ExpressionBase>(); _showCondition = showCondition; _memory = memory; _identifier = identifier; _isComputed = isComputed; _label = new Label { Content = label, Width = 300, Margin = new Thickness(0, 0, 25, 0), HorizontalContentAlignment = HorizontalAlignment.Right }; _input = _memory.GetDeclaredValue(_identifier).CreateInputControl(_identifier, _memory, _isComputed); _input.OnChanged = changeHandler; //ui properties Width = 600; Margin = new Thickness(0, 10, 0 , 0); Orientation = Orientation.Horizontal; }
public RouteMap() { InitializeComponent(); Changed += new ChangedEventHandler(routeService_CalculateRouteCompleted); endThread = false; getRoute(); }
public void AddHandler(ChangedEventHandler handler) { if (handler != null) { this.handlers.Add(handler); } }
public static void Main(string[] args) { for (var i = 0; i < 10; i++) { Changed = null; switch (new Random().Next(2)) { case 0: Changed += new ChangedEventHandler(m1); break; case 1: Changed += new ChangedEventHandler(m2); break; case 2: Changed += new ChangedEventHandler(m3); break; default: Changed += new ChangedEventHandler(m4); break; } Changed(null, new Args()); Console.ReadKey(); } }
void Test_LambdaDiscard_StaticLambda_Compliant() { ChangedEventHandler x = (_, _) => { }; Changed += x; Changed -= x; ChangedEventHandler2 y = static (sender) => { };
public Form1() { InitializeComponent(); Changed += new ChangedEventHandler(ClientAdded); TreeNode node = tvClientList.Nodes.Add("Connected Clients"); //tvClientList }
/// <summary> /// Invokes the 'ImageSizeChanged' event handler. /// </summary> /// <param name="e">Event arguments.</param> protected virtual void OnImageSizeChanged(ChangedEventArgs <ImageSize> e) { ChangedEventHandler <ImageSize> handler = ImageSizeChanged; if (handler != null) { ImageSizeChanged(this, e); } }
protected virtual void OnContentChanged(EventArgs e) { ChangedEventHandler handler = ContentChanged; if (handler != null) { handler(this.tab, e); } }
public void Test3() { ChangedEventHandler a = null; a += CreateNewRobot; RobotCommand res = a(new List <Robot.Common.Robot>(), 1, new Map()); Assert.AreEqual(new CreateNewRobotCommand(), res); }
public void Test4() { ChangedEventHandler a = null; a += Move; RobotCommand res = a(new List <Robot.Common.Robot>(), 1, new Map()); Assert.AreEqual(new MoveCommand(), res); }
protected virtual void DoOnChange(BlockStructure blockStructure) { ChangedEventHandler handler = OnChange; if (handler != null) { handler(blockStructure); } }
public void Test1() { ChangedEventHandler a = null; a += CollectEnergy; RobotCommand res = a(new List <Robot.Common.Robot>(), 1, new Map()); Assert.AreEqual(new CollectEnergyCommand(), res); }
void Test() { Changed += (obj, args) => { }; Changed -= (obj, args) => { }; //Noncompliant Changed -= (obj, args) => Console.WriteLine(); // Noncompliant - single statement Changed -= (obj, args) => delegate() { }; // Noncompliant Changed2 -= obj => delegate() { }; // Noncompliant ChangedEventHandler x = (obj, args) => { }; Changed -= x; }
public KinectGestures() { rightHandRotatedRightWays += new ChangedEventHandler(LeftHandRotateHandler); _sensor = KinectSensor.GetDefault(); timer.Interval = 100; timer.Elapsed += Timer_Tick; //timer.Start(); _bodyReader = _sensor.BodyFrameSource.OpenReader(); _bodyReader.FrameArrived += _bodyReader_FrameArrived; _sensor.Open(); }
void Test() { Changed += (obj, args) => { }; Changed -= (obj, args) => { }; //Noncompliant {{Unsubscribe with the same delegate that was used for the subscription.}} // ^^^^^^^^^^^^^^^^^^^^^ Changed -= (obj, args) => Console.WriteLine(); // Noncompliant - single statement // ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ Changed -= delegate(object sender, EventArgs e) { }; // Noncompliant Changed2 -= delegate { }; // Noncompliant ChangedEventHandler x = (obj, args) => { }; Changed -= x; }
internal IReactive[] UpdateReactionDependencies(IReactive[] oldDependencies, ChangedEventHandler dataChanged) { if (_nextDependencyIndex < _currentDependencies.Length) { if (_newDependencies != null) { throw new Exception("_newDependencies unexpectedly initialized when _nextDependencyIndex is before the end"); } _newDependencies = new List <IReactive>(); for (int i = 0; i < _nextDependencyIndex; ++i) { _newDependencies.Add(_currentDependencies[i]); } } IReactive[] newDependenciesArray = _newDependencies !.ToArray(); var currDependenciesSet = new HashSet <IReactive>(); foreach (IReactive currDependency in oldDependencies) { currDependenciesSet.Add(currDependency); } var newDependenciesSet = new HashSet <IReactive>(); foreach (IReactive newDependency in newDependenciesArray) { newDependenciesSet.Add(newDependency); } // TODO: Catch exceptions here to ensure in consistent state foreach (IReactive removeDependency in currDependenciesSet.Except(newDependenciesSet)) { removeDependency.Changed -= dataChanged; } foreach (IReactive addDependency in newDependenciesArray.Except(currDependenciesSet)) { addDependency.Changed += dataChanged; } return(newDependenciesArray); }
/// <summary> /// Constructor. It adds event to handle when client is connected and Initializes Tree View. /// </summary> public Form1() { InitializeComponent(); // Add Event to handle when a client is connected Changed += new ChangedEventHandler(ClientAdded); // Add node in Tree View TreeNode node; node = tvClientList.Nodes.Add("Connected Clients"); ImageList il = new ImageList(); // il.Images.Add(new Icon("audio.ico")); il.Images.Add(new Icon("messenger.ico")); tvClientList.ImageList = il; node.ImageIndex = 1; }
/// <summary> /// Constructor: adds event to handle when the /// client is connected and initalises tree view. /// </summary> public StaffChatForm(StaffModel s) { InitializeComponent(); staffMember = s; //Set the controls TextBoxServerStatus.BackColor = Color.Red; ButtonStopServer.Enabled = false; //Add event to handle when a client is connected Changed += new ChangedEventHandler(ClientAdded); //Create the first tree node TreeNode node; node = TreeViewClientList.Nodes.Add("Open chats"); node.Name = "OriginalNode"; }
public void HandleWhenChanged <TProperty>(Expression <Func <TNotifyingObject, TProperty> > propertyPathExpression, ChangedEventHandler <TProperty> propertyChangedHandler) { List <string> propertyPathList = new List <string>(); MemberExpression memberExpression = (MemberExpression)propertyPathExpression.Body; int count = 0; while (memberExpression != null) { propertyPathList.Add(memberExpression.Member.Name); count++; memberExpression = memberExpression.Expression as MemberExpression; } string[] propertyPath = new string[count]; for (int i = 0, j = count - 1; i < count; i++, j--) { propertyPath[i] = propertyPathList[j]; } HandleWhenChanged(propertyChangedHandler, 0, propertyPath); }
//private Dictionary<ushort, bool> UnfinishedWork = new Dictionary<ushort, bool>(); //private object UnfinishedWorkLock = new object(); public RtuHelper(RTUSerialPort[] ports, ChangedEventHandler handler, int baudrate = 9600, Parity parity = Parity.Even, int dataBits = 8, StopBits stopBits = StopBits.One) { mPorts = ports; if (mPorts.Count() <= 0) { throw new ArgumentOutOfRangeException("串口为空"); } else { clients = new SerialPort[mPorts.Count()]; masters = new ModbusSerialMaster[mPorts.Count()]; RtuConnected = new bool[mPorts.Count()]; mBaudrate = baudrate; mDataBits = dataBits; mParity = parity; mStopBits = stopBits; ValueUpdatedRequest += handler; Connect(); } }
public EventsWatcher(AConfiguration conf, CancellationToken token) { cancellationToken = token; // setup comunication with bot servers comunicator.ServersUrls = conf.ServersUrls; comunicator.OnRequest += onServerRequest; comunicator.ConnectSubscribers(); // create service for interecting with data eventService = new EventService(conf.ConnectionString, cancellationToken); event55Wtch = new EntitieWatcher <Event55>(conf.ConnectionString, filter: event55 => event55.EventCode == 105); onChangedEvent55EventHandler = new ChangedEventHandler <Event55>(async(s, e) => await onChanged(s, e)); event55Wtch.Dependancy.OnChanged += onChangedEvent55EventHandler; event55Wtch.Dependancy.OnStatusChanged += onStatusChanged; event55Wtch.Dependancy.OnError += onError; event55Wtch.Start(); }
public void RemoveLastCluster() { if (_clusterAddresses.Count == 0) { throw new InvalidOperationException(); } _clusterAddresses.RemoveAt(_clusterAddresses.Count - 1); _isModified.RemoveAt(_isModified.Count - 1); ChangedEventHandler h = _notifyChangedDelegates[_notifyChangedDelegates.Count - 1]; _notifyChangedDelegates.RemoveAt(_notifyChangedDelegates.Count - 1); int start = (_clusterAddresses.Count - 1) * _elementsPerCluster; for (int i = start; i < start + _elementsPerCluster; i++) { if (_elements[i] != null) { _elements[i].Changed -= h; } } _elements.RemoveRange(start, _elementsPerCluster); }
public void Callbacks_can_be_removed() { var reactor = new Reactor(); var inputCell1 = reactor.CreateInputCell(1); var computeCell1 = reactor.CreateComputeCell(new[] { inputCell1 }, (values) => values[0] + 1); var observed1 = new List <int>(); var observed2 = new List <int>(); ChangedEventHandler changedHandler1 = (object sender, int value) => observed1.Add(value); ChangedEventHandler changedHandler2 = (object sender, int value) => observed2.Add(value); computeCell1.Changed += changedHandler1; computeCell1.Changed += changedHandler2; inputCell1.Value = 2; Assert.That(observed1, Is.EquivalentTo(new[] { 3 })); Assert.That(observed2, Is.EquivalentTo(new[] { 3 })); computeCell1.Changed -= changedHandler1; inputCell1.Value = 3; Assert.That(observed1, Is.EquivalentTo(new[] { 3 })); Assert.That(observed2, Is.EquivalentTo(new[] { 3, 4 })); }
public void HandleWhenChanged <TProperty>(ChangedEventHandler <TProperty> propertyChangedHandler, int propertyPathPos, params string[] propertyPath) { int pathCount = propertyPath.Length - propertyPathPos; string currentpathPropertyName = propertyPath[propertyPathPos]; if (pathCount > 1) { var propertyInfo = this.GetType().GetProperty(currentpathPropertyName); var propertyType = propertyInfo.PropertyType; Type iNotifyingObjectType = typeof(INotifyingObject); //var notifyingObjectType = typeof(NotifyingObject<>); if (iNotifyingObjectType.IsAssignableFrom(propertyType)) { INotifyingObject childNotifyingObject = (INotifyingObject)propertyInfo.GetValue(this, null); if (childNotifyingObject != null) { childNotifyingObject.HandleWhenChanged(propertyChangedHandler, propertyPathPos + 1, propertyPath); } else { PropertyEventsPath currentPropertyEventsPath; if (_propertiesEvents == null) { _propertiesEvents = new Dictionary <string, PropertyEventsPath>(); currentPropertyEventsPath = new PropertyEventsPath(); _propertiesEvents.Add(currentpathPropertyName, currentPropertyEventsPath); } else { currentPropertyEventsPath = _propertiesEvents.GetValueOrAddIfNotExists(currentpathPropertyName, () => new PropertyEventsPath()); } for (int pathPos = propertyPathPos, i = 1; i < pathCount; pathPos++, i++) { PropertyEventsPath child; if (currentPropertyEventsPath.PropertiesEvents == null) { currentPropertyEventsPath.PropertiesEvents = new Dictionary <string, PropertyEventsPath>(); child = new PropertyEventsPath(); currentPropertyEventsPath.PropertiesEvents.Add(propertyPath[pathPos], child); } else { child = currentPropertyEventsPath.PropertiesEvents.GetValueOrAddIfNotExists(propertyPath[pathPos], () => new PropertyEventsPath()); } currentPropertyEventsPath = child; } if (currentPropertyEventsPath.Events == null) { currentPropertyEventsPath.Events = new List <Delegate>(); } currentPropertyEventsPath.Events.Add(propertyChangedHandler); } } else { throw new InvalidOperationException(string.Format( "You can't specify a property that has a parent type which is not derived from NotifyingObject<{0}>. " + "Details: The type \"{0}\" is not derived from NotifyingObject<{0}>", propertyType.FullName)); } } else { PropertyEventsPath currentPropertyEventsPath; if (_propertiesEvents == null) { _propertiesEvents = new Dictionary <string, PropertyEventsPath>(); currentPropertyEventsPath = new PropertyEventsPath(); currentPropertyEventsPath.Events = new List <Delegate>(); _propertiesEvents.Add(currentpathPropertyName, currentPropertyEventsPath); } else { currentPropertyEventsPath = _propertiesEvents.GetValueOrAddIfNotExists(currentpathPropertyName, () => new PropertyEventsPath()); if (currentPropertyEventsPath.Events == null) { currentPropertyEventsPath.Events = new List <Delegate>(); } } currentPropertyEventsPath.Events.Add(propertyChangedHandler); } }
public GUIQuestion(QLMemory memory, string identifier, string label, bool isComputed, ExpressionBase showCondition, ChangedEventHandler changeHandler) { _hideConditions = new List <ExpressionBase>(); _showCondition = showCondition; _memory = memory; _identifier = identifier; _isComputed = isComputed; _label = new Label { Content = label, Width = 300, Margin = new Thickness(0, 0, 25, 0), HorizontalContentAlignment = HorizontalAlignment.Right }; _input = _memory.GetDeclaredValue(_identifier).CreateInputControl(_identifier, _memory, _isComputed); _input.OnChanged = changeHandler; //ui properties Width = 600; Margin = new Thickness(0, 10, 0, 0); Orientation = Orientation.Horizontal; }
public static void AddToNotify(ChangedEventHandler changedEventHandler) { _reactionsToNotify !.Add(changedEventHandler); }
public void setEvent() { // use Changed, disable warning ChangedEventHandler t = Changed; }
public void HandleWhenChanged <TProperty>(ChangedEventHandler <TProperty> propertyChangedHandler, params string[] propertyPath) { HandleWhenChanged(propertyChangedHandler, 0, propertyPath); }
public void AddHandlersWithLoad(ChangedEventHandler changedEventHandler, LoadFinishedEventHandler loadFinishedEventHandler, PersistFinishedEventHandler persistFinishedEventHandler) { #if (CHATTY_DEBUG) string msg = "*** HRA OBJECT AddHandlersWithLoad on : " + this.ToString() + System.Environment.NewLine; if (changedEventHandler != null) { msg += "By: " + changedEventHandler.Target.ToString(); } else if (loadFinishedEventHandler != null) { msg += "By: " + loadFinishedEventHandler.Target.ToString(); } else if (persistFinishedEventHandler != null) { msg += "By: " + persistFinishedEventHandler.Target.ToString(); } Logger.Instance.DebugToLog(msg); #endif if (changedEventHandler != null) { if (Changed == null) { Changed += changedEventHandler; } else { bool ok = true; foreach (Delegate d in Changed.GetInvocationList()) { if (d.Target == changedEventHandler.Target) { ok = false; } } if (ok) { Changed += changedEventHandler; } } } if (loadFinishedEventHandler != null) { if (Loaded == null) { Loaded += loadFinishedEventHandler; } else { bool ok = true; foreach (Delegate d in Loaded.GetInvocationList()) { if (d.Target == loadFinishedEventHandler.Target) { ok = false; } } if (ok) { Loaded += loadFinishedEventHandler; } } } if (persistFinishedEventHandler != null) { if (Persisted == null) { Persisted += persistFinishedEventHandler; } else { bool ok = true; foreach (Delegate d in Persisted.GetInvocationList()) { if (d.Target == persistFinishedEventHandler.Target) { ok = false; } } if (ok) { Persisted += persistFinishedEventHandler; } } } switch (HraState) { case States.Null: LoadObject(); break; case States.Loading: break; case States.Ready: if (loadFinishedEventHandler != null) { RunWorkerCompletedEventArgs dummy = new RunWorkerCompletedEventArgs(this, null, false); #if (CHATTY_DEBUG) string msg2 = "*** HRA OBJECT loadFinishedEventHandler Firing on : " + this.ToString() + System.Environment.NewLine; msg2 += "FOR " + loadFinishedEventHandler.Target.ToString(); Logger.Instance.DebugToLog(msg2); #endif loadFinishedEventHandler.Invoke(null, dummy); } break; } }
public void AddHandlersWithLoad(ChangedEventHandler changedEventHandler, LoadFinishedEventHandler loadFinishedEventHandler, PersistFinishedEventHandler persistFinishedEventHandler) { #if (CHATTY_DEBUG) string msg = "*** HRA OBJECT AddHandlersWithLoad on : " + this.ToString() + System.Environment.NewLine; if (changedEventHandler != null) msg+= "By: " + changedEventHandler.Target.ToString(); else if (loadFinishedEventHandler != null) msg += "By: " + loadFinishedEventHandler.Target.ToString(); else if (persistFinishedEventHandler != null) msg += "By: " + persistFinishedEventHandler.Target.ToString(); Logger.Instance.DebugToLog(msg); #endif if (changedEventHandler != null) { if (Changed == null) Changed += changedEventHandler; else { bool ok = true; foreach (Delegate d in Changed.GetInvocationList()) { if (d.Target == changedEventHandler.Target) ok = false; } if (ok) Changed += changedEventHandler; } } if (loadFinishedEventHandler != null) { if (Loaded == null) Loaded += loadFinishedEventHandler; else { bool ok = true; foreach (Delegate d in Loaded.GetInvocationList()) { if (d.Target == loadFinishedEventHandler.Target) ok = false; } if (ok) Loaded += loadFinishedEventHandler; } } if (persistFinishedEventHandler != null) { if (Persisted == null) Persisted += persistFinishedEventHandler; else { bool ok = true; foreach (Delegate d in Persisted.GetInvocationList()) { if (d.Target == persistFinishedEventHandler.Target) ok = false; } if (ok) Persisted += persistFinishedEventHandler; } } switch (HraState) { case States.Null: LoadObject(); break; case States.Loading: break; case States.Ready: if (loadFinishedEventHandler != null) { RunWorkerCompletedEventArgs dummy = new RunWorkerCompletedEventArgs(this, null, false); #if (CHATTY_DEBUG) string msg2 = "*** HRA OBJECT loadFinishedEventHandler Firing on : " + this.ToString() + System.Environment.NewLine; msg2 += "FOR " + loadFinishedEventHandler.Target.ToString(); Logger.Instance.DebugToLog(msg2); #endif loadFinishedEventHandler.Invoke(null, dummy); } break; } }