コード例 #1
0
        Point CreateImageLabel(List <ExtPictureBox.ImageElement> c, Image i, Point postopright, Size size, string label,
                               string ttext, int labelhoff, bool fromEDSM, bool imgowned = true)
        {
            //System.Diagnostics.Debug.WriteLine("    " + label + " " + postopright + " size " + size + " hoff " + labelhoff + " laby " + (postopright.Y + size.Height + labelhoff));

            ExtPictureBox.ImageElement ie = new ExtPictureBox.ImageElement(new Rectangle(postopright.X, postopright.Y, size.Width, size.Height), i, ttext, ttext, imgowned);

            Point max = new Point(postopright.X + size.Width, postopright.Y + size.Height);

            if (label != null)
            {
                Font font = stdfont;
                if (fromEDSM)
                {
                    font = stdfontUnderline;
                }

                Point labposcenthorz = new Point(postopright.X + size.Width / 2, postopright.Y + size.Height + labelhoff);

                ExtPictureBox.ImageElement lab = new ExtPictureBox.ImageElement();
                Size maxsize = new Size(300, 30);

                //System.Diagnostics.Debug.WriteLine("Write Label " + label + " " + EDDTheme.Instance.LabelColor + " " + this.BackColor);

                lab.TextCentreAutosize(labposcenthorz, maxsize, label, font, EDDTheme.Instance.LabelColor, this.BackColor);

                if (lab.pos.X < postopright.X)
                {
                    int offset = postopright.X - lab.pos.X;
                    ie.Translate(offset, 0);
                    lab.Translate(offset, 0);
                }

                c.Add(lab);

                max = new Point(Math.Max(lab.pos.X + lab.pos.Width, max.X), lab.pos.Y + lab.pos.Height);
            }

            c.Add(ie);

            //System.Diagnostics.Debug.WriteLine(" ... to " + label + " " + max + " size " + (new Size(max.X-postopright.X,max.Y-postopright.Y)));
            return(max);
        }
コード例 #2
0
        // plot at leftmiddle the image of size, return bot left accounting for label
        // label can be null. returns ximagecentre of image

        Point CreateImageAndLabel(List <ExtPictureBox.ImageElement> c, Image i, Point leftmiddle, Size size, out Rectangle imageloc,
                                  string[] labels, string ttext, bool imgowned = true)
        {
            //System.Diagnostics.Debug.WriteLine("    " + label + " " + postopright + " size " + size + " hoff " + labelhoff + " laby " + (postopright.Y + size.Height + labelhoff));

            ExtPictureBox.ImageElement ie = new ExtPictureBox.ImageElement(new Rectangle(leftmiddle.X, leftmiddle.Y - size.Height / 2, size.Width, size.Height), i, ttext, ttext, imgowned);

            Point max = new Point(leftmiddle.X + size.Width, leftmiddle.Y + size.Height / 2);

            var labelie = new List <ExtPictureBox.ImageElement>();
            int laboff  = 0;
            int vpos    = leftmiddle.Y + size.Height / 2;

            foreach (string label in labels)
            {
                if (label.HasChars())
                {
                    Font f      = stdfont;
                    int  labcut = 0;
                    if (label[0] == '_')
                    {
                        f      = stdfontUnderline;
                        labcut = 1;
                    }

                    Point labposcenthorz = new Point(leftmiddle.X + size.Width / 2, vpos);

                    ExtPictureBox.ImageElement labie = new ExtPictureBox.ImageElement();
                    Color backcolor = this.BackColor;       // override for debug

                    using (var frmt = new StringFormat()
                    {
                        Alignment = StringAlignment.Center
                    })
                    {
                        labie.TextCentreAutosize(labposcenthorz, new Size(0, 1000), label.Substring(labcut), f, EDDTheme.Instance.LabelColor, backcolor, frmt: frmt);
                    }

                    labelie.Add(labie);

                    if (labie.Location.X < leftmiddle.X)
                    {
                        laboff = Math.Max(laboff, leftmiddle.X - labie.Location.X);
                    }
                    vpos += labie.Location.Height;
                }
            }


            foreach (var l in labelie)
            {
                l.Translate(laboff, 0);
                c.Add(l);
                max = new Point(Math.Max(max.X, l.Location.Right), Math.Max(max.Y, l.Location.Bottom));
                //System.Diagnostics.Debug.WriteLine("Label " + l.Location);
            }

            ie.Translate(laboff, 0);
            max = new Point(Math.Max(max.X, ie.Location.Right), Math.Max(max.Y, ie.Location.Bottom));
            c.Add(ie);

            imageloc = ie.Location;     // used to be ximagecentre = ie.Location.X+ie.Location.Width/2

            //System.Diagnostics.Debug.WriteLine(".. Max " + max);

            return(max);
        }