Exemplo n.º 1
0
        public void Do()
        {
            if (!scene.Children.Contains(originalItem))
            {
                return;
            }

            scene.Children.Modify(list =>
            {
                // Remove the group
                list.Remove(originalItem);

                // Apply transform
                foreach (var child in originalItem.Children)
                {
                    child.Matrix *= originalItem.Matrix;
                }

                // Add all children from the group
                list.AddRange(originalItem.Children);
            });

            scene.SelectLastChild();
            scene.Invalidate(new InvalidateArgs(null, InvalidateType.Children));
        }
Exemplo n.º 2
0
        public void Do()
        {
            if (!firstPass)
            {
                item.Matrix = originalTransform;
                firstPass   = false;
            }

            scene.Children.Modify(list => list.Add(item));

            scene.SelectedItem = item;

            scene.Invalidate(new InvalidateArgs(null, InvalidateType.Content));
        }
Exemplo n.º 3
0
        public void Do()
        {
            scene.ClearSelection();

            scene.Children.Modify(list =>
            {
                foreach (var item in items)
                {
                    list.Remove(item);
                }
            });

            scene.SelectLastChild();

            scene.Invalidate(new InvalidateArgs(null, InvalidateType.Content));
        }
Exemplo n.º 4
0
        public void Do()
        {
            if (!firstPass)
            {
                firstPass = false;
            }

            scene.Children.Modify(list => list.AddRange(items));

            scene.SelectedItem = null;
            foreach (var item in items)
            {
                scene.AddToSelection(item);
            }

            scene.Invalidate(new InvalidateArgs(null, InvalidateType.Content));
        }
Exemplo n.º 5
0
        public static void DeleteSelection(this InteractiveScene scene)
        {
            var selectedItem = scene.SelectedItem;

            if (selectedItem != null)
            {
                // Create and perform the delete operation
                var deleteOperation = new DeleteCommand(scene, selectedItem);

                // Store the operation for undo/redo
                scene.UndoBuffer.AddAndDo(deleteOperation);

                scene.ClearSelection();

                scene.Invalidate(new InvalidateArgs(null, InvalidateType.Children));
            }
        }
Exemplo n.º 6
0
        public MaterialControls(InteractiveScene scene, ThemeConfig theme)
            : base(FlowDirection.TopToBottom)
        {
            this.theme   = theme;
            this.scene   = scene;
            this.HAnchor = HAnchor.Stretch;
            this.VAnchor = VAnchor.Fit;

            materialButtons.Clear();
            int extruderCount = 4;

            for (int extruderIndex = -1; extruderIndex < extruderCount; extruderIndex++)
            {
                var name = $"{"Material".Localize()} {extruderIndex +1}";
                if (extruderIndex == -1)
                {
                    name = "Default".Localize();
                }

                var buttonView = new FlowLayoutWidget()
                {
                    HAnchor = HAnchor.Fit,
                    VAnchor = VAnchor.Fit
                };

                var scaledButtonSize = 16 * GuiWidget.DeviceScale;

                buttonView.AddChild(new ColorButton(extruderIndex == -1 ? Color.Black : MaterialRendering.Color(extruderIndex))
                {
                    Margin  = new BorderDouble(right: 5),
                    Width   = scaledButtonSize,
                    Height  = scaledButtonSize,
                    VAnchor = VAnchor.Center,
                });

                buttonView.AddChild(new TextWidget(name, pointSize: theme.DefaultFontSize, textColor: theme.Colors.PrimaryTextColor)
                {
                    VAnchor = VAnchor.Center
                });

                var radioButtonView = new RadioButtonView(buttonView)
                {
                    TextColor = theme.Colors.PrimaryTextColor
                };
                radioButtonView.RadioCircle.Margin = radioButtonView.RadioCircle.Margin.Clone(right: 5);

                var radioButton = new RadioButton(radioButtonView)
                {
                    HAnchor   = HAnchor.Stretch,
                    VAnchor   = VAnchor.Fit,
                    TextColor = theme.Colors.PrimaryTextColor
                };
                materialButtons.Add(radioButton);
                this.AddChild(radioButton);

                int extruderIndexCanPassToClick = extruderIndex;
                radioButton.Click += (sender, e) =>
                {
                    var selectedItem = scene.SelectedItem;
                    if (selectedItem != null)
                    {
                        selectedItem.MaterialIndex = extruderIndexCanPassToClick;
                        scene.Invalidate(new InvalidateArgs(null, InvalidateType.Material));
                    }
                };
            }

            scene.SelectionChanged += Scene_SelectionChanged;
        }