示例#1
0
 public override void SetRootSize(BaseFrameworkElement root, Size size, bool setWidth, bool setHeight)
 {
     root.ViewModel.DefaultView.UpdateLayout();
     if (!root.ViewModel.IsInGridDesignMode && root is GridElement)
     {
         size = RoundingHelper.RoundSize(size);
         using (GridLayoutDesigner.TryCanvasDesignMode(root, size, setWidth, setHeight))
         {
             BaseFrameworkElement sizeElement = this.GetSizeElement(root);
             if (setHeight)
             {
                 sizeElement.Height = size.Height;
             }
             if (!setWidth)
             {
                 return;
             }
             sizeElement.Width = size.Width;
         }
     }
     else
     {
         base.SetRootSize(root, size, setWidth, setHeight);
     }
 }
示例#2
0
 public CanvasDesignModeToken(GridElement grid, Size size, bool setWidth, bool setHeight)
 {
     this.grid = grid;
     this.size = size;
     this.gridLayoutDesigner          = new GridLayoutDesigner();
     this.enforceGridDesignModeToken  = this.grid.ViewModel.EnforceGridDesignMode;
     this.deferTokenForGridDesignMode = this.gridLayoutDesigner.DeferTokenForGridDesignMode(this.grid);
     this.grid.ViewModel.DefaultView.UpdateLayout();
     using (LayoutRoundingHelper.TurnOffLayoutRounding((BaseFrameworkElement)this.grid))
         this.rects = this.gridLayoutDesigner.GetCurrentRects((BaseFrameworkElement)this.grid);
     this.gridLayoutDesigner.AdjustLastColumnRow(this.grid, this.size, setWidth, setHeight);
 }
示例#3
0
 public void RemoveRow(GridElement grid, int index)
 {
     using (SceneEditTransaction editTransaction = grid.ViewModel.CreateEditTransaction(StringTable.UndoUnitRemoveGridline))
     {
         grid.ViewModel.GridRowSelectionSet.Clear();
         grid.ViewModel.AnimationEditor.DeleteAllAnimations((SceneNode)grid.RowDefinitions[index]);
         using (grid.ViewModel.ForceBaseValue())
         {
             List <LayoutCacheRecord> currentRects = this.GetCurrentRects((BaseFrameworkElement)grid);
             bool       isStar1           = grid.RowDefinitions[index - 1].Height.IsStar;
             bool       isStar2           = grid.RowDefinitions[index].Height.IsStar;
             List <int> heightStarIndices = this.GetHeightStarIndices(grid);
             grid.CacheComputedRowHeights();
             List <double> computedRowHeightCache;
             int           index1;
             (computedRowHeightCache = grid.ComputedRowHeightCache)[index1 = index - 1] = computedRowHeightCache[index1] + grid.ComputedRowHeightCache[index];
             grid.ComputedRowHeightCache.RemoveAt(index);
             grid.RowDefinitions.RemoveAt(index);
             if (isStar2)
             {
                 heightStarIndices.Remove(index);
             }
             if (isStar1 || isStar2)
             {
                 for (int index2 = 0; index2 < heightStarIndices.Count; ++index2)
                 {
                     if (heightStarIndices[index2] > index)
                     {
                         List <int> list;
                         int        index3;
                         (list = heightStarIndices)[index3 = index2] = list[index3] - 1;
                     }
                 }
                 this.NormalizeHeightStars(grid, heightStarIndices);
             }
             if (!isStar1)
             {
                 grid.RowDefinitions[index - 1].Height = new GridLength(grid.ComputedRowHeightCache[index - 1]);
                 grid.RowDefinitions[index - 1].ClearValue(RowDefinitionNode.MinHeightProperty);
             }
             editTransaction.Update();
             grid.ViewModel.RefreshSelection();
             this.SetCurrentRects((BaseFrameworkElement)grid, currentRects);
             grid.UncacheComputedRowHeights();
             GridLayoutDesigner.ReselectGridToRestoreAdorners(grid);
             editTransaction.Commit();
         }
     }
 }
示例#4
0
 public virtual void SetChildRect(BaseFrameworkElement child, Rect rect, LayoutOverrides layoutOverrides, LayoutOverrides overridesToIgnore, LayoutOverrides nonExplicitOverrides, SetRectMode setRectMode)
 {
     overridesToIgnore = this.AdjustOverrideToIgnore(child, overridesToIgnore);
     if (this.suppressLayoutRoundingCount == 0 && (LayoutRoundingHelper.GetLayoutRoundingStatus((SceneElement)child) & LayoutRoundingStatus.ShouldSnapToPixel) != LayoutRoundingStatus.Off)
     {
         rect = LayoutRoundingHelper.RoundRect(child.Platform.GeometryHelper, rect);
     }
     using (child.ViewModel.ScopeViewObjectCache())
     {
         using (GridLayoutDesigner.TryCanvasDesignMode(child, rect.Size, true, true))
         {
             LayoutUtilities.EnterLayoutMode();
             LayoutOperation layoutOperation = this.CreateLayoutOperation(child);
             if (layoutOverrides == LayoutOverrides.RecomputeDefault)
             {
                 layoutOverrides = this.InternalComputeOverrides(child, layoutOperation);
             }
             layoutOperation.SetRect(rect, layoutOverrides, overridesToIgnore, nonExplicitOverrides, setRectMode);
             LayoutUtilities.ExitLayoutMode();
         }
     }
 }