Ejemplo n.º 1
0
        /// <summary>
        /// Switch the options whenever a new node placer type is selected
        /// </summary>
        /// <remarks>If we didn't change the level, try to retrieve a previously set configuration, otherwise, start from scratch</remarks>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void NodePlacerComboBoxSelectionChanged(object sender, SelectionChangedEventArgs e)
        {
            var name = nodePlacerTypeComboBox.SelectedItem as string;

            if (name != null)
            {
                if (CurrentDescriptor.Name != (string)nodePlacerTypeComboBox.SelectedItem)
                {
                    //Check if we already have a configuration for this level...
                    NodePlacerDescriptor desc;
                    if (levelConfigurations.TryGetValue(name, out desc))
                    {
                        CurrentDescriptor = desc;
                    }
                    else
                    {
                        //Load from descriptor configurations... we use reflection
                        foreach (
                            PropertyInfo propertyInfo in
                            typeof(NodePlacerConfigurations).GetProperties(BindingFlags.Static | BindingFlags.Public))
                        {
                            var d = propertyInfo.GetValue(null, null) as NodePlacerDescriptor;
                            if (d != null && d.Name == name)
                            {
                                CurrentDescriptor         = d;
                                levelConfigurations[name] = d;
                                break;
                            }
                        }
                    }
                }
            }
        }
Ejemplo n.º 2
0
        private void SetDescriptor(NodePlacerDescriptor npd)
        {
            nodePlacers[Level] = npd;
            if (descriptorCollection.Count == 0)
            {
                descriptorCollection.Add(npd.Configuration);
            }
            else
            {
                descriptorCollection[0] = npd.Configuration;
            }

            rotationGrid.Enabled              = npd.Rotatable;
            nodePlacerTypeLabel.Text          = npd.Name;
            nodePlacerDescriptionTextBox.Text = npd.Description;

            if (npd.Configuration == null || npd.Name == NodePlacerConfigurations.None.Name)
            {
                editorControl.Visible     = false;
                nodeSettingsLabel.Visible = true;
            }
            else
            {
                selectionProvider.UpdatePropertyViewsNow();
                editorControl.Visible     = true;
                nodeSettingsLabel.Visible = false;
            }
            UpdatePreview();
        }
Ejemplo n.º 3
0
 private void SetDescriptor(NodePlacerDescriptor npd)
 {
     nodePlacers[Level] = npd;
     if (descriptorCollection.Count == 0)
     {
         descriptorCollection.Add(npd.Configuration);
     }
     else
     {
         descriptorCollection[0] = npd.Configuration;
     }
     rotationGrid.IsEnabled = npd.Rotatable;
     if (npd.Configuration != null)
     {
         selectionProvider.UpdatePropertyViewsNow();
         editorControl.Visibility = Visibility.Visible;
     }
     else
     {
         editorControl.Visibility = Visibility.Hidden;
     }
     UpdatePreview();
 }
Ejemplo n.º 4
0
 private void OnDescriptorChanged(NodePlacerDescriptor descriptor)
 {
     SetDescriptor(descriptor);
 }