I have tried many times. What is puzzling is that once the program is run, it then returns immediately after entering diagram_DrawForeground and does not respond to the diagram_NodeModifying event.. May I ask Lyubo, can you tell me your email account? I want to send you the project I'm working on now, help me see where it's done wrong, and wonder why I didn't make the diagram semi-transparent. private void diagram_DrawForeground(object sender, DiagramEventArgs e) { if (overlayNode == null) // overlayNode is the smaller node in the diagram return; var graphics = e.Graphics; var clip = new CombinedGeometry( GeometryCombineMode.Exclude, new RectangleGeometry(diagram.Bounds), new RectangleGeometry(overlayNode.Bounds));
graphics.PushClip(clip); graphics.DrawRectangle(new SolidColorBrush(Color.FromArgb(120, 200, 200, 200)), null, diagram.Bounds); graphics.Pop(); }
private void diagram_NodeModifying(object sender, NodeValidationEventArgs e) { diagram.InvalidateForeground(); }
//private void diagram_DrawNode(object sender, DrawNodeEventArgs e) //{ // if (e.Node != imageNode) // return;
// var graphics = e.Graphics; // var clip = new CombinedGeometry( // GeometryCombineMode.Exclude, // new RectangleGeometry(imageNode.Bounds), // new RectangleGeometry(overlayNode.Bounds)); // var translate = new TranslateTransform(-imageNode.Bounds.X, -imageNode.Bounds.Y); // graphics.PushTransform(translate); // graphics.PushClip(clip); // graphics.DrawRectangle(new SolidColorBrush(Color.FromArgb(120, 0, 0, 0)), null, imageNode.Bounds); // graphics.Pop(); // graphics.Pop(); //}
|