コード例 #1
0
        /// <summary>
        /// 页面的Css设置
        /// </summary>
        /// <param name="doc">对应的模板文档</param>
        public CssSetupForm(TmpltXmlDocument doc)
        {
            InitializeComponent();
            if (!Service.Util.DesignMode)
            {
                this.tabControlGeneral.TabPages.Clear();
            }
            Doc = doc;
            XmlElement ele = doc.DocumentElement;

            CSSText                          = ele.GetAttribute("webCss");
            _webPageDicA                     = CssSection.Parse(ele.GetAttribute("a"));
            _webPageDicA_visited             = CssSection.Parse(ele.GetAttribute("a_visited"));
            this.checkBoxUsingCurImg.Visible = false;
            checkBoxIsAutoSize.Enabled       = true;
            tabControlGeneral.TabPages.Add(this.tabPageBackGroud);
            tabControlGeneral.TabPages.Add(this.tabPageBorder);
            tabControlGeneral.TabPages.Add(this.tabPageFont);
            this.groupBoxLinkOption.Visible = true;
            //this.cssDesignerDisplayControl.NumericUpDown.Enabled = true;
            _curType = CurType.WebPage;
            this.textBoxCurType.Text = StringParserService.Parse("${res:tmpltDesign.tmpltDrawPanel.cssSetupFormType.tmplt}");
            this.Text = StringParserService.Parse("${res:tmpltDesign.tmpltDrawPanel.cssSetupFormText.tmplt}");
            _tmpltID  = doc.Id;
            this.textBoxTitle.Enabled = false;
            this.textBoxTitle.Text    = ele.GetAttribute("title");
            //InitEvent();
        }
コード例 #2
0
        /// <summary>
        /// 初始化现有的值
        /// </summary>
        public void InitValue(CssSection cssSection)
        {
            CurentFont = "";
            CssSection = cssSection;
            string cssVlaue = "";

            if (cssSection.Properties.TryGetValue("font-family", out cssVlaue))
            {
                comboBoxFont.Text = cssVlaue;
                CurentFont        = cssVlaue;
            }
            if (cssSection.Properties.TryGetValue("font-weight", out cssVlaue))
            {
                btnBold.FlatStyle = FlatStyle.Flat;
                IsBold            = true;
            }
            if (cssSection.Properties.TryGetValue("font-style", out cssVlaue))
            {
                btnI.FlatStyle = FlatStyle.Flat;
                IsItalic       = true;
            }
            if (cssSection.Properties.TryGetValue("font-size", out cssVlaue))
            {
                KeyValuePair <string, int> _kv = Service.Util.GetSizeAndUnit(cssVlaue);
                comboBoxSize.Text = _kv.Key;
                comboBoxSizeUint.SelectedIndex = _kv.Value;
            }

            if (cssSection.Properties.TryGetValue("color", out cssVlaue))
            {
                textBoxColor.Text = cssVlaue;
                btnColor.MyColor  = ColorTranslator.FromHtml(cssVlaue);
            }
        }
コード例 #3
0
 void BindingSection(TreeNode parentNode, CssSection section)
 {
     foreach (CssProperty property in section.Properties)
     {
         TreeNode node = new TreeNode(property.ToString());
         parentNode.Nodes.Add(node);
     }
 }
コード例 #4
0
 public CssMyFont()
 {
     InitializeComponent();
     CssSection = new CssSection();
     InitEvents();
     if (!Service.Util.DesignMode)
     {
         InitComboBoxFont(true);
         InitOther();
     }
 }
コード例 #5
0
        public static XhtmlTags.Img GetDefaultPicHtml(string picPath, string customerId)
        {
            XhtmlSection _section = new XhtmlSection();

            XhtmlTags.Img img = _section.CreateXhtmlImg();

            Image      upImage = Image.FromFile(picPath);
            string     width   = upImage.Width.ToString();
            string     height  = upImage.Height.ToString();
            CssSection css     = new CssSection();

            css.Properties["width"]  = width;
            css.Properties["height"] = height;
            img.Builder(css, "0", "0", customerId, Xhtml.Align.left, "0", "0", "img");
            return(img);
        }
コード例 #6
0
        /// <summary>
        /// 传入面板名称,创建Css主面板。
        /// </summary>
        /// <param name="name"></param>
        /// <returns></returns>
        static public CssMainControl Create(string name, CssSection value)
        {
            CssMainControl newMainControl;

            switch (name)
            {
            case "类型":
                newMainControl = new GeneralCssControl();
                break;

            case "背景":
                newMainControl = new BackgroundCssControl();
                break;

            case "区块":
                newMainControl = new BlockCssControl();
                break;

            case "方框":
                newMainControl = new BoxCssControl();
                break;

            case "列表":
                newMainControl = new ListCssControl();
                break;

            case "定位":
                newMainControl = new PositionCssControl();
                break;

            case "扩展":
                newMainControl = new ExpandCssControl();
                break;

            default:
                Debug.Fail("未知的name:" + name);
                newMainControl = null;
                break;
            }
            newMainControl.Value = value;

            return(newMainControl);
        }
コード例 #7
0
        public CssSettingForm(string css)
        {
            _cssSection = CssSection.Parse(css);

            InitializeComponent();

            ///初始化时便生成所有面板
            foreach (object item in listBoxLeftType.Items)
            {
                CssMainControl newMainControl = CssMainControl.Create(item.ToString(), _cssSection);
                this.splitContainerUI.Panel2.Controls.Add(newMainControl);
                newMainControl.Visible = false;

                _mainControls.Add(item.ToString(), newMainControl);
            }

            ///显示第一个Css主面板
            listBoxLeftType.SelectedIndex = 0;
        }
コード例 #8
0
        /// <summary>
        /// 保存矩形
        /// </summary>
        public void SaveRects()
        {
            float x = DrawPanel.CurZoom;

            DrawPanel.CurZoom = 1;
            Dictionary <string, XmlElement> _tempSnips = TmpltDoc.GetAllSnipElementClone();
            XmlElement docEle = (XmlElement)TmpltDoc.DocumentElement.SelectSingleNode("rects");

            docEle.RemoveAll();

            RectLayer boundaryRect = new RectLayer(0, 0, DrawPanel.Width, DrawPanel.Height, TmpltDoc.TmpltCss);

            LineToRect(boundaryRect);


            AddRectToXml(docEle, new RectTreeNode(boundaryRect, null));

            XmlNodeList snipNodes = docEle.SelectNodes(@"//snip");

            foreach (XmlNode snipNode in snipNodes)
            {
                if (snipNode.NodeType == XmlNodeType.Element)
                {
                    SnipXmlElement snipEle = (SnipXmlElement)snipNode;
                    string         id      = snipEle.Id;
                    if (_tempSnips.ContainsKey(id))
                    {
                        CssSection tempCss = CssSection.Parse(snipEle.GetAttribute("css"));
                        XmlUtilService.CopyXmlElement(_tempSnips[id], snipEle);
                        snipEle.Width  = tempCss.Properties["width"];
                        snipEle.Height = tempCss.Properties["height"];
                        snipEle.Css    = tempCss.ToString();
                    }
                }
            }
            DrawPanel.CurZoom = x;

            TmpltDoc.Reseted = true;
        }
コード例 #9
0
        protected SnipPagePart(SnipPageDesigner designer)
        {
            ResourcesReader.SetObjectResourcesHelper(this);
            _designer           = designer;
            Text                = "";
            Padding             = new System.Windows.Forms.Padding(0);
            Index               = -1;
            HtmlTagName         = "div";
            FactLines           = 2;
            _cssSection         = new CssSection();
            PartType            = SnipPartType.Static;
            ChildParts          = new SnipPagePartCollection(this);
            _classPartContainer = new ClassPartContainer(this);
            Random random = new Random();

            //BackColor = System.Drawing.Color.FromArgb(random.Next(0, 256), random.Next(0, 256), random.Next(0, 256));
            _cssSection.Properties["width"]  = "100%";
            _cssSection.Properties["height"] = "20px";
            _cssSection.Properties["float"]  = "left";
            BoxIconXOffset = 0;
            BoxIconYOffset = -8;
            BoxIconSize    = new Size(16, 16);
        }
コード例 #10
0
        /// <summary>
        /// 初始化现有的值
        /// </summary>
        public void InitValue(CssSection cssDic)
        {
            CssDic = cssDic;
            string strValue = "";

            if (CssDic.Properties.TryGetValue("overflow", out strValue))
            {
                switch (strValue)
                {
                case "auto":
                    _comboBoxOverFlow.SelectedIndex = 0;
                    break;

                case "visible":
                    _comboBoxOverFlow.SelectedIndex = 1;
                    break;

                case "hidden":
                    _comboBoxOverFlow.SelectedIndex = 2;
                    break;

                case "scroll":
                    _comboBoxOverFlow.SelectedIndex = 3;
                    break;

                default:
                    break;
                }
            }

            if (CssDic.Properties.TryGetValue("clear", out strValue))
            {
                switch (strValue)
                {
                case "both":
                    _comboBoxClear.SelectedIndex = 0;
                    break;

                case "left":
                    _comboBoxClear.SelectedIndex = 1;
                    break;

                case "right":
                    _comboBoxClear.SelectedIndex = 2;
                    break;

                case "none":
                    _comboBoxClear.SelectedIndex = 3;
                    break;

                default:
                    break;
                }
            }

            if (CssDic.Properties.TryGetValue("vertical-align", out strValue))
            {
                switch (strValue)
                {
                case "middle":
                    _comboBoxVerticalAlign.SelectedIndex = 0;
                    break;

                case "top":
                    _comboBoxVerticalAlign.SelectedIndex = 1;
                    break;

                case "bottom":
                    _comboBoxVerticalAlign.SelectedIndex = 2;
                    break;

                case "text-bottom":
                    _comboBoxVerticalAlign.SelectedIndex = 3;
                    break;

                case "text-top":
                    _comboBoxVerticalAlign.SelectedIndex = 4;
                    break;

                case "sub":
                    _comboBoxVerticalAlign.SelectedIndex = 5;
                    break;

                case "super":
                    _comboBoxVerticalAlign.SelectedIndex = 6;
                    break;

                case "baseline":
                    _comboBoxVerticalAlign.SelectedIndex = 7;
                    break;

                default:
                    break;
                }
            }

            if (CssDic.Properties.TryGetValue("text-align", out strValue))
            {
                switch (strValue)
                {
                case "left":
                    _comboBoxTextAlign.SelectedIndex = 1;
                    break;

                case "right":
                    _comboBoxTextAlign.SelectedIndex = 2;
                    break;

                case "center":
                    _comboBoxTextAlign.SelectedIndex = 0;
                    break;

                default:
                    break;
                }
            }

            if (CssDic.Properties.TryGetValue("line-height", out strValue))
            {
                KeyValuePair <string, int> _kv = Jeelu.SimplusD.Client.Win.Service.Util.GetSizeAndUnit(strValue);
                _textBoxHeight.Text            = _kv.Key;
                comboBoxSizeUnit.SelectedIndex = _kv.Value;
            }
        }
コード例 #11
0
        private int[] GetOldSize(CssSection cssSection, string name)
        {
            int[]  oldSize = new int[5];
            string oldStr  = "";
            KeyValuePair <string, int> kv = new KeyValuePair <string, int>("", 0);

            if (cssSection.Properties.TryGetValue(name, out oldStr))
            {
                if (!string.IsNullOrEmpty(oldStr))
                {
                    kv = GetModelSize(oldStr);
                    if (!string.IsNullOrEmpty(kv.Key))
                    {
                        oldSize[0] = Convert.ToInt32(kv.Key);
                    }
                    else
                    {
                        oldSize[0] = 0;
                    }
                }
            }
            else
            {
                oldSize[0] = 0;
            }

            if (cssSection.Properties.TryGetValue(name + "-bottom", out oldStr))
            {
                if (!string.IsNullOrEmpty(oldStr))
                {
                    kv = GetModelSize(oldStr);
                    if (!string.IsNullOrEmpty(kv.Key))
                    {
                        oldSize[1] = Convert.ToInt32(kv.Key);
                    }
                    else
                    {
                        oldSize[1] = 0;
                    }
                }
            }
            else
            {
                oldSize[1] = 0;
            }

            if (cssSection.Properties.TryGetValue(name + "-top", out oldStr))
            {
                if (!string.IsNullOrEmpty(oldStr))
                {
                    kv = GetModelSize(oldStr);
                    if (!string.IsNullOrEmpty(kv.Key))
                    {
                        oldSize[2] = Convert.ToInt32(kv.Key);
                    }
                    else
                    {
                        oldSize[2] = 0;
                    }
                }
            }
            else
            {
                oldSize[2] = 0;
            }

            if (cssSection.Properties.TryGetValue(name + "-right", out oldStr))
            {
                if (!string.IsNullOrEmpty(oldStr))
                {
                    kv = GetModelSize(oldStr);
                    if (!string.IsNullOrEmpty(kv.Key))
                    {
                        oldSize[3] = Convert.ToInt32(kv.Key);
                    }
                    else
                    {
                        oldSize[3] = 0;
                    }
                }
            }
            else
            {
                oldSize[3] = 0;
            }

            if (cssSection.Properties.TryGetValue(name + "-left", out oldStr))
            {
                if (!string.IsNullOrEmpty(oldStr))
                {
                    kv = GetModelSize(oldStr);
                    if (!string.IsNullOrEmpty(kv.Key))
                    {
                        oldSize[4] = Convert.ToInt32(kv.Key);
                    }
                    else
                    {
                        oldSize[4] = 0;
                    }
                }
            }
            else
            {
                oldSize[4] = 0;
            }
            return(oldSize);
        }
コード例 #12
0
        void ChangedCss(CssSection cssSection, string name, int[] oldSize, int index)
        {
            string str     = "";
            int    wLeft   = 0;
            int    wRight  = 0;
            int    hTop    = 0;
            int    hBottom = 0;

            int newSize = 0;

            KeyValuePair <string, int> kkvv = new KeyValuePair <string, int>();

            if (cssSection.Properties.TryGetValue(name, out str))
            {
                if (!string.IsNullOrEmpty(str))
                {
                    kkvv = GetModelSize(str);
                    if (!string.IsNullOrEmpty(kkvv.Key))
                    {
                        newSize = Convert.ToInt32(kkvv.Key);
                    }
                }
            }
            else
            {
                return;
            }

            switch (index)
            {
            case 0:
                #region
            {
                wLeft   -= (oldSize[4] + oldSize[0] - newSize);
                wRight  -= (oldSize[3] + oldSize[0] - newSize);
                hTop    -= (oldSize[2] + oldSize[0] - newSize);
                hBottom -= (oldSize[1] + oldSize[0] - newSize);
            }
                #endregion
                break;

            case 1:
                #region
            {
                hBottom -= (oldSize[1] + oldSize[0] - newSize);
            }
                #endregion
                break;

            case 2:
                #region
            {
                hTop -= (oldSize[2] + oldSize[0] - newSize);
            }
                #endregion
                break;

            case 3:
                #region
            {
                wRight -= (oldSize[3] + oldSize[0] - newSize);
            }
                #endregion
                break;

            case 4:
                #region
            {
                wLeft -= (oldSize[4] + oldSize[0] - newSize);
            }
                #endregion
                break;

            default:
                break;
            }

            KeyValuePair <string, int> kv = new KeyValuePair <string, int>();
            if (_dic.Properties.TryGetValue("width", out str))
            {
                kv = Service.Util.GetSizeAndUnit(str);
                if (kv.Value == kkvv.Value)
                {
                    string unit = Service.Util.GetUnitByInt(kv.Value);
                    int    w    = Convert.ToInt32(kv.Key);
                    w = w - wLeft - wRight;
                    _dic.Properties["width"] = w.ToString() + unit;
                }
            }

            if (_dic.Properties.TryGetValue("height", out str))
            {
                kv = Service.Util.GetSizeAndUnit(str);
                if (kv.Value == kkvv.Value)
                {
                    string unit = Service.Util.GetUnitByInt(kv.Value);
                    int    h    = Convert.ToInt32(kv.Key);
                    h = h - hTop - hBottom;
                    _dic.Properties["height"] = h.ToString() + unit;
                }
            }
        }
コード例 #13
0
        /// <summary>
        /// 初始化现有的值
        /// </summary>
        public void InitValue(CssSection _dic)
        {
            string strValue = "";

            //margin 边界
            if (_dic.Properties.TryGetValue("margin-bottom", out strValue))
            {
                _dic.Properties.Remove("margin-bottom");
                _page1_1.InitValue(strValue);
            }
            if (_dic.Properties.TryGetValue("margin-top", out strValue))
            {
                _dic.Properties.Remove("margin-top");
                _page1_2.InitValue(strValue);
            }
            if (_dic.Properties.TryGetValue("margin-right", out strValue))
            {
                _dic.Properties.Remove("margin-right");
                _page1_3.InitValue(strValue);
            }
            if (_dic.Properties.TryGetValue("margin-left", out strValue))
            {
                _dic.Properties.Remove("margin-left");
                _page1_4.InitValue(strValue);
            }
            if (_dic.Properties.TryGetValue("margin", out strValue))
            {
                _checkBox1.Checked = true;
                _dic.Properties.Remove("margin");
                _page1_5.InitValue(strValue);
            }
            else
            {
                _checkBox1.Checked = false;
            }
            //border 边框
            if (_dic.Properties.TryGetValue("border-bottom", out strValue))
            {
                _dic.Properties.Remove("border-bottom");
                _page2_1.InitValue(strValue);
            }
            if (_dic.Properties.TryGetValue("border-top", out strValue))
            {
                _dic.Properties.Remove("border-top");
                _page2_2.InitValue(strValue);
            }
            if (_dic.Properties.TryGetValue("border-right", out strValue))
            {
                _dic.Properties.Remove("border-right");
                _page2_3.InitValue(strValue);
            }
            if (_dic.Properties.TryGetValue("border-left", out strValue))
            {
                _dic.Properties.Remove("border-left");
                _page2_4.InitValue(strValue);
            }
            if (_dic.Properties.TryGetValue("border", out strValue))
            {
                _checkBox2.Checked = true;
                _dic.Properties.Remove("border");
                _page2_5.InitValue(strValue);
            }
            else
            {
                _checkBox2.Checked = false;
            }
            //padding 填充
            if (_dic.Properties.TryGetValue("padding-bottom", out strValue))
            {
                _dic.Properties.Remove("padding-bottom");
                _page3_1.InitValue(strValue);
            }
            if (_dic.Properties.TryGetValue("padding-top", out strValue))
            {
                _dic.Properties.Remove("padding-top");
                _page3_2.InitValue(strValue);
            }
            if (_dic.Properties.TryGetValue("padding-right", out strValue))
            {
                _dic.Properties.Remove("padding-right");
                _page3_3.InitValue(strValue);
            }
            if (_dic.Properties.TryGetValue("padding-left", out strValue))
            {
                _dic.Properties.Remove("padding-left");
                _page3_4.InitValue(strValue);
            }
            if (_dic.Properties.TryGetValue("padding", out strValue))
            {
                _checkBox3.Checked = true;
                _dic.Properties.Remove("padding");
                _page3_5.InitValue(strValue);
            }
            else
            {
                _checkBox3.Checked = false;
            }
            this._dic = _dic;
        }
コード例 #14
0
        /// <summary>
        /// 资源的高级设置
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void ResourceHighSetting_Click(object sender, EventArgs e)
        {
            if (resourceFilesListView.SelectedItems.Count != 1)
            {
                return;                                                 //不支持多选
            }
            MyListItem myitem = resourceFilesListView.SelectedItems[0] as MyListItem;

            if (myitem is MyListFileItem)
            {
                BaseForm        form         = new BaseForm();
                XhtmlTagElement xhtmlElement = null;// new XhtmlTagElement();
                XhtmlSection    _section     = new XhtmlSection();
                string          strHref      = "[url: " + ((MyListFileItem)myitem).Element.Id + "]";
                switch (((MyListFileItem)myitem).ItemMediaType)
                {
                case MediaFileType.None:
                    break;

                case MediaFileType.Pic:
                    #region 图片
                {
                    xhtmlElement = _section.CreateXhtmlImg();
                    ((XhtmlTags.Img)xhtmlElement).Src = strHref;
                    form = new InsertPicCodeForm(xhtmlElement, ((MyListFileItem)myitem).Element.AbsoluteFilePath);
                    break;
                }

                    #endregion
                case MediaFileType.Flash:
                    #region Flash
                {
                    xhtmlElement = _section.CreateXhtmlFlash();

                    CssSection style = new CssSection();
                    ((XhtmlTags.Flash)xhtmlElement).Builder(style, "", strHref, Xhtml.Align.left, "", -1, -1, "", "", "");
                    form = new InsertFlashCodeForm(xhtmlElement, ((MyListFileItem)myitem).Element.AbsoluteFilePath);

                    break;
                }

                    #endregion
                case MediaFileType.Audio:
                    #region Audio
                {
                    xhtmlElement = _section.CreateXhtmlObject();
                    //((XhtmlTags.Object)xhtmlElement).Src = strHref;
                    form = new InsertAudioCodeForm(xhtmlElement, ((MyListFileItem)myitem).Element.AbsoluteFilePath);
                    break;
                }

                    #endregion
                case MediaFileType.Video:
                    #region Video
                {
                    xhtmlElement = _section.CreateXhtmlObject();
                    //((XhtmlTags.Object)xhtmlElement).Src = strHref;
                    form = new InsertVideoCodeForm(xhtmlElement, ((MyListFileItem)myitem).Element.AbsoluteFilePath);
                    break;
                }

                    #endregion
                default:
                    Debug.Fail("未知的type:" + ((MyListFileItem)myitem).ItemMediaType.ToString());
                    break;
                }
                if (form.ShowDialog() == DialogResult.OK)
                {
                    ((MyListFileItem)myitem).XmlAttribute = (XmlElement)xhtmlElement.ToXmlNode();
                }
            }
        }
コード例 #15
0
        /// <summary>
        /// 初始化现有的值
        /// </summary>
        public void InitValue(CssSection cssDic)
        {
            CssDic = cssDic;
            string strValue = "";

            if (CssDic.Properties.TryGetValue("float", out strValue))
            {
                switch (strValue)
                {
                case "left":
                    _comboBoxlayoutFloat.SelectedIndex = 1;
                    break;

                case "right":
                    _comboBoxlayoutFloat.SelectedIndex = 2;
                    break;

                default:
                    _comboBoxlayoutFloat.SelectedIndex = 0;
                    break;
                }
            }
            else
            {
                _comboBoxlayoutFloat.SelectedIndex = 0;
            }

            if (CssDic.Properties.TryGetValue("width", out strValue))
            {
                KeyValuePair <string, int> _kv = Service.Util.GetSizeAndUnit(strValue);
                _textBoxWidth.Text = _kv.Key;
                comboBoxWidthSizeUnit.SelectedIndex = _kv.Value;
                switch (_kv.Value)
                {
                case 0:
                    _wUnit = "px";
                    break;

                case 1:
                    _wUnit = "pt";
                    break;

                case 2:
                    _wUnit = "in";
                    break;

                case 3:
                    _wUnit = "cm";
                    break;

                case 4:
                    _wUnit = "mm";
                    break;

                case 5:
                    _wUnit = "pc";
                    break;

                case 6:
                    _wUnit = "em";
                    break;

                case 7:
                    _wUnit = "ex";
                    break;

                case 8:
                    _wUnit = "%";
                    break;

                default:
                    break;
                }
            }

            if (CssDic.Properties.TryGetValue("height", out strValue))
            {
                KeyValuePair <string, int> _kv = Service.Util.GetSizeAndUnit(strValue);
                _textBoxHeight.Text = _kv.Key;
                comboBoxHeightSizeUnit.SelectedIndex = _kv.Value;
                switch (_kv.Value)
                {
                case 0:
                    _hUnit = "px";
                    break;

                case 1:
                    _hUnit = "pt";
                    break;

                case 2:
                    _hUnit = "in";
                    break;

                case 3:
                    _hUnit = "cm";
                    break;

                case 4:
                    _hUnit = "mm";
                    break;

                case 5:
                    _hUnit = "pc";
                    break;

                case 6:
                    _hUnit = "em";
                    break;

                case 7:
                    _hUnit = "ex";
                    break;

                case 8:
                    _hUnit = "%";
                    break;

                default:
                    break;
                }
            }
        }
コード例 #16
0
 private void SetCssCore(string value)
 {
     _cssSection = CssSection.Parse(value);
 }