public void SetButtonStates() { if (InvokeRequired) { BeginInvoke(new SetButtonStatesDelegate(SetButtonStates)); } else { bool projectOpen = false; ClientBaseProtocol.Permissions permissions = new ClientBaseProtocol.Permissions(false, false, false); if (frmFlowChart != null) { projectOpen = frmFlowChart.State.ProjectAttached; permissions = frmFlowChart.State.Permissions; // Uncomment to enable create/modify always. //permissions.Create = true; //permissions.Modify = true; } barManager1.Commands["File.PrintPreview"].Enabled = projectOpen; barManager1.Commands["File.Print"].Enabled = projectOpen; barManager1.Commands["File.Save"].Enabled = projectOpen; barManager1.Commands["File.Close"].Enabled = projectOpen; barManager1.Commands["View.ZoomIn"].Enabled = projectOpen; barManager1.Commands["View.ZoomOut"].Enabled = projectOpen; barManager1.Commands["View.ZoomToVisible"].Enabled = projectOpen; barManager1.Commands["View.ZoomToSelected"].Enabled = projectOpen; barManager1.Commands["View.ShowAreas"].Enabled = projectOpen; barManager1.Commands["View.ShowModels"].Enabled = projectOpen; barManager1.Commands["View.ShowGraphics"].Enabled = projectOpen; barManager1.Commands["View.ShowLinks"].Enabled = projectOpen; barManager1.Commands["View.ShowTags"].Enabled = projectOpen; barManager1.Commands["Tools.Unlock(Demo)"].Enabled = projectOpen; barManager1.Commands["Selection.SelectItems"].Enabled = projectOpen; barManager1.Commands["Selection.SelectLinks"].Enabled = projectOpen; barManager1.Commands["Mode.Modify"].Enabled = projectOpen && permissions.Modify; barManager1.Commands["Mode.CreateLink"].Enabled = projectOpen && permissions.Create; stencilChooser1.Enabled = projectOpen && permissions.Create; barManager1.Commands["Edit.Cut"].Enabled = projectOpen && permissions.Delete; barManager1.Commands["Edit.Copy"].Enabled = projectOpen; barManager1.Commands["Edit.Delete"].Enabled = projectOpen; barManager1.Commands["Edit.Paste"].Enabled = projectOpen && permissions.Create; barManager1.Commands["Edit.Undo"].Enabled = projectOpen && frmFlowChart.State.ClientProtocol.UndoAvailable; barManager1.Commands["Edit.Redo"].Enabled = projectOpen && frmFlowChart.State.ClientProtocol.RedoAvailable; if (frmFlowChart != null) { frmFlowChart.State.SelectItems = true; frmFlowChart.State.SelectLinks = false; } ((IBarCheckableCommand)barManager1.Commands["Selection.SelectItems"]).Checked = true; ((IBarCheckableCommand)barManager1.Commands["Selection.SelectLinks"]).Checked = false; } }
public void PermissionsChanged(ClientBaseProtocol.Permissions permissions) { frmFlowChart.State.Permissions = permissions; SetButtonStates(); }