private void PrepareLayoutConfiguration()
        {
            object layoutConfiguration = graphCanvas.CreateDefaultLayoutConfiguration();
            if (Messageflow.LayoutConfiguration != null) {
                Configurator.LoadConfiguration(layoutConfiguration, Messageflow.LayoutConfiguration);
            } else {
                Messageflow.LayoutConfiguration = new SerializableXDocument(Configurator.SaveConfiguration(layoutConfiguration));
            }
            graphCanvas.ApplyLayoutConfiguration(layoutConfiguration);

            uiLayoutConfigEditor = Configurator.CreateEditor(layoutConfiguration.GetType());
            uiLayoutConfigEditor.LoadConfiguration(Messageflow.LayoutConfiguration);
            uiLayoutConfigEditor.ConfigurationChanged += delegate {
                XDocument xNewConfiguration = uiLayoutConfigEditor.SaveConfiguration();
                bool isValid = true;
                try {
                    Configurator.LoadConfiguration(layoutConfiguration, xNewConfiguration);
                } catch {
                    isValid = false;
                }
                if (isValid) {
                    Messageflow.LayoutConfiguration = new SerializableXDocument(xNewConfiguration);
                    graphCanvas.ApplyLayoutConfiguration(layoutConfiguration);
                }
            };
            uiLayoutConfigurationContainer.Child = uiLayoutConfigEditor;
        }
        void IConfigurationControl.Initialize(ConfigurationManager configManager, ConfigurationTreeItem configTreeItem)
        {
            ConfigManager = configManager;
            ConfigTreeItem = configTreeItem;

            Config config = new Config {
                ConcurrentProcessingThreads = ConfigManager.Configuration.GetConcurrentThreadsCountForProcessor(ProcessorName)
            };
            editor = Configurator.CreateEditor(typeof(Config));
            XDocument xConfig = Configurator.SaveConfiguration(config);
            editor.LoadConfiguration(xConfig);
            uiContent.Content = editor;
		}
Пример #3
0
 /// <summary>
 /// Creates a WPF control for editing configuration items of given type.
 /// </summary>
 /// <param name="classMetadata">A description of a type which configuration items will be edited.</param>
 /// <returns>A new item editor.</returns>
 public static ConfigurationEditor CreateEditor(ClassMetadata classMetadata)
 {
     var result = new ConfigurationEditor(classMetadata);
     return result;
 }
        private void SetActiveAdapter(FrameworkElement uiAdapter)
        {
            if (uiAdapter == null) {
                activeAdapter = null;
                uiAdapterConfigurationRegion.Visibility = Visibility.Collapsed;
                return;
            }

            activeAdapter = (AdapterConfiguration)uiAdapter.Tag;
            uiAdapterConfigurationRegion.Visibility = Visibility.Visible;
            uiAdapterConfigurationHeader.Text = activeAdapter.AdapterName;

            AdapterType activeAdapterType = ConfigManager.Configuration.GetAdapterType(activeAdapter.AdapterTypeName);
            activeConfigurationEditor = Configurator.CreateEditor(activeAdapterType.ConfigurationMetadata);
            activeConfigurationEditor.LoadConfiguration(activeAdapter.Configuration.XDocument);
            activeConfigurationEditor.ConfigurationChanged += delegate {
                activeAdapter.Configuration = new SerializableXDocument(activeConfigurationEditor.SaveConfiguration());
                ConfigManager.Configuration.SaveAdapterConfiguration(activeAdapter);
            };
            uiAdapterConfigurationContainer.Child = activeConfigurationEditor;
        }
        private void SetActiveAction(FrameworkElement uiAction)
        {
            if (uiAction == null) {
                activeAction = null;
                uiActionConfigurationRegion.Visibility = Visibility.Collapsed;
                return;
            }

            activeAction = (ActionConfiguration)uiAction.Tag;
            uiActionConfigurationRegion.Visibility = Visibility.Visible;

            ActionType activeActionType = nodeSelectionManager.AppConfig.GetActionType(activeAction.ActionTypeName);
            activeConfigurationEditor = Configurator.CreateEditor(activeActionType.ConfigurationMetadata);
            activeConfigurationEditor.LoadConfiguration(activeAction.Configuration.XDocument);
            activeConfigurationEditor.ConfigurationChanged += delegate {
                activeAction.Configuration = new SerializableXDocument(activeConfigurationEditor.SaveConfiguration());
            };
            uiActionConfigurationContainer.Child = activeConfigurationEditor;
        }