Ejemplo n.º 1
0
        private void EdgeLabelControl_LayoutUpdatedDrawLoop(object sender, EventArgs e)
        {
            if (!IsLoaded)
            {
                return;
            }
            var edgeControl = GetEdgeControl(VisualParent);

            if (edgeControl == null)
            {
                return;
            }
            var source = edgeControl.Source;
            var p1     = new Point(GraphCanvas.GetX(source), GraphCanvas.GetY(source));
            var target = edgeControl.Target;
            var p2     = new Point(GraphCanvas.GetX(target), GraphCanvas.GetY(target));

            if (source != target)
            {
                return;
            }


            Point pp0 = new Point(p2.X, p2.Y + 50);
            Point pp1 = new Point(p2.X + 150, p2.Y + 50);
            Point pp2 = new Point(p2.X + 150, p2.Y);

            Point[] pt = new Point[] { pp0, pp1, pp2 };

            edgeControl.RoutePoints = pt;
        }
Ejemplo n.º 2
0
 public void setData(int num, AnimVR.KEYFRAME_TYPE kftype, GraphCanvas clickReciever, Color defaultColor)
 {
     type           = kftype;
     keyframeIndex  = num;
     ClickReciever  = clickReciever;
     m_defaultColor = defaultColor;
 }
Ejemplo n.º 3
0
    // Use this for initialization
    void Start()
    {
        Console.Log("Product Name:\t\t" + Application.productName);
        Console.Log("Company Name:\t\t" + Application.companyName);
        Console.Log("Product Version:\t" + Application.version);
        Console.Log("Unity3D Version:\t" + Application.unityVersion);
        Console.Log("Log Time:\t\t" + System.DateTime.Now.ToFileTime() + "\n");
        Console.Log("");
        Console.Log(LogType.Warning, "This is an example of a warning!");
        Console.Log(LogType.Exception, new IOException("Oh No! There was an exception"));

        DrawManager.DrawVariable("ConsoleOutput", "This is a test of the draw manager");

        DrawManager.DrawVariable("Wall", "This is a test of the draw manager");

        fpsGraph   = Grapher.CreateGraph("Realtime Graph", GraphCanvasType.LINE_PLOT, true, true, 0f, 100f);
        deltaGraph = Grapher.CreateGraph("Plot Graph", GraphCanvasType.SCATTER_PLOT, false, false, 100f, 100f);
        lineGraph  = Grapher.CreateGraph("Line Graph", GraphCanvasType.LINE_PLOT, false, false, 100f, 100f);

        for (int i = 0; i < 150; i++)
        {
            deltaGraph.SetPlotPoint(new Vector2(Random.value * 50, Random.value * 100));
        }

        for (int i = 0; i < 9; i++)
        {
            lineGraph.SetPlotPoint(new Vector2((i + 1) * 10, Random.Range(0, 100)));
        }


        InvokeRepeating("PostRandom", 2.5f, 2.5f);
    }
Ejemplo n.º 4
0
        public override void Initialize()
        {
            base.Initialize();

            _spriteBatch = new SpriteBatch(_game.GraphicsDevice);

            FindSystem <MusicSystem>().Music = Beatmap.Music;
            MediaPlayer.Volume = Settings.SongVolumeF;

            FindSystem <HealthSystem>().HpDrainRate = Beatmap.Settings.Difficulty.HpDrainRate;

            ScoreGraph = new GraphCanvas(_game)
            {
                Position             = new Vector2(Skin.Settings.PlayfieldPositionX, 300),
                Size                 = new Size2(Skin.PlayfieldLineTexture.Width * 2, 100),
                MinValue             = -158,
                MaxValue             = 158,
                Font                 = Skin.Font,
                ShouldDrawBackground = false,
                ShouldDrawBars       = false,
                CellSize             = new Size2(5, 20)
            };
            _game.Components.Add(ScoreGraph);

            FindSystem <ScoreV1System>().OnScoreGet += (sender, handler) =>
            {
                ScoreGraph.PushValue(handler.Offset);
            };

            InitializeAllHitObjects();
        }
Ejemplo n.º 5
0
        protected override void InitCanvas()
        {
            titleContent = new GUIContent("AI Designer");
            base.InitCanvas();
            GraphCanvas.LocalRect = new Rect(-50000, -50000, 100000, 100000);

            mWires = new BTWireGUI(this);
            GraphCanvas.AddElement(mWires);

            AIGraph           = new EditorGUICanvas();
            AIGraph.LocalRect = new Rect(-50000, -50000, 100000, 100000);
            GraphCanvas.AddElement(AIGraph);

            RootNode = new BTRootNodeGUI(this);
            AIGraph.AddElement(RootNode);

            BlackboardMonitor           = new BlackboardMonitorGUI(this);
            BlackboardMonitor.LocalRect = new Rect(0, 0, 200, 180);
            RootCanvas.AddElement(BlackboardMonitor);

            HelpBox           = new BehaviourHelpGUI();
            HelpBox.SortOrder = -10;
            RootCanvas.AddElement(HelpBox);

            mSelectionRect         = new EditorSelection();
            mSelectionRect.Visible = false;
            GraphCanvas.AddElement(mSelectionRect);

            Tip = new TipBox();
            RootCanvas.AddElement(Tip);

            RootCanvas.Resort(true);
        }
Ejemplo n.º 6
0
        public void SaveToPDF(string fileName)
        {
            RenderTargetBitmap renderBitmap = new RenderTargetBitmap(
                (int)GraphCanvas.ActualWidth, (int)GraphCanvas.ActualHeight,
                96d, 96d, PixelFormats.Pbgra32);

            GraphCanvas.Measure(new Size((int)GraphCanvas.ActualWidth, (int)GraphCanvas.ActualHeight));
            GraphCanvas.Arrange(new Rect(new Size((int)GraphCanvas.ActualWidth, (int)GraphCanvas.ActualHeight)));

            renderBitmap.Render(GraphCanvas);


            using (PdfDocument document = new PdfDocument())
            {
                PdfPage     page     = document.Pages.Add();
                PdfGraphics graphics = page.Graphics;

                using (var ms = new MemoryStream())
                {
                    PngBitmapEncoder encoder = new PngBitmapEncoder();
                    encoder.Frames.Add(BitmapFrame.Create(renderBitmap));
                    encoder.Save(ms);
                    PdfBitmap image = new PdfBitmap(ms);
                    graphics.DrawImage(image, 0, 0);

                    document.Save(fileName);
                }
            }
        }
        /// <summary>
        /// Updates the vertex internal information.
        /// Maintains consistency between the vertex's position on the
        /// screen and ins internal information.
        /// </summary>
        /// <param name="vertex"></param>
        /// <param name="graphLayout"></param>
        public void UpdateVertexInfo(ref VertexCity vertex, ref GraphLayoutCity graphLayout)
        {
            if (vertex != null)
            {
                // Get the vertex control
                VertexControl vertexControl = graphLayout.GetVertexControl(vertex);

                // If we could find the verex control
                if (vertexControl != null)
                {
                    double tempXCoord, tempYCoord;

                    // Get the vertex screen coordinates
                    tempXCoord = GraphCanvas.GetX(vertexControl);
                    tempYCoord = GraphCanvas.GetY(vertexControl);

                    // Update the internal information if the coordinates
                    // are in range from 0 to 800
                    if ((tempXCoord > 0) && (tempXCoord < 800) &&
                        (tempYCoord > 0) && (tempYCoord < 800))
                    {
                        vertex.CityCoordinates.setX((int)tempXCoord);
                        vertex.CityCoordinates.setY((int)tempYCoord);
                    }

                    // Set the new screen coordinates
                    GraphCanvas.SetX(vertexControl, vertex.CityCoordinates.getX());
                    GraphCanvas.SetY(vertexControl, vertex.CityCoordinates.getY());
                }
            }
        }
Ejemplo n.º 8
0
        protected override void Initialize()
        {
            LogHelper.Log("Game Root: Initialize..");

            _fpsCounter = new FpsCounter(this);

            Components.Add(_fpsCounter);

            _graphCanvas = new GraphCanvas(this)
            {
                Position = new Vector2(660, 256),
                Size     = new Size2(600, 100)
            };
            Components.Add(_graphCanvas);

            _fpsCounter.OnFpsUpdate += (sender, args) =>
            {
                FpsCounter fpsCounter = (FpsCounter)sender;
                _graphCanvas.PushValue(fpsCounter.FramesPerSecond);
            };

            base.Initialize();

            LogHelper.Log("Game Root: End Initialize..");
        }
Ejemplo n.º 9
0
        public Image DrawImage(string fileName)
        {
            var ltrans = GraphCanvas.LayoutTransform;
            var rtrans = GraphCanvas.RenderTransform;

            GraphCanvas.LayoutTransform = null;
            GraphCanvas.RenderTransform = null;
            var renderSize = GraphCanvas.RenderSize;

            double scale = FitFactor;
            int    w     = (int)(GeometryGraph.Width * scale);
            int    h     = (int)(GeometryGraph.Height * scale);

            SetTransformOnViewportWithoutRaisingViewChangeEvent(scale, GeometryGraph.BoundingBox.Center, new Rectangle(0, 0, w, h));

            Size size = new Size(w, h);

            // Measure and arrange the surface
            // VERY IMPORTANT
            GraphCanvas.Measure(size);
            GraphCanvas.Arrange(new Rect(size));

            foreach (var node in drawingGraph.Nodes.Concat(drawingGraph.RootSubgraph.AllSubgraphsDepthFirstExcludingSelf()))
            {
                IViewerObject o;
                if (drawingObjectsToIViewerObjects.TryGetValue(node, out o))
                {
                    ((KosmographViewerNode)o).Invalidate();
                }
            }

            RenderTargetBitmap renderBitmap = new RenderTargetBitmap(w, h, DpiX, DpiY, PixelFormats.Pbgra32);

            renderBitmap.Render(GraphCanvas);

            if (fileName != null)
            {
                // Create a file stream for saving image
                using (System.IO.FileStream outStream = new System.IO.FileStream(fileName, System.IO.FileMode.Create))
                {
                    // Use png encoder for our data
                    PngBitmapEncoder encoder = new PngBitmapEncoder();
                    // push the rendered bitmap to it
                    encoder.Frames.Add(BitmapFrame.Create(renderBitmap));
                    // save the data to the stream
                    encoder.Save(outStream);
                }
            }

            GraphCanvas.LayoutTransform = ltrans;
            GraphCanvas.RenderTransform = rtrans;
            GraphCanvas.Measure(renderSize);
            GraphCanvas.Arrange(new Rect(renderSize));

            return(new Image {
                Source = renderBitmap
            });
        }
Ejemplo n.º 10
0
 bool InteractGraphDragBegin(EMouseButton btn, Vector2 mousePos)
 {
     if (btn == EMouseButton.left)
     {
         mSelectionRect.Visible   = true;
         mSelectionRect.LocalRect = new Rect(GraphCanvas.CalculateLocalPosition(mousePos), Vector2.zero);
         return(true);
     }
     return(false);
 }
Ejemplo n.º 11
0
        private void DeleteButtonOnClick(object sender, RoutedEventArgs e)
        {
            GraphCanvas canvas = VisualTreeHelper.GetParent(this) as GraphCanvas;

            if (canvas != null)
            {
                SourceNode.Children.Remove(SinkNode);
                canvas.Children.Remove(this);
            }
        }
Ejemplo n.º 12
0
        public void Initialise(GraphCanvas canvas, List <string> filtersList)
        {
            _canvas              = canvas;
            _filters             = filtersList;
            cbxEnableCanvas.Text = _canvas.Name;

            btnColor.BackColor      = Color.FromArgb(_canvas.Color.ToArgb());
            cbxEnableCanvas.Checked = true;
            _canvas.Hide            = false;
        }
Ejemplo n.º 13
0
 bool InteractGraphDrag(EMouseButton btn, Vector2 mousePos, Vector2 mouseDelta)
 {
     if (btn == EMouseButton.left)
     {
         var rect = mSelectionRect.LocalRect;
         rect.max = GraphCanvas.CalculateLocalPosition(mousePos);
         mSelectionRect.LocalRect = rect;
         return(true);
     }
     return(false);
 }
Ejemplo n.º 14
0
        protected override void OnMouseLeftButtonDown(MouseButtonEventArgs e)
        {
            base.OnMouseLeftButtonDown(e);
            GraphCanvas canvas = VisualTreeHelper.GetParent(this) as GraphCanvas;

            if (canvas != null)
            {
                canvas.NodeService.ClearSelection();
                canvas.NodeService.SelectConnection(this);
            }
            e.Handled = true;
        }
Ejemplo n.º 15
0
        public void Invalidate()
        {
            var g = new FastGraphics(Canvas, _typedChildren);

            Canvas.Clip = new RectangleGeometry()
            {
                Rect = new Rect(0, 0, Canvas.ActualWidth, Canvas.ActualHeight)
            };

            GraphCanvas.Paint(g, (int)Canvas.ActualWidth, (int)Canvas.ActualHeight);

            g.FinalizeGraphics();
        }
Ejemplo n.º 16
0
        private void prop_PositionChanged(GraphCanvas sender, bool up)
        {
            SuspendLayout();
            int index = _collection.List.IndexOf(sender);

            if (up)
            {
                _collection.MoveBackward(index);
            }
            else
            {
                _collection.MoveForward(index);
            }
            RebindGraphs();
            ResumeLayout();
            Invalidate();
        }
Ejemplo n.º 17
0
        public BehaviourTreeDesignerWindow() : base()
        {
            mMaxScale            = 2;
            GraphCanvas.GridSize = 200;
            SelectionRect        = new SelectionGUI();
            RootCanvas.AddElement(SelectionRect);
            ScaledCanvas.Pivot = new Vector2(0.5f, 0.25f);
            GraphCanvas.Pivot  = new Vector2(0.5f, 0.1f);
            Rect r = GraphCanvas.LocalRect;

            r.position            = new Vector2(-0.5f * r.width, -0.1f * r.height);
            GraphCanvas.LocalRect = r;

            TreeGraph = new Graph <PaintElement>(1);

            Rect grect = new Rect(-GraphCanvas.LocalRect.size * 0.5f, GraphCanvas.LocalRect.size);
            BehaviourTreeWireGUI wires = new BehaviourTreeWireGUI(this);

            wires.LocalRect = grect;
            GraphCanvas.AddElement(wires);

            TreeCanvas           = new EditorGUICanvas();
            TreeCanvas.LocalRect = grect;
            GraphCanvas.AddElement(TreeCanvas);

            CommentCanvas           = new EditorGUICanvas();
            CommentCanvas.SortOrder = -2;
            CommentCanvas.LocalRect = grect;
            GraphCanvas.AddElement(CommentCanvas);

            ContextMenu = new BehaviourTreeContextMenuGUI(this);
            GraphCanvas.AddElement(ContextMenu);

            BlackboardMonitorGUI blackboard = new BlackboardMonitorGUI(this);

            blackboard.LocalRect = new Rect(0, 0, 200, 180);
            RootCanvas.AddElement(blackboard);

            RootCanvas.Resort(true);

            GraphCanvas.OnDragBegin  = OnGraphDragBegin;
            GraphCanvas.OnDrag       = OnGraphDrag;
            GraphCanvas.OnDragEnd    = OnGraphDragEnd;
            GraphCanvas.OnMouseClick = OnGraphClick;
            GraphCanvas.OnKeyUp      = OnGraphKeyUp;
        }
Ejemplo n.º 18
0
        /// <inheritdoc />
        public void Animate(
            IAnimationContext context,
            System.Windows.Controls.Control control,
            double x,
            double y,
            TimeSpan duration)
        {
            if (!double.IsNaN(x))
            {
                double from = GraphCanvas.GetX(control);
                from = double.IsNaN(from) ? 0.0 : from;

                // Create the animation for the horizontal position
                var animationX = new DoubleAnimation(
                    from,
                    x,
                    duration,
                    FillBehavior.HoldEnd);
                animationX.Completed += (s, e) =>
                {
                    control.BeginAnimation(GraphCanvas.XProperty, null);
                    control.SetValue(GraphCanvas.XProperty, x);
                };
                control.BeginAnimation(GraphCanvas.XProperty, animationX, HandoffBehavior.Compose);
            }

            if (!double.IsNaN(y))
            {
                double from = GraphCanvas.GetY(control);
                from = (double.IsNaN(from) ? 0.0 : from);

                // Create an animation for the vertical position
                var animationY = new DoubleAnimation(
                    from, y,
                    duration,
                    FillBehavior.HoldEnd);
                animationY.Completed += (s, e) =>
                {
                    control.BeginAnimation(GraphCanvas.YProperty, null);
                    control.SetValue(GraphCanvas.YProperty, y);
                };
                control.BeginAnimation(GraphCanvas.YProperty, animationY, HandoffBehavior.Compose);
            }
        }
Ejemplo n.º 19
0
        public TabCanvas(Canvas canvas, GraphCanvas graphCanvas, SLPropertyGrid.PropertyGrid propertyGrid, TabItem container)
        {
            GraphCanvas        = graphCanvas;
            Canvas             = canvas;
            GraphCanvas.Canvas = this;
            PropertyGrid       = propertyGrid;
            Container          = container;

            Canvas.MouseLeftButtonDown  += OnMouseLeftButtonDown;
            Canvas.MouseRightButtonDown += OnMouseRightButtonDown;
            Canvas.MouseLeftButtonUp    += OnMouseLeftButtonUp;
            Canvas.MouseRightButtonUp   += OnMouseRightButtonUp;
            Canvas.MouseMove            += image_MouseMove;

            Canvas.Loaded      += delegate { Invalidate(); };
            Canvas.SizeChanged += delegate { Invalidate(); };

            GraphCanvas.GraphModified += OnGraphModified;
            GraphCanvas.NameModified  += OnNameModified;
        }
        /// <summary>
        /// Get the data about the current graph's
        /// node, edges and their coordinates. Save this
        /// data to citiesLocations and citiesConnections.
        /// </summary>
        public void GetCurrentGraph(GraphLayoutCity graphLayout,
                                    ref CitiesLocations citiesLocations)
        {
            VertexControl vertexControl = new VertexControl();
            Coordinates   tempVertexCoordinates;
            int           tempXCoord;
            int           tempYCoord;

            foreach (VertexCity vertex in graphLayout.Graph.Vertices)
            {
                // Get the vertex data and a vertex control
                citiesLocations.locations.TryGetValue(vertex.City, out tempVertexCoordinates);
                vertexControl = graphLayout.GetVertexControl(vertex);

                // Get current coordinates
                tempXCoord = (int)GraphCanvas.GetX(vertexControl);
                tempYCoord = (int)GraphCanvas.GetY(vertexControl);

                // Update the information
                tempVertexCoordinates.setX(tempXCoord);
                tempVertexCoordinates.setY(tempYCoord);
            }
        }
Ejemplo n.º 21
0
        private void OnEnable()
        {
            if (graphCanvas == null)
            {
                graphCanvas = GetComponentInParent <GraphCanvas>();
            }

            if (graphCanvas == null)
            {
                graphCanvas = transform.parent
                              .GetComponentInChildren <GraphCanvas>();
            }

            if (graphCanvas == null)
            {
                graphCanvas = transform.parent.parent
                              .GetComponentInChildren <GraphCanvas>();
            }

            if (graphCanvas != null)
            {
                Generate();
            }
        }
        /// <summary>
        /// Set the nodes coordinates to the coordinates from the
        /// locations file.
        /// </summary>
        /// <param name="graphLayout">
        /// Graph layout
        /// </param>
        /// <param name="citiesLocations">
        /// Locations file that has the desired coordinates for the graph's vertices
        /// </param>
        public void EstablishCoordinates(ref GraphLayoutCity graphLayout,
                                         CitiesLocations citiesLocations)
        {
            VertexControl vertexControl = new VertexControl();
            Coordinates   tempVertexCoordinates;

            if (citiesLocations != null)
            {
                foreach (VertexCity vertex in graphLayout.Graph.Vertices)
                {
                    // Get the coordinates from the locations file
                    citiesLocations.locations.TryGetValue(vertex.City, out tempVertexCoordinates);

                    // Update the vertex data
                    vertex.CityCoordinates.setX(tempVertexCoordinates.getX());
                    vertex.CityCoordinates.setY(tempVertexCoordinates.getY());

                    // Update the vertex position on the screen
                    vertexControl = graphLayout.GetVertexControl(vertex);
                    GraphCanvas.SetX(vertexControl, vertex.CityCoordinates.getX());
                    GraphCanvas.SetY(vertexControl, vertex.CityCoordinates.getY());
                }
            }
        }
 public AnimationContext( GraphCanvas canvas )
 {
     GraphCanvas = canvas;
 }
Ejemplo n.º 24
0
        private void DrawABarChart(List <int> dataToDraw, List <string> cols, List <string> labelForBars)
        {
            for (int i = 0; i < dataToDraw.Count; i++)
            {
                int heightOfBar = dataToDraw[i];
                if (dataToDraw[i] > 100)
                {
                    heightOfBar = 0;
                }

                if (cols[i].Contains("Teacher", StringComparison.InvariantCultureIgnoreCase) || cols[i].Contains("Timetable", StringComparison.InvariantCultureIgnoreCase) || cols[i].Contains("Name", StringComparison.InvariantCultureIgnoreCase) || cols[i].Contains("Ethnicity", StringComparison.InvariantCultureIgnoreCase) || cols[i].Contains("birth", StringComparison.InvariantCultureIgnoreCase))
                {
                    continue;
                }

                Rectangle bar = new Rectangle
                {
                    Width   = widthOfTheGraphBars,
                    Height  = ((GraphCanvas.ActualHeight - 199 - 20) / 100) * heightOfBar,
                    Fill    = new SolidColorBrush(ColorDictionary[cols[i]]),
                    Stroke  = Brushes.Black,
                    ToolTip = cols[i].ToString() + " " + dataToDraw[i].ToString(),
                };
                Canvas.SetLeft(bar, distanceFromLeft);
                Canvas.SetBottom(bar, 200);

                if (heightOfBar != 0)
                {
                    System.Windows.Controls.Label LabelOnGraphForBars = new System.Windows.Controls.Label
                    {
                        Content    = $"{labelForBars[i]}",
                        Background = new SolidColorBrush(ColorDictionary[cols[i]]),
                        Foreground = Brushes.Black,
                        VerticalContentAlignment = VerticalAlignment.Center,
                        RenderTransform          = new RotateTransform(270),
                        Height  = widthOfTheGraphBars,
                        Padding = new System.Windows.Thickness(0, 0, 0, 0),
                    };

                    Canvas.SetLeft(LabelOnGraphForBars, distanceFromLeft);
                    Canvas.SetBottom(LabelOnGraphForBars, 190);
                    GraphCanvas.Children.Add(LabelOnGraphForBars);
                }

                System.Windows.Controls.Label PercentageMarkLabel = new System.Windows.Controls.Label
                {
                    Content                  = $"{dataToDraw[i]}%",
                    Foreground               = Brushes.Black,
                    RenderTransform          = new RotateTransform(270),
                    Height                   = widthOfTheGraphBars,
                    VerticalContentAlignment = VerticalAlignment.Center,
                    Padding                  = new System.Windows.Thickness(0, 0, 0, 0)
                };
                GraphCanvas.Children.Add(PercentageMarkLabel);
                Canvas.SetLeft(PercentageMarkLabel, distanceFromLeft);
                Canvas.SetBottom(PercentageMarkLabel, 188 + (((GraphCanvas.ActualHeight - 199 - 20) / 100) * heightOfBar));

                System.Windows.Controls.Label textBlock = new System.Windows.Controls.Label
                {
                    Content                    = cols[i],
                    Height                     = widthOfTheGraphBars,
                    Width                      = 170,
                    Foreground                 = Brushes.Black,
                    RenderTransform            = new RotateTransform(270),
                    VerticalContentAlignment   = VerticalAlignment.Center,
                    HorizontalContentAlignment = System.Windows.HorizontalAlignment.Right,
                    Padding                    = new System.Windows.Thickness(0, 0, 5, 0),
                };
                TextBlock.SetTextAlignment(textBlock, TextAlignment.Right);
                Canvas.SetLeft(textBlock, distanceFromLeft);
                Canvas.SetBottom(textBlock, 0 + (30 - widthOfTheGraphBars));

                GraphCanvas.Children.Add(textBlock);
                GraphCanvas.Children.Add(bar);
                distanceFromLeft += widthOfTheGraphBars;
                distanceFromLeft += 1; //gap between bars
            }
            distanceFromLeft += widthOfTheGraphBars;
            GraphCanvas.Width = distanceFromLeft + 20;
            GraphCanvas.UpdateLayout();
        }
        public void Initialise(GraphCanvas canvas, List <string> filters)
        {
            _canvas = canvas;
            cbGraphType.Items.AddRange(new object[] { "Line Graph", "Scatter Plot", "Solid Graph" });
            cbScaleFunction.Items.AddRange(new object[] { "Maximum", "Average" });
            cbScaleTarget.Items.AddRange(new object[] { "Data Volume", "Packet Count" });

            foreach (var f in filters)
            {
                cbScaleTarget.Items.Add("Filter: " + f);
            }

            selectedType     = _canvas.GraphType;
            selectedFunction = _canvas.ScaleFunction.Function;
            selectedTarget   = _canvas.ScaleFunction.Target;
            filter           = _canvas.ScaleFunction.FilterIndex;

            switch (_canvas.GraphType)
            {
            case GraphType.LineGraph:
                cbGraphType.SelectedIndex = 0;
                break;

            case GraphType.ScatterPlot:
                cbGraphType.SelectedIndex = 1;
                break;

            case GraphType.SolidGraph:
                cbGraphType.SelectedIndex = 2;
                break;

            default:
                throw new ArgumentOutOfRangeException("type");
            }


            switch (_canvas.ScaleFunction.Function)
            {
            case GraphScaleFunction.Maximum:
                cbScaleFunction.SelectedIndex = 0;
                break;

            case GraphScaleFunction.AverageOver2:
                cbScaleFunction.SelectedIndex = 1;
                break;

            default:
                throw new ArgumentOutOfRangeException();
            }

            switch (_canvas.ScaleFunction.Target)
            {
            case GraphScaleTarget.DataVolume:
                cbScaleTarget.SelectedIndex = 0;
                break;

            case GraphScaleTarget.PacketCount:
                cbScaleTarget.SelectedIndex = 1;
                break;

            case GraphScaleTarget.MatchingCount:
                cbScaleTarget.SelectedIndex = 2 + filter;
                break;

            default:
                throw new ArgumentOutOfRangeException();
            }
        }
Ejemplo n.º 26
0
        /// <summary>
        /// Likely defunct method/button because hardcoded stuff usually breaks
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void AutoGenerateButton_Click(object sender, RoutedEventArgs e)
        {
            try
            {
                col2.Width = new GridLength(0, GridUnitType.Pixel);
                col3.Width = new GridLength(1, GridUnitType.Star);
                Height     = System.Windows.SystemParameters.PrimaryScreenHeight;
                UpdateLayout();
                GraphCanvas.UpdateLayout();
                //System.Threading.Thread.Sleep(1000);

                List <string> grafsFor1Band = new List <string> {
                    "911", "912", "913", "914"
                };
                List <string> grafsFor2Band = new List <string> {
                    "921", "922", "923", "924", "925", "926", "927", "928", "929"
                };
                List <string> grafsFor3Band = new List <string> {
                    "931", "932", "933"
                };
                List <string> colsToDay = new List <string> {
                    "Algebra Average", "Number Average", "Prob & Stats Average", "Measurement Average", "Geometry Average", "Common Test Average"
                };
                //Algebra Average,Number Average,Prob & Stats Average,Measurement Average,Geometry Average,Common Test Average

                drawXandYAxis();
                foreach (var item in grafsFor1Band)
                {
                    List <int> dataToDraw = FilterGroupingsIntoDataToGraph(item, colsToDay.ToList <string>());
                    DrawAutoGenStuff(dataToDraw, colsToDay.ToList <string>(), item);
                }
                AutoSave(grafsFor1Band[0] + "Band Graphs");


                GraphCanvas.Children.Clear();
                distanceFromLeft = 40;
                drawXandYAxis();
                col3.Width = new GridLength(1200, GridUnitType.Pixel);
                GraphCanvas.UpdateLayout();
                foreach (var item in grafsFor2Band)
                {
                    List <int> dataToDraw = FilterGroupingsIntoDataToGraph(item, colsToDay.ToList <string>());
                    DrawAutoGenStuff(dataToDraw, colsToDay.ToList <string>(), item);
                }
                AutoSave(grafsFor2Band[0] + "Band Graphs");

                GraphCanvas.Children.Clear();
                distanceFromLeft = 40;
                drawXandYAxis();
                GraphCanvas.UpdateLayout();
                foreach (var item in grafsFor3Band)
                {
                    List <int> dataToDraw = FilterGroupingsIntoDataToGraph(item, colsToDay.ToList <string>());
                    DrawAutoGenStuff(dataToDraw, colsToDay.ToList <string>(), item);
                }
                AutoSave(grafsFor3Band[0] + "Band Graphs");

                col2.Width = new GridLength(1, GridUnitType.Star);
                col3.Width = new GridLength(0, GridUnitType.Pixel);
                GraphCanvas.Children.Clear();
                distanceFromLeft = 40;
            }
            catch
            {
                System.Windows.MessageBox.Show("Autogenerate only works with data in the correct format, make sure you have the bands: 911-933 and the columns: Algebra Average, Number Average, Prob & Stats Average, Measurement Average, Geometry Average, Common Test Average");
                viewDataButton_Click(sender, e);
            }
        }
Ejemplo n.º 27
0
        public static void NewTab(string name = null, Graph G = null)
        {
            if (string.IsNullOrEmpty(name))
            {
                name = "sheet " + _tabID;
            }

            var canvas = new HTMLCanvasElement();

            canvas.Id        = "Tab" + _tabID;
            canvas.Width     = (int)(Window.InnerWidth);
            canvas.Height    = (int)(Window.InnerHeight);
            canvas.ClassName = "IAmAGraphCanvas";

            canvas.OnShow += delegate
            {
                canvas.Width  = canvas.ParentElement.ClientWidth;
                canvas.Height = canvas.ParentElement.ClientHeight;
            };

            if (G == null)
            {
                G = new Graph();
            }
            var graphCanvas = new GraphCanvas(G);
            var tc          = new TabCanvas(canvas, graphCanvas);

            tc.Invalidate();

            var tabPane = new HTMLDivElement();

            tabPane.ClassName = "tab-pane active";
            tabPane.Id        = "Tab" + _tabID;
            tabPane.AppendChild(canvas);

            var tabControlContent = Document.GetElementById("TabControlContent");

            foreach (var child in tabControlContent.Children)
            {
                child.ClassName = "tab-pane";
            }
            tabControlContent.AppendChild(tabPane);

            var tab = new HTMLLIElement();

            tab.ClassName = "active";

            var anchor = new HTMLAnchorElement();

            anchor.SetAttribute("data-toggle", "tab");
            anchor.TextContent         = name;
            anchor.Href                = "#Tab" + _tabID;
            _canvasLookup[anchor.Href] = tc;
            _currentTabCanvas          = anchor.Href;

            tab.AppendChild(anchor);

            var tabControl = Document.GetElementById("TabControl");

            foreach (var child in tabControl.Children)
            {
                child.ClassName = "narf";
            }
            tabControl.InsertBefore(tab, _newSheetTab);

            _tabID++;
        }
Ejemplo n.º 28
0
        private void EdgeLabelControl_LayoutUpdated(object sender, EventArgs e)
        {
            if (!IsLoaded)
            {
                return;
            }


            var edgeControl = GetEdgeControl(VisualParent);

            if (edgeControl == null)
            {
                return;
            }
            var source = edgeControl.Source;
            var p1     = new Point(GraphCanvas.GetX(source), GraphCanvas.GetY(source));
            var target = edgeControl.Target;
            var p2     = new Point(GraphCanvas.GetX(target), GraphCanvas.GetY(target));


            double edgeLength;
            var    routePoints = edgeControl.RoutePoints;

            if (routePoints == null)
            {
                // the edge is a single segment (p1,p2)
                edgeLength = GetLabelDistance(GetDistanceBetweenPoints(p1, p2));
            }
            else
            {
                // the edge has one or more segments
                // compute the total length of all the segments
                edgeLength = 0;
                for (int i = 0; i <= routePoints.Length; ++i)
                {
                    if (i == 0)
                    {
                        edgeLength += GetDistanceBetweenPoints(p1, routePoints[0]);
                    }
                    else if (i == routePoints.Length)
                    {
                        edgeLength += GetDistanceBetweenPoints(routePoints[routePoints.Length - 1], p2);
                    }
                    else
                    {
                        edgeLength += GetDistanceBetweenPoints(routePoints[i - 1], routePoints[i]);
                    }
                }
                // find the line segment where the half distance is located
                edgeLength = GetLabelDistance(edgeLength);
                Point newp1 = p1;
                Point newp2 = p2;
                for (int i = 0; i <= routePoints.Length; ++i)
                {
                    double lengthOfSegment;
                    if (i == 0)
                    {
                        lengthOfSegment = GetDistanceBetweenPoints(newp1 = p1, newp2 = routePoints[0]);
                    }
                    else if (i == routePoints.Length)
                    {
                        lengthOfSegment = GetDistanceBetweenPoints(newp1 = routePoints[routePoints.Length - 1], newp2 = p2);
                    }
                    else
                    {
                        lengthOfSegment = GetDistanceBetweenPoints(newp1 = routePoints[i - 1], newp2 = routePoints[i]);
                    }
                    if (lengthOfSegment >= edgeLength)
                    {
                        break;
                    }
                    edgeLength -= lengthOfSegment;
                }
                // redefine our edge points
                p1 = newp1;
                p2 = newp2;
            }
            // align the point so that it  passes through the center of the label content
            var p           = p1;
            var desiredSize = DesiredSize;

            p.Offset(-desiredSize.Width / 2, -desiredSize.Height / 2);

            // move it "edgLength" on the segment
            var angleBetweenPoints = GetAngleBetweenPoints(p1, p2);

            p.Offset(edgeLength * Math.Cos(angleBetweenPoints), -edgeLength * Math.Sin(angleBetweenPoints));
            Arrange(new Rect(p, desiredSize));
        }
Ejemplo n.º 29
0
 public AnimationContext(GraphCanvas canvas)
 {
     GraphCanvas = canvas;
 }
Ejemplo n.º 30
0
 public GraphImporter(GraphCanvas canvas)
 {
     this.canvas = canvas;
 }