public void ReturnFalseIfStringDoesNotStartWithValue() { var e = new SystemEvent { Message = " Start of Message" }; var extendedProperties = new FakeExtendedProperties { { "property", "Message" }, { "value", "Start" } }; var filter = new StartsWithFilter(extendedProperties, Enumerable.Empty<ICreateFilterExpressions>()); Assert.False(Filter.Compile(filter).Invoke(e)); }
public void ReturnTrueIfStringContainsValue() { var e = new SystemEvent { Message = "Start Message End" }; var extendedProperties = new FakeExtendedProperties { { "property", "Message" }, { "value", "Message" } }; var filter = new ContainsFilter(extendedProperties, Enumerable.Empty<ICreateFilterExpressions>()); Assert.True(Filter.Compile(filter).Invoke(e)); }
public void CanHaveNullProperty() { var e = new SystemEvent { Message = null }; var extendedProperties = new FakeExtendedProperties { { "property", "Message" }, { "value", "Message" } }; var filter = new ContainsFilter(extendedProperties, Enumerable.Empty<ICreateFilterExpressions>()); Assert.False(Filter.Compile(filter).Invoke(e)); }
public void CanHaveNullValue() { var e = new SystemEvent { Message = "Start of Message" }; var extendedProperties = new FakeExtendedProperties { { "property", "Message" }, { "value", null } }; var filter = new StartsWithFilter(extendedProperties, Enumerable.Empty<ICreateFilterExpressions>()); Assert.True(Filter.Compile(filter).Invoke(e)); }
public void ValueCanBeString() { var e = new SystemEvent { Message = "My Message" }; var extendedProperties = new FakeExtendedProperties { { "property", "Message" }, { "value", "My Message" } }; var filter = new EqualFilter(extendedProperties, Enumerable.Empty<ICreateFilterExpressions>()); Assert.True(Filter.Compile(filter).Invoke(e)); }
public void ValueCanBeInt32() { var e = new SystemEvent { ProcessId = 123 }; var extendedProperties = new FakeExtendedProperties { { "property", "ProcessId" }, { "value", "123" } }; var filter = new EqualFilter(extendedProperties, Enumerable.Empty<ICreateFilterExpressions>()); Assert.True(Filter.Compile(filter).Invoke(e)); }
public void ReturnFalseIfNoChildFilters() { var e = new SystemEvent(); var extendedProperties = new FakeExtendedProperties { { "property", "Level" }, { "value", "Warning" } }; var filter = new NotFilter(extendedProperties, Enumerable.Empty<ICreateFilterExpressions>()); Assert.False(Filter.Compile(filter).Invoke(e)); }
public void ReturnTrueIfLessThanOrEqual() { var e = new SystemEvent { ProcessId = 50 }; var extendedProperties = new FakeExtendedProperties { { "property", "ProcessId" }, { "value", "50" } }; var filter = new LessThanOrEqualFilter(extendedProperties, Enumerable.Empty<ICreateFilterExpressions>()); Assert.True(Filter.Compile(filter).Invoke(e)); }
public void ValueCanBeUInt32() { var e = new SystemEvent(); var extendedProperties = new FakeExtendedProperties { { "property", "MessageId" }, { "value", e.MessageId.ToString(CultureInfo.InvariantCulture) } }; var filter = new EqualFilter(extendedProperties, Enumerable.Empty<ICreateFilterExpressions>()); Assert.True(Filter.Compile(filter).Invoke(e)); }
public void AlwaysCaseInsensitive() { var e = new SystemEvent { Message = "Start MESSAGE End" }; var extendedProperties = new FakeExtendedProperties { { "property", "Message" }, { "value", "Message" } }; var filter = new ContainsFilter(extendedProperties, Enumerable.Empty<ICreateFilterExpressions>()); Assert.True(Filter.Compile(filter).Invoke(e)); }
public void ReturnFalseIfSingleChildFilterFalse() { var e = new SystemEvent { Level = SystemEventLevel.Error }; var extendedProperties = new FakeExtendedProperties { { "property", "Level" }, { "value", "Warning" } }; var filter = new OrElseFilter(new FakeExtendedProperties(), new[] { new EqualFilter(extendedProperties, Enumerable.Empty<ICreateFilterExpressions>()) }); Assert.False(Filter.Compile(filter).Invoke(e)); }
public void ReturnTrueIfEqual() { var e = new SystemEvent { Level = SystemEventLevel.Warning }; var extendedProperties = new FakeExtendedProperties { { "property", "Level" }, { "value", "Warning" } }; var filter = new EqualFilter(extendedProperties, Enumerable.Empty<ICreateFilterExpressions>()); Assert.True(Filter.Compile(filter).Invoke(e)); }
public void ReturnFalseIfNotGreaterThan() { var e = new SystemEvent { ProcessId = 50 }; var extendedProperties = new FakeExtendedProperties { { "property", "ProcessId" }, { "value", "50" } }; var filter = new GreaterThanFilter(extendedProperties, Enumerable.Empty<ICreateFilterExpressions>()); Assert.False(Filter.Compile(filter).Invoke(e)); }
public void ValueCanBeDateTime() { var now = DateTime.Now; var e = new SystemEvent { Timestamp = new DateTime(now.Year, now.Month, now.Day, now.Hour, now.Minute, now.Second) }; var extendedProperties = new FakeExtendedProperties { { "property", "Timestamp" }, { "value", now.ToString("yyyy-MM-dd HH:mm:ss") } }; var filter = new EqualFilter(extendedProperties, Enumerable.Empty<ICreateFilterExpressions>()); Assert.True(Filter.Compile(filter).Invoke(e)); }
public void ReturnTrueIfAnyChildFilterTrue() { var e = new SystemEvent { Level = SystemEventLevel.Warning, ProcessId = 1234, Thread = "Main" }; var filter = new OrElseFilter( new FakeExtendedProperties(), new[] { new EqualFilter(new FakeExtendedProperties { { "property", "ProcessId" }, { "value", "1234" } }, Enumerable.Empty<ICreateFilterExpressions>()), new EqualFilter(new FakeExtendedProperties { { "property", "Thread" }, { "value", "Unknown" } }, Enumerable.Empty<ICreateFilterExpressions>()), new EqualFilter(new FakeExtendedProperties { { "property", "Level" }, { "value", "Error" } }, Enumerable.Empty<ICreateFilterExpressions>()) }); Assert.True(Filter.Compile(filter).Invoke(e)); }
private static Char GetLevel(SystemEvent e) { switch (e.Level) { case SystemEventLevel.Fatal: return('F'); case SystemEventLevel.Error: return('E'); case SystemEventLevel.Warning: return('W'); case SystemEventLevel.Information: return('I'); case SystemEventLevel.Debug: return('D'); default: return('T'); } }
public GammaService(SettingsService settingsService) { _settingsService = settingsService; // Register for all system events that may indicate that device context or gamma has changed from outside _eventRegistration = Disposable.Aggregate( PowerSettingNotification.TryRegister( PowerSettingNotification.ConsoleDisplayStateId, InvalidateGamma ) ?? Disposable.Null, PowerSettingNotification.TryRegister( PowerSettingNotification.PowerSavingStatusId, InvalidateGamma ) ?? Disposable.Null, PowerSettingNotification.TryRegister( PowerSettingNotification.SessionDisplayStatusId, InvalidateGamma ) ?? Disposable.Null, PowerSettingNotification.TryRegister( PowerSettingNotification.MonitorPowerOnId, InvalidateGamma ) ?? Disposable.Null, PowerSettingNotification.TryRegister( PowerSettingNotification.AwayModeId, InvalidateGamma ) ?? Disposable.Null, SystemEvent.Register( SystemEvent.DisplayChangedId, InvalidateDeviceContext ), SystemEvent.Register( SystemEvent.PaletteChangedId, InvalidateDeviceContext ), SystemEvent.Register( SystemEvent.SettingsChangedId, InvalidateDeviceContext ), SystemEvent.Register( SystemEvent.SystemColorsChangedId, InvalidateDeviceContext ) ); }
private ListViewItem CreateListViewItem(SystemEvent e) { return(new ListViewItem(new[] { e.MessageId.ToString(CultureInfo.InvariantCulture), e.Timestamp.ToString("HH:mm:ss,fff"), e.Level.ToString(), e.ProcessId.ToString(CultureInfo.InvariantCulture), e.ProcessName, e.Thread, e.Source, e.Username, e.Message }) { Tag = e, ForeColor = GetForegroundColor(e.Level), BackColor = GetBackgroundColor(e.Level) }); }
public void TestIfTimeBetweenOperationsIsBelowTimeout() { Rule.OperationName = null; Rule.StartOperationName = StartName; Rule.EndOperationName = EndName; var startOp = new SystemEvent(SystemEvent.OperationResult.Success); startOp.OperationName = StartName; var endOp = new SystemEvent(SystemEvent.OperationResult.Success); endOp.OperationName = EndName; Assert.IsFalse(Rule.AddAndCheckIfTriggered(startOp)); Thread.Sleep(6000); Assert.IsFalse(Rule.AddAndCheckIfTriggered(endOp)); Assert.IsFalse(Rule.AddAndCheckIfTriggered(startOp)); Thread.Sleep(4500); Assert.IsFalse(Rule.AddAndCheckIfTriggered(endOp)); }
public override bool AddAndCheckIfTriggered(SystemEvent opResult) { if (opResult.Result != SystemEvent.OperationResult.Failure) { return(false); } while (Failures.Any() && Failures.Peek() <= DateTime.UtcNow) { Failures.Dequeue(); } Failures.Enqueue(DateTime.UtcNow + KeepOperationInPileTime); if (Failures.Count >= MaxTimesFailureAllowed) { AlarmMessage = $"{MaxTimesFailureAllowed} failures occured within {KeepOperationInPileTime}."; Failures.Clear(); return(true); } return(false); }
/// <summary> /// Create the message queues and system event. /// </summary> public void InitQueueEndPoints() { //Create out reader and writer queues. Since this queue has a name it is accessible // by other programs. _writer = new MessageQueueWriter(QueueEndpointName, maxItems, maxMessageSize); if (_isReader) { _reader = new MessageQueueReader(QueueEndpointName, maxItems, maxMessageSize); //Create an unnamed event. This will be used to unblock the read thread //when the program is terminating. _readerWaitEvent = new SystemEvent(null, false, true); Thread readThread = new Thread(new ThreadStart(ReaderThread)); readThread.IsBackground = true; readThread.Start(); } }
public IHttpActionResult PostSystemEvent(SystemEvent systemEvent) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } using (SqlConnection con = new SqlConnection(conString.ConnectionString)) { using (SqlCommand cmd = new SqlCommand("AddSystemEvent", con)) { cmd.CommandType = CommandType.StoredProcedure; cmd.Parameters.AddWithValue("@Description", systemEvent.Description); con.Open(); cmd.ExecuteNonQuery(); } } return(CreatedAtRoute("DefaultApi", new { id = systemEvent.Id }, systemEvent)); }
public void Bind(SystemEvent e) { Verify.NotNull(e, "e"); // Message tab messageText.Text = e.Message; // Details tab messageId.Text = e.MessageId.ToString(CultureInfo.CurrentUICulture); level.Text = e.Level.ToString(); source.Text = e.Source; timestamp.Text = e.Timestamp.ToString("yyyy-MM-dd HH:mm:ss,fff"); process.Text = e.ProcessName + " (" + e.ProcessId + ")"; thread.Text = e.Thread; username.Text = e.Username; message.Text = e.Message; // Raw tab rawText.Text = e.RawMessage.Value; }
public string HandleEvent(SystemEvent e, int time, ref bool updateVisuals) { if (this.Disposed == true) { throw new ObjectDisposedException(this.GetType().Name); } _time = time; if ((_bindHandler != null) && (e.Type == SystemEventType.Key) && (e.Value2 == 1)) { string ret = _bindHandler.HandleEvent(e, ref updateVisuals); _bindHandler = null; return(ret); } if (e.Type == SystemEventType.Mouse) { _cursorX += e.Value; _cursorY += e.Value2; if (_cursorX < 0) { _cursorX = 0; } if (_cursorY < 0) { _cursorY = 0; } } if (this.Desktop != null) { this.Desktop.HandleEvent(e, ref updateVisuals); } return(string.Empty); }
public void LogSystemEvent(SystemEvent systemEvent) { using (var command = new NpgsqlCommand("log_system_event")) { Log.DebugFormat("Inserting system event {0} into databse...", systemEvent.Id); command.CommandType = System.Data.CommandType.StoredProcedure; AddCommonEventPropertyParametersToCommand(command, systemEvent); command.Parameters.Add(new NpgsqlParameter { NpgsqlDbType = NpgsqlDbType.Enum, Value = systemEvent.Command }); command.Parameters.Add(new NpgsqlParameter { NpgsqlDbType = NpgsqlDbType.Char, Value = ((object)systemEvent.StockSymbol) ?? DBNull.Value }); command.Parameters.Add(new NpgsqlParameter { NpgsqlDbType = NpgsqlDbType.Money, Value = ((object)systemEvent.Funds) ?? DBNull.Value }); command.Parameters.Add(new NpgsqlParameter { NpgsqlDbType = NpgsqlDbType.Varchar, Value = ((object)systemEvent.FileName) ?? DBNull.Value }); int id = ExecuteInsertCommand(command); Log.DebugFormat(CultureInfo.InvariantCulture, "Successfully inserted system event {0} (database id = {1}).", systemEvent.Id, id); } }
public override string HandleEvent(SystemEvent e, ref bool updateVisuals) { if (((e.Type == SystemEventType.Key) && (e.Value2 > 0)) == false) { return(string.Empty); } Keys key = (Keys)e.Value; if ((e.Value2 > 0) && (key == Keys.Mouse1)) { this.CaptureChild = this; RouteMouseCoordinates(0, 0); return(string.Empty); } if ((key == Keys.Right) || ((key == Keys.Mouse2) && ((this.UserInterface.CursorY > _thumbRect.Y) == true))) { _value.Set(_value + _stepSize); } if ((key == Keys.Left) || ((key == Keys.Mouse2) && ((this.UserInterface.CursorY < _thumbRect.Y) == true))) { _value.Set(_value - _stepSize); } if (this.Buddy != null) { this.Buddy.HandleBuddyUpdate(this); } else { this.UserInterface.State.Set(_cvarStr.ToString(), _value); } UpdateConsoleVariables(false); return(string.Empty); }
public void Post(SystemEvent @event) { var table = TableStorage.CreateCloudTable(); var entity = new EventEntity(@event.Date) { Message = @event.Message, User = @event.User }; try { table.CreateIfNotExists(); var insertOperation = new TableBatchOperation(); insertOperation.Insert(entity); table.ExecuteBatch(insertOperation); } catch (Exception) { } }
public void ReturnFalseIfAllChildFiltersFalse() { var e = new SystemEvent { Level = SystemEventLevel.Error, ProcessId = 123, Thread = "Unknown" }; var filter = new OrElseFilter( new FakeExtendedProperties(), new[] { new EqualFilter(new FakeExtendedProperties { { "property", "ProcessId" }, { "value", "1234" } }, Enumerable.Empty <ICreateFilterExpressions>()), new EqualFilter(new FakeExtendedProperties { { "property", "Thread" }, { "value", "Main" } }, Enumerable.Empty <ICreateFilterExpressions>()), new EqualFilter(new FakeExtendedProperties { { "property", "Level" }, { "value", "Warning" } }, Enumerable.Empty <ICreateFilterExpressions>()) }); Assert.False(Filter.Compile(filter).Invoke(e)); }
public override bool AddAndCheckIfTriggered(SystemEvent opResult) { if (Observers.Count == 0) { AlarmMessage = "No observers attached to rule. Rule can not let know when triggered through timeout."; return(true); } if (OperationName != null && opResult.OperationName == OperationName) { AddSingleOperation(); return(false); } if (opResult.OperationName == StartOperationName) { return(AddAndCheckIfTriggeredForStartOperation()); } if (opResult.OperationName == EndOperationName) { return(AddAndCheckIfTriggeredForEndOperation()); } return(false); }
public void Render(SystemEvent e) { if (filter.Exclude(e)) { return; } Console.ForegroundColor = timestampColor; Console.BackgroundColor = defaultBackColor; Console.Write(String.Format("{0:HH:mm:ss,fff} ", e.Timestamp)); Console.BackgroundColor = Settings.GetBackeColor(e.Level); Console.ForegroundColor = Settings.GetForeColor(e.Level); stringBuilder.Clear(); stringBuilder.AppendFormat("[{0}] ", GetProcessId(e)); stringBuilder.AppendFormat("{0} ", GetProcessName(e)); stringBuilder.AppendFormat("[{0}] ", GetThread(e)); stringBuilder.AppendFormat("{0} ", GetSource(e)); stringBuilder.AppendFormat("[{0}] ", GetLevel(e)); stringBuilder.Append(e.Message); Console.WriteLine(stringBuilder.ToString()); }
private void OnMessageReceived(string json) { Task.Run(async() => { SystemEvent systemEvent = JsonConvert.DeserializeObject <SystemEvent>(json); //update device status if (systemEvent.EventType == SystemEventTypesEnum.DeviceOnline || systemEvent.EventType == SystemEventTypesEnum.DeviceOffline) { _deviceManager.Tell(systemEvent); await this._devices.UpdateStatusAsync(systemEvent.EntityId, systemEvent.EventType == SystemEventTypesEnum.DeviceOnline ? true : false); Console.WriteLine("Device status updated"); } // Frame message for ack //dynamic message = new ExpandoObject(); //message.Type = "Acknowledgement"; //message.topic = ID; //var jsonMessage = JsonConvert.SerializeObject(message); ////send message to kafaka producer //_producer.ProduceMessage(Literals.KAFKA_TOPIC_CONFIG, jsonMessage); }); }
public IHttpActionResult PutSystemEvent(int id, SystemEvent systemEvent) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } if (id != systemEvent.Id) { return(BadRequest()); } using (SqlConnection con = new SqlConnection(conString.ConnectionString)) { using (SqlCommand cmd = new SqlCommand("UpdateSystemEvent", con)) { cmd.CommandType = CommandType.StoredProcedure; cmd.Parameters.AddWithValue("@Id", systemEvent.Id); cmd.Parameters.AddWithValue("@Description", systemEvent.Description); con.Open(); cmd.ExecuteNonQuery(); } } return(StatusCode(HttpStatusCode.NoContent)); }
public SystemEvent Parse(IMessage message) { Verify.NotNull(message, "message"); var match = pattern.Match(message.Message); var process = processes.GetProcessById(message.ProcessId); var level = Settings.GetLevel(match.Groups["level"].Value); return(match.Success ? new SystemEvent { Level = level, ProcessName = process.Name, ProcessId = process.Id, Timestamp = message.Timestamp, Thread = match.Groups["thread"].Value, Source = match.Groups["logger"].Value, Message = match.Groups["message"].Value, Username = match.Groups["username"].Value, RawMessage = new Lazy <String>(() => message.Message) } : SystemEvent.Create(message)); }
/// <summary> /// On shutdown we need to dispose our object manually before disposing the control /// </summary> public new void Dispose() { addLog("Dispose() called..."); #if USE_ENTER_KEY #else _continueWait = false; //signal thread to stop Thread.Sleep(100); SystemEvent waitEvent = new SystemEvent("EndWaitLoop52", false, false); waitEvent.PulseEvent(); Thread.Sleep(100); restoreKey(); #endif if (IntermecCamera != null) { #if STREAMING_ON addLog("...Dispose() we DO NOT SWITCH streaming"); #else IntermecCamera.Streaming = false; #endif IntermecCamera.Dispose(); IntermecCamera = null; } #if USE_ENTER_KEY #else //enable HW Trigger of Scanner //S9CconfigClass.S9Cconfig.HWTrigger.setHWTrigger(true); YetAnotherHelperClass.setHWTrigger(true); #endif #if REMAP_SCAN_TO_ENTERKEY restoreScanKey(); #endif //YetAnotherHelperClass.muteSpeakerVolume(false); Cursor.Current = Cursors.Default; //base.Dispose(); do not use!! addLog("...Dispose() finished"); }
public new void Dispose() { addLog("Dispose() called..."); _continueWait = false; //signal thread to stop Thread.Sleep(100); SystemEvent waitEvent = new SystemEvent("EndWaitLoop52", false, false); waitEvent.PulseEvent(); Thread.Sleep(100); #if STREAMING_ON //kill SnapShot Thread if (snapshotThread != null) { snapshotThread.Abort(); } #endif Thread.Sleep(100); if (_imager != null) { //restore AimerFlashing mode _imager.AimerFlashing = Imager.AimerFlashingMode.Auto; _imager.LightGoal = 128; _imager.VideoRunning = false; _imager.Dispose(); _imager = null; } //enable HW Trigger of Scanner //S9CconfigClass.S9Cconfig.HWTrigger.setHWTrigger(true); //removed as problems with ADCComInterface YetAnotherHelperClass.setHWTrigger(true); ITCTools.KeyBoard.restoreKey(); Cursor.Current = Cursors.Default; // base.Dispose(); do not use!! addLog("...Dispose() finished"); }
public Boolean Exclude(SystemEvent e) { return(!filter.Invoke(e)); }
public override string HandleEvent(SystemEvent e, ref bool updateVisuals) { idConsole.Warning("TODO: EditWindow HandleEvent"); /* TODO: static char buffer[ MAX_EDITFIELD ]; const char *ret = ""; if ( wrap ) { // need to call this to allow proper focus and capturing on embedded children ret = idWindow::HandleEvent( event, updateVisuals ); if ( ret && *ret ) { return ret; } } if ( ( event->evType != SE_CHAR && event->evType != SE_KEY ) ) { return ret; } idStr::Copynz( buffer, text.c_str(), sizeof( buffer ) ); int key = event->evValue; int len = text.Length(); if ( event->evType == SE_CHAR ) { if ( event->evValue == Sys_GetConsoleKey( false ) || event->evValue == Sys_GetConsoleKey( true ) ) { return ""; } if ( updateVisuals ) { *updateVisuals = true; } if ( maxChars && len > maxChars ) { len = maxChars; } if ( ( key == K_ENTER || key == K_KP_ENTER ) && event->evValue2 ) { RunScript( ON_ACTION ); RunScript( ON_ENTER ); return cmd; } if ( key == K_ESCAPE ) { RunScript( ON_ESC ); return cmd; } if ( readonly ) { return ""; } if ( key == 'h' - 'a' + 1 || key == K_BACKSPACE ) { // ctrl-h is backspace if ( cursorPos > 0 ) { if ( cursorPos >= len ) { buffer[len - 1] = 0; cursorPos = len - 1; } else { memmove( &buffer[ cursorPos - 1 ], &buffer[ cursorPos ], len + 1 - cursorPos); cursorPos--; } text = buffer; UpdateCvar( false ); RunScript( ON_ACTION ); } return ""; } // // ignore any non printable chars (except enter when wrap is enabled) // if ( wrap && (key == K_ENTER || key == K_KP_ENTER) ) { } else if ( !idStr::CharIsPrintable( key ) ) { return ""; } if ( numeric ) { if ( ( key < '0' || key > '9' ) && key != '.' ) { return ""; } } if ( dc->GetOverStrike() ) { if ( maxChars && cursorPos >= maxChars ) { return ""; } } else { if ( ( len == MAX_EDITFIELD - 1 ) || ( maxChars && len >= maxChars ) ) { return ""; } memmove( &buffer[ cursorPos + 1 ], &buffer[ cursorPos ], len + 1 - cursorPos ); } buffer[ cursorPos ] = key; text = buffer; UpdateCvar( false ); RunScript( ON_ACTION ); if ( cursorPos < len + 1 ) { cursorPos++; } EnsureCursorVisible(); } else if ( event->evType == SE_KEY && event->evValue2 ) { if ( updateVisuals ) { *updateVisuals = true; } if ( key == K_DEL ) { if ( readonly ) { return ret; } if ( cursorPos < len ) { memmove( &buffer[cursorPos], &buffer[cursorPos + 1], len - cursorPos); text = buffer; UpdateCvar( false ); RunScript( ON_ACTION ); } return ret; } if ( key == K_RIGHTARROW ) { if ( cursorPos < len ) { if ( idKeyInput::IsDown( K_CTRL ) ) { // skip to next word while( ( cursorPos < len ) && ( buffer[ cursorPos ] != ' ' ) ) { cursorPos++; } while( ( cursorPos < len ) && ( buffer[ cursorPos ] == ' ' ) ) { cursorPos++; } } else { if ( cursorPos < len ) { cursorPos++; } } } EnsureCursorVisible(); return ret; } if ( key == K_LEFTARROW ) { if ( idKeyInput::IsDown( K_CTRL ) ) { // skip to previous word while( ( cursorPos > 0 ) && ( buffer[ cursorPos - 1 ] == ' ' ) ) { cursorPos--; } while( ( cursorPos > 0 ) && ( buffer[ cursorPos - 1 ] != ' ' ) ) { cursorPos--; } } else { if ( cursorPos > 0 ) { cursorPos--; } } EnsureCursorVisible(); return ret; } if ( key == K_HOME ) { if ( idKeyInput::IsDown( K_CTRL ) || cursorLine <= 0 || ( cursorLine >= breaks.Num() ) ) { cursorPos = 0; } else { cursorPos = breaks[cursorLine]; } EnsureCursorVisible(); return ret; } if ( key == K_END ) { if ( idKeyInput::IsDown( K_CTRL ) || (cursorLine < -1) || ( cursorLine >= breaks.Num() - 1 ) ) { cursorPos = len; } else { cursorPos = breaks[cursorLine + 1] - 1; } EnsureCursorVisible(); return ret; } if ( key == K_INS ) { if ( !readonly ) { dc->SetOverStrike( !dc->GetOverStrike() ); } return ret; } if ( key == K_DOWNARROW ) { if ( idKeyInput::IsDown( K_CTRL ) ) { scroller->SetValue( scroller->GetValue() + 1.0f ); } else { if ( cursorLine < breaks.Num() - 1 ) { int offset = cursorPos - breaks[cursorLine]; cursorPos = breaks[cursorLine + 1] + offset; EnsureCursorVisible(); } } } if (key == K_UPARROW ) { if ( idKeyInput::IsDown( K_CTRL ) ) { scroller->SetValue( scroller->GetValue() - 1.0f ); } else { if ( cursorLine > 0 ) { int offset = cursorPos - breaks[cursorLine]; cursorPos = breaks[cursorLine - 1] + offset; EnsureCursorVisible(); } } } if ( key == K_ENTER || key == K_KP_ENTER ) { RunScript( ON_ACTION ); RunScript( ON_ENTER ); return cmd; } if ( key == K_ESCAPE ) { RunScript( ON_ESC ); return cmd; } } else if ( event->evType == SE_KEY && !event->evValue2 ) { if ( key == K_ENTER || key == K_KP_ENTER ) { RunScript( ON_ENTERRELEASE ); return cmd; } else { RunScript( ON_ACTIONRELEASE ); } } return ret;*/ return string.Empty; }
public void RaiseSystemEvent(object sender, XSystemEvent systemEvent) { SystemEvent?.Invoke(sender, systemEvent); }
static void Main(string[] args) { try { EventReporter.Instance.Init(); var t = 0; var innerCounter = 0; var edatalist = new List <SystemEvent>(); WriteLine("Generating first eventbatch..."); while (true) { try { if (innerCounter++ == 20) { WriteLine($"Enter för att skicka {innerCounter - 1} events."); //WriteLine($"Skickar {innerCounter - 1} events."); innerCounter = 0; ReadLine(); Clear(); //eventhubclient.SendBatch(edatalist); EventReporter.Instance.ReportEventBatchAsync(edatalist).Wait(); edatalist.Clear(); WriteLine("Sent."); WriteLine("Generating new eventbatch..."); } Write("."); //WriteLine(innerCounter); var opres = new SystemEvent(SystemEvent.OperationResult.Failure); opres.OtherInfo = $"{t++}"; if (t % 2 == 0) { opres.OperationName = "operation1"; } else { opres.OperationName = "operation2"; } opres.OperationParameters.Add(nameof(innerCounter), innerCounter); opres.OperationParameters.Add("test", 56); if (t % 8 == 0) { opres.AppInfo.ApplicationName = opres.PartitionKey = "Annan app"; } if (t % 6 == 0) { opres.Result = SystemEvent.OperationResult.Success; } else { opres.Result = SystemEvent.OperationResult.Failure; opres.CaughtException = new NullReferenceException(); //string error = null; //try //{ // if(t%7 == 0) // { // throw new ArgumentException("arg fail"); // } // if(error.Length == 9) // { // error = "9"; // } //} //catch(Exception ex) //{ // opres.Result = SystemEvent.OperationResult.Failure; // opres.CaughtException = ex; //} } var data = JsonConvert.SerializeObject(opres); //WriteLine(data); edatalist.Add(opres); //eventhubclient.Send(new EventData(Encoding.UTF8.GetBytes(data))); //Thread.Sleep(100); } catch (Exception ex) { WriteLine(ex.ToString()); ReadLine(); } } } catch (Exception ex) { WriteLine(ex.ToString()); ReadLine(); } }
//###################################################################### void waitLoop() { addLog("waitLoop starting..."); SystemEvent[] _events = new SystemEvent[3]; addLog("waitLoop setting up event array..."); _events[0] = new SystemEvent("StateLeftScan1", false, false); _events[1] = new SystemEvent("DeltaLeftScan1", false, false); _events[2] = new SystemEvent("EndWaitLoop52", false, false); try { do { //Sleep as long as a snapshot is pending while (_bTakingSnapShot && _continueWait) { Thread.Sleep(50); } if (!_continueWait) { Thread.CurrentThread.Abort(); } addLog2("waitLoop WaitForMultipleObjects..."); SystemEvent signaledEvent = SyncBase.WaitForMultipleObjects( -1, // wait for ever _events ) as SystemEvent; addLog2("waitLoop WaitForMultipleObjects released: "); if (_continueWait) { if (signaledEvent == _events[0]) { addLog2("######### Caught StateLeftScan ########"); onStateScan(); } if (signaledEvent == _events[1]) { addLog2("######### Caught DeltaLeftScan ########"); onDeltaScan(); } if (signaledEvent == _events[2]) { addLog2("######### Caught EndWaitLoop52 ########"); _continueWait = false; } } addLog2("waitLoop sleep(5)"); System.Threading.Thread.Sleep(5); } while (_continueWait); addLog("waitLoop while ended by _continueWait"); } catch (ThreadAbortException ex) { System.Diagnostics.Debug.WriteLine("waitLoop: ThreadAbortException: " + ex.Message); } catch (Exception ex) { System.Diagnostics.Debug.WriteLine("waitLoop: Exception: " + ex.Message); } finally { _events[0].Dispose(); _events[1].Dispose(); _events[2].Dispose(); } addLog("...waitLoop EXIT"); }
public void RenderMessageIfParserFound() { var e = new SystemEvent(); var message = new OutputDebugString("MySource", 123, "My Message"); var resetEvent = new ManualResetEvent(false); renderer.Setup(mock => mock.Render(It.IsAny<SystemEvent>())).Callback(() => resetEvent.Set()); parser.Setup(mock => mock.CanParseMessage("My Message")).Returns(true); parser.Setup(mock => mock.Parse(message)).Returns(e); processor.Process(message); Assert.True(resetEvent.WaitOne(TimeSpan.FromSeconds(1)), "ManualResetEvent not signalled within expected time."); renderer.Verify(mock => mock.Render(e), Times.Once()); }
public SystemEventWithMessage(ref SystemEvent e) { this.holder = e; }
public Boolean Exclude(SystemEvent e) { return !filter.Invoke(e); }
public Boolean Exclude(SystemEvent e) { return e == null || staticFilter.Exclude(e) || dynamicFilter != null && dynamicFilter.Exclude(e); }
public override string HandleEvent(SystemEvent e, ref bool updateVisuals) { idConsole.Warning("TODO: ListWindow HandleEvent"); // need to call this to allow proper focus and capturing on embedded children /*const char *ret = idWindow::HandleEvent(event, updateVisuals); float vert = GetMaxCharHeight(); int numVisibleLines = textRect.h / vert; int key = event->evValue; if ( event->evType == SE_KEY ) { if ( !event->evValue2 ) { // We only care about key down, not up return ret; } if ( key == K_MOUSE1 || key == K_MOUSE2 ) { // If the user clicked in the scroller, then ignore it if ( scroller->Contains(gui->CursorX(), gui->CursorY()) ) { return ret; } } if ( ( key == K_ENTER || key == K_KP_ENTER ) ) { RunScript( ON_ENTER ); return cmd; } if ( key == K_MWHEELUP ) { key = K_UPARROW; } else if ( key == K_MWHEELDOWN ) { key = K_DOWNARROW; } if ( key == K_MOUSE1) { if (Contains(gui->CursorX(), gui->CursorY())) { int cur = ( int )( ( gui->CursorY() - actualY - pixelOffset ) / vert ) + top; if ( cur >= 0 && cur < listItems.Num() ) { if ( multipleSel && idKeyInput::IsDown( K_CTRL ) ) { if ( IsSelected( cur ) ) { ClearSelection( cur ); } else { AddCurrentSel( cur ); } } else { if ( IsSelected( cur ) && ( gui->GetTime() < clickTime + doubleClickSpeed ) ) { // Double-click causes ON_ENTER to get run RunScript(ON_ENTER); return cmd; } SetCurrentSel( cur ); clickTime = gui->GetTime(); } } else { SetCurrentSel( listItems.Num() - 1 ); } } } else if ( key == K_UPARROW || key == K_PGUP || key == K_DOWNARROW || key == K_PGDN ) { int numLines = 1; if ( key == K_PGUP || key == K_PGDN ) { numLines = numVisibleLines / 2; } if ( key == K_UPARROW || key == K_PGUP ) { numLines = -numLines; } if ( idKeyInput::IsDown( K_CTRL ) ) { top += numLines; } else { SetCurrentSel( GetCurrentSel() + numLines ); } } else { return ret; } } else if ( event->evType == SE_CHAR ) { if ( !idStr::CharIsPrintable(key) ) { return ret; } if ( gui->GetTime() > typedTime + 1000 ) { typed = ""; } typedTime = gui->GetTime(); typed.Append( key ); for ( int i=0; i<listItems.Num(); i++ ) { if ( idStr::Icmpn( typed, listItems[i], typed.Length() ) == 0 ) { SetCurrentSel( i ); break; } } } else { return ret; } if ( GetCurrentSel() < 0 ) { SetCurrentSel( 0 ); } if ( GetCurrentSel() >= listItems.Num() ) { SetCurrentSel( listItems.Num() - 1 ); } if ( scroller->GetHigh() > 0.0f ) { if ( !idKeyInput::IsDown( K_CTRL ) ) { if ( top > GetCurrentSel() - 1 ) { top = GetCurrentSel() - 1; } if ( top < GetCurrentSel() - numVisibleLines + 2 ) { top = GetCurrentSel() - numVisibleLines + 2; } } if ( top > listItems.Num() - 2 ) { top = listItems.Num() - 2; } if ( top < 0 ) { top = 0; } scroller->SetValue(top); } else { top = 0; scroller->SetValue(0.0f); } if ( key != K_MOUSE1 ) { // Send a fake mouse click event so onAction gets run in our parents const sysEvent_t ev = sys->GenerateMouseButtonEvent( 1, true ); idWindow::HandleEvent(&ev, updateVisuals); } if ( currentSel.Num() > 0 ) { for ( int i = 0; i < currentSel.Num(); i++ ) { gui->SetStateInt( va( "%s_sel_%i", listName.c_str(), i ), currentSel[i] ); } } else { gui->SetStateInt( va( "%s_sel_0", listName.c_str() ), 0 ); } gui->SetStateInt( va( "%s_numsel", listName.c_str() ), currentSel.Num() ); return ret;*/ return string.Empty; }
public string HandleEvent(SystemEvent e, int time, ref bool updateVisuals) { if(this.Disposed == true) { throw new ObjectDisposedException(this.GetType().Name); } _time = time; if((_bindHandler != null) && (e.Type == SystemEventType.Key) && (e.Value2 == 1)) { string ret = _bindHandler.HandleEvent(e, ref updateVisuals); _bindHandler = null; return ret; } if(e.Type == SystemEventType.Mouse) { _cursorX += e.Value; _cursorY += e.Value2; if(_cursorX < 0) { _cursorX = 0; } if(_cursorY < 0) { _cursorY = 0; } } if(this.Desktop != null) { this.Desktop.HandleEvent(e, ref updateVisuals); } return string.Empty; }
public override string HandleEvent(SystemEvent e, ref bool updateVisuals) { if(this.Disposed == true) { throw new ObjectDisposedException(this.GetType().Name); } idConsole.Warning("TODO: ChoiceWindow HandleEvent"); /*int key; bool runAction = false; bool runAction2 = false; if ( event->evType == SE_KEY ) { key = event->evValue; if ( key == K_RIGHTARROW || key == K_KP_RIGHTARROW || key == K_MOUSE1) { // never affects the state, but we want to execute script handlers anyway if ( !event->evValue2 ) { RunScript( ON_ACTIONRELEASE ); return cmd; } currentChoice++; if (currentChoice >= choices.Num()) { currentChoice = 0; } runAction = true; } if ( key == K_LEFTARROW || key == K_KP_LEFTARROW || key == K_MOUSE2) { // never affects the state, but we want to execute script handlers anyway if ( !event->evValue2 ) { RunScript( ON_ACTIONRELEASE ); return cmd; } currentChoice--; if (currentChoice < 0) { currentChoice = choices.Num() - 1; } runAction = true; } if ( !event->evValue2 ) { // is a key release with no action catch return ""; } } else if ( event->evType == SE_CHAR ) { key = event->evValue; int potentialChoice = -1; for ( int i = 0; i < choices.Num(); i++ ) { if ( toupper(key) == toupper(choices[i][0]) ) { if ( i < currentChoice && potentialChoice < 0 ) { potentialChoice = i; } else if ( i > currentChoice ) { potentialChoice = -1; currentChoice = i; break; } } } if ( potentialChoice >= 0 ) { currentChoice = potentialChoice; } runAction = true; runAction2 = true; } else { return ""; } if ( runAction ) { RunScript( ON_ACTION ); } if ( choiceType == 0 ) { cvarStr.Set( va( "%i", currentChoice ) ); } else if ( values.Num() ) { cvarStr.Set( values[ currentChoice ] ); } else { cvarStr.Set( choices[ currentChoice ] ); } UpdateVars( false ); if ( runAction2 ) { RunScript( ON_ACTIONRELEASE ); } return cmd;*/ return string.Empty; }
private string HandleKeyEvent(SystemEvent e, Keys key, bool down, ref bool updateVisuals) { EvaluateRegisters(-1, true); updateVisuals = true; if(key == Keys.Mouse1) { if((down == false) && (this.CaptureChild != null)) { this.CaptureChild.HandleCaptureLost(); this.UserInterface.Desktop.CaptureChild = null; return string.Empty; } int c = _children.Count; while(--c >= 0) { idWindow child = _children[c]; if((child.IsVisible == true) && (child.Contains(child.DrawRectangle, this.UserInterface.CursorX, this.UserInterface.CursorY) == true) && (child.NoEvents == false)) { if(down == true) { BringToTop(child); SetFocus(child); if((child.Flags & WindowFlags.HoldCapture) == WindowFlags.HoldCapture) { this.CaptureChild = child; } } if(child.Contains(child.ClientRectangle, this.UserInterface.CursorX, this.UserInterface.CursorY) == true) { //if ((gui_edit.GetBool() && (child->flags & WIN_SELECTED)) || (!gui_edit.GetBool() && (child->flags & WIN_MOVABLE))) { // SetCapture(child); //} SetFocus(child); string childReturn = child.HandleEvent(e, ref updateVisuals); if(childReturn != string.Empty) { return childReturn; } if((child.Flags & WindowFlags.Modal) == WindowFlags.Modal) { return string.Empty; } } else { if(down == true) { SetFocus(child); bool capture = true; if((capture == true) && (((child.Flags & WindowFlags.Movable) == WindowFlags.Movable) || (idE.CvarSystem.GetBool("gui_edit") == true))) { this.CaptureChild = child; } return string.Empty; } } } } if((down == true) && (_actionDownRun == false)) { _actionDownRun = RunScript(ScriptName.Action); } else if(_actionUpRun == false) { _actionUpRun = RunScript(ScriptName.ActionRelease); } } else if (key == Keys.Mouse2) { if((down == false) && (this.CaptureChild != null)) { this.CaptureChild.HandleCaptureLost(); this.UserInterface.Desktop.CaptureChild = null; return string.Empty; } int c = _children.Count; while(--c >= 0) { idWindow child = _children[c]; if((child.IsVisible == true) && (child.Contains(child.DrawRectangle, this.UserInterface.CursorX, this.UserInterface.CursorY) == true) && (child.NoEvents == false)) { if(down == true) { BringToTop(child); SetFocus(child); } if((child.Contains(child.ClientRectangle, this.UserInterface.CursorX, this.UserInterface.CursorY) == true) || (this.CaptureChild == child)) { if(((idE.CvarSystem.GetBool("gui_edit") == true) && ((child.Flags & WindowFlags.Selected) == WindowFlags.Selected)) || (idE.CvarSystem.GetBool("gui_edit") == false) && ((child.Flags & WindowFlags.Movable) == WindowFlags.Movable)) { this.CaptureChild = child; } string childReturn = child.HandleEvent(e, ref updateVisuals); if(childReturn != string.Empty) { return childReturn; } if((child.Flags & WindowFlags.Modal) == WindowFlags.Modal) { return string.Empty; } } } } } else if(key == Keys.Mouse3) { if(idE.CvarSystem.GetBool("gui_edit") == true) { int c = _children.Count; for(int i = 0; i < c; i++) { if(_children[i].DrawRectangle.Contains(this.UserInterface.CursorX, this.UserInterface.CursorY) == true) { if(down == true) { _children[i].Flags ^= WindowFlags.Selected; if((_children[i].Flags & WindowFlags.Selected) == WindowFlags.Selected) { this.Flags &= ~WindowFlags.Selected; return "childsel"; } } } } } } else if((key == Keys.Tab) && (down == true)) { if(this.FocusedChild != null) { string childRet = this.FocusedChild.HandleEvent(e, ref updateVisuals); if(childRet != string.Empty) { return childRet; } // If the window didn't handle the tab, then move the focus to the next window // or the previous window if shift is held down int direction = 1; if(idE.Input.IsKeyDown(Keys.LeftShift) == true) { direction = -1; } idWindow currentFocus = this.FocusedChild; idWindow child = this.FocusedChild; idWindow parent = child.Parent; while(parent != null) { bool foundFocus = false; bool recurse = false; int index = 0; if(child != null) { index = parent.GetChildIndex(child) + direction; } else if(direction < 0) { index = parent.ChildCount - 1; } while((index < parent.ChildCount) && (index >= 0)) { idWindow testWindow = parent.GetChild(index); if(testWindow == currentFocus) { // we managed to wrap around and get back to our starting window foundFocus = true; break; } else if((testWindow != null) && (testWindow.NoEvents == false) && (testWindow.IsVisible == true)) { if((testWindow.Flags & WindowFlags.CanFocus) == WindowFlags.CanFocus) { SetFocus(testWindow); foundFocus = true; break; } else if(testWindow.ChildCount > 0) { parent = testWindow; child = null; recurse = true; break; } } index += direction; } if(foundFocus == true) { // we found a child to focus on break; } else if(recurse == true) { // we found a child with children continue; } else { // we didn't find anything, so go back up to our parent child = parent; parent = child.Parent; if(parent == this.UserInterface.Desktop) { // we got back to the desktop, so wrap around but don't actually go to the desktop parent = null; child = null; } } } } } else if((key == Keys.Escape) && (down == true)) { if(this.FocusedChild != null) { string childRet = this.FocusedChild.HandleEvent(e, ref updateVisuals); if(childRet != string.Empty) { return childRet; } } RunScript(ScriptName.Escape); } else if(key == Keys.Enter) { if(this.FocusedChild != null) { string childRet = this.FocusedChild.HandleEvent(e, ref updateVisuals); if(childRet != string.Empty) { return childRet; } } if((this.Flags & WindowFlags.WantEnter) == WindowFlags.WantEnter) { if(down == true) { RunScript(ScriptName.Action); } else { RunScript(ScriptName.ActionRelease); } } } else { if(this.FocusedChild != null) { string childRet = this.FocusedChild.HandleEvent(e, ref updateVisuals); if(childRet != string.Empty) { return childRet; } } } return string.Empty; }
public EventRecordProxy(ref SystemEvent item) { this.OriginalEvent = item; }
public void DefaultValues() { var sut = new SystemEvent(); Assert.AreEqual(SystemEventType.Unknown, sut.Type); }
public override string HandleEvent(SystemEvent e, ref bool updateVisuals) { if(((e.Type == SystemEventType.Key) && (e.Value2 > 0)) == false) { return string.Empty; } Keys key = (Keys) e.Value; if((e.Value2 > 0) && (key == Keys.Mouse1)) { this.CaptureChild = this; RouteMouseCoordinates(0, 0); return string.Empty; } if((key == Keys.Right) || ((key == Keys.Mouse2) && ((this.UserInterface.CursorY > _thumbRect.Y) == true))) { _value.Set(_value + _stepSize); } if((key == Keys.Left) || ((key == Keys.Mouse2) && ((this.UserInterface.CursorY < _thumbRect.Y) == true))) { _value.Set(_value - _stepSize); } if(this.Buddy != null) { this.Buddy.HandleBuddyUpdate(this); } else { this.UserInterface.State.Set(_cvarStr.ToString(), _value); } UpdateConsoleVariables(false); return string.Empty; }
void Run() { SystemEvent exclusiveEvent = null; SystemMutex exclusiveMutex = null; IDisposable exclusiveLock = null; SystemMutex priorityMutex = null; SystemMutex transientMutex = null; try { var em = HidSelector.Instance.EventManager; // *** Open the device. try { string transientName = GetResourceName("Transient"); // Create or open the exclusive event. exclusiveEvent = em.CreateEvent(GetResourceName("Event")); // Try to acquire the device. exclusiveMutex = em.CreateMutex(GetResourceName("Lock")); if (!exclusiveMutex.TryLock(0, out exclusiveLock)) { // We failed just locking it outright. First, can we interrupt? bool lockIsInterruptible = false; for (int priority = (int)OpenPriority.Idle; priority < (int)_priority; priority++) { if (em.MutexMayExist(GetResourceNameForPriority((OpenPriority)priority))) { lockIsInterruptible = true; break; } } // Let's try again. bool lockIsTransient = em.MutexMayExist(transientName); using (var tryPriorityMutex = (lockIsInterruptible ? em.CreateMutex(GetResourceNameForPriorityRequest()) : null)) { exclusiveEvent.Set(); int timeout; if (lockIsTransient) { timeout = Math.Max(0, _timeoutIfTransient); HidSharpDiagnostics.Trace("Failed to open the device. Luckily, it is in use by a transient process. We will wait {0} ms.", timeout); } else if (lockIsInterruptible) { timeout = Math.Max(0, _timeoutIfInterruptible); HidSharpDiagnostics.Trace("Failed to open the device. Luckily, it is in use by an interruptible process. We will wait {0} ms.", timeout); } else { timeout = 0; } if (!exclusiveMutex.TryLock(timeout, out exclusiveLock)) { throw DeviceException.CreateIOException(_device, "The device is in use.", Utility.HResult.SharingViolation); } } } if (_transient) { transientMutex = em.CreateMutex(transientName); } if (_interruptible) { priorityMutex = em.CreateMutex(GetResourceNameForPriority(_priority)); } } catch (Exception e) { _threadStartError = e; return; } finally { _threadStartEvent.Set(); } // *** OK! Now run the sharing monitor. { var handles = new WaitHandle[] { _closeEvent, exclusiveEvent.WaitHandle }; Exception ex = null; HidSharpDiagnostics.Trace("Started the sharing monitor thread ({0}).", Thread.CurrentThread.ManagedThreadId); while (true) { try { if (WaitHandle.WaitAny(handles) == 0) { break; } } catch (Exception e) { ex = e; break; } lock (_syncRoot) { // Okay. We received the request. Let's check for request priorities higher than ours. exclusiveEvent.Reset(); HidSharpDiagnostics.Trace("Received an interrupt request ({0}).", Thread.CurrentThread.ManagedThreadId); if (em.MutexMayExist(GetResourceNameForPriorityRequest())) { ThreadPool.QueueUserWorkItem(_ => { var ev = InterruptRequested; if (ev != null) { ev(this, EventArgs.Empty); } }); } } } HidSharpDiagnostics.Trace("Exited its sharing monitor thread ({0}).{1}", Thread.CurrentThread.ManagedThreadId, (ex != null ? " " + ex.ToString() : "")); } } finally { Close(ref priorityMutex); Close(ref transientMutex); Close(ref exclusiveLock); Close(ref exclusiveMutex); Close(ref exclusiveEvent); _closeEvent.Close(); _closeEvent = null; _thread = null; } }
public void OnSystemEvent(SystemEvent @event) { throw new NotImplementedException(); }
public string HandleEvent(SystemEvent e, int time) { if(this.Disposed == true) { throw new ObjectDisposedException(this.GetType().Name); } bool updateVisuals = false; return HandleEvent(e, time, ref updateVisuals); }
public void Notify(SystemEvent value) { Change(value); }
public override string HandleEvent(SystemEvent e, ref bool updateVisuals) { idConsole.Warning("TODO: BindWindow HandleEvent"); /*static char ret[ 256 ]; if (!(event->evType == SE_KEY && event->evValue2)) { return ""; } int key = event->evValue; if (waitingOnKey) { waitingOnKey = false; if (key == K_ESCAPE) { idStr::snPrintf( ret, sizeof( ret ), "clearbind \"%s\"", bindName.GetName()); } else { idStr::snPrintf( ret, sizeof( ret ), "bind %i \"%s\"", key, bindName.GetName()); } return ret; } else { if (key == K_MOUSE1) { waitingOnKey = true; gui->SetBindHandler(this); return ""; } } return "";*/ return string.Empty; }
private async void SystemActivityService_SystemActivitySnapshot(object sender, SystemEvent e) { await userSystemEventRepository.Create(new UserSystemEvent { EventType = e.EventType, DateTime = e.DateTime }); }
public virtual string HandleEvent(SystemEvent e, ref bool updateVisuals) { if(this.Disposed == true) { throw new ObjectDisposedException(this.GetType().Name); } if((_flags & WindowFlags.Desktop) == WindowFlags.Desktop) { _actionDownRun = false; _actionUpRun = false; if((_expressionRegisters.Count > 0) && (_ops.Count > 0)) { EvaluateRegisters(); } RunTimeEvents(_gui.Time); CalculateRectangles(0, 0); this.DeviceContext.Cursor = Cursor.Arrow; } if((_visible == true) && (_noEvents == false)) { if(e.Type == SystemEventType.Key) { string keyReturn = HandleKeyEvent(e, (Keys) e.Value, (e.Value2 == 1), ref updateVisuals); if(keyReturn != string.Empty) { return keyReturn; } } else if(e.Type == SystemEventType.Mouse) { string mouseReturn = HandleMouseEvent(e.Value, e.Value2, ref updateVisuals); if(mouseReturn != string.Empty) { return mouseReturn; } } else if(e.Type == SystemEventType.None) { } else if(e.Type == SystemEventType.Char) { if(this.FocusedChild != null) { string childRet = this.FocusedChild.HandleEvent(e, ref updateVisuals); if((childRet != null) && (childRet != string.Empty)) { return childRet; } } } } this.UserInterface.ReturnCommand = string.Empty; if(this.UserInterface.PendingCommand.Length > 0) { this.UserInterface.ReturnCommand += " ; "; this.UserInterface.ReturnCommand += this.UserInterface.PendingCommand; this.UserInterface.PendingCommand = string.Empty; } return this.UserInterface.ReturnCommand; }