/*public Shape GenerateShape(ShapeName shapeName, Point location, BlockType blockType) { * Shape shapeToReturn = null; * switch (shapeName) { * case ShapeName.I: * shapeToReturn = new Shape_I(location, blockType); * break; * case ShapeName.J: * shapeToReturn = new Shape_J(location, blockType); * break; * case ShapeName.L: * shapeToReturn = new Shape_L(location, blockType); * break; * case ShapeName.O: * shapeToReturn = new Shape_O(location, blockType); * break; * case ShapeName.S: * shapeToReturn = new Shape_S(location, blockType); * break; * case ShapeName.T: * shapeToReturn = new Shape_T(location, blockType); * break; * case ShapeName.Z: * shapeToReturn = new Shape_Z(location, blockType); * break; * } * return shapeToReturn; * } * * public Shape GenerateShape(int shapeName, Point location, BlockType blockType) * { * return GenerateShape((ShapeName)shapeName, location, blockType); * }*/ public Shape GenerateShape(ShapeName shapeName, Point location, BlockType blockType) { Shape shapeToReturn = new Shape(location, blockType, shapeName); /*switch (shapeName) * { * case ShapeName.I: * shapeToReturn = new Shape(location, blockType, shapeName); * break; * case ShapeName.J: * shapeToReturn = new Shape_J(location, blockType); * break; * case ShapeName.L: * shapeToReturn = new Shape_L(location, blockType); * break; * case ShapeName.O: * shapeToReturn = new Shape_O(location, blockType); * break; * case ShapeName.S: * shapeToReturn = new Shape_S(location, blockType); * break; * case ShapeName.T: * shapeToReturn = new Shape_T(location, blockType); * break; * case ShapeName.Z: * shapeToReturn = new Shape_Z(location, blockType); * break; * }*/ return(shapeToReturn); }
public override void WriteGroupCodes() { WriteGroupCodeValue(10, X0.ToString().Trim()); WriteGroupCodeValue(20, Y0.ToString().Trim()); WriteGroupCodeValue(30, Z0.ToString().Trim()); WriteGroupCodeValue(40, Size.ToString().Trim()); WriteGroupCodeValue(2, ShapeName.Trim()); WriteGroupCodeValue(50, RotationAngle.ToString().Trim()); WriteGroupCodeValue(51, ObliqueAngle.ToString().Trim()); WriteGroupCodeValue(41, XScale.ToString().Trim()); }
//Create and add new objects according to their matching shape type private void AddShapeToList(ShapeName shapeName, string[] vals) { switch (shapeName) { case ShapeName.VERTEX: AddVertexToList(vals); break; case ShapeName.POLYGON: AddPolygonToList(vals); break; default: break; } }
public static Shape Manufacture(ShapeName sn) { Random random = new Random(); switch (sn) { case ShapeName.rectangle: return(new Rectangle(random)); case ShapeName.square: return(new Square(random)); case ShapeName.triangle: return(new Triangle(random)); default: return(null); } }
private void OnThemeStyleIdChanged() { var info = this.Info as INodeInfo; if (Constraints.Contains(NodeConstraints.ThemeStyle) && info != null && info.Graph.Theme != null) { if (!string.IsNullOrEmpty(ShapeName) && !ShapeName.Equals("Line")) { DiagramItemStyle style = info.Graph.Theme.GetNodeStyle(ThemeStyleId); if (style != null) { foreach (TextAnnotationViewModel annotaiton in (this.Annotations as AnnotationCollection)) { annotaiton.Foreground = style.Foreground; annotaiton.FontSize = (int)style.FontSize; annotaiton.FontFamily = style.FontFamily; } } } } }
/// <summary> /// Instantiates an instance of the Shape class from a location point, a color, and a BlockType enum. /// </summary> /// <param name="location">The location point where the shape is made.</param> /// <param name="color">The color of the shape.</param> /// <param name="blockType">The type of block.</param> //public Shape(Point location, Color color, int rotationIndex, BlockType blockType, ShapeName shapeName) public Shape(Point location, int rotationIndex, BlockType blockType, ShapeName shapeName) { //this.boundaries = boundaries; this.Location = location; //this.color = color; this.ShapeBlocks = new List <Block>(); this.blockType = blockType; this.shapeName = shapeName; this.rotationIndex = rotationIndex; /*block1 = new Block(location, Color.Blue, blockType); * block2 = new Block(location, Color.Blue, blockType); * block3 = new Block(location, Color.Blue, blockType); * block4 = new Block(location, Color.Blue, blockType); * ShapeBlocks.Add(block1); * ShapeBlocks.Add(block2); * ShapeBlocks.Add(block3); * ShapeBlocks.Add(block4);*/ shapeConstructor = new ShapeConstructor(this); shapeConstructor.FormShape(); ArrangeShape(rotationIndex); } // end constructor method Shape
protected override void OnPropertyChanged(string name) { base.OnPropertyChanged(name); switch (name) { case "ShapeStyle": DecodeStyle(this.ShapeStyle); break; case "Fill": ApplyStyle(); break; case "Stroke": ApplyStyle(); break; case "ThemeStyleId": if (!string.IsNullOrEmpty(ShapeName) && (ShapeName.Equals("Line") || ShapeName.Equals("Freehand"))) { TextAnnotationViewModel textAnnotaiton = Annotations != null ? (Annotations as AnnotationCollection)[0] as TextAnnotationViewModel : null; if (textAnnotaiton != null) { textAnnotaiton.Foreground = Brushes.Black; } } if (this.Info != null && (this.Info as INodeInfo).OutConnectors != null && (this.Info as INodeInfo).OutConnectors.Count() > 0) { Style connectorGeometryStyle = SetDefultConnectorGeometryStyle(); Style targetDecoratorStyle = SetDefaultTargetDecoratorStyle(); foreach (IConnector connector in (this.Info as INodeInfo).OutConnectors.ToList()) { connector.ConnectorGeometryStyle = connectorGeometryStyle; connector.TargetDecoratorStyle = targetDecoratorStyle; } } break; case "Children": Children.CollectionChanged += (s, e) => { if (Children.Count() > 0) { HasChidren = true; } else { HasChidren = false; } }; break; case "Annotations": if (Annotations != null) { if (Annotations != null) { if ((Annotations as AnnotationCollection).Count > 0) { if ((Annotations as AnnotationCollection)[0] is TextAnnotationViewModel) { TextAnnotationViewModel textAnnotation = (Annotations as AnnotationCollection)[0] as TextAnnotationViewModel; textAnnotation.PropertyChanged += Annotation_PropertyChanged; } } else { (Annotations as AnnotationCollection).CollectionChanged += (s, e) => { if (e.NewItems != null && e.NewItems[0] is TextAnnotationViewModel) { (e.NewItems[0] as TextAnnotationViewModel).EditTemplate = GetEditTemplate(); (e.NewItems[0] as TextAnnotationViewModel).PropertyChanged += Annotation_PropertyChanged; } }; } } } //if (Annotations != null && (Annotations as AnnotationCollection).Count > 0) //{ // if ((Annotations as AnnotationCollection)[0] is TextAnnotationViewModel) // { // TextAnnotationViewModel textAnnotation = (Annotations as AnnotationCollection)[0] as TextAnnotationViewModel; // textAnnotation.PropertyChanged += Annotation_PropertyChanged; // } //} break; case "ShapeName": TextAnnotationViewModel annotation = Annotations != null ? (Annotations as AnnotationCollection)[0] as TextAnnotationViewModel : null; if (!string.IsNullOrEmpty(ShapeName) && ShapeName.Equals("Line")) { Shape = null; ContentTemplate = GetLineTempalte(); Content = this; if (annotation != null) { annotation.TextVerticalAlignment = VerticalAlignment.Stretch; annotation.Foreground = Brushes.Black; } if (this.Ports != null) { if ((this.Info as INodeInfo).InConnectors != null && (this.Info as INodeInfo).InConnectors.Count() > 0) { foreach (IConnector connector in (this.Info as INodeInfo).InConnectors.ToList()) { if (this.RenderedDirection == RootChildDirection.Left) { connector.TargetPort = (this.Ports as ObservableCollection <IPort>)[3]; } else if (this.RenderedDirection == RootChildDirection.Right) { connector.TargetPort = (this.Ports as ObservableCollection <IPort>)[0]; } } } if ((this.Info as INodeInfo).OutConnectors != null && (this.Info as INodeInfo).OutConnectors.Count() > 0) { foreach (IConnector connector in (this.Info as INodeInfo).OutConnectors.ToList()) { if (this.RenderedDirection == RootChildDirection.Left) { connector.SourcePort = (this.Ports as ObservableCollection <IPort>)[0]; } else if (this.RenderedDirection == RootChildDirection.Right) { connector.SourcePort = (this.Ports as ObservableCollection <IPort>)[3]; } } } } } else { Shape = GetShapeData(ShapeName); ContentTemplate = null; Content = null; if (annotation != null) { annotation.TextVerticalAlignment = VerticalAlignment.Center; if (!string.IsNullOrEmpty(ShapeName) && ShapeName.Equals("Freehand")) { annotation.Foreground = Brushes.Black; } else { OnThemeStyleIdChanged(); } } if (!string.IsNullOrEmpty(ShapeName) && ShapeName.Equals("Wave")) { if (this.Ports != null && this.Info != null) { if ((this.Info as INodeInfo).InConnectors != null && (this.Info as INodeInfo).InConnectors.Count() > 0) { foreach (IConnector connector in (this.Info as INodeInfo).InConnectors.ToList()) { if (this.RenderedDirection == RootChildDirection.Left) { connector.TargetPort = (this.Ports as ObservableCollection <IPort>)[2]; } else if (this.RenderedDirection == RootChildDirection.Right) { connector.TargetPort = (this.Ports as ObservableCollection <IPort>)[1]; } } } if ((this.Info as INodeInfo).OutConnectors != null && (this.Info as INodeInfo).OutConnectors.Count() > 0) { foreach (IConnector connector in (this.Info as INodeInfo).OutConnectors.ToList()) { if (this.RenderedDirection == RootChildDirection.Left) { connector.SourcePort = (this.Ports as ObservableCollection <IPort>)[1]; } else { connector.SourcePort = (this.Ports as ObservableCollection <IPort>)[2]; } } } } } else { if (this.Info != null) { if ((this.Info as INodeInfo).InConnectors != null && (this.Info as INodeInfo).InConnectors.Count() > 0) { foreach (IConnector connector in (this.Info as INodeInfo).InConnectors.ToList()) { connector.TargetPort = null; } } if ((this.Info as INodeInfo).OutConnectors != null && (this.Info as INodeInfo).OutConnectors.Count() > 0) { foreach (IConnector connector in (this.Info as INodeInfo).OutConnectors.ToList()) { connector.SourcePort = null; } } } } } break; } }
public void CreateShape(ShapeName name) { Draw(0, new AnonymousClassShape1(this, name)); }
public AnonymousClassShape1(A enclosingInstance, ShapeName name) { this.enclosingInstance = enclosingInstance; this.name = name; }
protected override void Serialize(IDictionary <string, object> json) { var dataSource = DataSource.ToJson(); if (dataSource.Any()) { json["dataSource"] = dataSource; } if (Subdomains != null) { json["subdomains"] = Subdomains; } //>> Serialization if (Attribution.HasValue()) { json["attribution"] = Attribution; } if (AutoBind.HasValue) { json["autoBind"] = AutoBind; } if (Extent != null) { json["extent"] = Extent; } if (Key.HasValue()) { json["key"] = Key; } if (LocationField.HasValue()) { json["locationField"] = LocationField; } if (TitleField.HasValue()) { json["titleField"] = TitleField; } if (Opacity.HasValue()) { json["opacity"] = Opacity; } var style = Style.ToJson(); if (style.Any()) { json["style"] = style; } if (UrlTemplateId.HasValue()) { json["urlTemplate"] = UrlTemplateId; } if (Type.HasValue) { json["type"] = Type; } //<< Serialization var tooltip = Tooltip.ToJson(); if (tooltip.Any()) { json["tooltip"] = tooltip; } if (ShapeName.HasValue()) { json["shape"] = ShapeName; } else if (Shape.HasValue) { var shapeName = Shape.ToString(); json["shape"] = shapeName.ToLowerInvariant()[0] + shapeName.Substring(1); } }
} // end constructor method Shape public Shape(Point location, BlockType blockType, ShapeName shapeName) : this(location, 0, blockType, shapeName) { } // end constructor method Shape
public static ShapeTopography FromShapeName(ShapeName shapeName) { return(shapeMapping[shapeName]); }
void ReleaseDesignerOutlets() { if (GroupUngroupButton != null) { GroupUngroupButton.Dispose(); GroupUngroupButton = null; } if (RotationSlider != null) { RotationSlider.Dispose(); RotationSlider = null; } if (RotationValue != null) { RotationValue.Dispose(); RotationValue = null; } if (ShapeHeight != null) { ShapeHeight.Dispose(); ShapeHeight = null; } if (ShapeName != null) { ShapeName.Dispose(); ShapeName = null; } if (ShapeType != null) { ShapeType.Dispose(); ShapeType = null; } if (ShapeWidth != null) { ShapeWidth.Dispose(); ShapeWidth = null; } if (ShapeX != null) { ShapeX.Dispose(); ShapeX = null; } if (ShapeY != null) { ShapeY.Dispose(); ShapeY = null; } if (VisibleButton != null) { VisibleButton.Dispose(); VisibleButton = null; } if (EditButton != null) { EditButton.Dispose(); EditButton = null; } }
protected override void OnPropertyChanged(string name) { base.OnPropertyChanged(name); if (name.Equals("Annotations")) { //if (Annotations is List<IAnnotation> && (Annotations as AnnotationCollection).Count > 0 // && (Annotations as AnnotationCollection)[0] is TextAnnotationViewModel) //{ // TextAnnotationViewModel annotation = (Annotations as AnnotationCollection)[0] as TextAnnotationViewModel; // annotation.PropertyChanged += Annotation_PropertyChanged; //} if ((Annotations as List <IAnnotation>).Count > 0) { LabelVM annotation = (Annotations as List <IAnnotation>)[0] as LabelVM; annotation.PropertyChanged += Annotation_PropertyChanged; } } else if (name.Equals("ShapeName")) { LabelVM annotation = (Annotations as List <IAnnotation>)[0] as LabelVM; if (ShapeName.Equals("Line")) { Shape = null; ContentTemplate = App.Current.Resources["LineShapeTemplate"] as DataTemplate; Content = this; annotation.TextVerticalAlignment = VerticalAlignment.Stretch; annotation.LabelForeground = Brushes.Black; if (this.Ports != null) { if ((this.Info as INodeInfo).InConnectors != null && (this.Info as INodeInfo).InConnectors.Count() > 0) { foreach (IConnector connector in (this.Info as INodeInfo).InConnectors.ToList()) { if (this.Type.Contains("left")) { connector.TargetPort = (this.Ports as ObservableCollection <IPort>)[3]; } else if (this.Type.Contains("right")) { connector.TargetPort = (this.Ports as ObservableCollection <IPort>)[0]; } } } if ((this.Info as INodeInfo).OutConnectors != null && (this.Info as INodeInfo).OutConnectors.Count() > 0) { foreach (IConnector connector in (this.Info as INodeInfo).OutConnectors.ToList()) { if (this.Type.Contains("left")) { connector.SourcePort = (this.Ports as ObservableCollection <IPort>)[0]; } else if (this.Type.Contains("right")) { connector.SourcePort = (this.Ports as ObservableCollection <IPort>)[3]; } } } } } else { Shape = App.Current.Resources[ShapeName]; ContentTemplate = null; Content = null; annotation.TextVerticalAlignment = VerticalAlignment.Center; if (ShapeName.Equals("Freehand")) { annotation.LabelForeground = Brushes.Black; } else { OnThemeStyleIdChanged(); } if (ShapeName.Equals("Wave")) { if (this.Ports != null) { if ((this.Info as INodeInfo).InConnectors != null && (this.Info as INodeInfo).InConnectors.Count() > 0) { foreach (IConnector connector in (this.Info as INodeInfo).InConnectors.ToList()) { if (this.Type.Contains("left")) { connector.TargetPort = (this.Ports as ObservableCollection <IPort>)[2]; } else if (this.Type.Contains("right")) { connector.TargetPort = (this.Ports as ObservableCollection <IPort>)[1]; } } } if ((this.Info as INodeInfo).OutConnectors != null && (this.Info as INodeInfo).OutConnectors.Count() > 0) { foreach (IConnector connector in (this.Info as INodeInfo).OutConnectors.ToList()) { if (this.Type.Contains("left")) { connector.SourcePort = (this.Ports as ObservableCollection <IPort>)[1]; } else { connector.SourcePort = (this.Ports as ObservableCollection <IPort>)[2]; } } } } } else { if (this.Info != null) { if ((this.Info as INodeInfo).InConnectors != null && (this.Info as INodeInfo).InConnectors.Count() > 0) { foreach (IConnector connector in (this.Info as INodeInfo).InConnectors.ToList()) { connector.TargetPort = null; } } if ((this.Info as INodeInfo).OutConnectors != null && (this.Info as INodeInfo).OutConnectors.Count() > 0) { foreach (IConnector connector in (this.Info as INodeInfo).OutConnectors.ToList()) { connector.SourcePort = null; } } } } } } }