Exemple #1
0
        public SelectLogic(Canvas simCanvas, ParticleSim particleSim)
        {
            this.simCanvas   = simCanvas;
            this.particleSim = particleSim;

            OptionBar = new SelectOptions();
            ToolType  = ToolType.Select;

            // Set up marquee select
            simCanvas.Children.Add(selectPreview);
            Panel.SetZIndex(selectPreview, 901);

            // Setup selection window
            selectionWindow            = new SelectionWindow();
            selectionWindow.Activated += SelectionWindowActivated;
            Application.Current.MainWindow.Closing += (s, e) =>
            {
                selectionWindow.Show();
                selectionWindow.Close();
            };
            (OptionBar as SelectOptions).ViewSelectionButton.Click += (s, e) =>
            {
                if (selectionWindow.IsVisible)
                {
                    selectionWindow.Hide();
                }
                else
                {
                    selectionWindow.Show();
                }
            };

            particleSim.BodySpawned += (s, e) => UpdateSelectionViewer();

            selectionWindow.SelectedItemView.SelectionChanged += (s, e) =>
            {
                while (selectionWindow.PropertiesPanel.Children.Count != 0)
                {
                    selectionWindow.PropertiesPanel.Children.RemoveAt(0);
                }

                int selectedIndex = (s as ListView).SelectedIndex;

                if (selectedIndex == -1)
                {
                    return;
                }

                Bodies.Rigidbody body = selectedBodies[selectedIndex];
                AddDataEntry(new Dictionary <string, object>()
                {
                    { "Radius", body.radius },
                    { "Charge", body.Charge }
                });
            };
        }
Exemple #2
0
        private UIElement CreateDataEntry(Bodies.Rigidbody body)
        {
            StackPanel entry = new StackPanel()
            {
                Orientation = Orientation.Horizontal
            };

            entry.Children.Add(new Ellipse()
            {
                Height = 10,
                Width  = 10,
                Fill   = new SolidColorBrush(body.color)
            });
            entry.Children.Add(new Label()
            {
                Content = "Particle " + body.UID
            });

            return(entry);
        }