Ejemplo n.º 1
0
        public Bitmap GetStyleBitmap(int index)
        {
            StyleCollection styleCollection = this[index];
            Style           style           = styleCollection[styleCollection.IndexOf("Header")];

            Color headerColor = Color.White;

            if (style.Fill is SolidFill)
            {
                headerColor = (style.Fill as SolidFill).Color;
            }
            else if (style.Fill is LinearGradientFill)
            {
                headerColor = (style.Fill as LinearGradientFill).StartColor;
            }

            style = styleCollection[styleCollection.IndexOf("Body")];
            Color bodyColor = Color.White;

            if (style.Fill is SolidFill)
            {
                bodyColor = (style.Fill as SolidFill).Color;
            }
            else if (style.Fill is LinearGradientFill)
            {
                bodyColor = (style.Fill as LinearGradientFill).StartColor;
            }

            // draw style picture
            Bitmap result = new Bitmap(16, 16);

            using (Graphics g = Graphics.FromImage(result))
            {
                g.FillRectangle(Brushes.White, 0, 0, 16, 16);

                using (Brush b = new SolidBrush(headerColor))
                {
                    g.FillRectangle(b, 0, 0, 15, 8);
                }
                using (Brush b = new SolidBrush(bodyColor))
                {
                    g.FillRectangle(b, 0, 8, 15, 8);
                }

                g.DrawRectangle(Pens.Silver, 0, 0, 14, 14);
            }

            return(result);
        }
Ejemplo n.º 2
0
        protected override void OnDrawItem(DrawItemEventArgs e)
        {
            e.DrawBackground();
            Graphics g = e.Graphics;

            if (e.Index >= 0)
            {
                string name = (string)Items[e.Index];
                using (TextObject sample = new TextObject())
                {
                    sample.Bounds    = new RectangleF(e.Bounds.Left + 2, e.Bounds.Top + 2, e.Bounds.Width - 4, e.Bounds.Height - 4);
                    sample.Text      = name;
                    sample.HorzAlign = HorzAlign.Center;
                    sample.VertAlign = VertAlign.Center;
                    if (FStyles != null)
                    {
                        int index = FStyles.IndexOf(name);
                        if (index != -1)
                        {
                            sample.ApplyStyle(FStyles[index]);
                        }
                    }
                    using (GraphicCache cache = new GraphicCache())
                    {
                        sample.Draw(new FRPaintEventArgs(g, 1, 1, cache));
                    }
                }
            }
        }
Ejemplo n.º 3
0
        private void ApplyStyle(TableCell cell, string styleName)
        {
            Style style      = null;
            int   styleIndex = CrossView.StyleSheet.IndexOf(CrossView.Style);

            if (styleIndex != -1)
            {
                StyleCollection styles = CrossView.StyleSheet[styleIndex];
                style = styles[styles.IndexOf(styleName)];
            }
            if (style != null)
            {
                cell.ApplyStyle(style);
            }
        }
Ejemplo n.º 4
0
        private void btnAdd_Click(object sender, EventArgs e)
        {
            Style  s           = new Style();
            int    styleNumber = 1;
            string baseName    = Res.Get("Forms,Style,StyleName");

            while (FStyles.IndexOf(baseName + styleNumber.ToString()) != -1)
            {
                styleNumber++;
            }
            s.Name = baseName + styleNumber.ToString();
            FStyles.Add(s);
            ListViewItem li = lvStyles.Items.Add(s.Name, 87);

            li.Tag = s;
            li.BeginEdit();
        }