// Use this for initialization
    void OnEnable()
    {
        if (!initialized)
        {
            profiler = new Profiler(240);
            for (int i = 0; i < labels.Length; i++)
            {
                Profiler.RecorderLayout layout = new Profiler.RecorderLayout();
                layout.color   = new Color(Random.Range(0.50f, 0.75f), Random.Range(0.5f, 0.75f), Random.Range(0.5f, 0.75f));
                layout.visible = true;
                profiler.CreateRecorder(labels[i].label, layout);
            }
            initialized = true;
        }
        else
        {
            profiler.ReloadRecorders();
        }
        List <int> indents = new List <int>(labels.Length);

        for (int i = 0; i < labels.Length; i++)
        {
            indents.Add(labels[i].indent);
        }
        VisualizerLayout graphLayout = HUD.Create(profiler, null, indents);

        graphLayout.align       = VisualizerLayout.AnchorPosition.BOTTOM_LEFT;
        graphLayout.layout.size = new Vector2(720, 768);
    }
 public static VisualizerLayout Create(Profiler profiler, VisualizerLayout layout = null)
 {
     if (layout == null)
     {
         layout = new VisualizerLayout();
     }
     profiler.AttachVisualizer(new CumulativeHistogram(layout));
     return(layout);
 }
예제 #3
0
    public static VisualizerLayout Create(Profiler prof, VisualizerLayout layout = null, List <int> labelIndents = null)
    {
        if (layout == null)
        {
            layout = new VisualizerLayout();
            layout.layout.width = 350;
        }
        FPSDisplay fps = new FPSDisplay(layout);

        prof.AttachVisualizer(fps);
        return(layout);
    }
예제 #4
0
    public static VisualizerLayout Create(Profiler prof, VisualizerLayout layout = null, List <int> labelIndents = null)
    {
        if (layout == null)
        {
            layout = new VisualizerLayout();
            layout.layout.width = 350;
        }
        HUD hud = new HUD(layout);

        hud.labelIndents = labelIndents;
        prof.AttachVisualizer(hud);
        return(layout);
    }
예제 #5
0
        public static void Run(
            string fileName,
            Dictionary <string, string> propertyAssignments,
            IObservable <TypeVisualizerDescriptor> visualizerProvider = null,
            string layoutPath = null)
        {
            if (string.IsNullOrEmpty(fileName))
            {
                throw new ArgumentNullException(nameof(fileName));
            }

            if (!File.Exists(fileName))
            {
                throw new ArgumentException("Specified workflow file does not exist.", nameof(fileName));
            }

            WorkflowBuilder workflowBuilder;

            using (var reader = XmlReader.Create(fileName))
            {
                reader.MoveToContent();
                var serializer = new XmlSerializer(typeof(WorkflowBuilder), reader.NamespaceURI);
                workflowBuilder = (WorkflowBuilder)serializer.Deserialize(reader);
            }

            workflowBuilder.Workflow.Build();
            foreach (var assignment in propertyAssignments)
            {
                workflowBuilder.Workflow.SetWorkflowProperty(assignment.Key, assignment.Value);
            }

            layoutPath ??= LayoutHelper.GetLayoutPath(fileName);
            if (visualizerProvider != null && File.Exists(layoutPath))
            {
                VisualizerLayout layout = null;
                using (var reader = XmlReader.Create(layoutPath))
                {
                    layout = (VisualizerLayout)VisualizerLayout.Serializer.Deserialize(reader);
                }

                RunLayout(fileName, visualizerProvider, workflowBuilder, layout);
            }
            else
            {
                RunHeadless(workflowBuilder);
            }
        }
예제 #6
0
        IEnumerable <VisualizerDialogSettings> GetVisualizerSettings(VisualizerLayout root)
        {
            var stack = new Stack <VisualizerLayout>();

            stack.Push(root);
            while (stack.Count > 0)
            {
                var layout = stack.Pop();
                foreach (var settings in layout.DialogSettings)
                {
                    yield return(settings);

                    var editorSettings = settings as WorkflowEditorSettings;
                    if (editorSettings != null && editorSettings.EditorVisualizerLayout != null)
                    {
                        stack.Push(editorSettings.EditorVisualizerLayout);
                    }
                }
            }
        }
예제 #7
0
        static void RunLayout(
            string fileName,
            IObservable <TypeVisualizerDescriptor> visualizerProvider,
            WorkflowBuilder workflowBuilder,
            VisualizerLayout layout)
        {
            var typeVisualizers = new TypeVisualizerMap();
            var loadVisualizers = (from typeVisualizer in visualizerProvider
                                   let targetType = Type.GetType(typeVisualizer.TargetTypeName)
                                                    let visualizerType = Type.GetType(typeVisualizer.VisualizerTypeName)
                                                                         where targetType != null && visualizerType != null
                                                                         select Tuple.Create(targetType, visualizerType))
                                  .Do(entry => typeVisualizers.Add(entry.Item1, entry.Item2))
                                  .ToEnumerable().ToList();

            workflowBuilder = new WorkflowBuilder(workflowBuilder.Workflow.ToInspectableGraph());
            LayoutHelper.SetWorkflowNotifications(workflowBuilder.Workflow, publishNotifications: false);
            foreach (var node in workflowBuilder.Workflow)
            {
                var layoutSettings = layout.GetLayoutSettings(node.Value);
                if (layoutSettings == null)
                {
                    layoutSettings = new VisualizerDialogSettings();
                    layout.DialogSettings.Add(layoutSettings);
                }
                layoutSettings.Tag = node.Value;
            }

            LayoutHelper.SetLayoutNotifications(layout);
            var services        = new System.ComponentModel.Design.ServiceContainer();
            var runtimeWorkflow = workflowBuilder.Workflow.BuildObservable();
            var mapping         = LayoutHelper.CreateVisualizerMapping(workflowBuilder.Workflow, layout, typeVisualizers, services);

            var cts         = new CancellationTokenSource();
            var contextMenu = new ContextMenuStrip();

            foreach (var launcher in mapping.Values.Where(launcher => launcher.Visualizer.IsValueCreated))
            {
                var activeLauncher = launcher;
                contextMenu.Items.Add(new ToolStripMenuItem(launcher.Text, null, (sender, e) =>
                {
                    activeLauncher.Show(services);
                }));
            }
            contextMenu.Items.Add(new ToolStripSeparator());
            contextMenu.Items.Add(new ToolStripMenuItem("Stop", null, (sender, e) => cts.Cancel()));

            var notifyIcon = new NotifyIcon();

            notifyIcon.Icon             = Properties.Resources.Icon;
            notifyIcon.Text             = Path.GetFileName(fileName);
            notifyIcon.ContextMenuStrip = contextMenu;
            notifyIcon.Visible          = true;
            runtimeWorkflow.Finally(() =>
            {
                notifyIcon.Visible = false;
                Application.Exit();
            }).Subscribe(
                unit => { },
                ex => { Console.WriteLine(ex); },
                () => { },
                cts.Token);
            Application.Run();
        }
예제 #8
0
 public void SetVisualizerLayout(VisualizerLayout layout)
 {
     this.layout = layout;
 }
예제 #9
0
 private HUD(VisualizerLayout layout)
 {
     this.layout = layout;
 }
 private CumulativeHistogram(VisualizerLayout layout) : this()
 {
     this.layout = layout;
 }
예제 #11
0
 private FPSDisplay(VisualizerLayout layout)
 {
     this.layout = layout;
     drawTimer   = 5000;
 }
예제 #12
0
 void Awake()
 {
     layout         = GetComponent <VisualizerLayout>();
     layout.manager = this;
 }