Ejemplo n.º 1
0
        internal void PositionAtCenter(uint nodeId)
        {
            IGraphVisualHost visualHost = this.graphController.GetVisualHost();

            if (visualHost != null)
            {
                DrawingVisual      visual    = visualHost.GetDrawingVisualForNode(nodeId);
                TranslateTransform transform = visual.Transform as TranslateTransform;
                transform.X         = (int)(this.nodePosition.X - this.Width / 2);
                transform.Y         = (int)(this.nodePosition.Y - this.Height / 2);
                this.nodePosition.X = transform.X;
                this.nodePosition.Y = transform.Y;

                if (this.errorBubble != null)
                {
                    DrawingVisual      errorVisual    = visualHost.GetDrawingVisualForBubble(this.errorBubble.BubbleId);
                    TranslateTransform errorTransform = errorVisual.Transform as TranslateTransform;
                    errorTransform.X = (int)(this.nodePosition.X);
                    errorTransform.Y = (int)(this.nodePosition.Y);
                }

                if (this.previewBubble != null)
                {
                    DrawingVisual      previewVisual    = visualHost.GetDrawingVisualForBubble(this.previewBubble.BubbleId);
                    TranslateTransform previewTransform = previewVisual.Transform as TranslateTransform;
                    previewTransform.X = (int)(this.nodePosition.X);
                    previewTransform.Y = (int)(this.nodePosition.Y);
                }
            }
        }
Ejemplo n.º 2
0
        internal void Compose()
        {
            GraphController  controller = graphController as GraphController;
            IGraphVisualHost visualHost = controller.GetVisualHost();

            if (null == visualHost)
            {
                return; // Running in headless mode, draw no further.
            }
            VisualNode node = graphController.GetVisualNode(nodeId);

            DrawingVisual  bubbleVisual   = visualHost.GetDrawingVisualForBubble(this.bubbleId);
            DrawingContext drawingContext = bubbleVisual.RenderOpen();

            if (content == null)
            {
                drawingContext.Close();
                return;
            }
            anchorPoint.X = node.GetBubbleXPosition();
            anchorPoint.Y = node.Height + Configurations.InfoBubbleTopMargin;
            anchorPoint   = new Point((int)anchorPoint.X, (int)anchorPoint.Y);
            arrowLeft     = new Point((int)(anchorPoint.X - Configurations.InfoBubbleArrowWidthHalf), (int)(anchorPoint.Y + Configurations.InfoBubbleArrowHeight));
            arrowRight    = new Point((int)(anchorPoint.X + Configurations.InfoBubbleArrowWidthHalf), (int)(anchorPoint.Y + Configurations.InfoBubbleArrowHeight));

            if (this.previewType.HasFlag(PreviewTypes.Collapsed))
            {
                arrowLeft.Y   = anchorPoint.Y;
                anchorPoint.Y = arrowRight.Y;
                arrowRight.Y  = arrowLeft.Y;
            }
            else
            {
                arrowLeft.Offset(-1, 2);
                arrowRight.Offset(1, 2);
            }

            if (this.previewType.HasFlag(PreviewTypes.String) ||
                this.previewType.HasFlag(PreviewTypes.Unknown))
            {
                this.ComposeValue(drawingContext);
            }
            else if (this.previewType.HasFlag(PreviewTypes.Bitmap))
            {
                this.ComposeGeo(drawingContext);
            }
            drawingContext.Close();

            TranslateTransform transform = bubbleVisual.Transform as TranslateTransform;

            transform.X = node.X;
            transform.Y = node.Y;
        }
        internal GraphController(IGraphVisualHost visualHost, string filePath)
        {
            if (!File.Exists(filePath))
            {
                throw new ArgumentException("'filePath' is not a valid path");
            }

            this.FileLoadInProgress = true;
            this.InitializeInternal(visualHost);
            this.LoadFileInternal(filePath);
            this.filePath = filePath;

            try
            {
                // Attempt to see if we are creating the graph controller from recovery file.
                int index = -1; uint graphId = uint.MaxValue;
                Utilities.GetBackupFileIndex(this.filePath, ref graphId, ref index);

                // If we reach here without exception, then "filePath" is a backup file
                // name. In which case we should not assign a name to "this.filePath" so
                // that the user will be prompted to supply an alternative file name.
                //
                this.filePath = string.Empty;
            }
            catch (Exception)
            {
            }

            DeltaNodes deltaNodes = new DeltaNodes();

            deltaNodes.AppendToAddedNodes(this.nodeCollection.Values.ToList <IVisualNode>());
            this.ValidateNodesSyntax(deltaNodes.AddedNodes);
            this.ValidateDefinedAndReferencedVariables();
            this.UpdateDirtyNodes();
            edgeController.AuditEdges();
            this.edgeController.UpdateDirtyEdges(null);
            if (this.nodeCollection.Count > 0)
            {
                this.SynchronizeToLiveRunner(deltaNodes);
            }
            this.FileLoadInProgress = false;
        }
Ejemplo n.º 4
0
        internal void Compose()
        {
            if (false == this.Dirty)
            {
                return;
            }

            if (IsRunningHeadless)
            {
                return;
            }

            GraphController  controller = graphController as GraphController;
            IGraphVisualHost visualHost = controller.GetVisualHost();

            DrawingVisual visual = visualHost.GetDrawingVisualForNode(this.NodeId);
            //TextOptions.SetTextFormattingMode(visual, TextFormattingMode.Display);
            //TextOptions.SetTextRenderingMode(visual, TextRenderingMode.Aliased);
            DrawingContext drawingContext = visual.RenderOpen();
            CultureInfo    cultureInfo    = new CultureInfo("en-us"); //@TODO(Ben) Move this into a single place and reuse it

            //RenderOptions.SetEdgeMode(visual, EdgeMode.Aliased);
            if (!dotsFlag.HasFlag(MenuDots.DotsFlag))
            {
                this.CheckDots();
            }

            this.ComposeCore(drawingContext, visual);
            drawingContext.Close();

            if (errorBubble != null)
            {
                errorBubble.Compose();
            }

            TranslateTransform nodeTransform = visual.Transform as TranslateTransform;

            nodeTransform.X = this.nodePosition.X;
            nodeTransform.Y = this.nodePosition.Y;

            this.Dirty = false;
        }
Ejemplo n.º 5
0
        internal void Compose()
        {
            if (false == this.Dirty)
            {
                return;
            }

            GraphController  controller = this.edgeController.GetGraphController();
            IGraphVisualHost visualHost = controller.GetVisualHost();

            if (null == visualHost)
            {
                return;
            }

            DrawingVisual  visual  = visualHost.GetDrawingVisualForEdge(this.EdgeId);
            DrawingContext context = visual.RenderOpen();

            DrawCurve(context, this.PreviewSelected);

            context.Close();
        }
        internal GraphController(IGraphVisualHost visualHost, string filePath)
        {
            if (!File.Exists(filePath))
                throw new ArgumentException("'filePath' is not a valid path");

            this.FileLoadInProgress = true;
            this.InitializeInternal(visualHost);
            this.LoadFileInternal(filePath);
            this.filePath = filePath;

            try
            {
                // Attempt to see if we are creating the graph controller from recovery file.
                int index = -1; uint graphId = uint.MaxValue;
                Utilities.GetBackupFileIndex(this.filePath, ref graphId, ref index);

                // If we reach here without exception, then "filePath" is a backup file
                // name. In which case we should not assign a name to "this.filePath" so
                // that the user will be prompted to supply an alternative file name.
                //
                this.filePath = string.Empty;
            }
            catch (Exception)
            {
            }

            DeltaNodes deltaNodes = new DeltaNodes();
            deltaNodes.AppendToAddedNodes(this.nodeCollection.Values.ToList<IVisualNode>());
            this.ValidateNodesSyntax(deltaNodes.AddedNodes);
            this.ValidateDefinedAndReferencedVariables();
            this.UpdateDirtyNodes();
            edgeController.AuditEdges();
            this.edgeController.UpdateDirtyEdges(null);
            if (this.nodeCollection.Count > 0)
                this.SynchronizeToLiveRunner(deltaNodes);
            this.FileLoadInProgress = false;
        }
Ejemplo n.º 7
0
 public SelectionBox(IGraphController graphController, IGraphVisualHost visualHost)
 {
     this.graphController = graphController;
     this.visualHost      = visualHost;
     InitializeSelectionBox();
 }
 internal GraphController(IGraphVisualHost visualHost)
 {
     this.InitializeInternal(visualHost);
 }
Ejemplo n.º 9
0
 public SelectionBox(IGraphController graphController, IGraphVisualHost visualHost)
 {
     this.graphController = graphController;
     this.visualHost = visualHost;
     InitializeSelectionBox();
 }
Ejemplo n.º 10
0
 public static IGraphController CreateGraphController(IGraphVisualHost visualHost, string filePath)
 {
     return new GraphController(visualHost, filePath);
 }
Ejemplo n.º 11
0
 public static IGraphController CreateGraphController(IGraphVisualHost visualHost)
 {
     return new GraphController(visualHost);
 }
 internal GraphController(IGraphVisualHost visualHost)
 {
     this.InitializeInternal(visualHost);
 }
Ejemplo n.º 13
0
        private void InitializeInternal(IGraphVisualHost visualHost)
        {
            //The identity of this graph controller
            this.Identifier = GraphController.identifierCounter++;

            //Optional Object
            this.visualHost = visualHost;

            //Essential Object
            this.edgeController = new EdgeController(this);
            this.graphProperties = new GraphProperties();
            this.undoRedoRecorder = new UndoRedoRecorder(this);

            DrawingVisual visual = new DrawingVisual();
            this.selectionBox = new SelectionBox(this, this.visualHost);

            // Create a timer for auto-saving in the background.
            this.autoSaveTimer = new DispatcherTimer();
            this.autoSaveTimer.Interval = TimeSpan.FromSeconds(58);
            this.autoSaveTimer.Tick += OnAutoSaveTimerTicked;
        }
Ejemplo n.º 14
0
        internal void Compose()
        {
            GraphController  controller = graphController as GraphController;
            IGraphVisualHost visualHost = controller.GetVisualHost();

            if (null == visualHost)
            {
                return; // Running in headless mode, draw no further.
            }
            DrawingVisual  bubbleVisual   = visualHost.GetDrawingVisualForBubble(this.bubbleId);
            DrawingContext drawingContext = bubbleVisual.RenderOpen();

            string text = this.content as string;

            if (string.IsNullOrEmpty(text))
            {
                drawingContext.Close();
                return;
            }

            if (this.ErrType == ErrorType.None)
            {
                ErrorManager.HandleError(new InvalidOperationException("'errorType' is not set"));
            }

            VisualNode node = graphController.GetVisualNode(this.OwnerId);

            this.anchorPoint.X = node.Width / 2;
            this.anchorPoint.Y = -Configurations.InfoBubbleTopMargin;
            this.anchorPoint   = new Point((int)this.anchorPoint.X, (int)this.anchorPoint.Y);
            this.arrowLeft     = new Point((int)this.anchorPoint.X - Configurations.InfoBubbleArrowWidthHalf, (int)this.anchorPoint.Y - Configurations.InfoBubbleArrowHeight);
            this.arrowRight    = new Point((int)this.anchorPoint.X + Configurations.InfoBubbleArrowWidthHalf, (int)this.anchorPoint.Y - Configurations.InfoBubbleArrowHeight);
            this.arrowLeft.Offset(-1, -2);
            this.arrowRight.Offset(1, -2);

            double          textLength;
            int             textHorizontalMargin;
            int             textVerticalMargin;
            FormattedText   newText;
            SolidColorBrush textColor;
            SolidColorBrush backgroundColor;
            Pen             borderPen;

            if (this.ErrType == ErrorType.Warning)
            {
                textColor       = Configurations.ErrorBubbleWarningTextColor;
                borderPen       = Configurations.ErrorBubbleWarningBorderPen;
                backgroundColor = Configurations.ErrorBubbleWarningBackground;
            }
            else
            {
                textColor = Configurations.ErrorBubbleErrorTextColor;
                borderPen = Configurations.ErrorBubbleErrorBorderPen;
                //if (this.node.Selected == true)
                backgroundColor = Configurations.ErrorBubbleErrorBackgroundActive;
                //else
                //    backgroundColor = Configurations.ErrorBubbleErrorBackgroundNonActive;
            }

            textHorizontalMargin = Configurations.InfoBubbleMargin;
            textVerticalMargin   = Configurations.InfoBubbleMargin;

            newText = new FormattedText(text,
                                        Configurations.culture,
                                        FlowDirection.LeftToRight,
                                        Configurations.TypeFace,
                                        Configurations.InfoBubbleText,
                                        textColor);

            newText.LineHeight = Configurations.InfoBubbleText;
            textLength         = newText.WidthIncludingTrailingWhitespace;

            this.rectWidth  = (int)(textLength + textHorizontalMargin * 2);
            this.rectHeight = (int)(textVerticalMargin * 2 + newText.Height);
            if (this.rectWidth < Configurations.InfoBubbleMinWidth)
            {
                this.rectWidth = Configurations.InfoBubbleMinWidth;
            }

            this.rectPoint = new Point((int)(this.anchorPoint.X - this.rectWidth / 2) + 0.5, (int)(this.anchorPoint.Y - Configurations.InfoBubbleArrowHeight - this.rectHeight) + 0.5);

            //Draw Bubble
            base.DrawBubble(drawingContext, backgroundColor, borderPen, true);

            //Draw Text
            drawingContext.DrawText(newText, new Point(this.rectPoint.X + textHorizontalMargin, this.rectPoint.Y + textVerticalMargin));
            drawingContext.Close();

            TranslateTransform transform = bubbleVisual.Transform as TranslateTransform;

            transform.X = node.X;
            transform.Y = node.Y;
        }
Ejemplo n.º 15
0
 public static IGraphController CreateGraphController(IGraphVisualHost visualHost, string filePath)
 {
     return(new GraphController(visualHost, filePath));
 }
Ejemplo n.º 16
0
 public static IGraphController CreateGraphController(IGraphVisualHost visualHost)
 {
     return(new GraphController(visualHost));
 }