private UIElement InputGraphBullet()
        {
            Predicate <string> validityCheck = path => File.Exists(path) && GraphEmbedding.CanParse(path);
            Action <string>    onPathChanged = path =>
            {
                InputGraphPath = path;
                SetGraph(GraphEmbedding.FromText(File.ReadLines(path)));
            };
            var textBox = InteractiveTextBox.Create(InputGraphPath, validityCheck, onPathChanged, Dispatcher);

            InputGraphTextBox = textBox;
            return(HorizontalContainerStrecherd.Create()
                   .AddLeft(TextBlockCreator.RegularTextBlock("Input Graph").WithBullet())
                   .AddRight(ButtonCreator.Create("...", () => DialogCreator.ChooseFile(path => textBox.Text = path)))
                   .AsDock(textBox));
        }
コード例 #2
0
        private void OpenGraphButton_OnClick(object __, RoutedEventArgs _)
        {
            try
            {
                void FileChosen(string path)
                {
                    var embedding = GraphEmbedding.FromText(File.ReadLines(path));

                    this.GraphVisual.SetNewEmbedding(embedding);
                }
                DialogCreator.ChooseFile(FileChosen);
            }
            catch (Exception e)
            {
                MessageBox.Show("An error occured. file is malformed:" + Environment.NewLine + e.Message);
            }
        }