using System; using System.IO; using System.Net; using System.Data; using System.Linq; using System.Text; using System.Drawing; using System.Management; using System.Reflection; using System.Diagnostics; using System.Net.Sockets; using System.Windows.Forms; using System.Globalization; using System.ComponentModel; using System.Drawing.Imaging; using System.Collections.Generic; using System.Security.Cryptography; using System.Runtime.InteropServices; using CS; using DDS; using SHN; using TXT; namespace SHNEditor { public partial class Main : Form { private Socket OE_Listener; private Socket OE_Socket; private Byte[] OE_Buffer; private Dictionary OpenSHNsArray = new Dictionary(); private Dictionary OpenSTArray = new Dictionary(); private Int32 LastSelectedSHNID = -1; private Dictionary SHNF = new Dictionary(); private Dictionary SHNFWT = new Dictionary(); private Dictionary SHNSR = new Dictionary(); private Dictionary>> SHNSC = new Dictionary>>(); private Dictionary SHNFDR = new Dictionary(); private Dictionary SHNHSO = new Dictionary(); private Dictionary> SHNVC = new Dictionary>(); private Dictionary> SHNCW = new Dictionary>(); private Boolean SHNIsClosing; private Boolean SHNFTrigger; private Boolean SHNDEOpening; private Boolean SHNVCTrigger; private Boolean STIsClosing; private Boolean STIsOpening; private Boolean SHNWTrigger; private Boolean SHNSGridTrigger; private Boolean SHNMFU; private Boolean SHNFWTU; private Int32 SHNSGridRowIndex; private String SHNIVIconPath; private SHNFile QuestDialogSHN; private SHNFile ItemInfoSHN; private SHNFile MobInfoSHN; public Main() { InitializeComponent(); } private void Main_Shown(Object Sender, EventArgs Args) { Hide(); Text = String.Concat(Text, " - ", Properties.Resources.BuildDate); SHN_Tools.Width = 205; SHN_Tools2.Width = 205; SHN_QTools.Width = 205; ST_Tools.Width = 205; ST_Tools2.Width = 205; Show(); CBV = SetClipboardViewer(this.Handle); SHN_Grid.DoubleBuffered(true); SHN_SGrid.DoubleBuffered(true); ST_Grid.DoubleBuffered(true); DataTable CreateSGridTable = SGridTable; if (!Directory.Exists("C:\\KEBackups\\")) { Directory.CreateDirectory("C:\\KEBackups\\"); } if (!File.Exists("C:\\SHNCrypto.cs")) { try { File.WriteAllBytes("C:\\SHNCrypto.cs", Encoding.UTF8.GetBytes(Properties.Resources.SHNCrypto)); } catch { MessageBox.Show("Unable to create \"SHNCrypto.cs\" in C:\\. Please restart the editor as Administrator, then close it and open it agian (without Administrator)."); Environment.Exit(0); } } foreach (String MethodName in CSFile.LoadMethodNames("C:\\SHNCrypto.cs", "SHN.SHNCrypto")) { SHNCrypt_List.Items.Add(MethodName); SHNEC_FE.Items.Add(MethodName); SHNEC_TE.Items.Add(MethodName); } SHNCrypt_List.SelectedIndex = 0; SHNEC_FE.SelectedIndex = 0; SHNEC_TE.SelectedIndex = 0; SHNQME_Increase.SelectedIndex = 0; SetInformation(Color.Green, " SHN Editor started successfully!"); OpenParams(); SHNST_Splitter.Panel2Collapsed = true; SHNST_Splitter.Panel2.Hide(); } private String GetMacaddresses() { ManagementClass MC = new ManagementClass("Win32_NetworkAdapterConfiguration"); ManagementObjectCollection MOC = MC.GetInstances(); String MacAddresses = ""; foreach (ManagementObject MO in MOC) { try { MacAddresses += MO["MacAddress"].ToString(); } catch { } } return MacAddresses; } private String CreateMD5(String Input) { Byte[] InputArray = Encoding.UTF8.GetBytes(Input); using (MD5 MD5Creator = MD5.Create()) { Byte[] HashedInputArray = MD5Creator.ComputeHash(InputArray); StringBuilder MD5Builder = new StringBuilder(32); foreach (Byte HashByte in HashedInputArray) { MD5Builder.Append(HashByte.ToString("X2")); } return MD5Builder.ToString(); } } private String CreateSHA512(String Input) { Byte[] InputArray = Encoding.UTF8.GetBytes(Input); using (SHA512 SHA512Creator = SHA512.Create()) { Byte[] HashedInputArray = SHA512Creator.ComputeHash(InputArray); StringBuilder SHA512Builder = new StringBuilder(128); foreach (Byte HashByte in HashedInputArray) { SHA512Builder.Append(HashByte.ToString("X2")); } return SHA512Builder.ToString(); } } private void OpenParams() { String[] Parameters = Environment.GetCommandLineArgs(); if (Parameters.Length == 1) { return; } OpenSHN(Parameters[1]); } #region CB Section [DllImport("User32.dll", CharSet = CharSet.Auto)] public static extern IntPtr SetClipboardViewer(IntPtr hWndNewViewer); [DllImport("User32.dll", CharSet = CharSet.Auto)] public static extern bool ChangeClipboardChain(IntPtr hWndRemove, IntPtr hWndNewNext); private const int WM_DRAWCLIPBOARD = 0x0308; private IntPtr CBV; protected override void WndProc(ref Message CBM) { base.WndProc(ref CBM); if (CBM.Msg == WM_DRAWCLIPBOARD) { IDataObject CBData = Clipboard.GetDataObject(); if (CBData.GetDataPresent(DataFormats.Text)) { String CBText = (String)CBData.GetData(DataFormats.Text); CB_Text.Text = CBText; } } } #endregion #region Icon Viewer private void SHNIV_SIcons_Click(Object Sender, EventArgs Args) { FolderBrowserDialog IconFolderDialog = new FolderBrowserDialog(); IconFolderDialog.Description = "Select Icons folder."; DialogResult IconFolderResult = IconFolderDialog.ShowDialog(); if (IconFolderResult == DialogResult.OK) { SHNIVIconPath = IconFolderDialog.SelectedPath; SHNIV_ISelected.Text = "Icon folder selected."; SetInformation(Color.Green, "Icon path selected."); } else { SetInformation(Color.Red, "No icon folder has been selected."); } } #endregion #region Crypto private void SHNCrypt_SC_Click(Object Sender, EventArgs Args) { if (OpenSHNsArray.Count == 0) { SetInformation(Color.Red, "No SHN file is currently open."); return; } SelectedSHN.CryptoMethod = CSFile.LoadCode("C:\\SHNCrypto.cs", "SHN.SHNCrypto", SHNCrypt_List.SelectedItem.ToString()); } #endregion #region One Editor private void OE_Connect() { OE_Socket = new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp); OE_Socket.BeginConnect(new IPEndPoint(IPAddress.Parse("127.0.0.1"), 38750), new AsyncCallback(OE_Connected), null); } private void OE_Connected(IAsyncResult IAResult) { try { OE_Socket.EndConnect(IAResult); String[] Parameters = Environment.GetCommandLineArgs(); if (Parameters.Length == 1) { Environment.Exit(0); } OE_Socket.Send(Encoding.ASCII.GetBytes(Parameters[1])); Environment.Exit(0); } catch { Environment.Exit(0); } } private void OE_Start() { OE_Listener = new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp); OE_Listener.Bind(new IPEndPoint(IPAddress.Parse("127.0.0.1"), 38750)); OE_Listener.Listen(1); OE_Accept(); } private void OE_Accept() { OE_Listener.BeginAccept(new AsyncCallback(OE_NewEditor), null); } private void OE_NewEditor(IAsyncResult IAResult) { OE_Socket = OE_Listener.EndAccept(IAResult); OE_Buffer = new Byte[255]; OE_Socket.BeginReceive(OE_Buffer, 0, OE_Buffer.Length, SocketFlags.None, new AsyncCallback(OE_ReceivedPath), null); } private void OE_ReceivedPath(IAsyncResult IAResult) { Int32 RLength = OE_Socket.EndReceive(IAResult); if (RLength != 0) { Array.Resize(ref OE_Buffer, RLength); String Path = Encoding.ASCII.GetString(OE_Buffer); OpenSHN(Path); } else { OE_Socket.Close(); } } #endregion #region SHN Buttons private void SHN_Open_Click(Object Sender, EventArgs Args) { OpenFileDialog SHNDialog = new OpenFileDialog(); SHNDialog.Filter = "SHN Files (.shn)|*.shn"; SHNDialog.Title = "Open SHN File"; DialogResult SHNResult = SHNDialog.ShowDialog(); if (SHNResult == DialogResult.OK) { OpenSHN(SHNDialog.FileName); SetInformation(Color.Green, String.Format("{0} has been opened.", SHNDialog.FileName)); } else { SetInformation(Color.Red, "No file has been opened due to cancelling the dialog."); } } private void SHN_SSP_Click(object sender, EventArgs Args) { if (SHN_SSP.Checked) { SidePanel.Visible = false; SHN_SSP.Checked = false; } else { SidePanel.Visible = true; SHN_SSP.Checked = true; } } private void SHN_ST_Click(Object Sender, EventArgs Args) { if (SHN_ST.Checked) { SHN_Tools.Visible = false; SHN_ST.Checked = false; } else { SHN_Tools.Visible = true; SHN_ST.Checked = true; } } private void SHN_ST2_Click(Object Sender, EventArgs Args) { if (SHN_ST2.Checked) { SHN_Tools2.Visible = false; SHN_ST2.Checked = false; } else { SHN_Tools2.Visible = true; SHN_ST2.Checked = true; } } private void SHN_SItems_Click(Object Sender, EventArgs Args) { if (SelectedSHN.Type != SHNType.ItemInfo) { SetInformation(Color.Red, "Please open ItemInfo."); } else if (!File.Exists(String.Format("{0}ItemViewInfo.shn", SelectedSHN.LoadPath.Replace("ItemInfo.shn", "")))) { SetInformation(Color.Red, "You need ItemViewInfo.shn in same directory as the open ItemInfo.shn"); } else if (!File.Exists(String.Format("{0}ChargedEffect.shn", SelectedSHN.LoadPath.Replace("ItemInfo.shn", "")))) { SetInformation(Color.Red, "You need ChargedEffect.shn in same directory as the open ItemInfo.shn"); } else if (!File.Exists(String.Format("{0}ItemUseEffect.shn", SelectedSHN.LoadPath.Replace("ItemInfo.shn", "")))) { SetInformation(Color.Red, "You need ItemUseEffect.shn in same directory as the open ItemInfo.shn"); } else { OpenFileDialog SHNDialog = new OpenFileDialog(); SHNDialog.Filter = "SHN Files (.shn)|*.shn"; SHNDialog.Title = "Open editing ItemInfo SHN"; DialogResult SHNResult = SHNDialog.ShowDialog(); if (SHNResult == DialogResult.OK) { if (!File.Exists(String.Format("{0}ItemViewInfo.shn", SHNDialog.FileName.Replace("ItemInfo.shn", "")))) { SetInformation(Color.Red, "You need ItemViewInfo.shn in same directory as the selected ItemInfo.shn"); } else if (!File.Exists(String.Format("{0}ChargedEffect.shn", SHNDialog.FileName.Replace("ItemInfo.shn", "")))) { SetInformation(Color.Red, "You need ChargedEffect.shn in same directory as the selected ItemInfo.shn"); } else if (!File.Exists(String.Format("{0}ItemUseEffect.shn", SHNDialog.FileName.Replace("ItemInfo.shn", "")))) { SetInformation(Color.Red, "You need ItemUseEffect.shn in same directory as the selected ItemInfo.shn"); } else { try { MethodInfo CryptoMethod = CSFile.LoadCode("C:\\SHNCrypto.cs", "SHN.SHNCrypto", SHNCrypt_List.SelectedItem.ToString()); SHNFile ItemViewInfo = new SHNFile(String.Format("{0}ItemViewInfo.shn", SelectedSHN.LoadPath.Replace("ItemInfo.shn", "")), CryptoMethod); if (ItemViewInfo.Type == SHNType.TextData) { ItemViewInfo.SHNEncoding = Encoding.ASCII; } else { ItemViewInfo.SHNEncoding = Encoding.GetEncoding("ISO-8859-1"); } if (ItemViewInfo.Type != SHNType.QuestData) { ItemViewInfo.Read(); } else { ItemViewInfo.ReadQuest(); } SHNFile ChargedEffect = new SHNFile(String.Format("{0}ChargedEffect.shn", SelectedSHN.LoadPath.Replace("ItemInfo.shn", "")), CryptoMethod); if (ChargedEffect.Type == SHNType.TextData) { ChargedEffect.SHNEncoding = Encoding.ASCII; } else { ChargedEffect.SHNEncoding = Encoding.GetEncoding("ISO-8859-1"); } if (ChargedEffect.Type != SHNType.QuestData) { ChargedEffect.Read(); } else { ChargedEffect.ReadQuest(); } SHNFile ItemUseEffect = new SHNFile(String.Format("{0}ItemUseEffect.shn", SelectedSHN.LoadPath.Replace("ItemInfo.shn", "")), CryptoMethod); if (ItemUseEffect.Type == SHNType.TextData) { ItemUseEffect.SHNEncoding = Encoding.ASCII; } else { ItemUseEffect.SHNEncoding = Encoding.GetEncoding("ISO-8859-1"); } if (ItemUseEffect.Type != SHNType.QuestData) { ItemUseEffect.Read(); } else { ItemUseEffect.ReadQuest(); } SHNFile ItemInfoServer = null; //if (File.Exists(String.Format("{0}ItemInfoServer.shn", SelectedSHN.LoadPath.Replace("ItemInfo.shn", "")))) //{ // ItemInfoServer = new SHNFile(String.Format("{0}ItemInfoServer.shn", SelectedSHN.LoadPath.Replace("ItemInfo.shn", "")), CryptoMethod); // if (ItemInfoServer.Type == SHNType.TextData) { ItemInfoServer.SHNEncoding = Encoding.ASCII; } // else { ItemInfoServer.SHNEncoding = Encoding.GetEncoding("ISO-8859-1"); } // if (ItemInfoServer.Type != SHNType.QuestData) { ItemInfoServer.Read(); } // else { ItemInfoServer.ReadQuest(); } //} SHNFile EItemInfo = new SHNFile(String.Format("{0}ItemInfo.shn", SHNDialog.FileName.Replace("ItemInfo.shn", "")), CryptoMethod); if (EItemInfo.Type == SHNType.TextData) { EItemInfo.SHNEncoding = Encoding.ASCII; } else { EItemInfo.SHNEncoding = Encoding.GetEncoding("ISO-8859-1"); } if (EItemInfo.Type != SHNType.QuestData) { EItemInfo.Read(); } else { EItemInfo.ReadQuest(); } SHNFile EItemViewInfo = new SHNFile(String.Format("{0}ItemViewInfo.shn", SHNDialog.FileName.Replace("ItemInfo.shn", "")), CryptoMethod); if (EItemViewInfo.Type == SHNType.TextData) { EItemViewInfo.SHNEncoding = Encoding.ASCII; } else { EItemViewInfo.SHNEncoding = Encoding.GetEncoding("ISO-8859-1"); } if (EItemViewInfo.Type != SHNType.QuestData) { EItemViewInfo.Read(); } else { EItemViewInfo.ReadQuest(); } SHNFile EChargedEffect = new SHNFile(String.Format("{0}ChargedEffect.shn", SHNDialog.FileName.Replace("ItemInfo.shn", "")), CryptoMethod); if (EChargedEffect.Type == SHNType.TextData) { EChargedEffect.SHNEncoding = Encoding.ASCII; } else { EChargedEffect.SHNEncoding = Encoding.GetEncoding("ISO-8859-1"); } if (EChargedEffect.Type != SHNType.QuestData) { EChargedEffect.Read(); } else { EChargedEffect.ReadQuest(); } SHNFile EItemUseEffect = new SHNFile(String.Format("{0}ItemUseEffect.shn", SHNDialog.FileName.Replace("ItemInfo.shn", "")), CryptoMethod); if (EItemUseEffect.Type == SHNType.TextData) { EItemUseEffect.SHNEncoding = Encoding.ASCII; } else { EItemUseEffect.SHNEncoding = Encoding.GetEncoding("ISO-8859-1"); } if (EItemUseEffect.Type != SHNType.QuestData) { EItemUseEffect.Read(); } else { EItemUseEffect.ReadQuest(); } foreach (DataGridViewRow Row in SHN_Grid.SelectedRows) { UInt16 ItemID = 0; String ItemIndex = String.Empty; if (EItemInfo.Table.Rows.Cast().Where(ItemArray => Convert.ToString(ItemArray.ItemArray[1]) == Convert.ToString(Row.Cells[1].Value)).FirstOrDefault() != null) { ItemIndex = String.Concat(Convert.ToString(Row.Cells[1].Value), "01"); } else { ItemIndex = Convert.ToString(Row.Cells[1].Value); } for (UInt16 Counter = 0; Counter < 65535; Counter++) { if (EItemInfo.Table.Rows.Cast().Where(ItemArray => Convert.ToUInt16(ItemArray.ItemArray[0]) == Counter).FirstOrDefault() == null) { ItemID = Counter; break; } } DataRow IFRow; DataRow CERow; DataRow IUERow; DataRow IVIRow; DataRow IFSRow; if ((IFRow = SelectedSHN.Table.Rows.Cast().Where(ItemArray => Convert.ToString(ItemArray.ItemArray[1]) == Convert.ToString(Row.Cells[1].Value)).FirstOrDefault()) != null) { Object[] ItemArray = IFRow.ItemArray; ItemArray[0] = ItemID; ItemArray[1] = ItemIndex; EItemInfo.Table.Rows.Add(ItemArray); } if ((CERow = ChargedEffect.Table.Rows.Cast().Where(ItemArray => Convert.ToString(ItemArray.ItemArray[1]) == Convert.ToString(Row.Cells[1].Value)).FirstOrDefault()) != null) { Object[] ItemArray = CERow.ItemArray; ItemArray[0] = Convert.ToUInt16(EChargedEffect.Table.Rows[ChargedEffect.Table.Rows.Count - 1].ItemArray[0]) + 1; ItemArray[1] = ItemIndex; EChargedEffect.Table.Rows.Add(ItemArray); } if ((IUERow = ItemUseEffect.Table.Rows.Cast().Where(ItemArray => Convert.ToString(ItemArray.ItemArray[0]) == Convert.ToString(Row.Cells[1].Value)).FirstOrDefault()) != null) { Object[] ItemArray = IUERow.ItemArray; ItemArray[0] = ItemIndex; EItemUseEffect.Table.Rows.Add(ItemArray); } if ((IVIRow = EItemViewInfo.Table.Rows.Cast().Where(ItemArray => Convert.ToString(ItemArray.ItemArray[1]) == Convert.ToString(Row.Cells[1].Value)).FirstOrDefault()) != null) { Object[] ItemArray = IVIRow.ItemArray; ItemArray[0] = ItemID; ItemArray[1] = ItemIndex; EItemViewInfo.Table.Rows.Add(ItemArray); } } EItemInfo.Write(EItemInfo.LoadPath); EChargedEffect.Write(EChargedEffect.LoadPath); EItemUseEffect.Write(EItemUseEffect.LoadPath); EItemViewInfo.Write(EItemViewInfo.LoadPath); } catch(Exception Error) { MessageBox.Show(Error.ToString()); } } } } } private void SHN_STQ_Click(Object Sender, EventArgs Args) { if (SHN_STQ.Checked) { SHN_QTools.Visible = false; SHN_STQ.Checked = false; } else { SHN_QTools.Visible = true; SHN_STQ.Checked = true; } } private void SHN_STQ2_Click(Object Sender, EventArgs Args) { if (SHN_STQ2.Checked) { SHN_QTools2.Visible = false; SHN_STQ2.Checked = false; } else { SHN_QTools2.Visible = true; SHN_STQ2.Checked = true; } } private void SHN_SV_Click(Object Sender, EventArgs Args) { if (SHN_SV.Checked) { SHN_SC.Panel1Collapsed = true; SHN_SC.Panel1.Hide(); SHN_SV.Checked = false; } else { SHN_SC.Panel1Collapsed = false; SHN_SC.Panel1.Show(); SHN_SV.Checked = true; } } private void SHNDecrypt_Click(Object Sender, EventArgs Args) { OpenFileDialog SHNDialog = new OpenFileDialog(); SHNDialog.Filter = "SHN Files (.shn)|*.shn"; SHNDialog.Title = "Open SHN File"; DialogResult SHNResult = SHNDialog.ShowDialog(); if (SHNResult == DialogResult.OK) { MethodInfo CryptoMethod = CSFile.LoadCode("C:\\SHNCrypto.cs", "SHN.SHNCrypto", SHNCrypt_List.SelectedItem.ToString()); SHNFile DecryptSHN = new SHNFile(SHNDialog.FileName, CryptoMethod); DecryptSHN.ReadData(true); DecryptSHN.WriteData(DecryptSHN.LoadPath, false); SetInformation(Color.Green, String.Format("{0} has been decrypted.", SHNDialog.FileName)); } else { SetInformation(Color.Red, "No file has been opened due to cancelling the dialog."); } } #endregion #region Shine Tables Buttons private void ShineTables_SE_Click(Object Sender, EventArgs Args) { if (ShineTables_SE.Checked) { SHNST_Splitter.Panel2Collapsed = true; SHNST_Splitter.Panel2.Hide(); ShineTables_OTP.Visible = false; ShineTables_SE.Checked = false; } else { SHNST_Splitter.Panel2Collapsed = false; SHNST_Splitter.Panel2.Show(); ShineTables_OTP.Visible = true; ShineTables_SE.Checked = true; } } private void ST_ST_Click(Object Sender, EventArgs Args) { if (ST_ST.Checked) { ST_Tools.Visible = false; ST_ST.Checked = false; } else { ST_Tools.Visible = true; ST_ST.Checked = true; } } private void ST_ST2_Click(Object Sender, EventArgs Args) { if (ST_ST2.Checked) { ST_Tools2.Visible = false; ST_ST2.Checked = false; } else { ST_Tools2.Visible = true; ST_ST2.Checked = true; } } private void ShineTables_Open_Click(Object Sender, EventArgs Args) { if (!ShineTables_SE.Checked) { SetInformation(Color.Red, "Please press Shine Tables -> Show Editor before opening a file."); return; } OpenFileDialog TXTDialog = new OpenFileDialog(); TXTDialog.Filter = "Shine Files (.txt)|*.txt"; TXTDialog.Title = "Open Shine File"; DialogResult SHNResult = TXTDialog.ShowDialog(); if (SHNResult == DialogResult.OK) { OpenST(TXTDialog.FileName); SetInformation(Color.Green, String.Format("{0} has been opened.", TXTDialog.FileName)); } else { SetInformation(Color.Red, "No file has been opened due to cancelling the dialog."); } } private void ShineTables_FNI_Click(Object Sender, EventArgs Args) { if (OpenSHNsArray.Count == 0) { SetInformation(Color.Red, "No SHN file is currently open."); } else { OpenFileDialog TXTDialog = new OpenFileDialog(); TXTDialog.Filter = "Shine Files (.txt)|*.txt"; TXTDialog.Title = "Open Shine File"; DialogResult SHNResult = TXTDialog.ShowDialog(); if (SHNResult == DialogResult.OK) { ShineTable OpenNPC = new ShineTable(TXTDialog.FileName); OpenNPC.Read(); if (!OpenNPC.Tables[0].Source.TableName.StartsWith("Tab")) { SetInformation(Color.Red, "This is not a valid NPC item list file."); } else { List ToFilter = new List(); foreach (Table NPCTable in OpenNPC.Tables) { foreach (DataRow Row in NPCTable.Source.Rows) { for (Int32 Counter = 1; Counter < 7; Counter++) { ToFilter.Add(Row[Counter].ToString()); } } } String FilterString = ""; if (SelectedSHN.Type == SHNType.ChargedEffect) { FilterString = FilterString + "ItemID IN ("; } else if (SelectedSHN.Type == SHNType.GradeItemOption) { FilterString = FilterString + "ItemIndex IN ("; } else { FilterString = FilterString + "InxName IN ("; } foreach (String Value in ToFilter) { FilterString = FilterString + String.Format("'{0}', ", Value); } SelectedSHN.Table.DefaultView.RowFilter = FilterString.TrimEnd(", ".ToCharArray()) + ")"; } } else { SetInformation(Color.Red, "No file has been opened due to cancelling the dialog."); } } } private void ShineTables_FMS_Click(Object Sender, EventArgs Args) { if (OpenSHNsArray.Count == 0) { SetInformation(Color.Red, "No SHN file is currently open."); } else { OpenFileDialog TXTDialog = new OpenFileDialog(); TXTDialog.Filter = "Shine Files (.txt)|*.txt"; TXTDialog.Title = "Open Shine File"; DialogResult SHNResult = TXTDialog.ShowDialog(); if (SHNResult == DialogResult.OK) { ShineTable OpenMob = new ShineTable(TXTDialog.FileName); OpenMob.Read(); if (OpenMob.Tables[0].Source.TableName != "MobRegenGroup") { SetInformation(Color.Red, "This is not a valid Mob spawn file."); } else { List ToFilter = new List(); foreach (DataRow Row in OpenMob.Tables[1].Source.Rows) { ToFilter.Add(Row[1].ToString()); } String FilterString = ""; if (SelectedSHN.Type == SHNType.ChargedEffect) { FilterString = FilterString + "ItemID IN ("; } else if (SelectedSHN.Type == SHNType.GradeItemOption) { FilterString = FilterString + "ItemIndex IN ("; } else { FilterString = FilterString + "InxName IN ("; } foreach (String Value in ToFilter) { FilterString = FilterString + String.Format("'{0}', ", Value); } SelectedSHN.Table.DefaultView.RowFilter = FilterString.TrimEnd(", ".ToCharArray()) + ")"; } } else { SetInformation(Color.Red, "No file has been opened due to cancelling the dialog."); } } } private void ShineTables_CNFR_Click(Object Sender, EventArgs Args) { if (OpenSHNsArray.Count == 0) { SetInformation(Color.Red, "No SHN file is currently open."); } else if (SelectedSHN.Type != SHNType.ItemInfo) { SetInformation(Color.Red, "This tool can only be used with ItemInfo.shn"); } else if (SHN_Grid.SelectedRows.Count == 0) { SetInformation(Color.Red, "Please select atleast 1 row to put into the NPC."); } else { SaveFileDialog TXTDialog = new SaveFileDialog(); TXTDialog.Filter = "Shine Files (.txt)|*.txt"; TXTDialog.Title = "Save Shine File"; DialogResult SHNResult = TXTDialog.ShowDialog(); if (SHNResult == DialogResult.OK) { ShineTable NewST = new ShineTable(TXTDialog.FileName); NewST.Tables = new List(); NewST.Tables.Add(TXT.TableCreator.CreateDefaultNPCTable()); Int32 Rec = 0; List RowData = new List(); foreach (DataGridViewRow Row in SHN_Grid.SelectedRows.Cast().OrderBy(Index => Index.Index)) { if (RowData.Count == 0) { RowData.Add(Rec.ToString()); } RowData.Add(Row.Cells[1].Value.ToString()); if (RowData.Count == 7) { NewST.Tables[0].Source.Rows.Add(RowData.ToArray()); Rec++; RowData.Clear(); } } if (RowData.Count != 1) { for (Int32 Counter = RowData.Count; Counter < 7; Counter++) { RowData.Add("-"); } if (RowData[0] == "-") { RowData[0] = Convert.ToString(Rec); } NewST.Tables[0].Source.Rows.Add(RowData.ToArray()); } NewST.Write(NewST.LoadPath); SetInformation(Color.Green, "Selected rows have been put into a new NPC file."); } else { SetInformation(Color.Red, "No file has been saved due to cancelling the dialog."); } } } private void ShineTables_CMRFR_Click(Object Sender, EventArgs Args) { if (OpenSHNsArray.Count == 0) { SetInformation(Color.Red, "No SHN file is currently open."); } else if (SelectedSHN.Type != SHNType.MobInfo) { SetInformation(Color.Red, "This tool can only be used with MobInfo.shn"); } else if (SHN_Grid.SelectedRows.Count == 0) { SetInformation(Color.Red, "Please select atleast 1 row to put into the NPC."); } else { SaveFileDialog TXTDialog = new SaveFileDialog(); TXTDialog.Filter = "Shine Files (.txt)|*.txt"; TXTDialog.Title = "Save Shine File"; DialogResult SHNResult = TXTDialog.ShowDialog(); if (SHNResult == DialogResult.OK) { ShineTable NewST = new ShineTable(TXTDialog.FileName); NewST.Tables = new List
(); NewST.Tables.Add(TXT.TableCreator.CreateDefaultMobRegenGroup()); NewST.Tables.Add(TXT.TableCreator.CreateMobRegen()); for (Int32 Counter = 0; Counter < SHN_Grid.SelectedRows.Count; Counter++) { NewST.Tables[0].Source.Rows.Add(new String[] { String.Concat("Area", Counter.ToString().PadLeft(3, '0')), "N", "0", "0", "0", "0", "0" }); } Int32 AreaID = 0; foreach (DataGridViewRow Row in SHN_Grid.SelectedRows.Cast().OrderBy(Index => Index.Index)) { NewST.Tables[1].Source.Rows.Add(new String[] { String.Concat("Area", AreaID.ToString().PadLeft(3, '0')), Row.Cells[1].Value.ToString(), "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0" }); AreaID++; } NewST.Write(NewST.LoadPath); SetInformation(Color.Green, "Selected rows have been put into a new MobRegen file."); } else { SetInformation(Color.Red, "No file has been saved due to cancelling the dialog."); } } } #endregion #region Modules Buttons #region General private void CBS_Click(Object Sender, EventArgs Args) { if (CBS.Checked) { CBG.Visible = false; CBS.Checked = false; } else { CBG.Visible = true; CBS.Checked = true; } } #endregion #region SHN private void SHNIVS_Click(Object Sender, EventArgs Args) { if (SHNIVS.Checked) { SHNIV_Panel.Visible = false; SHNIVS.Checked = false; } else { if (OpenSHNsArray.Count != 0 && SelectedSHN.Type == SHNType.ItemViewInfo) { SHNIV_Panel.Visible = true; } SHNIVS.Checked = true; } } private void SHNOFS_Click(Object Sender, EventArgs Args) { if (SHNOFS.Checked) { OpenSHNs.Visible = false; SHNOFS.Checked = false; } else { OpenSHNs.Visible = true; SHNOFS.Checked = true; } } private void SHNFS_Click(Object Sender, EventArgs Args) { if (SHNFS.Checked) { SHNFilterG.Visible = false; SHNFS.Checked = false; } else { SHNFilterG.Visible = true; SHNFS.Checked = true; } } private void SHNIS_Click(Object Sender, EventArgs Args) { if (SHNIS.Checked) { SHNIG.Visible = false; SHNIS.Checked = false; } else { SHNIG.Visible = true; SHNIS.Checked = true; } } private void SHNRS_Click(Object Sender, EventArgs Args) { if (SHNRS.Checked) { SHNRG.Visible = false; SHNRS.Checked = false; } else { SHNRG.Visible = true; SHNRS.Checked = true; } } private void SHNCMES_Click(Object Sender, EventArgs Args) { if (SHNCMES.Checked) { SHNCMEG.Visible = false; SHNCMES.Checked = false; } else { SHNCMEG.Visible = true; SHNCMES.Checked = true; } } private void SHNFWTS_Click(Object Sender, EventArgs Args) { if (SHNFWTS.Checked) { SHNFWTG.Visible = false; SHNFWTS.Checked = false; } else { SHNFWTG.Visible = true; SHNFWTS.Checked = true; } } private void SHNROS_Click(Object Sender, EventArgs Args) { if (SHNROS.Checked) { SHNROG.Visible = false; SHNROS.Checked = false; } else { SHNROG.Visible = true; SHNROS.Checked = true; } } private void SHNVCS_Click(Object Sender, EventArgs Args) { if (SHNVCS.Checked) { SHNVCG.Visible = false; SHNVCS.Checked = false; } else { SHNVCG.Visible = true; SHNVCS.Checked = true; } } #endregion #region Shine Tables private void STOFS_Click(Object Sender, EventArgs Args) { if (STOFS.Checked) { OpenShineTables.Visible = false; STOFS.Checked = false; } else { OpenShineTables.Visible = true; STOFS.Checked = true; } } private void STTS_Click(Object Sender, EventArgs Args) { if (STTS.Checked) { ShineTables_T.Visible = false; STTS.Checked = false; } else { ShineTables_T.Visible = true; STTS.Checked = true; } } private void STFS_Click(Object Sender, EventArgs Args) { if (STFS.Checked) { STFilterG.Visible = false; STFS.Checked = false; } else { STFilterG.Visible = true; STFS.Checked = true; } } private void STIS_Click(Object Sender, EventArgs Args) { if (STIS.Checked) { STIG.Visible = false; STIS.Checked = false; } else { STIG.Visible = true; STIS.Checked = true; } } private void STDTES_Click(Object Sender, EventArgs Args) { if (STDTES.Checked) { STDTM_Panel.Visible = false; STDTES.Checked = false; } else { if (OpenSTArray.Count != 0 && SelectedST.Tables[0].Source.TableName.StartsWith("ItemGroup")) { SHNIV_Panel.Visible = true; } STDTES.Checked = true; } } private void STRS_Click(Object Sender, EventArgs Args) { if (STRS.Checked) { STRG.Visible = false; STRS.Checked = false; } else { STRG.Visible = true; STRS.Checked = true; } } private void STCMES_Click(Object Sender, EventArgs Args) { if (STCMES.Checked) { STCMEG.Visible = false; STCMES.Checked = false; } else { STCMEG.Visible = true; STCMES.Checked = true; } } private void STFWTS_Click(Object Sender, EventArgs Args) { if (STFWTS.Checked) { STFWTG.Visible = false; STFWTS.Checked = false; } else { STFWTG.Visible = true; STFWTS.Checked = true; } } private void STROS_Click(Object Sender, EventArgs Args) { if (STROS.Checked) { STROG.Visible = false; STROS.Checked = false; } else { STROG.Visible = true; STROS.Checked = true; } } private void STVCS_Click(Object Sender, EventArgs Args) { if (STVCS.Checked) { STVCG.Visible = false; STVCS.Checked = false; } else { STVCG.Visible = true; STVCS.Checked = true; } } #endregion #endregion #region Extra Functions Buttons private void SHN_MSearch_Click(Object Sender, EventArgs Args) { } private void SHBDC_Click(Object Sender, EventArgs Args) { } #endregion #region Column Meaning private void CM_QD_Click(Object Sender, EventArgs Args) { ColumnMeaning CMDialog = new ColumnMeaning("QuestData", Properties.Resources.CM_QD); CMDialog.Show(); } #endregion #region Open SHNs private void OpenSHNs_SelectedIndexChanged(Object Sender, EventArgs Args) { if (OpenSHNs.Items.Count >= 1) { if (SHNIsClosing) { OpenSHNs.SelectedIndex = 0; SHNIsClosing = false; } if (OpenSHNs.Items.Count >= 2) { if (SHNF.ContainsKey(LastSelectedSHNID)) { SHNF.Remove(LastSelectedSHNID); } if (SHNFWT.ContainsKey(LastSelectedSHNID)) { SHNFWT.Remove(LastSelectedSHNID); } if (SHNSR.ContainsKey(LastSelectedSHNID)) { SHNSR.Remove(LastSelectedSHNID); } if (SHNSC.ContainsKey(LastSelectedSHNID)) { SHNSC.Remove(LastSelectedSHNID); } if (SHNFDR.ContainsKey(LastSelectedSHNID)) { SHNFDR.Remove(LastSelectedSHNID); } if (SHNHSO.ContainsKey(LastSelectedSHNID)) { SHNHSO.Remove(LastSelectedSHNID); } if (SHNVC.ContainsKey(LastSelectedSHNID)) { SHNVC.Remove(LastSelectedSHNID); } if (SHNCW.ContainsKey(LastSelectedSHNID)) { SHNCW.Remove(LastSelectedSHNID); } //if (SHNCC.ContainsKey(LastSelectedSHNID)) { SHNCC.Remove(LastSelectedSHNID); } SHNF.Add(LastSelectedSHNID, new Object[] { SHNFilter_Text.Text, SHNFilter_In.SelectedIndex, SHNFilter_SW.Checked, SHNFilter_EW.Checked, SHNFilter_C.Checked, SHNFilter_E.Checked, SHNMFU }); SHNFWT.Add(LastSelectedSHNID, new Object[] { SHNFWT_Lines.Text, SHNFWT_Column.SelectedIndex, SHNFWTU }); List SelectedRowIDs = new List(); Dictionary> SelectedCellIDs = new Dictionary>(); foreach (DataGridViewRow Row in SHN_Grid.SelectedRows.Cast().OrderBy(Index => Index.Index)) { SelectedRowIDs.Add(Row.Index); } foreach (DataGridViewCell Cell in SHN_Grid.SelectedCells.Cast().OrderBy(Index => Index.RowIndex)) { if (!SelectedCellIDs.ContainsKey(Cell.ColumnIndex)) { SelectedCellIDs.Add(Cell.ColumnIndex, new List()); } SelectedCellIDs[Cell.ColumnIndex].Add(Cell.RowIndex); } SHNSR.Add(LastSelectedSHNID, SelectedRowIDs.ToArray()); SHNSC.Add(LastSelectedSHNID, SelectedCellIDs); SHNFDR.Add(LastSelectedSHNID, SHN_Grid.FirstDisplayedScrollingRowIndex); SHNHSO.Add(LastSelectedSHNID, SHN_Grid.HorizontalScrollingOffset); List CheckedColumns = new List(); foreach (String BoxText in SHNVC_CB.Items) { if (SHNVC_CB.GetItemCheckState(SHNVC_CB.Items.IndexOf(BoxText)) == CheckState.Checked) { CheckedColumns.Add(true); } else if (SHNVC_CB.GetItemCheckState(SHNVC_CB.Items.IndexOf(BoxText)) == CheckState.Unchecked) { CheckedColumns.Add(false); } } SHNVC.Add(LastSelectedSHNID, CheckedColumns); SHNCW.Add(LastSelectedSHNID, new Dictionary()); foreach (DataGridViewColumn Column in SHN_Grid.Columns) { SHNCW[LastSelectedSHNID].Add(Column.Index, Column.Width); } //SHNCC.Add(LastSelectedSHNID, new Dictionary>()); //foreach (DataGridViewRow Row in SHN_Grid.Rows) //{ // foreach (DataGridViewCell Cell in Row.Cells.Cast().Where(BackColor => BackColor.Style.BackColor != Color.White)) // { // if (!SHNCC[LastSelectedSHNID].ContainsKey(Cell.ColumnIndex)) { SHNCC[LastSelectedSHNID].Add(Cell.ColumnIndex, new Dictionary()); } // SHNCC[LastSelectedSHNID][Cell.ColumnIndex].Add(Cell.RowIndex, Cell.Style.BackColor); // } //} } LastSelectedSHNID = SelectedSHNID; SHNFTrigger = false; SHNFilter_Text.Text = ""; SHNFTrigger = true; SHN_Grid.DataSource = null; SHN_Grid.DataSource = SelectedSHN.Table; SHNFilter_In.Items.Clear(); SHNR_In.Items.Clear(); SHNCME_In.Items.Clear(); SHNFWT_Column.Items.Clear(); SHNRO_Column.Items.Clear(); SHNVC_CB.Items.Clear(); SHNVCTrigger = false; foreach (DataColumn Column in SelectedSHN.Table.Columns) { SHNFilter_In.Items.Add(Column.ColumnName); SHNR_In.Items.Add(Column.ColumnName); SHNCME_In.Items.Add(Column.ColumnName); SHNFWT_Column.Items.Add(Column.ColumnName); SHNRO_Column.Items.Add(Column.ColumnName); SHNVC_CB.Items.Add(Column.ColumnName, true); } SHNVCTrigger = true; SHNFilter_Reset_Click(null, null); SHNR_Reset_Click(null, null); SHNCME_Reset_Click(null, null); SHNFWT_Reset_Click(null, null); SHNRO_Reset_Click(null, null); SetSHNType(SelectedSHN.Type); SetSHNColumnCount(SelectedSHN.Table.Columns.Count); SetSHNRowCount(SelectedSHN.Table.Rows.Count); SetSHNHandleID(SelectedSHNID); if (SHNIVS.Checked) { if (SelectedSHN.Type == SHNType.ItemViewInfo) { SHNIV_Panel.Visible = true; } else { SHNIV_Panel.Visible = false; } } if (OpenSHNs.Items.Count >= 2) { if (SHNF.ContainsKey(SelectedSHNID)) { if (!Convert.ToBoolean(SHNF[SelectedSHNID][6])) { SHNFTrigger = false; } SHNFilter_Text.Text = Convert.ToString(SHNF[SelectedSHNID][0]); SHNFilter_In.SelectedIndex = Convert.ToInt32(SHNF[SelectedSHNID][1]); SHNFilter_SW.Checked = Convert.ToBoolean(SHNF[SelectedSHNID][2]); SHNFilter_EW.Checked = Convert.ToBoolean(SHNF[SelectedSHNID][3]); SHNFilter_C.Checked = Convert.ToBoolean(SHNF[SelectedSHNID][4]); SHNFilter_E.Checked = Convert.ToBoolean(SHNF[SelectedSHNID][5]); SHNFTrigger = true; } if (SHNFWT.ContainsKey(SelectedSHNID) && Convert.ToString(SHNFWT[SelectedSHNID][0]) != String.Empty) { SHNFWT_Lines.Text = Convert.ToString(SHNFWT[SelectedSHNID][0]); SHNFWT_Column.SelectedIndex = Convert.ToInt32(SHNFWT[SelectedSHNID][1]); if (Convert.ToBoolean(SHNFWT[SelectedSHNID][2])) { SHNFWT_Go_Click(null, null); } } if (SHNSR.ContainsKey(SelectedSHNID)) { foreach (Int32 RowIndex in SHNSR[SelectedSHNID]) { SHN_Grid.Rows[RowIndex].Selected = true; } } if (SHNSC.ContainsKey(SelectedSHNID)) { foreach (Int32 ColumnIndex in SHNSC[SelectedSHNID].Keys) { foreach (Int32 RowIndex in SHNSC[SelectedSHNID][ColumnIndex]) { SHN_Grid.Rows[RowIndex].Cells[ColumnIndex].Selected = true; } } } if (SHNFDR.ContainsKey(SelectedSHNID)) { try { SHN_Grid.FirstDisplayedScrollingRowIndex = SHNFDR[SelectedSHNID]; } catch { } SHN_Grid.HorizontalScrollingOffset = SHNHSO[SelectedSHNID]; } } if (SelectedSHN.Type == SHNType.QuestDialog || SelectedSHN.Type == SHNType.ItemViewInfo || SelectedSHN.Type == SHNType.ActiveSkillView || SelectedSHN.Type == SHNType.CollectCardView || SelectedSHN.Type == SHNType.AbStateView || SelectedSHN.Type == SHNType.PassiveSkillView || SelectedSHN.Type == SHNType.ItemShopView || SelectedSHN.Type == SHNType.NpcDialogData || SelectedSHN.Type == SHNType.QuestData) { SHNDE_BP.Visible = true; } else { SHNDE_BP.Visible = false; } foreach (DataGridViewColumn Column in SHN_Grid.Columns) { Column.SortMode = DataGridViewColumnSortMode.Programmatic; } Int32 IndexCounter = 0; if (SHNVC.ContainsKey(SelectedSHNID)) { foreach (Boolean BoxValue in SHNVC[SelectedSHNID]) { SHNVC_CB.SetItemChecked(IndexCounter, SHNVC[SelectedSHNID][IndexCounter]); IndexCounter++; } } if (SHNCW.ContainsKey(SelectedSHNID)) { foreach (Int32 ColumnID in SHNCW[SelectedSHNID].Keys) { SHN_Grid.Columns[ColumnID].Width = SHNCW[SelectedSHNID][ColumnID]; } } if (SelectedSHN.Type == SHNType.QuestData) { MethodInfo CryptoMethod = CSFile.LoadCode("C:\\SHNCrypto.cs", "SHN.SHNCrypto", SHNCrypt_List.SelectedItem.ToString()); if (File.Exists(SelectedSHN.LoadPath.Replace(Path.GetFileName(SelectedSHN.LoadPath), "QuestDialog.shn"))) { QuestDialogSHN = new SHNFile(SelectedSHN.LoadPath.Replace(Path.GetFileName(SelectedSHN.LoadPath), "QuestDialog.shn"), CryptoMethod); if (QuestDialogSHN.Type == SHNType.TextData) { QuestDialogSHN.SHNEncoding = Encoding.ASCII; } else { QuestDialogSHN.SHNEncoding = Encoding.GetEncoding("ISO-8859-1"); } if (QuestDialogSHN.Type != SHNType.QuestData) { QuestDialogSHN.Read(); } else { QuestDialogSHN.ReadQuest(); } try { SHNQ_TV.Text = QuestDialogSHN.Table.Rows.Cast().Where(ItemArray => ItemArray.ItemArray[0].ToString() == SHN_Grid.Rows[0].Cells[1].Value.ToString()).FirstOrDefault().ItemArray[1].ToString(); } catch { SHNQ_TV.Text = "TITLE NOT FOUND"; } try { SHNQ_DV.Text = QuestDialogSHN.Table.Rows.Cast().Where(ItemArray => ItemArray.ItemArray[0].ToString() == SHN_Grid.Rows[0].Cells[2].Value.ToString()).FirstOrDefault().ItemArray[1].ToString(); } catch { SHNQ_DV.Text = "DESCRIPTION NOT FOUND"; } } else { QuestDialogSHN = null; } if (File.Exists(SelectedSHN.LoadPath.Replace(Path.GetFileName(SelectedSHN.LoadPath), "MobInfo.shn"))) { MobInfoSHN = new SHNFile(SelectedSHN.LoadPath.Replace(Path.GetFileName(SelectedSHN.LoadPath), "MobInfo.shn"), CryptoMethod); if (MobInfoSHN.Type == SHNType.TextData) { MobInfoSHN.SHNEncoding = Encoding.ASCII; } else { MobInfoSHN.SHNEncoding = Encoding.GetEncoding("ISO-8859-1"); } if (MobInfoSHN.Type != SHNType.QuestData) { MobInfoSHN.Read(); } else { MobInfoSHN.ReadQuest(); } String MobName0 = String.Empty, MobName1 = String.Empty, MobName2 = String.Empty, MobName3 = String.Empty, MobName4 = String.Empty; if (SelectedSHN.QuestHeader == 4) { try { MobName0 = String.Concat("Mob 0: ", MobInfoSHN.Table.Rows.Cast().Where(ItemArray => ItemArray.ItemArray[0].ToString() == SHN_Grid.Rows[0].Cells[20].Value.ToString()).FirstOrDefault().ItemArray[2].ToString()); } catch { MobName0 = "Mob 0: NOT FOUND"; } try { MobName1 = String.Concat("Mob 1: ", MobInfoSHN.Table.Rows.Cast().Where(ItemArray => ItemArray.ItemArray[0].ToString() == SHN_Grid.Rows[0].Cells[25].Value.ToString()).FirstOrDefault().ItemArray[2].ToString()); } catch { MobName1 = "Mob 1: NOT FOUND"; } try { MobName2 = String.Concat("Mob 2: ", MobInfoSHN.Table.Rows.Cast().Where(ItemArray => ItemArray.ItemArray[0].ToString() == SHN_Grid.Rows[0].Cells[30].Value.ToString()).FirstOrDefault().ItemArray[2].ToString()); } catch { MobName2 = "Mob 2: NOT FOUND"; } try { MobName3 = String.Concat("Mob 3: ", MobInfoSHN.Table.Rows.Cast().Where(ItemArray => ItemArray.ItemArray[0].ToString() == SHN_Grid.Rows[0].Cells[35].Value.ToString()).FirstOrDefault().ItemArray[2].ToString()); } catch { MobName3 = "Mob 3: NOT FOUND"; } try { MobName4 = String.Concat("Mob 4: ", MobInfoSHN.Table.Rows.Cast().Where(ItemArray => ItemArray.ItemArray[0].ToString() == SHN_Grid.Rows[0].Cells[40].Value.ToString()).FirstOrDefault().ItemArray[2].ToString()); } catch { MobName4 = "Mob 4: NOT FOUND"; } } else if (SelectedSHN.QuestHeader == 6) { try { MobName0 = String.Concat("Mob 0: ", MobInfoSHN.Table.Rows.Cast().Where(ItemArray => ItemArray.ItemArray[0].ToString() == SHN_Grid.Rows[0].Cells[23].Value.ToString()).FirstOrDefault().ItemArray[2].ToString()); } catch { MobName0 = "Mob 0: NOT FOUND"; } try { MobName1 = String.Concat("Mob 1: ", MobInfoSHN.Table.Rows.Cast().Where(ItemArray => ItemArray.ItemArray[0].ToString() == SHN_Grid.Rows[0].Cells[30].Value.ToString()).FirstOrDefault().ItemArray[2].ToString()); } catch { MobName1 = "Mob 1: NOT FOUND"; } try { MobName2 = String.Concat("Mob 2: ", MobInfoSHN.Table.Rows.Cast().Where(ItemArray => ItemArray.ItemArray[0].ToString() == SHN_Grid.Rows[0].Cells[47].Value.ToString()).FirstOrDefault().ItemArray[2].ToString()); } catch { MobName2 = "Mob 2: NOT FOUND"; } try { MobName3 = String.Concat("Mob 3: ", MobInfoSHN.Table.Rows.Cast().Where(ItemArray => ItemArray.ItemArray[0].ToString() == SHN_Grid.Rows[0].Cells[44].Value.ToString()).FirstOrDefault().ItemArray[2].ToString()); } catch { MobName3 = "Mob 3: NOT FOUND"; } try { MobName4 = String.Concat("Mob 4: ", MobInfoSHN.Table.Rows.Cast().Where(ItemArray => ItemArray.ItemArray[0].ToString() == SHN_Grid.Rows[0].Cells[51].Value.ToString()).FirstOrDefault().ItemArray[2].ToString()); } catch { MobName4 = "Mob 4: NOT FOUND"; } } SHNQ_MN.Lines = new String[] { MobName0, MobName1, MobName2, MobName3, MobName4 }; } else { MobInfoSHN = null; } if (File.Exists(SelectedSHN.LoadPath.Replace(Path.GetFileName(SelectedSHN.LoadPath), "ItemInfo.shn"))) { ItemInfoSHN = new SHNFile(SelectedSHN.LoadPath.Replace(Path.GetFileName(SelectedSHN.LoadPath), "ItemInfo.shn"), CryptoMethod); if (ItemInfoSHN.Type == SHNType.TextData) { ItemInfoSHN.SHNEncoding = Encoding.ASCII; } else { ItemInfoSHN.SHNEncoding = Encoding.GetEncoding("ISO-8859-1"); } if (ItemInfoSHN.Type != SHNType.QuestData) { ItemInfoSHN.Read(); } else { ItemInfoSHN.ReadQuest(); } String ItemName0 = String.Empty, ItemName1 = String.Empty, ItemName2 = String.Empty, ItemName3 = String.Empty, ItemName4 = String.Empty, ItemName5 = String.Empty, ItemName6 = String.Empty, ItemName7 = String.Empty, ItemName8 = String.Empty, ItemName9 = String.Empty; String RewardName0 = String.Empty, RewardName1 = String.Empty, RewardName2 = String.Empty, RewardName3 = String.Empty, RewardName4 = String.Empty, RewardName5 = String.Empty, RewardName6 = String.Empty, RewardName7 = String.Empty, RewardName8 = String.Empty, RewardName9 = String.Empty, RewardName10 = String.Empty, RewardName11 = String.Empty; if (SelectedSHN.QuestHeader == 4) { try { ItemName0 = String.Concat("Item 0: ", ItemInfoSHN.Table.Rows.Cast().Where(ItemArray => ItemArray.ItemArray[0].ToString() == SHN_Grid.Rows[0].Cells[45].Value.ToString()).FirstOrDefault().ItemArray[2].ToString()); } catch { ItemName0 = "Item 0: NOT FOUND"; } try { ItemName1 = String.Concat("Item 1: ", ItemInfoSHN.Table.Rows.Cast().Where(ItemArray => ItemArray.ItemArray[0].ToString() == SHN_Grid.Rows[0].Cells[49].Value.ToString()).FirstOrDefault().ItemArray[2].ToString()); } catch { ItemName1 = "Item 1: NOT FOUND"; } try { ItemName2 = String.Concat("Item 2: ", ItemInfoSHN.Table.Rows.Cast().Where(ItemArray => ItemArray.ItemArray[0].ToString() == SHN_Grid.Rows[0].Cells[53].Value.ToString()).FirstOrDefault().ItemArray[2].ToString()); } catch { ItemName2 = "Item 2: NOT FOUND"; } try { ItemName3 = String.Concat("Item 3: ", ItemInfoSHN.Table.Rows.Cast().Where(ItemArray => ItemArray.ItemArray[0].ToString() == SHN_Grid.Rows[0].Cells[57].Value.ToString()).FirstOrDefault().ItemArray[2].ToString()); } catch { ItemName3 = "Item 3: NOT FOUND"; } try { ItemName4 = String.Concat("Item 4: ", ItemInfoSHN.Table.Rows.Cast().Where(ItemArray => ItemArray.ItemArray[0].ToString() == SHN_Grid.Rows[0].Cells[61].Value.ToString()).FirstOrDefault().ItemArray[2].ToString()); } catch { ItemName4 = "Item 4: NOT FOUND"; } try { ItemName5 = String.Concat("Item 5: ", ItemInfoSHN.Table.Rows.Cast().Where(ItemArray => ItemArray.ItemArray[0].ToString() == SHN_Grid.Rows[0].Cells[65].Value.ToString()).FirstOrDefault().ItemArray[2].ToString()); } catch { ItemName5 = "Item 5: NOT FOUND"; } try { ItemName6 = String.Concat("Item 6: ", ItemInfoSHN.Table.Rows.Cast().Where(ItemArray => ItemArray.ItemArray[0].ToString() == SHN_Grid.Rows[0].Cells[69].Value.ToString()).FirstOrDefault().ItemArray[2].ToString()); } catch { ItemName6 = "Item 6: NOT FOUND"; } try { ItemName7 = String.Concat("Item 7: ", ItemInfoSHN.Table.Rows.Cast().Where(ItemArray => ItemArray.ItemArray[0].ToString() == SHN_Grid.Rows[0].Cells[73].Value.ToString()).FirstOrDefault().ItemArray[2].ToString()); } catch { ItemName7 = "Item 7: NOT FOUND"; } try { ItemName8 = String.Concat("Item 8: ", ItemInfoSHN.Table.Rows.Cast().Where(ItemArray => ItemArray.ItemArray[0].ToString() == SHN_Grid.Rows[0].Cells[77].Value.ToString()).FirstOrDefault().ItemArray[2].ToString()); } catch { ItemName8 = "Item 8: NOT FOUND"; } try { ItemName9 = String.Concat("Item 9: ", ItemInfoSHN.Table.Rows.Cast().Where(ItemArray => ItemArray.ItemArray[0].ToString() == SHN_Grid.Rows[0].Cells[81].Value.ToString()).FirstOrDefault().ItemArray[2].ToString()); } catch { ItemName9 = "Item 9: NOT FOUND"; } try { RewardName0 = String.Concat("Reward 0: ", ItemInfoSHN.Table.Rows.Cast().Where(ItemArray => ItemArray.ItemArray[0].ToString() == SHN_Grid.Rows[0].Cells[157].Value.ToString()).FirstOrDefault().ItemArray[2].ToString()); } catch { RewardName0 = "Reward 0: NOT FOUND"; } try { RewardName1 = String.Concat("Reward 1: ", ItemInfoSHN.Table.Rows.Cast().Where(ItemArray => ItemArray.ItemArray[0].ToString() == SHN_Grid.Rows[0].Cells[163].Value.ToString()).FirstOrDefault().ItemArray[2].ToString()); } catch { RewardName1 = "Reward 1: NOT FOUND"; } try { RewardName2 = String.Concat("Reward 2: ", ItemInfoSHN.Table.Rows.Cast().Where(ItemArray => ItemArray.ItemArray[0].ToString() == SHN_Grid.Rows[0].Cells[169].Value.ToString()).FirstOrDefault().ItemArray[2].ToString()); } catch { RewardName2 = "Reward 2: NOT FOUND"; } try { RewardName3 = String.Concat("Reward 3: ", ItemInfoSHN.Table.Rows.Cast().Where(ItemArray => ItemArray.ItemArray[0].ToString() == SHN_Grid.Rows[0].Cells[175].Value.ToString()).FirstOrDefault().ItemArray[2].ToString()); } catch { RewardName3 = "Reward 3: NOT FOUND"; } try { RewardName4 = String.Concat("Reward 4: ", ItemInfoSHN.Table.Rows.Cast().Where(ItemArray => ItemArray.ItemArray[0].ToString() == SHN_Grid.Rows[0].Cells[181].Value.ToString()).FirstOrDefault().ItemArray[2].ToString()); } catch { RewardName4 = "Reward 4: NOT FOUND"; } try { RewardName5 = String.Concat("Reward 5: ", ItemInfoSHN.Table.Rows.Cast().Where(ItemArray => ItemArray.ItemArray[0].ToString() == SHN_Grid.Rows[0].Cells[187].Value.ToString()).FirstOrDefault().ItemArray[2].ToString()); } catch { RewardName5 = "Reward 5: NOT FOUND"; } try { RewardName6 = String.Concat("Reward 6: ", ItemInfoSHN.Table.Rows.Cast().Where(ItemArray => ItemArray.ItemArray[0].ToString() == SHN_Grid.Rows[0].Cells[193].Value.ToString()).FirstOrDefault().ItemArray[2].ToString()); } catch { RewardName6 = "Reward 6: NOT FOUND"; } try { RewardName7 = String.Concat("Reward 7: ", ItemInfoSHN.Table.Rows.Cast().Where(ItemArray => ItemArray.ItemArray[0].ToString() == SHN_Grid.Rows[0].Cells[199].Value.ToString()).FirstOrDefault().ItemArray[2].ToString()); } catch { RewardName7 = "Reward 7: NOT FOUND"; } try { RewardName8 = String.Concat("Reward 8: ", ItemInfoSHN.Table.Rows.Cast().Where(ItemArray => ItemArray.ItemArray[0].ToString() == SHN_Grid.Rows[0].Cells[205].Value.ToString()).FirstOrDefault().ItemArray[2].ToString()); } catch { RewardName8 = "Reward 8: NOT FOUND"; } try { RewardName9 = String.Concat("Reward 9: ", ItemInfoSHN.Table.Rows.Cast().Where(ItemArray => ItemArray.ItemArray[0].ToString() == SHN_Grid.Rows[0].Cells[211].Value.ToString()).FirstOrDefault().ItemArray[2].ToString()); } catch { RewardName9 = "Reward 9: NOT FOUND"; } try { RewardName10 = String.Concat("Reward 10: ", ItemInfoSHN.Table.Rows.Cast().Where(ItemArray => ItemArray.ItemArray[0].ToString() == SHN_Grid.Rows[0].Cells[217].Value.ToString()).FirstOrDefault().ItemArray[2].ToString()); } catch { RewardName10 = "Reward 10: NOT FOUND"; } try { RewardName11 = String.Concat("Reward 11: ", ItemInfoSHN.Table.Rows.Cast().Where(ItemArray => ItemArray.ItemArray[0].ToString() == SHN_Grid.Rows[0].Cells[223].Value.ToString()).FirstOrDefault().ItemArray[2].ToString()); } catch { RewardName11 = "Reward 11: NOT FOUND"; } } else if (SelectedSHN.QuestHeader == 6) { try { ItemName0 = String.Concat("Item 0: ", ItemInfoSHN.Table.Rows.Cast().Where(ItemArray => ItemArray.ItemArray[0].ToString() == SHN_Grid.Rows[0].Cells[58].Value.ToString()).FirstOrDefault().ItemArray[2].ToString()); } catch { ItemName0 = "Item 0: NOT FOUND"; } try { ItemName1 = String.Concat("Item 1: ", ItemInfoSHN.Table.Rows.Cast().Where(ItemArray => ItemArray.ItemArray[0].ToString() == SHN_Grid.Rows[0].Cells[62].Value.ToString()).FirstOrDefault().ItemArray[2].ToString()); } catch { ItemName1 = "Item 1: NOT FOUND"; } try { ItemName2 = String.Concat("Item 2: ", ItemInfoSHN.Table.Rows.Cast().Where(ItemArray => ItemArray.ItemArray[0].ToString() == SHN_Grid.Rows[0].Cells[66].Value.ToString()).FirstOrDefault().ItemArray[2].ToString()); } catch { ItemName2 = "Item 2: NOT FOUND"; } try { ItemName3 = String.Concat("Item 3: ", ItemInfoSHN.Table.Rows.Cast().Where(ItemArray => ItemArray.ItemArray[0].ToString() == SHN_Grid.Rows[0].Cells[70].Value.ToString()).FirstOrDefault().ItemArray[2].ToString()); } catch { ItemName3 = "Item 3: NOT FOUND"; } try { ItemName4 = String.Concat("Item 4: ", ItemInfoSHN.Table.Rows.Cast().Where(ItemArray => ItemArray.ItemArray[0].ToString() == SHN_Grid.Rows[0].Cells[74].Value.ToString()).FirstOrDefault().ItemArray[2].ToString()); } catch { ItemName4 = "Item 4: NOT FOUND"; } try { ItemName5 = String.Concat("Item 5: ", ItemInfoSHN.Table.Rows.Cast().Where(ItemArray => ItemArray.ItemArray[0].ToString() == SHN_Grid.Rows[0].Cells[78].Value.ToString()).FirstOrDefault().ItemArray[2].ToString()); } catch { ItemName5 = "Item 5: NOT FOUND"; } try { ItemName6 = String.Concat("Item 6: ", ItemInfoSHN.Table.Rows.Cast().Where(ItemArray => ItemArray.ItemArray[0].ToString() == SHN_Grid.Rows[0].Cells[82].Value.ToString()).FirstOrDefault().ItemArray[2].ToString()); } catch { ItemName6 = "Item 6: NOT FOUND"; } try { ItemName7 = String.Concat("Item 7: ", ItemInfoSHN.Table.Rows.Cast().Where(ItemArray => ItemArray.ItemArray[0].ToString() == SHN_Grid.Rows[0].Cells[86].Value.ToString()).FirstOrDefault().ItemArray[2].ToString()); } catch { ItemName7 = "Item 7: NOT FOUND"; } try { ItemName8 = String.Concat("Item 8: ", ItemInfoSHN.Table.Rows.Cast().Where(ItemArray => ItemArray.ItemArray[0].ToString() == SHN_Grid.Rows[0].Cells[90].Value.ToString()).FirstOrDefault().ItemArray[2].ToString()); } catch { ItemName8 = "Item 8: NOT FOUND"; } try { ItemName9 = String.Concat("Item 9: ", ItemInfoSHN.Table.Rows.Cast().Where(ItemArray => ItemArray.ItemArray[0].ToString() == SHN_Grid.Rows[0].Cells[94].Value.ToString()).FirstOrDefault().ItemArray[2].ToString()); } catch { ItemName9 = "Item 9: NOT FOUND"; } try { RewardName0 = String.Concat("Reward 0: ", ItemInfoSHN.Table.Rows.Cast().Where(ItemArray => ItemArray.ItemArray[0].ToString() == SHN_Grid.Rows[0].Cells[170].Value.ToString()).FirstOrDefault().ItemArray[2].ToString()); } catch { RewardName0 = "Reward 0: NOT FOUND"; } try { RewardName1 = String.Concat("Reward 1: ", ItemInfoSHN.Table.Rows.Cast().Where(ItemArray => ItemArray.ItemArray[0].ToString() == SHN_Grid.Rows[0].Cells[176].Value.ToString()).FirstOrDefault().ItemArray[2].ToString()); } catch { RewardName1 = "Reward 1: NOT FOUND"; } try { RewardName2 = String.Concat("Reward 2: ", ItemInfoSHN.Table.Rows.Cast().Where(ItemArray => ItemArray.ItemArray[0].ToString() == SHN_Grid.Rows[0].Cells[182].Value.ToString()).FirstOrDefault().ItemArray[2].ToString()); } catch { RewardName2 = "Reward 2: NOT FOUND"; } try { RewardName3 = String.Concat("Reward 3: ", ItemInfoSHN.Table.Rows.Cast().Where(ItemArray => ItemArray.ItemArray[0].ToString() == SHN_Grid.Rows[0].Cells[186].Value.ToString()).FirstOrDefault().ItemArray[2].ToString()); } catch { RewardName3 = "Reward 3: NOT FOUND"; } try { RewardName4 = String.Concat("Reward 4: ", ItemInfoSHN.Table.Rows.Cast().Where(ItemArray => ItemArray.ItemArray[0].ToString() == SHN_Grid.Rows[0].Cells[192].Value.ToString()).FirstOrDefault().ItemArray[2].ToString()); } catch { RewardName4 = "Reward 4: NOT FOUND"; } try { RewardName5 = String.Concat("Reward 5: ", ItemInfoSHN.Table.Rows.Cast().Where(ItemArray => ItemArray.ItemArray[0].ToString() == SHN_Grid.Rows[0].Cells[198].Value.ToString()).FirstOrDefault().ItemArray[2].ToString()); } catch { RewardName5 = "Reward 5: NOT FOUND"; } try { RewardName6 = String.Concat("Reward 6: ", ItemInfoSHN.Table.Rows.Cast().Where(ItemArray => ItemArray.ItemArray[0].ToString() == SHN_Grid.Rows[0].Cells[204].Value.ToString()).FirstOrDefault().ItemArray[2].ToString()); } catch { RewardName6 = "Reward 6: NOT FOUND"; } try { RewardName7 = String.Concat("Reward 7: ", ItemInfoSHN.Table.Rows.Cast().Where(ItemArray => ItemArray.ItemArray[0].ToString() == SHN_Grid.Rows[0].Cells[210].Value.ToString()).FirstOrDefault().ItemArray[2].ToString()); } catch { RewardName7 = "Reward 7: NOT FOUND"; } try { RewardName8 = String.Concat("Reward 8: ", ItemInfoSHN.Table.Rows.Cast().Where(ItemArray => ItemArray.ItemArray[0].ToString() == SHN_Grid.Rows[0].Cells[216].Value.ToString()).FirstOrDefault().ItemArray[2].ToString()); } catch { RewardName8 = "Reward 8: NOT FOUND"; } try { RewardName9 = String.Concat("Reward 9: ", ItemInfoSHN.Table.Rows.Cast().Where(ItemArray => ItemArray.ItemArray[0].ToString() == SHN_Grid.Rows[0].Cells[222].Value.ToString()).FirstOrDefault().ItemArray[2].ToString()); } catch { RewardName9 = "Reward 9: NOT FOUND"; } try { RewardName10 = String.Concat("Reward 10: ", ItemInfoSHN.Table.Rows.Cast().Where(ItemArray => ItemArray.ItemArray[0].ToString() == SHN_Grid.Rows[0].Cells[228].Value.ToString()).FirstOrDefault().ItemArray[2].ToString()); } catch { RewardName10 = "Reward 10: NOT FOUND"; } try { RewardName11 = String.Concat("Reward 11: ", ItemInfoSHN.Table.Rows.Cast().Where(ItemArray => ItemArray.ItemArray[0].ToString() == SHN_Grid.Rows[0].Cells[234].Value.ToString()).FirstOrDefault().ItemArray[2].ToString()); } catch { RewardName11 = "Reward 11: NOT FOUND"; } } SHNQ_IN.Lines = new String[] { ItemName0, ItemName1, ItemName2, ItemName3, ItemName4, ItemName5, ItemName6, ItemName7, ItemName8, ItemName9 }; SHNQ_RN.Lines = new String[] { RewardName0, RewardName1, RewardName2, RewardName3, RewardName4, RewardName5, RewardName6, RewardName7, RewardName8, RewardName9, RewardName10, RewardName11 }; } } if (SelectedSHN.Type == SHNType.QuestData) { if (SHN_ST.Checked) { SHN_ST_Click(null, null); } if (SHN_ST2.Checked) { SHN_ST2_Click(null, null); } if (!SHN_STQ.Checked) { SHN_STQ_Click(null, null); } } else { if (!SHN_ST.Checked) { SHN_ST_Click(null, null); } if (SHN_STQ.Checked) { SHN_STQ_Click(null, null); } } SHNRI.Text = "SHN Row Index: 0"; SHNCI.Text = "SHN Column Index: 0"; //foreach(Int32 ColumnID in SHNCC[SelectedSHNID].Keys) //{ // foreach (Int32 RowID in SHNCC[SelectedSHNID][ColumnID].Keys) { SHN_Grid.Rows[RowID].Cells[ColumnID].Style.BackColor = SHNCC[SelectedSHNID][ColumnID][RowID]; } //} } else { SHN_Grid.DataSource = null; } } #endregion #region Open STs private void OpenShineTables_SelectedIndexChanged(Object Sender, EventArgs Args) { if (OpenShineTables.Items.Count >= 1) { if (STIsClosing) { OpenShineTables.SelectedIndex = 0; STIsClosing = false; } if (STDTES.Checked) { ST_Grid.DataSource = null; if (SelectedST.Tables[0].Source.TableName.StartsWith("ItemGroup")) { STDTM_Panel.Visible = true; } else { STDTM_Panel.Visible = false; } } STIsOpening = true; STFilter_Text.Text = ""; ST_Grid.DataSource = SelectedST.Tables[0].Source; STFilter_In.Items.Clear(); STR_In.Items.Clear(); STCME_In.Items.Clear(); STFWT_Column.Items.Clear(); ShineTables_T.Items.Clear(); STRO_Column.Items.Clear(); STVC_CB.Items.Clear(); foreach (DataColumn Column in SelectedST.Tables[0].Source.Columns) { STFilter_In.Items.Add(Column.ColumnName); STR_In.Items.Add(Column.ColumnName); STCME_In.Items.Add(Column.ColumnName); STFWT_Column.Items.Add(Column.ColumnName); STRO_Column.Items.Add(Column.ColumnName); STVC_CB.Items.Add(Column.ColumnName, true); } foreach (Table STTable in SelectedST.Tables) { ShineTables_T.Items.Add(STTable.Source.TableName); } ShineTables_T.SelectedIndex = 0; STFilter_Reset_Click(null, null); STR_Reset_Click(null, null); STCME_Reset_Click(null, null); STFWT_Reset_Click(null, null); STRO_Reset_Click(null, null); SetSTType(SHNType.Unknown); SetSTColumnCount(SelectedST.Tables[0].Source.Columns.Count); SetSTTablesCount(SelectedST.Tables.Count); SetSTRowCount(SelectedST.Tables[0].Source.Rows.Count); SetSTHandleID(SelectedSTID); STIsOpening = false; } else { ST_Grid.DataSource = null; } } private void ShineTables_T_SelectedIndexChanged(Object Sender, EventArgs Args) { if (ShineTables_T.Items.Count == 0) { return; } else if (STIsOpening) { return; } STFilter_Text.Text = ""; ST_Grid.DataSource = null; ST_Grid.DataSource = SelectedST.Tables[ShineTables_T.SelectedIndex].Source; STFilter_In.Items.Clear(); STR_In.Items.Clear(); STCME_In.Items.Clear(); STFWT_Column.Items.Clear(); STRO_Column.Items.Clear(); STVC_CB.Items.Clear(); foreach (DataColumn Column in SelectedST.Tables[ShineTables_T.SelectedIndex].Source.Columns) { STFilter_In.Items.Add(Column.ColumnName); STR_In.Items.Add(Column.ColumnName); STCME_In.Items.Add(Column.ColumnName); STFWT_Column.Items.Add(Column.ColumnName); STRO_Column.Items.Add(Column.ColumnName); STVC_CB.Items.Add(Column.ColumnName, true); } STFilter_Reset_Click(null, null); STR_Reset_Click(null, null); STCME_Reset_Click(null, null); STFWT_Reset_Click(null, null); STRO_Reset_Click(null, null); SetSTType(SHNType.Unknown); SetSTColumnCount(SelectedST.Tables[ShineTables_T.SelectedIndex].Source.Columns.Count); SetSTTablesCount(SelectedST.Tables.Count); SetSTRowCount(SelectedST.Tables[ShineTables_T.SelectedIndex].Source.Rows.Count); SetSTHandleID(SelectedSTID); } #endregion #region SHN Filter private void SHNFilter_Text_TextChanged(Object Sender, EventArgs Args) { if (OpenSHNsArray.Count == 0) { SetInformation(Color.Red, "No SHN file is currently open."); return; } else if (!SHNFTrigger) { return; } if (SHNFilter_SW.Checked) { SelectedSHN.Table.DefaultView.RowFilter = String.Format("Convert({0}, 'System.String') LIKE '{1}*'", SHNFilter_In.SelectedItem, SHNFilter_Text.Text); } else if (SHNFilter_EW.Checked) { SelectedSHN.Table.DefaultView.RowFilter = String.Format("Convert({0}, 'System.String') LIKE '*{1}'", SHNFilter_In.SelectedItem, SHNFilter_Text.Text); } else if (SHNFilter_C.Checked) { SelectedSHN.Table.DefaultView.RowFilter = String.Format("Convert({0}, 'System.String') LIKE '%{1}%'", SHNFilter_In.SelectedItem, SHNFilter_Text.Text); } else if (SHNFilter_E.Checked) { SelectedSHN.Table.DefaultView.RowFilter = String.Format("Convert({0}, 'System.String') = '{1}'", SHNFilter_In.SelectedItem, SHNFilter_Text.Text); } SHNMFU = true; SHNFWTU = false; } private void SHNFilter_Reset_Click(Object Sender, EventArgs Args) { if (OpenSHNsArray.Count == 0) { SetInformation(Color.Red, "No SHN file is currently open."); return; } SHNFilter_Text.Text = ""; SHNFilter_In.SelectedIndex = 0; SHNFilter_C.Checked = true; } #endregion #region ST Filter private void STFilter_Text_TextChanged(Object Sender, EventArgs Args) { if (OpenSTArray.Count == 0) { SetInformation(Color.Red, "No Shine file is currently open."); return; } if (STFilter_SW.Checked) { SelectedST.Tables[ShineTables_T.SelectedIndex].Source.DefaultView.RowFilter = String.Format("Convert({0}, 'System.String') LIKE '{1}*'", STFilter_In.SelectedItem, STFilter_Text.Text); } else if (STFilter_EW.Checked) { SelectedST.Tables[ShineTables_T.SelectedIndex].Source.DefaultView.RowFilter = String.Format("Convert({0}, 'System.String') LIKE '*{1}'", STFilter_In.SelectedItem, STFilter_Text.Text); } else if (STFilter_C.Checked) { SelectedST.Tables[ShineTables_T.SelectedIndex].Source.DefaultView.RowFilter = String.Format("Convert({0}, 'System.String') LIKE '%{1}%'", STFilter_In.SelectedItem, STFilter_Text.Text); } else if (STFilter_E.Checked) { SelectedST.Tables[ShineTables_T.SelectedIndex].Source.DefaultView.RowFilter = String.Format("Convert({0}, 'System.String') = '{1}'", STFilter_In.SelectedItem, STFilter_Text.Text); } } private void STFilter_Reset_Click(Object Sender, EventArgs Args) { if (OpenSTArray.Count == 0) { SetInformation(Color.Red, "No Shine file is currently open."); return; } STFilter_Text.Text = ""; STFilter_In.SelectedIndex = 0; STFilter_C.Checked = true; } #endregion #region SHN Information Group private void SetSHNType(SHNType Type) { SHN_Type.Text = String.Format("Type: {0}", Type); } private void SetSHNHandleID(Int32 HandleID) { SHN_HandleID.Text = String.Format("Handle ID: {0}", HandleID); } private void SetSHNColumnCount(Int32 Count) { SHN_Columns.Text = String.Format("Column Count: {0}", Count); } private void SetSHNRowCount(Int32 Count) { SHN_Rows.Text = String.Format("Row Count: {0}", Count - 1); } private void SHN_OpenPath_Click(Object Sender, EventArgs Args) { if (OpenSHNsArray.Count == 0) { SetInformation(Color.Red, "No SHN file is currently open."); return; } Process.Start(Path.GetDirectoryName(SelectedSHN.LoadPath)); SetInformation(Color.Green, String.Format("{0}'s directory has been opened.", Path.GetFileName(SelectedSHN.LoadPath))); } private void SHN_Close_Click(Object Sender, EventArgs Args) { if (OpenSHNsArray.Count == 0) { SetInformation(Color.Red, "No SHN file is currently open."); return; } SetInformation(Color.Green, String.Format("{0} has been closed.", Path.GetFileName(SelectedSHN.LoadPath))); OpenSHNsArray.Remove(SelectedSHNID); SHNIsClosing = true; OpenSHNs.Items.Remove(OpenSHNs.SelectedItem); } private void SHN_Save_Click(Object Sender, EventArgs Args) { if (OpenSHNsArray.Count == 0) { SetInformation(Color.Red, "No SHN file is currently open."); return; } SelectedSHN.Table.DefaultView.RowFilter = ""; if (SelectedSHN.Type != SHNType.QuestData) { SelectedSHN.Write(SelectedSHN.LoadPath); } else { SelectedSHN.WriteQuest(SelectedSHN.LoadPath); } SetInformation(Color.Green, String.Format("{0} has been saved.", Path.GetFileName(SelectedSHN.LoadPath))); } private void SHN_SaveAs_Click(Object Sender, EventArgs Args) { if (OpenSHNsArray.Count == 0) { SetInformation(Color.Red, "No SHN file is currently open."); return; } SaveFileDialog SHNDialog = new SaveFileDialog(); SHNDialog.Filter = "SHN Files (.shn)|*.shn"; SHNDialog.Title = "Open SHN File"; DialogResult SHNResult = SHNDialog.ShowDialog(); if (SHNResult == DialogResult.OK) { SelectedSHN.Table.DefaultView.RowFilter = ""; if (SelectedSHN.Type != SHNType.QuestData) { SelectedSHN.Write(SHNDialog.FileName); } else { SelectedSHN.WriteQuest(SHNDialog.FileName); } SetInformation(Color.Green, String.Format("{0} has been saved to {1}.", Path.GetFileName(SelectedSHN.LoadPath), SHNDialog.FileName)); } else { SetInformation(Color.Red, "No file has been saved due to cancelling the dialog."); } } private void SHN_SaveAll_Click(Object Sender, EventArgs Args) { if (OpenSHNsArray.Count == 0) { SetInformation(Color.Red, "No SHN file is currently open."); return; } String Saved = ""; foreach (SHNFile OpenSHN in OpenSHNsArray.Values) { OpenSHN.Write(OpenSHN.LoadPath); Saved += String.Format("{0}, ", Path.GetFileName(OpenSHN.LoadPath)); } Saved += "have been saved."; Information.Text = Saved; } private void SHN_ClearFilter_Click(Object Sender, EventArgs Args) { if (OpenSHNsArray.Count == 0) { SetInformation(Color.Red, "No SHN file is currently open."); return; } SHNFilter_Reset_Click(null, null); SHNR_Reset_Click(null, null); SHNCME_Reset_Click(null, null); SHNFWT_Reset_Click(null, null); SelectedSHN.Table.DefaultView.RowFilter = ""; } private void SHNF_Size_ValueChanged(Object Sender, EventArgs Args) { SHN_Grid.Font = new Font(SHN_Grid.Font.FontFamily, (float)SHNF_Size.Value); } #endregion #region SHN Replace private void SHNR_Reset_Click(Object Sender, EventArgs Args) { if (OpenSHNsArray.Count == 0) { SetInformation(Color.Red, "No SHN file is currently open."); return; } SHNR_Text.Text = ""; SHNR_In.SelectedIndex = 0; SHNR_E.Checked = true; SHNR_ST.Text = ""; SHNR_CC.Text = "-"; } private void SHNR_Go_Click(Object Sender, EventArgs Args) { if (OpenSHNsArray.Count == 0) { SetInformation(Color.Red, "No SHN file is currently open."); return; } else if (SHNR_Text.Text == String.Empty) { SetInformation(Color.Red, "Please type something before searching."); return; } Int32 CellsEdited = 0; SHNColumn Column = SelectedSHN.SHNColumns.Where(ColumnName => ColumnName.Name == SHNR_In.Text).FirstOrDefault(); foreach (DataGridViewRow Row in SHN_Grid.Rows.Cast().Where(IsVisible => IsVisible.Visible == true)) { Boolean NeedsEdit = false; if (SHNR_SW.Checked) { if (Row.Cells[Column.ID].Value.ToString().StartsWith(SHNR_Text.Text)) { NeedsEdit = true; } } else if (SHNR_EW.Checked) { if (Row.Cells[Column.ID].Value.ToString().EndsWith(SHNR_Text.Text)) { NeedsEdit = true; } } else if (SHNR_C.Checked) { if (Row.Cells[Column.ID].Value.ToString().Contains(SHNR_Text.Text)) { NeedsEdit = true; } } else if (SHNR_E.Checked) { if (Row.Cells[Column.ID].Value.ToString() == SHNR_Text.Text) { NeedsEdit = true; } } if (SHNR_IS.Checked && Row.Selected) { NeedsEdit = true; } else if (SHNR_IS.Checked) { NeedsEdit = false; } if (NeedsEdit) { Row.Cells[Column.ID].Value = Row.Cells[Column.ID].Value.ToString().Replace(SHNR_Text.Text, SHNR_ST.Text); CellsEdited++; } } SHNR_CC.Text = String.Format("Cells Edited: {0}", CellsEdited); } #endregion #region SHN CME private void SHNCME_Reset_Click(Object Sender, EventArgs Args) { if (OpenSHNsArray.Count == 0) { SetInformation(Color.Red, "No SHN file is currently open."); return; } SHNCME_Text.Text = ""; SHNCME_In.SelectedIndex = 0; SHNCME_Modifiers.SelectedIndex = 0; SHNCME_CC.Text = "-"; SHNCME_Modify.Checked = true; } private void SHNCME_Go_Click(Object Sender, EventArgs Args) { if (OpenSHNsArray.Count == 0) { SetInformation(Color.Red, "No SHN file is currently open."); return; } else if (SHNCME_Text.Text == String.Empty) { SetInformation(Color.Red, "Please type something before searching."); return; } Int32 CellsEdited = 0; SHNColumn Column = SelectedSHN.SHNColumns.Where(ColumnName => ColumnName.Name == SHNCME_In.Text).FirstOrDefault(); foreach (DataGridViewRow Row in SHN_Grid.Rows.Cast().Where(IsVisible => IsVisible.Visible == true)) { Boolean NeedModify = false; if (SHNCME_IS.Checked && Row.Selected) { NeedModify = true; } else if (!SHNCME_IS.Checked) { NeedModify = true; } if (NeedModify) { if (SHNCME_Modifiers.Text == "None") { if (SHNCME_Modify.Checked) { String NewValue = SHNCME_Text.Text; if (SHNCME_Text.Text.Contains("{") && SHNCME_Text.Text.Contains("}")) { String ColumnName = SHNCME_Text.Text.Split('{')[1].Split('}')[0]; Int32 ReplaceColumnID = SHN_Grid.Columns.Cast().Where(Name => Name.Name.ToLower() == ColumnName.ToLower()).FirstOrDefault().Index; NewValue = SHNCME_Text.Text.Replace(String.Concat("{", ColumnName, "}"), Row.Cells[ReplaceColumnID].Value.ToString()); } Row.Cells[Column.ID].Value = NewValue; } else if (SHNCME_Add.Checked) { Double NewValue = Convert.ToDouble(Row.Cells[Column.ID].Value) + Convert.ToDouble(SHNCME_Text.Text); if (NewValue.ToString().Contains('.') || NewValue.ToString().Contains(',')) { if (NewValue.ToString().Contains('.')) { NewValue = Convert.ToDouble(NewValue.ToString().Split('.')[0]); } if (NewValue.ToString().Contains(',')) { NewValue = Convert.ToDouble(NewValue.ToString().Split(',')[0]); } } Row.Cells[Column.ID].Value = NewValue; } else if (SHNCME_Subtract.Checked) { Double NewValue = Convert.ToDouble(Row.Cells[Column.ID].Value) - Convert.ToDouble(SHNCME_Text.Text); if (NewValue.ToString().Contains('.') || NewValue.ToString().Contains(',')) { if (NewValue.ToString().Contains('.')) { NewValue = Convert.ToDouble(NewValue.ToString().Split('.')[0]); } if (NewValue.ToString().Contains(',')) { NewValue = Convert.ToDouble(NewValue.ToString().Split(',')[0]); } } Row.Cells[Column.ID].Value = NewValue; } else if (SHNCME_Multiply.Checked) { Double NewValue = Convert.ToDouble(Row.Cells[Column.ID].Value) * Convert.ToDouble(SHNCME_Text.Text); if (NewValue.ToString().Contains('.') || NewValue.ToString().Contains(',')) { if (NewValue.ToString().Contains('.')) { NewValue = Convert.ToDouble(NewValue.ToString().Split('.')[0]); } if (NewValue.ToString().Contains(',')) { NewValue = Convert.ToDouble(NewValue.ToString().Split(',')[0]); } } Row.Cells[Column.ID].Value = NewValue; } else if (SHNCME_Divide.Checked) { Double NewValue = Convert.ToDouble(Row.Cells[Column.ID].Value) / Convert.ToDouble(SHNCME_Text.Text); if (NewValue.ToString().Contains('.') || NewValue.ToString().Contains(',')) { if (NewValue.ToString().Contains('.')) { NewValue = Convert.ToDouble(NewValue.ToString().Split('.')[0]); } if (NewValue.ToString().Contains(',')) { NewValue = Convert.ToDouble(NewValue.ToString().Split(',')[0]); } } Row.Cells[Column.ID].Value = NewValue; } } else if (SHNCME_Modifiers.Text == "Add at Beginning") { if (SHNCME_Modify.Checked) { String NewValue = SHNCME_Text.Text + Row.Cells[Column.ID].Value.ToString(); if (SHNCME_Text.Text.Contains("{") && SHNCME_Text.Text.Contains("}")) { String ColumnName = SHNCME_Text.Text.Split('{')[1].Split('}')[0]; Int32 ReplaceColumnID = SHN_Grid.Columns.Cast().Where(Name => Name.Name.ToLower() == ColumnName.ToLower()).FirstOrDefault().Index; NewValue = SHNCME_Text.Text.Replace(String.Concat("{", ColumnName, "}"), Row.Cells[ReplaceColumnID].Value.ToString()) + Row.Cells[Column.ID].Value.ToString(); } Row.Cells[Column.ID].Value = NewValue; } else { SetInformation(Color.Red, "You cannot use anyhing other than Modify for this modifier."); } } else if (SHNCME_Modifiers.Text == "Add at End") { if (SHNCME_Modify.Checked) { String NewValue = Row.Cells[Column.ID].Value.ToString() + SHNCME_Text.Text; if (SHNCME_Text.Text.Contains("{") && SHNCME_Text.Text.Contains("}")) { String ColumnName = SHNCME_Text.Text.Split('{')[1].Split('}')[0]; Int32 ReplaceColumnID = SHN_Grid.Columns.Cast().Where(Name => Name.Name.ToLower() == ColumnName.ToLower()).FirstOrDefault().Index; NewValue = Row.Cells[Column.ID].Value.ToString() + SHNCME_Text.Text.Replace(String.Concat("{", ColumnName, "}"), Row.Cells[ReplaceColumnID].Value.ToString()); } Row.Cells[Column.ID].Value = NewValue; } else { SetInformation(Color.Red, "You cannot use anyhing other than Modify for this modifier."); } } else if (SHNCME_Modifiers.Text == "Remove at Beginning") { if (SHNCME_Modify.Checked) { String NewValue = Row.Cells[Column.ID].Value.ToString().TrimStart(SHNCME_Text.Text.ToCharArray()); if (SHNCME_Text.Text.Contains("{") && SHNCME_Text.Text.Contains("}")) { String ColumnName = SHNCME_Text.Text.Split('{')[1].Split('}')[0]; Int32 ReplaceColumnID = SHN_Grid.Columns.Cast().Where(Name => Name.Name.ToLower() == ColumnName.ToLower()).FirstOrDefault().Index; NewValue = Row.Cells[Column.ID].Value.ToString().TrimStart(SHNCME_Text.Text.Replace(String.Concat("{", ColumnName, "}"), Row.Cells[ReplaceColumnID].Value.ToString()).ToCharArray()); } if (Row.Cells[Column.ID].Value.ToString().StartsWith(SHNCME_Text.Text) || (SHNCME_Text.Text.Contains("{") && SHNCME_Text.Text.Contains("}"))) { Row.Cells[Column.ID].Value = NewValue; } } else { SetInformation(Color.Red, "You cannot use anyhing other than Modify for this modifier."); } } else if (SHNCME_Modifiers.Text == "Remove at End") { if (SHNCME_Modify.Checked) { String NewValue = Row.Cells[Column.ID].Value.ToString().TrimEnd(SHNCME_Text.Text.ToCharArray()); if (SHNCME_Text.Text.Contains("{") && SHNCME_Text.Text.Contains("}")) { String ColumnName = SHNCME_Text.Text.Split('{')[1].Split('}')[0]; Int32 ReplaceColumnID = SHN_Grid.Columns.Cast().Where(Name => Name.Name.ToLower() == ColumnName.ToLower()).FirstOrDefault().Index; NewValue = Row.Cells[Column.ID].Value.ToString().TrimEnd(SHNCME_Text.Text.Replace(String.Concat("{", ColumnName, "}"), Row.Cells[ReplaceColumnID].Value.ToString()).ToCharArray()); } if (Row.Cells[Column.ID].Value.ToString().EndsWith(SHNCME_Text.Text) || (SHNCME_Text.Text.Contains("{") && SHNCME_Text.Text.Contains("}"))) { Row.Cells[Column.ID].Value = NewValue; } } else { SetInformation(Color.Red, "You cannot use anyhing other than Modify for this modifier."); } } CellsEdited++; } } SHNCME_CC.Text = String.Format("Cells Edited: {0}", CellsEdited); } #endregion #region SHN FWT private void SHNFWT_Lines_KeyDown(Object Sender, KeyEventArgs Args) { if (Args.Control && Args.KeyCode == Keys.A) { SHNFWT_Lines.SelectAll(); } } private void SHNFWT_MT_KeyDown(Object Sender, KeyEventArgs Args) { if (Args.Control && Args.KeyCode == Keys.A) { SHNFWT_MT.SelectAll(); } } private void SHNFWT_Reset_Click(Object Sender, EventArgs Args) { if (OpenSHNsArray.Count == 0) { SetInformation(Color.Red, "No SHN file is currently open."); return; } SHNFWT_Column.SelectedIndex = 0; SHNFWT_Lines.Text = ""; SHNFWT_MT.Lines = new String[] { "" }; SHNFWT_Missing.Text = "-"; SHNFWT_Filtered.Text = "-"; } private void SHNFWT_Go_Click(Object Sender, EventArgs Args) { if (OpenSHNsArray.Count == 0) { SetInformation(Color.Red, "No SHN file is currently open."); return; } else if (SHNFWT_Lines.Text == String.Empty) { SelectedSHN.Table.DefaultView.RowFilter = ""; SetInformation(Color.Green, "Resetted filtered rows."); return; } try { SHNFWT_MT.Lines = new String[] { "" }; String FilterString = String.Format("{0} IN (", SHNFWT_Column.Text); foreach (String Line in SHNFWT_Lines.Lines) { FilterString = FilterString + String.Format("'{0}', ", Line); } SelectedSHN.Table.DefaultView.RowFilter = FilterString.TrimEnd(", ".ToCharArray()) + ")"; List Missing = new List(); SHNColumn Column = SelectedSHN.SHNColumns.Where(ColumnName => ColumnName.Name == SHNFWT_Column.Text).FirstOrDefault(); DataGridViewRow[] VisibleRows = SHN_Grid.Rows.Cast().Where(IsVisible => IsVisible.Visible == true).ToArray(); foreach (String Line in SHNFWT_Lines.Lines) { Int32 TextCount = VisibleRows.Where(CellValue => CellValue.Cells[Column.ID].Value.ToString() == Line).Count(); if (TextCount == 0) { Missing.Add(Line); } } SHNFWT_MT.Lines = Missing.ToArray(); SHNFWT_Missing.Text = String.Format("Missing: {0} rows.", SHNFWT_MT.Lines.Count()); SHNFWT_Filtered.Text = String.Format("Showing: {0} rows.", SHNFWT_Lines.Lines.Count()); } catch (Exception) { MessageBox.Show("There was a error while searching what what you have specified, please check that you have the right column selected."); } SHNMFU = false; SHNFWTU = true; } private void SHNFWT_RM_Click(Object Sender, EventArgs Args) { if (OpenSHNsArray.Count == 0) { SetInformation(Color.Red, "No SHN file is currently open."); return; } foreach (String Line in SHNFWT_MT.Lines) { if (SHNFWT_Lines.Lines.Contains(Line)) { List Lines = SHNFWT_Lines.Lines.ToList(); Lines.Remove(Line); SHNFWT_Lines.Lines = Lines.ToArray(); } } SHNFWT_Go_Click(null, null); } #endregion #region SHN RO private void SHNRO_Reset_Click(Object Sender, EventArgs Args) { if (OpenSHNsArray.Count == 0) { SetInformation(Color.Red, "No SHN file is currently open."); return; } SHNRO_Column.SelectedIndex = 0; SHNRO_SF.Value = 0; SHNRO_A.Value = 0; SHNRO_CC.Text = "-"; } private void SHNRO_Go_Click(Object Sender, EventArgs Args) { if (OpenSHNsArray.Count == 0) { SetInformation(Color.Red, "No SHN file is currently open."); return; } Int32 CellsEdited = 0; Int32 CurrentNumber = Convert.ToInt32(SHNRO_SF.Value); SHNColumn Column = SelectedSHN.SHNColumns.Where(ColumnName => ColumnName.Name == SHNRO_Column.Text).FirstOrDefault(); foreach (DataGridViewRow Row in SHN_Grid.Rows.Cast().Where(IsVisible => IsVisible.Visible == true)) { Boolean NeedModify = false; if (SHNRO_IS.Checked && Row.Selected) { NeedModify = true; } else if (!SHNRO_IS.Checked) { NeedModify = true; } if (NeedModify) { Row.Cells[Column.ID].Value = CurrentNumber; CurrentNumber = CurrentNumber + Convert.ToInt32(SHNRO_A.Value); CellsEdited++; } } SHNRO_CC.Text = String.Format("Cells Edited: {0}", CellsEdited); } #endregion #region SHN VC private void SHNVC_CB_ItemCheck(Object Sender, ItemCheckEventArgs Args) { if (!SHNVCTrigger) { return; } if (Args.CurrentValue == CheckState.Checked) { SHN_Grid.Columns[Args.Index].Visible = false; } else { SHN_Grid.Columns[Args.Index].Visible = true; } } private void SHNVC_SA_Click(Object Sender, EventArgs Args) { for (Int32 Counter = 0; Counter < SHNVC_CB.Items.Count; Counter++) { SHNVC_CB.SetItemChecked(Counter, true); } } private void SHNVC_USA_Click(Object Sender, EventArgs Args) { for (Int32 Counter = 0; Counter < SHNVC_CB.Items.Count; Counter++) { SHNVC_CB.SetItemChecked(Counter, false); } } #endregion #region SHN EC private void SHNEC_SFF_Click(Object Sender, EventArgs Args) { FolderBrowserDialog OSHNsDialog = new FolderBrowserDialog(); DialogResult OSHNsResult = OSHNsDialog.ShowDialog(); if (OSHNsResult == DialogResult.OK) { SHNEC_FF.Text = OSHNsDialog.SelectedPath; SetInformation(Color.Green, String.Format("{0} has been selected.", OSHNsDialog.SelectedPath)); } else { SetInformation(Color.Red, "No from encryption folder has been selected, due to cancelling the dialog."); } } private void SHNEC_STF_Click(Object Sender, EventArgs Args) { FolderBrowserDialog NSHNsDialog = new FolderBrowserDialog(); DialogResult NSHNsResult = NSHNsDialog.ShowDialog(); if (NSHNsResult == DialogResult.OK) { SHNEC_TF.Text = NSHNsDialog.SelectedPath; SetInformation(Color.Green, String.Format("{0} has been selected.", NSHNsDialog.SelectedPath)); } else { SetInformation(Color.Red, "No to encryption folder has been selected, due to cancelling the dialog."); } } private void SHNEC_Reset_Click(Object Sender, EventArgs Args) { SHNEC_FE.SelectedIndex = 0; SHNEC_TE.SelectedIndex = 0; SHNEC_FF.Text = String.Empty; SHNEC_TF.Text = String.Empty; SHNEC_Worked.Text = "-"; SHNEC_Errored.Text = "-"; } private void SHNEC_Go_Click(Object Sender, EventArgs Args) { if (SHNEC_FE.SelectedItem == SHNEC_TE.SelectedItem) { SetInformation(Color.Red, "Cannot change to the same encryption."); } else if (SHNEC_FF.Text == SHNEC_TF.Text) { SetInformation(Color.Red, "Cannot write SHNs to the same directory as they are coming from."); } else if (Directory.GetFiles(SHNEC_TF.Text).Count() != 0) { SetInformation(Color.Red, "Please select a empty directory for the To Folder."); } else { Int32 Worked = 0; Int32 Errored = 0; foreach (String OSHN in Directory.GetFiles(SHNEC_FF.Text, "*.shn", SearchOption.AllDirectories)) { try { if (!Directory.Exists(OSHN.Replace(SHNEC_FF.Text, SHNEC_TF.Text).Replace(Path.GetFileName(OSHN), ""))) { Directory.CreateDirectory(OSHN.Replace(SHNEC_FF.Text, SHNEC_TF.Text).Replace(Path.GetFileName(OSHN), "")); } MethodInfo OCryptoMethod = CSFile.LoadCode("C:\\SHNCrypto.cs", "SHN.SHNCrypto", SHNEC_FE.SelectedItem.ToString()); SHNFile OpenSHN = new SHNFile(OSHN, OCryptoMethod); if (OpenSHN.Type == SHNType.TextData) { OpenSHN.SHNEncoding = Encoding.ASCII; } else { OpenSHN.SHNEncoding = Encoding.GetEncoding("ISO-8859-1"); } if (OpenSHN.Type != SHNType.QuestData) { OpenSHN.Read(); } MethodInfo NCryptoMethod = CSFile.LoadCode("C:\\SHNCrypto.cs", "SHN.SHNCrypto", SHNEC_TE.SelectedItem.ToString()); OpenSHN.CryptoMethod = NCryptoMethod; OpenSHN.Write(OSHN.Replace(SHNEC_FF.Text, SHNEC_TF.Text)); Worked++; } catch { Errored++; } } SHNEC_Worked.Text = String.Format("{0} converted.", Worked); SHNEC_Errored.Text = String.Format("{0} failed.", Errored); } } #endregion #region SHN DT private void SHNDT_TextChanged(Object Sender, EventArgs Args) { if (!SHNDEOpening) { Int32 RowID = Convert.ToInt32(SHNDE_Row.Text.Split(' ')[1]); Int32 ColumnID = Convert.ToInt32(SHNDE_Column.Text.Split(' ')[1]); SHN_Grid.Rows[RowID].Cells[ColumnID].Value = SHNDE_Text.Text; } } #endregion #region SHN QME private void SHNQME_Reset_Click(Object Sender, EventArgs Args) { if (OpenSHNsArray.Count == 0) { SetInformation(Color.Red, "No SHN file is currently open."); return; } SHNQME_Increase.SelectedIndex = 0; SHNQME_Value.Text = ""; SHNQME_Multiply.Checked = true; } private void SHNQME_Go_Click(Object Sender, EventArgs Args) { if (OpenSHNsArray.Count == 0) { SetInformation(Color.Red, "No SHN file is currently open."); return; } else if (SelectedSHN.Type != SHNType.QuestData) { SetInformation(Color.Red, "Please open QuestData."); return; } else if (SHNQME_Value.Text == String.Empty) { SetInformation(Color.Red, "Please type a value."); return; } Byte Type = 0; switch (SHNQME_Increase.SelectedIndex) { case 0: { Type = 0; break; } case 1: { Type = 2; break; } case 2: { Type = 4; break; } } foreach (DataGridViewRow Row in SHN_Grid.Rows.Cast().Where(IsVisible => IsVisible.Visible == true)) { Boolean NeedModify = false; if (SHNQME_IS.Checked && Row.Selected) { NeedModify = true; } else if (!SHNQME_IS.Checked) { NeedModify = true; } if (NeedModify) { //84 = type //88 = amount //90 = next Int32 TypeColumn = -1; Int32 AmountColumn = -1; if (SelectedSHN.QuestHeader == 4) { TypeColumn = 155; AmountColumn = 159; } else if (SelectedSHN.QuestHeader == 6) { TypeColumn = 168; AmountColumn = 172; } for (Int32 Counter = 0; Counter < 12; Counter++) { //0, 1, 4 if (Convert.ToByte(Row.Cells[TypeColumn].Value) == Type) { if (SHNQME_Set.Checked) { Double NewValue = Convert.ToDouble(SHNQME_Value.Text); if (NewValue.ToString().Contains('.') || NewValue.ToString().Contains(',')) { if (NewValue.ToString().Contains('.')) { NewValue = Convert.ToDouble(NewValue.ToString().Split('.')[0]); } if (NewValue.ToString().Contains(',')) { NewValue = Convert.ToDouble(NewValue.ToString().Split(',')[0]); } } Row.Cells[AmountColumn].Value = NewValue; } else if (SHNQME_Multiply.Checked) { Double NewValue = Convert.ToDouble(Row.Cells[AmountColumn].Value) * Convert.ToDouble(SHNQME_Value.Text); if (NewValue.ToString().Contains('.') || NewValue.ToString().Contains(',')) { if (NewValue.ToString().Contains('.')) { NewValue = Convert.ToDouble(NewValue.ToString().Split('.')[0]); } if (NewValue.ToString().Contains(',')) { NewValue = Convert.ToDouble(NewValue.ToString().Split(',')[0]); } } Row.Cells[AmountColumn].Value = NewValue; } else if (SHNQME_Add.Checked) { Double NewValue = Convert.ToDouble(Row.Cells[AmountColumn].Value) + Convert.ToDouble(SHNQME_Value.Text); if (NewValue.ToString().Contains('.') || NewValue.ToString().Contains(',')) { if (NewValue.ToString().Contains('.')) { NewValue = Convert.ToDouble(NewValue.ToString().Split('.')[0]); } if (NewValue.ToString().Contains(',')) { NewValue = Convert.ToDouble(NewValue.ToString().Split(',')[0]); } } Row.Cells[AmountColumn].Value = NewValue; } else if (SHNQME_Subtract.Checked) { Double NewValue = Convert.ToDouble(Row.Cells[AmountColumn].Value) - Convert.ToDouble(SHNQME_Value.Text); if (NewValue.ToString().Contains('.') || NewValue.ToString().Contains(',')) { if (NewValue.ToString().Contains('.')) { NewValue = Convert.ToDouble(NewValue.ToString().Split('.')[0]); } if (NewValue.ToString().Contains(',')) { NewValue = Convert.ToDouble(NewValue.ToString().Split(',')[0]); } } Row.Cells[AmountColumn].Value = NewValue; } else { Double NewValue = Convert.ToDouble(Row.Cells[AmountColumn].Value) / Convert.ToDouble(SHNQME_Value.Text); if (NewValue.ToString().Contains('.') || NewValue.ToString().Contains(',')) { if (NewValue.ToString().Contains('.')) { NewValue = Convert.ToDouble(NewValue.ToString().Split('.')[0]); } if (NewValue.ToString().Contains(',')) { NewValue = Convert.ToDouble(NewValue.ToString().Split(',')[0]); } } Row.Cells[AmountColumn].Value = NewValue; } } TypeColumn = TypeColumn + 6; AmountColumn = AmountColumn + 6; } } } } #endregion #region ST Replace private void STR_Reset_Click(Object Sender, EventArgs Args) { if (OpenSTArray.Count == 0) { SetInformation(Color.Red, "No Shine file is currently open."); return; } STR_Text.Text = ""; STR_In.SelectedIndex = 0; STR_E.Checked = true; STR_ST.Text = ""; STR_CC.Text = "-"; } private void STR_Go_Click(Object Sender, EventArgs Args) { if (OpenSTArray.Count == 0) { SetInformation(Color.Red, "No Shine file is currently open."); return; } else if (STR_Text.Text == String.Empty) { SetInformation(Color.Red, "Please type something before searching."); return; } Int32 CellsEdited = 0; Int32 ColumnID = ST_Grid.Columns.Cast().Where(ColumnName => ColumnName.Name == STR_In.Text).FirstOrDefault().Index; foreach (DataGridViewRow Row in ST_Grid.Rows.Cast().Where(IsVisible => IsVisible.Visible == true)) { Boolean NeedsEdit = false; Row.Cells[ColumnID].Value.ToString(); if (STR_SW.Checked) { if (Row.Cells[ColumnID].Value.ToString().StartsWith(STR_Text.Text)) { NeedsEdit = true; } } else if (STR_EW.Checked) { if (Row.Cells[ColumnID].Value.ToString().EndsWith(STR_Text.Text)) { NeedsEdit = true; } } else if (STR_C.Checked) { if (Row.Cells[ColumnID].Value.ToString().Contains(STR_Text.Text)) { NeedsEdit = true; } } else if (STR_E.Checked) { if (Row.Cells[ColumnID].Value.ToString() == STR_Text.Text) { NeedsEdit = true; } } if (STR_IS.Checked && Row.Selected) { NeedsEdit = true; } else if (STR_IS.Checked) { NeedsEdit = false; } if (NeedsEdit) { Row.Cells[ColumnID].Value = Row.Cells[ColumnID].Value.ToString().Replace(STR_Text.Text, STR_ST.Text); CellsEdited++; } } STR_CC.Text = String.Format("Cells Edited: {0}", CellsEdited); } #endregion #region ST CME private void STCME_Reset_Click(Object Sender, EventArgs Args) { if (OpenSTArray.Count == 0) { SetInformation(Color.Red, "No Shine file is currently open."); return; } STCME_Text.Text = ""; STCME_In.SelectedIndex = 0; STCME_Modifiers.SelectedIndex = 0; STCME_CC.Text = "-"; STCME_Modify.Checked = true; } private void STCME_Go_Click(Object Sender, EventArgs Args) { if (OpenSTArray.Count == 0) { SetInformation(Color.Red, "No Shine file is currently open."); return; } else if (STCME_Text.Text == String.Empty) { SetInformation(Color.Red, "Please type something before searching."); return; } Int32 CellsEdited = 0; Int32 ColumnID = ST_Grid.Columns.Cast().Where(ColumnName => ColumnName.Name == STCME_In.Text).FirstOrDefault().Index; foreach (DataGridViewRow Row in ST_Grid.Rows.Cast().Where(IsVisible => IsVisible.Visible == true)) { Boolean NeedModify = false; if (STCME_IS.Checked && Row.Selected) { NeedModify = true; } else if (!STCME_IS.Checked) { NeedModify = true; } if (NeedModify) { if (STCME_Modifiers.Text == "None") { if (STCME_Modify.Checked) { Row.Cells[ColumnID].Value = STCME_Text.Text; } else if (STCME_Add.Checked) { Double NewValue = Convert.ToDouble(Row.Cells[ColumnID].Value) + Convert.ToDouble(STCME_Text.Text); if (NewValue.ToString().Contains('.') || NewValue.ToString().Contains(',')) { if (NewValue.ToString().Contains('.')) { NewValue = Convert.ToDouble(NewValue.ToString().Split('.')[0]); } if (NewValue.ToString().Contains(',')) { NewValue = Convert.ToDouble(NewValue.ToString().Split(',')[0]); } } Row.Cells[ColumnID].Value = NewValue; } else if (STCME_Subtract.Checked) { Double NewValue = Convert.ToDouble(Row.Cells[ColumnID].Value) - Convert.ToDouble(STCME_Text.Text); if (NewValue.ToString().Contains('.') || NewValue.ToString().Contains(',')) { if (NewValue.ToString().Contains('.')) { NewValue = Convert.ToDouble(NewValue.ToString().Split('.')[0]); } if (NewValue.ToString().Contains(',')) { NewValue = Convert.ToDouble(NewValue.ToString().Split(',')[0]); } } Row.Cells[ColumnID].Value = NewValue; } else if (STCME_Multiply.Checked) { Double NewValue = Convert.ToDouble(Row.Cells[ColumnID].Value) * Convert.ToDouble(STCME_Text.Text); if (NewValue.ToString().Contains('.') || NewValue.ToString().Contains(',')) { if (NewValue.ToString().Contains('.')) { NewValue = Convert.ToDouble(NewValue.ToString().Split('.')[0]); } if (NewValue.ToString().Contains(',')) { NewValue = Convert.ToDouble(NewValue.ToString().Split(',')[0]); } } Row.Cells[ColumnID].Value = NewValue; } else if (STCME_Divide.Checked) { Double NewValue = Convert.ToDouble(Row.Cells[ColumnID].Value) / Convert.ToDouble(STCME_Text.Text); if (NewValue.ToString().Contains('.') || NewValue.ToString().Contains(',')) { if (NewValue.ToString().Contains('.')) { NewValue = Convert.ToDouble(NewValue.ToString().Split('.')[0]); } if (NewValue.ToString().Contains(',')) { NewValue = Convert.ToDouble(NewValue.ToString().Split(',')[0]); } } Row.Cells[ColumnID].Value = NewValue; } } else if (STCME_Modifiers.Text == "Add at Beginning") { if (STCME_Modify.Checked) { Row.Cells[ColumnID].Value = STCME_Text.Text + Row.Cells[ColumnID].Value.ToString(); } else { SetInformation(Color.Red, "You cannot use anyhing other than Modify for this modifier."); } } else if (STCME_Modifiers.Text == "Add at End") { if (STCME_Modify.Checked) { Row.Cells[ColumnID].Value = Row.Cells[ColumnID].Value.ToString() + STCME_Text.Text; } else { SetInformation(Color.Red, "You cannot use anyhing other than Modify for this modifier."); } } else if (STCME_Modifiers.Text == "Remove at Beginning" && Row.Cells[ColumnID].Value.ToString().StartsWith(STCME_Text.Text)) { if (STCME_Modify.Checked) { Row.Cells[ColumnID].Value = Row.Cells[ColumnID].Value.ToString().TrimStart(STCME_Text.Text.ToCharArray()); } else { SetInformation(Color.Red, "You cannot use anyhing other than Modify for this modifier."); } } else if (STCME_Modifiers.Text == "Remove at Beginning" && Row.Cells[ColumnID].Value.ToString().EndsWith(STCME_Text.Text)) { if (STCME_Modify.Checked) { Row.Cells[ColumnID].Value = Row.Cells[ColumnID].Value.ToString().TrimEnd(STCME_Text.Text.ToCharArray()); } else { SetInformation(Color.Red, "You cannot use anyhing other than Modify for this modifier."); } } CellsEdited++; } } STCME_CC.Text = String.Format("Cells Edited: {0}", CellsEdited); } #endregion #region ST FWT private void STFWT_Lines_KeyDown(Object Sender, KeyEventArgs Args) { if (Args.Control && Args.KeyCode == Keys.A) { STFWT_Lines.SelectAll(); } } private void STFWT_MT_KeyDown(Object Sender, KeyEventArgs Args) { if (Args.Control && Args.KeyCode == Keys.A) { STFWT_MT.SelectAll(); } } private void STFWT_Reset_Click(Object Sender, EventArgs Args) { if (OpenSTArray.Count == 0) { SetInformation(Color.Red, "No Shine file is currently open."); return; } STFWT_Column.SelectedIndex = 0; STFWT_Lines.Text = ""; STFWT_MT.Lines = new String[] { "" }; STFWT_Missing.Text = "-"; STFWT_Filtered.Text = "-"; } private void STFWT_Go_Click(Object Sender, EventArgs Args) { if (OpenSTArray.Count == 0) { SetInformation(Color.Red, "No Shine file is currently open."); return; } else if (STFWT_Lines.Text == String.Empty) { SelectedST.Tables[ShineTables_T.SelectedIndex].Source.DefaultView.RowFilter = ""; SetInformation(Color.Green, "Resetted filtered rows."); return; } STFWT_MT.Lines = new String[] { "" }; String FilterString = String.Format("{0} IN (", STFWT_Column.Text); foreach (String Line in STFWT_Lines.Lines) { FilterString = FilterString + String.Format("'{0}', ", Line); } SelectedST.Tables[ShineTables_T.SelectedIndex].Source.DefaultView.RowFilter = FilterString.TrimEnd(", ".ToCharArray()) + ")"; List Missing = new List(); Int32 ColumnID = ST_Grid.Columns.Cast().Where(ColumnName => ColumnName.Name == STFWT_Column.Text).FirstOrDefault().Index; DataGridViewRow[] VisibleRows = ST_Grid.Rows.Cast().Where(IsVisible => IsVisible.Visible == true).ToArray(); foreach (String Line in STFWT_Lines.Lines) { Int32 TextCount = VisibleRows.Where(CellValue => CellValue.Cells[ColumnID].Value.ToString() == Line).Count(); if (TextCount == 0) { Missing.Add(Line); } } STFWT_MT.Lines = Missing.ToArray(); STFWT_Missing.Text = String.Format("Missing: {0} rows.", STFWT_MT.Lines.Count()); STFWT_Filtered.Text = String.Format("Showing: {0} rows.", STFWT_Lines.Lines.Count()); } private void STFWT_RM_Click(Object Sender, EventArgs Args) { if (OpenSTArray.Count == 0) { SetInformation(Color.Red, "No Shine file is currently open."); return; } foreach (String Line in STFWT_MT.Lines) { if (STFWT_Lines.Lines.Contains(Line)) { List Lines = STFWT_Lines.Lines.ToList(); Lines.Remove(Line); STFWT_Lines.Lines = Lines.ToArray(); } } STFWT_Go_Click(null, null); } #endregion #region ST RO private void STRO_Reset_Click(Object Sender, EventArgs Args) { if (OpenSTArray.Count == 0) { SetInformation(Color.Red, "No Shine file is currently open."); return; } STRO_Column.SelectedIndex = 0; STRO_SF.Value = 0; STRO_A.Value = 0; STRO_CC.Text = "-"; } private void STRO_Go_Click(Object Sender, EventArgs Args) { if (OpenSTArray.Count == 0) { SetInformation(Color.Red, "No Shine file is currently open."); return; } Int32 CellsEdited = 0; Int32 CurrentNumber = Convert.ToInt32(STRO_SF.Value); Int32 ColumnID = ST_Grid.Columns.Cast().Where(ColumnName => ColumnName.Name == STFWT_Column.Text).FirstOrDefault().Index; foreach (DataGridViewRow Row in ST_Grid.Rows.Cast().Where(IsVisible => IsVisible.Visible == true)) { Boolean NeedModify = false; if (STRO_IS.Checked && Row.Selected) { NeedModify = true; } else if (!STRO_IS.Checked) { NeedModify = true; } if (NeedModify) { Row.Cells[ColumnID].Value = CurrentNumber; CurrentNumber = CurrentNumber + Convert.ToInt32(STRO_A.Value); CellsEdited++; } } STRO_CC.Text = String.Format("Cells Edited: {0}", CellsEdited); } #endregion #region ST VC private void STVC_CB_ItemCheck(Object Sender, ItemCheckEventArgs Args) { if (Args.CurrentValue == CheckState.Checked) { ST_Grid.Columns[Args.Index].Visible = false; } else { ST_Grid.Columns[Args.Index].Visible = true; } } private void STVC_SA_Click(Object Sender, EventArgs Args) { for (Int32 Counter = 0; Counter < STVC_CB.Items.Count; Counter++) { STVC_CB.SetItemChecked(Counter, true); } } private void STVC_USA_Click(Object Sender, EventArgs Args) { for (Int32 Counter = 0; Counter < STVC_CB.Items.Count; Counter++) { STVC_CB.SetItemChecked(Counter, false); } } #endregion #region ST Information Group private void SetSTType(SHNType Type) { ST_Type.Text = String.Format("Type: {0}", Type); } private void SetSTHandleID(Int32 HandleID) { ST_HandleID.Text = String.Format("Handle ID: {0}", HandleID); } private void SetSTTablesCount(Int32 Count) { ST_Tables.Text = String.Format("Tables: {0}", Count); } private void SetSTColumnCount(Int32 Count) { ST_Columns.Text = String.Format("Column Count: {0}", Count); } private void SetSTRowCount(Int32 Count) { ST_Rows.Text = String.Format("Row Count: {0}", Count - 1); } private void ST_OpenPath_Click(Object Sender, EventArgs Args) { if (OpenSTArray.Count == 0) { SetInformation(Color.Red, "No Shine file is currently open."); return; } Process.Start(Path.GetDirectoryName(SelectedST.LoadPath)); SetInformation(Color.Green, String.Format("{0}'s directory has been opened.", Path.GetFileName(SelectedST.LoadPath))); } private void ST_Close_Click(Object Sender, EventArgs Args) { if (OpenSTArray.Count == 0) { SetInformation(Color.Red, "No Shine file is currently open."); return; } SetInformation(Color.Green, String.Format("{0} has been closed.", Path.GetFileName(SelectedST.LoadPath))); OpenSTArray.Remove(SelectedSTID); ShineTables_T.Items.Clear(); STIsClosing = true; OpenShineTables.Items.Remove(OpenShineTables.SelectedItem); } private void ST_Save_Click(Object Sender, EventArgs Args) { if (OpenSTArray.Count == 0) { SetInformation(Color.Red, "No SHN file is currently open."); return; } for (Int32 Counter = 0; Counter < SelectedST.Tables.Count; Counter++) { SelectedST.Tables[Counter].Source.DefaultView.RowFilter = ""; } SelectedST.Write(SelectedST.LoadPath); SetInformation(Color.Green, String.Format("{0} has been saved.", Path.GetFileName(SelectedST.LoadPath))); } private void ST_SaveAs_Click(Object Sender, EventArgs Args) { if (OpenSTArray.Count == 0) { SetInformation(Color.Red, "No SHN file is currently open."); return; } SaveFileDialog TXTDialog = new SaveFileDialog(); TXTDialog.Filter = "Shine Files (.txt)|*.txt"; TXTDialog.Title = "Open Shine File"; DialogResult SHNResult = TXTDialog.ShowDialog(); if (SHNResult == DialogResult.OK) { for (Int32 Counter = 0; Counter < SelectedST.Tables.Count; Counter++) { SelectedST.Tables[Counter].Source.DefaultView.RowFilter = ""; } SelectedST.Write(TXTDialog.FileName); SetInformation(Color.Green, String.Format("{0} has been saved to {1}.", Path.GetFileName(SelectedST.LoadPath), TXTDialog.FileName)); } else { SetInformation(Color.Red, "No file has been saved due to cancelling the dialog."); } } private void ST_SaveAll_Click(Object Sender, EventArgs Args) { if (OpenSTArray.Count == 0) { SetInformation(Color.Red, "No Shine file is currently open."); return; } String Saved = ""; foreach (ShineTable OpenST in OpenSTArray.Values) { OpenST.Write(OpenST.LoadPath); Saved += String.Format("{0}, ", Path.GetFileName(OpenST.LoadPath)); } Saved += "have been saved."; Information.Text = Saved; } private void ST_ClearFilter_Click(Object Sender, EventArgs Args) { if (OpenSTArray.Count == 0) { SetInformation(Color.Red, "No SHN file is currently open."); return; } STFilter_Reset_Click(null, null); STR_Reset_Click(null, null); STCME_Reset_Click(null, null); SelectedST.Tables[ShineTables_T.SelectedIndex].Source.DefaultView.RowFilter = ""; } private void STF_Size_ValueChanged(Object Sender, EventArgs Args) { ST_Grid.Font = new Font(ST_Grid.Font.FontFamily, (float)STF_Size.Value); } #endregion #region ST DTM private void STDTM_Reset_Click(Object Sender, EventArgs Args) { STDTM_Value.Text = ""; STDTM_Multiply.Checked = true; STDTM_CZeros.Checked = false; } private void STDTM_Go_Click(Object Sender, EventArgs Args) { try { Convert.ToDouble(STDTM_Value.Text); } catch { SetInformation(Color.Red, "The entered value is not an Integer."); return; } for (Int32 RowCounter = 0; RowCounter < SelectedST.Tables[0].Source.Rows.Count; RowCounter++) { for (Int32 ColumnCounter = 0; ColumnCounter < SelectedST.Tables[0].Source.Columns.Count; ColumnCounter++) { Boolean NeedModify = false; if (STDTM_IS.Checked && ST_Grid.Rows[RowCounter].Cells[ColumnCounter].Selected) { NeedModify = true; } else if (!STDTM_IS.Checked) { NeedModify = true; } if (NeedModify) { if (SelectedST.Tables[0].Source.Columns[ColumnCounter].ColumnName.StartsWith("DrItem") && SelectedST.Tables[0].Source.Columns[ColumnCounter].ColumnName.EndsWith("R")) { if (STDTM_Set.Checked) { try { if (Convert.ToInt32(ST_Grid.Rows[RowCounter].Cells[ColumnCounter].Value) == 0 && !STDTM_CZeros.Checked) { } else { ST_Grid.Rows[RowCounter].Cells[ColumnCounter].Value = STDTM_Value.Text; } if (!IsWholeNumber(Convert.ToDouble(ST_Grid.Rows[RowCounter].Cells[ColumnCounter].Value))) { ST_Grid.Rows[RowCounter].Cells[ColumnCounter].Value = Math.Round(Convert.ToDouble(ST_Grid.Rows[RowCounter].Cells[ColumnCounter].Value)); } if (STDTM_FO1M.Checked && Convert.ToInt32(ST_Grid.Rows[RowCounter].Cells[ColumnCounter].Value) > 1000000) { ST_Grid.Rows[RowCounter].Cells[ColumnCounter].Value = 1000000; } } catch { } } else if (STDTM_Add.Checked) { try { if (Convert.ToInt32(ST_Grid.Rows[RowCounter].Cells[ColumnCounter].Value) == 0 && !STDTM_CZeros.Checked) { } else { ST_Grid.Rows[RowCounter].Cells[ColumnCounter].Value = Convert.ToInt32(ST_Grid.Rows[RowCounter].Cells[ColumnCounter].Value) + Convert.ToDouble(STDTM_Value.Text); } if (!IsWholeNumber(Convert.ToDouble(ST_Grid.Rows[RowCounter].Cells[ColumnCounter].Value))) { ST_Grid.Rows[RowCounter].Cells[ColumnCounter].Value = Math.Round(Convert.ToDouble(ST_Grid.Rows[RowCounter].Cells[ColumnCounter].Value)); } if (STDTM_FO1M.Checked && Convert.ToInt32(ST_Grid.Rows[RowCounter].Cells[ColumnCounter].Value) > 1000000) { ST_Grid.Rows[RowCounter].Cells[ColumnCounter].Value = 1000000; } } catch { } } else if (STDTM_Subtract.Checked) { try { if (Convert.ToInt32(ST_Grid.Rows[RowCounter].Cells[ColumnCounter].Value) == 0 && !STDTM_CZeros.Checked) { } else { ST_Grid.Rows[RowCounter].Cells[ColumnCounter].Value = Convert.ToInt32(ST_Grid.Rows[RowCounter].Cells[ColumnCounter].Value) - Convert.ToDouble(STDTM_Value.Text); } if (Convert.ToInt32(ST_Grid.Rows[RowCounter].Cells[ColumnCounter].Value) < 0) { ST_Grid.Rows[RowCounter].Cells[ColumnCounter].Value = 0; } } catch { } } else if (STDTM_Multiply.Checked) { try { if (Convert.ToInt32(ST_Grid.Rows[RowCounter].Cells[ColumnCounter].Value) == 0 && !STDTM_CZeros.Checked) { } else { ST_Grid.Rows[RowCounter].Cells[ColumnCounter].Value = Convert.ToInt32(ST_Grid.Rows[RowCounter].Cells[ColumnCounter].Value) * Convert.ToDouble(STDTM_Value.Text); } if (!IsWholeNumber(Convert.ToDouble(ST_Grid.Rows[RowCounter].Cells[ColumnCounter].Value))) { ST_Grid.Rows[RowCounter].Cells[ColumnCounter].Value = Math.Round(Convert.ToDouble(ST_Grid.Rows[RowCounter].Cells[ColumnCounter].Value)); } if (STDTM_FO1M.Checked && Convert.ToInt32(ST_Grid.Rows[RowCounter].Cells[ColumnCounter].Value) > 1000000) { ST_Grid.Rows[RowCounter].Cells[ColumnCounter].Value = 1000000; } } catch { } } else if (STDTM_Divide.Checked) { try { if (Convert.ToInt32(ST_Grid.Rows[RowCounter].Cells[ColumnCounter].Value) == 0 && !STDTM_CZeros.Checked) { } else { ST_Grid.Rows[RowCounter].Cells[ColumnCounter].Value = Convert.ToInt32(ST_Grid.Rows[RowCounter].Cells[ColumnCounter].Value) / Convert.ToDouble(STDTM_Value.Text); } if (Convert.ToInt32(ST_Grid.Rows[RowCounter].Cells[ColumnCounter].Value) < 0) { ST_Grid.Rows[RowCounter].Cells[ColumnCounter].Value = 0; } } catch { } } } } } } } private Boolean IsWholeNumber(Double Number) { return Math.Abs(Number % 1) < Double.Epsilon; } #endregion #region API private Int32 SelectedSHNID { get { return Convert.ToInt32(Convert.ToString(OpenSHNs.SelectedItem).Split(':')[0]); } } private SHNFile SelectedSHN { get { return OpenSHNsArray[SelectedSHNID]; } } private void OpenSHN(String SHNPath) { try { MethodInfo CryptoMethod = CSFile.LoadCode("C:\\SHNCrypto.cs", "SHN.SHNCrypto", SHNCrypt_List.SelectedItem.ToString()); SHNFile OpenSHN = new SHNFile(SHNPath, CryptoMethod); if (OpenSHN.Type == SHNType.TextData) { OpenSHN.SHNEncoding = Encoding.ASCII; } else { OpenSHN.SHNEncoding = Encoding.GetEncoding("ISO-8859-1"); } if (OpenSHN.Type != SHNType.QuestData) { OpenSHN.Read(); } else { OpenSHN.ReadQuest(); } for (Int32 Counter = 0; Counter < 99999; Counter++) { if (!OpenSHNsArray.ContainsKey(Counter)) { if (SHNIVS.Checked) { if (OpenSHN.Type == SHNType.ItemViewInfo) { SHNIV_Panel.Visible = true; } else { SHNIV_Panel.Visible = false; } } OpenSHNsArray.Add(Counter, OpenSHN); OpenSHNs.Items.Add(String.Format("{0}: {1}", Counter, Path.GetFileNameWithoutExtension(OpenSHN.LoadPath))); OpenSHNs.SelectedItem = String.Format("{0}: {1}", Counter, Path.GetFileNameWithoutExtension(OpenSHN.LoadPath)); break; } } } catch { SetInformation(Color.Red, String.Format("{0} cannot be read.", SHNPath)); } } private DataTable SGridTable { get { if (SHN_SGrid.DataSource != null) { return ((DataTable)SHN_SGrid.DataSource); } else { DataTable SHNSGridTable = new DataTable(); SHNSGridTable.Columns.Add("ColumnID"); SHNSGridTable.Columns.Add("ColumnName"); SHNSGridTable.Columns.Add("Value"); SHN_SGrid.DataSource = SHNSGridTable; SHN_SGrid.Columns[0].Visible = false; SHN_SGrid.Columns[1].ReadOnly = true; foreach (DataGridViewColumn Column in SHN_SGrid.Columns) { Column.SortMode = DataGridViewColumnSortMode.Programmatic; } return null; } } } private Int32 SelectedSTID { get { return Convert.ToInt32(Convert.ToString(OpenShineTables.SelectedItem).Split(':')[0]); } } private ShineTable SelectedST { get { return OpenSTArray[SelectedSTID]; } } private void OpenST(String STPath) { ShineTable OpenST = new ShineTable(STPath); if (!OpenST.IsShineTable()) { SetInformation(Color.Red, String.Format("{0} cannot be read.", STPath)); return; } OpenST.Read(); for (Int32 Counter = 0; Counter < 99999; Counter++) { if (!OpenSTArray.ContainsKey(Counter)) { OpenSTArray.Add(Counter, OpenST); OpenShineTables.Items.Add(String.Format("{0}: {1}", Counter, Path.GetFileNameWithoutExtension(OpenST.LoadPath))); OpenShineTables.SelectedItem = String.Format("{0}: {1}", Counter, Path.GetFileNameWithoutExtension(OpenST.LoadPath)); break; } } } #endregion #region SHN Grid private void SHN_Grid_DragEnter(Object Sender, DragEventArgs Args) { Args.Effect = DragDropEffects.Move; } private void SHN_Grid_DragDrop(Object Sender, DragEventArgs Args) { if (Args.Data.GetDataPresent(DataFormats.FileDrop)) { String[] Files = (String[])Args.Data.GetData(DataFormats.FileDrop); foreach (String File in Files) { if (File.EndsWith(".shn")) { OpenSHN(File); } else if (File.EndsWith(".txt")) { ShineTable OpenShineTable = new ShineTable(File); OpenShineTable.Read(); if (OpenShineTable.Tables[0].Source.TableName.StartsWith("Tab")) { List ToFilter = new List(); foreach (Table NPCTable in OpenShineTable.Tables) { foreach (DataRow Row in NPCTable.Source.Rows) { for (Int32 Counter = 1; Counter < 7; Counter++) { ToFilter.Add(Row[Counter].ToString()); } } } String FilterString = ""; if (SelectedSHN.Type == SHNType.ChargedEffect) { FilterString = FilterString + "ItemID IN ("; } else if (SelectedSHN.Type == SHNType.GradeItemOption) { FilterString = FilterString + "ItemIndex IN ("; } else { FilterString = FilterString + "InxName IN ("; } foreach (String Value in ToFilter) { FilterString = FilterString + String.Format("'{0}', ", Value); } SelectedSHN.Table.DefaultView.RowFilter = FilterString.TrimEnd(", ".ToCharArray()) + ")"; } else if (OpenShineTable.Tables[0].Source.TableName == "MobRegenGroup") { List ToFilter = new List(); foreach (DataRow Row in OpenShineTable.Tables[1].Source.Rows) { ToFilter.Add(Row[1].ToString()); } String FilterString = ""; if (SelectedSHN.Type == SHNType.ChargedEffect) { FilterString = FilterString + "ItemID IN ("; } else if (SelectedSHN.Type == SHNType.GradeItemOption) { FilterString = FilterString + "ItemIndex IN ("; } else { FilterString = FilterString + "InxName IN ("; } foreach (String Value in ToFilter) { FilterString = FilterString + String.Format("'{0}', ", Value); } SelectedSHN.Table.DefaultView.RowFilter = FilterString.TrimEnd(", ".ToCharArray()) + ")"; } else { SetInformation(Color.Red, String.Format("{0} cannot be opened currently.", Path.GetFileName(File))); } } else { SetInformation(Color.Red, String.Format("{0} cannot be opened. Allowed drop types: SHN, TXT.", Path.GetFileName(File))); } } } else { SetInformation(Color.Red, "Invalid object was dropped onto the grid."); } } private void SHN_Grid_CellValueChanged(Object Sender, DataGridViewCellEventArgs Args) { SHN_Grid.Rows[Args.RowIndex].Cells[Args.ColumnIndex].Style.BackColor = Color.Orange; if ((SHN_Grid.Columns[0].Name == "ID" || SHN_Grid.Columns[0].Name == "Handle") && SelectedSHN.Type != SHNType.MobWeapon) { if (Args.ColumnIndex != 0) { return; } foreach (DataGridViewRow Row in SHN_Grid.Rows) { if (Row.Index != Args.RowIndex) { if (!Row.IsNewRow && Row.Cells[0].Value.ToString() == SHN_Grid.Rows[Args.RowIndex].Cells[0].Value.ToString()) { SHN_Grid.Rows[Args.RowIndex].Cells[Args.ColumnIndex].Style.BackColor = Color.Red; } } } } } private void SHN_Grid_CellClick(Object Sender, DataGridViewCellEventArgs Args) { if ((SelectedSHN.Type == SHNType.QuestDialog && Args.ColumnIndex == 1) || (SelectedSHN.Type == SHNType.ItemViewInfo && Args.ColumnIndex == 21) || (SelectedSHN.Type == SHNType.ActiveSkillView && Args.ColumnIndex == 28) || (SelectedSHN.Type == SHNType.AbStateView && Args.ColumnIndex == 4) || (SelectedSHN.Type == SHNType.PassiveSkillView && Args.ColumnIndex == 7) || (SelectedSHN.Type == SHNType.ItemShopView && Args.ColumnIndex == 11) || (SelectedSHN.Type == SHNType.NpcDialogData && Args.ColumnIndex == 1) || (SelectedSHN.Type == SHNType.QuestData && (Args.ColumnIndex == 226 || Args.ColumnIndex == 227 || Args.ColumnIndex == 228) || (SelectedSHN.Type == SHNType.QuestData && (Args.ColumnIndex == 239 || Args.ColumnIndex == 240 || Args.ColumnIndex == 241)))) { SHNDEOpening = true; SHNDE_Text.ReadOnly = false; SHNDE_Text.Text = SHN_Grid.Rows[Args.RowIndex].Cells[Args.ColumnIndex].Value.ToString(); SHNDE_Row.Text = String.Format("Row: {0}", Args.RowIndex); SHNDE_Column.Text = String.Format("Column: {0}", Args.ColumnIndex); SHNDEOpening = false; } else if (SelectedSHN.Type == SHNType.QuestDialog || SelectedSHN.Type == SHNType.ItemViewInfo || SelectedSHN.Type == SHNType.ActiveSkillView || SelectedSHN.Type == SHNType.CollectCardView || SelectedSHN.Type == SHNType.AbStateView || SelectedSHN.Type == SHNType.PassiveSkillView || SelectedSHN.Type == SHNType.ItemShopView || SelectedSHN.Type == SHNType.NpcDialogData || SelectedSHN.Type == SHNType.QuestData) { SHNDEOpening = true; SHNDE_Text.ReadOnly = true; SHNDE_Text.Text = ""; SHNDE_Row.Text = "-"; SHNDE_Column.Text = "-"; SHNDEOpening = false; } } private void SHN_Grid_CellMouseDoubleClick(Object Sender, DataGridViewCellMouseEventArgs Args) { if (SHN_Grid.SelectedRows.Count >= 1 && Args.Button == System.Windows.Forms.MouseButtons.Right) { Int32 GreenRows = 0; foreach (DataGridViewRow Row in SHN_Grid.SelectedRows) { foreach (DataGridViewCell Cell in Row.Cells) { if (Cell.Style.BackColor == Color.LightSeaGreen) { GreenRows++; break; } } } foreach (DataGridViewRow Row in SHN_Grid.SelectedRows) { foreach (DataGridViewCell Cell in Row.Cells) { if (Cell.Style.BackColor == Color.LightSeaGreen && GreenRows == SHN_Grid.SelectedRows.Count) { Cell.Style.BackColor = Color.White; } else { Cell.Style.BackColor = Color.LightSeaGreen; } } } } else if (SHN_Grid.SelectedCells.Count >= 1 && Args.Button == MouseButtons.Right) { Int32 GreenCells = 0; foreach (DataGridViewCell Cell in SHN_Grid.SelectedCells) { if (Cell.Style.BackColor == Color.LightSeaGreen) { GreenCells++; } } foreach (DataGridViewCell Cell in SHN_Grid.SelectedCells) { if (Cell.Style.BackColor == Color.LightSeaGreen && GreenCells == SHN_Grid.SelectedCells.Count) { Cell.Style.BackColor = Color.White; } else { Cell.Style.BackColor = Color.LightSeaGreen; } } } } private void SHN_Grid_CellMouseDown(Object Sender, DataGridViewCellMouseEventArgs Args) { SHNRI.Text = String.Concat("SHN Row Index: ", Args.RowIndex); SHNCI.Text = String.Concat("SHN Column Index: ", Args.ColumnIndex); if (SHN_Grid.SelectedRows.Count >= 1 && Args.Button == MouseButtons.Right) { Int32 GreenRows = 0; foreach (DataGridViewRow Row in SHN_Grid.SelectedRows) { foreach (DataGridViewCell Cell in Row.Cells) { if (Cell.Style.BackColor == Color.ForestGreen) { GreenRows++; break; } } } foreach (DataGridViewRow Row in SHN_Grid.SelectedRows) { foreach (DataGridViewCell Cell in Row.Cells) { if (Cell.Style.BackColor == Color.ForestGreen && GreenRows == SHN_Grid.SelectedRows.Count) { Cell.Style.BackColor = Color.White; } else { Cell.Style.BackColor = Color.ForestGreen; } } } } else if (SHN_Grid.SelectedCells.Count >= 1 && Args.Button == MouseButtons.Right) { Int32 GreenCells = 0; foreach (DataGridViewCell Cell in SHN_Grid.SelectedCells) { if (Cell.Style.BackColor == Color.ForestGreen) { GreenCells++; } } foreach (DataGridViewCell Cell in SHN_Grid.SelectedCells) { if (Cell.Style.BackColor == Color.ForestGreen && GreenCells == SHN_Grid.SelectedCells.Count) { Cell.Style.BackColor = Color.White; } else { Cell.Style.BackColor = Color.ForestGreen; } } } if (SelectedSHN.Type == SHNType.QuestData) { if (SelectedSHN.QuestHeader == 4) { if (QuestDialogSHN != null) { try { SHNQ_TV.Text = QuestDialogSHN.Table.Rows.Cast().Where(ItemArray => ItemArray.ItemArray[0].ToString() == SHN_Grid.Rows[Args.RowIndex].Cells[1].Value.ToString()).FirstOrDefault().ItemArray[1].ToString(); } catch { SHNQ_TV.Text = "TITLE NOT FOUND"; } try { SHNQ_DV.Text = QuestDialogSHN.Table.Rows.Cast().Where(ItemArray => ItemArray.ItemArray[0].ToString() == SHN_Grid.Rows[Args.RowIndex].Cells[2].Value.ToString()).FirstOrDefault().ItemArray[1].ToString(); } catch { SHNQ_DV.Text = "DESCRIPTION NOT FOUND"; } } if (MobInfoSHN != null) { String MobName0 = String.Empty, MobName1 = String.Empty, MobName2 = String.Empty, MobName3 = String.Empty, MobName4 = String.Empty; try { MobName0 = String.Concat("Mob 0: ", MobInfoSHN.Table.Rows.Cast().Where(ItemArray => ItemArray.ItemArray[0].ToString() == SHN_Grid.Rows[Args.RowIndex].Cells[20].Value.ToString()).FirstOrDefault().ItemArray[2].ToString()); } catch { MobName0 = "Mob 0: NOT FOUND"; } try { MobName1 = String.Concat("Mob 1: ", MobInfoSHN.Table.Rows.Cast().Where(ItemArray => ItemArray.ItemArray[0].ToString() == SHN_Grid.Rows[Args.RowIndex].Cells[25].Value.ToString()).FirstOrDefault().ItemArray[2].ToString()); } catch { MobName1 = "Mob 1: NOT FOUND"; } try { MobName2 = String.Concat("Mob 2: ", MobInfoSHN.Table.Rows.Cast().Where(ItemArray => ItemArray.ItemArray[0].ToString() == SHN_Grid.Rows[Args.RowIndex].Cells[30].Value.ToString()).FirstOrDefault().ItemArray[2].ToString()); } catch { MobName2 = "Mob 2: NOT FOUND"; } try { MobName3 = String.Concat("Mob 3: ", MobInfoSHN.Table.Rows.Cast().Where(ItemArray => ItemArray.ItemArray[0].ToString() == SHN_Grid.Rows[Args.RowIndex].Cells[35].Value.ToString()).FirstOrDefault().ItemArray[2].ToString()); } catch { MobName3 = "Mob 3: NOT FOUND"; } try { MobName4 = String.Concat("Mob 4: ", MobInfoSHN.Table.Rows.Cast().Where(ItemArray => ItemArray.ItemArray[0].ToString() == SHN_Grid.Rows[Args.RowIndex].Cells[40].Value.ToString()).FirstOrDefault().ItemArray[2].ToString()); } catch { MobName4 = "Mob 4: NOT FOUND"; } SHNQ_MN.Lines = new String[] { MobName0, MobName1, MobName2, MobName3, MobName4 }; } if (ItemInfoSHN != null) { String ItemName0 = String.Empty, ItemName1 = String.Empty, ItemName2 = String.Empty, ItemName3 = String.Empty, ItemName4 = String.Empty, ItemName5 = String.Empty, ItemName6 = String.Empty, ItemName7 = String.Empty, ItemName8 = String.Empty, ItemName9 = String.Empty; try { ItemName0 = String.Concat("Item 0: ", ItemInfoSHN.Table.Rows.Cast().Where(ItemArray => ItemArray.ItemArray[0].ToString() == SHN_Grid.Rows[Args.RowIndex].Cells[45].Value.ToString()).FirstOrDefault().ItemArray[2].ToString()); } catch { ItemName0 = "Item 0: NOT FOUND"; } try { ItemName1 = String.Concat("Item 1: ", ItemInfoSHN.Table.Rows.Cast().Where(ItemArray => ItemArray.ItemArray[0].ToString() == SHN_Grid.Rows[Args.RowIndex].Cells[49].Value.ToString()).FirstOrDefault().ItemArray[2].ToString()); } catch { ItemName1 = "Item 1: NOT FOUND"; } try { ItemName2 = String.Concat("Item 2: ", ItemInfoSHN.Table.Rows.Cast().Where(ItemArray => ItemArray.ItemArray[0].ToString() == SHN_Grid.Rows[Args.RowIndex].Cells[53].Value.ToString()).FirstOrDefault().ItemArray[2].ToString()); } catch { ItemName2 = "Item 2: NOT FOUND"; } try { ItemName3 = String.Concat("Item 3: ", ItemInfoSHN.Table.Rows.Cast().Where(ItemArray => ItemArray.ItemArray[0].ToString() == SHN_Grid.Rows[Args.RowIndex].Cells[57].Value.ToString()).FirstOrDefault().ItemArray[2].ToString()); } catch { ItemName3 = "Item 3: NOT FOUND"; } try { ItemName4 = String.Concat("Item 4: ", ItemInfoSHN.Table.Rows.Cast().Where(ItemArray => ItemArray.ItemArray[0].ToString() == SHN_Grid.Rows[Args.RowIndex].Cells[61].Value.ToString()).FirstOrDefault().ItemArray[2].ToString()); } catch { ItemName4 = "Item 4: NOT FOUND"; } try { ItemName5 = String.Concat("Item 5: ", ItemInfoSHN.Table.Rows.Cast().Where(ItemArray => ItemArray.ItemArray[0].ToString() == SHN_Grid.Rows[Args.RowIndex].Cells[65].Value.ToString()).FirstOrDefault().ItemArray[2].ToString()); } catch { ItemName5 = "Item 5: NOT FOUND"; } try { ItemName6 = String.Concat("Item 6: ", ItemInfoSHN.Table.Rows.Cast().Where(ItemArray => ItemArray.ItemArray[0].ToString() == SHN_Grid.Rows[Args.RowIndex].Cells[69].Value.ToString()).FirstOrDefault().ItemArray[2].ToString()); } catch { ItemName6 = "Item 6: NOT FOUND"; } try { ItemName7 = String.Concat("Item 7: ", ItemInfoSHN.Table.Rows.Cast().Where(ItemArray => ItemArray.ItemArray[0].ToString() == SHN_Grid.Rows[Args.RowIndex].Cells[73].Value.ToString()).FirstOrDefault().ItemArray[2].ToString()); } catch { ItemName7 = "Item 7: NOT FOUND"; } try { ItemName8 = String.Concat("Item 8: ", ItemInfoSHN.Table.Rows.Cast().Where(ItemArray => ItemArray.ItemArray[0].ToString() == SHN_Grid.Rows[Args.RowIndex].Cells[77].Value.ToString()).FirstOrDefault().ItemArray[2].ToString()); } catch { ItemName8 = "Item 8: NOT FOUND"; } try { ItemName9 = String.Concat("Item 9: ", ItemInfoSHN.Table.Rows.Cast().Where(ItemArray => ItemArray.ItemArray[0].ToString() == SHN_Grid.Rows[Args.RowIndex].Cells[81].Value.ToString()).FirstOrDefault().ItemArray[2].ToString()); } catch { ItemName9 = "Item 9: NOT FOUND"; } SHNQ_IN.Lines = new String[] { ItemName0, ItemName1, ItemName2, ItemName3, ItemName4, ItemName5, ItemName6, ItemName7, ItemName8, ItemName9 }; String RewardName0 = String.Empty, RewardName1 = String.Empty, RewardName2 = String.Empty, RewardName3 = String.Empty, RewardName4 = String.Empty, RewardName5 = String.Empty, RewardName6 = String.Empty, RewardName7 = String.Empty, RewardName8 = String.Empty, RewardName9 = String.Empty, RewardName10 = String.Empty, RewardName11 = String.Empty; try { RewardName0 = String.Concat("Reward 0: ", ItemInfoSHN.Table.Rows.Cast().Where(ItemArray => ItemArray.ItemArray[0].ToString() == SHN_Grid.Rows[Args.RowIndex].Cells[157].Value.ToString()).FirstOrDefault().ItemArray[2].ToString()); } catch { RewardName0 = "Reward 0: NOT FOUND"; } try { RewardName1 = String.Concat("Reward 1: ", ItemInfoSHN.Table.Rows.Cast().Where(ItemArray => ItemArray.ItemArray[0].ToString() == SHN_Grid.Rows[Args.RowIndex].Cells[163].Value.ToString()).FirstOrDefault().ItemArray[2].ToString()); } catch { RewardName1 = "Reward 1: NOT FOUND"; } try { RewardName2 = String.Concat("Reward 2: ", ItemInfoSHN.Table.Rows.Cast().Where(ItemArray => ItemArray.ItemArray[0].ToString() == SHN_Grid.Rows[Args.RowIndex].Cells[169].Value.ToString()).FirstOrDefault().ItemArray[2].ToString()); } catch { RewardName2 = "Reward 2: NOT FOUND"; } try { RewardName3 = String.Concat("Reward 3: ", ItemInfoSHN.Table.Rows.Cast().Where(ItemArray => ItemArray.ItemArray[0].ToString() == SHN_Grid.Rows[Args.RowIndex].Cells[175].Value.ToString()).FirstOrDefault().ItemArray[2].ToString()); } catch { RewardName3 = "Reward 3: NOT FOUND"; } try { RewardName4 = String.Concat("Reward 4: ", ItemInfoSHN.Table.Rows.Cast().Where(ItemArray => ItemArray.ItemArray[0].ToString() == SHN_Grid.Rows[Args.RowIndex].Cells[181].Value.ToString()).FirstOrDefault().ItemArray[2].ToString()); } catch { RewardName4 = "Reward 4: NOT FOUND"; } try { RewardName5 = String.Concat("Reward 5: ", ItemInfoSHN.Table.Rows.Cast().Where(ItemArray => ItemArray.ItemArray[0].ToString() == SHN_Grid.Rows[Args.RowIndex].Cells[187].Value.ToString()).FirstOrDefault().ItemArray[2].ToString()); } catch { RewardName5 = "Reward 5: NOT FOUND"; } try { RewardName6 = String.Concat("Reward 6: ", ItemInfoSHN.Table.Rows.Cast().Where(ItemArray => ItemArray.ItemArray[0].ToString() == SHN_Grid.Rows[Args.RowIndex].Cells[193].Value.ToString()).FirstOrDefault().ItemArray[2].ToString()); } catch { RewardName6 = "Reward 6: NOT FOUND"; } try { RewardName7 = String.Concat("Reward 7: ", ItemInfoSHN.Table.Rows.Cast().Where(ItemArray => ItemArray.ItemArray[0].ToString() == SHN_Grid.Rows[Args.RowIndex].Cells[199].Value.ToString()).FirstOrDefault().ItemArray[2].ToString()); } catch { RewardName7 = "Reward 7: NOT FOUND"; } try { RewardName8 = String.Concat("Reward 8: ", ItemInfoSHN.Table.Rows.Cast().Where(ItemArray => ItemArray.ItemArray[0].ToString() == SHN_Grid.Rows[Args.RowIndex].Cells[205].Value.ToString()).FirstOrDefault().ItemArray[2].ToString()); } catch { RewardName8 = "Reward 8: NOT FOUND"; } try { RewardName9 = String.Concat("Reward 9: ", ItemInfoSHN.Table.Rows.Cast().Where(ItemArray => ItemArray.ItemArray[0].ToString() == SHN_Grid.Rows[Args.RowIndex].Cells[211].Value.ToString()).FirstOrDefault().ItemArray[2].ToString()); } catch { RewardName9 = "Reward 9: NOT FOUND"; } try { RewardName10 = String.Concat("Reward 10: ", ItemInfoSHN.Table.Rows.Cast().Where(ItemArray => ItemArray.ItemArray[0].ToString() == SHN_Grid.Rows[Args.RowIndex].Cells[217].Value.ToString()).FirstOrDefault().ItemArray[2].ToString()); } catch { RewardName10 = "Reward 10: NOT FOUND"; } try { RewardName11 = String.Concat("Reward 11: ", ItemInfoSHN.Table.Rows.Cast().Where(ItemArray => ItemArray.ItemArray[0].ToString() == SHN_Grid.Rows[Args.RowIndex].Cells[223].Value.ToString()).FirstOrDefault().ItemArray[2].ToString()); } catch { RewardName11 = "Reward 11: NOT FOUND"; } SHNQ_RN.Lines = new String[] { RewardName0, RewardName1, RewardName2, RewardName3, RewardName4, RewardName5, RewardName6, RewardName7, RewardName8, RewardName9, RewardName10, RewardName11 }; } } else if (SelectedSHN.QuestHeader == 6) { if (QuestDialogSHN != null) { try { SHNQ_TV.Text = QuestDialogSHN.Table.Rows.Cast().Where(ItemArray => ItemArray.ItemArray[0].ToString() == SHN_Grid.Rows[Args.RowIndex].Cells[1].Value.ToString()).FirstOrDefault().ItemArray[1].ToString(); } catch { SHNQ_TV.Text = "TITLE NOT FOUND"; } try { SHNQ_DV.Text = QuestDialogSHN.Table.Rows.Cast().Where(ItemArray => ItemArray.ItemArray[0].ToString() == SHN_Grid.Rows[Args.RowIndex].Cells[2].Value.ToString()).FirstOrDefault().ItemArray[1].ToString(); } catch { SHNQ_DV.Text = "DESCRIPTION NOT FOUND"; } } if (MobInfoSHN != null) { String MobName0 = String.Empty, MobName1 = String.Empty, MobName2 = String.Empty, MobName3 = String.Empty, MobName4 = String.Empty; try { MobName0 = String.Concat("Mob 0: ", MobInfoSHN.Table.Rows.Cast().Where(ItemArray => ItemArray.ItemArray[0].ToString() == SHN_Grid.Rows[Args.RowIndex].Cells[23].Value.ToString()).FirstOrDefault().ItemArray[2].ToString()); } catch { MobName0 = "Mob 0: NOT FOUND"; } try { MobName1 = String.Concat("Mob 1: ", MobInfoSHN.Table.Rows.Cast().Where(ItemArray => ItemArray.ItemArray[0].ToString() == SHN_Grid.Rows[Args.RowIndex].Cells[30].Value.ToString()).FirstOrDefault().ItemArray[2].ToString()); } catch { MobName1 = "Mob 1: NOT FOUND"; } try { MobName2 = String.Concat("Mob 2: ", MobInfoSHN.Table.Rows.Cast().Where(ItemArray => ItemArray.ItemArray[0].ToString() == SHN_Grid.Rows[Args.RowIndex].Cells[47].Value.ToString()).FirstOrDefault().ItemArray[2].ToString()); } catch { MobName2 = "Mob 2: NOT FOUND"; } try { MobName3 = String.Concat("Mob 3: ", MobInfoSHN.Table.Rows.Cast().Where(ItemArray => ItemArray.ItemArray[0].ToString() == SHN_Grid.Rows[Args.RowIndex].Cells[44].Value.ToString()).FirstOrDefault().ItemArray[2].ToString()); } catch { MobName3 = "Mob 3: NOT FOUND"; } try { MobName4 = String.Concat("Mob 4: ", MobInfoSHN.Table.Rows.Cast().Where(ItemArray => ItemArray.ItemArray[0].ToString() == SHN_Grid.Rows[Args.RowIndex].Cells[51].Value.ToString()).FirstOrDefault().ItemArray[2].ToString()); } catch { MobName4 = "Mob 4: NOT FOUND"; } SHNQ_MN.Lines = new String[] { MobName0, MobName1, MobName2, MobName3, MobName4 }; } if (ItemInfoSHN != null) { String ItemName0 = String.Empty, ItemName1 = String.Empty, ItemName2 = String.Empty, ItemName3 = String.Empty, ItemName4 = String.Empty, ItemName5 = String.Empty, ItemName6 = String.Empty, ItemName7 = String.Empty, ItemName8 = String.Empty, ItemName9 = String.Empty; try { ItemName0 = String.Concat("Item 0: ", ItemInfoSHN.Table.Rows.Cast().Where(ItemArray => ItemArray.ItemArray[0].ToString() == SHN_Grid.Rows[Args.RowIndex].Cells[58].Value.ToString()).FirstOrDefault().ItemArray[2].ToString()); } catch { ItemName0 = "Item 0: NOT FOUND"; } try { ItemName1 = String.Concat("Item 1: ", ItemInfoSHN.Table.Rows.Cast().Where(ItemArray => ItemArray.ItemArray[0].ToString() == SHN_Grid.Rows[Args.RowIndex].Cells[62].Value.ToString()).FirstOrDefault().ItemArray[2].ToString()); } catch { ItemName1 = "Item 1: NOT FOUND"; } try { ItemName2 = String.Concat("Item 2: ", ItemInfoSHN.Table.Rows.Cast().Where(ItemArray => ItemArray.ItemArray[0].ToString() == SHN_Grid.Rows[Args.RowIndex].Cells[66].Value.ToString()).FirstOrDefault().ItemArray[2].ToString()); } catch { ItemName2 = "Item 2: NOT FOUND"; } try { ItemName3 = String.Concat("Item 3: ", ItemInfoSHN.Table.Rows.Cast().Where(ItemArray => ItemArray.ItemArray[0].ToString() == SHN_Grid.Rows[Args.RowIndex].Cells[70].Value.ToString()).FirstOrDefault().ItemArray[2].ToString()); } catch { ItemName3 = "Item 3: NOT FOUND"; } try { ItemName4 = String.Concat("Item 4: ", ItemInfoSHN.Table.Rows.Cast().Where(ItemArray => ItemArray.ItemArray[0].ToString() == SHN_Grid.Rows[Args.RowIndex].Cells[74].Value.ToString()).FirstOrDefault().ItemArray[2].ToString()); } catch { ItemName4 = "Item 4: NOT FOUND"; } try { ItemName5 = String.Concat("Item 5: ", ItemInfoSHN.Table.Rows.Cast().Where(ItemArray => ItemArray.ItemArray[0].ToString() == SHN_Grid.Rows[Args.RowIndex].Cells[78].Value.ToString()).FirstOrDefault().ItemArray[2].ToString()); } catch { ItemName5 = "Item 5: NOT FOUND"; } try { ItemName6 = String.Concat("Item 6: ", ItemInfoSHN.Table.Rows.Cast().Where(ItemArray => ItemArray.ItemArray[0].ToString() == SHN_Grid.Rows[Args.RowIndex].Cells[82].Value.ToString()).FirstOrDefault().ItemArray[2].ToString()); } catch { ItemName6 = "Item 6: NOT FOUND"; } try { ItemName7 = String.Concat("Item 7: ", ItemInfoSHN.Table.Rows.Cast().Where(ItemArray => ItemArray.ItemArray[0].ToString() == SHN_Grid.Rows[Args.RowIndex].Cells[86].Value.ToString()).FirstOrDefault().ItemArray[2].ToString()); } catch { ItemName7 = "Item 7: NOT FOUND"; } try { ItemName8 = String.Concat("Item 8: ", ItemInfoSHN.Table.Rows.Cast().Where(ItemArray => ItemArray.ItemArray[0].ToString() == SHN_Grid.Rows[Args.RowIndex].Cells[90].Value.ToString()).FirstOrDefault().ItemArray[2].ToString()); } catch { ItemName8 = "Item 8: NOT FOUND"; } try { ItemName9 = String.Concat("Item 9: ", ItemInfoSHN.Table.Rows.Cast().Where(ItemArray => ItemArray.ItemArray[0].ToString() == SHN_Grid.Rows[Args.RowIndex].Cells[94].Value.ToString()).FirstOrDefault().ItemArray[2].ToString()); } catch { ItemName9 = "Item 9: NOT FOUND"; } SHNQ_IN.Lines = new String[] { ItemName0, ItemName1, ItemName2, ItemName3, ItemName4, ItemName5, ItemName6, ItemName7, ItemName8, ItemName9 }; String RewardName0 = String.Empty, RewardName1 = String.Empty, RewardName2 = String.Empty, RewardName3 = String.Empty, RewardName4 = String.Empty, RewardName5 = String.Empty, RewardName6 = String.Empty, RewardName7 = String.Empty, RewardName8 = String.Empty, RewardName9 = String.Empty, RewardName10 = String.Empty, RewardName11 = String.Empty; try { RewardName0 = String.Concat("Reward 0: ", ItemInfoSHN.Table.Rows.Cast().Where(ItemArray => ItemArray.ItemArray[0].ToString() == SHN_Grid.Rows[Args.RowIndex].Cells[170].Value.ToString()).FirstOrDefault().ItemArray[2].ToString()); } catch { RewardName0 = "Reward 0: NOT FOUND"; } try { RewardName1 = String.Concat("Reward 1: ", ItemInfoSHN.Table.Rows.Cast().Where(ItemArray => ItemArray.ItemArray[0].ToString() == SHN_Grid.Rows[Args.RowIndex].Cells[176].Value.ToString()).FirstOrDefault().ItemArray[2].ToString()); } catch { RewardName1 = "Reward 1: NOT FOUND"; } try { RewardName2 = String.Concat("Reward 2: ", ItemInfoSHN.Table.Rows.Cast().Where(ItemArray => ItemArray.ItemArray[0].ToString() == SHN_Grid.Rows[Args.RowIndex].Cells[182].Value.ToString()).FirstOrDefault().ItemArray[2].ToString()); } catch { RewardName2 = "Reward 2: NOT FOUND"; } try { RewardName3 = String.Concat("Reward 3: ", ItemInfoSHN.Table.Rows.Cast().Where(ItemArray => ItemArray.ItemArray[0].ToString() == SHN_Grid.Rows[Args.RowIndex].Cells[186].Value.ToString()).FirstOrDefault().ItemArray[2].ToString()); } catch { RewardName3 = "Reward 3: NOT FOUND"; } try { RewardName4 = String.Concat("Reward 4: ", ItemInfoSHN.Table.Rows.Cast().Where(ItemArray => ItemArray.ItemArray[0].ToString() == SHN_Grid.Rows[Args.RowIndex].Cells[192].Value.ToString()).FirstOrDefault().ItemArray[2].ToString()); } catch { RewardName4 = "Reward 4: NOT FOUND"; } try { RewardName5 = String.Concat("Reward 5: ", ItemInfoSHN.Table.Rows.Cast().Where(ItemArray => ItemArray.ItemArray[0].ToString() == SHN_Grid.Rows[Args.RowIndex].Cells[198].Value.ToString()).FirstOrDefault().ItemArray[2].ToString()); } catch { RewardName5 = "Reward 5: NOT FOUND"; } try { RewardName6 = String.Concat("Reward 6: ", ItemInfoSHN.Table.Rows.Cast().Where(ItemArray => ItemArray.ItemArray[0].ToString() == SHN_Grid.Rows[Args.RowIndex].Cells[204].Value.ToString()).FirstOrDefault().ItemArray[2].ToString()); } catch { RewardName6 = "Reward 6: NOT FOUND"; } try { RewardName7 = String.Concat("Reward 7: ", ItemInfoSHN.Table.Rows.Cast().Where(ItemArray => ItemArray.ItemArray[0].ToString() == SHN_Grid.Rows[Args.RowIndex].Cells[210].Value.ToString()).FirstOrDefault().ItemArray[2].ToString()); } catch { RewardName7 = "Reward 7: NOT FOUND"; } try { RewardName8 = String.Concat("Reward 8: ", ItemInfoSHN.Table.Rows.Cast().Where(ItemArray => ItemArray.ItemArray[0].ToString() == SHN_Grid.Rows[Args.RowIndex].Cells[216].Value.ToString()).FirstOrDefault().ItemArray[2].ToString()); } catch { RewardName8 = "Reward 8: NOT FOUND"; } try { RewardName9 = String.Concat("Reward 9: ", ItemInfoSHN.Table.Rows.Cast().Where(ItemArray => ItemArray.ItemArray[0].ToString() == SHN_Grid.Rows[Args.RowIndex].Cells[222].Value.ToString()).FirstOrDefault().ItemArray[2].ToString()); } catch { RewardName9 = "Reward 9: NOT FOUND"; } try { RewardName10 = String.Concat("Reward 10: ", ItemInfoSHN.Table.Rows.Cast().Where(ItemArray => ItemArray.ItemArray[0].ToString() == SHN_Grid.Rows[Args.RowIndex].Cells[228].Value.ToString()).FirstOrDefault().ItemArray[2].ToString()); } catch { RewardName10 = "Reward 10: NOT FOUND"; } try { RewardName11 = String.Concat("Reward 11: ", ItemInfoSHN.Table.Rows.Cast().Where(ItemArray => ItemArray.ItemArray[0].ToString() == SHN_Grid.Rows[Args.RowIndex].Cells[234].Value.ToString()).FirstOrDefault().ItemArray[2].ToString()); } catch { RewardName11 = "Reward 11: NOT FOUND"; } SHNQ_RN.Lines = new String[] { RewardName0, RewardName1, RewardName2, RewardName3, RewardName4, RewardName5, RewardName6, RewardName7, RewardName8, RewardName9, RewardName10, RewardName11 }; } } } } private void SHN_Grid_ColumnHeaderMouseClick(Object Sender, DataGridViewCellMouseEventArgs Args) { if (SHN_Grid.Columns[Args.ColumnIndex].HeaderCell.SortGlyphDirection == SortOrder.None) { SHN_Grid.Sort(SHN_Grid.Columns[Args.ColumnIndex], ListSortDirection.Ascending); SHN_Grid.Columns[Args.ColumnIndex].HeaderCell.SortGlyphDirection = SortOrder.Ascending; } else if (SHN_Grid.Columns[Args.ColumnIndex].HeaderCell.SortGlyphDirection == SortOrder.Ascending) { SHN_Grid.Sort(SHN_Grid.Columns[Args.ColumnIndex], ListSortDirection.Descending); SHN_Grid.Columns[Args.ColumnIndex].HeaderCell.SortGlyphDirection = SortOrder.Descending; } else { SelectedSHN.Table.DefaultView.Sort = String.Empty; SHN_Grid.Columns[Args.ColumnIndex].HeaderCell.SortGlyphDirection = SortOrder.None; } } private void SHN_Grid_ColumnWidthChanged(Object Sender, DataGridViewColumnEventArgs Args) { if (SHNWTrigger) { return; } else if (SHN_Grid.SelectedCells.Count >= 1) { Boolean ColumnSelected = false; foreach (DataGridViewCell Cell in SHN_Grid.SelectedCells) { if (Cell.ColumnIndex == Args.Column.Index) { ColumnSelected = true; } } if (ColumnSelected) { foreach (DataGridViewCell Cell in SHN_Grid.SelectedCells) { SHNWTrigger = true; SHN_Grid.Columns[Cell.ColumnIndex].Width = Args.Column.Width; SHNWTrigger = false; } } } } private void SHN_Grid_SelectionChanged(Object Sender, EventArgs Args) { SGridTable.Clear(); if (SHN_Grid.SelectedRows.Count == 1) { Int32 RowIndex = 0; foreach (DataGridViewCell Cell in SHN_Grid.SelectedRows[0].Cells) { SGridTable.Rows.Add(new Object[] { Cell.ColumnIndex, SHN_Grid.Columns[Cell.ColumnIndex].Name, Cell.Value }); SHN_SGrid.Rows[RowIndex].Cells[1].Style.BackColor = Cell.Style.BackColor; SHN_SGrid.Rows[RowIndex].Cells[2].Style.BackColor = Cell.Style.BackColor; RowIndex++; } SHNSGridRowIndex = SHN_Grid.SelectedRows[0].Index; if (SelectedSHN.Type == SHNType.ItemViewInfo && SHNIVIconPath != String.Empty) { Dictionary Icons; Dictionary Grades = null; if (File.Exists(String.Format("{0}\\{1}.dds", SHNIVIconPath, SHN_Grid.SelectedRows[0].Cells[3].Value))) { Icons = FiestaDDS.LoadItemImages(String.Format("{0}\\{1}.dds", SHNIVIconPath, SHN_Grid.SelectedRows[0].Cells[3].Value)); if (File.Exists(String.Format("{0}\\{1}.dds", SHNIVIconPath, SHN_Grid.SelectedRows[0].Cells[5].Value))) { Grades = FiestaDDS.LoadGrades(String.Format("{0}\\{1}.dds", SHNIVIconPath, SHN_Grid.SelectedRows[0].Cells[5].Value)); SHNIV_Icon.BackgroundImage = MergeImages(Icons[Convert.ToInt32(SHN_Grid.SelectedRows[0].Cells[2].Value)], Grades[Convert.ToInt32(SHN_Grid.SelectedRows[0].Cells[4].Value)]); } else if (File.Exists(String.Format("{0}\\{1}.dds", SHNIVIconPath, SHN_Grid.SelectedRows[0].Cells[7].Value))) { Grades = FiestaDDS.LoadGrades(String.Format("{0}\\{1}.dds", SHNIVIconPath, SHN_Grid.SelectedRows[0].Cells[7].Value)); SHNIV_Icon.BackgroundImage = MergeImages(Icons[Convert.ToInt32(SHN_Grid.SelectedRows[0].Cells[2].Value)], Grades[Convert.ToInt32(SHN_Grid.SelectedRows[0].Cells[6].Value)]); } else { SHNIV_Icon.BackgroundImage = Icons[Convert.ToInt32(SHN_Grid.SelectedRows[0].Cells[2].Value)]; } } } } } private Image MergeImages(Image BackImage, Image OverlayImage) { Image CombinedImage = BackImage; if (OverlayImage != null) { Image OImage = OverlayImage; if (OverlayImage.PixelFormat != PixelFormat.Format32bppArgb) { OImage = new Bitmap(OverlayImage.Width, OverlayImage.Height, PixelFormat.Format32bppArgb); using (Graphics OverlayDrawer = Graphics.FromImage(OImage)) { OverlayDrawer.DrawImage(OverlayImage, new Rectangle(0, 0, OImage.Width, OImage.Height), new Rectangle(0, 0, OverlayImage.Width, OverlayImage.Height), GraphicsUnit.Pixel); } ((Bitmap)OImage).MakeTransparent(); } using (Graphics OverlayDrawer = Graphics.FromImage(CombinedImage)) { OverlayDrawer.DrawImage(OImage, new Rectangle(0, 0, CombinedImage.Width, CombinedImage.Height), new Rectangle(0, 0, OImage.Width, OImage.Height), GraphicsUnit.Pixel); } } return CombinedImage; } private void SHN_Grid_KeyDown(Object Sender, KeyEventArgs Args) { if (Args.Control && Args.KeyCode == Keys.O) { SHN_OpenPath_Click(null, null); } else if (Args.Control && Args.Shift && Args.KeyCode == Keys.C) { SHN_Close_Click(null, null); } else if (Args.Control && Args.KeyCode == Keys.S) { SHN_Save_Click(null, null); } else if (Args.Control && Args.Shift && Args.KeyCode == Keys.S) { SHN_SaveAs_Click(null, null); } else if (Args.Control && Args.KeyCode == Keys.C) { if (SelectedSHN.Type != SHNType.QuestDialog && SelectedSHN.Type != SHNType.QuestData) { SHN_Grid.ClipboardCopyMode = DataGridViewClipboardCopyMode.EnableWithAutoHeaderText; Clipboard.SetDataObject(SHN_Grid.GetClipboardContent()); SetInformation(Color.Green, String.Format("Copied: {0} Rows. {1} Cells.", SHN_Grid.SelectedRows.Count, SHN_Grid.SelectedCells.Count)); } else if (SelectedSHN.Type == SHNType.QuestData) { SHN_Grid.ClipboardCopyMode = DataGridViewClipboardCopyMode.Disable; String ClipboardData = ""; if (SHN_Grid.SelectedRows.Count >= 1) { foreach (DataGridViewRow Row in SHN_Grid.SelectedRows.Cast().OrderBy(Index => Index.Index).ToArray()) { String RowData = "\t"; for (Int32 Counter = 0; Counter < 226; Counter++) { RowData += String.Concat(Row.Cells[Counter].Value, "\t"); } RowData += String.Concat(HexOfString(Row.Cells[226].Value.ToString()), "\t"); RowData += String.Concat(HexOfString(Row.Cells[227].Value.ToString()), "\t"); RowData += String.Concat(HexOfString(Row.Cells[228].Value.ToString()), "\t"); for (Int32 Counter = 229; Counter <= 235; Counter++) { RowData += String.Concat(Row.Cells[Counter].Value, "\t"); } RowData = RowData.TrimEnd('\t'); ClipboardData += String.Concat(RowData, "\n"); } } else { SHN_Grid.ClipboardCopyMode = DataGridViewClipboardCopyMode.EnableWithAutoHeaderText; Clipboard.SetDataObject(SHN_Grid.GetClipboardContent()); SetInformation(Color.Green, String.Format("Copied: {0} Rows. {1} Cells.", SHN_Grid.SelectedRows.Count, SHN_Grid.SelectedCells.Count)); } Clipboard.SetDataObject(ClipboardData.TrimEnd('\n')); } else { SHN_Grid.ClipboardCopyMode = DataGridViewClipboardCopyMode.Disable; String ClipboardData = ""; if (SHN_Grid.SelectedRows.Count >= 1) { foreach (DataGridViewRow Row in SHN_Grid.SelectedRows.Cast().OrderBy(Index => Index.Index).ToArray()) { String RowData = "\t"; RowData += Row.Cells[0].Value; String Hex = "\t"; foreach (Char Character in Row.Cells[1].Value.ToString().ToCharArray()) { Int32 CInt = Convert.ToInt32(Character); Hex += String.Format("{0:X} ", CInt); } RowData += Hex.TrimEnd(' '); ClipboardData += String.Concat(RowData, "\n"); } } else if (SHN_Grid.SelectedCells.Count == 1 && SHN_Grid.SelectedCells[0].ColumnIndex == 1) { DataGridViewCell Cell = SHN_Grid.SelectedCells[0]; String Hex = ""; foreach (Char Character in Cell.Value.ToString().ToCharArray()) { Int32 CInt = Convert.ToInt32(Character); Hex += String.Format("{0:X} ", CInt); } ClipboardData += Hex.TrimEnd(' '); } else if (SHN_Grid.SelectedCells.Count == 1 && SHN_Grid.SelectedCells[0].ColumnIndex == 0) { ClipboardData += SHN_Grid.SelectedCells[0].Value.ToString(); } Clipboard.SetDataObject(ClipboardData.TrimEnd('\n')); } } else if (Args.KeyCode == Keys.Delete) { Int32 DeletedCount = 0; foreach (DataGridViewRow SelectedRow in SHN_Grid.SelectedRows) { if (!SelectedRow.IsNewRow) { SHN_Grid.Rows.Remove(SelectedRow); SetSHNRowCount(SHN_Grid.Rows.Count); DeletedCount++; } } SetInformation(Color.Green, String.Format("{0} rows deleted.", DeletedCount)); } else if (Args.Control && Args.Shift && Args.KeyCode == Keys.V) { foreach (DataGridViewRow Row in SHN_Grid.SelectedRows) { Row.Selected = false; } String ClipboardText = Clipboard.GetText(); String[] Lines = ClipboardText.Split('\n'); if (SelectedSHN.Type != SHNType.QuestDialog && SelectedSHN.Type != SHNType.QuestData) { foreach (String Line in Lines) { if (Line.StartsWith("\t")) { String EditedLine = Line.TrimStart('\t'); SelectedSHN.Table.Rows.Add(EditedLine.Split('\t')); SetSHNRowCount(SHN_Grid.Rows.Count); } } } else if (SelectedSHN.Type == SHNType.QuestData) { foreach (String Line in Lines) { if (Line.StartsWith("\t")) { String EditedLine = Line.TrimStart('\t'); SelectedSHN.Table.Rows.Add(EditedLine.Split('\t')); try { SHN_Grid.Rows[SHN_Grid.Rows.Count - 1].Cells[226].Value = HexToString(SHN_Grid.Rows[SHN_Grid.Rows.Count - 1].Cells[226].Value.ToString()); } catch { } try { SHN_Grid.Rows[SHN_Grid.Rows.Count - 1].Cells[227].Value = HexToString(SHN_Grid.Rows[SHN_Grid.Rows.Count - 1].Cells[227].Value.ToString()); } catch { } try { SHN_Grid.Rows[SHN_Grid.Rows.Count - 1].Cells[228].Value = HexToString(SHN_Grid.Rows[SHN_Grid.Rows.Count - 1].Cells[228].Value.ToString()); } catch { } SetSHNRowCount(SHN_Grid.Rows.Count); } } } else { foreach (String Line in Lines) { if (Line.StartsWith("\t")) { String EditedLine = Line.TrimStart('\t'); Int32 ID = Convert.ToInt32(EditedLine.Split('\t')[0]); String Hex = EditedLine.Split('\t')[1]; String Text = ""; foreach (String Value in Hex.Split(' ')) { Text += Convert.ToChar(Int32.Parse(Value, NumberStyles.HexNumber)); } SelectedSHN.Table.Rows.Add(new Object[] { ID, Text }); SetSHNRowCount(SHN_Grid.Rows.Count); } } } } else if (Args.Control && Args.KeyCode == Keys.V) { String ClipboardText = Clipboard.GetText(); if (!ClipboardText.Contains('\n') && !Clipboard.GetText().Contains('\t')) { if (SelectedSHN.Type != SHNType.QuestDialog) { foreach (DataGridViewCell Cell in SHN_Grid.SelectedCells) { Cell.Value = ClipboardText; } } else if (SelectedSHN.Type == SHNType.QuestDialog && SHN_Grid.SelectedCells[0].ColumnIndex == 1) { String Hex = ClipboardText; String Text = ""; foreach (String Value in Hex.Split(' ')) { Text += Convert.ToChar(Int32.Parse(Value, NumberStyles.HexNumber)); } foreach (DataGridViewCell Cell in SHN_Grid.SelectedCells) { Cell.Value = Text; } } else if (SelectedSHN.Type == SHNType.QuestDialog && SHN_Grid.SelectedCells[0].ColumnIndex == 0) { foreach (DataGridViewCell Cell in SHN_Grid.SelectedCells) { Cell.Value = ClipboardText; } } } else if (ClipboardText.StartsWith("\t")) { if (SHN_Grid.SelectedRows.Count == 0) { SetInformation(Color.Red, "Please select a starting row."); } else if (SHN_Grid.SelectedRows.Count != 1 && ClipboardText.Split('\n').Count() > 1) { SetInformation(Color.Red, "Please select only the starting row to paste to."); } else { String[] Lines = ClipboardText.Split('\n'); Int32 Index = SHN_Grid.SelectedRows[0].Index; if (Lines.Count() > 1) { foreach (String Line in Lines) { if (Line != String.Empty) { String EditedLine = Line.TrimStart('\t'); if (SelectedSHN.Type != SHNType.QuestDialog) { SHN_Grid.Rows[Index].SetValues(EditedLine.Split('\t')); } else { Int32 ID = Convert.ToInt32(EditedLine.Split('\t')[0]); String Hex = EditedLine.Split('\t')[1]; String Text = ""; foreach (String Value in Hex.Split(' ')) { Text += Convert.ToChar(Int32.Parse(Value, NumberStyles.HexNumber)); } SHN_Grid.Rows[Index].SetValues(new Object[] { ID, Text }); } Index++; for (Int32 Counter = Index; Counter < SHN_Grid.Rows.Count; Counter++) { if (SHN_Grid.Rows[Counter].Visible == true) { Index = Counter; break; } } } } } else if (Lines.Count() == 1) { if (SelectedSHN.Type != SHNType.QuestDialog) { foreach (DataGridViewRow SelectedRow in SHN_Grid.SelectedRows) { String EditedLine = Lines[0].TrimStart('\t'); SelectedRow.SetValues(EditedLine.Split('\t')); } } else { foreach (DataGridViewRow SelectedRow in SHN_Grid.SelectedRows) { String EditedLine = Lines[0].TrimStart('\t'); Int32 ID = Convert.ToInt32(EditedLine.Split('\t')[0]); String Hex = EditedLine.Split('\t')[1]; String Text = ""; foreach (String Value in Hex.Split(' ')) { Text += Convert.ToChar(Int32.Parse(Value, NumberStyles.HexNumber)); } SelectedRow.SetValues(new Object[] { ID, Text }); } } } else { SetInformation(Color.Red, "Invalid clipboard data."); } } } else { if (SHN_Grid.SelectedCells.Count == 0) { SetInformation(Color.Red, "Please select a starting cell."); } else { Int32 ColumnID = -1; Int32 SameColumnID = 0; foreach (DataGridViewCell SelectedCell in SHN_Grid.SelectedCells.Cast().Where(IsVisible => IsVisible.Visible == true)) { if (ColumnID == -1) { ColumnID = SelectedCell.ColumnIndex; SameColumnID++; } else if (SelectedCell.ColumnIndex == ColumnID) { SameColumnID++; } } if (SameColumnID == SHN_Grid.SelectedCells.Cast().Where(IsVisible => IsVisible.Visible == true).Count() && SHN_Grid.SelectedCells.Cast().Where(IsVisible => IsVisible.Visible == true).Count() != 1) { Int32 Index = SHN_Grid.SelectedCells[0].ColumnIndex; foreach (DataGridViewCell SelectedCell in SHN_Grid.SelectedCells.Cast().Where(IsVisible => IsVisible.Visible == true)) { String[] Cells = ClipboardText.Split('\t'); Int32 CellsIndex = 0; for (Int32 Counter = Index; Counter < Index + Cells.Count(); Counter++) { SHN_Grid.Rows[SelectedCell.RowIndex].Cells[Counter].Value = Cells[CellsIndex].Trim(); CellsIndex++; } } } else if (SHN_Grid.SelectedCells.Count != 1) { SetInformation(Color.Red, "Please select only the starting cell to paste to."); } else { if (ClipboardText.Contains('\t')) { String[] Lines = ClipboardText.Split('\n'); Int32 Index = SHN_Grid.SelectedCells[0].RowIndex; foreach (String Line in Lines) { if (Line != String.Empty) { String[] Cells = Line.Split('\t'); Int32 CurrentCell = 0; for (Int32 Counter = SHN_Grid.SelectedCells[0].ColumnIndex; Counter < SHN_Grid.SelectedCells[0].ColumnIndex + Line.Split('\t').Count(); Counter++) { if (SelectedSHN.Type != SHNType.QuestDialog) { SHN_Grid.Rows[Index].Cells[Counter].Value = Cells[CurrentCell].Trim(); CurrentCell++; } } Index++; for (Int32 Counter = Index; Counter < SHN_Grid.Rows.Count; Counter++) { if (SHN_Grid.Rows[Counter].Visible == true) { Index = Counter; break; } } } } } else { String[] Lines = ClipboardText.Split('\n'); Int32 Index = SHN_Grid.SelectedCells[0].RowIndex; foreach (String Line in Lines) { if (Line != String.Empty) { if (SHN_Grid.Rows[Index].Visible) { SHN_Grid.Rows[Index].Cells[SHN_Grid.SelectedCells[0].ColumnIndex].Value = Line.Trim(); Index++; } } } } } } } } } private String HexOfString(String CellValue) { String Hex = ""; foreach (Char Character in CellValue.ToCharArray()) { Int32 CInt = Convert.ToInt32(Character); Hex += String.Format("{0:X} ", CInt); } return Hex.TrimEnd(' '); } private String HexToString(String HexValues) { String Text = ""; foreach (String Value in HexValues.Split(' ')) { Text += Convert.ToChar(Int32.Parse(Value, NumberStyles.HexNumber)); } return Text; } public Byte[] FromHex(String Hex) { Hex = Hex.Replace("-", ""); Byte[] HexArray = new Byte[Hex.Length / 2]; for (Int32 Counter = 0; Counter < HexArray.Length; Counter++) { HexArray[Counter] = Convert.ToByte(Hex.Substring(Counter * 2, 2), 16); } return HexArray; } private void SHN_Grid_CellDoubleClick(Object Sender, DataGridViewCellEventArgs Args) { if (SelectedSHN.Table.DefaultView.RowFilter != "" && SHN_Grid.SelectedRows.Count == 1) { String SearchRowString = ""; foreach (DataGridViewCell Cell in SHN_Grid.Rows[Args.RowIndex].Cells) { SearchRowString = SearchRowString + Cell.Value.ToString(); } SelectedSHN.Table.DefaultView.RowFilter = ""; foreach (DataGridViewRow Row in SHN_Grid.Rows) { String CompareRowString = ""; foreach (DataGridViewCell Cell in Row.Cells) { CompareRowString = CompareRowString + Cell.Value.ToString(); } if (SearchRowString == CompareRowString) { Row.Selected = true; SHN_Grid.FirstDisplayedScrollingRowIndex = Row.Index; } } } } #endregion #region SHN SGrid private void SHN_SGrid_CellValueChanged(Object Sender, DataGridViewCellEventArgs Args) { if (SHNSGridTrigger) { return; } Int32 ColumnID = Convert.ToInt32(SHN_SGrid.Rows[Args.RowIndex].Cells[0].Value); String NewValue = Convert.ToString(SHN_SGrid.Rows[Args.RowIndex].Cells[2].Value); SHN_Grid.Rows[SHNSGridRowIndex].Cells[ColumnID].Value = NewValue; if (SHN_Grid.Rows[SHNSGridRowIndex].Cells[ColumnID].Value != NewValue) { SHNSGridTrigger = true; SHN_SGrid.Rows[Args.RowIndex].Cells[2].Value = SHN_Grid.Rows[SHNSGridRowIndex].Cells[ColumnID].Value; SHNSGridTrigger = false; } } private void SHN_SGrid_ColumnHeaderMouseClick(Object Sender, DataGridViewCellMouseEventArgs Args) { if (SHN_SGrid.Columns[Args.ColumnIndex].HeaderCell.SortGlyphDirection == SortOrder.None) { SHN_SGrid.Sort(SHN_SGrid.Columns[Args.ColumnIndex], ListSortDirection.Ascending); SHN_SGrid.Columns[Args.ColumnIndex].HeaderCell.SortGlyphDirection = SortOrder.Ascending; } else if (SHN_SGrid.Columns[Args.ColumnIndex].HeaderCell.SortGlyphDirection == SortOrder.Ascending) { SHN_SGrid.Sort(SHN_SGrid.Columns[Args.ColumnIndex], ListSortDirection.Descending); SHN_SGrid.Columns[Args.ColumnIndex].HeaderCell.SortGlyphDirection = SortOrder.Descending; } else { SGridTable.DefaultView.Sort = String.Empty; SHN_SGrid.Columns[Args.ColumnIndex].HeaderCell.SortGlyphDirection = SortOrder.None; } } #endregion #region ST Grid private void ST_Grid_DragEnter(Object Sender, DragEventArgs Args) { Args.Effect = DragDropEffects.Move; } private void ST_Grid_DragDrop(Object Sender, DragEventArgs Args) { if (Args.Data.GetDataPresent(DataFormats.FileDrop)) { String[] Files = (String[])Args.Data.GetData(DataFormats.FileDrop); foreach (String File in Files) { if (File.EndsWith(".txt")) { OpenST(File); } else { SetInformation(Color.Red, String.Format("{0} cannot be opened. Allowed drop types: TXT.", Path.GetFileName(File))); } } } else { SetInformation(Color.Red, "Invalid object was dropped onto the grid."); } } private void ST_Grid_CellValueChanged(Object Sender, DataGridViewCellEventArgs Args) { ST_Grid.Rows[Args.RowIndex].Cells[Args.ColumnIndex].Style.BackColor = Color.Orange; } private void ST_Grid_CellMouseDoubleClick(Object Sender, DataGridViewCellMouseEventArgs Args) { if (ST_Grid.SelectedRows.Count >= 1 && Args.Button == System.Windows.Forms.MouseButtons.Right) { Int32 GreenRows = 0; foreach (DataGridViewRow Row in ST_Grid.SelectedRows) { foreach (DataGridViewCell Cell in Row.Cells) { if (Cell.Style.BackColor == Color.LightSeaGreen) { GreenRows++; break; } } } foreach (DataGridViewRow Row in ST_Grid.SelectedRows) { foreach (DataGridViewCell Cell in Row.Cells) { if (Cell.Style.BackColor == Color.LightSeaGreen && GreenRows == ST_Grid.SelectedRows.Count) { Cell.Style.BackColor = Color.White; } else { Cell.Style.BackColor = Color.LightSeaGreen; } } } } else if (ST_Grid.SelectedCells.Count >= 1 && Args.Button == MouseButtons.Right) { Int32 GreenCells = 0; foreach (DataGridViewCell Cell in ST_Grid.SelectedCells) { if (Cell.Style.BackColor == Color.LightSeaGreen) { GreenCells++; } } foreach (DataGridViewCell Cell in ST_Grid.SelectedCells) { if (Cell.Style.BackColor == Color.LightSeaGreen && GreenCells == ST_Grid.SelectedCells.Count) { Cell.Style.BackColor = Color.White; } else { Cell.Style.BackColor = Color.LightSeaGreen; } } } } private void ST_Grid_CellMouseDown(Object Sender, DataGridViewCellMouseEventArgs Args) { if (ST_Grid.SelectedRows.Count >= 1 && Args.Button == System.Windows.Forms.MouseButtons.Right) { Int32 GreenRows = 0; foreach (DataGridViewRow Row in ST_Grid.SelectedRows) { foreach (DataGridViewCell Cell in Row.Cells) { if (Cell.Style.BackColor == Color.ForestGreen) { GreenRows++; break; } } } foreach (DataGridViewRow Row in ST_Grid.SelectedRows) { foreach (DataGridViewCell Cell in Row.Cells) { if (Cell.Style.BackColor == Color.ForestGreen && GreenRows == ST_Grid.SelectedRows.Count) { Cell.Style.BackColor = Color.White; } else { Cell.Style.BackColor = Color.ForestGreen; } } } } else if (ST_Grid.SelectedCells.Count >= 1 && Args.Button == MouseButtons.Right) { Int32 GreenCells = 0; foreach (DataGridViewCell Cell in ST_Grid.SelectedCells) { if (Cell.Style.BackColor == Color.ForestGreen) { GreenCells++; } } foreach (DataGridViewCell Cell in ST_Grid.SelectedCells) { if (Cell.Style.BackColor == Color.ForestGreen && GreenCells == ST_Grid.SelectedCells.Count) { Cell.Style.BackColor = Color.White; } else { Cell.Style.BackColor = Color.ForestGreen; } } } } private void ST_Grid_ColumnWidthChanged(Object Sender, DataGridViewColumnEventArgs Args) { if (ST_Grid.SelectedCells.Count >= 1) { foreach (DataGridViewCell Cell in ST_Grid.SelectedCells) { ST_Grid.Columns[Cell.ColumnIndex].Width = Args.Column.Width; } } } private void ST_Grid_ColumnHeaderMouseClick(Object Sender, DataGridViewCellMouseEventArgs Args) { if (ST_Grid.Columns[Args.ColumnIndex].HeaderCell.SortGlyphDirection == SortOrder.None) { ST_Grid.Sort(ST_Grid.Columns[Args.ColumnIndex], ListSortDirection.Ascending); ST_Grid.Columns[Args.ColumnIndex].HeaderCell.SortGlyphDirection = SortOrder.Ascending; } else if (ST_Grid.Columns[Args.ColumnIndex].HeaderCell.SortGlyphDirection == SortOrder.Ascending) { ST_Grid.Sort(ST_Grid.Columns[Args.ColumnIndex], ListSortDirection.Descending); ST_Grid.Columns[Args.ColumnIndex].HeaderCell.SortGlyphDirection = SortOrder.Descending; } else { SelectedST.Tables[ShineTables_T.SelectedIndex].Source.DefaultView.Sort = String.Empty; ST_Grid.Columns[Args.ColumnIndex].HeaderCell.SortGlyphDirection = SortOrder.None; } } private void ST_Grid_KeyDown(Object Sender, KeyEventArgs Args) { if (Args.Control && Args.KeyCode == Keys.O) { ST_OpenPath_Click(null, null); } else if (Args.Control && Args.Shift && Args.KeyCode == Keys.C) { ST_Close_Click(null, null); } else if (Args.Control && Args.KeyCode == Keys.S) { ST_Save_Click(null, null); } else if (Args.Control && Args.Shift && Args.KeyCode == Keys.S) { ST_SaveAs_Click(null, null); } else if (Args.Control && Args.KeyCode == Keys.C) { ST_Grid.ClipboardCopyMode = DataGridViewClipboardCopyMode.EnableWithAutoHeaderText; Clipboard.SetDataObject(ST_Grid.GetClipboardContent()); SetInformation(Color.Green, String.Format("Copied: {0} Rows. {1} Cells.", ST_Grid.SelectedRows.Count, ST_Grid.SelectedCells.Count)); } else if (Args.KeyCode == Keys.Delete) { Int32 DeletedCount = 0; foreach (DataGridViewRow SelectedRow in ST_Grid.SelectedRows) { if (!SelectedRow.IsNewRow) { ST_Grid.Rows.Remove(SelectedRow); SetSTRowCount(ST_Grid.Rows.Count); DeletedCount++; } } SetInformation(Color.Green, String.Format("{0} rows deleted.", DeletedCount)); } else if (Args.Control && Args.Shift && Args.KeyCode == Keys.V) { foreach (DataGridViewRow Row in ST_Grid.SelectedRows) { Row.Selected = false; } String ClipboardText = Clipboard.GetText(); String[] Lines = ClipboardText.Split('\n'); foreach (String Line in Lines) { if (Line.StartsWith("\t")) { String EditedLine = Line.TrimStart('\t'); SelectedST.Tables[ShineTables_T.SelectedIndex].Source.Rows.Add(EditedLine.Split('\t')); SetSTRowCount(ST_Grid.Rows.Count); } } } else if (Args.Control && Args.KeyCode == Keys.V) { String ClipboardText = Clipboard.GetText(); if (!ClipboardText.Contains('\n') && !Clipboard.GetText().Contains('\t')) { foreach (DataGridViewCell Cell in ST_Grid.SelectedCells) { Cell.Value = ClipboardText; } } else if (ClipboardText.StartsWith("\t")) { if (ST_Grid.SelectedRows.Count == 0) { SetInformation(Color.Red, "Please select a starting row."); } else if (ST_Grid.SelectedRows.Count != 1 && ClipboardText.Split('\n').Count() > 1) { SetInformation(Color.Red, "Please select only the starting row to paste to."); } else { String[] Lines = ClipboardText.Split('\n'); Int32 Index = ST_Grid.SelectedRows[0].Index; if (Lines.Count() > 1) { foreach (String Line in Lines) { if (Line != String.Empty) { String EditedLine = Line.TrimStart('\t'); ST_Grid.Rows[Index].SetValues(EditedLine.Split('\t')); Index++; for (Int32 Counter = Index; Counter < ST_Grid.Rows.Count; Counter++) { if (ST_Grid.Rows[Counter].Visible == true) { Index = Counter; break; } } } } } else if (Lines.Count() == 1) { foreach (DataGridViewRow SelectedRow in ST_Grid.SelectedRows) { String EditedLine = Lines[0].TrimStart('\t'); SelectedRow.SetValues(EditedLine.Split('\t')); } } else { SetInformation(Color.Red, "Invalid clipboard data."); } } } else { if (ST_Grid.SelectedCells.Count == 0) { SetInformation(Color.Red, "Please select a starting cell."); } else { Int32 ColumnID = -1; Int32 SameColumnID = 0; foreach (DataGridViewCell SelectedCell in ST_Grid.SelectedCells.Cast().Where(IsVisible => IsVisible.Visible == true)) { if (ColumnID == -1) { ColumnID = SelectedCell.ColumnIndex; SameColumnID++; } else if (SelectedCell.ColumnIndex == ColumnID) { SameColumnID++; } } if (SameColumnID == ST_Grid.SelectedCells.Cast().Where(IsVisible => IsVisible.Visible == true).Count() && ST_Grid.SelectedCells.Cast().Where(IsVisible => IsVisible.Visible == true).Count() != 1) { Int32 Index = ST_Grid.SelectedCells[0].ColumnIndex; foreach (DataGridViewCell SelectedCell in ST_Grid.SelectedCells.Cast().Where(IsVisible => IsVisible.Visible == true)) { String[] Cells = ClipboardText.Split('\t'); Int32 CellsIndex = 0; for (Int32 Counter = Index; Counter < Index + Cells.Count(); Counter++) { ST_Grid.Rows[SelectedCell.RowIndex].Cells[Counter].Value = Cells[CellsIndex].Trim(); CellsIndex++; } } } else if (ST_Grid.SelectedCells.Count != 1) { SetInformation(Color.Red, "Please select only the starting cell to paste to."); } else { if (ClipboardText.Contains('\t')) { String[] Lines = ClipboardText.Split('\n'); Int32 Index = ST_Grid.SelectedCells[0].RowIndex; foreach (String Line in Lines) { if (Line != String.Empty) { String[] Cells = Line.Split('\t'); Int32 CurrentCell = 0; for (Int32 Counter = ST_Grid.SelectedCells[0].ColumnIndex; Counter < ST_Grid.SelectedCells[0].ColumnIndex + Line.Split('\t').Count(); Counter++) { ST_Grid.Rows[Index].Cells[Counter].Value = Cells[CurrentCell].Trim(); CurrentCell++; } Index++; for (Int32 Counter = Index; Counter < ST_Grid.Rows.Count; Counter++) { if (ST_Grid.Rows[Counter].Visible == true) { Index = Counter; break; } } } } } else { String[] Lines = ClipboardText.Split('\n'); Int32 Index = ST_Grid.SelectedCells[0].RowIndex; foreach (String Line in Lines) { if (Line != String.Empty) { if (ST_Grid.Rows[Index].Visible) { ST_Grid.Rows[Index].Cells[ST_Grid.SelectedCells[0].ColumnIndex].Value = Line.Trim(); Index++; } } } } } } } } } private void ST_Grid_CellDoubleClick(Object Sender, DataGridViewCellEventArgs Args) { if (SelectedST.Tables[ShineTables_T.SelectedIndex].Source.DefaultView.RowFilter != "" && ST_Grid.SelectedRows.Count == 1) { String SearchRowString = ""; foreach (DataGridViewCell Cell in ST_Grid.Rows[Args.RowIndex].Cells) { SearchRowString = SearchRowString + Cell.Value.ToString(); } SelectedST.Tables[ShineTables_T.SelectedIndex].Source.DefaultView.RowFilter = ""; foreach (DataGridViewRow Row in ST_Grid.Rows) { String CompareRowString = ""; foreach (DataGridViewCell Cell in Row.Cells) { CompareRowString = CompareRowString + Cell.Value.ToString(); } if (SearchRowString == CompareRowString) { Row.Selected = true; ST_Grid.FirstDisplayedScrollingRowIndex = Row.Index; } } } } #endregion private void Backup_Dir_Click(Object Sender, EventArgs Args) { Process.Start("C:\\KEBackups\\"); } private void SetInformation(Color C, String T) { Information.ForeColor = C; Information.Text = T; } } }