Exemple #1
0
 private void txtFind_KeyPressEvent(object o, KeyPressEventArgs args)
 {
     if (KeyShortcuts.Equal(args.Event, KeyShortcuts.ChooseKey))
     {
         ChooseDataFieldValue(args);
     }
 }
 private void txtLocation_KeyPressEvent(object o, KeyPressEventArgs args)
 {
     if (KeyShortcuts.Equal(args.Event, KeyShortcuts.ChooseKey))
     {
         ChangeLocation();
     }
 }
 private void txtDefaultPartner_KeyPressEvent(object o, KeyPressEventArgs args)
 {
     if (KeyShortcuts.Equal(args.Event, KeyShortcuts.ChooseKey))
     {
         ChangeDefaultPartner();
     }
 }
Exemple #4
0
        private void ItemColumn_KeyPress(object sender, CellKeyPressEventArgs args)
        {
            if (gridNavigator.ColumnKeyPress(args, colItem.Index, ItemColumnChoose,
                                             ItemColumnEvaluate, ItemColumnEditPrev, ItemColumnEditNext))
            {
                return;
            }

            string gdkKey = KeyShortcuts.KeyToString(args.EventKey);
            string quickGoods;

            if (!BusinessDomain.QuickItems.TryGetValue(gdkKey, out quickGoods))
            {
                return;
            }

            ItemColumnEvaluate(grid.EditedCell.Row, quickGoods);

            QtyColumnEvaluate(grid.EditedCell.Row, 1);

            if (selectedDetails.Count <= grid.EditedCell.Row + 1)
            {
                selectedDetails.Add(new SaleDetail());
            }

            EditGridCell(grid.EditedCell.Row + 1, colItem.Index);

            args.MarkAsHandled();
        }
 /// <inheritdoc/>
 public override int GetHashCode()
 => Role.GetHashCode() ^
 Name.GetHashCode() ^
 Value.GetHashCode() ^
 Description.GetHashCode() ^
 KeyShortcuts.GetHashCode() ^
 RoleDescription.GetHashCode() ^
 ValueText.GetHashCode() ^
 AutoComplete.GetHashCode() ^
 HasPopup.GetHashCode() ^
 Orientation.GetHashCode() ^
 Disabled.GetHashCode() ^
 Expanded.GetHashCode() ^
 Focused.GetHashCode() ^
 Modal.GetHashCode() ^
 Multiline.GetHashCode() ^
 Multiselectable.GetHashCode() ^
 Readonly.GetHashCode() ^
 Required.GetHashCode() ^
 Selected.GetHashCode() ^
 Pressed.GetHashCode() ^
 Checked.GetHashCode() ^
 Level.GetHashCode() ^
 ValueMin.GetHashCode() ^
 ValueMax.GetHashCode() ^
 Children.GetHashCode();
        private void MatItem_KeyPress(object sender, CellKeyPressEventArgs args)
        {
            if (GridNavigator.ColumnKeyPress(args, colItem.Index, MatItemChoose,
                                             MatItemEvaluate, MatItemEditPrev, MatItemEditNext))
            {
                return;
            }

            string gdkKey = KeyShortcuts.KeyToString(args.EventKey);
            string quickGoods;

            if (!BusinessDomain.QuickItems.TryGetValue(gdkKey, out quickGoods))
            {
                return;
            }

            if (!MatItemEvaluate(grdMaterials.EditedCell.Row, quickGoods))
            {
                return;
            }

            MatQtyEvaluate(grdMaterials.EditedCell.Row, 1);

            if (recipe.DetailsMat.Count <= grdMaterials.EditedCell.Row + 1)
            {
                recipe.AddNewDetail();
            }

            MatEditGridField(grdMaterials.EditedCell.Row + 1, colItem.Index);

            args.MarkAsHandled();
        }
 private void txtCompany_KeyPressEvent(object o, KeyPressEventArgs args)
 {
     if (KeyShortcuts.Equal(args.Event, KeyShortcuts.ChooseKey))
     {
         ChangeCompany();
     }
 }
 private void txtCompareTo_KeyPressEvent(object o, KeyPressEventArgs args)
 {
     if (KeyShortcuts.Equal(args.Event, KeyShortcuts.ChooseKey))
     {
         txtCompareTo.Text = ChooseDataFieldValue(args, txtCompareTo.Text);
     }
 }
Exemple #9
0
 protected void OnDueDateKeyPressEvent(object o, KeyPressEventArgs args)
 {
     if (KeyShortcuts.Equal(args.Event, KeyShortcuts.ChooseKey))
     {
         ChooseDate();
     }
 }
        private void ProdItem_KeyPress(object sender, CellKeyPressEventArgs args)
        {
            if (SecondGridNavigator.ColumnKeyPress(args, colSecondItem.Index, ProdItemChoose,
                                                   ProdItemEvaluate, ProdItemEditPrev, ProdItemEditNext))
            {
                return;
            }

            string gdkKey = KeyShortcuts.KeyToString(args.EventKey);
            string quickGoods;

            if (!BusinessDomain.QuickItems.TryGetValue(gdkKey, out quickGoods))
            {
                return;
            }

            ProdItemEvaluate(grdProducts.EditedCell.Row, quickGoods);

            ProdQtyEvaluate(grdProducts.EditedCell.Row, 1);

            if (recipe.DetailsProd.Count <= grdProducts.EditedCell.Row + 1)
            {
                recipe.AddNewAdditionalDetail();
            }

            ProdEditGridField(grdProducts.EditedCell.Row + 1, colSecondItem.Index);

            args.MarkAsHandled();
        }
Exemple #11
0
        protected void btnOK_Clicked(object o, EventArgs args)
        {
            if (grid.EditedCell.IsValid && grid.EditedCell.Row < itemShortcuts.Count &&
                !ShortcutColumnEvaluate(grid.EditedCell.Row, string.Empty))
            {
                return;
            }

            BusinessDomain.QuickItems.Clear();
            List <KeyValuePair <string, AccelKey> > changedShortcuts = new List <KeyValuePair <string, AccelKey> > ();

            foreach (ItemShortcut itemShortcut in itemShortcuts)
            {
                if (itemShortcut.ItemId < 0)
                {
                    continue;
                }
                string accelPath = KeyShortcuts.GetAccelPath(itemShortcut.ItemId.ToString());
                AccelMap.ChangeEntry(accelPath, (uint)itemShortcut.Shortcut.Key,
                                     KeyShortcuts.GetAllowedModifier(itemShortcut.Shortcut.AccelMods), true);
                if (itemShortcut.Shortcut.Key > 0)
                {
                    string key = KeyShortcuts.KeyToString(itemShortcut.Shortcut.Key, itemShortcut.Shortcut.AccelMods);
                    BusinessDomain.QuickItems.Add(key, itemShortcut.ItemName);
                }
                changedShortcuts.Add(new KeyValuePair <string, AccelKey> (accelPath, itemShortcut.Shortcut));
            }
            KeyShortcuts.Save(changedShortcuts);
            dlgEditQuickItems.Respond(ResponseType.Ok);
        }
Exemple #12
0
 private void Grid_CellKeyPressEvent(object sender, CellKeyPressEventArgs args)
 {
     if (KeyShortcuts.IsScreenModifierControl(args.EventKey.State) &&
         args.EventKey.Key == KeyShortcuts.DeleteKey.Key)
     {
         DeleteGridRow(true);
     }
 }
 private void grdProducts_CellKeyPressEvent(object sender, CellKeyPressEventArgs args)
 {
     if (KeyShortcuts.IsScreenModifierControl(args.EventKey.State) &&
         args.EventKey.Key == KeyShortcuts.DeleteKey.Key &&
         !editMode)
     {
         ProdDeleteRow(true);
     }
 }
        private void txtTo_KeyPressEvent(object o, KeyPressEventArgs args)
        {
            if (!KeyShortcuts.Equal(args.Event, KeyShortcuts.ChooseKey))
            {
                return;
            }

            ChooseDataFieldTo(args);
        }
Exemple #15
0
        private void txtTaxDate_KeyPressEvent(object o, KeyPressEventArgs args)
        {
            if (!KeyShortcuts.Equal(args.Event, KeyShortcuts.ChooseKey))
            {
                return;
            }

            ChooseTaxDate();
            args.RetVal = true;
        }
        private void txtExchangeLocation_KeyPress(object o, KeyPressEventArgs args)
        {
            if (!KeyShortcuts.Equal(args.Event, KeyShortcuts.ChooseKey))
            {
                return;
            }

            LocationChoose();
            args.RetVal = true;
        }
        private static void RemoveQuickItem(string key)
        {
            string quickItem = BusinessDomain.QuickItems [key];

            BusinessDomain.QuickItems.Remove(key);
            Item item = Item.GetByAny(quickItem);

            if (item != null)
            {
                AccelMap.ChangeEntry(KeyShortcuts.GetAccelPath(item.Id.ToString(CultureInfo.InvariantCulture)), (uint)Key.VoidSymbol, 0, true);
            }
        }
        private static void RemoveQuickItem(string key, Dictionary <string, AccelKey> shortcuts)
        {
            string quickItem = BusinessDomain.QuickItems [key];

            BusinessDomain.QuickItems.Remove(key);
            Item item = Item.GetByAny(quickItem);

            if (item != null)
            {
                shortcuts.Add(KeyShortcuts.GetAccelPath(item.Id.ToString(CultureInfo.InvariantCulture)), AccelKey.Zero);
            }
        }
        private void TryApplyShortcut()
        {
            TreeIter selectedRow  = GetSelectedRow();
            string   menuItemName = (string)treeViewMenu.Model.GetValue(selectedRow, 2);

            if (!IsFreeToUse(enteredAccelKey))
            {
                treeViewMenu.GrabFocus();
                return;
            }
            ApplyShortcut(menuItemName, enteredAccelKey);
            treeViewMenu.Model.SetValue(selectedRow, 1, KeyShortcuts.KeyToString(enteredAccelKey));
        }
        private void Selection_Changed(object sender, EventArgs e)
        {
            TreeIter selectedRow = GetSelectedRow();

            if (!IsSelectionValid(selectedRow))
            {
                return;
            }

            string selectedName = (string)treeViewMenu.Model.GetValue(selectedRow, 2);

            enteredAccelKey = KeyShortcuts.LookupEntry(selectedName);
        }
        private void DialogControl_KeyPressEvent(object o, KeyPressEventArgs args)
        {
            if (!KeyShortcuts.Equal(args.Event, KeyShortcuts.HelpKey))
            {
                return;
            }

            if (string.IsNullOrEmpty(HelpFile))
            {
                return;
            }

            FormHelper.ShowWindowHelp(HelpFile);
        }
Exemple #22
0
        private void AddItemShortcut(IntPtr data, string accelPath, uint accelKey, ModifierType accelMods, bool changed)
        {
            long itemId;

            if (IsKeyForItem(accelPath, out itemId) && accelKey != 0 && accelKey != (uint)Key.VoidSymbol)
            {
                ItemShortcut itemShortcut = new ItemShortcut();
                if (!itemShortcut.ItemEvaluate(Item.GetById(itemId), PriceGroup.RegularPrice))
                {
                    return;
                }

                itemShortcut.Shortcut = new AccelKey((Key)accelKey, KeyShortcuts.GetAllowedModifier(accelMods), AccelFlags.Visible);
                itemShortcuts.Add(itemShortcut);
            }
        }
Exemple #23
0
        private void txtDateTo_KeyPressEvent(object o, KeyPressEventArgs args)
        {
            if (!KeyShortcuts.Equal(args.Event, KeyShortcuts.ChooseKey))
            {
                return;
            }

            object ret = txtDateTo.Text;

            if (FormHelper.ChooseDataFieldValue(DataField.OperationDate, ref ret) != ResponseType.Ok)
            {
                return;
            }

            txtDateTo.Text = (string)ret;
            args.RetVal    = true;
        }
        private static void AddCustomShortcut(TreeIter parent, TreeStore treeStore, string path, string name, string type)
        {
            // only menu shortcuts supported on the mac because of the GTK "cmd is alt" bug
            if (PlatformHelper.Platform == PlatformTypes.MacOSX &&
                (path.Contains("btn") || path == KeyShortcuts.CHOOSE_KEY || path == KeyShortcuts.HELP_KEY))
            {
                return;
            }

            string   parentPath       = (string)treeStore.GetValue(parent, 2);
            int      indexOfSeparator = path.LastIndexOf('/');
            TreeIter finalParent      = parent;

            if (indexOfSeparator >= 0)
            {
                string parentNode = path.Substring(0, indexOfSeparator);
                if (parentNode != parentPath)
                {
                    for (int i = 0; i < treeStore.IterNChildren(parent); i++)
                    {
                        TreeIter row;
                        treeStore.IterNthChild(out row, parent, i);
                        string child = (string)treeStore.GetValue(row, 2);
                        if (child.Substring(child.LastIndexOf('/') + 1) != parentNode)
                        {
                            continue;
                        }

                        finalParent = row;
                        break;
                    }
                    name = name.Substring(name.LastIndexOf('/') + 1);
                }
            }
            AccelKey key = KeyShortcuts.LookupEntry(path);

            // set "menu" as the type because these custom bindings cannot be the same as some real menu bindings
            if (finalParent.Equals(TreeIter.Zero))
            {
                treeStore.AppendValues(name, KeyShortcuts.KeyToString(key), path, type);
            }
            else
            {
                treeStore.AppendValues(finalParent, name, KeyShortcuts.KeyToString(key), path, type);
            }
        }
        private bool UsedInMenuOrSameScreen(AccelKey newKey)
        {
            TreeIter selectedRow  = GetSelectedRow();
            string   selectedName = (string)treeViewMenu.Model.GetValue(selectedRow, 2);
            string   selectedType = (string)treeViewMenu.Model.GetValue(selectedRow, 3);
            TreeIter ownerRow     = TreeIter.Zero;

            treeViewMenu.Model.Foreach((model, path, row) =>
            {
                string name = (string)model.GetValue(row, 2);
                if (selectedName == name)
                {
                    return(false);
                }

                string type  = (string)model.GetValue(row, 3);
                AccelKey key = KeyShortcuts.LookupEntry(name);
                // when comparing with menus, ignore paths containing a '/' because menus do not have such (in incomplete paths)
                if (selectedType == type && (selectedType != KeyShortcuts.MENU_NEIGHBOURING_SHORTCUT || !name.Contains("/")) &&
                    KeyShortcuts.KeyEqual((uint)newKey.Key, (uint)key.Key) && newKey.AccelMods == key.AccelMods)
                {
                    ownerRow = row;
                    return(true);
                }
                return(false);
            });

            if (!ownerRow.Equals(TreeIter.Zero))
            {
                string translation = Translator.GetString("The selected shortcut is already used for the \"{0}\" menu item. " +
                                                          "Do you want to remove the shortcut for \"{0}\" to reassign it?");
                string message = string.Format(translation, treeViewMenu.Model.GetValue(ownerRow, 0));
                if (Message.ShowDialog(Translator.GetString("Warning!"), string.Empty,
                                       message, "Icons.Question32.png",
                                       MessageButtons.YesNo) == ResponseType.Yes)
                {
                    string ownerItem = (string)treeViewMenu.Model.GetValue(ownerRow, 2);
                    ApplyShortcut(ownerItem, new AccelKey(Key.VoidSymbol, ModifierType.None, AccelFlags.Visible));
                    treeViewMenu.Model.SetValue(ownerRow, 1, KeyShortcuts.KeyToString(AccelKey.Zero));
                    return(false);
                }
                return(true);
            }
            return(false);
        }
Exemple #26
0
 private void ColumnShortcut_KeyPressEvent(object sender, CellKeyPressEventArgs args)
 {
     if (args.Editing && KeyShortcuts.CombinationValidForItem(args.EventKey))
     {
         currentKey      = new AccelKey(args.EventKey.Key, args.EventKey.State, AccelFlags.Visible);
         args.Entry.Text = KeyShortcuts.KeyToString(currentKey);
         args.MarkAsHandled();
     }
     switch (args.EventKey.Key)
     {
     case Key.BackSpace:
     case Key.Delete:
         currentKey      = AccelKey.Zero;
         args.Entry.Text = string.Empty;
         break;
     }
     gridNavigator.ColumnKeyPress(args, args.Cell.Column, ShortcutColumnEvaluate, ShortcutColumnEditPrev, ShortcutColumnEditNext);
 }
        private void WbpPrintPreview_KeyPressEvent(object o, KeyPressEventArgs args)
        {
            if (KeyShortcuts.Equal(args.Event, KeyShortcuts.HelpKey) && !string.IsNullOrEmpty(HelpFile))
            {
                FormHelper.ShowWindowHelp(HelpFile);
                return;
            }

            switch (args.Event.Key)
            {
            case Key.Escape:
                RequestClose();
                return;

            case Key.F9:
                btnPrint_Clicked(null, EventArgs.Empty);
                return;

            case Key.Left:
                currentPreview.StartPage--;
                return;

            case Key.Right:
                currentPreview.StartPage++;
                return;

            case Key.End:
                if (KeyShortcuts.GetAllowedModifier(args.Event.State) == KeyShortcuts.ControlModifier)
                {
                    currentPreview.StartPage = currentPreview.TotalPages - 1;
                }

                return;

            case Key.Home:
                if (KeyShortcuts.GetAllowedModifier(args.Event.State) == KeyShortcuts.ControlModifier)
                {
                    currentPreview.StartPage = 0;
                }

                return;
            }
        }
        private static bool IsUsedInQuickItems(AccelKey newKey)
        {
            string key = KeyShortcuts.KeyToString(newKey);

            if (!BusinessDomain.QuickItems.ContainsKey(key))
            {
                return(false);
            }

            using (Message dialog = GetInUseQuickItemMessage(key)) {
                dialog.Buttons = MessageButtons.YesNo;
                if (dialog.Run() != ResponseType.Yes)
                {
                    return(true);
                }

                RemoveQuickItem(key);
                return(false);
            }
        }
        private void ApplyShortcut(string menuItemName, AccelKey accelKey)
        {
            string accelPath = KeyShortcuts.GetAccelPath(menuItemName);

            changedShortcuts.Add(new KeyValuePair <string, AccelKey> (accelPath,
                                                                      new AccelKey(accelKey.Key, KeyShortcuts.GetAllowedModifier(accelKey.AccelMods), AccelFlags.Visible)));
            MenuItemWrapper menuItemWrapper = menu.FindMenuItem(menuItemName);

            if (menuItemWrapper == null)
            {
                return;
            }
            if (accelKey.Key != Key.VoidSymbol)
            {
                return;
            }

            AccelKey key = KeyShortcuts.LookupEntry(menuItemName);

            menuItemWrapper.Item.RemoveAccelerator(accelGroup, (uint)key.Key, key.AccelMods);
        }
Exemple #30
0
        private void GridBarcodes_CellKeyPressEvent(object sender, CellKeyPressEventArgs args)
        {
            if (KeyShortcuts.IsScreenModifierControl(args.EventKey.State) &&
                args.EventKey.Key == KeyShortcuts.DeleteKey.Key)
            {
                DeleteGridRow();
                // prevent the "Delete" key from acting upon the content of
                // the newly edited cell (i.e. from deleting the content)
                args.MarkAsHandled();
                return;
            }

            switch (args.EventKey.Key)
            {
            case Key.ISO_Left_Tab:
                if (args.Cell.Row == 0 && args.Cell.Column == 0)
                {
                    alignmentFocusStopper.GrabFocus();
                }
                break;
            }
        }