예제 #1
0
        static void SetLayoutNotifications(VisualizerDialogSettings settings, VisualizerLayout root, bool publishNotifications = false)
        {
            var inspectBuilder = settings.Tag as InspectBuilder;

            while (inspectBuilder != null && !inspectBuilder.PublishNotifications)
            {
                inspectBuilder.PublishNotifications = publishNotifications || !string.IsNullOrEmpty(settings.VisualizerTypeName);
                foreach (var mashup in settings.Mashups)
                {
                    if (mashup < 0 || mashup >= root.DialogSettings.Count)
                    {
                        continue;
                    }
                    var dialogSettings = root.DialogSettings[mashup];
                    SetLayoutNotifications(dialogSettings, root, publishNotifications: true);
                }

                var visualizerElement = ExpressionBuilder.GetVisualizerElement(inspectBuilder);
                if (inspectBuilder.PublishNotifications && visualizerElement != inspectBuilder)
                {
                    inspectBuilder = visualizerElement;
                }
                else
                {
                    inspectBuilder = null;
                }
            }

            if (settings is WorkflowEditorSettings editorSettings && editorSettings.EditorVisualizerLayout != null)
            {
                SetLayoutNotifications(editorSettings.EditorVisualizerLayout);
            }
        }
예제 #2
0
 public static void SetLayoutNotifications(VisualizerLayout root)
 {
     foreach (var settings in root.DialogSettings)
     {
         SetLayoutNotifications(settings, root, publishNotifications: false);
     }
 }
예제 #3
0
        public static Dictionary <InspectBuilder, VisualizerDialogLauncher> CreateVisualizerMapping(
            ExpressionBuilderGraph workflow,
            VisualizerLayout visualizerLayout,
            TypeVisualizerMap typeVisualizerMap,
            IServiceProvider provider = null,
            IWin32Window owner        = null,
            Editor.GraphView.WorkflowGraphView graphView = null)
        {
            if (workflow == null)
            {
                return(null);
            }
            var visualizerMapping = (from node in workflow.TopologicalSort()
                                     let key = (InspectBuilder)node.Value
                                               let visualizerLauncher = CreateVisualizerLauncher(key, visualizerLayout, typeVisualizerMap, workflow, graphView)
                                                                        where visualizerLauncher != null
                                                                        select new { key, visualizerLauncher })
                                    .ToDictionary(mapping => mapping.key,
                                                  mapping => mapping.visualizerLauncher);

            foreach (var mapping in visualizerMapping)
            {
                var key = mapping.Key;
                var visualizerLauncher = mapping.Value;
                var layoutSettings     = visualizerLayout.GetLayoutSettings(key);
                if (layoutSettings != null)
                {
                    var visualizer       = visualizerLauncher.Visualizer;
                    var mashupVisualizer = visualizer.IsValueCreated ? visualizer.Value as DialogMashupVisualizer : null;
                    if (mashupVisualizer != null)
                    {
                        foreach (var mashup in layoutSettings.Mashups)
                        {
                            if (mashup < 0 || mashup >= visualizerLayout.DialogSettings.Count)
                            {
                                continue;
                            }
                            var dialogSettings = visualizerLayout.DialogSettings[mashup];
                            var node           = workflow.FirstOrDefault(node => node.Value == dialogSettings.Tag);
                            if (node?.Value is InspectBuilder inspectBuilder &&
                                visualizerMapping.TryGetValue(inspectBuilder, out VisualizerDialogLauncher visualizerDialog))
                            {
                                visualizerLauncher.CreateMashup(visualizerDialog, typeVisualizerMap);
                            }
                        }
                    }

                    visualizerLauncher.Bounds      = layoutSettings.Bounds;
                    visualizerLauncher.WindowState = layoutSettings.WindowState;
                    if (layoutSettings.Visible)
                    {
                        visualizerLauncher.Show(owner, provider);
                    }
                }
            }

            return(visualizerMapping);
        }
예제 #4
0
        public static VisualizerDialogLauncher CreateVisualizerLauncher(
            InspectBuilder source,
            VisualizerLayout visualizerLayout,
            TypeVisualizerMap typeVisualizerMap,
            ExpressionBuilderGraph workflow,
            Editor.GraphView.WorkflowGraphView workflowGraphView = null)
        {
            var inspectBuilder = ExpressionBuilder.GetVisualizerElement(source);

            if (inspectBuilder.ObservableType == null || !inspectBuilder.PublishNotifications)
            {
                return(null);
            }

            Type visualizerType        = null;
            var  deserializeVisualizer = false;
            Func <DialogTypeVisualizer> visualizerFactory = null;
            var layoutSettings  = visualizerLayout.GetLayoutSettings(source);
            var visualizerTypes = typeVisualizerMap.GetTypeVisualizers(inspectBuilder);

            if (layoutSettings != null && !string.IsNullOrEmpty(layoutSettings.VisualizerTypeName))
            {
                visualizerType = visualizerTypes.FirstOrDefault(type => type.FullName == layoutSettings.VisualizerTypeName);
                if (visualizerType != null && layoutSettings.VisualizerSettings != null)
                {
                    var root = layoutSettings.VisualizerSettings;
                    root.SetAttributeValue(XsdAttributeName, XsdAttributeValue);
                    root.SetAttributeValue(XsiAttributeName, XsiAttributeValue);
                    var serializer = new XmlSerializer(visualizerType);
                    using (var reader = layoutSettings.VisualizerSettings.CreateReader())
                    {
                        if (serializer.CanDeserialize(reader))
                        {
                            var visualizer = (DialogTypeVisualizer)serializer.Deserialize(reader);
                            visualizerFactory     = () => visualizer;
                            deserializeVisualizer = true;
                        }
                    }
                }
            }

            visualizerType ??= visualizerTypes.FirstOrDefault();
            if (visualizerType == null)
            {
                return(null);
            }

            if (visualizerFactory == null)
            {
                var visualizerActivation = Expression.New(visualizerType);
                visualizerFactory = Expression.Lambda <Func <DialogTypeVisualizer> >(visualizerActivation).Compile();
            }

            var launcher = new VisualizerDialogLauncher(visualizerType, inspectBuilder, visualizerFactory, workflow, source, workflowGraphView);

            launcher.Text = source != null?ExpressionBuilder.GetElementDisplayName(source) : null;

            if (deserializeVisualizer)
            {
                launcher = launcher.Visualizer.Value != null ? launcher : null;
            }
            return(launcher);
        }
예제 #5
0
 public static VisualizerDialogSettings GetLayoutSettings(this VisualizerLayout visualizerLayout, object key)
 {
     return(visualizerLayout != null
         ? visualizerLayout.DialogSettings.FirstOrDefault(xs => xs.Tag == key || xs.Tag == null)
         : null);
 }