public static NodeRender GetNodeRender(NodeCollectionStorage <FullConnectedGraph> storage, Canvas canvas) { var nodeEllipseCreator = new EllipseCreator(Brushes.Black, Brushes.DarkGray, 5, 0.7); var startNodeEllipseCreator = new EllipseCreator(Brushes.Blue, Brushes.Transparent, 8, 0.9); var endNodeEllipseCreator = new EllipseCreator(Brushes.Red, Brushes.Transparent, 8, 0.9); return(new NodeRender(storage, canvas, nodeEllipseCreator, startNodeEllipseCreator, endNodeEllipseCreator)); }
public static ResultRender GetResultRender(Canvas canvas, SolversHolder solversHolder, NodeCollectionStorage <FullConnectedGraph> storage) { var ellipseCreator = new EllipseCreator(Brushes.Black, Brushes.SlateGray, 4, 0.5); var polyLinesCreator = new PolylineCreator(Brushes.Blue, 1, 1); const double border = 5; return(new ResultRender(canvas, solversHolder, ellipseCreator, polyLinesCreator, border, storage)); }
public void Reset() { ShapeTypesInfoMap.Clear(); RegisterShapeType(LineCreator.getInstance(), StandardLineRenderer.getInstance()); RegisterShapeType(RectangleCreator.getInstance(), StandardRectangleRenderer.getInstance()); RegisterShapeType(SquareCreator.getInstance(), StandardRectangleRenderer.getInstance()); RegisterShapeType(EllipseCreator.getInstance(), StandardEllipseRenderer.getInstance()); RegisterShapeType(CircleCreator.getInstance(), StandardEllipseRenderer.getInstance()); RegisterShapeType(TriangleCreator.getInstance(), StandardTriangleRenderer.getInstance()); }
public ResultRender(Canvas canvas, SolversHolder solversHolder, EllipseCreator ellipseCreator, PolylineCreator polylineCreator, double border, NodeCollectionStorage <FullConnectedGraph> storage) { _canvas = canvas; _canvas.SizeChanged += CanvasChangedHanler; _ellipseCreator = ellipseCreator; _polylineCreator = polylineCreator; _border = border; storage.CollectionChanged += StorageOnChangeHandler; storage.PointPropertyChanged += StorageOnChangeHandler; }
static Figure ReceiveMessage()//Give message { while (true) { try { byte[] data = new byte[64]; // буфер для получаемых данных StringBuilder builder = new StringBuilder(); int bytes = 0; do { bytes = stream.Read(data, 0, data.Length); builder.Append(Encoding.Unicode.GetString(data, 0, bytes)); } while (stream.DataAvailable); string message = builder.ToString(); string[] words = message.Split(new char[] { '/' }); Creator cr; if (words[0] == "Rectangle") { cr = new RectangleCreator(); } else { cr = new EllipseCreator(); } Figure fig = cr.Create(); fig.Move(Convert.ToInt32(words[1]), Convert.ToInt32(words[2])); byte a = 255; // or whatever... byte r = (byte)(Convert.ToUInt32(words[3].Substring(1, 2), 16)); byte g = (byte)(Convert.ToUInt32(words[3].Substring(3, 2), 16)); byte b = (byte)(Convert.ToUInt32(words[3].Substring(5, 2), 16)); fig.SetCol(Color.c(a,r,b,g); fig.Draw(g); lst.Add(figure); } catch { Console.WriteLine("Подключение прервано!"); //соединение было прервано Console.ReadLine(); Disconnect(); } } }
public NodeRender(NodeCollectionStorage <FullConnectedGraph> nodeCollectionStorage, Canvas canvas, EllipseCreator nodeEllipseCreator, EllipseCreator startNodeEllipseCreator, EllipseCreator endNodeEllipseCreator) { _canvas = canvas; _nodeEllipseCreator = nodeEllipseCreator; _startNodeEllipseCreator = startNodeEllipseCreator; _endNodeEllipseCreator = endNodeEllipseCreator; _canvas.MouseLeftButtonUp += Canvas_MouseLeftButtonUp; _nodeCollectionStorage = nodeCollectionStorage; _nodeCollectionStorage.CollectionChanged += NodeCollectionChangeHandler; _nodeCollectionStorage.PointPropertyChanged += PointPropertyChangedHandler; _nodeEllipseCreator.ContextMenu = NodeContextMenuCreator.NodeContextMenu(StartPointMenuItem_OnClick, EndPointMenuItem_OnClick, RemovePointMenuItem_OnClick); var startEndContextMenu = NodeContextMenuCreator.StartAndEndNodeContextMenu(RemoveStartOrEndPointMenuItem_OnClick); _endNodeEllipseCreator.ContextMenu = startEndContextMenu; _startNodeEllipseCreator.ContextMenu = startEndContextMenu; }
public string RenderingShapeTypeName() { return(EllipseCreator.getInstance().ShapeTypeName()); }
private Ellipse CreateEllipse(Point point, EllipseCreator creator) { return(creator.Create(point)); }