private void ButtonXDelActionClick(object sender, EventArgs e) { if (AI == null) { MessageBox.Show(Resources.openAIPolicy + Resources.delAS); return; } if (listBox_Controller.SelectedIndex == -1) return; if (SafeMode && MessageBox.Show(Resources.sureDelete + Resources.ASNamed + textBoxX_ActionName.Text + Resources.QMark, Resources.DelAction, MessageBoxButtons.YesNo) == DialogResult.No) return; var cSelectedIndex = listBox_Controller.SelectedIndex; var asSelectedIndex = listBox_ActionSet.SelectedIndex; var actionSetCount = AI.ActionController[cSelectedIndex].ActionSetsCount; if (asSelectedIndex == -1) { MessageBox.Show(Resources.noAS); return; } var actionSet = new ActionSet[actionSetCount - 1]; for (var i = 0; i < actionSetCount - 1; i++) { if (i < asSelectedIndex) actionSet[i] = AI.ActionController[cSelectedIndex].ActionSet[i]; if (i >= asSelectedIndex) actionSet[i] = AI.ActionController[cSelectedIndex].ActionSet[i + 1]; } AI.ActionController[cSelectedIndex].ActionSetsCount = AI.ActionController[cSelectedIndex].ActionSetsCount - 1; AI.ActionController[cSelectedIndex].ActionSet = actionSet; listBox_ActionSet.Items.Clear(); foreach (var t in AI.ActionController[cSelectedIndex].ActionSet) { var iD = t.ID; listBox_ActionSet.Items.Add("[" + iD.ToString(CultureInfo.InvariantCulture) + "] " + t.Name); } textBoxX_Condition.Clear(); listBox_Procedure.Items.Clear(); }
private void ButtonXAddActionClick(object sender, EventArgs e) { var actionID = 0; if (AI == null) { MessageBox.Show(Resources.openAIPolicy + Resources.AddAS); return; } if (listBox_Controller.SelectedIndex == -1) return; if (textBoxX_ActionName.Text == "") { MessageBox.Show(Resources.EnterAS); return; } var cSelectedIndex = listBox_Controller.SelectedIndex; var asSelectedIndex = listBox_ActionSet.SelectedIndex; var actionSetCount = AI.ActionController[cSelectedIndex].ActionSetsCount; if (Program.IsNumber(textBoxX_ActionID.Text)) { actionID = Convert.ToInt32(textBoxX_ActionID.Text); for (var i = 0; i < actionSetCount; i++) { if (actionID != AI.ActionController[cSelectedIndex].ActionSet[i].ID) continue; MessageBox.Show(Resources.ActionID + actionID + Resources.Exists); return; } } if (asSelectedIndex == -1) asSelectedIndex = actionSetCount; var actionSet = new ActionSet[actionSetCount + 1]; for (var j = 0; j <= actionSetCount; j++) { if (j < asSelectedIndex) actionSet[j] = AI.ActionController[cSelectedIndex].ActionSet[j]; if (j > asSelectedIndex) actionSet[j] = AI.ActionController[cSelectedIndex].ActionSet[j - 1]; } actionSet[asSelectedIndex] = new ActionSet(); actionSet[asSelectedIndex].Version = 11; if (textBoxX_ActionID.Text == "") { var asCount = actionSetCount; for (var k = 0; k < actionSetCount; k++) if (asCount < AI.ActionController[cSelectedIndex].ActionSet[k].ID) asCount = AI.ActionController[cSelectedIndex].ActionSet[k].ID; for (var x = 0; x <= asCount; x++) { for (var y = 0; y < actionSetCount; y++) if (x == AI.ActionController[cSelectedIndex].ActionSet[y].ID) actionSet[asSelectedIndex].ID = -1; if (actionSet[asSelectedIndex].ID != -1) { actionSet[asSelectedIndex].ID = x; break; } actionSet[asSelectedIndex].ID = x; } } else actionSet[asSelectedIndex].ID = actionID; var tmpFlags = new byte[3]; tmpFlags[0] = 1; var flags = tmpFlags; actionSet[asSelectedIndex].Flags = flags; actionSet[asSelectedIndex].Name = textBoxX_ActionName.Text; actionSet[asSelectedIndex].Condition = new Condition(); actionSet[asSelectedIndex].Condition.OperID = 3; actionSet[asSelectedIndex].Condition.ArgBytes = 4; var value = new byte[] { 0, 0, 128, 63 }; actionSet[asSelectedIndex].Condition.Value = value; actionSet[asSelectedIndex].Condition.SubNodeL = 0; actionSet[asSelectedIndex].Condition.SubNodeR = 0; actionSet[asSelectedIndex].Condition.ConditionType = 3; actionSet[asSelectedIndex].ProcedureCount = 1; actionSet[asSelectedIndex].Procedure = new Procedure[1]; actionSet[asSelectedIndex].Procedure[0] = new Procedure(); actionSet[asSelectedIndex].Procedure[0].Type = 2; var unicode = Encoding.Unicode; var rageMsg = unicode.GetBytes("RaGEZONE Forums - http://Forum.RaGEZONE.com"); var msgSize = rageMsg.Length + 2; var msg = new byte[msgSize]; Array.Copy(rageMsg, msg, rageMsg.Length); msg[rageMsg.Length] = 0; msg[rageMsg.Length + 1] = 0; var parameter = new object[] { msgSize, msg }; actionSet[asSelectedIndex].Procedure[0].Parameter = parameter; actionSet[asSelectedIndex].Procedure[0].Target = 0; AI.ActionController[cSelectedIndex].ActionSetsCount = AI.ActionController[cSelectedIndex].ActionSetsCount + 1; AI.ActionController[cSelectedIndex].ActionSet = actionSet; listBox_ActionSet.Items.Clear(); foreach (var t in AI.ActionController[cSelectedIndex].ActionSet) { var iD = t.ID; listBox_ActionSet.Items.Add("[" + iD.ToString(CultureInfo.InvariantCulture) + "] " + t.Name); } textBoxX_Condition.Clear(); listBox_Procedure.Items.Clear(); }