public void MergeAndUpdate(EventClass cl) { if (!Classes.ContainsKey(cl.ClassName)) { Classes.Add(cl.ClassName, cl); FireClassChanged(cl); foreach (Runner r in cl.Runners.Values) { FireRunnerChanged(r); } } else { if (!Classes[cl.ClassName].DefinitionEquals(cl)) { //Something changed, update and FireChange... Classes[cl.ClassName].CourseLength = cl.CourseLength; Classes[cl.ClassName].Order = cl.Order; Classes[cl.ClassName].RadioControls = cl.RadioControls; FireClassChanged(Classes[cl.ClassName]); } /*Merge Runners and find Changes*/ List<Runner> deletedRunners; List<Runner> updatedRunners = Classes[cl.ClassName].UpdateRunnersInClassAndGetChanges(cl.Runners, out deletedRunners); } }
void m_Parser_OnClass(string className, int courseLength, int numControls, int order, List<ControlStruct> splitControls) { if (!m_ModelEvent.Classes.ContainsKey(className)) { EventClass ec = new EventClass() { ClassName = className, CourseLength = courseLength, Order = order, RadioControls = null, Runners = new Dictionary<int, Runner>() }; if (splitControls != null) ec.RadioControls = splitControls.Select(x => new RadioControl() { ControlName = x.Name, ControlCode = x.Code, Upload = true }).ToList(); m_ModelEvent.Classes.Add(className, ec); m_ModelEvent.FireClassChanged(ec); m_Logger("[" + className + "] added"); } else { EventClass ec = m_ModelEvent.Classes[className]; ec.ClassName = className; ec.CourseLength = courseLength; ec.Order = order; if (splitControls != null) ec.RadioControls = splitControls.Select(x => new RadioControl() { ControlName = x.Name, ControlCode = x.Code, Upload = true }).ToList(); m_ModelEvent.FireClassChanged(ec); m_Logger("[" + className + "] changed"); } }
public void BasicEventExplicitThis() { var o = new EventClass(); var success = false; o.FooThis += () => success = true; o.OnFooThis(); AssertTrue(success); }
public void MulticastEvent() { var o = new EventClass(); var success1 = false; var success2 = false; o.Foo += () => success1 = true; o.Foo += () => success2 = true; o.OnFoo(); AssertTrue(success1); AssertTrue(success2); }
public void MulticastEventRemove() { var o = new EventClass(); var success1 = false; var success2 = false; Action foo1 = () => success1 = true; o.Foo += foo1; o.Foo += () => success2 = true; o.Foo -= foo1; o.OnFoo(); AssertTrue((!success1)); AssertTrue(success2); }
public static byte[] GetEncodedData(EventClass eventClass, EventType type, HookArgs args, int[] pressedKeys=null, char pressedChar='\0') { byte[] data = null; using (MemoryStream ms = new MemoryStream()) { ms.WriteByte(GetHeaderByte(eventClass, type, args)); if (eventClass == EventClass.MouseEvent) { MouseHookEventArgs me = args as MouseHookEventArgs; ms.Write(BitConverter.GetBytes((ushort)me.Location.X),0 , 2); ms.Write(BitConverter.GetBytes((ushort)me.Location.Y), 0, 2); //ms.WriteByte((byte)me.Location.X); //ms.WriteByte((byte)me.Location.Y); //System.Windows.Forms.MouseButtons.Right; ms.WriteByte((byte)((int)me.Button >> 20)); byte extra = 0; switch (type) { case EventType.MouseClick: case EventType.MouseDblClick: extra = (byte)me.ClickCount; break; case EventType.MouseWheel: extra = (byte)Math.Abs(me.ScrollAmount); if (me.ScrollAmount < 0) extra |= 0x80; break; } ms.WriteByte(extra); } else { KeyHookEventArgs ke = args as KeyHookEventArgs; byte[] pKeys = { 0, 0, 0 }; int len = Math.Min(3, pressedKeys.Length); for (int i = 0; i < len; i++) pKeys[i] = (byte)pressedKeys[i]; ms.Write(pKeys, 0, 3); ms.WriteByte((byte)pressedChar); } data = ms.ToArray(); } return data; }
private static byte GetHeaderByte(EventClass ec, EventType et, HookArgs ha) { byte head = 0; if(ec == EventClass.MouseEvent) head = 0x80; head |= (byte)((uint)et << 4); if (ha.Alt) head |= 0x08; if(ha.Control) head |= 0x04; if (ha.Shift) head |= 0x02; if (ha.CapsLock) head |= 0x01; return head; }
public EventTypeSpec(EventClass evtClass, AppleEventKind appleKind) { this.EventClass = evtClass; this.EventKind = (uint)appleKind; }
public EventTypeSpec(EventClass evtClass, WindowEventKind evtKind) { this.EventClass = evtClass; this.EventKind = (uint)evtKind; }
public void RemoveMethodHandler() { var eventClass = new EventClass(); var eventHandlers = new EventHandlers(); eventClass.Foo += eventHandlers.M1; eventClass.Foo += eventHandlers.M2; eventClass.OnFoo(); AssertEquals(eventHandlers.m1, "M1"); AssertEquals(eventHandlers.m2, "M2"); eventHandlers.m1 = null; eventHandlers.m2 = null; eventClass.Foo -= eventHandlers.M1; eventClass.OnFoo(); AssertEquals(eventHandlers.m2, "M2"); AssertTrue((eventHandlers.m1 == null)); }
public void OnEventSelected(EventClass eventObject) { }
private void Grid_CurrentCellChanged(object sender, EventArgs e) { EventClass.getInstance().RunDisable(); updateButton.IsEnabled = true; deleteButton.IsEnabled = true; }
public EventTypeSpec(EventClass evtClass, MouseEventKind evtKind) { this.EventClass = evtClass; this.EventKind = (uint)evtKind; }
public EventInfoX(EventClass e) { _event = e; _type = e.RootPointer.TypeDesigntime; }
public MethodInfoEventHandlerRemove(EventClass e) : base(e) { }
public MethodInfoEventHandlerAdd(EventClass e) : base(e) { }
public MethodInfoEventHandler(EventClass e) { _event = e; _type = e.RootPointer.TypeDesigntime; }
public void OnAddEvent(EventClass eventObject) { }
/// <summary> /// 数据分析接口 /// </summary> /// <param name="lockname"></param> /// <param name="starttime"></param> /// <param name="endtime"></param> /// <param name="username"></param> /// <returns></returns> public string StatisticalAnalysis(string lockname, string starttime, string endtime, string username) { string msg = string.Empty; RecordGolable obj = DataAnalysis.GetInstance().StatisticalAnalysis(out msg, EventClass.GetInstance()._gloabledataTable, lockname, starttime, endtime, username); if (msg != "Success") { return(msg); } else { string json = JsonConvert.SerializeObject(obj._monthlydisplaysList); return(json); } }
/// <summary> /// Создает индекс риска с известными параметрами /// </summary> /// <param name="eventCategory">Категория события</param> /// <param name="eventClass">Класс события</param> public RiskIndex(EventCategory eventCategory, EventClass eventClass) { EventCategory = eventCategory; EventClass = eventClass; }
/// <summary> /// 清除内存变量 /// </summary> /// <returns></returns> private string ClearDevice() { EventClass.GetInstance().Cleanup(); RecordLog.GetInstance().WriteLog(Level.Info, "初始化参数"); return("初始化参数"); }
static void Main(string[] args) { //Calculator cobj = new Calculator(); /*Calculations CalDelegate; * CalDelegate = cobj.sub; * CalDelegate += cobj.add; * * CalDelegate.Invoke(5, 3); */ /*Calculations CalDelegate1 = new Calculations(cobj.add); * Calculations CalDelegate2 = new Calculations(cobj.sub); * CalDelegate1 += CalDelegate2; * CalDelegate1(5, 4); */ /*Calculations CalDelegate = new Calculations(cobj.add); * //CalDelegate.Invoke(7, 8); * CalDelegate(4, 5); */ /*Calculations AddDelegate = new Calculations(cobj.add); * cobj.AssignDelegate(AddDelegate); //Dynamic (Using this, we can send method in function parameter.) */ /* * LambdaClass lobj = new LambdaClass(); * Console.WriteLine(lobj.add(5, 6)); */ /*LambdaClass lobj = new LambdaClass(); * ArithmeticDelegate add = (x, y) => x + y; * ArithmeticDelegate mul = (x, y) => x * y; * * lobj.OperationDelegate(4, 5, mul); //this make loose coupling. */ /*ActionClass aobj = new ActionClass(); * aobj.display(); */ /*ActionClass aobj = new ActionClass(); * Action<int,int> Add = (x, y) => Console.WriteLine(x + y); * Action<int, int> mul = (x, y) => Console.WriteLine(x * y); * * aobj.ArithmeticOperation(4, 5, mul); */ Calculator cobj = new Calculator(); EventClass eobj = new EventClass(); // ArithmeticOperations arithmeticOperationsDelegate; eobj.WorkPerformed += cobj.add; eobj.WorkPerformed += cobj.sub; eobj.WorkPerformed += cobj.mul; eobj.WorkPerformed += cobj.add; eobj.WorkPerformed -= cobj.sub; eobj.WorkPerformed += delegate(int x, int y) //Anonymous method. { Console.WriteLine("division of given values: " + (x / y)); }; eobj.DoWork(4, 5); //eobj.Working(5, 6); //another event }
public Dictionary<string, EventClass> ParseIOFXmlFile(string filename) { bool processed = false; Dictionary<string, EventClass> ret = new Dictionary<string, EventClass>(); for (int i = 0; i < 10; i++) { try { StreamReader sr = null; if (!File.Exists(filename)) { return null; } else { sr = new StreamReader(filename, Encoding.Default); } string tmp = sr.ReadToEnd(); sr.Close(); File.Delete(filename); tmp = tmp.Replace("<!DOCTYPE ResultList SYSTEM \"IOFdata.dtd\">", ""); processed = true; XmlDocument xmlDoc = new XmlDocument(); xmlDoc.LoadXml(tmp); foreach (XmlNode classNode in xmlDoc.GetElementsByTagName("ClassResult")) { XmlNode classNameNode = classNode.SelectSingleNode("ClassShortName"); string className = classNameNode.InnerText; EventClass eventClass = null; if (ret.ContainsKey(className)) { eventClass = ret[className]; } else { eventClass = new EventClass(); ret.Add(className, eventClass); eventClass.ClassName = className; } foreach (XmlNode personNode in classNode.SelectNodes("PersonResult")) { XmlNode personNameNode = personNode.SelectSingleNode("Person/PersonName"); string familyname = personNameNode.SelectSingleNode("Family").InnerText; string givenname = personNameNode.SelectSingleNode("Given").InnerText; string id = personNode.SelectSingleNode("Person/PersonId").InnerText; long pid = 0; if (id.Trim().Length > 0) { pid = Convert.ToInt64(id); } string club = personNode.SelectSingleNode("Club/ShortName").InnerText; string status = personNode.SelectSingleNode("Result/CompetitorStatus").Attributes["value"].Value; string time = personNode.SelectSingleNode("Result/Time").InnerText; string si = personNode.SelectSingleNode("Result/CCard/CCardId").InnerText; int iSi; if (!Int32.TryParse(si, out iSi)) { //NO SICARD! FireLogMsg("No SICard for Runner: " + familyname + " " + givenname); } int dbid = 0; if (pid < Int32.MaxValue && pid > 0) { dbid = (int)pid; } else if (iSi > 0) { dbid = -1 * iSi; } else { FireLogMsg("Cant generate DBID for runner: " + givenname + " " + familyname); } int itime = -1; itime = ParseTime(time); RunnerStatus istatus = RunnerStatus.STARTED; switch (status) { case "MisPunch": istatus = RunnerStatus.MISSING_PUNCH; break; case "Disqualified": istatus = RunnerStatus.DISQUALIFIED; break; case "DidNotFinish": istatus = RunnerStatus.MISSING_PUNCH; itime = -2; break; case "DidNotStart": istatus = RunnerStatus.DID_NOT_START; itime = -3; break; case "Overtime": istatus = RunnerStatus.OVERTIME; break; case "OK": istatus = RunnerStatus.OK; break; } Runner r = new Runner(); r.ClassName = className; r.ClubName = club; r.FirstName = givenname; r.ID = dbid; r.LastName = familyname; r.Status = istatus; r.Time = itime; eventClass.Runners.Add(dbid, r); List<int> lsplitCodes = new List<int>(); List<int> lsplitTimes = new List<int>(); XmlNodeList splittimes = personNode.SelectNodes("Result/SplitTime"); List<ResultStruct> splits = new List<ResultStruct>(); if (splittimes != null) { foreach (XmlNode splitNode in splittimes) { XmlNode splitcode = splitNode.SelectSingleNode("ControlCode"); XmlNode splittime = splitNode.SelectSingleNode("Time"); int i_splitcode; string s_splittime = splittime.InnerText; if (int.TryParse(splitcode.InnerText, out i_splitcode) && s_splittime.Length > 0) { if (i_splitcode == 999) { if (istatus == 0 && itime == -1) { //Målstämpling itime = ParseTime(s_splittime); } } else { i_splitcode += 1000; while (lsplitCodes.Contains(i_splitcode)) { i_splitcode += 1000; } int i_splittime = ParseTime(s_splittime); lsplitCodes.Add(i_splitcode); lsplitTimes.Add(i_splittime); ResultStruct rs = new ResultStruct(); rs.ControlCode = i_splitcode; rs.Time = i_splittime; splits.Add(rs); } } } } for (int c = 0; c < splits.Count; c++) { r.RadioTimes.Add(splits[c].ControlCode, splits[c].Time); } } } } catch (Exception ee) { FireLogMsg(ee.Message); } if (!processed) { System.Threading.Thread.Sleep(1000); } else { break; } } if (!processed) { FireLogMsg("Could not open " + filename + " for processing"); return null; } else { return ret; } }
public void FireClassChanged(EventClass cl) { ClassChangedHandler h = ClassChanged; if (h != null) h(cl); }
void m_ModelEvent_ClassChanged(EventClass cl) { m_Logger("Class Changed: " + cl.ClassName); m_Server.QueueUpload(cl.OnlineClass); }
public ProjectLayer(MODBEntities db) : base(null, true) { this.db = db; EventClass.getInstance().UpdateEvent += Update; }
void m_Parser_OnResult(int id, int SI, string firstName, string lastName, string club, string Class, int start, int time, RunnerStatus status, List<ResultStruct> splits) { if (!m_ModelEvent.Classes.ContainsKey(Class)) { //New Class! EventClass ec = new EventClass() { ClassName = Class, Runners = new Dictionary<int, Runner>(), Upload = true }; m_ModelEvent.Classes.Add(Class, ec); m_ModelEvent.FireClassChanged(ec); m_Logger("[" + Class + "] added"); Runner r = CreateRunner(id, firstName, lastName, club, Class, start, time, status, splits); ec.Runners.Add(id, r); m_ModelEvent.FireRunnerChanged(r); } else { if (!m_ModelEvent.Classes[Class].Runners.ContainsKey(id)) { //new runner Runner r = CreateRunner(id, firstName, lastName, club, Class, start, time, status, splits); if (time == -2) //split updated { r.Time = -1; r.Status = RunnerStatus.STARTED; } m_ModelEvent.Classes[Class].Runners.Add(id,r); m_ModelEvent.FireRunnerChanged(r); m_Logger("[" + Class + "] Runner " + r.FirstName + " " + r.LastName + " added.."); } else { Runner r = m_ModelEvent.Classes[Class].Runners[id]; Dictionary<int, int> radioTimes = null; if (splits != null) { radioTimes = splits.ToDictionary(x => x.ControlCode, x => x.Time); } if (time != -2) { if (r.MergeNewValues(start, time, status, r.RadioTimes)) { m_ModelEvent.FireRunnerChanged(r); m_Logger("[" + Class + "] Runner " + r.FirstName + " " + r.LastName + " changed.."); } } else { if (radioTimes != null) { bool haveChange = false; foreach (var kvp in radioTimes) { if (r.RadioTimes.ContainsKey(kvp.Key)) { if (r.RadioTimes[kvp.Key] != kvp.Value) { r.RadioTimes[kvp.Key] = kvp.Value; haveChange = true; } } else { r.RadioTimes.Add(kvp.Key, kvp.Value); haveChange = true; } } if (haveChange) { m_ModelEvent.FireRunnerChanged(r); m_Logger("[" + Class + "] Runner " + r.FirstName + " " + r.LastName + " splittimechanged.."); } } } } } }
internal EventTypeSpec(EventClass evtClass, MouseEventKind evtKind) { this.EventClass = evtClass; this.EventKind = (uint)evtKind; }
public EventTypeSpec(EventClass evtClass, KeyboardEventKind evtKind) { this.EventClass = evtClass; this.EventKind = (uint)evtKind; }
private void CancelButton_Click(object sender, RoutedEventArgs e) { EventClass.getInstance().RunCancel(); EventClass.getInstance().RunEnable(); }
static extern OSStatus CreateEvent(IntPtr inAllocator, EventClass inClassID, UInt32 kind, EventTime when, EventAttributes flags, out IntPtr outEvent);
private void Update() { EventClass.getInstance().RunUpdate(); EventClass.getInstance().RunEnable(); }
private static void FromHeaderByte(byte head, out EventClass ec, out EventType et, out HookArgs ha) { if ((head & 0x80) == 0x80) ec = EventClass.MouseEvent; else ec = EventClass.KeyEvent; et = (EventType)((head & 0x70) >> 4); ha = new HookArgs((head & 0x08) == 0x08, (head & 0x04) == 0x04, (head & 0x02) == 0x02, (head & 0x01) == 0x01, false, false); }
private void Cancel() { EventClass.getInstance().RunCancel(); EventClass.getInstance().RunEnable(); }
public static bool GetDecodedData(int offset, byte[] data, out EventClass eventClass, out EventType type, out HookArgs args, out byte[] pressedKeys, out char pressedChar) { using (MemoryStream ms = new MemoryStream(data)) { // Set Offset ms.Position = offset; // Assign pressedKeys = null; pressedChar = '\0'; eventClass = EventClass.None; type = EventType.None; args = null; // Check if (ms.Position < ms.Length) { FromHeaderByte((byte)ms.ReadByte(), out eventClass, out type, out args); pressedKeys = new byte[3] { 0, 0, 0 }; if (eventClass == EventClass.MouseEvent) { //int x = ms.ReadByte(); //int y = ms.ReadByte(); byte[] loc = new byte[2]; ms.Read(loc, 0, 2); int x = BitConverter.ToInt16(loc, 0); ms.Read(loc, 0, 2); int y = BitConverter.ToInt16(loc, 0); System.Windows.Forms.MouseButtons button = System.Windows.Forms.MouseButtons.None; switch(ms.ReadByte()) { case 1: button = System.Windows.Forms.MouseButtons.Left; break; case 2: button = System.Windows.Forms.MouseButtons.Right; break; case 4: button = System.Windows.Forms.MouseButtons.Middle; break; case 8: button = System.Windows.Forms.MouseButtons.XButton1; break; case 16: button = System.Windows.Forms.MouseButtons.XButton2; break; } int extra = ms.ReadByte(); int click = 0; int scroll = 0; switch (type) { case EventType.MouseClick: case EventType.MouseDblClick: click = extra; break; case EventType.MouseWheel: if ((extra & 0x80) == 0x80) scroll = -1; else scroll = 1; extra &= 0x7F; scroll = scroll * extra * 120; //Delta break; } args = new MouseHookEventArgs(false, button, click, x, y, scroll, args.Alt, args.Control, args.Shift, args.CapsLock, args.NumLock, args.ScrollLock); } else { ms.Read(pressedKeys, 0, 3); pressedChar = (char)ms.ReadByte(); args = new KeyHookEventArgs(pressedKeys[0], pressedChar, false, args.Alt, args.Control, args.Shift, args.CapsLock, args.NumLock, args.ScrollLock); } return true; } } return false; }
public void Dispose() { model.Dispose(); EventClass.getInstance().DisableEvent -= enableButton; EventClass.getInstance().EnableEvent -= disableButton; }
/// <summary> /// 数据导出 /// </summary> public void DataTableToExcel() { string path = string.Empty; SaveFileDialog saveFileDialog = new SaveFileDialog(); saveFileDialog.Filter = "Execl 表格文件 (*.xls)|*.xls"; saveFileDialog.FilterIndex = 0; saveFileDialog.RestoreDirectory = true; saveFileDialog.CreatePrompt = false; saveFileDialog.Title = "导出Excel文件"; //设置默认文件名称 saveFileDialog.FileName = "报表-" + DateTime.Now.ToString("yyyyMMdd-HHmmss") + ".xls"; if (saveFileDialog.ShowDialog() != System.Windows.Forms.DialogResult.OK) { return; } if (saveFileDialog.FileName == "") { return; } Task ta = Task.Factory.StartNew(delegate { DoExcelHelper.GetInstance().DataTableToExcel(EventClass.GetInstance()._gloabledataTable, saveFileDialog.FileName, "Table1"); }); Task.WaitAny(ta); //DoExcelHelper.GetInstance().DataGridtoExcelModify(EventClass.GetInstance()._gloabledataTable); }
public void Dispose() => EventClass.getInstance().UpdateEvent -= Update;
public EventInfo(IntPtr eventRef) { EventClass = API.GetEventClass(eventRef); EventKind = API.GetEventKind(eventRef); }
public void Dispose() { EventClass.getInstance().CancelEvent -= Cancel; EventClass.getInstance().UpdateEvent -= Update; }
static extern OSStatus CreateEvent( IntPtr inAllocator, EventClass inClassID, UInt32 kind, EventTime when, EventAttributes flags, out IntPtr outEvent);
public void EventAccessor() { var eventClass = new EventClass(); var ran = false; Action evt = () => ran = true; eventClass.Bar += evt; eventClass.OnBar(); AssertTrue(ran); ran = false; eventClass.Bar -= evt; eventClass.OnBar(); AssertTrue((!ran)); }
public void MulticastEventKeepsDelegateType() { var i = 0; var eventClass = new EventClass(); eventClass.Foo += () => i++; eventClass.Foo += () => i++; var action = eventClass.GetFoo(); AssertTrue((action is Action)); }
internal EventTypeSpec(EventClass evtClass, KeyboardEventKind evtKind) { this.EventClass = evtClass; this.EventKind = (uint)evtKind; }
/// <summary> /// Constructs a GEDCOMEventStructure from a GEDCOMRecord /// </summary> /// <param name = "record">a GEDCOMRecord</param> /// <param name = "eventClass"></param> public GEDCOMEventStructure(GEDCOMRecord record, EventClass eventClass) : base(record) { _eventClass = eventClass; }
private static OSStatus _CreateEvent(IntPtr inAllocator, EventClass inClassID, uint kind, double when, EventAttributes flags, out IntPtr outEvent);
public void OnDeleteEvent(EventClass eventObject) { _objExplorer.OnDeleteEvent(eventObject); }
public void OnDeleteEvent(EventClass eventObject) { }
internal EventTypeSpec(EventClass evtClass, AppleEventKind appleKind) { this.EventClass = evtClass; this.EventKind = (uint)appleKind; }
public void OnAddEvent(EventClass eventObject) { _objExplorer.OnAddEvent(eventObject); }
internal EventTypeSpec(EventClass evtClass, WindowEventKind evtKind) { this.EventClass = evtClass; this.EventKind = (uint)evtKind; }
public void OnEventSelected(EventClass eventObject) { _objExplorer.OnEventSelected(eventObject); }
internal EventInfo(IntPtr eventRef) { this._eventClass = API.GetEventClass(eventRef); this._eventKind = API.GetEventKind(eventRef); }
public void Dispose() { EventClass.getInstance().UpdateEvent -= Update; EventClass.getInstance().DisableEvent -= Disabl; EventClass.getInstance().EnableEvent -= Enabl; }