Esempio n. 1
0
        // called when there is a graphCache[graphFamily] item to process
        // called only through currentOutputAction or the output actions menu
        public void ProcessGraph(string graphFamily)
        {
            var execution = Exec.lastExecution; // atomically copy it

            if (execution == null)
            {
                return;                    // something's wrong
            }
            lock (Exec.exporterMutex) { GraphLayoutHandler.SetGraphLayout(GraphLayout.MessageGraph("...", "... working ...", "...")); plot.DoInvalidate(); }
            Dictionary <string, object> layoutCache = execution.layoutCache; // Dictionary<string, GraphLayout>
            GraphLayout layout;

            if (layoutCache.ContainsKey(graphFamily))
            {
                layout = (GraphLayout)layoutCache[graphFamily];
            }
            else
            {
                var graph = execution.graphCache[graphFamily];
                if (graph.VertexCount == 0 || graph.EdgeCount == 0) // GraphSharp crashes in these cases
                {
                    layout = GraphLayout.MessageGraph("...", "...", "... empty .");
                }
                else
                {
                    try { layout = new GraphLayout("Graph Layout", graph); }
                    catch { layout = GraphLayout.MessageGraph("...", "...", "... failed !!!"); }
                }
            }
            execution.layoutCache[graphFamily] = layout;
            lock (Exec.exporterMutex) { GraphLayoutHandler.SetGraphLayout(layout); plot.DoInvalidate(); }
        }
Esempio n. 2
0
 public void OutputClear()   // external call, wait until we switch to this page
 {
     if (MainTabbedPage.theMainTabbedPage.CurrentPage == MainTabbedPage.theOutputPageNavigation)
     {
         SetText("");
         lock (Exec.exporterMutex) { GraphLayoutHandler.SetGraphLayout(GraphLayout.MessageGraph("Preparing ...", "...", "...")); plot.DoInvalidate(); }
     }
 }
Esempio n. 3
0
        public OutputPage()
        {
            Title           = "Output";
            IconImageSource = "icons8truefalse100.png";

            outputActions = new Dictionary <string, OutputAction>();
            foreach (OutputAction outputAction in outputActionsList())
            {
                outputActions[outputAction.name] = outputAction;
            }

            // in iOS>Resource the images of the TitleBar buttons must be size 40, otherwise they will scale but still take the horizontal space of the original

            textOutputButton  = TextOuputButton();
            graphOutputButton = GraphOutputButton();
            scoreOutputButton = ScoreOutputButton();

            ToolbarItems.Add(scoreOutputButton);
            scoreOutputButton.IsEnabled = false;
            ToolbarItems.Add(graphOutputButton);
            graphOutputButton.IsEnabled = true;
            ToolbarItems.Add(textOutputButton);
            textOutputButton.IsEnabled = true;
            ToolbarItems.Add(
                new ToolbarItem("CopyAll", "icons8export96", async() => {
                string text = "";
                if (currentOutputAction.kind == OutputKind.Text)
                {
                    text = editor.GetText();
                }
                if (currentOutputAction.kind == OutputKind.Graph)
                {
                    var layout = GraphLayoutHandler.GraphLayout();
                    if (layout == null)
                    {
                        return;
                    }
                    var graph = layout.GRAPH;
                    if (graph == null)
                    {
                        return;
                    }
                    text = Export.GraphViz(graph);
                }
                if (currentOutputAction.kind == OutputKind.Score)
                {
                    // ####  SVG
                }
                if (text != "")
                {
                    await Clipboard.SetTextAsync(text);
                }
            }));

            editor = Kaemika.XMGui.TextEditor();
            editor.SetEditable(false);

            plot = new GraphLayoutView();

            score = new ScoreView();

            var stepper     = MainTabbedPage.theModelEntryPage.TextSizeStepper(editor);
            var startButton = MainTabbedPage.theModelEntryPage.StartButton(switchToChart: false, switchToOutput: false); // just needed to get its HightRequest

            outputPicker = OutputPicker();

            int  bottomBarPadding = 4;
            Grid bottomBar        = new Grid {
                RowSpacing = 0, Padding = bottomBarPadding
            };

            bottomBar.RowDefinitions.Add(new RowDefinition {
                Height = new GridLength(1, GridUnitType.Star)
            });
            bottomBar.ColumnDefinitions.Add(new ColumnDefinition {
                Width = new GridLength(1, GridUnitType.Star)
            });
            bottomBar.ColumnDefinitions.Add(new ColumnDefinition {
                Width = new GridLength(1, GridUnitType.Star)
            });
            bottomBar.ColumnDefinitions.Add(new ColumnDefinition {
                Width = new GridLength(1, GridUnitType.Star)
            });
            bottomBar.BackgroundColor = MainTabbedPage.secondBarColor;

            bottomBar.Children.Add(stepper, 0, 0);
            bottomBar.Children.Add(outputPicker, 1, 0);
            Grid.SetColumnSpan(outputPicker, 2);

            grid = new Grid {
                ColumnSpacing = 0
            };
            grid.RowDefinitions.Add(new RowDefinition {
                Height = new GridLength(1, GridUnitType.Star)
            });
            grid.RowDefinitions.Add(new RowDefinition {
                Height = new GridLength(startButton.HeightRequest + 2 * bottomBarPadding)
            });
            grid.ColumnDefinitions.Add(new ColumnDefinition {
                Width = new GridLength(1, GridUnitType.Star)
            });

            backdrop = new Label {
                Text = "", BackgroundColor = Color.White
            };

            overlapping = new AbsoluteLayout();
            AbsoluteLayout.SetLayoutBounds(score, new Rectangle(0, 0, 1, 1));
            AbsoluteLayout.SetLayoutFlags(score, AbsoluteLayoutFlags.All);
            AbsoluteLayout.SetLayoutBounds(plot, new Rectangle(0, 0, 1, 1));
            AbsoluteLayout.SetLayoutFlags(plot, AbsoluteLayoutFlags.All);
            AbsoluteLayout.SetLayoutBounds(backdrop, new Rectangle(0, 0, 1, 1));
            AbsoluteLayout.SetLayoutFlags(backdrop, AbsoluteLayoutFlags.All);
            AbsoluteLayout.SetLayoutBounds(editor.AsView(), new Rectangle(0, 0, 1, 1));
            AbsoluteLayout.SetLayoutFlags(editor.AsView(), AbsoluteLayoutFlags.All);
            overlapping.Children.Add(score);
            overlapping.Children.Add(plot);
            overlapping.Children.Add(backdrop);
            overlapping.Children.Add(editor.AsView());

            grid.Children.Add(overlapping, 0, 0);
            grid.Children.Add(bottomBar, 0, 1);

            Content = grid;
        }