예제 #1
0
 private bool CreateControls(Point dropPoint)
 {
     using (SceneEditTransaction editTransaction = this.DragModel.Document.CreateEditTransaction(StringTable.UndoUnitDragDropCreateDataboundControl))
     {
         DataContextInfo dataContextInfo = new DataContextEvaluator().Evaluate(this.DragModel.TargetNode);
         DataSourceInfo  other           = new DataSourceInfo(new DataSchemaNodePath(this.DragModel.DataSource.PrimaryAbsoluteSchema, this.GetRelativeSchema().Root));
         bool            flag            = false;
         if (dataContextInfo.DataSource == null || !dataContextInfo.DataSource.IsValidWithSource || dataContextInfo.DataSource.CompareSources(other) != DataSourceMatchCriteria.Exact)
         {
             flag = true;
         }
         IList <DataSchemaNodePath>      relativeSchemaPaths = this.GetRelativeSchemaPaths();
         CanvasLikeDataViewLayoutBuilder viewLayoutBuilder   = new CanvasLikeDataViewLayoutBuilder(this.DragModel.InsertionPoint.InsertIndex, false);
         DocumentCompositeNode           containerNode       = (DocumentCompositeNode)this.DragModel.TargetNode.DocumentNode;
         DataViewFactory.GenerateDataView(this.DragModel.Platform, this.DragModel.DocumentContext, relativeSchemaPaths, DataViewCategory.Master, containerNode, (IDataViewLayoutBuilder)viewLayoutBuilder);
         if (flag)
         {
             viewLayoutBuilder.RebindFields(this.DragModel.ViewModel, this.DragModel.DataSource.PrimaryAbsoluteSchema, relativeSchemaPaths);
         }
         editTransaction.Update();
         viewLayoutBuilder.ApplyActiveUserThemeStyle(this.DragModel.ViewModel);
         viewLayoutBuilder.CompleteLayout(this.DragModel.ViewModel, dropPoint);
         viewLayoutBuilder.SelectElements(this.DragModel.ViewModel);
         editTransaction.Commit();
     }
     return(true);
 }
예제 #2
0
 private bool CreateDetailsVisualization(Point dropPoint)
 {
     using (SceneEditTransaction editTransaction = this.DragModel.Document.CreateEditTransaction(StringTable.UndoUnitDragDropCreateDataboundControl))
     {
         bool flag = true;
         DocumentCompositeNode containerNode = (DocumentCompositeNode)null;
         BaseFrameworkElement  child         = this.GetReusableDetailsContainer(true, this.DragModel.CheckDropFlags(DataBindingDragDropFlags.SetBinding));
         if (child != null)
         {
             containerNode = (DocumentCompositeNode)child.DocumentNode;
             flag          = false;
         }
         IList <DataSchemaNodePath> relativeSchemaPaths = this.GetRelativeSchemaPaths();
         bool shouldCreateLabels = true;
         if (relativeSchemaPaths.Count == 1 && this.DragModel.DataSource.Count == 1 && relativeSchemaPaths[0].Node == this.DragModel.DataSource.PrimarySchemaNodePath.Node)
         {
             shouldCreateLabels = false;
         }
         CanvasLikeDataViewLayoutBuilder viewLayoutBuilder     = new CanvasLikeDataViewLayoutBuilder(this.DragModel.InsertionPoint.InsertIndex, shouldCreateLabels);
         DocumentCompositeNode           documentCompositeNode = DataViewFactory.GenerateDataView(this.DragModel.Platform, this.DragModel.DocumentContext, relativeSchemaPaths, DataViewCategory.Details, containerNode, (IDataViewLayoutBuilder)viewLayoutBuilder);
         if (flag)
         {
             this.DragModel.ViewModel.ElementSelectionSet.Clear();
             child = (BaseFrameworkElement)this.DragModel.ViewModel.GetSceneNode((DocumentNode)documentCompositeNode);
             this.DragModel.InsertionPoint.Insert((SceneNode)child);
             this.DragModel.ViewModel.BindingEditor.CreateAndSetBindingOrData((SceneNode)child, DesignTimeProperties.DesignDataContextProperty, this.DragModel.DetailsContainerSchemaPath);
         }
         editTransaction.Update();
         viewLayoutBuilder.ApplyActiveUserThemeStyle(this.DragModel.ViewModel);
         if (flag)
         {
             Size size = viewLayoutBuilder.CalcCombinedSize(this.DragModel.ViewModel);
             Rect rect = new Rect(dropPoint, new Size()
             {
                 Width  = Math.Max(size.Width, 200.0),
                 Height = Math.Max(size.Height, 200.0)
             });
             this.DragModel.ViewModel.GetLayoutDesignerForChild((SceneElement)child, true).SetChildRect(child, rect);
             editTransaction.Update();
             this.DragModel.ViewModel.ElementSelectionSet.SetSelection((SceneElement)child);
             dropPoint = new Point();
         }
         viewLayoutBuilder.CompleteLayout(this.DragModel.ViewModel, dropPoint);
         if (!flag)
         {
             viewLayoutBuilder.SelectElements(this.DragModel.ViewModel);
         }
         this.LinkDetailsWithMasterControl((SceneElement)child);
         editTransaction.Commit();
     }
     return(true);
 }