Beispiel #1
0
        protected override void Initialize(ToolStrip toolStrip)
        {
            base.Initialize(toolStrip);

            this.rendererFor = toolStrip;

            toolStrip.FindForm().Activated  += this.Form_Activated;
            toolStrip.FindForm().Deactivate += this.Form_Deactivated;
        }
Beispiel #2
0
        private static void SetToolStripMenuItemText(ToolStripItem item, List <int> indexes)
        {
            if (__RootNode != null)
            {
                string    formName = string.Empty;
                ToolStrip owner    = item.Owner;
                while (owner is ToolStripDropDownMenu)
                {
                    owner = (owner as ToolStripDropDownMenu).OwnerItem.Owner;
                }
                formName = owner.FindForm().Name;

                System.Text.StringBuilder builder = new System.Text.StringBuilder();

                builder.AppendFormat("screen[@name='{0}']", formName);

                for (int i = 0; i < indexes.Count; i++)
                {
                    builder.AppendFormat("/menu{0}[@index='{1}']", i == 0 ? string.Empty : "item", indexes[i]);
                }

                XmlNode node = __RootNode.SelectSingleNode(builder.ToString());
                if (node != null)
                {
                    if (node.Attributes["value"] != null)
                    {
                        item.Text = node.Attributes["value"].Value;
                    }
                }
            }
        }
Beispiel #3
0
        void defaultButton_Click(object sender, EventArgs e)
        {
            ToolStrip ts = (sender as ToolStripButton).Owner as ToolStrip;

            if (ts.FindForm().Equals(_defaultOwner))
            {
                FreeToolStrip(ts);
            }
            else
            {
                FixToolStrip(ts, true);
            }
        }
Beispiel #4
0
        private static bool Enable(ToolStrip menuStrip, User user)
        {
            Form owner = menuStrip.FindForm();

            if (owner != null)
            {
                if (user == null)
                {
                    PermissionForm pf = owner as PermissionForm;
                    if (pf != null)
                    {
                        user = pf.User;
                    }
                }
                if (user != null)
                {
                    menuStrip.Enabled = true;
                    int    nofinded         = 0;
                    string formName         = owner.Name;
                    PermissionCollection ps = user.GetAllPermissions(false);
                    foreach (ToolStripItem c in menuStrip.Items)
                    {
                        string controlName = c.Name;
                        if (ps.ContainsControl(formName, menuStrip.Name, controlName))
                        {
                            c.Enabled = true;
                        }
                        else
                        {
                            c.Enabled = false;
                            nofinded++;
                            if (c.EnableChildrenForUser(user))
                            {
                                nofinded--;
                            }
                        }
                    }
                    if (nofinded == menuStrip.Items.Count)
                    {
                        menuStrip.Enabled = false; return(false);
                    }
                    else
                    {
                        return(true);
                    }
                }
            }
            return(false);
        }
Beispiel #5
0
        private static bool Disable(ToolStrip menuStrip, User user)
        {
            Form owner = menuStrip.FindForm();

            if (owner != null)
            {
                if (user == null)
                {
                    PermissionForm pf = owner as PermissionForm;
                    if (pf != null)
                    {
                        user = pf.User;
                    }
                }
                if (user != null)
                {
                    menuStrip.Enabled = true;
                    string formName         = owner.Name;
                    string controlName      = menuStrip.Name;
                    PermissionCollection ps = user.GetAllPermissions(false);
                    if (ps.ExceptControl(formName, controlName))
                    {
                        menuStrip.Enabled = false;
                        return(true);
                    }
                    else
                    {
                        foreach (ToolStripItem c in menuStrip.Items)
                        {
                            controlName = c.Name;
                            if (ps.ExceptControl(formName, menuStrip.Name, controlName))
                            {
                                c.Enabled = false;
                            }
                            else
                            {
                                c.DisableForUser(user);
                            }
                        }
                    }
                }
            }
            return(false);
        }
Beispiel #6
0
        private void FixToolStrip(ToolStrip ts, bool isCloseForm)
        {
            Form frm = ts.FindForm();

            _defaultOwner.Controls.Add(ts);
            foreach (ToolStripItem it in ts.Items)
            {
                if (it is ToolStripSeparator)
                {
                    it.Visible = true;
                }
            }
            ts.Dock        = _originalDock;
            ts.LayoutStyle = _originalLayout;
            ts.BringToFront();
            if (isCloseForm)
            {
                frm.Close();
            }
        }