예제 #1
0
파일: GraphUI.cs 프로젝트: cobaka/dm8
        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);
        }
예제 #2
0
파일: GraphUI.cs 프로젝트: cobaka/dm8
        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();
        }