public void SaveKey( ) { string err = String.Empty; if (!ValidateInput(ref err)) { MessageService.ShowError(err); return; } try { if (_newKey != null) { _newKey.Create(); _initializing = true; cmbPk.Items.Add(_newKey); cmbPk.SelectedItem = _newKey; _newKey = null; _initializing = false; } else if (SelectedKey != null) { SelectedKey.DropAndRecreate(); } } catch (Exception ex) { if (ex.GetType() != typeof(CancelledByUserException)) { Utils.ShowException(ex); } } }
public bool Remove(TKey key) { if (key == null) { throw new ArgumentNullException("key"); } TValue value; bool removed = false; if (Dictionary.TryGetValue(key, out value)) { removed = Dictionary.Remove(key); if (removed) { if ((key == null && SelectedKey == null) || SelectedKey.Equals(key)) { SelectedKey = default(TKey); } OnCollectionChanged(); } } return(removed); }
public void RefreshPrimaryKeys(bool loadProps, TableWrapper initialTable) { string keyName = String.Empty; try { _initializing = true; keyName = SelectedKey != null?SelectedKey.ToString() : String.Empty; DbCmd.PopulatePrimaryKeysCombo(cmbPk, _cp, loadProps, (initialTable != null ? initialTable.ID : -1)); _initialTable = initialTable; DbCmd.PopulateUserDefinedTablesCombo(cmbTables, _cp, (initialTable != null ? initialTable.ID : -1)); } finally { _initializing = false; } if (cmbPk.Items.Count > 0) { cmbPk.SelectedIndex = cmbPk.FindStringExact(keyName); if (cmbPk.SelectedIndex < 0) { cmbPk.SelectedIndex = 0; } } else { CreateNewKey(); } }
void IDictionary.Remove(object key) { if (key == null) { throw new ArgumentNullException("key"); } if (!(key is TKey)) { throw new ArgumentException("The type of parameter \"key\" must be " + typeof(TKey).Name, "key"); } TValue value; if (Dictionary.TryGetValue((TKey)key, out value)) { if (Dictionary.Remove((TKey)key)) { if ((key == null && SelectedKey == null) || SelectedKey.Equals(key)) { SelectedKey = default(TKey); } OnCollectionChanged(); } } }
protected override void Execute(CodeActivityContext context) { Int32 _delayAfter = Common.GetValueOrDefault(context, this.DelayAfter, 300); Int32 _delayBefore = Common.GetValueOrDefault(context, this.DelayBefore, 300); try { Thread.Sleep(_delayBefore); var selStr = Selector.Get(context); UiElement element = Common.GetValueOrDefault(context, this.Element, null); if (element == null && selStr != null) { element = UiElement.FromSelector(selStr); } Int32 pointX = 0; Int32 pointY = 0; if (usePoint) { pointX = offsetX.Get(context); pointY = offsetY.Get(context); } else { if (element != null) { pointX = element.GetClickablePoint().X; pointY = element.GetClickablePoint().Y; element.SetForeground(); } } if (isRunClick) { UiElement.MouseMoveTo(pointX, pointY); UiElement.MouseAction((Plugins.Shared.Library.UiAutomation.ClickType)ClickType, (Plugins.Shared.Library.UiAutomation.MouseButton)MouseButton); } DealBaseKeyBordPress(); if (Common.DealVirtualKeyPress(SelectedKey.ToUpper())) { Common.DealVirtualKeyRelease(SelectedKey.ToUpper()); } DealBaseKeyBordRelease(); Thread.Sleep(_delayAfter); } catch (Exception e) { SharedObject.Instance.Output(SharedObject.enOutputType.Error, "有一个错误产生", e.Message); if (ContinueOnError.Get(context)) { return; } else { throw new NotImplementedException(e.Message); } } }
protected override void Execute(CodeActivityContext context) { Int32 _delayAfter = Common.GetValueOrDefault(context, this.DelayAfter, 300); Int32 _delayBefore = Common.GetValueOrDefault(context, this.DelayBefore, 300); try { Thread.Sleep(_delayBefore); var selStr = Selector.Get(context); UiElement element = Common.GetValueOrDefault(context, this.Element, null); if (element == null && selStr != null) { element = UiElement.FromSelector(selStr); } //Int32 pointX = 0; //Int32 pointY = 0; //if (usePoint) //{ // pointX = offsetX.Get(context); // pointY = offsetY.Get(context); //} //else //{ // if (element != null) // { // pointX = element.GetClickablePoint().X; // pointY = element.GetClickablePoint().Y; // element.SetForeground(); // } //} var point = UIAutomationCommon.GetPoint(context, usePoint, offsetX, offsetY, element); if (point.X == -1 && point.Y == -1) { UIAutomationCommon.HandleContinueOnError(context, ContinueOnError, Localize.LocalizedResources.GetString("msgNoElementFound")); return; } if (isRunClick) { UiElement.MouseMoveTo(point); UiElement.MouseAction((Plugins.Shared.Library.UiAutomation.ClickType)ClickType, (Plugins.Shared.Library.UiAutomation.MouseButton)MouseButton); } DealBaseKeyBordPress(); if (Common.DealVirtualKeyPress(SelectedKey.ToUpper())) { Common.DealVirtualKeyRelease(SelectedKey.ToUpper()); } DealBaseKeyBordRelease(); Thread.Sleep(_delayAfter); } catch (Exception e) { UIAutomationCommon.HandleContinueOnError(context, ContinueOnError, e.Message); } }
/// <summary> /// Loads top level entry list /// </summary> /// <history> /// [tamttt] 20/10/2004 Created /// </history> private void InitList() { ListController ctlLists = new ListController(); string listName = SelectedKey.Substring(SelectedKey.IndexOf(":") + 1); string parentKey = SelectedKey.Replace(listName, "").TrimEnd(':'); selListInfo = ctlLists.GetListInfo(listName, parentKey); SelectedText = selListInfo.DisplayName; EnableSortOrder = selListInfo.EnableSortOrder; SystemList = selListInfo.SystemList; }
private void SaveKey( ) { grd.EndEdit(); string err = String.Empty; if (!ValidateInput(ref err)) { MessageService.ShowError(err); return; } string hostCols = String.Empty; string refCols = String.Empty; GenerateCols(out hostCols, out refCols); SelectedKey.ColsHost = hostCols; SelectedKey.ColsRef = refCols; bool isNew = _newKey != null; try { _initializing = true; if (_newKey != null) { _newKey.Create(); _newKey = null; } else if (SelectedKey != null) { SelectedKey.DropAndRecreateKey(); } InitializeForeignKeys(_mode, _hostTable, true); if (isNew && _afterNewKeySaved != null) { _afterNewKeySaved(this, SelectedKey); } else if (_afterKeySaved != null) { _afterKeySaved(this, SelectedKey); } } catch (Exception ex) { MessageService.ShowError(ex.Message); } finally { _initializing = false; } }
/// <summary> /// Delete List /// </summary> /// <history> /// [tamttt] 20/10/2004 Created /// </history> protected void cmdDeleteList_Click(object sender, EventArgs e) { string listName = SelectedKey.Substring(SelectedKey.IndexOf(":") + 1); string parentKey = SelectedKey.Replace(listName, "").TrimEnd(':'); ListController ctlLists = new ListController(); ctlLists.DeleteList(listName, parentKey); Response.Redirect(Globals.NavigateURL(TabId)); //BindTree() }
private void cmbFk_SelectedIndexChanged(object sender, EventArgs e) { if (_initializing || SelectedKey == null) { return; } if (!SelectedKey.AllPropsLoaded) { SelectedKey.LoadAllProperties(); } RenderKeyProperties(); }
private void ToggleKeyState( ) { if (SelectedKey.Disabled) { SelectedKey.Enable(); } else { SelectedKey.Disable(); } if (_afterKeyStateChanged != null) { _afterKeyStateChanged(this, SelectedKey); } }
public void UseKeys(byte[] keyA, byte[] keyB, byte[] accessBits, SelectedKey selKey) { if (!IsConnected) { throw new InvalidOperationException("No port connected"); } if (keyA.Length != 6 || keyB.Length != 6 || accessBits.Length != 4) { throw new InvalidOperationException("KeyA and KeyB must be 6, AccessBits must be 4 bytes long"); } AddCommandToQueue(new UseKeysCommand(this) { KeyA = keyA, KeyB = keyB, AccessBits = accessBits, SelectedKey = selKey }); }
/// <summary> /// Handles Add New Entry command /// </summary> /// <remarks> /// Using "CommandName" property of cmdSaveEntry to determine this is a new entry of an existing list /// </remarks> /// <history> /// [tamttt] 20/10/2004 Created /// </history> protected void cmdAddEntry_Click(object sender, EventArgs e) { string listName = SelectedKey.Substring(SelectedKey.IndexOf(":") + 1); string parentKey = SelectedKey.Replace(listName, "").TrimEnd(':'); EnableView(false); EnableEdit(false); this.txtParentKey.Text = parentKey; this.txtEntryName.Text = listName; this.txtEntryValue.Text = ""; this.txtEntryText.Text = ""; this.txtEntryName.ReadOnly = true; this.cmdDelete.Visible = false; this.cmdSaveEntry.CommandName = "SaveEntry"; }
private void RenameKey( ) { if (SelectedKey == null) { return; } string newName = SelectedKey.Name; if (InputDialog.ShowDialog("Rename Primary Key", "New Name", ref newName) != DialogResult.OK) { return; } if (SelectedKey.Name.ToLowerInvariant() == newName.ToLowerInvariant()) { return; } try { string hostCols = String.Empty; string refCols = String.Empty; GenerateCols(out hostCols, out refCols); SelectedKey.ColsHost = hostCols; SelectedKey.ColsRef = refCols; SelectedKey.Rename(newName); txtName.Text = newName; ForeignKeyWrapper key = SelectedKey; int index = cmbFk.SelectedIndex; cmbFk.Items.Remove(key); cmbFk.Items.Insert(index, key); cmbFk.SelectedIndex = index; if (_afterKeyRenamed != null) { _afterKeyRenamed(this, SelectedKey); } } catch (Exception ex) { MessageService.ShowError(ex.Message); } }
private void DropKey( ) { if (!MessageService.AskQuestion("Are you sure you want to drop the primary key?")) { return; } if (SelectedKey == null) { return; } int selIndex = -1; selIndex = cmbPk.SelectedIndex; try { SelectedKey.DropWithDepends(); cmbPk.Items.Remove(SelectedKey); if (_mode == TableKeyEditorMode.SingleTable) { CreateNewKey(); } else { ClearKeyPropertyControls(); SetKeyDefinitionControlVisibility(false); if (cmbPk.Items.Count >= selIndex) { cmbPk.SelectedIndex = selIndex; } } } catch (Exception ex) { if (ex.GetType() != typeof(CancelledByUserException)) { Utils.ShowException(ex); } } }
public RfidAccess(byte[] keyA, byte[] keyB, byte[] accessBits, SelectedKey selectedKey) { if (keyA == null || keyA.Length != 6) { throw new ArgumentOutOfRangeException(nameof(keyA)); } if (keyB == null || keyB.Length != 6) { throw new ArgumentOutOfRangeException(nameof(keyB)); } if (accessBits == null || accessBits.Length != 4) { throw new ArgumentOutOfRangeException(nameof(accessBits)); } KeyA = keyA; KeyB = keyB; AccessBits = accessBits; SelectedKey = selectedKey; }
private void LoadedAction() { var preferences = PreferencesService.GetPreferences(); Delimiter.Value = preferences.Delimiter; var count = 1; foreach (var modifierKey in ModifierKey1.Where(x => x != ModifierKeys.None && preferences.ShowHideShortcut.ModifierKeys.HasFlag(x))) { if (count == 1) { var modifierKeyIndex = ModifierKey1.IndexOf(modifierKey); SelectedModifierKey1.Value = modifierKeyIndex < 0 ? ModifierKeys.None : ModifierKey1[modifierKeyIndex]; } if (count == 2) { var modifierKeyIndex = ModifierKey2.IndexOf(modifierKey); SelectedModifierKey2.Value = modifierKeyIndex < 0 ? ModifierKeys.None : ModifierKey2[modifierKeyIndex]; break; } count++; } var keyIndex = Keys.IndexOf(preferences.ShowHideShortcut.Key); SelectedKey.Value = keyIndex < 0 ? Key.None : Keys[keyIndex]; Delimiter.Subscribe(_ => ClearMessage()); SelectedModifierKey1.Subscribe(_ => ClearMessage()); SelectedModifierKey2.Subscribe(_ => ClearMessage()); SelectedKey.Subscribe(_ => ClearMessage()); SelectedTheme.Subscribe(_ => ClearMessage()); AutoLaunch.Subscribe(_ => ClearMessage()); var themeIndex = ThemeNames.IndexOf(preferences.ThemeName); SelectedTheme.Value = themeIndex < 0 ? AppTheme.GenerateDefault().ThemeName : ThemeNames[themeIndex]; AutoLaunch.Value = preferences.AutoLaunch; }
private void DropKey( ) { if (!MessageService.AskQuestion("Are you sure you want to drop the foreign key?")) { return; } if (SelectedKey == null) { return; } int selIndex = -1; selIndex = cmbFk.SelectedIndex; try { SelectedKey.Drop(); if (_afterKeyDropped != null) { _afterKeyDropped(this, SelectedKey); } cmbFk.Items.Remove(SelectedKey); if (cmbFk.Items.Count >= selIndex) { cmbFk.SelectedIndex = selIndex; } else { ClearKeyPropertyControls(); InitializeNewKey(); } } catch (Exception ex) { MessageService.ShowError(ex.Message); } }
private void RenameKey( ) { if (SelectedKey == null) { return; } string newName = SelectedKey.Name; if (InputDialog.ShowDialog("Rename Primary Key", "New Name", ref newName) != DialogResult.OK) { return; } if (SelectedKey.Name.ToLowerInvariant() == newName.ToLowerInvariant()) { return; } try { SelectedKey.Rename(newName); txtName.Text = newName; PrimaryKeyWrapper key = SelectedKey; int index = cmbPk.SelectedIndex; cmbPk.Items.Remove(key); cmbPk.Items.Insert(index, key); cmbPk.SelectedIndex = index; } catch (Exception ex) { if (ex.GetType() != typeof(CancelledByUserException)) { Utils.ShowException(ex); } } }
public IRfidAccess CreateRfidAccess(byte[] keyA, byte[] keyB, byte[] accessBits, SelectedKey selectedKey) { return(new RfidAccess(keyA, keyB, accessBits, selectedKey)); }