コード例 #1
0
 private void btnOpen_Click(object sender, EventArgs e)
 {
     try
     {
         MobInfo        = new ShnFile(txtMobInfo.Text);
         ItemInfoServer = new ShnFile(txtItemInfoServer.Text);
         ItemDropGroup  = new ShineFile(txtDropGroup.Text);
         ItemDropTable  = new ShineFile(txtDropTable.Text);
     }
     catch (Exception ex)
     {
         MessageBox.Show(ex.Message, "Failed to open file");
     }
 }
コード例 #2
0
        public async void LoadFiles(frmOpenFile dlg)
        {
            Mobs   = new BindingList <Mob>();
            Groups = new BindingList <ItemGroup>();
            Items  = new BindingList <string>();

            ItemInfoServer = dlg.ItemInfoServer;
            MobInfo        = dlg.MobInfo;
            ItemDropGroup  = dlg.ItemDropGroup;
            ItemDropTable  = dlg.ItemDropTable;

            ItemDropGroup.ReadFile();
            ItemDropTable.ReadFile();

            lblStatus.Text = @"Reading MobInfo..";
            await MobInfo.Open();

            lblStatus.Text = @"Reading ItemInfoServer..";
            await ItemInfoServer.Open();

            lblStatus.Text = @"Putting items in their groups..";
            await LoadGroups();

            lbItemGroups.DataSource    = Groups;
            lbItemGroups.DisplayMember = "Index";

            lblStatus.Text = @"Reading Mobs..";
            await LoadMobs();

            lbMobs.DataSource    = Mobs;
            lbMobs.DisplayMember = "InxName";

            await LoadItems();

            lbAllItems.DataSource = Items;

            lblStatus.Text = @"Ready";

            ToggleControls(true);
            _isLoaded = true;
        }
コード例 #3
0
ファイル: frmMain.cs プロジェクト: roknus/Spark-Editor
        private async void openFile(string fileName)
        {
            try
            {
                dynamic file = null;
                var     dgv  = new DataGridView();

                // Display the hidden progressbar in the statusbar.
                pbProgress.Visible = true;

                // Determine what file type it is and cast to the appropriate type.
                switch (Path.GetExtension(fileName))
                {
                case ".shn":
                    if (Path.GetFileNameWithoutExtension(fileName).ToLower() == "questdata")
                    {
                        file = new QuestFile(fileName);
                        Program.LoadedFiles.Add(file);
                        Extensions.FileType = FileType.QuestFile;

                        var mainTab = new TabPage("QuestFile");
                        var qTab    = new TabPage("Quests");
                        var dTab    = new TabPage("Dialouges");
                        mainTab.BackColor = Color.White;
                        dTab.BackColor    = Color.White;
                        qTab.BackColor    = Color.White;

                        var tc = new TabControl();
                        tc.Dock         = DockStyle.Fill;
                        qTab.Padding    = new Padding(0, 5, 0, 0);
                        dTab.Padding    = new Padding(0, 5, 0, 0);
                        mainTab.Padding = new Padding(0, 5, 0, 0);

                        tc.TabPages.Add(qTab);
                        tc.TabPages.Add(dTab);

                        mainTab.Controls.Add(tc);

                        var qPanel = new QuestPanel(file);
                        qPanel.Dock    = DockStyle.Fill;
                        qTab.BackColor = Color.White;
                        qTab.Controls.Add(qPanel);

                        tcFiles.TabPages.Add(mainTab);
                        tcFiles.SelectedIndex = tcFiles.TabPages.Count - 1;

                        pbProgress.Visible = false;
                        pbProgress.Value   = 0;
                        lblStatus.Text     = "Ready";
                        updateFileInfo();

                        return;
                    }

                    file = new SHNFile(fileName);
                    Extensions.FileType = FileType.SHNFile;

                    break;

                case ".txt":
                    file = new ShineFile(fileName);
                    Extensions.FileType = FileType.ShineFile;

                    break;

                default:
                    throw new Exception("File type not supported");
                }

                lblStatus.Text = "Reading " + Path.GetFileName(fileName);

                // Await the asynchronous Load method and display the reported progress in our progressbar.
                await Task.Run(() => file.Load(new Progress <int>(value =>
                                                                  mainStatusStrip.Invoke(new MethodInvoker(() =>
                {
                    pbProgress.Value = value;
                }))
                                                                  )));

                Program.LoadedFiles.Add(file);

                if (file.GetType() == typeof(SHNFile))
                {
                    dgv                 = new DataGridView();
                    dgv.Dock            = DockStyle.Fill;
                    dgv.BackgroundColor = Color.WhiteSmoke;
                    dgv.DoubleBuffered(true);
                    dgv.DataSource = file;

                    dgv.CellEnter += File_CellEnter;

                    var tab = new TabPage(file.TableName);
                    file.RowChanged += new DataRowChangeEventHandler(File_RowChanged);
                    tab.Controls.Add(dgv);

                    tcFiles.TabPages.Add(tab);
                    tcFiles.SelectedIndex = tcFiles.TabPages.Count - 1;
                }

                else if (file.GetType() == typeof(ShineFile))
                {
                    var mainTab  = new TabPage(file.DataSetName);
                    var tcTables = new TabControl();
                    tcTables.Dock = DockStyle.Fill;

                    tcTables.SelectedIndexChanged += new EventHandler((object s, EventArgs e) =>
                    {
                        file.SelectedIndex = tcTables.SelectedIndex;
                    });

                    mainTab.Controls.Add(tcTables);
                    tcFiles.TabPages.Add(mainTab);
                    mainTab.BackColor = Color.White;

                    tcFiles.SelectedIndex = tcFiles.TabCount - 1;

                    foreach (var table in file.Tables)
                    {
                        dgv                 = new DataGridView();
                        dgv.Dock            = DockStyle.Fill;
                        dgv.BackgroundColor = Color.WhiteSmoke;
                        dgv.DoubleBuffered(true);
                        dgv.DataSource = table;

                        dgv.CellEnter += File_CellEnter;

                        var tab = new TabPage(table.TableName);
                        table.RowChanged += new DataRowChangeEventHandler(File_RowChanged);
                        tab.Controls.Add(dgv);

                        tcTables.TabPages.Add(tab);
                    }
                }


                // Hide and reset the progressbar.
                pbProgress.Visible = false;
                pbProgress.Value   = 0;
                lblStatus.Text     = "Ready";
                updateFileInfo();
            }
            catch (Exception ex)
            {
                pbProgress.Visible = false;
                pbProgress.Value   = 0;
                lblStatus.Text     = "Ready";
                MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
コード例 #4
0
ファイル: frmMain.cs プロジェクト: Wicious/Spark-Editor
        private async void openFile(string fileName)
        {
            try
            {
                dynamic file = null;
                var dgv = new DataGridView();

                // Display the hidden progressbar in the statusbar.
                pbProgress.Visible = true;

                // Determine what file type it is and cast to the appropriate type.
                switch (Path.GetExtension(fileName))
                {
                    case ".shn":
                        if (Path.GetFileNameWithoutExtension(fileName).ToLower() == "questdata")
                        {
                            file = new QuestFile(fileName);
                            Program.LoadedFiles.Add(file);
                            Extensions.FileType = FileType.QuestFile;

                            var mainTab = new TabPage("QuestFile");
                            var qTab = new TabPage("Quests");
                            var dTab = new TabPage("Dialouges");
                            mainTab.BackColor = Color.White;
                            dTab.BackColor = Color.White;
                            qTab.BackColor = Color.White;

                            var tc = new TabControl();
                            tc.Dock = DockStyle.Fill;
                            qTab.Padding = new Padding(0, 5, 0, 0);
                            dTab.Padding = new Padding(0, 5, 0, 0);
                            mainTab.Padding = new Padding(0, 5, 0, 0);

                            tc.TabPages.Add(qTab);
                            tc.TabPages.Add(dTab);

                            mainTab.Controls.Add(tc);

                            var qPanel = new QuestPanel(file);
                            qPanel.Dock = DockStyle.Fill;
                            qTab.BackColor = Color.White;
                            qTab.Controls.Add(qPanel);

                            tcFiles.TabPages.Add(mainTab);
                            tcFiles.SelectedIndex = tcFiles.TabPages.Count - 1;

                            pbProgress.Visible = false;
                            pbProgress.Value = 0;
                            lblStatus.Text = "Ready";
                            updateFileInfo();

                            return;
                        }

                        file = new SHNFile(fileName);
                        Extensions.FileType = FileType.SHNFile;

                        break;

                    case ".txt":
                        file = new ShineFile(fileName);
                        Extensions.FileType = FileType.ShineFile;

                        break;

                    default:
                        throw new Exception("File type not supported");
                }

                lblStatus.Text = "Reading " + Path.GetFileName(fileName);

                // Await the asynchronous Load method and display the reported progress in our progressbar.
                await Task.Run(() => file.Load(new Progress<int>(value =>
                    mainStatusStrip.Invoke(new MethodInvoker(() =>
                    {
                        pbProgress.Value = value;
                    }))
                )));

                Program.LoadedFiles.Add(file);

                if (file.GetType() == typeof(SHNFile))
                {
                    dgv = new DataGridView();
                    dgv.Dock = DockStyle.Fill;
                    dgv.BackgroundColor = Color.WhiteSmoke;
                    dgv.DoubleBuffered(true);
                    dgv.DataSource = file;

                    dgv.CellEnter += File_CellEnter;

                    var tab = new TabPage(file.TableName);
                    file.RowChanged += new DataRowChangeEventHandler(File_RowChanged);
                    tab.Controls.Add(dgv);

                    tcFiles.TabPages.Add(tab);
                    tcFiles.SelectedIndex = tcFiles.TabPages.Count - 1;
                }

                else if (file.GetType() == typeof(ShineFile))
                {
                    var mainTab = new TabPage(file.DataSetName);
                    var tcTables = new TabControl();
                    tcTables.Dock = DockStyle.Fill;

                    tcTables.SelectedIndexChanged += new EventHandler((object s, EventArgs e) =>
                    {
                        file.SelectedIndex = tcTables.SelectedIndex;
                    });

                    mainTab.Controls.Add(tcTables);
                    tcFiles.TabPages.Add(mainTab);
                    mainTab.BackColor = Color.White;

                    tcFiles.SelectedIndex = tcFiles.TabCount - 1;

                    foreach (var table in file.Tables)
                    {
                        dgv = new DataGridView();
                        dgv.Dock = DockStyle.Fill;
                        dgv.BackgroundColor = Color.WhiteSmoke;
                        dgv.DoubleBuffered(true);
                        dgv.DataSource = table;

                        dgv.CellEnter += File_CellEnter;

                        var tab = new TabPage(table.TableName);
                        table.RowChanged += new DataRowChangeEventHandler(File_RowChanged);
                        tab.Controls.Add(dgv);

                        tcTables.TabPages.Add(tab);
                    }
                }


                // Hide and reset the progressbar.
                pbProgress.Visible = false;
                pbProgress.Value = 0;
                lblStatus.Text = "Ready";
                updateFileInfo();
            }
            catch (Exception ex)
            {
                pbProgress.Visible = false;
                pbProgress.Value = 0;
                lblStatus.Text = "Ready";
                MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }