Exemplo n.º 1
0
        private static void BoardPropertyChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
        {
            (d as DesignerCanvas).Children.Clear();
            //初始化可视元素

            foreach (DesignerControl obj in (e.NewValue as DesignerBoard).VisualChildren)
            {
                UserControl u = BoardControlFactory.CreateBoardControlByDesignerType(obj.GetType(), obj);

                (d as DesignerCanvas).AddDesignerItem(u, new Point((obj as DesignerControl).Position.Location.X, (obj as DesignerControl).Position.Location.Y));
            }

            //注册后台元素
            foreach (DesignerDataSource ds in (e.NewValue as DesignerBoard).BackChildren)
            {
                DataSourceManager.Register(ds.Name, ds.DataSourceType, ds);
                switch (ds.DataSourceType)
                {
                case DesignerDataSourceType.DataBase:
                    DataBaseDataSourceManager.UpdateDataBaseDataSource(ds as DesignerDataBaseDataSource);
                    break;

                case DesignerDataSourceType.StaticText:
                    StaticTextDataSourceManager.UpdateStaticTextDataSource(ds as DesignerStaticTextDataSource);
                    break;
                }
            }

            ((DesignerCanvas)d).SelectItem = e.NewValue as DesignerBoard;
        }
 private void OKButton_Click(object sender, RoutedEventArgs e)
 {
     //确认后,更新每个数据源
     //Database
     foreach (DesignerDataBaseDataSource ds in DataBaseDataSourceList)
     {
         DataBaseDataSourceManager.UpdateDataBaseDataSource(ds);
     }
     //StaticText
     foreach (DesignerStaticTextDataSource ds in StaticTextDataSourceList)
     {
         StaticTextDataSourceManager.UpdateStaticTextDataSource(ds);
     }
     this.DialogResult = true;
 }