예제 #1
0
        private static void drawRegionBorder(ConsoleRegion r)
        {
            //bool touchLeft = Regions.Any(p => (p.Value.Origin.X + p.Value.Width) == r.Origin.X);
            //bool touchRight = Regions.Any(p => (p.Value.Origin.X) == r.Origin.X + r.Width);
            //bool touchTop = Regions.Any(p => (p.Value.Origin.Y + p.Value.Height) == r.Origin.Y);
            //bool touchBottom = Regions.Any(p => (p.Value.Origin.Y) == r.Origin.Y + r.Height);

            //Generate first line
            string firstline  = Corner;
            int    lentitle   = r.Title.Length;
            int    w          = r.Width;
            int    titlestart = Convert.ToInt32(Math.Floor((w / 2m) - (lentitle / 2m)));

            if (titlestart * 2 + lentitle > r.Width)
            {
                titlestart--;
            }

            //Replace part of line with title
            for (int x = 0; x < r.Width - 2; x++)
            {
                if (x == titlestart)
                {
                    firstline += r.Title;
                    x         += lentitle - 1;
                }
                else
                {
                    firstline += Hori;
                }
            }
            firstline += Corner;

            //Generate last line
            string lastline = Corner;

            for (int x = 0; x < r.Width - 2; x++)
            {
                lastline += Hori;
            }
            lastline += Corner;

            //Make space-buffer
            string space = string.Empty;

            for (int x = 0; x < r.Width - 2; x++)
            {
                space += Blank;
            }

            //Write border
            Console.SetCursorPosition(r.Origin.X, r.Origin.Y);
            Console.WriteLine(firstline);

            for (int x = 1; x < r.Height - 1; x++)
            {
                Console.SetCursorPosition(r.Origin.X, r.Origin.Y + x);
                Console.Write(Vert + space + Vert);
            }

            Console.SetCursorPosition(r.Origin.X, r.Origin.Y + r.Height - 1);
            Console.WriteLine(lastline);
        }
    private static void drawRegionBorder(ConsoleRegion r) {
      //bool touchLeft = Regions.Any(p => (p.Value.Origin.X + p.Value.Width) == r.Origin.X);
      //bool touchRight = Regions.Any(p => (p.Value.Origin.X) == r.Origin.X + r.Width);
      //bool touchTop = Regions.Any(p => (p.Value.Origin.Y + p.Value.Height) == r.Origin.Y);
      //bool touchBottom = Regions.Any(p => (p.Value.Origin.Y) == r.Origin.Y + r.Height);

      //Generate first line
      string firstline = Corner;
      int lentitle = r.Title.Length;
      int w = r.Width;
      int titlestart = Convert.ToInt32(Math.Floor((w / 2m) - (lentitle / 2m)));
      if (titlestart * 2 + lentitle > r.Width) titlestart--;

      //Replace part of line with title
      for (int x = 0; x < r.Width - 2; x++)
        if (x == titlestart) {
          firstline += r.Title;
          x += lentitle - 1;
        } else
          firstline += Hori;
      firstline += Corner;

      //Generate last line
      string lastline = Corner;
      for (int x = 0; x < r.Width - 2; x++)
        lastline += Hori;
      lastline += Corner;

      //Make space-buffer
      string space = string.Empty;
      for (int x = 0; x < r.Width - 2; x++)
        space += Blank;

      //Write border
      Console.SetCursorPosition(r.Origin.X, r.Origin.Y);
      Console.WriteLine(firstline);

      for (int x = 1; x < r.Height - 1; x++) {
        Console.SetCursorPosition(r.Origin.X, r.Origin.Y + x);
        Console.Write(Vert + space + Vert);
      }

      Console.SetCursorPosition(r.Origin.X, r.Origin.Y + r.Height - 1);
      Console.WriteLine(lastline);
    }