Exemplo n.º 1
0
        private void UpdateVerticesLayout()
        {
            if (this.canvas == null ||
                this.Graph == null ||
                DesignerProperties.GetIsInDesignMode(this))
            {
                return;
            }

            var        builder = new WPFLayoutBuilder(this.canvas, this.elementsFactory);
            IDotRunner runner;

            if (string.IsNullOrWhiteSpace(this.DotExecutablePath) == false)
            {
                runner = new DotExeRunner {
                    DotExecutablePath = this.DotExecutablePath
                };
            }
            else
            {
                runner = new DotExeRunner();
            }

            if (this.LogGraphvizOutput)
            {
                runner = new DotRunnerLogDecorator(runner);
            }

            director = LayoutDirector.GetLayoutDirector(builder, dotRunner: runner);

            this.canvas.Children.Clear();
            this.progress = new ProgressBar {
                MinWidth = 100, MinHeight = 12, IsIndeterminate = true, Margin = new Thickness(50)
            };
            this.canvas.Children.Add(this.progress);
            try
            {
                director.StartBuilder(this.Graph);
                Task.Factory.StartNew(new LayoutAction(this, director).Run);
            }
            catch (Exception ex)
            {
                var textBlock = new TextBlock {
                    Width = 300, TextWrapping = TextWrapping.Wrap
                };
                textBlock.Text =
                    string.Format(
                        "Graphviz4Net: an exception was thrown during layouting." +
                        "Exception message: {0}.",
                        ex.Message);
                this.canvas.Children.Add(textBlock);
            }
        }
Exemplo n.º 2
0
        private void UpdateVerticesLayout()
        {
            if (this.canvas == null ||
				this.Graph == null ||
                DesignerProperties.GetIsInDesignMode(this))
            {
                return;
            }

            var builder = new WPFLayoutBuilder(this.canvas, this.elementsFactory);
            IDotRunner runner;
#if SILVERLIGHT
            runner = null;
#else
            if (string.IsNullOrWhiteSpace(this.DotExecutablePath) == false)
            {
                runner = new DotExeRunner { DotExecutablePath = this.DotExecutablePath };
            }
            else
            {
                runner = new DotExeRunner();
            }
#endif

            if (this.LogGraphvizOutput)
            {
                runner = new DotRunnerLogDecorator(runner);
            }

            director = LayoutDirector.GetLayoutDirector(builder, dotRunner: runner);

            this.canvas.Children.Clear();
            this.progress = new ProgressBar { MinWidth = 100, MinHeight = 12, IsIndeterminate = true, Margin = new Thickness(50) };
            this.canvas.Children.Add(this.progress);
            try
            {
                director.StartBuilder(this.Graph);
#if SILVERLIGHT
                ThreadPool.QueueUserWorkItem(new LayoutAction(this, director).Run);
#else
                Task.Factory.StartNew(new LayoutAction(this, director).Run);
#endif                    
            }
            catch (Exception ex)
            {
                var textBlock = new TextBlock { Width = 300, TextWrapping = TextWrapping.Wrap };
                textBlock.Text =
                    string.Format(
                        "Graphviz4Net: an exception was thrown during layouting." +
                        "Exception message: {0}.",
                        ex.Message);
                this.canvas.Children.Add(textBlock);
            }
        }