private void deletePolicyToolStripMenuItem_Click(object sender, EventArgs e) { if (TVPolicies.SelectedNode == null) { return; } Int64 SelPol = Convert.ToInt64(TVPolicies.SelectedNode.Name); PolicyObject obj = Program.net.GetPolicyObject(SelPol); if (obj == null) { return; } if (MessageBox.Show(this, "Do you want to delete the policy " + obj.Name + "?", Program.Title, MessageBoxButtons.YesNo, MessageBoxIcon.Exclamation, MessageBoxDefaultButton.Button2) != System.Windows.Forms.DialogResult.Yes) { return; } if (Program.net.DeletePolicy(obj.ID) == false) { MessageBox.Show(this, "Cannot delete policy: " + Program.net.GetLastError(), Program.Title, MessageBoxButtons.OK, MessageBoxIcon.Information); return; } TVPolicies.Nodes.Remove(TVPolicies.SelectedNode); }
public void Object_PolicyObject_Test() { PolicyObject pol = new PolicyObject(); pol.Condition = "1=1"; pol.Order = 1; pol.Data = "{Test:\"foo\",Data:\"bar\"}"; pol.DataAddtions1 = "Addition1"; pol.DataAddtions2 = "Addition2"; pol.DataAddtions3 = "Addition3"; pol.DataAddtions4 = "Addition4"; pol.DataAddtions5 = "Addition5"; pol.DT = new DateTime(2016, 1, 1, 0, 0, 0, 0); pol.Enabled = true; pol.Grouping = 123; pol.ID = 456; pol.MachineID = "D9C4A40A-86E5-4915-B106-CC184889A3C1"; pol.Name = "Test Policy"; pol.TimeStampCheck = new DateTime(2016, 11, 29, 13, 45, 51, 30); pol.Type = 555; pol.Version = 1; string JSON = JsonConvert.SerializeObject(pol); Assert.AreEqual("{\"ID\":456,\"Order\":1,\"Name\":\"Test Policy\",\"MachineID\":\"D9C4A40A-86E5-4915-B106-CC184889A3C1\",\"Grouping\":123,\"Data\":\"{Test:\\\"foo\\\",Data:\\\"bar\\\"}\",\"DT\":\"2016-01-01T00:00:00\",\"Version\":1,\"Enabled\":true,\"Type\":555,\"TimeStampCheck\":\"2016-11-29T13:45:51.03\",\"Condition\":\"1=1\",\"DataAddtions1\":\"Addition1\",\"DataAddtions2\":\"Addition2\",\"DataAddtions3\":\"Addition3\",\"DataAddtions4\":\"Addition4\",\"DataAddtions5\":\"Addition5\"}", JSON); }
private void deletePolicyToolStripMenuItem_Click(object sender, EventArgs e) { bool valid = false; Int64?PolID = GroupFolders.GetSelectedPolicyID(treeAction.SelectedNode, out valid); if (valid == false) { return; } PolicyObject obj = Program.net.GetPolicyObject(PolID.Value); if (obj == null) { return; } if (MessageBox.Show(this, "Do you want to delete the policy " + obj.Name + "?", Program.Title, MessageBoxButtons.YesNo, MessageBoxIcon.Exclamation, MessageBoxDefaultButton.Button2) != System.Windows.Forms.DialogResult.Yes) { return; } if (Program.net.DeletePolicy(obj.ID) == false) { MessageBox.Show(this, "Cannot delete policy: " + Program.net.GetLastError(), Program.Title, MessageBoxButtons.OK, MessageBoxIcon.Information); return; } treeAction.SelectedNode.Parent.Nodes.Remove(treeAction.SelectedNode); }
private void TVPolicies_AfterSelect(object sender, TreeViewEventArgs e) { Splitty.Panel2.Controls.Clear(); if (TVPolicies.SelectedNode == null) { SelectedPolicy = null; return; } SelectedPolicy = Convert.ToInt64(e.Node.Name); PolicyObject obj = Program.net.GetPolicyObject(SelectedPolicy.Value); if (obj == null) { MessageBox.Show(this, "Loading policy failed: " + Program.net.GetLastError(), Program.Title, MessageBoxButtons.OK, MessageBoxIcon.Exclamation); return; } else { PolicyElementInterface i = PolicyList.GetInstance(obj.Type); i.SetData(obj); UserControl ctl = (UserControl)i; ctl.Dock = DockStyle.Fill; Splitty.Panel2.Controls.Add(ctl); } }
public RESTStatus GetPolicyObject(SQLLib sql, object dummy, NetworkConnectionInfo ni, Int64 id) { if (ni.HasAcl(ACLFlags.ChangeServerSettings) == false) { ni.Error = "Access denied"; ni.ErrorID = ErrorFlags.AccessDenied; return(RESTStatus.Denied); } lock (ni.sqllock) { if (Policies.PolicyExsits(sql, id) == false) { ni.Error = "Invalid data"; ni.ErrorID = ErrorFlags.InvalidData; return(RESTStatus.NotFound); } } lock (ni.sqllock) { PolicyObj = GetPolicy(sql, id); } return(RESTStatus.Success); }
static public bool ContainsPolicy(PolicyObject obj, bool CheckData, bool CheckIDOnly) { if (LoadedPolicyObjects == null) { LoadedPolicyObjects = new List <LoadedPolicyObject>(); } bool ElementFound = false; foreach (LoadedPolicyObject pol in LoadedPolicyObjects) { if (CheckIDOnly == true) { if (pol.PolicyObject.ID != obj.ID) { continue; } ElementFound = true; } else { if (pol.PolicyObject.ID != obj.ID) { continue; } if (pol.PolicyObject.Name != obj.Name) { continue; } if (pol.PolicyObject.Type != obj.Type) { continue; } if (pol.PolicyObject.Version != obj.Version) { continue; } if (pol.PolicyObject.DT != obj.DT) { continue; } if (CheckData == true) { if (pol.PolicyObject.Data != obj.Data) { continue; } } ElementFound = true; } break; } return(ElementFound); }
public void TestClone() { PolicyObject obj = new PolicyObject(Guid.NewGuid(), new TranslateableLanguageItem(Guid.NewGuid()), true); PolicyObject newObject = obj.Clone() as PolicyObject; Assert.AreNotEqual(obj.Identifier, newObject.Identifier); Assert.AreNotEqual(obj.Name.Identifier, newObject.Name.Identifier); Assert.AreEqual(obj.Name.Value, newObject.Name.Value); Assert.AreEqual(obj.ReadOnly, newObject.ReadOnly); }
public static PolicyObject GetPolicy(SQLLib sql, Int64 ID) { PolicyObject PolicyObj = null; SqlDataReader dr = sql.ExecSQLReader("select * from Policies where ID=@id", new SQLParam("@id", ID)); while (dr.Read()) { PolicyObj = LoadPolicyDB(dr, true, false); } dr.Close(); return(PolicyObj); }
public bool SetData(FoxSDC_Common.PolicyObject obj) { Pol = obj; Cert = JsonConvert.DeserializeObject <PolicySigningCertificates>(obj.Data); if (Cert == null) { Cert = new PolicySigningCertificates(); } UpdateStatus(); return(true); }
public static void PrepareConsiderationDebugMessage(Clan clan, PolicyObject policyObject, KingdomDecision clanDecision, out TextObject debugLogMessage) { if (policyObject != null) { SetConsideredAction(out debugLogMessage, policyObject.Name, clanDecision, ConsiderationType.ChangingKingdomPolicy, revertPolicy: clan.Kingdom.ActivePolicies.Contains(policyObject)); } else { SetPossibleAction(out debugLogMessage, ConsiderationType.ChangingKingdomPolicy); } StringHelper.SetEntitiyProperties(debugLogMessage, "REFLECTING_CLAN", clan); }
public bool SetData(PolicyObject obj) { Pol = obj; CliSettings = JsonConvert.DeserializeObject <ClientSettingsPolicy>(obj.Data); if (CliSettings == null) { CliSettings = new ClientSettingsPolicy(); } UpdateStatus(); return(true); }
public bool SetData(PolicyObject obj) { Pol = obj; Debug.WriteLine("SetData: " + obj.Data); Test = JsonConvert.DeserializeObject <PolicyTesting>(obj.Data); if (Test == null) { Test = new PolicyTesting(); } return(true); }
public bool SetData(PolicyObject obj) { Pol = obj; WSUS = JsonConvert.DeserializeObject <WSUSPolicy>(obj.Data); if (WSUS == null) { WSUS = new WSUSPolicy(); } UpdateStatus(); return(true); }
public bool SetData(PolicyObject obj) { Pol = obj; Mapping = JsonConvert.DeserializeObject <PortMappingPolicy>(obj.Data); if (Mapping == null) { Mapping = new PortMappingPolicy(); } UpdateStatus(); return(true); }
public static bool Prefix(Clan clan, ref KingdomDecision?__result, KingdomDecisionProposalBehavior __instance) //Bool prefixes compete with each other and skip others, as well as original, if return false { try { bool SubSystemEnabled = SettingsHelper.SubSystemEnabled(SubSystemType.ElectionCooldowns, clan); bool SystemDebugEnabled = SettingsHelper.SystemDebugEnabled(AOSystems.PoliticsRebalance, DebugType.General, clan); if (!SubSystemEnabled && !SystemDebugEnabled) { return(true); } Kingdom kingdom = clan.Kingdom; __result = null; if (kingdom.UnresolvedDecisions.FirstOrDefault(x => x is KingdomPolicyDecision) == null && clan.Influence >= 200.0) { #if STABLE PolicyObject randomElement = DefaultPolicies.All.Where(x => !(SubSystemEnabled && AOCooldownManager.HasDecisionCooldown(new KingdomPolicyDecision(clan, x, kingdom.ActivePolicies.Contains(x)))) ).ToArray().GetRandomElement(); #else PolicyObject randomElement = PolicyObject.All.Where(x => !(SubSystemEnabled && AOCooldownManager.HasDecisionCooldown(new KingdomPolicyDecision(clan, x, kingdom.ActivePolicies.Contains(x)))) ).ToArray().GetRandomElement(); #endif bool revertPolicy = kingdom.ActivePolicies.Contains(randomElement); //ConsiderPolicyDelegate deConsiderPolicy = AccessHelper.GetDelegate<ConsiderPolicyDelegate, KingdomDecisionProposalBehavior>(__instance, "ConsiderPolicy"); if (randomElement != null && deConsiderPolicy !(__instance, clan, kingdom, randomElement, revertPolicy)) { __result = new KingdomPolicyDecision(clan, randomElement, revertPolicy); } if (SystemDebugEnabled) { PoliticsDebugHelper.PrepareConsiderationDebugMessage(clan, randomElement, __result, out TextObject debugLogMessage); MessageHelper.SimpleMessage(debugLogMessage); } } return(false); } catch (Exception ex) { MethodInfo?methodInfo = MethodBase.GetCurrentMethod() as MethodInfo; DebugHelper.HandleException(ex, methodInfo, "Harmony patch for KingdomDecisionProposalBehavior. GetRandomPolicyDecision"); return(true); } }
public bool SetData(FoxSDC_Common.PolicyObject obj) { Pol = obj; PP = JsonConvert.DeserializeObject <PackagePolicy>(obj.Data); if (PP == null) { PP = new PackagePolicy(); } if (PP.Packages == null) { PP.Packages = new List <long>(); } UpdateStatus(); return(true); }
public bool SetData(FoxSDC_Common.PolicyObject obj) { Pol = obj; Int64 selpol; if (Int64.TryParse(Pol.Data, out selpol) == false) { SelectedPolicy = null; } else { SelectedPolicy = selpol; } UpdateStatus(); return(true); }
public bool SetData(PolicyObject obj) { Pol = obj; Cert = JsonConvert.DeserializeObject <ReportingPolicyElement>(obj.Data); if (Cert == null) { Cert = new ReportingPolicyElement(); } if (Cert.ReportingElements == null) { Cert.ReportingElements = new List <string>(); } UpdateStatus(); return(true); }
private void lowLevelEditPolicyToolStripMenuItem_Click(object sender, EventArgs e) { if (TVPolicies.SelectedNode == null) { return; } Int64 SelPol = Convert.ToInt64(TVPolicies.SelectedNode.Name); PolicyObject obj = Program.net.GetPolicyObject(SelPol); if (obj == null) { return; } frmLowLevelEdit frm = new frmLowLevelEdit(obj); frm.ShowDialog(this); }
public RESTStatus GetPolicyObjectSigned(SQLLib sql, object dummy, NetworkConnectionInfo ni, Int64 id) { if (ni.HasAcl(ACLFlags.ComputerLogin) == false) { ni.Error = "Access denied"; ni.ErrorID = ErrorFlags.AccessDenied; return(RESTStatus.Denied); } lock (ni.sqllock) { if (Policies.PolicyExsits(sql, id) == false) { ni.Error = "Invalid data"; ni.ErrorID = ErrorFlags.InvalidData; return(RESTStatus.NotFound); } } lock (ni.sqllock) { SqlDataReader dr = sql.ExecSQLReader("select * from Policies where ID=@id", new SQLParam("@id", id)); while (dr.Read()) { PolicyObj = LoadPolicyDB(dr, true, true); } dr.Close(); } PolicyObjectSigned objs = new PolicyObjectSigned(); objs.Policy = PolicyObj; if (Certificates.Sign(objs, SettingsManager.Settings.UseCertificate) == false) { FoxEventLog.WriteEventLog("Cannot sign policy with Certificate " + SettingsManager.Settings.UseCertificate, System.Diagnostics.EventLogEntryType.Warning); ni.Error = "Cannot sign policy with Certificate " + SettingsManager.Settings.UseCertificate; ni.ErrorID = ErrorFlags.CannotSign; return(RESTStatus.ServerError); } PolicyObjSigned = objs; return(RESTStatus.Success); }
void UpdateStatus() { if (SelectedPolicy != null) { PolicyObject p = Program.net.GetPolicyObject(SelectedPolicy.Value); if (p == null) { lblLinkPolicy.Text = "Invalid policy"; } else { lblLinkPolicy.Text = p.Name; } } else { lblLinkPolicy.Text = "No policy"; } }
private void lowLevelEditPolicyToolStripMenuItem_Click(object sender, EventArgs e) { bool valid = false; Int64?PolID = GroupFolders.GetSelectedPolicyID(treeAction.SelectedNode, out valid); if (valid == false) { policyEnabledToolStripMenuItem.Enabled = false; } else { PolicyObject obj = Program.net.GetPolicyObject(PolID.Value); if (obj == null) { return; } frmLowLevelEdit frm = new frmLowLevelEdit(obj); frm.ShowDialog(this); } }
static PolicyObject LoadPolicyDB(SqlDataReader dr, bool withdata, bool CensorData) { PolicyObject po = new PolicyObject(); if (withdata == false) { po.Data = null; } else { po.Data = Convert.ToString(dr["DataBlob"]); } po.DT = SQLLib.GetDTUTC(dr["DT"]); po.Grouping = dr["Grouping"] is DBNull ? (Int64?)null : Convert.ToInt64(dr["Grouping"]); po.ID = Convert.ToInt64(dr["ID"]); po.MachineID = dr["MachineID"] is DBNull ? null : Convert.ToString(dr["MachineID"]); po.Name = Convert.ToString(dr["Name"]); po.Version = Convert.ToInt64(dr["Version"]); po.Enabled = Convert.ToBoolean(dr["Enabled"]); po.Type = Convert.ToInt32(dr["Type"]); if (CensorData == true && withdata == true) { if (po.Type == PolicyIDs.PortMapping) { try { PortMappingPolicy p = JsonConvert.DeserializeObject <PortMappingPolicy>(po.Data); p.ServerPort = 0; p.ServerServer = ""; po.Data = JsonConvert.SerializeObject(p); } catch { po.Data = null; } } } return(po); }
// Start is called before the first frame update void Start() { progress = 0; PolicyObject policyObject = new PolicyObject(); if (macLineEndings) { delimeter = "\n"; } schoolPolicies = policyObject.ParsePolicies(policies, delimeter); foreach (Policy policy in schoolPolicies) { Debug.Log("Name: " + policy.name); Debug.Log("Cost: " + policy.cost); Debug.Log("--"); } mainMenu.SetActive(true); pauseMenu.SetActive(false); endScreen.SetActive(false); }
private void contextMenuStrip1_Opening(object sender, CancelEventArgs e) { createpolicyToolStripMenuItem.Enabled = true; policyEnabledToolStripMenuItem.Enabled = false; lowLevelEditPolicyToolStripMenuItem.Enabled = false; deletePolicyToolStripMenuItem.Enabled = false; policyEnabledToolStripMenuItem.Text = "Enable/Disable polic&y"; if (TVPolicies.SelectedNode == null) { return; } deletePolicyToolStripMenuItem.Enabled = true; policyEnabledToolStripMenuItem.Enabled = true; if (Settings.Default.EnableDebug == true) { lowLevelEditPolicyToolStripMenuItem.Visible = true; lowLevelEditPolicyToolStripMenuItem.Enabled = true; } else { lowLevelEditPolicyToolStripMenuItem.Visible = false; lowLevelEditPolicyToolStripMenuItem.Enabled = false; } Int64 SelPol = Convert.ToInt64(TVPolicies.SelectedNode.Name); PolicyObject obj = Program.net.GetPolicyObject(SelPol); if (obj == null) { policyEnabledToolStripMenuItem.Enabled = false; } else { policyEnabledToolStripMenuItem.Enabled = true; policyEnabledToolStripMenuItem.Text = obj.Enabled == true ? "Disable polic&y" : "Enable polic&y"; } }
private void policyEnabledToolStripMenuItem_Click(object sender, EventArgs e) { if (TVPolicies.SelectedNode == null) { return; } Int64 SelPol = Convert.ToInt64(TVPolicies.SelectedNode.Name); PolicyObject obj = Program.net.GetPolicyObject(SelPol); if (obj == null) { return; } if (Program.net.EnableDisablePolicy(obj.ID, !obj.Enabled) == false) { MessageBox.Show(this, "Cannot enable/disable policy: " + Program.net.GetLastError(), Program.Title, MessageBoxButtons.OK, MessageBoxIcon.Information); return; } TVPolicies.SelectedNode.Text = obj.Name + (obj.Enabled == false ? "" : " [disabled]"); }
private void policyEnabledToolStripMenuItem_Click(object sender, EventArgs e) { bool valid = false; Int64?PolID = GroupFolders.GetSelectedPolicyID(treeAction.SelectedNode, out valid); if (valid == false) { return; } PolicyObject obj = Program.net.GetPolicyObject(PolID.Value); if (obj == null) { return; } if (Program.net.EnableDisablePolicy(obj.ID, !obj.Enabled) == false) { MessageBox.Show(this, "Cannot enable/disable policy: " + Program.net.GetLastError(), Program.Title, MessageBoxButtons.OK, MessageBoxIcon.Information); return; } treeAction.SelectedNode.Text = obj.Name + (obj.Enabled == false ? "" : " [disabled]"); }
private void treeAction_AfterSelect(object sender, TreeViewEventArgs e) { Splitty.Panel2.Controls.Clear(); switch (e.Node.Name) { case "server": { ctlFirstPage ctl = new ctlFirstPage(); ctl.Dock = DockStyle.Fill; Splitty.Panel2.Controls.Add(ctl); break; } case "unapprovcomputer": { ctlListPCs ctl = new ctlListPCs(false, null); ctl.Dock = DockStyle.Fill; Splitty.Panel2.Controls.Add(ctl); break; } case "allcomputers": { ctlListPCs ctl = new ctlListPCs(null, null); ctl.Dock = DockStyle.Fill; Splitty.Panel2.Controls.Add(ctl); break; } case "allprograms": { ctlAddRemovePrograms ctl = new ctlAddRemovePrograms(""); ctl.Dock = DockStyle.Fill; Splitty.Panel2.Controls.Add(ctl); break; } case "alldiskdata": { ctlListDiskData ctl = new ctlListDiskData(""); ctl.Dock = DockStyle.Fill; Splitty.Panel2.Controls.Add(ctl); break; } case "alleventlogs": { ctlEventLogs ctl = new ctlEventLogs(); ctl.Dock = DockStyle.Fill; Splitty.Panel2.Controls.Add(ctl); break; } case "allstartup": { ctlStartupItems ctl = new ctlStartupItems(""); ctl.Dock = DockStyle.Fill; Splitty.Panel2.Controls.Add(ctl); break; } #if ENABLECHAT case "pendingchats": { ctlPendingChats ctl = new ctlPendingChats(); ctl.Dock = DockStyle.Fill; Splitty.Panel2.Controls.Add(ctl); break; } #endif case "uploaddownload": { ctlUploadDownloadStatus ctl = new ctlUploadDownloadStatus(); ctl.Dock = DockStyle.Fill; Splitty.Panel2.Controls.Add(ctl); break; } case "simpletasks": { ctlSimpleTasks ctl = new ctlSimpleTasks(""); ctl.Dock = DockStyle.Fill; Splitty.Panel2.Controls.Add(ctl); break; } } SelectedGroup = null; SelectedPolicy = null; if (GroupFolders.AfterSelect(treeAction, e, out SelectedGroup, out SelectedPolicy) == true) { if (SelectedGroup != null) { ctlListPCs ctl = new ctlListPCs(null, SelectedGroup); ctl.Dock = DockStyle.Fill; Splitty.Panel2.Controls.Add(ctl); } if (SelectedPolicy != null) { PolicyObject obj = Program.net.GetPolicyObject(SelectedPolicy.Value); if (obj == null) { MessageBox.Show(this, "Loading policy failed: " + Program.net.GetLastError(), Program.Title, MessageBoxButtons.OK, MessageBoxIcon.Exclamation); return; } else { PolicyElementInterface i = PolicyList.GetInstance(obj.Type); i.SetData(obj); UserControl ctl = (UserControl)i; ctl.Dock = DockStyle.Fill; Splitty.Panel2.Controls.Add(ctl); } } } }
public frmLowLevelEdit(PolicyObject Pol) { this.Pol = Pol; InitializeComponent(); }
public RESTStatus ConnectWSServerMappingPort(SQLLib sql, NetInt64 ID, NetworkConnectionInfo ni) { if (ni.HasAcl(ACLFlags.ComputerLogin) == false) { ni.Error = "Access denied"; ni.ErrorID = ErrorFlags.AccessDenied; return(RESTStatus.Denied); } List <PolicyObject> pols = Policies.GetPolicyForComputerInternal(sql, ni.Username); PolicyObject FoundPolicy = null; foreach (PolicyObject p in pols) { if (p.ID == ID.Data && p.Type == PolicyIDs.PortMapping) { FoundPolicy = p; break; } } if (FoundPolicy == null) { ni.Error = "Not found"; ni.ErrorID = ErrorFlags.NotAccepted; return(RESTStatus.Denied); } PortMappingPolicy pmp = JsonConvert.DeserializeObject <PortMappingPolicy>(Policies.GetPolicy(sql, FoundPolicy.ID).Data); IPAddress ip; IPHostEntry ipaddr; if (IPAddress.TryParse(pmp.ServerServer, out ip) == false) { ipaddr = Dns.GetHostEntry(pmp.ServerServer); } else { ipaddr = new IPHostEntry(); ipaddr.AddressList = new IPAddress[] { ip }; } if (ipaddr == null) { ni.Error = "Cannot resolve"; ni.ErrorID = ErrorFlags.NoData; return(RESTStatus.Fail); } if (ipaddr.AddressList.Length == 0) { ni.Error = "Resolve - no data"; ni.ErrorID = ErrorFlags.NoData; return(RESTStatus.Fail); } Socket socket; try { socket = new Socket(ipaddr.AddressList[0].AddressFamily, SocketType.Stream, ProtocolType.Tcp); socket.Connect(ipaddr.AddressList[0], pmp.ServerPort); } catch (Exception ee) { Debug.WriteLine("Cannot connect " + ee.ToString()); ni.Error = "Resolve - no data"; ni.ErrorID = ErrorFlags.NoData; return(RESTStatus.Fail); } string SessionID = ""; RemoteNetworkConnectionWSCrosser.CreateCustomAgentConnection <WS_ServerPortMappingConnection>(ni.Username, ref SessionID, i => i.InitThis(ref SessionID, socket)); Res = new PushConnectNetworkResult(); Res.ConnectedGUID = SessionID; Res.Result = 0; return(RESTStatus.Success); }
private void contextMenuStrip1_Opening(object sender, CancelEventArgs e) { createGroupToolStripMenuItem.Enabled = false; deleteGroupToolStripMenuItem.Enabled = false; refreshGroupToolStripMenuItem.Enabled = false; renameGroupToolStripMenuItem.Enabled = false; createpolicyToolStripMenuItem.Enabled = false; deletePolicyToolStripMenuItem.Enabled = false; policyEnabledToolStripMenuItem.Enabled = false; lowLevelEditPolicyToolStripMenuItem.Enabled = false; policyEnabledToolStripMenuItem.Text = "Enable/Disable polic&y"; if (treeAction.SelectedNode == null) { return; } if (treeAction.SelectedNode.Name.StartsWith("grp:") == true) { createpolicyToolStripMenuItem.Enabled = true; createGroupToolStripMenuItem.Enabled = true; refreshGroupToolStripMenuItem.Enabled = true; if (treeAction.SelectedNode.Name.StartsWith("grp:root") == false) { deleteGroupToolStripMenuItem.Enabled = true; renameGroupToolStripMenuItem.Enabled = true; createsimpleTasksInThisGroupToolStripMenuItem.Enabled = true; } else { deleteGroupToolStripMenuItem.Enabled = false; renameGroupToolStripMenuItem.Enabled = false; createsimpleTasksInThisGroupToolStripMenuItem.Enabled = false; } } else { createsimpleTasksInThisGroupToolStripMenuItem.Enabled = false; createGroupToolStripMenuItem.Enabled = false; deleteGroupToolStripMenuItem.Enabled = false; refreshGroupToolStripMenuItem.Enabled = false; renameGroupToolStripMenuItem.Enabled = false; } if (treeAction.SelectedNode.Name.StartsWith("pol:") == true) { deletePolicyToolStripMenuItem.Enabled = true; policyEnabledToolStripMenuItem.Enabled = true; if (Settings.Default.EnableDebug == true) { lowLevelEditPolicyToolStripMenuItem.Visible = true; lowLevelEditPolicyToolStripMenuItem.Enabled = true; } else { lowLevelEditPolicyToolStripMenuItem.Visible = false; lowLevelEditPolicyToolStripMenuItem.Enabled = false; } bool valid = false; Int64?PolID = GroupFolders.GetSelectedPolicyID(treeAction.SelectedNode, out valid); if (valid == false) { policyEnabledToolStripMenuItem.Enabled = false; } else { PolicyObject obj = Program.net.GetPolicyObject(PolID.Value); if (obj == null) { policyEnabledToolStripMenuItem.Enabled = false; } else { policyEnabledToolStripMenuItem.Enabled = true; policyEnabledToolStripMenuItem.Text = obj.Enabled == true ? "Disable polic&y" : "Enable polic&y"; } } } }