Example #1
0
        public static void CopyTuplesDefault(TabGenerator <TKey> tabGenerator, List <ReadableTuple <TKey> > items, BaseDb gdb)
        {
            int max = tabGenerator.MaxElementsToCopyInCustomMethods < 0 ? gdb.AttributeList.Attributes.Count - tabGenerator.StartIndexInCustomMethods : tabGenerator.MaxElementsToCopyInCustomMethods;

            StringBuilder builder  = new StringBuilder();
            List <int>    toRemove =
                (from attribute in gdb.AttributeList.Attributes.OrderByDescending(p => p.Index)
                 where attribute.IsSkippable && !_isAttributeEnabled(attribute, gdb)
                 select attribute.Index).ToList();

            for (int i = 0; i < items.Count; i++)
            {
                ReadableTuple <TKey> item = items[i];

                List <string> objs = item.GetRawElements().Skip(tabGenerator.StartIndexInCustomMethods).Take(max).Select(p => (p ?? "").ToString()).ToList();

                foreach (var index in toRemove)
                {
                    if (index < objs.Count)
                    {
                        objs.RemoveAt(index);
                    }
                }

                builder.AppendLine(string.Join(",", objs.ToArray()));
            }

            Clipboard.SetDataObject(builder.ToString());
        }
Example #2
0
        public DbConstants()
        {
            DbSource      = ServerDbs.Constants;
            AttributeList = ServerConstantsAttributes.AttributeList;
            DbLoader      = DbLoaderMethods.DbTabsLoader;
            DbWriter      = DbWriterMethods.DbConstantsWriter;
            TabGenerator.OnSetCustomCommands = delegate(GDbTabWrapper <string, ReadableTuple <string> > tab, GTabSettings <string, ReadableTuple <string> > settings, BaseDb gdb) {
                settings.AddedCommands.Add(new GItemCommand <string, ReadableTuple <string> > {
                    AllowMultipleSelection = true,
                    DisplayName            = "Copy entries to clipboard",
                    ImagePath          = "export.png",
                    InsertIndex        = 3,
                    Shortcut           = ApplicationShortcut.Copy,
                    AddToCommandsStack = false,
                    GenericCommand     = delegate(List <ReadableTuple <string> > items) {
                        StringBuilder builder = new StringBuilder();

                        for (int i = 0; i < items.Count; i++)
                        {
                            ReadableTuple <string> tuple = items[i];

                            int item2 = tuple.GetValue <int>(2);

                            if (item2 == 0)
                            {
                                builder.AppendLine(string.Join("\t", tuple.GetRawElements().Take(2).Select(p => (p ?? "").ToString()).ToArray()));
                            }
                            else
                            {
                                builder.AppendLine(string.Join("\t", tuple.GetRawElements().Take(3).Select(p => (p ?? "").ToString()).ToArray()));
                            }
                        }

                        Clipboard.SetText(builder.ToString());
                    }
                });
            };
        }
Example #3
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));
        }
Example #4
0
        public static void AdvancedCustomCommands(GDbTabWrapper <int, ReadableTuple <int> > tab, GTabSettings <int, ReadableTuple <int> > settings, BaseDb gdb)
        {
            settings.AddedCommands.Add(new GItemCommand <int, ReadableTuple <int> > {
                AllowMultipleSelection = true,
                DisplayName            = "Copy entries to clipboard",
                ImagePath          = "export.png",
                InsertIndex        = 3,
                AddToCommandsStack = false,
                Shortcut           = ApplicationShortcut.Copy,
                GenericCommand     = delegate(List <ReadableTuple <int> > items) {
                    StringBuilder builder = new StringBuilder();
                    var db = gdb.To <int>();

                    List <DbAttribute> attributesToRemove = new List <DbAttribute>();
                    List <DbAttribute> attributes         = new List <DbAttribute>(gdb.AttributeList.Attributes);
                    attributes.Reverse();

                    foreach (DbAttribute attribute in attributes)
                    {
                        if (db.Attached[attribute.DisplayName] != null)
                        {
                            bool isLoaded = (bool)db.Attached[attribute.DisplayName];

                            if (!isLoaded)
                            {
                                attributesToRemove.Add(attribute);
                            }
                        }
                    }

                    for (int i = 0; i < items.Count; i++)
                    {
                        ReadableTuple <int> item  = items[i];
                        List <object> rawElements = item.GetRawElements().Skip(db.TabGenerator.StartIndexInCustomMethods).Take(db.TabGenerator.MaxElementsToCopyInCustomMethods).ToList();

                        foreach (var attribute in attributesToRemove)
                        {
                            rawElements.RemoveAt(attribute.Index);
                        }

                        builder.AppendLine(string.Join(",", rawElements.Select(p => (p ?? "").ToString()).ToArray()));
                    }

                    Clipboard.SetText(builder.ToString());
                }
            });
        }
Example #5
0
        public static void CopyTuples(List <ReadableTuple <TKey> > items, BaseDb gdb)
        {
            StringBuilder builder  = new StringBuilder();
            List <int>    toRemove =
                (from attribute in gdb.AttributeList.Attributes.OrderByDescending(p => p.Index)
                 where attribute.IsSkippable && !_isAttributeEnabled(attribute, gdb)
                 select attribute.Index).ToList();

            for (int i = 0; i < items.Count; i++)
            {
                ReadableTuple <TKey> item = items[i];

                List <string> objs = item.GetRawElements().Select(p => (p ?? "").ToString()).ToList();

                foreach (var index in toRemove)
                {
                    objs.RemoveAt(index);
                }

                builder.AppendLine(string.Join(",", objs.ToArray()));
            }

            Clipboard.SetDataObject(builder.ToString());
        }
Example #6
0
        private void _onSetCustomCommands(GDbTabWrapper <TKey, ReadableTuple <TKey> > tab, GTabSettings <TKey, ReadableTuple <TKey> > settings, BaseDb gdb)
        {
            int max = MaxElementsToCopyInCustomMethods < 0 ? settings.AttributeList.Attributes.Count - StartIndexInCustomMethods : MaxElementsToCopyInCustomMethods;

            settings.AddedCommands.Add(new GItemCommand <TKey, ReadableTuple <TKey> > {
                AllowMultipleSelection = true,
                DisplayName            = "Copy entries to clipboard",
                ImagePath          = "export.png",
                InsertIndex        = 3,
                AddToCommandsStack = false,
                Shortcut           = ApplicationShortcut.Copy,
                GenericCommand     = delegate(List <ReadableTuple <TKey> > items) {
                    StringBuilder builder = new StringBuilder();
                    List <int> toRemove   =
                        (from attribute in gdb.AttributeList.Attributes.OrderByDescending(p => p.Index)
                         where attribute.IsSkippable && !_isAttributeEnabled(attribute, gdb)
                         select attribute.Index).ToList();

                    for (int i = 0; i < items.Count; i++)
                    {
                        ReadableTuple <TKey> item = items[i];

                        List <string> objs = item.GetRawElements().Skip(StartIndexInCustomMethods).Take(max).Select(p => (p ?? "").ToString()).ToList();

                        foreach (var index in toRemove)
                        {
                            objs.RemoveAt(index);
                        }

                        builder.AppendLine(string.Join(",", objs.ToArray()));
                    }

                    Clipboard.SetDataObject(builder.ToString());
                }
            });
        }
Example #7
0
        private void _onSetCustomCommands(GDbTabWrapper <TKey, ReadableTuple <TKey> > tab, GTabSettings <TKey, ReadableTuple <TKey> > settings, BaseDb gdb)
        {
            int max = MaxElementsToCopyInCustomMethods < 0 ? settings.AttributeList.Attributes.Count - StartIndexInCustomMethods : MaxElementsToCopyInCustomMethods;

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

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

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