/// <summary> /// Overridden <see cref="PictureModifiable.ShapeAdded"/> event handler. /// Adds a shape name user dialog to the shape creation process. /// </summary> /// <param name="e"> /// The <see cref="ShapeEventArgs"/> with the new shape. /// </param> protected override void OnShapeAdded(ShapeEventArgs e) { // Show NameDialog if name is empty if (e.Shape.Name == string.Empty) { var newDlg = new NameShapeDlg(Document.ActiveDocument.SelectionState.TrialID); if (newDlg.ShowDialog() == DialogResult.OK) { // Set new shapes name e.Shape.Name = newDlg.ShapeName; // Save to aoi collection this.AoiCollection.Add(e.Shape); // Raise event base.OnShapeAdded(e); } else { this.Elements.Remove(e.Shape); this.DrawForeground(false); } } else { // Raise event base.OnShapeAdded(e); // Save to aoi collection this.AoiCollection.Add(e.Shape); } }
void ShapeFactory_OnShapeAdded(object sender, ShapeEventArgs e) { if (e.Shape is ClassShape) { InjectReflectedData(e.Shape as ClassShape); } }
protected override void OnShapeChanged(ShapeEventArgs e) { // Do any rectangle-specific processing here. // Call the base class event invocation method. base.OnShapeChanged(e); }
/////////////////////////////////////////////////////////////////////////////// // Eventhandler for Custom Defined Events // /////////////////////////////////////////////////////////////////////////////// #region CUSTOMEVENTHANDLER /// <summary> /// Raises the <see cref="CursorStyleChanged"/> event by invoking the delegates. /// </summary> /// <param name="e"><see cref="ShapeEventArgs"/> event arguments</param>. public void OnCursorStyleChanged(ShapeEventArgs e) { if (this.CursorStyleChanged != null) { this.CursorStyleChanged(this, e); } }
public void ShoulBeTheSameShapeInEventArgs() { var circle = new Circle(); var args = new ShapeEventArgs(circle); args.Shape.Should().Be(circle); }
public void OnShapeAdded(object sender, ShapeEventArgs args) { var viewModel = new ShapeListItemViewModel { Shape = args.Shape }; ShapeListItems.Add(viewModel); SelectedShapeListItemViewModel = viewModel; }
// ...Other methods to draw, resize, etc. private void HandleShapeChanged(object sender, ShapeEventArgs e) { Shape s = (Shape)sender; // Diagnostic message for demonstration purposes. Console.WriteLine("Received event. Shape area is now {0}", e.NewArea); // Redraw the shape here. s.Draw(); }
//The event-invoking method that derived classes can override. protected virtual void OnShapeChanged(ShapeEventArgs e) { // Make a temporary copy of the event to avoid possibility of // a race condition if the last subscriber unsubscribes // immediately after the null check and before the event is raised. EventHandler <ShapeEventArgs> handler = ShapeChanged; if (handler != null) { handler(this, e); } }
private void Controller_OnDraw(object sender, ShapeEventArgs e) { if (InvokeRequired) { Invoke((MethodInvoker)(() => Controller_OnDraw(sender, e))); return; } var graphic = CreateGraphics(); graphic.Clear(BackColor); graphic.Draw(e.Shape); }
/// <summary> /// Event handler. Invoked whenever new shape is added to shape repository /// </summary> /// <param name="sender"></param> /// <param name="args"></param> private void OnShapeAdded(object sender, ShapeEventArgs args) { Shapes.Add(args.Shape); SelectedShape = args.Shape; }
/// <summary> /// Wires the event from the underlying control to the listeners. /// </summary> /// <param name="sender">The source of the event.</param> /// <param name="e">A <see cref="ShapeEventArgs"/> with the new cursor.</param> private void cursorSelectControl_CursorStyleChanged(object sender, ShapeEventArgs e) { OnCursorStyleChanged(e); }