Example #1
0
        public static object ShowPropertyGridInWindows(object insObj, object inspector = null)
        {
            var mLastPropertyGrid = inspector as WPG.PropertyGrid;

            if (mLastPropertyGrid == null)
            {
                var win = new DockControl.DockAbleWindow();
                mLastPropertyGrid          = new WPG.PropertyGrid();
                mLastPropertyGrid.Instance = insObj;
                win.MainGrid.Children.Add(mLastPropertyGrid);
                win.Show();
                return(mLastPropertyGrid);
            }
            else
            {
                mLastPropertyGrid.Instance = insObj;
                return(mLastPropertyGrid);
            }
        }
        /// <summary>
        /// Setting the GUI property as active when the editor is switched to GUIEditor
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void GUIEditorCanvas_IsActiveDocumentChanged(object sender, EventArgs e)
        {
            WPG.PropertyGrid pe = new WPG.PropertyGrid();
            pe.Instance = guiProp;
            pe.DisplayName = "GUI Properties";
            pe.ShowPreview = false;

            if (dockableComponentProperties.ContainerPane.ActualWidth > 15) {
                pe.Width = dockableComponentProperties.ContainerPane.ActualWidth - 15;
            }
            if (dockableComponentProperties.ContainerPane.ActualHeight > 48) {
                pe.Height = dockableComponentProperties.ContainerPane.ActualHeight - 48;
            }
            propertyDockScrollViewer.Content = pe;
        }
        /// <summary>
        /// Set the property editors and the tabs in the property dock
        /// </summary>
        /// <param name="tempComponent">The component, which will be displayed</param>
        private void SetPropertyDock(componentType tempComponent)
        {
            if (tempComponent != null) {
                backupIdForPropertyEditor = tempComponent.id;
                WPG.PropertyGrid pe = new WPG.PropertyGrid();
                pe.Instance = tempComponent;
                pe.DisplayName = tempComponent.id;
                pe.ShowPreview = false;

                if (dockableComponentProperties.ContainerPane.ActualWidth > 15) {
                    pe.Width = dockableComponentProperties.ContainerPane.ActualWidth - 15;
                }
                if (dockableComponentProperties.ContainerPane.ActualHeight > 48) {
                    pe.Height = dockableComponentProperties.ContainerPane.ActualHeight - 48;
                }
                propertyDockScrollViewer.Content = pe;

                pe.GotKeyboardFocus += new KeyboardFocusChangedEventHandler(PropertyEditor_GotKeyboardFocus);
                KeyboardNavigation.SetTabNavigation(dockableInportsList, KeyboardNavigationMode.Continue);
                // Keyboard navigation within the list has to be done with the arrow-keys. A better solution might be here:
                // http://social.msdn.microsoft.com/Forums/en/wpf/thread/daca7b71-2893-4564-8379-097aabcdd553

                dockableInportsList.Items.Clear();
                dockableOutportsList.Items.Clear();

                foreach (object o in tempComponent.PortsList.Values) {
                    WPG.PropertyGrid pe2 = new WPG.PropertyGrid();
                    pe2.Instance = o;
                    pe2.ShowPreview = false;
                    pe2.IsTabStop = true;
                    //KeyboardNavigation.SetTabNavigation(pe2, KeyboardNavigationMode.Continue);
                    pe2.Margin = new Thickness(-35, 0, 0, 0);
                    if (dockableComponentProperties.ContainerPane.ActualWidth > 15) {
                        pe2.Width = dockableComponentProperties.ContainerPane.ActualWidth - 15;
                    }
                    //pe2.BorderBrush = new SolidColorBrush(Colors.Black);
                    //pe2.BorderThickness = new Thickness(1, 1, 1, 1);

                    if (o is inputPortType) {
                        dockableInportsList.Items.Add(new TreeViewItem() {
                            Header = ((inputPortType)o).portTypeID , IsTabStop = true, IsExpanded = true
                        });
                        pe2.DisplayName = ((inputPortType)o).portTypeID;
                        ((TreeViewItem)dockableInportsList.Items[dockableInportsList.Items.Count - 1]).Items.Add(pe2);
                        pe2.TabIndex = dockableInportsList.Items.Count + 58;
                    }
                    else {
                        dockableOutportsList.Items.Add(new TreeViewItem() {
                            Header = ((outputPortType)o).portTypeID, IsTabStop = true, IsExpanded = true
                        });
                        pe2.DisplayName = ((outputPortType)o).portTypeID;
                        ((TreeViewItem)dockableOutportsList.Items[dockableOutportsList.Items.Count - 1]).Items.Add(pe2);
                    }
                }
                dockableComponentProperties.Visibility = Visibility.Visible;
                // Tab 'Input Ports' just available, if the component has input ports
                if (dockableInportsList.Items.Count == 0) {
                    dockableInportsTab.Visibility = Visibility.Collapsed;
                }
                else {
                    dockableInportsTab.Visibility = Visibility.Visible;
                }
                // Tab 'Output Ports' just available, if the component has output ports
                if (dockableOutportsList.Items.Count == 0) {
                    dockableOutportsTab.Visibility = Visibility.Collapsed;
                }
                else {
                    dockableOutportsTab.Visibility = Visibility.Visible;
                }

                // Tab 'Event Listeners' just available, if the component has event listeners
                if (tempComponent.EventListenerList.Count == 0) {
                    dockableEventListenerTab.Visibility = Visibility.Collapsed;
                }
                else {
                    eventListenerDockScrollViewer.Content = SetListnerTriggerList(true, tempComponent);
                    dockableEventListenerTab.Visibility = Visibility.Visible;
                }
                // Tab 'Event Triggers' just available, if the component has event triggers
                if (tempComponent.EventTriggerList.Count == 0) {
                    dockableEventTriggerTab.Visibility = Visibility.Collapsed;
                }
                else {
                    eventTriggerDockScrollViewer.Content = SetListnerTriggerList(false, tempComponent);
                    dockableEventTriggerTab.Visibility = Visibility.Visible;
                }

                dockableEventsTab.Visibility = Visibility.Collapsed;
                dockManager.ActiveDocument = dockableComponentProperties;
            }
        }
 /// <summary>
 /// A property editor got the focus. The active property editor will be stored, needed for input validation
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 void PropertyEditor_GotKeyboardFocus(object sender, KeyboardFocusChangedEventArgs e)
 {
     activePropertyGrid = (WPG.PropertyGrid)sender;
 }