SetWindowWaitControl.xaml.cs
上传用户:lvyingde
上传日期:2018-04-24
资源大小:610k
文件大小:4k
源码类别:

SilverLight

开发平台:

C#

  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Net;
  5. using System.Windows;
  6. using System.Windows.Controls;
  7. using System.Windows.Documents;
  8. using System.Windows.Input;
  9. using System.Windows.Media;
  10. using System.Windows.Media.Animation;
  11. using System.Windows.Shapes;
  12. namespace wxwinter.WFDesignerSl
  13. {
  14.     public partial class SetWindowWaitControl : UserControl
  15.     {
  16.         WaitControl activity;
  17.         List<string> designerNameList;
  18.         DesignerControl designer;
  19.         System.Random rd = new Random();
  20.         public SetWindowWaitControl(WaitControl waitActivity, List<string> nameList, DesignerControl designer)
  21.         {
  22.             InitializeComponent();
  23.             this.designer = designer;
  24.             this.designerNameList = nameList;
  25.             this.activity = waitActivity;
  26.             this.activityName.Text = activity.Name;
  27.             this.activityX.Text = rd.Next(10, 200).ToString();
  28.             this.activityY.Text = rd.Next(10, 200).ToString();
  29.             this.activityTitle.Text = activity.标题;
  30.             this.lbSubmtOption.ItemsSource = activity.分支集合;
  31.         }
  32.         public SetWindowWaitControl(WaitControl waitActivity)
  33.         {
  34.             InitializeComponent();
  35.             this.activity = waitActivity;
  36.             this.activityName.Text = activity.Name;
  37.             this.activityX.Text = activity.X坐标.ToString();
  38.             this.activityY.Text = activity.Y坐标.ToString();
  39.             this.activityDescription.Text = activity.说明;
  40.             this.activityTitle.Text = activity.标题;
  41.             this.lbSubmtOption.ItemsSource = activity.分支集合;
  42.             this.activityName.IsEnabled = false;
  43.             buttonRemovesubmtItem.IsEnabled = false;
  44.          }
  45.         private void Button_Click_0(object sender, RoutedEventArgs e)
  46.         {
  47.             if (this.activityName.Text == "")
  48.             {
  49.                 ErrorInfo.Text = "Name没有添写";
  50.                 return;
  51.             }
  52.             if (this.activityName.IsEnabled)
  53.             {
  54.                 if (designerNameList.Count(p => p == this.activityName.Text)!=0)
  55.                 {
  56.                     ErrorInfo.Text = "指定的Name已存在";
  57.                     return;
  58.                 }
  59.             }
  60.             double x;
  61.             if (!double.TryParse(this.activityX.Text, out x))
  62.             {
  63.                 ErrorInfo.Text = "X坐标应为数字";
  64.                 return;
  65.             }
  66.             double y;
  67.             if (!double.TryParse(this.activityY.Text, out y))
  68.             {
  69.                 ErrorInfo.Text = "Y坐标应为数字";
  70.                 return;
  71.             }
  72.             if (activity.分支集合.Count == 0)
  73.             {
  74.                 ErrorInfo.Text = "至少要的一个分支选项";
  75.                 return;
  76.             }
  77.             activity.Name = this.activityName.Text;
  78.             activity.类型 = "节";
  79.             activity.X坐标 = x;
  80.             activity.Y坐标 = y;
  81.             activity.说明 = this.activityDescription.Text;
  82.             activity.标题 = this.activityTitle.Text;
  83.             if (designer != null)
  84.             {
  85.                 designer.AddActivity(activity);
  86.             }
  87.            activity.显示分支选项();
  88.            Canvas cn = this.Parent as Canvas;
  89.            cn.Children.Remove(this);
  90.         }
  91.         private void Button_Click_1(object sender, RoutedEventArgs e)
  92.         {
  93.             Canvas cn = this.Parent as Canvas;
  94.             cn.Children.Remove(this);
  95.         }
  96.         private void buttonRemovesubmtItem_Click(object sender, RoutedEventArgs e)
  97.         {
  98.             if (this.lbSubmtOption.SelectedItem != null)
  99.             {
  100.                 activity.分支集合.Remove(this.lbSubmtOption.SelectedItem.ToString());
  101.             }
  102.             this.lbSubmtOption.ItemsSource = null;
  103.             this.lbSubmtOption.ItemsSource = activity.分支集合;
  104.         }
  105.         private void buttonAddsubmtItem_Click(object sender, RoutedEventArgs e)
  106.         {
  107.             if (this.txtSubmtItem.Text != null && activity.分支集合.Count(p => p == this.txtSubmtItem.Text)==0)
  108.             {
  109.                 activity.分支集合.Add(this.txtSubmtItem.Text);
  110.             }
  111.             this.lbSubmtOption.ItemsSource = null;
  112.             this.lbSubmtOption.ItemsSource = activity.分支集合;
  113.         }
  114.     }
  115. }