為使設計介面類似專業繪圖工具,動態生成網格線。採用 Canvas 承載 Line 元素,避免使用背景圖片。
GridLinesContainer.Children.Clear();
SolidColorBrush brush = new SolidColorBrush(Color.FromArgb(255, 160, 160, 160));
double thickness = 0.3;
double stepLength = 40;
double width = cnsDesignerContainer.Width;
double height = cnsDesignerContainer.Height;
// 垂直線
for (double x = stepLength; x < width; x += stepLength)
{
Line line = new Line { X1 = x, Y1 = 0, X2 = x, Y2 = height, Stroke = brush, StrokeThickness = thickness };
GridLinesContainer.Children.Add(line);
}
// 水平線
for (double y = stepLength; y < height; y += stepLength)
{
Line line = new Line { X1 = 0, Y1 = y, X2 = width, Y2 = y, Stroke = brush, StrokeThickness = thickness };
GridLinesContainer.Children.Add(line);
}
注意:實際專案中需處理捲軸位移與 Z-Index 層級,確保網格線永遠在最底層。
定義 IWorkflowService 介面,包含 GetWorkflow(string id) 與 SaveWorkflow(WorkflowData data) 方法。WorkflowData 為資料傳輸物件(DTO),封裝流程 ID、名稱、XML 內容等欄位。Silverlight 客戶端透過非同步呼叫與伺服器互動。