Example #1
0
        public GraphData LoadGraph(string fileName)
        {
            try
            {
                GraphData data = null;

                //Open the file written above and read values from it.

                Stream          stream     = File.Open(fileName, FileMode.Open);
                BinaryFormatter bformatter = new BinaryFormatter();

                data = (GraphData)bformatter.Deserialize(stream);
                stream.Close();

                Reset();

                foreach (var item in data.NodeLocations)
                {
                    AddNewNode(item);
                }
                _edges = data.Edges;


                OnContentChanged(null, null);
                return(data);
            }
            catch { }
            return(null);
        }
Example #2
0
        public GraphUI()
        {
            _edges = new EdgeCollection();

            this.DoubleBuffered = true;
            Control.CheckForIllegalCrossThreadCalls = false;

            _penEdge        = new Pen(Color.MediumPurple, 4);
            _penEdge.EndCap = LineCap.ArrowAnchor;

            _matrix              = new Matrix();
            _matrix.SizeChanged += new EventHandler(_matrix_SizeChanged);
            Reset();
        }