123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081 |
- using Compdfkit_Tools.Data;
- using System;
- using System.Collections.Generic;
- using System.Drawing.Drawing2D;
- using System.Linq;
- using System.Text;
- using System.Threading.Tasks;
- using System.Windows;
- using System.Windows.Controls;
- using System.Windows.Data;
- using System.Windows.Documents;
- using System.Windows.Input;
- using System.Windows.Media;
- using System.Windows.Media.Imaging;
- using System.Windows.Navigation;
- using System.Windows.Shapes;
- using DashStyle = System.Windows.Media.DashStyle;
- namespace Compdfkit_Tools.Common
- {
- /// <summary>
- /// CPDFLineStyleControl.xaml 的交互逻辑
- /// </summary>
- public partial class CPDFLineStyleControl : UserControl
- {
- public event EventHandler LineStyleChanged;
- private DashStyle _dashStyle;
- public DashStyle DashStyle
- {
- get
- {
- _dashStyle = CalculateDashStyle(CPDFLineStyleUI.DashStyle);
- return _dashStyle;
- }
- set
- {
- _dashStyle = value;
- if(_dashStyle.Dashes.ToArray().Length == 0)
- {
- CPDFLineStyleUI.SolidRadioButton.IsChecked = true;
- CPDFLineStyleUI.IsSolid = true;
- CPDFLineStyleUI.DashSpacing = 1;
- }
- else
- {
- CPDFLineStyleUI.DashRadioButton.IsChecked = true;
- CPDFLineStyleUI.IsSolid = false;
- CPDFLineStyleUI.DashSpacing = (int)(_dashStyle.Dashes.ToArray().First());
- }
- }
- }
- public CPDFLineStyleControl()
- {
- InitializeComponent();
- CPDFLineStyleUI.LineStyleChanged += CPDFLineStyleUI_LineStyleChanged;
- }
- public DashStyle CalculateDashStyle(CPDFDashData pdfDash)
- {
- DashStyle dashStyle = new DashStyle();
- if (pdfDash.IsSolid)
- {
- dashStyle = DashStyles.Solid;
- return dashStyle;
- }
- else
- {
- dashStyle.Dashes.Add(pdfDash.DashSpacing);
- dashStyle.Dashes.Add(pdfDash.DashSpacing);
- return dashStyle;
- }
- }
- private void CPDFLineStyleUI_LineStyleChanged(object sender, EventArgs e)
- {
- LineStyleChanged?.Invoke(this, EventArgs.Empty);
- }
- }
- }
|