public List <Polygon> GetPolygonsObjects(int layerId) { var polygonList = new List <Polygon>(); DataRow[] plgnObjects = LayersObjectsDataTable.Select("LayerID=" + layerId + " AND ObjectTypeID = 2 AND IsEnabled='True'"); if (plgnObjects.Length == 0) { return(polygonList); } foreach (DataRow plgnObj in plgnObjects) { int objectId = Convert.ToInt32(plgnObj["ObjectID"]); bool isVisible = Convert.ToBoolean(plgnObj["IsVisible"]); string colorObjStr = plgnObj["Color"].ToString(); var colorObj = (Brush) new BrushConverter().ConvertFrom(colorObjStr); var objInfo = new ObjectInfo { LayerId = layerId, ObjectId = objectId, ObjectName = plgnObj["Name"].ToString(), Color = colorObj }; DataRow[] plgnDataRows = PolygonsDataTable.Select("ObjectID=" + objectId); bool isFill = Convert.ToBoolean(plgnDataRows[0]["IsFill"]); var plgn = new Polygon { StrokeThickness = 0.3, Tag = objInfo, Stroke = colorObj, Visibility = isVisible ? Visibility.Visible : Visibility.Hidden, }; if (isFill) { var fillColor = (Brush) new BrushConverter().ConvertFrom(colorObjStr); fillColor.Opacity = 0.1; plgn.Fill = fillColor; } PointCollection pc; var serializer = new XmlSerializer(typeof(PointCollection)); using (var ms = new MemoryStream((Byte[])plgnDataRows[0]["Points"])) { pc = (PointCollection)serializer.Deserialize(ms); } plgn.Points = pc; polygonList.Add(plgn); } return(polygonList); }
public List <Border> GetBordersObjects(int layerId) { var brdList = new List <Border>(); var xPosBinding = new Binding("Xpos") { Mode = BindingMode.TwoWay }; var yPosBinding = new Binding("Ypos") { Mode = BindingMode.TwoWay }; var visBinding = new Binding("IsVisible") { Mode = BindingMode.TwoWay, Converter = new BooleanToVisibilityConverter() }; DataRow[] brdObjects = LayersObjectsDataTable.Select("LayerID=" + layerId + " AND ObjectTypeID = 1 AND IsEnabled='True'"); if (brdObjects.Length == 0) { return(brdList); } foreach (DataRow brdObj in brdObjects) { int objectId = Convert.ToInt32(brdObj["ObjectID"]); bool isVisible = Convert.ToBoolean(brdObj["IsVisible"]); var color = (Brush) new BrushConverter().ConvertFrom(brdObj["Color"].ToString()); color.Opacity = 0.9; RectanglesDataTable.DefaultView.RowFilter = "ObjectID=" + objectId; double width = Convert.ToDouble(RectanglesDataTable.DefaultView[0]["Width"]); double height = Convert.ToDouble(RectanglesDataTable.DefaultView[0]["Height"]); var objInfo = new ObjectInfo { ObjectId = objectId, ObjectName = brdObj["Name"].ToString(), Color = color, LayerId = layerId, Width = width / ScaleVar, Height = height / ScaleVar }; var brd = new Border { Tag = objInfo, Width = width, Height = height, BorderBrush = color, Background = color, BorderThickness = new Thickness(0.3), CornerRadius = new CornerRadius(0.05), DataContext = RectanglesDataTable.DefaultView[0], Visibility = isVisible ? Visibility.Visible : Visibility.Hidden, }; brd.SetBinding(UIElement.VisibilityProperty, visBinding); brd.SetBinding(Canvas.TopProperty, yPosBinding); brd.SetBinding(Canvas.LeftProperty, xPosBinding); brdList.Add(brd); } return(brdList); }