Changeset 7226 for trunk/sources
- Timestamp:
- 12/21/11 23:26:30 (13 years ago)
- Location:
- trunk/sources
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/sources/HeuristicLab.Operators.Views.GraphVisualization.Views/3.3/OperatorShape.cs
r7199 r7226 79 79 } 80 80 81 public string TypeName { get; set; }81 public string Subtitle { get; set; } 82 82 83 83 private IconMaterial iconMaterial; … … 218 218 g.SmoothingMode = SmoothingMode.HighQuality; 219 219 220 Pen pen = new Pen(lineColor, lineWidth); 221 222 SizeF titleSize = g.MeasureString(this.Title, ArtPalette.DefaultBoldFont, Rectangle.Width - 45); 223 titleSize.Height += 10; //add spacing 224 SizeF typeNameSize = g.MeasureString(this.TypeName, ArtPalette.DefaultFont, Rectangle.Width - 45); 225 typeNameSize.Height += 10; //add spacing 226 if (this.Title == this.TypeName) typeNameSize = new SizeF(0, 0); 227 228 if (titleSize.Height + typeNameSize.Height > Rectangle.Height) { 229 headerHeight = (int)titleSize.Height + (int)typeNameSize.Height; 230 this.UpdateLabels(); 231 } 232 233 GraphicsPath path = new GraphicsPath(); 234 path.AddArc(Rectangle.X, Rectangle.Y, 20, 20, -180, 90); 235 path.AddLine(Rectangle.X + 10, Rectangle.Y, Rectangle.X + Rectangle.Width - 10, Rectangle.Y); 236 path.AddArc(Rectangle.X + Rectangle.Width - 20, Rectangle.Y, 20, 20, -90, 90); 237 path.AddLine(Rectangle.X + Rectangle.Width, Rectangle.Y + 10, Rectangle.X + Rectangle.Width, Rectangle.Y + Rectangle.Height - 10); 238 path.AddArc(Rectangle.X + Rectangle.Width - 20, Rectangle.Y + Rectangle.Height - 20, 20, 20, 0, 90); 239 path.AddLine(Rectangle.X + Rectangle.Width - 10, Rectangle.Y + Rectangle.Height, Rectangle.X + 10, Rectangle.Y + Rectangle.Height); 240 path.AddArc(Rectangle.X, Rectangle.Y + Rectangle.Height - 20, 20, 20, 90, 90); 241 path.AddLine(Rectangle.X, Rectangle.Y + Rectangle.Height - 10, Rectangle.X, Rectangle.Y + 10); 242 //shadow 243 if (ArtPalette.EnableShadows) { 244 Region darkRegion = new Region(path); 245 darkRegion.Translate(5, 5); 246 g.FillRegion(ArtPalette.ShadowBrush, darkRegion); 247 } 248 //background 249 g.FillPath(Brush, path); 250 251 using (LinearGradientBrush gradientBrush = new LinearGradientBrush(Rectangle.Location, new Point(Rectangle.X + Rectangle.Width, Rectangle.Y), this.Color, Color.White)) { 252 Region gradientRegion = new Region(path); 253 g.FillRegion(gradientBrush, gradientRegion); 254 } 255 256 if (!this.Collapsed) { 257 TextStyle textStyle = new TextStyle(Color.Black, new Font("Arial", 7), StringAlignment.Near, StringAlignment.Near); 258 StringFormat stringFormat = textStyle.StringFormat; 259 stringFormat.Trimming = StringTrimming.EllipsisWord; 260 stringFormat.FormatFlags = StringFormatFlags.LineLimit; 261 Rectangle rect; 262 263 for (int i = 0; i < this.labels.Count; i++) { 264 rect = new Rectangle(Rectangle.X + 25, Rectangle.Y + headerHeight + i * (LABEL_HEIGHT + LABEL_SPACING), LABEL_WIDTH, LABEL_HEIGHT); 265 g.DrawString(textStyle.GetFormattedText(this.labels[i]), textStyle.Font, textStyle.GetBrush(), rect, stringFormat); 266 } 267 } 268 269 //the border 270 g.DrawPath(pen, path); 271 272 //the title 273 g.DrawString(this.Title, ArtPalette.DefaultBoldFont, Brushes.Black, 274 new Rectangle(Rectangle.X + 25, Rectangle.Y + 5, 275 Rectangle.Width - 45, Rectangle.Height - 5 - (int)typeNameSize.Height)); 276 277 //the typeName 278 if (this.Title != this.TypeName) { 279 g.DrawString(this.TypeName, ArtPalette.DefaultFont, Brushes.Black, 280 new Rectangle(Rectangle.X + 25, Rectangle.Y + (int)titleSize.Height, 281 Rectangle.Width - 45, Rectangle.Height - 5)); 282 } 283 284 285 //the material 286 foreach (IPaintable material in Children) 287 material.Paint(g); 288 289 //the connectors 290 if (this.ShowConnectors) { 291 for (int k = 0; k < Connectors.Count; k++) 292 Connectors[k].Paint(g); 220 using (Pen pen = new Pen(lineColor, lineWidth)) { 221 222 SizeF titleSize = g.MeasureString(this.Title, ArtPalette.DefaultBoldFont, Rectangle.Width - 45); 223 titleSize.Height += 10; //add spacing 224 SizeF subtitleSize = g.MeasureString(this.Subtitle, ArtPalette.DefaultFont, Rectangle.Width - 45); 225 subtitleSize.Height += 5; //add spacing 226 if (this.Title == this.Subtitle || string.IsNullOrEmpty(this.Subtitle)) subtitleSize = new SizeF(0, 0); 227 228 if ((int)titleSize.Height + (int)subtitleSize.Height != Rectangle.Height) { 229 headerHeight = (int)titleSize.Height + (int)subtitleSize.Height; 230 this.UpdateLabels(); 231 } 232 233 GraphicsPath path = new GraphicsPath(); 234 path.AddArc(Rectangle.X, Rectangle.Y, 20, 20, -180, 90); 235 path.AddLine(Rectangle.X + 10, Rectangle.Y, Rectangle.X + Rectangle.Width - 10, Rectangle.Y); 236 path.AddArc(Rectangle.X + Rectangle.Width - 20, Rectangle.Y, 20, 20, -90, 90); 237 path.AddLine(Rectangle.X + Rectangle.Width, Rectangle.Y + 10, Rectangle.X + Rectangle.Width, Rectangle.Y + Rectangle.Height - 10); 238 path.AddArc(Rectangle.X + Rectangle.Width - 20, Rectangle.Y + Rectangle.Height - 20, 20, 20, 0, 90); 239 path.AddLine(Rectangle.X + Rectangle.Width - 10, Rectangle.Y + Rectangle.Height, Rectangle.X + 10, Rectangle.Y + Rectangle.Height); 240 path.AddArc(Rectangle.X, Rectangle.Y + Rectangle.Height - 20, 20, 20, 90, 90); 241 path.AddLine(Rectangle.X, Rectangle.Y + Rectangle.Height - 10, Rectangle.X, Rectangle.Y + 10); 242 //shadow 243 if (ArtPalette.EnableShadows) { 244 Region darkRegion = new Region(path); 245 darkRegion.Translate(5, 5); 246 g.FillRegion(ArtPalette.ShadowBrush, darkRegion); 247 } 248 //background 249 g.FillPath(Brush, path); 250 251 using (LinearGradientBrush gradientBrush = new LinearGradientBrush(Rectangle.Location, new Point(Rectangle.X + Rectangle.Width, Rectangle.Y), this.Color, Color.White)) { 252 Region gradientRegion = new Region(path); 253 g.FillRegion(gradientBrush, gradientRegion); 254 } 255 256 if (!this.Collapsed) { 257 TextStyle textStyle = new TextStyle(Color.Black, new Font("Arial", 7), StringAlignment.Near, StringAlignment.Near); 258 StringFormat stringFormat = textStyle.StringFormat; 259 stringFormat.Trimming = StringTrimming.EllipsisWord; 260 stringFormat.FormatFlags = StringFormatFlags.LineLimit; 261 Rectangle rect; 262 263 const int verticalHeaderSpacing = 5; 264 Point separationLineStart = new Point(Rectangle.X + 25, Rectangle.Y + headerHeight - verticalHeaderSpacing); 265 Point separationLineEnd = new Point(Rectangle.X + Rectangle.Width - 25, Rectangle.Y + headerHeight - verticalHeaderSpacing); 266 using (LinearGradientBrush brush = new LinearGradientBrush(separationLineStart, separationLineEnd, Color.Black, Color.White)) { 267 using (Pen separationLinePen = new Pen(brush)) { 268 g.DrawLine(separationLinePen, separationLineStart, separationLineEnd); 269 } 270 } 271 272 273 for (int i = 0; i < this.labels.Count; i++) { 274 rect = new Rectangle(Rectangle.X + 25, Rectangle.Y + headerHeight + i * (LABEL_HEIGHT + LABEL_SPACING), LABEL_WIDTH, LABEL_HEIGHT); 275 g.DrawString(textStyle.GetFormattedText(this.labels[i]), textStyle.Font, textStyle.GetBrush(), rect, stringFormat); 276 } 277 } 278 279 //the border 280 g.DrawPath(pen, path); 281 282 //the title 283 g.DrawString(this.Title, ArtPalette.DefaultBoldFont, Brushes.Black, 284 new Rectangle(Rectangle.X + 25, Rectangle.Y + 5, 285 Rectangle.Width - 45, Rectangle.Height - 5 - (int)subtitleSize.Height)); 286 287 //the subtitle 288 if (this.Title != this.Subtitle || string.IsNullOrEmpty(this.Subtitle)) { 289 g.DrawString(this.Subtitle, ArtPalette.DefaultFont, Brushes.Black, 290 new Rectangle(Rectangle.X + 25, Rectangle.Y + (int)titleSize.Height -5 , 291 Rectangle.Width - 45, Rectangle.Height - 5)); 292 } 293 294 295 //the material 296 foreach (IShapeMaterial material in Children) 297 material.Paint(g); 298 299 //the connectors 300 if (this.ShowConnectors) { 301 foreach (IConnector t in Connectors) 302 t.Paint(g); 303 } 293 304 } 294 305 } -
trunk/sources/HeuristicLab.Operators.Views.GraphVisualization.Views/3.3/ShapeInfoExtensions.cs
r7199 r7226 50 50 shape.Location = shapeInfo.Location; 51 51 shape.Title = shapeInfo.Title; 52 shape. TypeName = shapeInfo.TypeName;52 shape.Subtitle = shapeInfo.TypeName; 53 53 shape.Color = shapeInfo.Color; 54 54 shape.LineColor = shapeInfo.LineColor; … … 66 66 public static void UpdateShape(IOperatorShapeInfo operatorShapeInfo, OperatorShape operatorShape) { 67 67 operatorShape.Title = operatorShapeInfo.Title; 68 operatorShape. TypeName = operatorShapeInfo.TypeName;68 operatorShape.Subtitle = operatorShapeInfo.TypeName; 69 69 operatorShape.Color = operatorShapeInfo.Color; 70 70 operatorShape.LineColor = operatorShapeInfo.LineColor; … … 107 107 public static void UpdateShapeInfo(IOperatorShapeInfo operatorShapeInfo, OperatorShape operatorShape) { 108 108 operatorShapeInfo.Title = operatorShape.Title; 109 operatorShapeInfo.TypeName = operatorShape. TypeName;109 operatorShapeInfo.TypeName = operatorShape.Subtitle; 110 110 operatorShapeInfo.Color = operatorShape.Color; 111 111 operatorShapeInfo.LineColor = operatorShape.LineColor; -
trunk/sources/HeuristicLab.Operators.Views.GraphVisualization/3.3/OperatorGraphVisualization/OperatorGraphVisualizationInfo.cs
r6572 r7226 121 121 } 122 122 } 123 124 foreach (IOperatorShapeInfo shapeInfo2 in this.operatorShapeInfoMapping.SecondValues) 125 if (string.IsNullOrEmpty(shapeInfo2.TypeName)) shapeInfo2.TypeName = this.operatorShapeInfoMapping.GetBySecond(shapeInfo2).GetType().GetPrettyName(); 123 126 } 124 127 -
trunk/sources/HeuristicLab.Operators.Views.GraphVisualization/3.3/OperatorGraphVisualization/OperatorShapeInfo.cs
r7199 r7226 38 38 [StorableConstructor] 39 39 protected OperatorShapeInfo(bool deserializing) : base(deserializing) { } 40 [StorableHook(HookType.AfterDeserialization)] 41 private void AfterDeserialization() { 42 if (string.IsNullOrEmpty(this.typeName)) 43 typeName = title; 44 } 40 45 41 protected OperatorShapeInfo(OperatorShapeInfo original, Cloner cloner) 46 42 : base(original, cloner) {
Note: See TracChangeset
for help on using the changeset viewer.