private void buttonTestConnection_Click(object sender, EventArgs e) { MySqlConnectionStringBuilder _connectionString = new MySqlConnectionStringBuilder(); _connectionString.Server = textBoxHost.Text; _connectionString.UserID = textBoxUsername.Text; _connectionString.Port = XConverter.ToUInt32(textBoxPort.Text); _connectionString.Database = textBoxWorldDatabase.Text; if (textBoxPassword.Text.Length > 0) { _connectionString.Password = textBoxPassword.Text; } WorldDatabase worldDatabase = null; if (!Settings.Default.UseWorldDatabase) { worldDatabase = new WorldDatabase(Settings.Default.Host, Settings.Default.Port, Settings.Default.User, SAI_Editor_Manager.Instance.GetPasswordSetting(), Settings.Default.Database); } else { worldDatabase = SAI_Editor_Manager.Instance.worldDatabase; } //! If no connection was established, it would throw an error in WorldDatabase.CanConnectToDatabase. if (worldDatabase.CanConnectToDatabase(_connectionString)) { MessageBox.Show("Connection successful!", "Connection status", MessageBoxButtons.OK, MessageBoxIcon.Information); } }
private void buttonSaveCondition_Click(object sender, EventArgs e) { Condition condition = new Condition(); condition.SourceTypeOrReferenceId = comboBoxConditionSourceTypes.SelectedIndex; condition.SourceGroup = XConverter.ToInt32(textBoxSourceGroup.Text); condition.SourceEntry = XConverter.ToInt32(textBoxSourceEntry.Text); condition.SourceId = XConverter.ToInt32(textBoxSourceId.Text); condition.ElseGroup = XConverter.ToInt32(textBoxElseGroup.Text); condition.ConditionTypeOrReference = comboBoxConditionTypes.SelectedIndex; condition.ConditionTarget = comboBoxConditionTarget.SelectedIndex; condition.ConditionValue1 = XConverter.ToInt32(textBoxCondValue1.Text); condition.ConditionValue2 = XConverter.ToInt32(textBoxCondValue2.Text); condition.ConditionValue3 = XConverter.ToInt32(textBoxCondValue3.Text); condition.NegativeCondition = XConverter.ToInt32(textBoxCondValue4.Text); condition.ErrorType = XConverter.ToInt32(textBoxErrorType.Text); condition.ErrorTextId = XConverter.ToInt32(textBoxErrorTextId.Text); condition.ScriptName = textBoxScriptName.Text; condition.Comment = textBoxComment.Text; conditions.Add(condition); tabControl.SelectedIndex = 1; listViewConditions.AddScript(condition, selectNewItem: true); ResetAllFields(); }
private Creature BuildCreature(DataRow row) { var creature = new Creature(); creature.guid = row["guid"] != DBNull.Value ? XConverter.ToInt32(row["guid"]) : 0; creature.id = row["id"] != DBNull.Value ? XConverter.ToInt32(row["id"]) : 0; creature.map = row["map"] != DBNull.Value ? XConverter.ToInt32(row["map"]) : 0; creature.spawnMask = row["spawnMask"] != DBNull.Value ? XConverter.ToInt32(row["spawnMask"]) : 0; creature.phaseMask = row["phaseMask"] != DBNull.Value ? XConverter.ToInt32(row["phaseMask"]) : 0; creature.modelid = row["modelid"] != DBNull.Value ? XConverter.ToInt32(row["modelid"]) : 0; creature.equipment_id = row["equipment_id"] != DBNull.Value ? XConverter.ToInt32(row["equipment_id"]) : 0; creature.position_x = row["position_x"] != DBNull.Value ? XConverter.ToInt32(row["position_x"]) : 0; creature.position_y = row["position_y"] != DBNull.Value ? XConverter.ToInt32(row["position_y"]) : 0; creature.position_z = row["position_z"] != DBNull.Value ? XConverter.ToInt32(row["position_z"]) : 0; creature.orientation = row["orientation"] != DBNull.Value ? XConverter.ToInt32(row["orientation"]) : 0; creature.spawntimesecs = row["spawntimesecs"] != DBNull.Value ? XConverter.ToInt32(row["spawntimesecs"]) : 0; creature.spawndist = row["spawndist"] != DBNull.Value ? XConverter.ToInt32(row["spawndist"]) : 0; creature.currentwaypoint = row["currentwaypoint"] != DBNull.Value ? XConverter.ToInt32(row["currentwaypoint"]) : 0; creature.curhealth = row["curhealth"] != DBNull.Value ? XConverter.ToInt32(row["curhealth"]) : 0; creature.curmana = row["curmana"] != DBNull.Value ? XConverter.ToInt32(row["curmana"]) : 0; creature.movementType = row["movementType"] != DBNull.Value ? XConverter.ToInt32(row["movementType"]) : 0; creature.npcflag = row["npcflag"] != DBNull.Value ? XConverter.ToInt32(row["npcflag"]) : 0; creature.unit_flags = row["unit_flags"] != DBNull.Value ? XConverter.ToInt32(row["unit_flags"]) : 0; creature.dynamicflags = row["dynamicflags"] != DBNull.Value ? XConverter.ToInt32(row["dynamicflags"]) : 0; return(creature); }
/// <summary> /// This method is inherited from the IComparer interface. /// It compares the two objects passed\ /// using a case insensitive comparison. /// </summary> /// <param name="x">First object to be compared</param> /// <param name="y">Second object to be compared</param> /// <returns>The result of the comparison. "0" if equal, /// negative if 'x' is less than 'y' and positive /// if 'x' is greater than 'y'</returns> public int Compare(object x, object y) { int compareResult = 0; ListViewItem listviewX, listviewY; // Cast the objects to be compared to ListViewItem objects listviewX = x as ListViewItem; listviewY = y as ListViewItem; if (listviewX != listviewY) { if (XConverter.ToInt32(listviewX.SubItems[ColumnToSort].Text) > 0 && XConverter.ToInt32(listviewY.SubItems[ColumnToSort].Text) > 0) { compareResult = Decimal.Compare(XConverter.ToInt32(listviewX.SubItems[ColumnToSort].Text), XConverter.ToInt32(listviewY.SubItems[ColumnToSort].Text)); } else { compareResult = String.Compare(listviewX.SubItems[ColumnToSort].Text, listviewY.SubItems[ColumnToSort].Text); } } if (OrderOfSort == SortOrder.Ascending) { return(compareResult); } return(-compareResult); }
/// <summary> ///转换到新的 /// </summary> /// <param name="old"></param> /// <returns></returns> public Point GetNewPoint(XY old) { var newX = XConverter.GetNew(old.X); var newY = YConverter.GetNew(old.Y); return(new Point((int)Math.Round(newX), (int)Math.Round(newY))); }
/// <summary> ///转换到新的 /// </summary> /// <param name="old"></param> /// <returns></returns> public XY GetNew(XY old) { var newX = XConverter.GetNew(old.X); var newY = YConverter.GetNew(old.Y); return(new XY(newX, newY)); }
private SmartScript BuildSmartScript(DataRow row) { var smartScript = new SmartScript(); smartScript.entryorguid = row["entryorguid"] != DBNull.Value ? XConverter.ToInt32(row["entryorguid"]) : -1; smartScript.source_type = row["source_type"] != DBNull.Value ? XConverter.ToInt32(row["source_type"]) : 0; smartScript.id = row["id"] != DBNull.Value ? XConverter.ToInt32(row["id"]) : 0; smartScript.link = row["link"] != DBNull.Value ? XConverter.ToInt32(row["link"]) : 0; smartScript.event_type = row["event_type"] != DBNull.Value ? XConverter.ToInt32(row["event_type"]) : 0; smartScript.event_phase_mask = row["event_phase_mask"] != DBNull.Value ? XConverter.ToInt32(row["event_phase_mask"]) : 0; smartScript.event_chance = row["event_chance"] != DBNull.Value ? XConverter.ToInt32(row["event_chance"]) : 0; smartScript.event_flags = row["event_flags"] != DBNull.Value ? XConverter.ToInt32(row["event_flags"]) : 0; smartScript.event_param1 = row["event_param1"] != DBNull.Value ? XConverter.ToInt32(row["event_param1"]) : 0; smartScript.event_param2 = row["event_param2"] != DBNull.Value ? XConverter.ToInt32(row["event_param2"]) : 0; smartScript.event_param3 = row["event_param3"] != DBNull.Value ? XConverter.ToInt32(row["event_param3"]) : 0; smartScript.event_param4 = row["event_param4"] != DBNull.Value ? XConverter.ToInt32(row["event_param4"]) : 0; smartScript.action_type = row["action_type"] != DBNull.Value ? XConverter.ToInt32(row["action_type"]) : 0; smartScript.action_param1 = row["action_param1"] != DBNull.Value ? XConverter.ToInt32(row["action_param1"]) : 0; smartScript.action_param2 = row["action_param2"] != DBNull.Value ? XConverter.ToInt32(row["action_param2"]) : 0; smartScript.action_param3 = row["action_param3"] != DBNull.Value ? XConverter.ToInt32(row["action_param3"]) : 0; smartScript.action_param4 = row["action_param4"] != DBNull.Value ? XConverter.ToInt32(row["action_param4"]) : 0; smartScript.action_param5 = row["action_param5"] != DBNull.Value ? XConverter.ToInt32(row["action_param5"]) : 0; smartScript.action_param6 = row["action_param6"] != DBNull.Value ? XConverter.ToInt32(row["action_param6"]) : 0; smartScript.target_type = row["target_type"] != DBNull.Value ? XConverter.ToInt32(row["target_type"]) : 0; smartScript.target_param1 = row["target_param1"] != DBNull.Value ? XConverter.ToInt32(row["target_param1"]) : 0; smartScript.target_param2 = row["target_param2"] != DBNull.Value ? XConverter.ToInt32(row["target_param2"]) : 0; smartScript.target_param3 = row["target_param3"] != DBNull.Value ? XConverter.ToInt32(row["target_param3"]) : 0; smartScript.target_x = row["target_x"] != DBNull.Value ? XConverter.ToInt32(row["target_x"]) : 0; smartScript.target_y = row["target_y"] != DBNull.Value ? XConverter.ToInt32(row["target_y"]) : 0; smartScript.target_z = row["target_z"] != DBNull.Value ? XConverter.ToInt32(row["target_z"]) : 0; smartScript.target_o = row["target_o"] != DBNull.Value ? XConverter.ToInt32(row["target_o"]) : 0; smartScript.comment = row["comment"] != DBNull.Value ? (string)row["comment"] : String.Empty; return(smartScript); }
private void UpdateRealm(Realm r) { r.dbId = XConverter.ToInt32(numRealmId.Value); r.chardb = txtCharDB.Text; r.worlddb = txtWorldDB.Text; ServerManager.Status = RealmsStatus.SAVED; }
/// <summary> /// 获取新的 /// </summary> /// <param name="contentBoxUserCoord"></param> /// <returns></returns> public Envelope GetNew(Envelope contentBoxUserCoord) { var MinX = XConverter.GetNew(contentBoxUserCoord.MinX); var MaxX = XConverter.GetNew(contentBoxUserCoord.MaxX); var MinY = YConverter.GetNew(contentBoxUserCoord.MinY); var MaxY = YConverter.GetNew(contentBoxUserCoord.MaxY); return(new Envelope(MinX, MinY, MaxX, MaxY)); }
public async Task <int> GetGameobjectIdByGuid(int guid) { DataTable dt = await ExecuteQuery("SELECT id FROM gameobject WHERE guid = '" + guid + "'"); if (dt.Rows.Count == 0) { return(0); } return(XConverter.ToInt32(dt.Rows[0]["id"])); }
public AreaTrigger BuildAreaTrigger(DataRow row) { var areaTrigger = new AreaTrigger(); areaTrigger.id = row["m_id"] != DBNull.Value ? XConverter.ToInt32(row["m_id"]) : -1; areaTrigger.map_id = row["m_mapId"] != DBNull.Value ? XConverter.ToInt32(row["m_mapId"]) : 0; areaTrigger.posX = row["m_posX"] != DBNull.Value ? (double)row["m_posX"] : 0; areaTrigger.posY = row["m_posY"] != DBNull.Value ? (double)row["m_posY"] : 0; areaTrigger.posZ = row["m_posZ"] != DBNull.Value ? (double)row["m_posZ"] : 0; return(areaTrigger); }
private async void buttonSearchForWorldDb_Click(object sender, EventArgs e) { WorldDatabase worldDatabase = new WorldDatabase(textBoxHost.Text, XConverter.ToUInt32(textBoxPort.Text), textBoxUsername.Text, textBoxPassword.Text, ""); List <string> databaseNames = await SAI_Editor_Manager.Instance.GetDatabasesInConnection(textBoxHost.Text, textBoxUsername.Text, XConverter.ToUInt32(textBoxPort.Text), textBoxPassword.Text, worldDatabase); if (databaseNames != null && databaseNames.Count > 0) { using (var selectDatabaseForm = new SelectDatabaseForm(databaseNames, textBoxWorldDatabase)) selectDatabaseForm.ShowDialog(this); } }
private void LoadScript() { if (listBoxGuids.SelectedItem == null) { return; } ((MainForm)Owner).textBoxEntryOrGuid.Text = (-XConverter.ToInt32(listBoxGuids.SelectedItem.ToString())).ToString(); ((MainForm)Owner).comboBoxSourceType.SelectedIndex = (int)SourceTypes.SourceTypeCreature; ((MainForm)Owner).TryToLoadScript(); Close(); }
public async Task <int> GetCreatureIdByGuid(int guid) { //DataTable dt = await ExecuteQuery("SELECT id FROM creature WHERE guid = '@guid'", new MySqlParameter("@guid", guid)); DataTable dt = await ExecuteQuery("SELECT id FROM creature WHERE guid = '" + guid + "'"); if (dt.Rows.Count == 0) { return(0); } return(XConverter.ToInt32(dt.Rows[0]["id"])); }
private void buttonTestConnection_Click(object sender, EventArgs e) { connectionString.Server = textBoxHost.Text; connectionString.UserID = textBoxUsername.Text; connectionString.Port = XConverter.ToUInt32(textBoxPort.Text); connectionString.Database = textBoxWorldDatabase.Text; if (textBoxPassword.Text.Length > 0) { connectionString.Password = textBoxPassword.Text; } if (SAI_Editor_Manager.Instance.worldDatabase.CanConnectToDatabase(connectionString)) { MessageBox.Show("Connection successful!", "Connection status", MessageBoxButtons.OK, MessageBoxIcon.Information); } }
private void UpdateServer(Server s) { s.sqlHost = txtSQLHost.Text; s.sqlPort = XConverter.ToUInt32(numSQLPort.Value); s.sqlUser = txtSQLUser.Text; s.sqlPassword = txtSQLPassword.Text; s.authdb = txtAuthDB.Text; s.sshHost = txtSSHHost.Text; s.sshPort = XConverter.ToInt32(numSSHPort.Value); s.sshUser = txtSSHUser.Text; s.sshPassword = txtSSSHPassword.Text; s.sshForwardedPort = XConverter.ToUInt32(numLocalSSHPort.Value); s.useSSHTunnel = chkUseSSH.Checked; ServerManager.Status = RealmsStatus.SAVED; }
public MultiSelectForm(TextBox textBoxToChange) { InitializeComponent(); this.textBoxToChange = textBoxToChange; listViewSelectableItems.Columns.Add(typeof(T).Name, 235, HorizontalAlignment.Left); foreach (var en in Enum.GetNames(typeof(T))) { listViewSelectableItems.Items.Add("").SubItems.Add(en); } if (textBoxToChange != null) { long bitmask = XConverter.ToInt64(textBoxToChange.Text); bool anyFlag = false; foreach (ListViewItem item in listViewSelectableItems.Items) { foreach (var en in Enum.GetNames(typeof(T))) { if (en.Equals(item.SubItems[1].Text)) { object enu = Enum.Parse(typeof(T), en); if ((bitmask & Convert.ToInt64(enu)) == Convert.ToInt64(enu)) { anyFlag = true; item.Checked = true; } } } } if (!anyFlag) { foreach (ListViewItem item in listViewSelectableItems.Items.Cast <ListViewItem>().Where(item => item.Index > 0)) { item.Checked = false; } } } }
private void MultiSelectForm_Load(object sender, EventArgs e) { if (textBoxToChange.Text == "0" || String.IsNullOrWhiteSpace(textBoxToChange.Text)) { listViewSelectableItems.Items[0].Checked = true; } else { int bitmask = XConverter.ToInt32(textBoxToChange.Text); foreach (ListViewItem item in listViewSelectableItems.Items) { if (item.Index > 0 && (bitmask & GetMaskByIndex(item.Index)) == GetMaskByIndex(item.Index)) { item.Checked = true; } } } }
private void textBoxAnimationSpeed_TextChanged(object sender, EventArgs e) { int newValue = XConverter.ToInt32(textBoxAnimationSpeed.Text); if (newValue > 12) { newValue = 12; } if (newValue < 1) { newValue = 1; } trackBarAnimationSpeed.Value = newValue; if (newValue != XConverter.ToInt32(textBoxAnimationSpeed.Text)) { textBoxAnimationSpeed.Text = newValue.ToString(); } }
private Gameobject BuildGameobject(DataRow row) { var gameobject = new Gameobject(); gameobject.guid = row["guid"] != DBNull.Value ? XConverter.ToInt32(row["guid"]) : 0; gameobject.id = row["id"] != DBNull.Value ? XConverter.ToInt32(row["id"]) : 0; gameobject.map = row["map"] != DBNull.Value ? XConverter.ToInt32(row["map"]) : 0; gameobject.spawnMask = row["spawnMask"] != DBNull.Value ? XConverter.ToInt32(row["spawnMask"]) : 0; gameobject.phaseMask = row["phaseMask"] != DBNull.Value ? XConverter.ToInt32(row["phaseMask"]) : 0; gameobject.position_x = row["position_x"] != DBNull.Value ? XConverter.ToInt32(row["position_x"]) : 0; gameobject.position_y = row["position_y"] != DBNull.Value ? XConverter.ToInt32(row["position_y"]) : 0; gameobject.position_z = row["position_z"] != DBNull.Value ? XConverter.ToInt32(row["position_z"]) : 0; gameobject.orientation = row["orientation"] != DBNull.Value ? XConverter.ToInt32(row["orientation"]) : 0; gameobject.rotation0 = row["rotation0"] != DBNull.Value ? XConverter.ToInt32(row["rotation0"]) : 0; gameobject.rotation1 = row["rotation1"] != DBNull.Value ? XConverter.ToInt32(row["rotation1"]) : 0; gameobject.rotation2 = row["rotation2"] != DBNull.Value ? XConverter.ToInt32(row["rotation2"]) : 0; gameobject.rotation3 = row["rotation3"] != DBNull.Value ? XConverter.ToInt32(row["rotation3"]) : 0; gameobject.spawntimesecs = row["spawntimesecs"] != DBNull.Value ? XConverter.ToInt32(row["spawntimesecs"]) : 0; gameobject.animprogress = row["animprogress"] != DBNull.Value ? XConverter.ToInt32(row["animprogress"]) : 0; gameobject.state = row["state"] != DBNull.Value ? XConverter.ToInt32(row["state"]) : 0; return(gameobject); }
private void SaveSettings() { if (checkBoxChangeStaticInfo.Checked != Settings.Default.ChangeStaticInfo) { EntryOrGuidAndSourceType originalEntryOrGuidAndSourceType = ((MainForm)Owner).originalEntryOrGuidAndSourceType; ((MainForm)Owner).textBoxEntryOrGuid.Text = originalEntryOrGuidAndSourceType.entryOrGuid.ToString(); ((MainForm)Owner).comboBoxSourceType.SelectedIndex = ((MainForm)Owner).GetIndexBySourceType(originalEntryOrGuidAndSourceType.sourceType); } bool showTooltipsPermanently = Settings.Default.ShowTooltipsPermanently; bool generateComments = Settings.Default.GenerateComments; RNGCryptoServiceProvider rng = new RNGCryptoServiceProvider(); byte[] buffer = new byte[1024]; rng.GetBytes(buffer); string salt = BitConverter.ToString(buffer); rng.Dispose(); string decryptedPassword = textBoxPassword.Text; connectionString.Server = textBoxHost.Text; connectionString.UserID = textBoxUsername.Text; connectionString.Port = XConverter.ToUInt32(textBoxPort.Text); connectionString.Database = textBoxWorldDatabase.Text; if (textBoxPassword.Text.Length > 0) { connectionString.Password = textBoxPassword.Text; } bool newConnectionSuccesfull = SAI_Editor_Manager.Instance.worldDatabase.CanConnectToDatabase(connectionString, false); if (newConnectionSuccesfull) { Settings.Default.Entropy = salt; Settings.Default.Host = textBoxHost.Text; Settings.Default.User = textBoxUsername.Text; Settings.Default.Password = decryptedPassword.ToSecureString().EncryptString(Encoding.Unicode.GetBytes(salt)); Settings.Default.Database = textBoxWorldDatabase.Text; Settings.Default.Port = textBoxPort.Text.Length > 0 ? XConverter.ToUInt32(textBoxPort.Text) : 0; Settings.Default.AutoConnect = checkBoxAutoConnect.Checked; ((MainForm)Owner).connectionString = connectionString; SAI_Editor_Manager.Instance.ResetDatabases(); } Settings.Default.InstantExpand = checkBoxInstantExpand.Checked; Settings.Default.LoadScriptInstantly = checkBoxLoadScriptInstantly.Checked; Settings.Default.AutoSaveSettings = checkBoxAutoSaveSettings.Checked; Settings.Default.PromptToQuit = checkBoxPromptToQuit.Checked; Settings.Default.HidePass = checkBoxHidePass.Checked; Settings.Default.AnimationSpeed = XConverter.ToInt32(textBoxAnimationSpeed.Text); Settings.Default.PromptExecuteQuery = checkBoxPromptExecuteQuery.Checked; Settings.Default.ChangeStaticInfo = checkBoxChangeStaticInfo.Checked; Settings.Default.ShowTooltipsPermanently = checkBoxShowTooltipsPermanently.Checked; Settings.Default.GenerateComments = checkBoxAutoGenerateComments.Checked; Settings.Default.CreateRevertQuery = checkBoxCreateRevertQuery.Checked; Settings.Default.Save(); if (newConnectionSuccesfull) { ((MainForm)Owner).checkBoxAutoConnect.Checked = checkBoxAutoConnect.Checked; ((MainForm)Owner).textBoxHost.Text = textBoxHost.Text; ((MainForm)Owner).textBoxUsername.Text = textBoxUsername.Text; ((MainForm)Owner).textBoxPassword.Text = decryptedPassword; ((MainForm)Owner).textBoxWorldDatabase.Text = textBoxWorldDatabase.Text; ((MainForm)Owner).checkBoxAutoConnect.Checked = checkBoxAutoConnect.Checked; ((MainForm)Owner).expandAndContractSpeed = XConverter.ToInt32(textBoxAnimationSpeed.Text); ((MainForm)Owner).textBoxPassword.PasswordChar = Convert.ToChar(checkBoxHidePass.Checked ? '●' : '\0'); } else { MessageBox.Show("The database settings were not saved because no connection could be established.", "Something went wrong!", MessageBoxButtons.OK, MessageBoxIcon.Error); } if (checkBoxAutoGenerateComments.Checked != generateComments && checkBoxAutoGenerateComments.Checked) { ((MainForm)Owner).GenerateCommentsForAllItems(); } if (checkBoxShowTooltipsPermanently.Checked != showTooltipsPermanently) { ((MainForm)Owner).ExpandToShowPermanentTooltips(!checkBoxShowTooltipsPermanently.Checked); } ((MainForm)Owner).menuItemRevertQuery.Enabled = checkBoxCreateRevertQuery.Checked; }
//--------------------------------------------------------------------------------------------------------- /// <summary> /// Конвертация объекта типа Double в соответствующий числовой тип /// </summary> /// <param name="value">Значение</param> /// <param name="target_type">Целевой тип</param> /// <param name="parameter">Дополнительный параметр(реальный тип для преобразования)</param> /// <param name="culture">Культура</param> /// <returns>Значение</returns> //--------------------------------------------------------------------------------------------------------- public Object ConvertBack(Object value, Type target_type, Object parameter, CultureInfo culture) { return(XConverter.ToNumber(target_type, (Double)value)); }
private TargetTypeInformation BuildTargetTypeInformation(DataRow row) { var targetTypeInformation = new TargetTypeInformation(); targetTypeInformation.target_type = row["target_type"] != DBNull.Value ? XConverter.ToInt32(row["target_type"]) : -1; targetTypeInformation.tooltip = row["tooltip"] != DBNull.Value ? (string)row["tooltip"] : String.Empty; targetTypeInformation.parameterString1 = row["parameterString1"] != DBNull.Value ? (string)row["parameterString1"] : "Unused Parameter"; targetTypeInformation.parameterString2 = row["parameterString2"] != DBNull.Value ? (string)row["parameterString2"] : "Unused Parameter"; targetTypeInformation.parameterString3 = row["parameterString3"] != DBNull.Value ? (string)row["parameterString3"] : "Unused Parameter"; targetTypeInformation.parameterTooltip1 = row["parameterTooltip1"] != DBNull.Value ? (string)row["parameterTooltip1"] : String.Empty; targetTypeInformation.parameterTooltip2 = row["parameterTooltip2"] != DBNull.Value ? (string)row["parameterTooltip2"] : String.Empty; targetTypeInformation.parameterTooltip3 = row["parameterTooltip3"] != DBNull.Value ? (string)row["parameterTooltip3"] : String.Empty; return(targetTypeInformation); }
private void SaveSettings() { if (checkBoxChangeStaticInfo.Checked != Settings.Default.ChangeStaticInfo) { EntryOrGuidAndSourceType originalEntryOrGuidAndSourceType = ((MainForm)Owner).originalEntryOrGuidAndSourceType; ((MainForm)Owner).textBoxEntryOrGuid.Text = originalEntryOrGuidAndSourceType.entryOrGuid.ToString(); ((MainForm)Owner).comboBoxSourceType.SelectedIndex = ((MainForm)Owner).GetIndexBySourceType(originalEntryOrGuidAndSourceType.sourceType); } bool showTooltipsPermanently = Settings.Default.ShowTooltipsPermanently; bool generateComments = Settings.Default.GenerateComments; bool phaseHighlighting = Settings.Default.PhaseHighlighting; RNGCryptoServiceProvider rng = new RNGCryptoServiceProvider(); byte[] buffer = new byte[1024]; rng.GetBytes(buffer); string salt = BitConverter.ToString(buffer); rng.Dispose(); string decryptedPassword = textBoxPassword.Text; connectionString.Server = textBoxHost.Text; connectionString.UserID = textBoxUsername.Text; connectionString.Port = XConverter.ToUInt32(textBoxPort.Text); connectionString.Database = textBoxWorldDatabase.Text; if (textBoxPassword.Text.Length > 0) { connectionString.Password = textBoxPassword.Text; } Settings.Default.UseWorldDatabase = radioButtonConnectToMySql.Checked; Settings.Default.Save(); bool newConnectionSuccesfull = false; if (radioButtonConnectToMySql.Checked) { newConnectionSuccesfull = SAI_Editor_Manager.Instance.worldDatabase.CanConnectToDatabase(connectionString, false); } //! We also save the settings if no connection was made. It's possible the user unchecked //! the radioboxes, changed some settings and then set it back to no DB connection. if (newConnectionSuccesfull || !radioButtonConnectToMySql.Checked) { Settings.Default.Entropy = salt; Settings.Default.Host = textBoxHost.Text; Settings.Default.User = textBoxUsername.Text; Settings.Default.Password = decryptedPassword.ToSecureString().EncryptString(Encoding.Unicode.GetBytes(salt)); Settings.Default.Database = textBoxWorldDatabase.Text; Settings.Default.Port = textBoxPort.Text.Length > 0 ? XConverter.ToUInt32(textBoxPort.Text) : 0; Settings.Default.AutoConnect = checkBoxAutoConnect.Checked; if (radioButtonConnectToMySql.Checked) { ((MainForm)Owner).connectionString = connectionString; SAI_Editor_Manager.Instance.ResetDatabases(); } } Settings.Default.InstantExpand = checkBoxInstantExpand.Checked; Settings.Default.PromptToQuit = checkBoxPromptToQuit.Checked; Settings.Default.HidePass = checkBoxHidePass.Checked; Settings.Default.AnimationSpeed = XConverter.ToInt32(textBoxAnimationSpeed.Text); Settings.Default.PromptExecuteQuery = checkBoxPromptExecuteQuery.Checked; Settings.Default.ChangeStaticInfo = checkBoxChangeStaticInfo.Checked; Settings.Default.ShowTooltipsPermanently = checkBoxShowTooltipsPermanently.Checked; Settings.Default.GenerateComments = checkBoxAutoGenerateComments.Checked; Settings.Default.CreateRevertQuery = checkBoxCreateRevertQuery.Checked; Settings.Default.PhaseHighlighting = checkBoxPhaseHighlighting.Checked; Settings.Default.Save(); if (newConnectionSuccesfull) { ((MainForm)Owner).checkBoxAutoConnect.Checked = checkBoxAutoConnect.Checked; ((MainForm)Owner).textBoxHost.Text = textBoxHost.Text; ((MainForm)Owner).textBoxUsername.Text = textBoxUsername.Text; ((MainForm)Owner).textBoxPassword.Text = decryptedPassword; ((MainForm)Owner).textBoxWorldDatabase.Text = textBoxWorldDatabase.Text; ((MainForm)Owner).checkBoxAutoConnect.Checked = checkBoxAutoConnect.Checked; ((MainForm)Owner).expandAndContractSpeed = XConverter.ToInt32(textBoxAnimationSpeed.Text); ((MainForm)Owner).textBoxPassword.PasswordChar = Convert.ToChar(checkBoxHidePass.Checked ? '●' : '\0'); } else if (radioButtonConnectToMySql.Checked) //! Don't report this if there is no connection to be made anyway { MessageBox.Show("The database settings were not saved because no connection could be established. All other changed settings were saved.", "Something went wrong!", MessageBoxButtons.OK, MessageBoxIcon.Error); } if (checkBoxAutoGenerateComments.Checked != generateComments && checkBoxAutoGenerateComments.Checked) { ((MainForm)Owner).GenerateCommentsForAllItems(); } if (checkBoxShowTooltipsPermanently.Checked != showTooltipsPermanently) { ((MainForm)Owner).ExpandToShowPermanentTooltips(!checkBoxShowTooltipsPermanently.Checked); } if (checkBoxPhaseHighlighting.Checked != phaseHighlighting) { ((MainForm)Owner).listViewSmartScripts.Init(); } ((MainForm)Owner).HandleUseWorldDatabaseSettingChanged(); }
private EventTypeInformation BuildEventTypeInformation(DataRow row) { var eventTypeInformation = new EventTypeInformation(); eventTypeInformation.event_type = row["event_type"] != DBNull.Value ? XConverter.ToInt32(row["event_type"]) : -1; eventTypeInformation.tooltip = row["tooltip"] != DBNull.Value ? (string)row["tooltip"] : String.Empty; eventTypeInformation.parameterString1 = row["parameterString1"] != DBNull.Value ? (string)row["parameterString1"] : "Unused Parameter"; eventTypeInformation.parameterString2 = row["parameterString2"] != DBNull.Value ? (string)row["parameterString2"] : "Unused Parameter"; eventTypeInformation.parameterString3 = row["parameterString3"] != DBNull.Value ? (string)row["parameterString3"] : "Unused Parameter"; eventTypeInformation.parameterString4 = row["parameterString4"] != DBNull.Value ? (string)row["parameterString4"] : "Unused Parameter"; eventTypeInformation.parameterTooltip1 = row["parameterTooltip1"] != DBNull.Value ? (string)row["parameterTooltip1"] : String.Empty; eventTypeInformation.parameterTooltip2 = row["parameterTooltip2"] != DBNull.Value ? (string)row["parameterTooltip2"] : String.Empty; eventTypeInformation.parameterTooltip3 = row["parameterTooltip3"] != DBNull.Value ? (string)row["parameterTooltip3"] : String.Empty; eventTypeInformation.parameterTooltip4 = row["parameterTooltip4"] != DBNull.Value ? (string)row["parameterTooltip4"] : String.Empty; return(eventTypeInformation); }
private ActionTypeInformation BuildActionTypeInformation(DataRow row) { var actionTypeInformation = new ActionTypeInformation(); actionTypeInformation.action_type = row["action_type"] != DBNull.Value ? XConverter.ToInt32(row["action_type"]) : -1; actionTypeInformation.tooltip = row["tooltip"] != DBNull.Value ? (string)row["tooltip"] : String.Empty; actionTypeInformation.parameterString1 = row["parameterString1"] != DBNull.Value ? (string)row["parameterString1"] : "Unused Parameter"; actionTypeInformation.parameterString2 = row["parameterString2"] != DBNull.Value ? (string)row["parameterString2"] : "Unused Parameter"; actionTypeInformation.parameterString3 = row["parameterString3"] != DBNull.Value ? (string)row["parameterString3"] : "Unused Parameter"; actionTypeInformation.parameterString4 = row["parameterString4"] != DBNull.Value ? (string)row["parameterString4"] : "Unused Parameter"; actionTypeInformation.parameterString5 = row["parameterString5"] != DBNull.Value ? (string)row["parameterString5"] : "Unused Parameter"; actionTypeInformation.parameterString6 = row["parameterString6"] != DBNull.Value ? (string)row["parameterString6"] : "Unused Parameter"; actionTypeInformation.parameterTooltip1 = row["parameterTooltip1"] != DBNull.Value ? (string)row["parameterTooltip1"] : String.Empty; actionTypeInformation.parameterTooltip2 = row["parameterTooltip2"] != DBNull.Value ? (string)row["parameterTooltip2"] : String.Empty; actionTypeInformation.parameterTooltip3 = row["parameterTooltip3"] != DBNull.Value ? (string)row["parameterTooltip3"] : String.Empty; actionTypeInformation.parameterTooltip4 = row["parameterTooltip4"] != DBNull.Value ? (string)row["parameterTooltip4"] : String.Empty; actionTypeInformation.parameterTooltip5 = row["parameterTooltip5"] != DBNull.Value ? (string)row["parameterTooltip5"] : String.Empty; actionTypeInformation.parameterTooltip6 = row["parameterTooltip6"] != DBNull.Value ? (string)row["parameterTooltip6"] : String.Empty; return(actionTypeInformation); }