private void UpdatePaintBrushesBrowser(float width) { var removeCategory = default(string); foreach (var brushCategory in brushCategories.Values) { brushCategory.PaintBrushes.Clear(); } for (var i = P3dPaintBrush.CachedInstances.Count - 1; i >= 0; i--) { var paintBrush = P3dPaintBrush.CachedInstances[i]; if (paintBrush != null) { var category = paintBrush.Category ?? ""; var brushCategory = default(BrushCategory); if (brushCategories.TryGetValue(category, out brushCategory) == false) { brushCategory = new BrushCategory(); brushCategories.Add(category, brushCategory); } brushCategory.PaintBrushes.Add(paintBrush); } else { P3dPaintBrush.CachedInstances.RemoveAt(i); } } foreach (var pair in brushCategories) { var category = pair.Key; var brushCategory = pair.Value; if (brushCategory.PaintBrushes.Count > 0) { brushCategory.Expand = EditorGUILayout.Foldout(brushCategory.Expand, category); if (brushCategory.Expand == true) { brushCategory.PaintBrushes.Sort(BrushCategory.Compare); DrawBrushes(brushCategory.PaintBrushes, width); } } else { removeCategory = category; } } if (removeCategory != null) { brushCategories.Remove(removeCategory); } }
private void UpdateTranslation(bool scrollNow) { SceneView activeView = this.ActiveView; SceneViewModel viewModel = activeView.ViewModel; if (!this.HasMouseMovedAfterDown) { this.hasInitializedBrush = false; } SceneElement primarySelection = this.ActiveView.ElementSelectionSet.PrimarySelection; if (primarySelection == null) { return; } PropertyReference propertyReference = this.GetBrushPropertyReference((SceneNode)primarySelection); if (propertyReference == null || Adorner.NonAffineTransformInParentStack(primarySelection)) { return; } this.EnsureEditTransaction(); if (!this.hasInitializedBrush) { if (!PlatformTypes.IsInstance(this.ActiveView.ElementSelectionSet.PrimarySelection.GetComputedValue(propertyReference), PlatformTypes.GradientBrush, (ITypeResolver)primarySelection.ProjectContext)) { object lastUsed = BrushCategory.GetLastUsed(this.ActiveView.DesignerContext, this.ActiveView.Document.DocumentContext, BrushCategory.Gradient); this.ActiveView.ElementSelectionSet.PrimarySelection.SetValueAsWpf(propertyReference, lastUsed); this.UpdateEditTransaction(); } this.CopyPrimaryBrushToSelection(); this.hasInitializedBrush = true; } object computedValue = primarySelection.GetComputedValue(propertyReference); Matrix matrix = activeView.GetComputedTransformFromRoot(primarySelection) * BrushAdorner.GetCompleteInverseBrushTransformMatrix((Base2DElement)primarySelection, computedValue, true); Point point1 = this.dragStartPosition * matrix; Point point2 = this.dragCurrentPosition * matrix; Point point3 = RoundingHelper.RoundPosition(point1); Point point4 = RoundingHelper.RoundPosition(point2); if (PlatformTypes.IsInstance(computedValue, PlatformTypes.LinearGradientBrush, (ITypeResolver)primarySelection.ProjectContext)) { this.SetBrushValue(LinearGradientBrushNode.StartPointProperty, (object)point3); this.SetBrushValue(LinearGradientBrushNode.EndPointProperty, (object)point4); } else if (PlatformTypes.IsInstance(computedValue, PlatformTypes.RadialGradientBrush, (ITypeResolver)primarySelection.ProjectContext)) { this.SetBrushValue(RadialGradientBrushNode.CenterProperty, (object)point3); this.SetBrushValue(RadialGradientBrushNode.GradientOriginProperty, (object)point3); if (this.IsShiftDown) { Vector vector = point4 - point3; this.SetBrushValue(RadialGradientBrushNode.RadiusXProperty, (object)vector.Length); this.SetBrushValue(RadialGradientBrushNode.RadiusYProperty, (object)vector.Length); } else { Point point5 = RoundingHelper.RoundPosition(new Point(Math.Abs(point3.X - point4.X), Math.Abs(point3.Y - point4.Y))); this.SetBrushValue(RadialGradientBrushNode.RadiusXProperty, (object)point5.X); this.SetBrushValue(RadialGradientBrushNode.RadiusYProperty, (object)point5.Y); } } activeView.EnsureVisible(this.dragStartPosition + this.dragCurrentPosition - this.dragStartPosition, scrollNow); this.UpdateEditTransaction(); }