135 lines
4.5 KiB
C#
135 lines
4.5 KiB
C#
using Autodesk.Revit.UI;
|
|
using HandyControl.Tools;
|
|
using RookieStation.ParcelAreaModule;
|
|
using RookieStation.ParcelAreaModule.Models;
|
|
using RookieStation.ParcelAreaModule.ViewModels;
|
|
using RookieStation.Utils;
|
|
using System;
|
|
using System.Collections.Specialized;
|
|
using System.Linq;
|
|
using System.Windows;
|
|
using System.Windows.Input;
|
|
|
|
namespace RookieStation.ParcelAreaModule.Views
|
|
{
|
|
/// <summary>
|
|
/// WpfShelvesLayout.xaml 的交互逻辑
|
|
/// </summary>
|
|
public partial class WpfShelvesLayout
|
|
{
|
|
public ShelvesPlacementViewModel vm = new ShelvesPlacementViewModel();
|
|
|
|
public WpfShelvesLayout()
|
|
{
|
|
InitializeComponent();
|
|
|
|
dgShelves.DataContext = vm;
|
|
}
|
|
|
|
private void btnConfirm_Click(object sender, RoutedEventArgs e)
|
|
{
|
|
//bool a = int.TryParse(cbLength.Text, out tLength);
|
|
//bool b = int.TryParse(cbWidth.Text, out tWidth);
|
|
double verticalDistance;
|
|
double parallelDistance;
|
|
double passageWidth;
|
|
double shelfSpacing;
|
|
double lightHeight;
|
|
bool a = double.TryParse(tbOffest.Text, out verticalDistance);
|
|
bool b = double.TryParse(tbDistance.Text, out parallelDistance);
|
|
bool c = double.TryParse(tbPassageWidth.Text, out passageWidth);
|
|
bool d = double.TryParse(tbSpacing.Text, out shelfSpacing);
|
|
bool f = double.TryParse(tbLightHeight.Text, out lightHeight);
|
|
vm.IsPlaceLight = cbLight.IsChecked;
|
|
vm.IsPlaceCableTray = cbCableTray.IsChecked;
|
|
vm.IsPlaceShelfCards = cbCards.IsChecked;
|
|
|
|
if (a && b && c && d && f)
|
|
{
|
|
vm.VerticalReferlineOffest = verticalDistance;
|
|
vm.ParallelReferlineOffest = parallelDistance;
|
|
vm.PassageWidth = passageWidth;
|
|
vm.ShelfSpacing = shelfSpacing;
|
|
vm.LightHeight = lightHeight;
|
|
SaveShelvesData();
|
|
DialogResult = true;
|
|
}
|
|
else
|
|
{
|
|
TaskDialog.Show("温馨提示", "请输入所需参数");
|
|
}
|
|
}
|
|
|
|
/// <summary>
|
|
/// 保存datagrid中的货架信息
|
|
/// </summary>
|
|
private void SaveShelvesData()
|
|
{
|
|
StringCollection sc = new StringCollection();
|
|
for (int i = 0; i < vm.Data.Count; i++)
|
|
{
|
|
Shelf shelf = vm.Data[i];
|
|
string str = $"{CommonUtils.GetEnumDescription(shelf.NumOfGroup)},{CommonUtils.GetEnumDescription(shelf.ShelfLength)},{CommonUtils.GetEnumDescription(shelf.ShelfWidth)}";
|
|
sc.Add(str);
|
|
}
|
|
Properties.Settings.Default.Shelves = sc;
|
|
Properties.Settings.Default.Save();
|
|
}
|
|
|
|
private void btnAdd_Click(object sender, RoutedEventArgs e)
|
|
{
|
|
Shelf s = new Shelf()
|
|
{
|
|
ShelfLength = ShelfLength.x1500,
|
|
ShelfWidth = ShelfWidth.x400,
|
|
NumOfGroup = NumOfGroup.Single,
|
|
};
|
|
vm.Data.Add(s);
|
|
SaveShelvesData();
|
|
//foreach (var shelve in vm.Data)
|
|
//{
|
|
// var g = shelve.GroupAmount;
|
|
// var l = shelve.LengthType;
|
|
// var w = shelve.WidthType;
|
|
//}
|
|
//dgShelves.ItemsSource = null;
|
|
//dgShelves.ItemsSource = Shelves;
|
|
}
|
|
|
|
private void btnDelete_Click(object sender, RoutedEventArgs e)
|
|
{
|
|
if (dgShelves.SelectedItem != null)
|
|
{
|
|
vm.Data.RemoveAt(dgShelves.SelectedIndex);
|
|
SaveShelvesData();
|
|
}
|
|
else
|
|
{
|
|
try
|
|
{
|
|
vm.Data.Remove(vm.Data.Last());
|
|
SaveShelvesData();
|
|
}
|
|
catch (Exception)
|
|
{
|
|
}
|
|
}
|
|
}
|
|
|
|
private void tb_PreviewTextInput(object sender, TextCompositionEventArgs e)
|
|
{
|
|
System.Text.RegularExpressions.Regex re = new System.Text.RegularExpressions.Regex("[^0-9]+");
|
|
e.Handled = re.IsMatch(e.Text);
|
|
}
|
|
|
|
private void btnDuplicate_Click(object sender, RoutedEventArgs e)
|
|
{
|
|
var shelf = dgShelves.SelectedItem as Shelf;
|
|
if (dgShelves.SelectedItem != null && shelf != null)
|
|
{
|
|
vm.Data.Add(shelf);
|
|
SaveShelvesData();
|
|
}
|
|
}
|
|
}
|
|
} |