Exemple #1
0
        public void DrawByName(string name, string exportPath, string logoName,
                               string splitString, string exportSplitString, bool isScaleAll)
        {
            if (!Directory.Exists(exportPath))
            {
                Directory.CreateDirectory(exportPath);
            }

            // get list logo order behind main logo
            ScriptConfig        config   = props.ScriptConfig;
            List <ScriptObject> logoList = config.LogoList.OrderBy(p => p.Order).ToList();

            string[] names      = name.Trim().Split(new string[] { splitString }, StringSplitOptions.None);
            string   exportName = name.Replace(splitString, exportSplitString);

            for (int i = 0; i < names.Length; i++)
            {
                ScriptObject obj      = logoList[i];
                string       fontPath = props.LogoRootPath + obj.FontName;
                Font         ff       = GetCustomFont(fontPath, obj.FontSize);
                {
                    Layer layer = new Layer(new LayerText(names[i], ff, obj.FontSize, LogoUtil.ConvertStringToColor(obj.TextColor)
                                                          , (int)obj.OutlineSize, LogoUtil.ConvertStringToColor(obj.OutlineColorHex)
                                                          , (LineJoin)obj.LineJoin));

                    layer.UpdateLayer(obj.LogoPosition, obj.LogoScale, obj.LogoRotation, obj.LogoContainer);
                    layerManager.AddTextLayer(layer);
                }
            }
            if (logoList.Count > 0)
            {
                layerManager.ExportImage(exportPath + exportName + ".png", new Size(2400, 3200), isScaleAll);
            }
        }
Exemple #2
0
        private void btnAddText_Click(object sender, EventArgs e)
        {
            string strText = tbText.Text.Trim();

            if (strText.Length == 0)
            {
                MessageBox.Show("Please input text!");
                return;
            }
            FontFamily font = GetFontByName(cbbFontName.SelectedItem.ToString());

            if (font != null)
            {
                int       outlineSize = int.Parse(tbOutlineSize.Text.Trim());
                LineJoin  lineJoin    = (LineJoin)(cbbOutlineStyle.SelectedIndex);
                FontStyle fontStyle   = (FontStyle)Enum.Parse(typeof(FontStyle), cbbFontStyle.Text.ToString());

                Font  ff    = new Font(font, int.Parse(cbbFontSize.Text.ToString()), fontStyle, GraphicsUnit.Pixel);
                Layer layer = new Layer(new LayerText(strText, ff, int.Parse(cbbFontSize.Text.ToString()), selectedColor, outlineSize, outlineColor, lineJoin));
                layerManager.AddTextLayer(layer);
                UpdateInfo();
                pictureBox1.Invalidate();
            }
            else
            {
                MessageBox.Show("Cannot found font " + cbbFontName.SelectedItem.ToString());
            }
        }