SetWindowWaitControl.xaml.cs
上传用户:lvyingde
上传日期:2018-04-24
资源大小:610k
文件大小:4k
源码类别:
SilverLight
开发平台:
C#
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Net;
- using System.Windows;
- using System.Windows.Controls;
- using System.Windows.Documents;
- using System.Windows.Input;
- using System.Windows.Media;
- using System.Windows.Media.Animation;
- using System.Windows.Shapes;
- namespace wxwinter.WFDesignerSl
- {
- public partial class SetWindowWaitControl : UserControl
- {
- WaitControl activity;
- List<string> designerNameList;
- DesignerControl designer;
- System.Random rd = new Random();
- public SetWindowWaitControl(WaitControl waitActivity, List<string> nameList, DesignerControl designer)
- {
- InitializeComponent();
- this.designer = designer;
- this.designerNameList = nameList;
- this.activity = waitActivity;
- this.activityName.Text = activity.Name;
- this.activityX.Text = rd.Next(10, 200).ToString();
- this.activityY.Text = rd.Next(10, 200).ToString();
- this.activityTitle.Text = activity.标题;
- this.lbSubmtOption.ItemsSource = activity.分支集合;
- }
- public SetWindowWaitControl(WaitControl waitActivity)
- {
- InitializeComponent();
- this.activity = waitActivity;
- this.activityName.Text = activity.Name;
- this.activityX.Text = activity.X坐标.ToString();
- this.activityY.Text = activity.Y坐标.ToString();
- this.activityDescription.Text = activity.说明;
- this.activityTitle.Text = activity.标题;
- this.lbSubmtOption.ItemsSource = activity.分支集合;
- this.activityName.IsEnabled = false;
- buttonRemovesubmtItem.IsEnabled = false;
- }
- private void Button_Click_0(object sender, RoutedEventArgs e)
- {
- if (this.activityName.Text == "")
- {
- ErrorInfo.Text = "Name没有添写";
- return;
- }
- if (this.activityName.IsEnabled)
- {
- if (designerNameList.Count(p => p == this.activityName.Text)!=0)
- {
- ErrorInfo.Text = "指定的Name已存在";
- return;
- }
- }
- double x;
- if (!double.TryParse(this.activityX.Text, out x))
- {
- ErrorInfo.Text = "X坐标应为数字";
- return;
- }
- double y;
- if (!double.TryParse(this.activityY.Text, out y))
- {
- ErrorInfo.Text = "Y坐标应为数字";
- return;
- }
- if (activity.分支集合.Count == 0)
- {
- ErrorInfo.Text = "至少要的一个分支选项";
- return;
- }
- activity.Name = this.activityName.Text;
- activity.类型 = "节";
- activity.X坐标 = x;
- activity.Y坐标 = y;
- activity.说明 = this.activityDescription.Text;
- activity.标题 = this.activityTitle.Text;
- if (designer != null)
- {
- designer.AddActivity(activity);
- }
- activity.显示分支选项();
- Canvas cn = this.Parent as Canvas;
- cn.Children.Remove(this);
- }
- private void Button_Click_1(object sender, RoutedEventArgs e)
- {
- Canvas cn = this.Parent as Canvas;
- cn.Children.Remove(this);
- }
- private void buttonRemovesubmtItem_Click(object sender, RoutedEventArgs e)
- {
- if (this.lbSubmtOption.SelectedItem != null)
- {
- activity.分支集合.Remove(this.lbSubmtOption.SelectedItem.ToString());
- }
- this.lbSubmtOption.ItemsSource = null;
- this.lbSubmtOption.ItemsSource = activity.分支集合;
- }
- private void buttonAddsubmtItem_Click(object sender, RoutedEventArgs e)
- {
- if (this.txtSubmtItem.Text != null && activity.分支集合.Count(p => p == this.txtSubmtItem.Text)==0)
- {
- activity.分支集合.Add(this.txtSubmtItem.Text);
- }
- this.lbSubmtOption.ItemsSource = null;
- this.lbSubmtOption.ItemsSource = activity.分支集合;
- }
- }
- }