public KeyboardDevice () { PreviewKeyPressEvent = new TunnelingEvent<KeyEventArgs> (); KeyPressEvent = new BubblingEvent<KeyEventArgs> (); GotKeyboardFocusEvent = new BubblingEvent<EventArgs> (); LostKeyboardFocusEvent = new BubblingEvent<EventArgs> (); }
/// <summary> /// TODO The crete json event configuration template. /// </summary> /// <param name="BubblingEvent"> /// TODO The bubbling event. /// </param> /// <returns> /// The <see cref="string"/>. /// </returns> public static string CreteJsonEventConfigurationTemplate(BubblingEvent BubblingEvent) { try { var eventConfiguration = new EventConfiguration(); eventConfiguration.Event = new Event( BubblingEvent.IdComponent, "{Configuration ID to execute}", BubblingEvent.Name, BubblingEvent.Description); eventConfiguration.Event.EventProperties = new List <EventProperty>(); foreach (var Property in BubblingEvent.Properties) { if (Property.Name != "DataContext") { var eventProperty = new EventProperty(Property.Name, "Value to set"); eventConfiguration.Event.EventProperties.Add(eventProperty); } } var eventCorrelationTemplate = new Event( "{Event component ID to execute if Correlation = true}", "{Configuration ID to execute if Correlation = true}", "EventName", "EventDescription"); eventCorrelationTemplate.Channels = new List <Channel>(); var points = new List <Point>(); points.Add(new Point("Point ID", "Point Name", "Point Description")); eventCorrelationTemplate.Channels.Add( new Channel("Channel ID", "Channel Name", "Channel Description", points)); var events = new List <Event>(); events.Add(eventCorrelationTemplate); eventConfiguration.Event.Channels = new List <Channel>(); eventConfiguration.Event.Channels.Add( new Channel("Channel ID", "Channel Name", "Channel Description", points)); eventConfiguration.Event.Correlation = new Correlation("Correlation Name", "C# script", events); var serializedMessage = JsonConvert.SerializeObject( eventConfiguration, Formatting.Indented, new JsonSerializerSettings { ReferenceLoopHandling = ReferenceLoopHandling.Ignore }); return(serializedMessage); // return "<![CDATA[" + serializedMessage + "]]>"; } catch (Exception ex) { return(ex.Message); } }
/// <summary> /// Persist the message in local file system /// </summary> /// <param name="bubblingEvent"> /// </param> /// <param name="communicationDiretion"> /// The communication Diretion. /// </param> /// <returns> /// The <see cref="bool"/>. /// </returns> public static bool PersistMessage(BubblingEvent bubblingEvent, CommunicationDiretion communicationDiretion) { try { if (!Configuration.EnablePersistingMessaging()) { return(true); } var serializedMessage = JsonConvert.SerializeObject(bubblingEvent); var directoryDate = string.Concat( DateTime.Now.Year, "\\", DateTime.Now.Month.ToString().PadLeft(2, '0'), "\\", DateTime.Now.Day.ToString().PadLeft(2, '0'), "\\", communicationDiretion.ToString()); var datetimeFile = string.Concat( DateTime.Now.Year, DateTime.Now.Month.ToString().PadLeft(2, '0'), DateTime.Now.Day.ToString().PadLeft(2, '0'), "-", DateTime.Now.Hour.ToString().PadLeft(2, '0'), "-", DateTime.Now.Minute.ToString().PadLeft(2, '0'), "-", DateTime.Now.Second.ToString().PadLeft(2, '0')); var persistingForlder = Path.Combine(Configuration.LocalStorageConnectionString(), directoryDate); Directory.CreateDirectory(persistingForlder); var filePersisted = Path.Combine( persistingForlder, string.Concat(datetimeFile, "-", bubblingEvent.MessageId, Configuration.MessageFileStorageExtension)); File.WriteAllText(filePersisted, serializedMessage); LogEngine.ConsoleWriteLine( "Event persisted - Consistency Transaction Point created.", ConsoleColor.DarkGreen); return(true); } catch (Exception ex) { LogEngine.WriteLog( Configuration.EngineName, $"Error in {MethodBase.GetCurrentMethod().Name}", Constant.DefconOne, Constant.TaskCategoriesError, ex, EventLogEntryType.Error); return(false); } }
public MouseDevice () { PreviewButtonPressEvent = new TunnelingEvent<MouseButtonEventArgs> (); ButtonPressEvent = new BubblingEvent<MouseButtonEventArgs> (); PreviewButtonReleaseEvent = new TunnelingEvent<MouseButtonEventArgs> (); ButtonReleaseEvent = new BubblingEvent<MouseButtonEventArgs> (); PreviewMotionNotifyEvent = new TunnelingEvent<MouseButtonEventArgs> (); MotionNotifyEvent = new BubblingEvent<MouseButtonEventArgs> (); MouseEnterEvent = new DirectEvent<EventArgs> (); MouseLeaveEvent = new DirectEvent<EventArgs> (); }
/// <summary> /// Initializes a new instance of the <see cref="EventActionContext"/> class. /// </summary> /// <param name="bubblingConfiguration"> /// The bubbling configuration. /// </param> public EventActionContext(BubblingEvent bubblingConfiguration) { this.BubblingConfiguration = bubblingConfiguration; }