Exemple #1
0
        private void _initMenus()
        {
            foreach (GItemCommand <TKey, TValue> commandCopy in Settings.AddedCommands)
            {
                GItemCommand <TKey, TValue> command = commandCopy;
                MenuItem item = new MenuItem();
                item.Header = command.DisplayName;
                item.Click += (e, a) => _menuItem_Click(command);

                Image image = new Image();
                image.Source = (BitmapSource)ApplicationManager.PreloadResourceImage(command.ImagePath);
                item.Icon    = image;

                if (command.Shortcut != null)
                {
                    ApplicationShortcut.Link(command.Shortcut, () => _menuItem_Click(command), List);
                    item.InputGestureText = command.Shortcut.DisplayString;
                }

                _listView.ContextMenu.Items.Insert(command.InsertIndex, item);
            }

            _miDelete.Click          += _menuItemDeleteItem_Click;
            _miCopyTo.Click          += _menuItemCopyItemTo_Click;
            _miShowSelected.Click    += _menuItemKeepSelectedItemsOnly_Click;
            _buttonOpenSubMenu.Click += _buttonOpenSubMenu_Click;
            _miChangeId.Click        += _miChangeId_Click;
            _miSelectInNotepad.Click += _miSelectInNotepad_Click;
            _miCut.Click             += _miCut_Click;

            if (!Settings.CanChangeId)
            {
                _miChangeId.Visibility = Visibility.Collapsed;
            }
        }
Exemple #2
0
        static GTabsMaker()
        {
            CopyEntriesToClipboardFunctionInt = new GItemCommand <int, ReadableTuple <int> > {
                AllowMultipleSelection = true,
                DisplayName            = "Copy entries to clipboard",
                ImagePath          = "export.png",
                InsertIndex        = 3,
                Shortcut           = ApplicationShortcut.Copy,
                AddToCommandsStack = false,
                GenericCommand     = delegate(List <ReadableTuple <int> > items) {
                    StringBuilder builder = new StringBuilder();

                    for (int i = 0; i < items.Count; i++)
                    {
                        ReadableTuple <int> item = items[i];
                        builder.AppendLine(string.Join(",", item.GetRawElements().Select(p => (p ?? "").ToString()).ToArray()));
                    }

                    Clipboard.SetText(builder.ToString());
                }
            };

            CopyEntriesToClipboardFunctionString = new GItemCommand <string, ReadableTuple <string> > {
                AllowMultipleSelection = true,
                DisplayName            = "Copy entries to clipboard",
                ImagePath          = "export.png",
                Shortcut           = ApplicationShortcut.Copy,
                InsertIndex        = 3,
                AddToCommandsStack = false,
                GenericCommand     = delegate(List <ReadableTuple <string> > items) {
                    StringBuilder builder = new StringBuilder();

                    for (int i = 0; i < items.Count; i++)
                    {
                        ReadableTuple <string> item = items[i];
                        builder.AppendLine(string.Join(",", item.GetRawElements().Select(p => (p ?? "").ToString()).ToArray()));
                    }

                    Clipboard.SetText(builder.ToString());
                }
            };

            SelectFromMobDb               = (tab, settings, gdb) => settings.AddedCommands.Add(GenerateSelectFrom(ServerDbs.Mobs, tab));
            SelectFromItemDb              = (tab, settings, gdb) => settings.AddedCommands.Add(GenerateSelectFrom(ServerDbs.Items, tab));
            SelectFromSkillDb             = (tab, settings, gdb) => settings.AddedCommands.Add(GenerateSelectFrom(ServerDbs.Skills, tab));
            SelectFromMobDbString         = (tab, settings, gdb) => settings.AddedCommands.Add(GenerateSelectFrom(ServerDbs.Mobs, tab, ServerMobSkillAttributes.MobId));
            SelectFromSkillDbString       = (tab, settings, gdb) => settings.AddedCommands.Add(GenerateSelectFrom(ServerDbs.Skills, tab, ServerMobSkillAttributes.SkillId));
            SelectFromSkillRequirementsDb = (tab, settings, gdb) => settings.AddedCommands.Add(GenerateSelectFrom(ServerDbs.SkillsRequirement, tab));
        }
Exemple #3
0
        private void _menuItem_Click(GItemCommand <TKey, TValue> command)
        {
            if (command.AddToCommandsStack)
            {
                if (command.AllowMultipleSelection)
                {
                    List <ITableCommand <TKey, TValue> > commands = new List <ITableCommand <TKey, TValue> >();
                    SearchEngine.Collection.Disable();

                    for (int index = 0; index < _listView.SelectedItems.Count; index++)
                    {
                        TValue rItem = (TValue)_listView.SelectedItems[index];
                        commands.Add(command.Command(rItem));
                    }

                    Table.Commands.StoreAndExecute(new GroupCommand <TKey, TValue>(commands));
                    SearchEngine.Collection.UpdateAndEnable();
                }
                else
                {
                    try {
                        if (_listView.SelectedItem != null)
                        {
                            TValue rItem = (TValue)_listView.SelectedItem;
                            Table.Commands.StoreAndExecute(command.Command(rItem));
                        }
                    }
                    catch (Exception err) {
                        ErrorHandler.HandleException(err);
                    }
                }
            }
            else
            {
                if (command.GenericCommand == null)
                {
                    ErrorHandler.HandleException("The added command in the generic database tab hasn't been compiled properly.");
                    return;
                }

                command.GenericCommand(_listView.SelectedItems.OfType <TValue>().ToList());
            }
        }