示例#1
0
        public static void GenerateBitmap(int dim, string path)
        {
            string loc = "Equator";

            // loc: Equator
            Position pos = new Position(Position.LATITUDE_POS,
                                        0, 0, 0,
                                        Position.LONGITUDE_POS,
                                        0, 0, 0);
            // time: Now
            DateTime dt = DateTime.Now;
            UTCDate udt = new UTCDate(0, null,
                                     dt.Year, dt.Month, dt.Day,
                                     dt.Hour, dt.Minute, dt.Second);

            // set up constants
            Colors colors = new Colors();
            string font_face = "Arial";

            // generate base image
            GraphBitmap grbit = new GraphBitmap(true, dim, colors, font_face);
            Bitmap bitmap_plain = grbit.RenderBaseImage(pos, udt);

            // render current day
            Bitmap bitmap = grbit.RenderCurrentDay(bitmap_plain, pos, udt);

            // render caption
            CaptionInfo ci = new CaptionInfo(loc, pos, udt);
            bitmap = grbit.RenderCaption(ci);

            // save
            grbit.SaveBitmap(bitmap, path);
        }
示例#2
0
 public static string FormatCaptionTime(UTCDate udt, CaptionInfo ci)
 {
     string dst_s = string.Empty;
     if (udt.HasDST) {
         dst_s = udt.IsDST ? " DST" : " ST";
     }
     return string.Format("time: {0}{1}", udt.PrintTime(), dst_s);
 }
示例#3
0
        public void PrintCaption(Graphics g, Caption caption, CaptionInfo ci)
        {
            using (SolidBrush brush = new SolidBrush(colors.GraphFg)) {
                PaintCaptionBackground(g, caption);

                int dxx = GetInc(caption);

                float font_size = GetLabelFontSize() * 1.1F;
                using (Font font = new Font(font_face, font_size, GraphicsUnit.Pixel)) {
                    int height = font.Height;

                    List<string> stack = new List<string>();
                    stack.Add(ci.Location);
                    stack.Add(Formatter.FormatCaptionPosition(ci.Position));
                    stack.Add(Formatter.FormatCaptionTimezone(ci.Timezone, ci.Timezone+ci.DST));
                    PrintVertically(g, brush, font, caption, caption.A+dxx, caption.B, stack);

                    stack = new List<string>();
                    stack.Add(string.Empty);
                    stack.Add(Formatter.FormatCaptionDate(ci.Date));
                    stack.Add(Formatter.FormatCaptionTime(ci.Date, ci));
                    PrintVertically(g, brush, font, caption, caption.A+dxx, caption.B+3*height, stack);

                    int h_ang = (int) (7.5 * (double) height);

                    stack = new List<string>();
                    stack.Add(string.Format("solar elevation: {0}",
                                            Formatter.FormatAngle(ci.Elevation)));
                    stack.Add(string.Format("solar azimuth: {0}",
                                            Formatter.FormatAngle(ci.Azimuth)));
                    PrintHorizontally(g, brush, font, caption, caption.B+h_ang, stack);

                    int h_tm = (int) (10 * (double) height);

                    stack = new List<string>();
                    stack.Add(Formatter.FormatTime(ci.Dawn));
                    stack.Add(Formatter.FormatTime(ci.Sunrise));
                    stack.Add(Formatter.FormatTime(ci.Noon));
                    stack.Add(Formatter.FormatTime(ci.Sunset));
                    stack.Add(Formatter.FormatTime(ci.Dusk));
                    PrintHorizontally(g, brush, font, caption, caption.B+h_tm, stack);

                    stack = new List<string>();
                    stack.Add("dawn");
                    stack.Add("sunrise");
                    stack.Add("solar noon");
                    stack.Add("sunset");
                    stack.Add("dusk");
                    PrintHorizontally(g, brush, font, caption, caption.B+h_tm+1*height, stack);

                    RenderMap(g, ci.Position, caption);
                }
            }
        }
示例#4
0
 public Bitmap RenderCaption(CaptionInfo ci)
 {
     using (Graphics g = Graphics.FromImage(bitmap)) {
         Caption caption = new Caption(0, dimensions+titleheight,
                                       dimensions, dimensions+titleheight+captionheight);
         grapher.PrintCaption(g, caption, ci);
         grapher.PrintTitle(g, 0, 0, dimensions, titleheight);
     }
     return bitmap;
 }