private void taskCombo_SelectionChanged(object sender, SelectionChangedEventArgs e) { ComboBox box = sender as ComboBox; ShortCutInfo oldInfo = box.DataContext as ShortCutInfo; ObservableCollection <ShortCutInfo> userShortcutMap = null; DataGrid dataGrid = GlobalConfig.GetParentObject <DataGrid>(box, "_subListViewTouch");//查找第一列的Textbox if (dataGrid == null) { dataGrid = GlobalConfig.GetParentObject <DataGrid>(box, "_subListViewPress");//查找第一列的Textbox } userShortcutMap = dataGrid.ItemsSource as ObservableCollection <ShortCutInfo>; foreach (ShortCutInfo info in userShortcutMap) { if (info.AppShowName == box.SelectedValue) { box.SelectedValue = oldInfo.AppShowName; } } if (box.SelectedValue != null) { _shortCutInfoTemp.AppShowName = box.SelectedValue as string; } }
private void _subListView_BeginningEdit(object sender, DataGridBeginningEditEventArgs e) { if (e.Column.DisplayIndex <= 0) //第0列即使进入编辑状态,TextBlock也不能编辑 { e.Cancel = true; return; } _shortCutInfoTemp = e.Row.DataContext as ShortCutInfo; ChangeInputLanguage(); }
private void _subListView_RowEditEnding(object sender, DataGridRowEditEndingEventArgs e) { DataGrid dataGrid = sender as DataGrid; ObservableCollection <ShortCutInfo> userShortcutMap = dataGrid.ItemsSource as ObservableCollection <ShortCutInfo>; //TextBlock textBlock0 = GlobalConfig.GetChildObject<TextBlock>(dataGrid.ContainerFromElement(e.Row), "TextBlock0");//查找第一列的Textbox if (e.Row.IsNewItem || e.Row.IsEditing) { if (_shortCutInfoTemp.AppShowName == null || _shortCutInfoTemp.AppShowName == "" || _shortCutInfoTemp.ShortCutString == null || _shortCutInfoTemp.ShortCutString == "") { ShortCutInfo sInfo = e.Row.DataContext as ShortCutInfo; sInfo.Empty(); if (e.Row.IsNewItem) { userShortcutMap.Remove(sInfo); } else if (e.Row.IsEditing) { e.Cancel = true; } } else { // if (textBlock0 != null) // { string str1 = _shortCutInfoTemp.AppShowName; string str2 = _shortCutInfoTemp.ShortCutString; KeyTreeNodeTag tag = dataGrid.Tag as KeyTreeNodeTag; string processPath = ShortCutInfo._computerApps[str1]; //应包含应用程序显示名称 if (processPath.Length != 0) { _shortCutInfoTemp.AppShowName = str1; ushort appID = 0xffff; foreach (KeyValuePair <ushort, string> kvp in ShortCutInfo._constSuportApps) //路径中应包含相应的EXE { if (kvp.Value.Length > 0 && processPath.Contains(kvp.Value)) { appID = kvp.Key; break; } } if (_CreateSerial80 != null && _WriteDelegate != null) { byte[] data = _CreateSerial80(_shortCutInfoTemp.Control0, _shortCutInfoTemp.Shift0, _shortCutInfoTemp.Alt0, Convert.ToByte(_shortCutInfoTemp.key0), _shortCutInfoTemp.Control1, _shortCutInfoTemp.Shift1, _shortCutInfoTemp.Alt1, Convert.ToByte(_shortCutInfoTemp.key1), appID, 0, tag.keyType ); if (_WriteDelegate(data)) //对于记录应用信息只需保存安装目录即可 { //textBlock0.Text = " "; } else { ShortCutInfo sInfo = e.Row.DataContext as ShortCutInfo; sInfo.Empty(); if (e.Row.IsNewItem) { userShortcutMap.Remove(sInfo); } else if (e.Row.IsEditing) { e.Cancel = true; } dataGrid.UpdateLayout(); } } /* }*/ } } } }
public void ProcessDataComplete80(object result) { try { unsafe { byte[] byteAry = result as byte[]; fixed(byte *pByte = &(byteAry[0])) { byte Ctr_Alt_Shift0 = *(pByte + 8); byte Key0 = *(pByte + 9); byte Ctr_Alt_Shift1 = *(pByte + 10); byte Key1 = *(pByte + 11); ushort AppName = *((ushort *)(pByte + 12)); byte KeyType = *(pByte + 16); if (ShortCutInfo._constSuportApps.ContainsKey(AppName))//是否包含APPID { foreach (KeyValuePair <string, string> kvp in ShortCutInfo._computerApps) { if (kvp.Value.Contains(ShortCutInfo._constSuportApps[AppName]))//安装路径中是否包含EXE文件名称 { switch (KeyType) { case 0x01: //KEY_TOUCH_LEFT = 0x01, { KeyTreeNodeTag taginfo = touchCntNode.Children[0]._treeTag as KeyTreeNodeTag; bool bFind = false; foreach (ShortCutInfo info in taginfo.userShortcutMap) { if (info.AppShowName == kvp.Key) { bFind = true; break; } } if (false == bFind) { ShortCutInfo shortCutTemp = new ShortCutInfo(); shortCutTemp.Control0 = (Ctr_Alt_Shift0 & 0x01) != 0; shortCutTemp.Shift0 = (Ctr_Alt_Shift0 & 0x02) != 0; shortCutTemp.Alt0 = (Ctr_Alt_Shift0 & 0x04) != 0; shortCutTemp.key0 = (Key)Key0; shortCutTemp.Control1 = (Ctr_Alt_Shift1 & 0x01) != 0; shortCutTemp.Shift1 = (Ctr_Alt_Shift1 & 0x02) != 0; shortCutTemp.Alt1 = (Ctr_Alt_Shift1 & 0x04) != 0; shortCutTemp.key1 = (Key)Key1; shortCutTemp.AppShowName = kvp.Key; taginfo.userShortcutMap.Add(shortCutTemp); } } break; case 0x02: //KEY_TOUCH_RIGHT = 0x02, { KeyTreeNodeTag taginfo = touchCntNode.Children[1]._treeTag as KeyTreeNodeTag; bool bFind = false; foreach (ShortCutInfo info in taginfo.userShortcutMap) { if (info.AppShowName == kvp.Key) { bFind = true; break; } } if (false == bFind) { ShortCutInfo shortCutTemp = new ShortCutInfo(); shortCutTemp.Control0 = (Ctr_Alt_Shift0 & 0x01) != 0; shortCutTemp.Shift0 = (Ctr_Alt_Shift0 & 0x02) != 0; shortCutTemp.Alt0 = (Ctr_Alt_Shift0 & 0x04) != 0; shortCutTemp.key0 = (Key)Key0; shortCutTemp.Control1 = (Ctr_Alt_Shift1 & 0x01) != 0; shortCutTemp.Shift1 = (Ctr_Alt_Shift1 & 0x02) != 0; shortCutTemp.Alt1 = (Ctr_Alt_Shift1 & 0x04) != 0; shortCutTemp.key1 = (Key)Key1; shortCutTemp.AppShowName = kvp.Key; taginfo.userShortcutMap.Add(shortCutTemp); } } break; case 0x03: //KEY_TOUCH_MID = 0x03, { KeyTreeNodeTag taginfo = touchCntNode.Children[2]._treeTag as KeyTreeNodeTag; bool bFind = false; foreach (ShortCutInfo info in taginfo.userShortcutMap) { if (info.AppShowName == kvp.Key) { bFind = true; break; } } if (false == bFind) { ShortCutInfo shortCutTemp = new ShortCutInfo(); shortCutTemp.Control0 = (Ctr_Alt_Shift0 & 0x01) != 0; shortCutTemp.Shift0 = (Ctr_Alt_Shift0 & 0x02) != 0; shortCutTemp.Alt0 = (Ctr_Alt_Shift0 & 0x04) != 0; shortCutTemp.key0 = (Key)Key0; shortCutTemp.Control1 = (Ctr_Alt_Shift1 & 0x01) != 0; shortCutTemp.Shift1 = (Ctr_Alt_Shift1 & 0x02) != 0; shortCutTemp.Alt1 = (Ctr_Alt_Shift1 & 0x04) != 0; shortCutTemp.key1 = (Key)Key1; shortCutTemp.AppShowName = kvp.Key; taginfo.userShortcutMap.Add(shortCutTemp); } } break; case 0x04: //KEY_TOUCH_UP = 0x04, { KeyTreeNodeTag taginfo = touchCntNode.Children[3]._treeTag as KeyTreeNodeTag; bool bFind = false; foreach (ShortCutInfo info in taginfo.userShortcutMap) { if (info.AppShowName == kvp.Key) { bFind = true; break; } } if (false == bFind) { ShortCutInfo shortCutTemp = new ShortCutInfo(); shortCutTemp.Control0 = (Ctr_Alt_Shift0 & 0x01) != 0; shortCutTemp.Shift0 = (Ctr_Alt_Shift0 & 0x02) != 0; shortCutTemp.Alt0 = (Ctr_Alt_Shift0 & 0x04) != 0; shortCutTemp.key0 = (Key)Key0; shortCutTemp.Control1 = (Ctr_Alt_Shift1 & 0x01) != 0; shortCutTemp.Shift1 = (Ctr_Alt_Shift1 & 0x02) != 0; shortCutTemp.Alt1 = (Ctr_Alt_Shift1 & 0x04) != 0; shortCutTemp.key1 = (Key)Key1; shortCutTemp.AppShowName = kvp.Key; taginfo.userShortcutMap.Add(shortCutTemp); } } break; case 0x05: //KEY_TOUCH_DOWN = 0x05, { KeyTreeNodeTag taginfo = touchCntNode.Children[4]._treeTag as KeyTreeNodeTag; bool bFind = false; foreach (ShortCutInfo info in taginfo.userShortcutMap) { if (info.AppShowName == kvp.Key) { bFind = true; break; } } if (false == bFind) { ShortCutInfo shortCutTemp = new ShortCutInfo(); shortCutTemp.Control0 = (Ctr_Alt_Shift0 & 0x01) != 0; shortCutTemp.Shift0 = (Ctr_Alt_Shift0 & 0x02) != 0; shortCutTemp.Alt0 = (Ctr_Alt_Shift0 & 0x04) != 0; shortCutTemp.key0 = (Key)Key0; shortCutTemp.Control1 = (Ctr_Alt_Shift1 & 0x01) != 0; shortCutTemp.Shift1 = (Ctr_Alt_Shift1 & 0x02) != 0; shortCutTemp.Alt1 = (Ctr_Alt_Shift1 & 0x04) != 0; shortCutTemp.key1 = (Key)Key1; shortCutTemp.AppShowName = kvp.Key; taginfo.userShortcutMap.Add(shortCutTemp); } } break; case 0x11: //KEY_PRESS_LEFT = 0x11, { KeyTreeNodeTag taginfo = touchCntNode.Children[5]._treeTag as KeyTreeNodeTag; bool bFind = false; foreach (ShortCutInfo info in taginfo.userShortcutMap) { if (info.AppShowName == kvp.Key) { bFind = true; break; } } if (false == bFind) { ShortCutInfo shortCutTemp = new ShortCutInfo(); shortCutTemp.Control0 = (Ctr_Alt_Shift0 & 0x01) != 0; shortCutTemp.Shift0 = (Ctr_Alt_Shift0 & 0x02) != 0; shortCutTemp.Alt0 = (Ctr_Alt_Shift0 & 0x04) != 0; shortCutTemp.key0 = (Key)Key0; shortCutTemp.Control1 = (Ctr_Alt_Shift1 & 0x01) != 0; shortCutTemp.Shift1 = (Ctr_Alt_Shift1 & 0x02) != 0; shortCutTemp.Alt1 = (Ctr_Alt_Shift1 & 0x04) != 0; shortCutTemp.key1 = (Key)Key1; shortCutTemp.AppShowName = kvp.Key; taginfo.userShortcutMap.Add(shortCutTemp); } } break; case 0x12: //KEY_PRESS_RIGHT = 0x12, { KeyTreeNodeTag taginfo = touchCntNode.Children[6]._treeTag as KeyTreeNodeTag; bool bFind = false; foreach (ShortCutInfo info in taginfo.userShortcutMap) { if (info.AppShowName == kvp.Key) { bFind = true; break; } } if (false == bFind) { ShortCutInfo shortCutTemp = new ShortCutInfo(); shortCutTemp.Control0 = (Ctr_Alt_Shift0 & 0x01) != 0; shortCutTemp.Shift0 = (Ctr_Alt_Shift0 & 0x02) != 0; shortCutTemp.Alt0 = (Ctr_Alt_Shift0 & 0x04) != 0; shortCutTemp.key0 = (Key)Key0; shortCutTemp.Control1 = (Ctr_Alt_Shift1 & 0x01) != 0; shortCutTemp.Shift1 = (Ctr_Alt_Shift1 & 0x02) != 0; shortCutTemp.Alt1 = (Ctr_Alt_Shift1 & 0x04) != 0; shortCutTemp.key1 = (Key)Key1; shortCutTemp.AppShowName = kvp.Key; taginfo.userShortcutMap.Add(shortCutTemp); } } break; case 0x13: //KEY_PRESS_MID = 0x13, { KeyTreeNodeTag taginfo = touchCntNode.Children[7]._treeTag as KeyTreeNodeTag; bool bFind = false; foreach (ShortCutInfo info in taginfo.userShortcutMap) { if (info.AppShowName == kvp.Key) { bFind = true; break; } } if (false == bFind) { ShortCutInfo shortCutTemp = new ShortCutInfo(); shortCutTemp.Control0 = (Ctr_Alt_Shift0 & 0x01) != 0; shortCutTemp.Shift0 = (Ctr_Alt_Shift0 & 0x02) != 0; shortCutTemp.Alt0 = (Ctr_Alt_Shift0 & 0x04) != 0; shortCutTemp.key0 = (Key)Key0; shortCutTemp.Control1 = (Ctr_Alt_Shift1 & 0x01) != 0; shortCutTemp.Shift1 = (Ctr_Alt_Shift1 & 0x02) != 0; shortCutTemp.Alt1 = (Ctr_Alt_Shift1 & 0x04) != 0; shortCutTemp.key1 = (Key)Key1; shortCutTemp.AppShowName = kvp.Key; taginfo.userShortcutMap.Add(shortCutTemp); } } break; case 0x14: //KEY_PRESS_UP = 0x14, { KeyTreeNodeTag taginfo = touchCntNode.Children[8]._treeTag as KeyTreeNodeTag; bool bFind = false; foreach (ShortCutInfo info in taginfo.userShortcutMap) { if (info.AppShowName == kvp.Key) { bFind = true; break; } } if (false == bFind) { ShortCutInfo shortCutTemp = new ShortCutInfo(); shortCutTemp.Control0 = (Ctr_Alt_Shift0 & 0x01) != 0; shortCutTemp.Shift0 = (Ctr_Alt_Shift0 & 0x02) != 0; shortCutTemp.Alt0 = (Ctr_Alt_Shift0 & 0x04) != 0; shortCutTemp.key0 = (Key)Key0; shortCutTemp.Control1 = (Ctr_Alt_Shift1 & 0x01) != 0; shortCutTemp.Shift1 = (Ctr_Alt_Shift1 & 0x02) != 0; shortCutTemp.Alt1 = (Ctr_Alt_Shift1 & 0x04) != 0; shortCutTemp.key1 = (Key)Key1; shortCutTemp.AppShowName = kvp.Key; taginfo.userShortcutMap.Add(shortCutTemp); } } break; case 0x15: //KEY_PRESS_DOWN = 0x15 { KeyTreeNodeTag taginfo = touchCntNode.Children[9]._treeTag as KeyTreeNodeTag; bool bFind = false; foreach (ShortCutInfo info in taginfo.userShortcutMap) { if (info.AppShowName == kvp.Key) { bFind = true; break; } } if (false == bFind) { ShortCutInfo shortCutTemp = new ShortCutInfo(); shortCutTemp.Control0 = (Ctr_Alt_Shift0 & 0x01) != 0; shortCutTemp.Shift0 = (Ctr_Alt_Shift0 & 0x02) != 0; shortCutTemp.Alt0 = (Ctr_Alt_Shift0 & 0x04) != 0; shortCutTemp.key0 = (Key)Key0; shortCutTemp.Control1 = (Ctr_Alt_Shift1 & 0x01) != 0; shortCutTemp.Shift1 = (Ctr_Alt_Shift1 & 0x02) != 0; shortCutTemp.Alt1 = (Ctr_Alt_Shift1 & 0x04) != 0; shortCutTemp.key1 = (Key)Key1; shortCutTemp.AppShowName = kvp.Key; taginfo.userShortcutMap.Add(shortCutTemp); } } break; } break; } } } } } } catch (System.Exception ex) { string str = ex.Message; } }