<output id="qn6qe"></output>

    1. <output id="qn6qe"><tt id="qn6qe"></tt></output>
    2. <strike id="qn6qe"></strike>

      亚洲 日本 欧洲 欧美 视频,日韩中文字幕有码av,一本一道av中文字幕无码,国产线播放免费人成视频播放,人妻少妇偷人无码视频,日夜啪啪一区二区三区,国产尤物精品自在拍视频首页,久热这里只有精品12

      一、思路

      在AI的大背景,應(yīng)用層算法已經(jīng)不是問題,那么程序員的差距主要在認知思維模式和創(chuàng)新上面。目前AI的局限主要卻決于溝通的效率,這是雙方的問題,AI可能理解能力不足,或者提問者表達能力不足。
      這里我以PDFsharp實現(xiàn)Grid布局模式分享一下基于GPT實現(xiàn)的過程。因為PDFsharp只提供了XGraphics。類似.NET自帶的Drawing圖像庫。
      即這個思路通用適用于支持Drawing操作相關(guān)的庫。

      1. Grid布局:基于行列進行布局。
      2. 內(nèi)外邊距:行和單元格存在內(nèi)外邊距,這里的內(nèi)外邊距控制當前元素繪制的起點實現(xiàn)。
      3. 行寬:優(yōu)先扣除掉行左右外邊距,如果寬度不夠那么壓縮最后一個單元格。這樣實現(xiàn)了行居中的效果,通過控制內(nèi)外邊距Margin。
      4. 單元格的寬度:如果是一個文本單元格,用戶未指定寬度,那么使用XGraphics計算出來文本的寬度,作為單元格的寬度。如果行內(nèi)只有一個單元格并且沒有指定寬度,那么等于行寬。
      5. 單元格的高度:如果當前是單行文本,那么使用XGraphics計算出來文本的高度,如果單元格支持換行。我們這時候需要先計算完所有單元格的寬度,然后基于單元格的寬度(扣除掉內(nèi)邊距,因為寬度計算方式由思路4決定),就可以計算出來行數(shù)了,顯然內(nèi)邊距會影響行數(shù)。
      6. 單元格的高度:行數(shù) * 字體高度 +(行數(shù)-1)* 行間距 + 上下內(nèi)邊距。(高度自適應(yīng))
      7. 行高:等于行內(nèi)單元格最高的高度,實現(xiàn)高度自適應(yīng)。如果用戶指定了行高,并且大于行內(nèi)單元格最高的高度,那么行高使用用戶指定的行高

      二、抽象數(shù)據(jù)結(jié)構(gòu)

      //網(wǎng)格
      public class XGrid
      {
          private readonly List<XGridRow> _rows = new List<XGridRow>();
      
          public void DrawRow(Action<XGridRow> configure)
          {
              var row = new XGridRow();
              configure(row);
              _rows.Add(row);
          }
      
          internal IReadOnlyList<XGridRow> Rows => _rows;
      }
      //行
      public class XGridRow
      {
          private readonly List<XGridCell> _cells = new List<XGridCell>();
      
          public XGridBox Margin { get; set; } = new XGridBox(0);
      
          public double Height { get; set; }
          public double Width { get; set; }
      
          public XGridBorder Border { get; } = new XGridBorder();
      
          public void DrawTextCell(Action<XGridTextCell> configure)
          {
              var cell = new XGridTextCell();
              configure(cell);
              _cells.Add(cell);
          }
      
          public void DrawImageCell(Action<XGridImageCell> configure)
          {
              var cell = new XGridImageCell();
              configure(cell);
              _cells.Add(cell);
          }
      
          internal IReadOnlyList<XGridCell> Cells => _cells;
      }
      //單元格
      public abstract class XGridCell
      {
          /// <summary>
          /// 高度
          /// </summary>
          public double Height { get; set; }
          /// <summary>
          /// 寬度
          /// </summary>
          public double Width { get; set; }
          /// <summary>
          /// 控制內(nèi)邊距
          /// </summary>
          public XGridBox Margin { get; set; } = new XGridBox(0);
          /// <summary>
          /// 控制外邊距
          /// </summary>
          public XGridBox Padding { get; set; } = new XGridBox(0);
          /// <summary>
          /// 水平對齊方式
          /// </summary>
          public XGridAlignment HorizontalAlignment { get; set; } = XGridAlignment.Left;
          /// <summary>
          /// 垂直對齊方式
          /// </summary>
          public XGridAlignment VerticalAlignment { get; set; } = XGridAlignment.Center;
      
          internal XGridRow Row { get; }
          /// <summary>
          /// 控制邊框
          /// </summary>
          public XGridBorder Border { get; } = new XGridBorder();
      }
      //文本單元格
      public class XGridTextCell : XGridCell
      {
         /// <summary>
         /// 控制換行
         /// </summary>
         public bool Warp { get; set; } = true;
         /// <summary>
         /// 文本
         /// </summary>
         public string Text { get; set; }
         /// <summary>
         /// 多行文本的行間距
         /// </summary>
         public double LineSpacing { get; set; } = 0;
      }
      //圖像單元格
      public class XGridImageCell : XGridCell
      {
          /// <summary>
          /// 要在此單元格中渲染的圖片。
          /// </summary>
          public XImage Image { get; set; }
          
          public double ImageWidth { get; set; }
      
          public double ImageHeight { get; set; }
        
      }
      //邊框,對齊,內(nèi)外邊距就略過了。
      

      三、定義保留的API和使用方式

      document.DrawPage((page, gfx) =>
      {
          var footerFont = new XFont("STSONG.TTF", 18, XFontStyleEx.Bold);
          //繪制網(wǎng)格,指定y軸偏移
          gfx.DrawGrid(100, footerFont, XBrushes.Black, grid =>
          {
              //繪制行
              grid.DrawRow(row =>
              {
                  //設(shè)置外邊距
                  row.Margin.SetHorizontal(100, 100);
                  row.DrawTextCell(cell =>
                  {
                      cell.Text = "你好";
                      cell.Border.Visible = true;
                      cell.Width = 100;
                      cell.VerticalAlignment = XGridAlignment.Top;
                      cell.HorizontalAlignment = XGridAlignment.Right;
                  });
                  row.DrawTextCell(cell =>
                  {
                      cell.Text = "工程造價咨詢報告書工程造價咨詢報告書工程造價咨詢報告書工程造價咨詢報告書工程造價咨詢報告書工程造價咨詢報告書";
                      cell.Border.Visible = true;
                      cell.Width = 200;
                      cell.Padding = 0;//設(shè)置內(nèi)邊距,這里用到了隱式轉(zhuǎn)換語法,Padding 實際是一個class
                      cell.HorizontalAlignment = XGridAlignment.Left;
                  });
                  row.DrawImageCell(cell =>
                  {
                      cell.Image = XImage.FromFile("./images/hjd.jpg");
                      cell.Border.Visible = true;
                      cell.Width = 200;
                      cell.ImageWidth = 40;
                      cell.ImageHeight = 40;
                      cell.HorizontalAlignment = XGridAlignment.Center;
                      cell.VerticalAlignment = XGridAlignment.Center;
                  });
              });
          });
      });
      

      四、通過GPT實現(xiàn)

      我們將實現(xiàn)思路和定義好的數(shù)據(jù)結(jié)構(gòu)給他,告訴他需要實現(xiàn)的函數(shù)簽名即:void DrawGrid(this XGraphics graphics, double y, XFont font, XBrush brush, Action configure)
      我們一步步引導(dǎo)完成。省事省力。

      五最終效果



      posted on 2024-08-23 13:06  花間島  閱讀(57)  評論(0)    收藏  舉報

      主站蜘蛛池模板: 国产日韩久久免费影院| 激情伊人五月天久久综合| aaa少妇高潮大片免费看| 日本高清视频网站www| 国产精品偷伦费观看一次 | 免费人成再在线观看视频| 成人做受120秒试看试看视频| 久久久久久无码午夜精品直播| 性XXXX视频播放免费直播| 无码天堂亚洲国产av麻豆| 久久精品国产久精国产| 兴仁县| 国产精品va无码一区二区| 亚洲国产精品黄在线观看| 免费大黄网站在线观看| 深田えいみ禁欲后被隔壁人妻| 色综合伊人色综合网站| 女同在线观看亚洲国产精品| 国产精品国产三级国产a| 亚洲精品无码av人在线观看| 日韩精品福利一二三专区| 久久人人97超碰爱香蕉 | 中文字幕av无码免费一区| h无码精品动漫在线观看| 露脸一二三区国语对白| 国产仑乱无码内谢| 蜜桃无码一区二区三区| 国产精品v片在线观看不卡| 亚洲精品喷潮一区二区三区| 一区二区免费高清观看国产丝瓜| 国产精品尤物乱码一区二区| 国产91精选在线观看| 国产精品中文字幕自拍| 中文人妻AV高清一区二区| 国产午夜无码视频在线观看| 福泉市| 伊人中文在线最新版天堂 | 国内自拍小视频在线看| 深夜福利资源在线观看| 亚洲aⅴ无码专区在线观看q| 国产成人午夜福利在线播放 |