public void FillData()
        {
            SQLiteTableReader reader = new SQLiteTableReader(null, Program.DbPath);

            reader.Connect();
            DataTable shopItemTable = reader.ExecuteQuery("SELECT tm.item_id, tm.coin_num, tm.motion_id, t0.text as ItemName, t1.text as ItemDesc FROM (SELECT item_id, coin_num, motion_id FROM single_mode_free_shop_item) as tm, (SELECT \"index\", text FROM text_data WHERE category=225) as t0, (SELECT \"index\", text FROM text_data WHERE category=238) as t1 WHERE tm.item_id = t0.\"index\" AND tm.item_id = t1.\"index\"");

            reader.Disconnect();
            for (int i = 0; i < shopItemTable.Rows.Count; i++)
            {
                FreeShopItemData data = new FreeShopItemData();
                data.ItemId    = (long)shopItemTable.Rows[i]["item_id"];
                data.ItemPrice = (long)shopItemTable.Rows[i]["coin_num"];
                data.SetItemName(((string)shopItemTable.Rows[i]["ItemName"]).Replace("\\n", ""));
                data.ItemDesc = ((string)shopItemTable.Rows[i]["ItemDesc"]).Replace("\\n", "");
                if (!FreeShopDataList.Exists(a => a.ItemName.Equals(data.ItemName)))
                {
                    string transName = Program.TransDict.GetTranslation(transDict, data.ItemName);
                    if (string.IsNullOrEmpty(transName))
                    {
                        transName = string.Empty;
                    }
                    data.ItemNameTrans = transName;
                    string transDesc = Program.TransDict.GetTranslation(transDict, data.ItemDesc);
                    if (string.IsNullOrEmpty(transDesc))
                    {
                        transDesc = string.Empty;
                    }
                    data.ItemDescTrans = transDesc;
                    FreeShopDataList.Add(data);
                }
            }
        }
        public void FillData()
        {
            SQLiteTableReader reader = new SQLiteTableReader(null, Program.DbPath);

            reader.Connect();
            DataTable missionTable = reader.ExecuteQuery("SELECT tm.id as id, tm.item_id as item_id, tm.item_num as item_num, t0.text as MissionText FROM (SELECT id, item_id, item_num FROM mission_data) as tm, (SELECT \"index\", text FROM text_data WHERE category=67) as t0 WHERE tm.id = t0.\"index\"");

            reader.Disconnect();
            for (int i = 0; i < missionTable.Rows.Count; i++)
            {
                MissionData data = new MissionData();
                data.Id        = (long)missionTable.Rows[i]["id"];
                data.ItemId    = (long)missionTable.Rows[i]["item_id"];
                data.ItemCount = (long)missionTable.Rows[i]["item_num"];
                data.SetMissionText(((string)missionTable.Rows[i]["MissionText"]).Replace("\\n", ""));
                if (!MissionDataList.Exists(a => a.MissionText.Equals(data.MissionText)))
                {
                    string transText = Program.TransDict.GetTranslation(transDict, data.MissionText);
                    if (string.IsNullOrEmpty(transText))
                    {
                        transText = string.Empty;
                    }
                    data.TransMissionText = transText;
                    MissionDataList.Add(data);
                }
            }
        }
        public void FillData()
        {
            SQLiteTableReader reader = new SQLiteTableReader(null, Program.DbPath);

            reader.Connect();
            DataTable factorTable = reader.ExecuteQuery("SELECT tm.factor_id as id, tm.factor_type, t0.text as FactorName, t1.text as FactorDesc FROM (SELECT factor_id, factor_type FROM succession_factor) as tm, (SELECT \"index\", text FROM text_data WHERE category=147) as t0, (SELECT \"index\", text FROM text_data WHERE category=172) as t1 WHERE tm.factor_id = t0.\"index\" AND tm.factor_id = t1.\"index\"");

            reader.Disconnect();
            for (int i = 0; i < factorTable.Rows.Count; i++)
            {
                FactorData data = new FactorData();
                data.Id         = (long)factorTable.Rows[i]["id"];
                data.FactorType = (FactorType)factorTable.Rows[i]["factor_type"];
                data.Desc       = (string)factorTable.Rows[i]["FactorDesc"];
                data.Desc       = data.Desc.Replace("\\n", "");
                data.SetName((string)factorTable.Rows[i]["FactorName"]);
                if (!FactorDataList.Exists(a => a.Name.Equals(data.Name)))
                {
                    string transName = Program.TransDict.GetTranslation(transDict, data.Name);
                    if (string.IsNullOrEmpty(transName))
                    {
                        transName = string.Empty;
                    }
                    data.NameTrans = transName;
                    string transDesc = Program.TransDict.GetTranslation(transDict, data.Desc);
                    if (string.IsNullOrEmpty(transDesc))
                    {
                        transDesc = string.Empty;
                    }
                    data.DescTrans = transDesc;
                    FactorDataList.Add(data);
                }
            }

            for (int i = 0; i < FactorDataList.Count; i++)
            {
                KeyValuePair <int, StringData> data = new KeyValuePair <int, StringData>(i, new StringData(FactorDataList[i].NameToCheck));
                int key = FactorDataList[i].NameToCheck.Length;
                if (factorListByName.ContainsKey(key))
                {
                    factorListByName[key].Add(data);
                }
                else
                {
                    factorListByName.Add(key, new List <KeyValuePair <int, StringData> >()
                    {
                        data
                    });
                }
            }
        }
        public void FillData()
        {
            SQLiteTableReader reader = new SQLiteTableReader(null, Program.DbPath);

            reader.Connect();
            DataTable skillTable = reader.ExecuteQuery("SELECT tm.id, tm.icon_id,tm.rarity, t0.text as SkillName, t1.text as SkillDesc FROM (SELECT id, rarity, icon_id FROM skill_data) as tm, (SELECT \"index\", text FROM text_data WHERE category=47) as t0, (SELECT \"index\", text FROM text_data WHERE category=48) as t1 WHERE tm.id = t0.\"index\" AND tm.id = t1.\"index\"");

            reader.Disconnect();
            for (int i = 0; i < skillTable.Rows.Count; i++)
            {
                SkillData data = new SkillData();
                data.Id     = (long)skillTable.Rows[i]["id"];
                data.IconId = (long)skillTable.Rows[i]["icon_id"];
                data.Rarity = (long)skillTable.Rows[i]["rarity"];
                data.Desc   = (string)skillTable.Rows[i]["SkillDesc"];
                data.Desc   = data.Desc.Replace("\\n", "");
                data.SetName((string)skillTable.Rows[i]["SkillName"]);
                SkillDataList.Add(data);
            }

            for (int i = 0; i < SkillDataList.Count; i++)
            {
                if (SkillDataList[i].Rarity > 2)
                {
                    continue;
                }
                KeyValuePair <int, StringData> data = new KeyValuePair <int, StringData>(i, new StringData(SkillDataList[i].NameToCheck));
                int key = SkillDataList[i].NameToCheck.Length;
                if (skillListByName.ContainsKey(key))
                {
                    skillListByName[key].Add(data);
                }
                else
                {
                    skillListByName.Add(key, new List <KeyValuePair <int, StringData> >()
                    {
                        data
                    });
                }
            }
        }
Esempio n. 5
0
        public void LoadTableByText(string text)
        {
            SQLiteTableReader reader = new SQLiteTableReader(Application.StartupPath, Program.DbPath);

            reader.Connect();
            var data = reader.GetDataTableByText(text, Program.TableDisplaySettings);

            reader.Disconnect();
            listBox1.ClearSelected();
            if (data.table == null)
            {
                dataGridView1.DataSource = null;
                currentTableSettings     = null;
                currentTable             = null;
            }
            else
            {
                CheckBeforeReload();
                SetDataTable(data.settings, data.table);
            }
        }
Esempio n. 6
0
        public void LoadTableByIds(string tableName, List <Int64> ids)
        {
            var tableSetting = Program.TableDisplaySettings.Find(a => a.TableName.Equals(tableName));

            SQLiteTableReader reader = new SQLiteTableReader(Application.StartupPath, Program.DbPath);

            reader.Connect();
            var table = reader.GetDataTable(tableSetting, ids);

            reader.Disconnect();
            listBox1.ClearSelected();
            if (table == null)
            {
                dataGridView1.DataSource = null;
                currentTableSettings     = null;
                currentTable             = null;
            }
            else
            {
                CheckBeforeReload();
                SetDataTable(tableSetting, table);
            }
        }
Esempio n. 7
0
        private void SetDataTable(TableSettings settings, DataTable preloadedTable = null)
        {
            DataTable table = null;

            if (preloadedTable == null)
            {
                SQLiteTableReader reader = new SQLiteTableReader(Application.StartupPath, Program.DbPath);
                reader.Connect();
                table = reader.GetDataTable(settings);
                reader.Disconnect();
            }
            else
            {
                table = preloadedTable;
            }

            currentDictonary = Program.TransDict.LoadDictonary(Path.Combine(Program.DictonariesDir, settings.TableName + "_" + toolStripComboBox1.SelectedItem + ".txt"));
            if (currentDictonary.Count > 0)
            {
                foreach (var item in settings.TextTypeAndName)
                {
                    for (int i = 0; i < table.Rows.Count; i++)
                    {
                        string original = (string)table.Rows[i][item.Value];
                        if (!string.IsNullOrWhiteSpace(original))
                        {
                            string trans = Program.TransDict.GetTranslation(currentDictonary, original);
                            if (!string.IsNullOrWhiteSpace(trans))
                            {
                                table.Rows[i][item.Value + "_trans"] = trans;
                            }
                        }
                    }
                }
            }
            table.AcceptChanges();
            dataGridView1.RowTemplate.Height = settings.RowHeight;
            dataGridView1.DataSource         = table;
            //dataGridView1.RowTemplate.Height = 50;
            for (int i = 0; i < dataGridView1.ColumnCount; i++)
            {
                if (dataGridView1.Columns[i].ValueType == typeof(Image))
                {
                    ((DataGridViewImageColumn)dataGridView1.Columns[i]).ImageLayout = DataGridViewImageCellLayout.Zoom;
                    dataGridView1.Columns[i].AutoSizeMode = DataGridViewAutoSizeColumnMode.AllCells;
                }
                else if (dataGridView1.Columns[i].Name.EndsWith("_imagePath"))
                {
                    dataGridView1.Columns[i].Visible = false;
                }
                else
                {
                    dataGridView1.Columns[i].AutoSizeMode = DataGridViewAutoSizeColumnMode.AllCells;
                    dataGridView1.Columns[i].ReadOnly     = true;
                }
            }
            foreach (var item in settings.TextTypeAndName)
            {
                dataGridView1.Columns[item.Value].AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill;
                dataGridView1.Columns[item.Value].DefaultCellStyle.WrapMode = DataGridViewTriState.True;
                dataGridView1.Columns[item.Value].ReadOnly = false;

                dataGridView1.Columns[item.Value + "_trans"].AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill;
                dataGridView1.Columns[item.Value + "_trans"].DefaultCellStyle.WrapMode = DataGridViewTriState.True;
                dataGridView1.Columns[item.Value + "_trans"].ReadOnly = false;
            }
            foreach (var item in settings.ColumnWidth)
            {
                dataGridView1.Columns[item.Key].AutoSizeMode = DataGridViewAutoSizeColumnMode.None;
                dataGridView1.Columns[item.Key].Width        = item.Value;
                dataGridView1.Columns[item.Key].DefaultCellStyle.WrapMode = DataGridViewTriState.True;
            }

            currentTableSettings = settings;
            currentTable         = table;
            if (filter != null)
            {
                filter.Close();
                filter = null;
            }

            // var test = table.DefaultView.RowFilter = "LEN(SkillName)=5";
        }