You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
428 lines
14 KiB
428 lines
14 KiB
using DevExpress.Xpf.Core; |
|
using KGIS.Framework.Utils; |
|
using KGIS.Framework.Utils.ExtensionMethod; |
|
using Kingo.Plugin.EngineEditor.Model; |
|
using KGIS.Framework.Utils.Helper; |
|
using System; |
|
using System.Collections.Generic; |
|
using System.ComponentModel; |
|
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; |
|
|
|
namespace Kingo.Plugin.EngineEditor.Views |
|
{ |
|
/// <summary> |
|
/// FrmDrawDoublePolyline.xaml 的交互逻辑 |
|
/// </summary> |
|
public partial class FrmDrawDoublePolyline : DXWindow |
|
{ |
|
private DrawParam DrawParam = new DrawParam(); |
|
public delegate void StartDrawHandler(DrawParam drawParam); |
|
/// <summary> |
|
/// 开始绘制事件 |
|
/// </summary> |
|
public event StartDrawHandler StartDrawEvent; |
|
public FrmDrawDoublePolyline() |
|
{ |
|
InitializeComponent(); |
|
//绘制方式(默认左右两边绘制) |
|
DrawParam.DrawMode = DrawMode.LeftAndRight; |
|
DrawParam.Width = 10; |
|
DrawParam.OutType = "Polyline"; |
|
DrawParam.DLBM = "1004-城镇村道路用地"; |
|
//FrmDrawDoublePolyline fddpl = new FrmDrawDoublePolyline(); |
|
//fddpl.Show(); |
|
|
|
} |
|
public FrmDrawDoublePolyline(DrawParam pDrawParam, int p = 0) |
|
{ |
|
InitializeComponent(); |
|
if (p == -1) |
|
{ |
|
paraXWKD.Visibility = System.Windows.Visibility.Collapsed; |
|
spAutoCheckbox.Visibility = System.Windows.Visibility.Collapsed; |
|
//this.Height = 75; |
|
} |
|
//else |
|
//{ |
|
// spAutoCheckbox.Visibility = System.Windows.Visibility.Visible; |
|
// this.Height = 95; |
|
//} |
|
List<DataDicTionary> dic = new List<DataDicTionary>(); |
|
dic.Add(new DataDicTionary() { CODE = "LeftAndRight", NAME = "中心线" }); |
|
dic.Add(new DataDicTionary() { CODE = "Left", NAME = "左边线" }); |
|
dic.Add(new DataDicTionary() { CODE = "Right", NAME = "右边线" }); |
|
combDrawMode.ItemsSource = dic; |
|
//绘制方式(默认左右两边绘制) |
|
this.DrawParam = pDrawParam; |
|
if (string.IsNullOrWhiteSpace(this.DrawParam.DLBM)) |
|
{ |
|
this.DrawParam.DLBM = "1004-城镇村道路用地"; |
|
} |
|
this.DataContext = this.DrawParam; |
|
//记录之前选中过的地类编码 |
|
if (this.DrawParam != null && !string.IsNullOrWhiteSpace(this.DrawParam.DLBM)) |
|
{ |
|
for (int i = 0; i < cmbDL.Items.Count; i++) |
|
{ |
|
ComboBoxItem comBox = cmbDL.Items[i] as ComboBoxItem; |
|
if (comBox.Content.Equals(DrawParam.DLBM)) |
|
{ |
|
cmbDL.SelectedIndex = i; |
|
} |
|
} |
|
} |
|
|
|
this.cbAutoClose.IsChecked = DrawParam.IsAutoClose; |
|
this.cbAutoStep.IsChecked = DrawParam.IsAutoStep; |
|
this.cbAutoTrack.IsChecked = DrawParam.IsAutoTrack; |
|
//有记录值时再赋值,防止值变化导致变更事件判断错误 |
|
if (DrawParam.SetWidth >= 0.1 && DrawParam.SetWidth <= 10) |
|
{ |
|
this.txtSetWidth.Text = DrawParam.SetWidth.ToString(); |
|
} |
|
//给出DrawParam里微调值的默认值 |
|
else |
|
{ |
|
DrawParam.SetWidth = this.txtSetWidth.Text.Trim().ToDouble(); |
|
} |
|
this.SetParam(false, true); |
|
this.ShowInMainForm(); |
|
//this.spinScale.EditValue = this.DrawParam.ToloranceScale; |
|
} |
|
//public void SetVisible(bool isVisible) |
|
//{ |
|
// if (isVisible) |
|
// { |
|
// cmbDL.Visibility = System.Windows.Visibility.Visible; |
|
// cbAutoClose.Visibility = System.Windows.Visibility.Collapsed; |
|
// } |
|
// else |
|
// { |
|
// cbAutoClose.Visibility = System.Windows.Visibility.Visible; |
|
// cmbDL.Visibility = System.Windows.Visibility.Collapsed; |
|
// } |
|
//} |
|
public void SetParam(bool IsImgIdentity, bool IsPolygon) |
|
{ |
|
try |
|
{ |
|
if (IsImgIdentity) |
|
{ |
|
paraAutoIdentity.Visibility = System.Windows.Visibility.Visible; |
|
paraXWKD.Visibility = System.Windows.Visibility.Collapsed; |
|
} |
|
else |
|
{ |
|
paraAutoIdentity.Visibility = System.Windows.Visibility.Collapsed; |
|
paraXWKD.Visibility = System.Windows.Visibility.Visible; |
|
} |
|
if (IsPolygon) |
|
{ |
|
cmbDL.Visibility = System.Windows.Visibility.Visible; |
|
cbAutoClose.Visibility = System.Windows.Visibility.Collapsed; |
|
} |
|
else |
|
{ |
|
cbAutoClose.Visibility = System.Windows.Visibility.Visible; |
|
cmbDL.Visibility = System.Windows.Visibility.Collapsed; |
|
} |
|
if (!IsImgIdentity && IsPolygon) |
|
{ |
|
laSetWidth.Visibility = System.Windows.Visibility.Visible; |
|
} |
|
else |
|
{ |
|
laSetWidth.Visibility = System.Windows.Visibility.Collapsed; |
|
} |
|
} |
|
catch (Exception ex) |
|
{ |
|
//Common.Utility.LogAPI.Debug(ex); |
|
|
|
LogAPI.Debug("画双线期间 设置参数 时异常,异常信息如下:"); |
|
LogAPI.Debug(ex); |
|
LogAPI.Debug("画双线期间 设置参数 时异常信息结束"); |
|
} |
|
} |
|
/// <summary> |
|
/// 控制控件状态 |
|
/// </summary> |
|
/// <param name="sender"></param> |
|
/// <param name="e"></param> |
|
private void RadioButton_Click(object sender, RoutedEventArgs e) |
|
{ |
|
RadioButton btn = sender as RadioButton; |
|
DrawParam.DrawMode = (DrawMode)System.Enum.Parse(typeof(DrawMode), btn.Tag.ToString()); |
|
} |
|
/// <summary> |
|
/// 开始绘制按钮事件 |
|
/// </summary> |
|
/// <param name="sender"></param> |
|
/// <param name="e"></param> |
|
private void btnStartDraw_Click(object sender, RoutedEventArgs e) |
|
{ |
|
//DrawParam.IsAutoClose = cbAutoClose.IsChecked == true ? true : false; |
|
if (StartDrawEvent != null) |
|
{ |
|
StartDrawEvent(DrawParam); |
|
} |
|
} |
|
|
|
private void OutTypeRadioButton_Click(object sender, RoutedEventArgs e) |
|
{ |
|
RadioButton btn = sender as RadioButton; |
|
DrawParam.OutType = btn.Tag.ToString(); |
|
switch (btn.Tag.ToString()) |
|
{ |
|
case "Polyline": |
|
cbAutoClose.IsEnabled = true; |
|
break; |
|
case "Polygon": |
|
cbAutoClose.IsEnabled = false; |
|
cbAutoClose.IsChecked = true; |
|
break; |
|
default: |
|
break; |
|
} |
|
} |
|
|
|
private void cbAutoClose_Click(object sender, RoutedEventArgs e) |
|
{ |
|
DrawParam.IsAutoClose = cbAutoClose.IsChecked == true ? true : false; |
|
} |
|
|
|
private void spinScale_EditValueChanged(object sender, DevExpress.Xpf.Editors.EditValueChangedEventArgs e) |
|
{ |
|
//this.DrawParam.ToloranceScale = (double)spinScale.Value; |
|
} |
|
|
|
private void combDrawMode_SelectionChanged(object sender, SelectionChangedEventArgs e) |
|
{ |
|
//this.DrawParam.DrawMode = (DrawMode)Enum.Parse(typeof(DrawMode), combDrawMode.SelectedValue.ToString()); |
|
} |
|
|
|
private void cbAutoTrack_Click(object sender, RoutedEventArgs e) |
|
{ |
|
if (cbAutoTrack.IsChecked == true) |
|
{ |
|
DrawParam.IsAutoTrack = true; |
|
} |
|
else |
|
{ |
|
DrawParam.IsAutoTrack = false; |
|
} |
|
} |
|
|
|
private void cbAutoStep_Click(object sender, RoutedEventArgs e) |
|
{ |
|
if (cbAutoStep.IsChecked == true) |
|
{ |
|
DrawParam.IsAutoStep = true; |
|
} |
|
else |
|
{ |
|
DrawParam.IsAutoStep = false; |
|
} |
|
} |
|
|
|
private void cmbDL_SelectionChanged(object sender, SelectionChangedEventArgs e) |
|
{ |
|
ComboBoxItem item = (ComboBoxItem)cmbDL.Items[cmbDL.SelectedIndex]; |
|
if (item.Content != null) |
|
{ |
|
DrawParam.DLBM = item.Content.ToString(); |
|
} |
|
else |
|
{ |
|
DrawParam.DLBM = string.Empty; |
|
} |
|
} |
|
|
|
private void paraWidth_EditValueChanged(object sender, DevExpress.Xpf.Editors.EditValueChangedEventArgs e) |
|
{ |
|
decimal widthTxt = 10; |
|
if (decimal.TryParse(paraWidth.Text, out widthTxt)) |
|
{ |
|
this.paraWidth.Value = Math.Round(widthTxt, 2, MidpointRounding.AwayFromZero); |
|
} |
|
} |
|
//更换判断事件,原事件在修改过程中就会判断,容易导致判断错误 |
|
private void txtSetWidth_MouseLeave(object sender, MouseEventArgs e) |
|
{ |
|
double setWidth; |
|
if (!double.TryParse(txtSetWidth.Text.Trim(), out setWidth)) |
|
{ |
|
MessageHelper.ShowError("数值不合法!"); |
|
return; |
|
} |
|
double RoundSetWidth = Math.Round(setWidth, 1); |
|
//增加微调值范围控制 |
|
if ((RoundSetWidth < 0.1 || RoundSetWidth > 10)) |
|
{ |
|
MessageHelper.ShowTips("微调值须在0.1-10之间!"); |
|
//微调值输入不合法时,恢复上一次设置的微调值 |
|
txtSetWidth.Text = DrawParam.SetWidth.ToString(); |
|
return; |
|
} |
|
txtSetWidth.Text = RoundSetWidth.ToString(); |
|
DrawParam.SetWidth = RoundSetWidth; |
|
} |
|
|
|
private void DXWindow_Closed(object sender, EventArgs e) |
|
{ |
|
BindingOperations.ClearAllBindings(this); |
|
} |
|
|
|
} |
|
|
|
/// <summary> |
|
/// 绘制方式 |
|
/// </summary> |
|
public enum DrawMode |
|
{ |
|
/// <summary> |
|
/// 左边绘制 |
|
/// </summary> |
|
Left = 1, |
|
/// <summary> |
|
/// 右边绘制 |
|
/// </summary> |
|
Right = 2, |
|
/// <summary> |
|
/// 两边绘制 |
|
/// </summary> |
|
LeftAndRight = 3 |
|
} |
|
public class DrawParam : INotifyPropertyChanged |
|
{ |
|
/// <summary> |
|
/// 绘制方式 |
|
/// </summary> |
|
public DrawMode DrawMode { get; set; } |
|
private double _Width; |
|
/// <summary> |
|
/// 宽度 |
|
/// </summary> |
|
public double Width |
|
{ |
|
get |
|
{ |
|
return _Width; |
|
} |
|
set |
|
{ |
|
_Width = Math.Round(value, 2, MidpointRounding.AwayFromZero); |
|
//if (_Width > 15) |
|
//{ |
|
// this.ToloranceScale = 0.3; |
|
//} |
|
//else if (_Width <= 15 && _Width > 0) |
|
//{ |
|
// this.ToloranceScale = 0.1; |
|
//} |
|
if (PropertyChanged != null) |
|
{ |
|
PropertyChanged(this, new PropertyChangedEventArgs("Width")); |
|
} |
|
} |
|
} |
|
private double _setWdth; |
|
/// <summary> |
|
/// 微调值 |
|
/// </summary> |
|
public double SetWidth |
|
{ |
|
get |
|
{ |
|
return _setWdth; |
|
} |
|
set |
|
{ |
|
_setWdth = value; |
|
} |
|
} |
|
/// <summary> |
|
/// 是否自动封闭 |
|
/// </summary> |
|
public bool IsAutoClose { get; set; } |
|
/// <summary> |
|
/// 输出类型 |
|
/// </summary> |
|
public string OutType { get; set; } |
|
private double _ToloranceScale; |
|
/// <summary> |
|
/// 容差比例(自动识别度) |
|
/// </summary> |
|
public double ToloranceScale |
|
{ |
|
get |
|
{ |
|
return _ToloranceScale; |
|
} |
|
set |
|
{ |
|
_ToloranceScale = value; |
|
if (PropertyChanged != null) |
|
{ |
|
PropertyChanged(this, new PropertyChangedEventArgs("ToloranceScale")); |
|
} |
|
} |
|
} |
|
private bool _IsAutoTrack { get; set; } |
|
public bool IsAutoTrack |
|
{ |
|
get |
|
{ |
|
return _IsAutoTrack; |
|
} |
|
set |
|
{ |
|
_IsAutoTrack = value; |
|
if (PropertyChanged != null) |
|
{ |
|
PropertyChanged(this, new PropertyChangedEventArgs("IsAutoTrack")); |
|
} |
|
} |
|
} |
|
private bool _IsAutoStep; |
|
public bool IsAutoStep |
|
{ |
|
get { return _IsAutoStep; } |
|
set |
|
{ |
|
_IsAutoStep = value; |
|
if (PropertyChanged != null) |
|
{ |
|
PropertyChanged(this, new PropertyChangedEventArgs("IsAutoStep")); |
|
} |
|
} |
|
} |
|
private string _DLBM; |
|
public string DLBM |
|
{ |
|
get { return _DLBM; } |
|
set |
|
{ |
|
_DLBM = value; |
|
if (PropertyChanged != null) |
|
{ |
|
PropertyChanged(this, new PropertyChangedEventArgs("DLBM")); |
|
} |
|
} |
|
} |
|
public event PropertyChangedEventHandler PropertyChanged; |
|
|
|
} |
|
|
|
}
|
|
|