private void InitRClickMenu(ModuleMenus rclickMenu)
        {
            try
            {
                if (this.ContextMenuStrip == null)
                {
                    return;
                }

                Font bFont = new Font(this.Font.FontFamily, (float)10.5, FontStyle.Bold);

                //添加用户工具按钮
                foreach (ModuleMenuInfo menuItem in rclickMenu.Menus)
                {
                    //创建快捷按钮
                    ToolStripItem rClickMenu = null;

                    if (menuItem.Name == "-")
                    {
                        rClickMenu = new ToolStripSeparator();
                    }
                    else
                    {
                        ToolStripMenuItem curMenu = new ToolStripMenuItem();

                        curMenu.Name   = menuItem.Name;
                        curMenu.Image  = Img24Resource.LoadImg(menuItem.Icon);
                        curMenu.Text   = menuItem.Name + ((string.IsNullOrEmpty(menuItem.Shortcutkey)) ? "" : "(&" + menuItem.Shortcutkey + ")");
                        curMenu.Click += DoRClickMenuEvent;

                        rClickMenu = curMenu;
                    }

                    rClickMenu.Tag = menuItem;

                    if (string.IsNullOrEmpty(menuItem.ParentName))
                    {
                        this.ContextMenuStrip.Items.Add(rClickMenu);
                    }
                    else
                    {
                        ToolStripItem[] tsiParent = this.ContextMenuStrip.Items.Find(menuItem.ParentName, true);

                        ToolStripMenuItem dropDownMenu = tsiParent[0] as ToolStripMenuItem;

                        if (dropDownMenu != null)
                        {
                            dropDownMenu.DropDownItems.Add(rClickMenu);
                        }
                    }

                    menuItem.LinkMenu = rClickMenu;
                }
            }
            catch (Exception ex)
            {
                MsgBox.ShowException(ex, this);
            }
        }
        private void LoadDesign()
        {
            timerRoll.Interval = _rollTextDesign.RollSpeed;

            labRoll.BackColor = Color.Transparent;

            this.BackColor    = _rollTextDesign.BackColor;
            labRoll.ForeColor = _rollTextDesign.ForeColor;
            labRoll.Text      = _rollTextDesign.RollText;

            if (string.IsNullOrEmpty(_rollTextDesign.BackgroundImage) == false)
            {
                this.BackgroundImageLayout = _rollTextDesign.BackgroundImageLayout;
                this.BackgroundImage       = Img24Resource.LoadImg(_rollTextDesign.BackgroundImage);
            }
            else
            {
                this.BackgroundImage = null;
            }

            float fontSize = 0;

            try
            {
                fontSize = _rollTextDesign.FontSize;
            }
            catch { }
            if (fontSize <= 0)
            {
                fontSize = this.Font.Size;
            }

            FontStyle fs = FontStyle.Regular;

            if (_rollTextDesign.IsBold)
            {
                fs = fs | FontStyle.Bold;
            }
            if (_rollTextDesign.IsItalic)
            {
                fs = fs | FontStyle.Italic;
            }



            Font ft = new Font(_rollTextDesign.FontName, fontSize, fs);

            labRoll.Font = ft;

            //如果没有文本,则不启动timer
            if (string.IsNullOrEmpty(_rollTextDesign.RollText))
            {
                return;
            }

            timerRoll.Enabled = true;
        }
 private void butLoadImg_Click(object sender, EventArgs e)
 {
     try
     {
         txtImgName.Text = Img24Resource.ShowImgResourcesSelector(this);
     }
     catch (Exception ex)
     {
         MsgBox.ShowException(ex, this);
     }
 }
Exemple #4
0
 private void button1_Click(object sender, EventArgs e)
 {
     try
     {
         txtBackgroundImage.Text = Img24Resource.ShowImgResourcesSelector(this);
     }
     catch (Exception ex)
     {
         MsgBox.ShowException(ex, this);
     }
 }
        protected void InitUserTool(List <NavItemConfig> toolsCfg)
        {
            try
            {
                //先移除用户控件
                menuPopup.Items.Clear();

                tileNavPane.Appearance.BackColor = _navDesign.BackColor;
                tileNavPane.Appearance.ForeColor = _navDesign.ForceColor;

                tileNavPane.Appearance.Options.UseBackColor = true;
                tileNavPane.Appearance.Options.UseForeColor = true;

                NavButton navButton = null;
                for (int i = tileNavPane.Buttons.Count - 1; i >= 0; i--)
                {
                    navButton = (NavButton)tileNavPane.Buttons[i];

                    if (navButton.Tag != null && navButton.Tag.ToString().Equals("Navigate"))
                    {
                        continue;
                    }

                    tileNavPane.Buttons.Remove(navButton);
                }

                Font bMainFont   = new Font(this.Font.FontFamily, (float)11.5, FontStyle.Bold);
                Font bSmallFont  = new Font(this.Font.FontFamily, (float)10.5);
                int  insertIndex = 1;

                //添加用户工具按钮
                foreach (NavItemConfig mt in toolsCfg)
                {
                    switch (mt.Style)
                    {
                    case NavigateType.ntMain:
                        //创建主导航
                        NavButton funcMenu = new NavButton();
                        funcMenu.Caption   = mt.Name;
                        funcMenu.Tag       = mt.Tag;
                        funcMenu.Alignment = NavButtonAlignment.Left;

                        funcMenu.Glyph = Img24Resource.LoadImg(mt.IconName);

                        funcMenu.Appearance.Font            = bMainFont;
                        funcMenu.Appearance.Options.UseFont = true;

                        funcMenu.AppearanceHovered.Font                 = bMainFont;
                        funcMenu.AppearanceHovered.ForeColor            = Color.FromArgb(255, 255, 128);
                        funcMenu.AppearanceHovered.Options.UseFont      = true;
                        funcMenu.AppearanceHovered.Options.UseForeColor = true;

                        funcMenu.AppearanceSelected.Font            = bMainFont;
                        funcMenu.AppearanceSelected.Options.UseFont = true;

                        funcMenu.ElementClick += DoUserToolEvent_NavElement;

                        tileNavPane.Buttons.Insert(insertIndex, funcMenu);

                        mt.LinkObj = funcMenu;

                        insertIndex = insertIndex + 1;

                        break;

                    case NavigateType.ntDropdown:
                        //创建下拉项
                        ToolStripItem tsMenu = menuPopup.Items.Add(mt.Name);

                        tsMenu.Image = Img24Resource.LoadImg(mt.IconName);

                        tsMenu.Tag    = mt.Tag;
                        tsMenu.Click += DoUserToolEvent_StripItem;

                        mt.LinkObj = tsMenu;
                        break;

                    default:

                        break;
                    }
                }

                int attachButCount = 0;
                //添加用户工具按钮
                foreach (NavItemConfig mt in toolsCfg)
                {
                    if (mt.Style == NavigateType.ntAttach)
                    {
                        if (attachButCount == 0)
                        {
                            NavButton funcSplit = new NavButton();
                            funcSplit.Caption = "|";

                            funcSplit.Appearance.ForeColor            = Color.DarkGray;
                            funcSplit.Appearance.Options.UseForeColor = true;

                            funcSplit.AppearanceHovered.ForeColor            = Color.DarkGray;
                            funcSplit.AppearanceHovered.Options.UseForeColor = true;

                            funcSplit.AppearanceSelected.ForeColor            = Color.DarkGray;
                            funcSplit.AppearanceSelected.Options.UseForeColor = true;

                            funcSplit.Enabled = false;

                            tileNavPane.Buttons.Insert(insertIndex, funcSplit);

                            insertIndex = insertIndex + 1;
                        }


                        NavButton funcMenu = new NavButton();
                        funcMenu.Caption   = mt.Name;
                        funcMenu.Tag       = mt.Tag;
                        funcMenu.Alignment = NavButtonAlignment.Left;

                        funcMenu.Appearance.Font                    = bSmallFont;
                        funcMenu.Appearance.Options.UseFont         = true;
                        funcMenu.AppearanceHovered.Font             = bSmallFont;
                        funcMenu.AppearanceHovered.Options.UseFont  = true;
                        funcMenu.AppearanceSelected.Font            = bSmallFont;
                        funcMenu.AppearanceSelected.Options.UseFont = true;

                        funcMenu.Glyph = Img24Resource.LoadImg(mt.IconName);

                        tileNavPane.Buttons.Insert(insertIndex, funcMenu);

                        mt.LinkObj = funcMenu;

                        insertIndex = insertIndex + 1;

                        attachButCount = attachButCount + 1;
                    }
                }
            }
            catch (Exception ex)
            {
                MsgBox.ShowException(ex, this);
            }
        }
        private void ConfigBtnStyle()
        {
            Tag = _btnDesign.Tag;

            simpleButton1.Appearance.BackColor            = _btnDesign.BackColor;
            simpleButton1.Appearance.Options.UseBackColor = true;

            simpleButton1.ForeColor = _btnDesign.ForceColor;

            simpleButton1.Text  = _btnDesign.Text;
            simpleButton1.Tag   = _btnDesign.Tag;
            simpleButton1.Image = Img24Resource.LoadImg(_btnDesign.ImageName);

            switch (_btnDesign.Style)
            {
            case ButtonStyle.bsDefault:
                simpleButton1.ButtonStyle = DevExpress.XtraEditors.Controls.BorderStyles.Default;
                break;

            case ButtonStyle.bsSimple:
                simpleButton1.ButtonStyle = DevExpress.XtraEditors.Controls.BorderStyles.Simple;
                break;

            case ButtonStyle.bsFlat:
                simpleButton1.ButtonStyle = DevExpress.XtraEditors.Controls.BorderStyles.Flat;
                break;

            default:
                break;
            }

            switch (_btnDesign.ImagePostion)
            {
            case ButtonImagePostion.bipImageAboveText:
                simpleButton1.ImageToTextAlignment = DevExpress.XtraEditors.ImageAlignToText.TopCenter;
                break;

            case ButtonImagePostion.bipTextAboveImage:
                simpleButton1.ImageToTextAlignment = DevExpress.XtraEditors.ImageAlignToText.BottomCenter;
                break;

            case ButtonImagePostion.bipImageBeforeText:
                simpleButton1.ImageToTextAlignment = DevExpress.XtraEditors.ImageAlignToText.LeftCenter;
                break;

            case ButtonImagePostion.bipTextBeforeImage:
                simpleButton1.ImageToTextAlignment = DevExpress.XtraEditors.ImageAlignToText.RightCenter;
                break;

            default:
                break;
            }

            float     fontSize = 0;
            FontStyle fs       = FontStyle.Regular;

            try
            {
                fontSize = _btnDesign.FontSize;
            }
            catch { }
            if (fontSize <= 0)
            {
                fontSize = this.Font.Size;
            }

            if (_btnDesign.FontBold)
            {
                fs = fs | FontStyle.Bold;
            }
            if (_btnDesign.FontItalic)
            {
                fs = fs | FontStyle.Italic;
            }

            Font font = new Font(_btnDesign.FontName, fontSize, fs);

            this.Font = font;

            simpleButton1.Font = this.Font;
        }
Exemple #7
0
        private void LoadDesign()
        {
            labContext.BackColor = Color.Transparent;

            this.BackColor = _labDesign.BackColor;

            labContext.Appearance.TextOptions.WordWrap = DevExpress.Utils.WordWrap.Wrap;
            labContext.ForeColor = _labDesign.ForeColor;
            labContext.Text      = _labDesign.LabText;


            if (string.IsNullOrEmpty(_labDesign.BackgroundImage) == false)
            {
                this.BackgroundImageLayout = _labDesign.BackgroundImageLayout;
                this.BackgroundImage       = BigImgResource.LoadImg(_labDesign.BackgroundImage);
            }
            else
            {
                this.BackgroundImage = null;
            }

            if (string.IsNullOrEmpty(_labDesign.TextIcon) == false)
            {
                labContext.Appearance.Image = Img24Resource.LoadImg(_labDesign.TextIcon);
            }
            else
            {
                labContext.Appearance.Image = null;
            }


            float fontSize = 0;

            try
            {
                fontSize = _labDesign.FontSize;
            }
            catch { }
            if (fontSize <= 0)
            {
                fontSize = this.Font.Size;
            }

            FontStyle fs = FontStyle.Regular;

            if (_labDesign.IsBold)
            {
                fs = fs | FontStyle.Bold;
            }
            if (_labDesign.IsItalic)
            {
                fs = fs | FontStyle.Italic;
            }



            Font ft = new Font(_labDesign.FontName, fontSize, fs);

            labContext.Font = ft;


            switch (_labDesign.TextPostion)
            {
            case PostionType.ipTop:
                labContext.Appearance.TextOptions.HAlignment = DevExpress.Utils.HorzAlignment.Center;
                labContext.Appearance.TextOptions.VAlignment = DevExpress.Utils.VertAlignment.Top;
                break;

            case PostionType.ipLeft:
                labContext.Appearance.TextOptions.HAlignment = DevExpress.Utils.HorzAlignment.Near;
                labContext.Appearance.TextOptions.VAlignment = DevExpress.Utils.VertAlignment.Center;
                break;

            case PostionType.ipRight:
                labContext.Appearance.TextOptions.HAlignment = DevExpress.Utils.HorzAlignment.Far;
                labContext.Appearance.TextOptions.VAlignment = DevExpress.Utils.VertAlignment.Center;
                break;

            case PostionType.ipBottom:
                labContext.Appearance.TextOptions.HAlignment = DevExpress.Utils.HorzAlignment.Center;
                labContext.Appearance.TextOptions.VAlignment = DevExpress.Utils.VertAlignment.Bottom;
                break;

            case PostionType.ipCenter:
                labContext.Appearance.TextOptions.HAlignment = DevExpress.Utils.HorzAlignment.Center;
                labContext.Appearance.TextOptions.VAlignment = DevExpress.Utils.VertAlignment.Center;
                break;


            default:
                break;
            }


            switch (_labDesign.IconPostion)
            {
            case PostionType.ipTop:
                labContext.ImageAlignToText = DevExpress.XtraEditors.ImageAlignToText.TopCenter;
                break;

            case PostionType.ipLeft:
                labContext.ImageAlignToText = DevExpress.XtraEditors.ImageAlignToText.LeftCenter;
                break;

            case PostionType.ipRight:
                labContext.ImageAlignToText = DevExpress.XtraEditors.ImageAlignToText.RightCenter;
                break;

            case PostionType.ipBottom:
                labContext.ImageAlignToText = DevExpress.XtraEditors.ImageAlignToText.BottomCenter;
                break;

            case PostionType.ipCenter:
                labContext.ImageAlignToText = DevExpress.XtraEditors.ImageAlignToText.LeftCenter;
                break;


            default:
                break;
            }
        }
Exemple #8
0
        static public void ConfigButtons(ToolStrip toolStrip, ToolsDesign toolDesign, EventHandler itemClick)
        {
            toolStrip.ImageList = Img24Resource.Imgs;

            //添加用户工具按钮
            foreach (ToolItemConfig toolItem in toolDesign.ToolsCfg)
            {
                //创建快捷按钮
                ToolStripItem tsBut = null;

                switch (toolItem.钮类型)
                {
                case ToolType.ttLabel:
                    tsBut = new ToolStripLabel();
                    break;

                case ToolType.ttButton:
                    tsBut = new ToolStripButton();
                    break;

                case ToolType.ttDrowDownButton:
                    tsBut = new ToolStripDropDownButton();
                    break;

                case ToolType.ttSeparator:
                    tsBut = new ToolStripSeparator();
                    break;

                default:
                    break;
                }

                switch (toolItem.显示样式)
                {
                case ToolDisplayStyle.tdsText:
                    tsBut.DisplayStyle = ToolStripItemDisplayStyle.Text;
                    break;

                case ToolDisplayStyle.tdsImage:
                    tsBut.DisplayStyle = ToolStripItemDisplayStyle.Image;
                    break;

                case ToolDisplayStyle.tdsTextAndImage:
                    tsBut.DisplayStyle = ToolStripItemDisplayStyle.ImageAndText;
                    break;

                default:
                    break;
                }

                switch (toolItem.图标位置)
                {
                case ToolIconStyle.tisImageAboveText:
                    tsBut.TextImageRelation = TextImageRelation.ImageAboveText;
                    break;

                case ToolIconStyle.tisTextAboveImage:
                    tsBut.TextImageRelation = TextImageRelation.TextAboveImage;
                    break;

                case ToolIconStyle.tisImageBeforeText:
                    tsBut.TextImageRelation = TextImageRelation.ImageBeforeText;
                    break;

                default:
                    tsBut.TextImageRelation = TextImageRelation.TextBeforeImage;
                    break;
                }

                if (toolItem.右对齐)
                {
                    tsBut.Alignment = ToolStripItemAlignment.Right;
                }

                tsBut.Name = toolItem.称;
                tsBut.Text = toolItem.称;
                tsBut.Tag  = toolItem.标记;

                Img24Resource.LoadImg(toolItem.图标);
                tsBut.ImageKey = toolItem.图标;


                tsBut.ForeColor = toolDesign.ForceColor;
                tsBut.Click    += itemClick;

                if (string.IsNullOrEmpty(toolItem.父级名称))
                {
                    toolStrip.Items.Add(tsBut);
                }
                else
                {
                    ToolStripItem[] tsiParent = toolStrip.Items.Find(toolItem.父级名称, true);

                    ToolStripDropDownButton dropDownButton = tsiParent[0] as ToolStripDropDownButton;

                    if (dropDownButton != null)
                    {
                        dropDownButton.DropDownItems.Add(tsBut);
                    }
                }

                toolItem.LinkObj = tsBut;
            }
        }
Exemple #9
0
        private void ReloadDictionary(Dictionary <string, object> dicts)
        {
            foreach (BaseLayoutItem bli in layoutControl1.Items)
            {
                DesignLabel dl = bli as DesignLabel;

                if (dl == null)
                {
                    continue;
                }
                if (string.IsNullOrEmpty(dl.Formats.数据项名称))
                {
                    continue;
                }

                dl.Image = null;
                dl.AppearanceItemCaption.BackColor = dl.Formats.默认背景色;
                dl.AppearanceItemCaption.ForeColor = dl.Formats.默认前景色;

                if (dicts == null)
                {
                    dl.Text = " ";

                    continue;
                }

                string showDisplay = "";

                bool isDataItem = dicts.ContainsKey(dl.Formats.数据项名称);
                if (isDataItem)
                {
                    string value = Convert.ToString(dicts[dl.Formats.数据项名称]);
                    showDisplay = value;

                    if (dl.Formats.文本格式.Count > 0)
                    {
                        int vIndex = dl.Formats.文本格式.FindIndex(T => T.数据值 == value);

                        if (vIndex >= 0)
                        {
                            DesignLabelFormatItem formatItem = dl.Formats.文本格式[vIndex];

                            dl.Image    = Img24Resource.LoadImg(formatItem.图标名称);
                            showDisplay = formatItem.显示内容;

                            if (formatItem.背景色.Name != "0")
                            {
                                dl.AppearanceItemCaption.BackColor = formatItem.背景色;
                            }

                            if (formatItem.前景色.Name != "0")
                            {
                                dl.AppearanceItemCaption.ForeColor = formatItem.前景色;
                            }
                        }
                    }
                }

                if (string.IsNullOrEmpty(showDisplay))
                {
                    showDisplay = " ";
                }
                dl.Text = showDisplay;
            }
        }