void AddGroup(AnnGroupsRoles groupRoles, string groupName, AnnRoles roles) { groupRoles.GroupRoles.Add(groupName, roles); groupRoles.GroupUsers.Add(groupName, new List <string>()); // Fill Groups Combo boxed GroupItem item = new GroupItem(groupName, roles); _chkLstGroups.Items.Add(item); _lstGroups.Items.Add(item); }
XmlElement WriteGroup(XmlDocument document, string groupName, AnnRoles roles, List <string> users) { XmlElement group = document.CreateElement("Group"); group.SetAttribute("Name", groupName); string rolesValue = string.Empty; string usersValue = string.Empty; foreach (string role in roles) { rolesValue += role + ";"; } foreach (string user in users) { usersValue += user + ";"; } group.SetAttribute("Roles", rolesValue); group.SetAttribute("Users", usersValue); return(group); }
private void _btnLoad_Click(object sender, EventArgs e) { using (OpenFileDialog openFileDialog = new OpenFileDialog()) { openFileDialog.Filter = "Annotations Roles File (.xml)|*.xml"; if (openFileDialog.ShowDialog(this) == DialogResult.OK) { XmlDocument document = new XmlDocument(); document.Load(openFileDialog.FileName); XmlNodeList groups = document.GetElementsByTagName("Group"); if (groups != null && groups.Count > 0) { _lstUsers.Items.Clear(); _lstGroups.Items.Clear(); _chkLstGroups.Items.Clear(); AnnGroupsRoles groupRoles = new AnnGroupsRoles(); _automationManager.GroupsRoles = _groupsRoles; foreach (XmlNode group in groups) { XmlAttributeCollection attribs = group.Attributes; if (attribs != null) { string groupName = attribs["Name"].Value; if (!string.IsNullOrEmpty(groupName)) { string rolesValue = attribs["Roles"].Value; string usersValue = attribs["Users"].Value; List <string> users = new List <string>(usersValue.Split(';')); AnnRoles roles = new AnnRoles(); roles.AddRange(rolesValue.Split(';')); AddGroup(groupRoles, groupName, roles); // Fill Users foreach (string user in users) { AddUser(groupRoles, groupName, user); } } } if (_groupsRoles.GroupRoles != null) { _groupsRoles.GroupRoles.Clear(); } if (groupRoles.GroupRoles != null) { foreach (var item in groupRoles.GroupRoles) { _groupsRoles.GroupRoles.Add(item.Key, item.Value); } } if (_groupsRoles.GroupUsers != null) { _groupsRoles.GroupUsers.Clear(); } if (groupRoles.GroupUsers != null) { foreach (var item in groupRoles.GroupUsers) { _groupsRoles.GroupUsers.Add(item.Key, item.Value); } } } } else { Messager.ShowError(this, "Invalid Roles File"); } } UpdateUI(); } }
protected override void OnLoad(EventArgs e) { if (!DesignMode) { _automationManager = new AnnAutomationManager(); _automationManager.GroupsRoles = _groupsRoles; _automationManager.RedactionRealizePassword = string.Empty; _automationManager.CreateDefaultObjects(); _managerHelper = new AutomationManagerHelper(_automationManager); _managerHelper.CreateToolBar(); tabControl1.TabPages[1].Controls.Add(_managerHelper.ToolBar); _imageViewer = new AutomationImageViewer(); _imageViewer.KeyDown += new KeyEventHandler(_imageViewer_KeyDown); tabControl1.TabPages[1].Controls.Add(_imageViewer); _managerHelper.ToolBar.Dock = DockStyle.Right; _managerHelper.ToolBar.AutoSize = false; _managerHelper.ToolBar.Appearance = ToolBarAppearance.Flat; _managerHelper.ToolBar.BringToFront(); _imageViewer.Dock = DockStyle.Fill; _imageViewer.UseDpi = false; _imageViewer.ImageHorizontalAlignment = Leadtools.Controls.ControlAlignment.Center; _imageViewer.ImageBorderColor = Color.Black; _imageViewer.ImageBorderThickness = 1; _imageViewer.BringToFront(); AutomationInteractiveMode automationInteractiveMode = new AutomationInteractiveMode(); automationInteractiveMode.MouseButtons = MouseButtons.Left | MouseButtons.Right; _imageViewer.InteractiveModes.Add(automationInteractiveMode); using (RasterCodecs codec = new RasterCodecs()) { _imageViewer.Image = codec.Load(DemosGlobal.ImagesFolder + @"\ocr1.tif"); _imageViewer.Zoom(Leadtools.Controls.ControlSizeMode.FitWidth, 1, LeadPoint.Empty); } _automation = new AnnAutomation(_automationManager, _imageViewer); // Update the container size _automation.Container.Size = _automation.Container.Mapper.SizeToContainerCoordinates(LeadSizeD.Create(_imageViewer.Image.ImageWidth, _imageViewer.Image.ImageHeight)); _automation.EditText += new EventHandler <AnnEditTextEventArgs>(automation_EditText); _automation.OnShowContextMenu += new EventHandler <AnnAutomationEventArgs>(automation_OnShowContextMenu); _automation.OnShowObjectProperties += new EventHandler <AnnAutomationEventArgs>(automation_OnShowObjectProperties); _automation.LockObject += new EventHandler <AnnLockObjectEventArgs>(automation_LockObject); _automation.UnlockObject += new EventHandler <AnnLockObjectEventArgs>(automation_UnlockObject); _automation.SetCursor += new EventHandler <AnnCursorEventArgs>(automation_SetCursor); _automation.RestoreCursor += new EventHandler(automation_RestoreCursor); FlipReverseText(_automationManager.RenderingEngine, true); _automation.Active = true; _chkLstGroups.CheckOnClick = true; _chkLstGroups.ItemCheck += new ItemCheckEventHandler(_chkLstGroups_ItemCheck); _chkLstGroups.Enabled = _lstUsers.Items.Count > 0 && _lstUsers.SelectedIndex >= 0; _chkLstRoles.CheckOnClick = true; _chkLstRoles.ItemCheck += new ItemCheckEventHandler(_chkLstRoles_ItemCheck); _chkLstRoles.Items.Add(new CheckRoleItem(AnnRoles.View)); _chkLstRoles.Items.Add(new CheckRoleItem(AnnRoles.ViewAll)); _chkLstRoles.Items.Add(new CheckRoleItem(AnnRoles.Edit)); _chkLstRoles.Items.Add(new CheckRoleItem(AnnRoles.EditAll)); _chkLstRoles.Items.Add(new CheckRoleItem(CustomRoles.RulersOnly)); _lstGroups.SelectedIndexChanged += new EventHandler(_lstGroups_SelectedIndexChanged); _chkLstRoles.Enabled = _lstGroups.Items.Count > 0 && _lstGroups.SelectedIndex >= 0; _lstUsers.SelectedIndexChanged += new EventHandler(_lstUsers_SelectedIndexChanged); _groupsRoles.GenerateRole += new EventHandler <AnnOperationInfoEventArgs>(_groupsRoles_GenerateRole); AnnRoles medicalRoles = new AnnRoles(); medicalRoles.Add(CustomRoles.RulersOnly); AddGroup(_groupsRoles, "Medical", medicalRoles); AnnRoles documentRoles = new AnnRoles(); documentRoles.Add(AnnRoles.View); documentRoles.Add(AnnRoles.Edit); AddGroup(_groupsRoles, "Document", documentRoles); AnnRoles adminRoles = new AnnRoles(); adminRoles.Add(AnnRoles.EditAll); AddGroup(_groupsRoles, "Admins", adminRoles); AnnRoles guestRoles = new AnnRoles(); guestRoles.Add(AnnRoles.ViewAll); AddGroup(_groupsRoles, "Guests", guestRoles); AddUser(_groupsRoles, "Medical", "MedicalUser"); AddUser(_groupsRoles, "Document", "DocumentUser"); AddUser(_groupsRoles, "Guests", "Guest"); AddUser(_groupsRoles, "Admins", "Admin"); OnResize(EventArgs.Empty); } base.OnLoad(e); }
public GroupItem(string name, AnnRoles roles) { _groupName = name; _roles = roles; }
public GroupItem(string name) { _groupName = name; _roles = new AnnRoles(); }