public static void ValidateMenuStrip(Int64 ModuleID, User UserID, ToolStripItemCollection Items, string FormName, ref ResourceManager RM, bool debug, SecureAndTranslateMode Mode) { foreach (ToolStripItem ts_item in Items) { string label = GetLabel(ref RM, FormName + "." + ts_item.Name, debug); if (((Mode & SecureAndTranslateMode.Transalte) != 0) && label != null && label != string.Empty && label.Length > 0) { ts_item.Text = label; } if ((Mode & SecureAndTranslateMode.Secure) != 0) { ts_item.Enabled = UserID.IsControlEnabledForUser(FormName + ts_item.Name); ts_item.Visible = UserID.IsControlVisibleForUser(FormName + ts_item.Name); } if (ts_item is ToolStripDropDownItem) { ToolStripDropDownItem tsdd_item = (ToolStripDropDownItem)ts_item; ValidateMenuStrip(ModuleID, UserID, tsdd_item.DropDownItems, FormName, ref RM, debug, Mode); } if (debug) { ts_item.ToolTipText = ts_item.Name + ":" + GetControlGroups(ModuleID, FormName, ts_item.Name); } } }
public static void SecureAndTranslate(Int64 ModuleID, User UserID, System.Windows.Forms.Control.ControlCollection controlCollection, ref ResourceManager RM, bool debug, SecureAndTranslateMode Mode) { foreach (Control C in controlCollection) { bool IsActive = false; bool IsVisible = false; bool SetLabel = false; if (C.Name != null && C.Name.Length > 0) { IsActive = UserID.IsControlEnabledForUser(C.FindForm().Name + C.Name); IsVisible = UserID.IsControlVisibleForUser(C.FindForm().Name + C.Name); } else { IsActive = true; IsVisible = true; } if ((Mode & SecureAndTranslateMode.Secure) != 0) { C.Visible = IsVisible; C.Enabled = IsActive; } switch (C.GetType().ToString()) { case "System.Windows.Forms.Label": SetLabel = true; break; case "System.Windows.Forms.Button": SetLabel = true; break; case "System.Windows.Forms.MenuStrip": MenuStrip Menu = (MenuStrip)C; ValidateMenuStrip(ModuleID, UserID, Menu.Items, C.FindForm().Name, ref RM, debug, Mode); break; case "System.Windows.Forms.TextBox": if ((Mode & SecureAndTranslateMode.Secure) != 0) { TextBox Edit = (TextBox)C; Edit.ReadOnly = !IsActive; } break; case "System.Windows.Forms.FlowLayoutPanel": FlowLayoutPanel FP = (FlowLayoutPanel)C; SecureAndTranslate(ModuleID, UserID, FP.Controls, ref RM, debug, Mode); break; case "System.Windows.Forms.GroupBox": SetLabel = true; GroupBox group = (GroupBox)C; SecureAndTranslate(ModuleID, UserID, group.Controls, ref RM, debug, Mode); break; case "System.Windows.Forms.CheckedListBox": break; case "System.Windows.Forms.CheckBox": SetLabel = true; break; case "System.Windows.Forms.ToolStrip": ToolStrip Tool = (ToolStrip)C; ValidateMenuStrip(ModuleID, UserID, Tool.Items, C.FindForm().Name, ref RM, debug, Mode); break; case "System.Windows.Forms.StatusStrip": StatusStrip Status = (StatusStrip)C; ValidateMenuStrip(ModuleID, UserID, Status.Items, C.FindForm().Name, ref RM, debug, Mode); break; case "System.Windows.Forms.ToolStripPanel": ContainerControl mycontainer = (ContainerControl)C; SecureAndTranslate(ModuleID, UserID, mycontainer.Controls, ref RM, debug, Mode); break; case "System.Windows.Forms.TabPage": SetLabel = true; Panel mytabpage = (Panel)C; SecureAndTranslate(ModuleID, UserID, mytabpage.Controls, ref RM, debug, Mode); break; case "System.Windows.Forms.Panel": case "System.Windows.Forms.SplitterPanel": case "System.Windows.Forms.ToolStripContentPanel": Panel myPanel = (Panel)C; SecureAndTranslate(ModuleID, UserID, myPanel.Controls, ref RM, debug, Mode); break; case "System.Windows.Forms.ToolStripContainer": ToolStripContainer tscontainer = (ToolStripContainer)C; SecureAndTranslate(ModuleID, UserID, tscontainer.Controls, ref RM, debug, Mode); break; case "System.Windows.Forms.SplitContainer": SplitContainer mySplit = (SplitContainer)C; SecureAndTranslate(ModuleID, UserID, mySplit.Controls, ref RM, debug, Mode); break; case "System.Windows.Forms.TabControl": TabControl tabControl = (TabControl)C; SecureAndTranslate(ModuleID, UserID, tabControl.Controls, ref RM, debug, Mode); break; case "System.Windows.Forms.ListView": ListView liste = (ListView)C; foreach (ColumnHeader Col in liste.Columns) { string sublabel = GetLabel(ref RM, C.FindForm().Name + "." + C.Name + "." + Col.Name, debug); if (((Mode & SecureAndTranslateMode.Transalte) != 0) && sublabel != null && sublabel != string.Empty && sublabel.Length > 0) { Col.Text = sublabel; } if ((Mode & SecureAndTranslateMode.Secure) != 0) { } } break; case "SynapseAdvancedControls.ObjectListView": ObjectListView oliste = (ObjectListView)C; oliste.MenuLabelColumns = GetLabel(ref RM, "ObjectListView.MenuLabelColumns", debug); oliste.MenuLabelGroupBy = GetLabel(ref RM, "ObjectListView.MenuLabelColumns", debug); oliste.MenuLabelLockGroupingOn = GetLabel(ref RM, "ObjectListView.MenuLabelLockGroupingOn", debug); oliste.MenuLabelSelectColumns = GetLabel(ref RM, "ObjectListView.MenuLabelSelectColumns", debug); oliste.MenuLabelSortAscending = GetLabel(ref RM, "ObjectListView.MenuLabelSortAscending", debug); oliste.MenuLabelSortDescending = GetLabel(ref RM, "ObjectListView.MenuLabelSortDescending", debug); oliste.MenuLabelTurnOffGroups = GetLabel(ref RM, "ObjectListView.MenuLabelTurnOffGroups", debug); oliste.MenuLabelUnlockGroupingOn = GetLabel(ref RM, "ObjectListView.MenuLabelUnlockGroupingOn", debug); oliste.MenuLabelUnsort = GetLabel(ref RM, "ObjectListView.MenuLabelUnsort", debug); foreach (OLVColumn Col in oliste.AllColumns) { string sublabel = GetLabel(ref RM, C.FindForm().Name + "." + C.Name + "." + Col.Text.Replace(' ', '_').ToUpper(), debug); if ((Mode & SecureAndTranslateMode.Secure) != 0) { bool CIsActive = UserID.IsControlEnabledForUser(C.FindForm().Name + C.Name + "." + Col.Text.Replace(' ', '_').ToUpper()); bool CIsVisible = UserID.IsControlVisibleForUser(C.FindForm().Name + C.Name + "." + Col.Text.Replace(' ', '_').ToUpper()); Col.IsVisible = CIsVisible; Col.IsEditable = CIsActive; } if (((Mode & SecureAndTranslateMode.Transalte) != 0) && sublabel != null && sublabel != string.Empty && sublabel.Length > 0) { Col.Text = sublabel; } } oliste.RebuildColumns(); break; case "SynapseCore.Controls.SynapseGraphic": SynapseGraphic graph = (SynapseGraphic)C; graph.CopyMenu = GetLabel(ref RM, "SynapseGraphic.CopyMenu", debug); graph.CurveOnlyMenu = GetLabel(ref RM, "SynapseGraphic.CurveOnlyMenu", debug); graph.CurvesMenu = GetLabel(ref RM, "SynapseGraphic.CurvesMenu", debug); graph.PageSetupMenu = GetLabel(ref RM, "SynapseGraphic.PageSetupMenu", debug); graph.PrintMenu = GetLabel(ref RM, "SynapseGraphic.PrintMenu", debug); graph.SaveAsMenu = GetLabel(ref RM, "SynapseGraphic.SaveAsMenu", debug); graph.SetDefaultScaleMenu = GetLabel(ref RM, "SynapseGraphic.SetDefaultScaleMenu", debug); graph.ShowAllCurvesMenu = GetLabel(ref RM, "SynapseGraphic.ShowAllCurvesMenu", debug); graph.ShowHideCurveMenu = GetLabel(ref RM, "SynapseGraphic.ShowHideCurveMenu", debug); graph.ShowHideLegendMenu = GetLabel(ref RM, "SynapseGraphic.ShowHideLegendMenu", debug); graph.ShowPointValuesMenu = GetLabel(ref RM, "SynapseGraphic.ShowPointValuesMenu", debug); graph.UndoAllZoomMenu = GetLabel(ref RM, "SynapseGraphic.UndoAllZoomMenu", debug); graph.UnZoomMenu = GetLabel(ref RM, "SynapseGraphic.UnZoomMenu", debug); break; default: if (C is UserControl) { if ((Mode & SecureAndTranslateMode.Secure) != 0) { C.Enabled = IsActive; C.Visible = IsVisible; } } break; } if (((Mode & SecureAndTranslateMode.Transalte) != 0) && SetLabel) { string label = GetLabel(ref RM, C.FindForm().Name + "." + C.Name, debug); if (label != null && label != string.Empty && label.Length > 0) { C.Text = label; } } if (C.ContextMenuStrip != null) { ValidateMenuStrip(ModuleID, UserID, C.ContextMenuStrip.Items, C.FindForm().Name, ref RM, debug, Mode); } if (debug) { System.Windows.Forms.ToolTip ToolTip = new System.Windows.Forms.ToolTip(); ToolTip.ToolTipTitle = "Synapse Security"; ToolTip.UseFading = true; ToolTip.UseAnimation = true; ToolTip.IsBalloon = true; ToolTip.ShowAlways = true; ToolTip.AutoPopDelay = 5000; ToolTip.InitialDelay = 500; ToolTip.ReshowDelay = 100; ToolTip.SetToolTip(C, C.FindForm().Name + "\n" + C.Name + "\n" + GetControlGroups(ModuleID, C.FindForm().Name, C.Name)); } } }