private void SpyderConsole_Refresh(IPRefreshPacket pkt) { var newSegments = pkt.GetPortRefresh(); List <int> keysOn = new List <int>(); List <int> keysOff = new List <int>(); List <QuickKeyButton> quickKeys = new List <QuickKeyButton>(); foreach (var newSegment in newSegments) { int segmentID = newSegment.Key; var segment = newSegment.Value; var spyderKeys = segment.ColorButtons; var sm3Keys = buttonMap.GetKeysFromSegmentID(segmentID); var mappings = from spyderKey in spyderKeys join sm3Key in sm3Keys on spyderKey.ControlID equals sm3Key.Value.SpyderButtonIndex select new { Sm3Index = sm3Key.Key, Mapping = sm3Key.Value, SpyderKey = spyderKey, spyderKey.Text, QuickKeyIndex = KeyConfig.GetQuickKeyIndex(sm3Key.Key) }; var lampMappings = from mapping in mappings where mapping.QuickKeyIndex == -1 select new { Index = mapping.Sm3Index, LampOn = ShouldLampBeOn(mapping.SpyderKey) }; var quickKeyMappings = from mapping in mappings where mapping.QuickKeyIndex != -1 select new QuickKeyButton() { Index = mapping.QuickKeyIndex, Text = GetQuickKeyText(segment, mapping.SpyderKey), Color = GetQuickKeyColor(mapping.SpyderKey) }; keysOn.AddRange(lampMappings.Where(key => key.LampOn).Select(key => key.Index)); keysOff.AddRange(lampMappings.Where(key => !key.LampOn).Select(key => key.Index)); quickKeys.AddRange(quickKeyMappings); } //Send lamp updates to SM3 screenMasterConsole.SetLamps(true, keysOn.ToArray()); screenMasterConsole.SetLamps(false, keysOff.ToArray()); screenMasterConsole.SetQuickKeys(quickKeys.ToArray()); }
private void client_Refresh(IPRefreshPacket pkt) { var updatedSegmentData = pkt.GetPortRefresh(); dispatcher.BeginInvoke((ThreadStart)(() => { foreach (int port in updatedSegmentData.Keys) { var segment = (Segment)updatedSegmentData[port]; //Need to force the segment type to update on the source module; it only returns 2x8 typed segments? segment.Type = this.segments[port].SegmentType; this.segments[port].CopyFrom(segment, LcdDisplayMode.Segment); } })); }