コード例 #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);
 }
コード例 #3
0
        public void CompleteLayout(SceneViewModel viewModel, Point startPoint)
        {
            ILayoutDesigner layoutDesigner = (ILayoutDesigner)null;
            Point           point          = startPoint;

            for (int index = 0; index < this.records.Count; ++index)
            {
                if (index > 0)
                {
                    point.Y += CanvasLikeDataViewLayoutBuilder.defaultInnerMargin.Height;
                }
                CanvasLikeDataViewLayoutBuilder.LabelField labelField = this.records[index];
                BaseFrameworkElement element1 = (BaseFrameworkElement)viewModel.GetSceneNode(labelField.Label);
                BaseFrameworkElement element2 = (BaseFrameworkElement)viewModel.GetSceneNode(labelField.Field);
                if (layoutDesigner == null)
                {
                    layoutDesigner = viewModel.GetLayoutDesignerForChild((SceneElement)element2, true);
                }
                Rect rect1 = element1 != null?element1.GetComputedTightBounds() : Rect.Empty;

                Rect   computedTightBounds = element2.GetComputedTightBounds();
                Point  location            = point;
                double num = element1 != null?Math.Max(rect1.Height, computedTightBounds.Height) : computedTightBounds.Height;

                if (element1 != null)
                {
                    location.Y += (num - rect1.Height) / 2.0;
                    Rect rect2 = new Rect(location, rect1.Size);
                    CanvasLikeDataViewLayoutBuilder.SetElementRect(layoutDesigner, element1, rect2);
                    location.Y -= (num - rect1.Height) / 2.0;
                    location.X  = rect2.Right + CanvasLikeDataViewLayoutBuilder.defaultInnerMargin.Width;
                }
                location.Y += (num - computedTightBounds.Height) / 2.0;
                Rect rect3 = new Rect(location, computedTightBounds.Size);
                CanvasLikeDataViewLayoutBuilder.SetElementRect(layoutDesigner, element2, rect3);
                double right = rect3.Right;
                double y     = point.Y;
                point.Y += num;
            }
        }