Advertisement
Guest User

d2ieditor

a guest
Jul 13th, 2019
146
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.53 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.ComponentModel;
  4. using System.Data;
  5. using System.Drawing;
  6. using System.Linq;
  7. using System.Text;
  8. using System.Threading.Tasks;
  9. using System.Windows.Forms;
  10. using System.IO;
  11. using Stump.DofusProtocol.Tools.D2i;
  12.  
  13. namespace WindowsFormsApp1
  14. {
  15. public partial class Form1 : Form
  16. {
  17. public string path
  18. {
  19. get;
  20. set;
  21. }
  22. public string IdOfTextChange
  23. {
  24. get;
  25. set;
  26. }
  27. public D2IFile d2i;
  28.  
  29.  
  30. public Form1()
  31. {
  32. InitializeComponent();
  33. }
  34.  
  35. private void button1_Click(object sender, EventArgs e)
  36. {
  37. OpenFileDialog ofd = new OpenFileDialog();
  38. DialogResult result = ofd.ShowDialog();
  39. if (result == DialogResult.OK && ofd.CheckFileExists && Path.GetExtension(ofd.FileName) == ".d2i")
  40. {
  41. path = Path.GetFullPath(ofd.FileName);
  42. MessageBox.Show("Load ! ","Load");
  43. d2i = new D2IFile(path);
  44. }
  45. else { MessageBox.Show("Erreur","Load"); }
  46. }
  47.  
  48. private void loadtext_Click(object sender, EventArgs e)
  49. {
  50. if (d2i == null)
  51. {
  52. MessageBox.Show("Load a file !", "Error");
  53. }
  54. else
  55. {
  56. //foreach(var text in d2i.GetAllText())
  57. //{
  58. var txt = d2i.GetText(500);
  59. dataGridView1.Rows.Add("500", txt);
  60. //}
  61. }
  62. }
  63.  
  64. private void dataGridView1_CellContentClick(object sender, DataGridViewCellEventArgs e)
  65. {
  66.  
  67. richTextBox1.Text = dataGridView1.CurrentRow.Cells[1].Value.ToString();
  68. IdOfTextChange= dataGridView1.CurrentRow.Cells[0].Value.ToString();
  69. groupBox1.Show();
  70.  
  71. }
  72.  
  73. private void textSave_Click(object sender, EventArgs e)
  74. {
  75. var content = richTextBox1.Text;
  76. d2i.SetText(IdOfTextChange,content);
  77. groupBox1.Hide();
  78. }
  79.  
  80. private void textCancel_Click(object sender, EventArgs e)
  81. {
  82. groupBox1.Hide();
  83. }
  84.  
  85. private void Save_Click(object sender, EventArgs e)
  86. {
  87. SaveFileDialog save = new SaveFileDialog();
  88. if(save.ShowDialog() == DialogResult.OK)
  89. {
  90. d2i.Save(save.FileName);
  91. }
  92. }
  93. }
  94. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement