原有的規則註釋(TextBlock)位置會隨規則自動調整,無法手動拖曳定位。為解決此問題,新增獨立的「標籤」類別,專門用於流程圖上的文字說明,不涉及流程屬性,僅儲存於 XML 設定檔中。
新建 Label.xaml 使用者控制項,包含顯示用的 TextBlock 與編輯用的 TextBox(預設隱藏):
<UserControl x:Class="Shareidea.Web.UI.Control.Workflow.Designer.Label"
xmlns="https://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="https://schemas.microsoft.com/winfx/2006/xaml"
MouseLeftButtonDown="UserControl_MouseLeftButtonDown"
MouseMove="UserControl_MouseMove"
MouseLeftButtonUp="UserControl_MouseLeftButtonUp"
MouseLeave="UserControl_MouseLeave"
Width="400" Height="20">
<Grid x:Name="LayoutRoot" Background="Transparent">
<TextBlock Name="txtLabelName" />
<TextBox Name="tbLabelName" TextChanged="TextBox_TextChanged" Visibility="Collapsed" />
</Grid>
</UserControl>
本節將詳細說明拖曳、XML 序列化與編輯功能的實作細節。