/// <summary> /// Binds the adapter to the adaptable control. Called in the order that the adapters /// were defined on the control.</summary> /// <param name="control">Adaptable control. Must be a D2dAdaptableControl.</param> protected override void Bind(AdaptableControl control) { m_transformAdapter = control.As<ITransformAdapter>(); m_autoTranslateAdapter = control.As<IAutoTranslateAdapter>(); base.Bind(control); }
/// <summary> /// Binds the adapter to the adaptable control; called in the order that the adapters /// were defined on the control.</summary> /// <param name="control">Adaptable control</param> protected override void Bind(AdaptableControl control) { m_autoTranslateAdapter = control.As <IAutoTranslateAdapter>(); m_selectionPathProvider = control.As <ISelectionPathProvider>(); control.ContextChanged += control_ContextChanged; control.MouseMove += control_MouseMove; control.MouseUp += control_MouseUp; base.Bind(control); }
public Color SelectionFillColor = Color.FromArgb(64, Color.DodgerBlue);//25% opaque /// <summary> /// Binds the adapter to the adaptable control. Called in the order that the adapters /// were defined on the control.</summary> /// <param name="control">Adaptable control. Must be a D2dAdaptableControl.</param> protected override void Bind(AdaptableControl control) { m_transformAdapter = control.As<ITransformAdapter>(); var d2dControl = (D2dAdaptableControl)control; d2dControl.DrawingD2d += control_DrawingD2d; base.Bind(control); }
/// <summary> /// Binds the adapter to the adaptable control; called in the order that the adapters /// were defined on the control.</summary> /// <param name="control">Adaptable control</param> protected override void Bind(AdaptableControl control) { m_autoTranslateAdapter = control.As <IAutoTranslateAdapter>(); control.ContextChanged += new EventHandler(control_ContextChanged); control.Paint += new PaintEventHandler(control_Paint); base.Bind(control); }
/// <summary> /// Binds the adapter to the adaptable control; called in the order that the adapters /// were defined on the control</summary> /// <param name="control">Adaptable control</param> protected override void Bind(AdaptableControl control) { base.Bind(control); control.ContextChanged += control_ContextChanged; control.PreviewKeyDown += PreviewKeyDown; m_pickingAdapter = control.Cast <IPickingAdapter2>(); m_transformAdapter = control.As <ITransformAdapter>(); //optional }
/// <summary> /// Binds the adapter to the adaptable control; called in the order that the adapters /// were defined on the control.</summary> /// <param name="control">Adaptable control</param> protected override void Bind(AdaptableControl control) { m_autoTranslateAdapter = control.As <IAutoTranslateAdapter>(); control.ContextChanged += control_ContextChanged; control.Paint += control_Paint; base.Bind(control); }
/// <summary> /// Binds the adapter to the adaptable control. Called in the order that the adapters /// were defined on the control.</summary> /// <param name="control">Adaptable control</param> protected override void Bind(AdaptableControl control) { var d2dControl = (D2dAdaptableControl)control; m_transformAdapter = control.As <ITransformAdapter>(); d2dControl.DrawingD2d += PaintD2d; d2dControl.MouseWheel += control_MouseWheel; base.Bind(control); }
/// <summary> /// Binds the adapter to the adaptable control; called in the order that the adapters /// were defined on the control</summary> /// <param name="control">Adaptable control</param> protected override void Bind(AdaptableControl control) { m_autoTranslateAdapter = control.As <IAutoTranslateAdapter>(); var d2dControl = control as D2dAdaptableControl; d2dControl.ContextChanged += control_ContextChanged; d2dControl.DrawingD2d += control_Paint; base.Bind(control); }
/// <summary> /// Binds the adapter to the adaptable control. Called in the order that the adapters /// were defined on the control.</summary> /// <param name="control">Adaptable control</param> protected override void Bind(AdaptableControl control) { m_autoTranslateAdapter = control.As<IAutoTranslateAdapter>(); control.ContextChanged += control_ContextChanged; var d2dControl = control as D2dAdaptableControl; if (d2dControl != null) d2dControl.DrawingD2d += d2dControl_DrawingD2d; else control.Paint += control_Paint; base.Bind(control); }
/// <summary> /// Inserts object into statechart at the center of the canvas or last selected state if there was one</summary> /// <param name="insertingObject">Object to insert</param> public void Insert(object insertingObject) { Statechart insertionPoint = m_statechart; // default is root statechart AdaptableControl control = m_viewingContext.Control; DragDropAdapter dragDropAdapter = control.As <DragDropAdapter>(); Matrix transform = control.As <ITransformAdapter>().Transform; Point center; // in world coordinates if (dragDropAdapter != null && dragDropAdapter.IsDropping) { insertionPoint = FindStatechartUnder(dragDropAdapter.MousePosition); center = GdiUtil.InverseTransform(transform, dragDropAdapter.MousePosition); } else // paste into last selected state { State state = Selection.GetLastSelected <State>(); if (state != null) { insertionPoint = GetStatechart(state); Rectangle stateBounds = m_viewingContext.GetBounds(state); center = new Point( stateBounds.X + stateBounds.Width / 2, stateBounds.Y + stateBounds.Height / 2); center = GdiUtil.InverseTransform(transform, center); } else { center = GdiUtil.InverseTransform(transform, new Point( control.Width / 2, control.Height / 2)); } } Insert(insertingObject, center, insertionPoint); }
/// <summary> /// Binds the adapter to the adaptable control. Called in the order that the adapters /// were defined on the control</summary> /// <param name="control">Adaptable control</param> protected override void Bind(AdaptableControl control) { // get picking adapters in reverse order on the control m_pickingAdapters = control.AsAll<IPickingAdapter>().ToArray(); Array.Reverse(m_pickingAdapters); m_pickingAdapters2 = control.AsAll<IPickingAdapter2>().ToArray(); Array.Reverse(m_pickingAdapters2); m_dragSelector = control.As<IDragSelector>(); if (m_dragSelector != null) m_dragSelector.Selected += dragSelector_Selected; control.ContextChanged += control_ContextChanged; }
/// <summary> /// Binds the adapter to the adaptable control; called in the order that the adapters /// were defined on the control</summary> /// <param name="control">Adaptable control</param> protected override void Bind(AdaptableControl control) { if (m_d2dControl != null) { throw new InvalidOperationException("We can only bind to one D2dAdaptableControl at a time"); } m_d2dControl = (D2dAdaptableControl)control; m_d2dGraphics = m_d2dControl.D2dGraphics; m_d2dControl.ContextChanged += control_ContextChanged; m_d2dControl.DrawingD2d += control_Paint; m_d2dControl.MouseDown += d2dControl_MouseDown; m_d2dControl.MouseMove += d2dControl_MouseMove; m_d2dControl.MouseLeave += d2dControl_MouseLeave; m_selectionPathProvider = control.As <ISelectionPathProvider>(); }
private Statechart FindStatechartUnder(Point clientPoint) { AdaptableControl control = m_viewingContext.Control; GraphHitRecord <StateBase, Transition, BoundaryRoute> hitRecord = control.As <D2dGraphAdapter <StateBase, Transition, BoundaryRoute> >().Pick(clientPoint); if (hitRecord.Node != null) { State hitState = hitRecord.Node as State; if (hitState != null) { return(GetStatechart(hitState)); } } // default to root statechart return(m_statechart); }
private void ZoomView(PointF newScale, AdaptableControl adaptableControl) { Point clientPoint = adaptableControl.PointToClient(Cursor.Position); if (!adaptableControl.ClientRectangle.Contains(clientPoint)) { clientPoint = new Point(adaptableControl.Width / 2, adaptableControl.Height / 2); // use control center } var transformAdapter = adaptableControl.As <ITransformAdapter>(); Point anchorPoint = GdiUtil.InverseTransform(transformAdapter.Transform, clientPoint); PointF scale = transformAdapter.ConstrainScale(newScale); var translation = new PointF( (transformAdapter.Scale.X - scale.X) * anchorPoint.X + transformAdapter.Translation.X, (transformAdapter.Scale.Y - scale.Y) * anchorPoint.Y + transformAdapter.Translation.Y); transformAdapter.SetTransform(scale.X, scale.Y, translation.X, translation.Y); }
/// <summary> /// Binds the adapter to the adaptable control. Called in the order that the adapters /// were defined on the control.</summary> /// <param name="control">Adaptable control</param> protected override void Bind(AdaptableControl control) { m_transformAdapter = control.As<ITransformAdapter>(); m_autoTranslateAdapter = control.As<IAutoTranslateAdapter>(); var d2dControl = control as D2dAdaptableControl; d2dControl.ContextChanged += control_ContextChanged; d2dControl.DrawingD2d += control_Paint; d2dControl.KeyPress += control_KeyPress; d2dControl.PreviewKeyDown += control_PreviewKeyDown; d2dControl.GotFocus += control_GotFocus; d2dControl.LostFocus += control_LostFocus; d2dControl.DoubleClick += control_DoubleClick; base.Bind(control); }
private void ZoomView(PointF newScale, AdaptableControl adaptableControl) { Point clientPoint = adaptableControl.PointToClient(Cursor.Position); if (!adaptableControl.ClientRectangle.Contains(clientPoint)) clientPoint = new Point(adaptableControl.Width/2, adaptableControl.Height/2); // use control center var transformAdapter = adaptableControl.As<ITransformAdapter>(); Point anchorPoint = GdiUtil.InverseTransform(transformAdapter.Transform, clientPoint); PointF scale = transformAdapter.ConstrainScale(newScale); var translation = new PointF( (transformAdapter.Scale.X - scale.X) * anchorPoint.X + transformAdapter.Translation.X, (transformAdapter.Scale.Y - scale.Y) * anchorPoint.Y + transformAdapter.Translation.Y); transformAdapter.SetTransform(scale.X, scale.Y, translation.X, translation.Y); }
/// <summary> /// Binds the adapter to the adaptable control. Called in the order that the adapters /// were defined on the control.</summary> /// <param name="control">Adaptable control</param> protected override void Bind(AdaptableControl control) { m_transformAdapter = control.As<ITransformAdapter>(); m_autoTranslateAdapter = control.As<IAutoTranslateAdapter>(); m_pickingAdapters = control.AsAll<IPickingAdapter2>().ToArray(); Array.Reverse(m_pickingAdapters); var d2dControl = control as D2dAdaptableControl; d2dControl.ContextChanged += control_ContextChanged; d2dControl.DrawingD2d += control_Paint; d2dControl.KeyPress += control_KeyPress; d2dControl.PreviewKeyDown += control_PreviewKeyDown; d2dControl.GotFocus += control_GotFocus; d2dControl.LostFocus += control_LostFocus; base.Bind(control); }
private void control_DoubleClick(object sender, EventArgs e) { AdaptableControl d2dHoverControl = (AdaptableControl)sender; Point clientPoint = d2dHoverControl.PointToClient(Control.MousePosition); D2dGraphAdapter <Module, Connection, ICircuitPin> graphAdapter = d2dHoverControl.As <D2dGraphAdapter <Module, Connection, ICircuitPin> >(); GraphHitRecord <Module, Connection, ICircuitPin> hitRecord = graphAdapter.Pick(clientPoint); Group subGraph = null; var subGraphReference = hitRecord.Node.As <GroupReference>(); if (subGraphReference != null) { var templatingContext = m_contextRegistry.GetMostRecentContext <TemplatingContext>(); if (templatingContext != null && templatingContext.IsExternalTemplate(subGraphReference.Template)) { return; // templates should only be editable in the document that owns the template } DialogResult checkResult = DialogResult.No; //direct editing if (checkResult == DialogResult.No) { subGraph = subGraphReference.Group.As <Group>(); var graphValidator = subGraphReference.DomNode.GetRoot().Cast <CircuitValidator>(); graphValidator.UpdateTemplateInfo(subGraph); } } else { subGraph = hitRecord.Node.As <Group>(); } if (subGraph != null) { var viewingContext = subGraph.Cast <ViewingContext>(); if (viewingContext.Control != null) { // sub-graph is already open, just show control m_controlHostService.Show(viewingContext.Control); } else { // create new circuit editing control for sub-circuit AdaptableControl subCircuitControl = CreateCircuitControl(subGraph.DomNode); viewingContext.Control = subCircuitControl; // use group’s hierarchy as control name string name = string.Empty; bool first = true; foreach (var domNode in subGraph.DomNode.GetPath()) { if (domNode.Is <Group>()) { if (first) { name = domNode.Cast <Group>().Name; first = false; } else { name += "/" + domNode.Cast <Group>().Name; } } } string description = name; var editingContext = subGraph.DomNode.Cast <CircuitEditingContext>(); editingContext.GetLocalBound = GetLocalBound; editingContext.GetWorldOffset = GetWorldOffset; editingContext.GetTitleHeight = GetTitleHeight; editingContext.GetLabelHeight = GetLabelHeight; editingContext.GetSubContentOffset = GetSubContentOffset; subCircuitControl.Context = editingContext; editingContext.SchemaLoader = m_schemaLoader; // schema needed for cut and paste between applications ControlInfo controlInfo = new ControlInfo(name, description, StandardControlGroup.Center); //controlInfo.Docking = new ControlInfo.DockingInfo() // smart docking behavior //{ // GroupTag = subGraph.DomNode.Lineage.AsIEnumerable<Group>().Last(),// use the top-level parent group // Order = subGraph.Level //}; m_circuitControlRegistry.RegisterControl(subGraph.DomNode, subCircuitControl, controlInfo, this); var enumerableContext = subGraph.DomNode.Cast <CircuitEditingContext>().Cast <IEnumerableContext>(); var items = (enumerableContext != null) ? enumerableContext.Items : null; subCircuitControl.As <IViewingContext>().Frame(items); } } }
/// <summary> /// Binds the adapter to the adaptable control; called in the order that the adapters /// were defined on the control</summary> /// <param name="control">Adaptable control</param> protected override void Bind(AdaptableControl control) { m_transformAdapter = control.As<ITransformAdapter>(); m_autoTranslateAdapter = control.As<IAutoTranslateAdapter>(); control.ContextChanged += control_ContextChanged; control.Paint += control_Paint; base.Bind(control); }
/// <summary> /// Binds the adapter to the adaptable control. Called in the order that the adapters /// were defined on the control.</summary> /// <param name="control">Adaptable control</param> protected override void Bind(AdaptableControl control) { m_transformAdapter = control.As<ITransformAdapter>(); m_selectionAdapter = control.As<ISelectionAdapter>(); if (m_selectionAdapter != null) m_selectionAdapter.SelectedItemHit += selectionAdapter_SelectedItemHit; control.ContextChanged += control_ContextChanged; control.Invalidated += control_Invalidated; control.KeyDown += control_KeyDown; control.Controls.Add(m_textBox); }
/// <summary> /// Binds the adapter to the adaptable control; called in the order that the adapters /// were defined on the control</summary> /// <param name="control">Adaptable control</param> protected override void Bind(AdaptableControl control) { m_transformAdapter = control.As<ITransformAdapter>(); SetGridColor(); if (control is D2dAdaptableControl) { var d2dControl = control as D2dAdaptableControl; d2dControl.DrawingD2d += control_DrawingD2d; } else control.Paint += control_Paint; control.BackColorChanged += control_BackColorChanged; }
/// <summary> /// Binds the adapter to the adaptable control. Called in the order that the adapters /// were defined on the control.</summary> /// <param name="control">Adaptable control</param> protected override void Bind(AdaptableControl control) { var d2dControl = (D2dAdaptableControl)control; m_transformAdapter = control.As<ITransformAdapter>(); d2dControl.DrawingD2d += PaintD2d; d2dControl.MouseWheel += control_MouseWheel; base.Bind(control); }
/// <summary> /// Binds the adapter to the adaptable control; called in the order that the adapters /// were defined on the control</summary> /// <param name="control">Adaptable control</param> protected override void Bind(AdaptableControl control) { m_transformAdapter = control.As<ITransformAdapter>(); control.Controls.Add(m_columnHeaders); m_columnHeaders.Height = control.Font.Height; control.ContextChanged += new EventHandler(control_ContextChanged); control.FontChanged += new EventHandler(control_FontChanged); }
/// <summary> /// Binds the adapter to the adaptable control. Called in the order that the adapters /// were defined on the control.</summary> /// <param name="control">Adaptable control</param> protected override void Bind(AdaptableControl control) { m_windowBounds = control.ClientRectangle; m_transformAdapter = control.As<ITransformAdapter>(); if (m_transformAdapter != null) m_transformAdapter.TransformChanged += transformAdapter_TransformChanged; control.ClientSizeChanged += control_ClientSizeChanged; }
/// <summary> /// Binds the adapter to the adaptable control. Called in the order that the adapters /// were defined on the control.</summary> /// <param name="control">Adaptable control</param> protected override void Bind(AdaptableControl control) { m_transformAdapter = control.As<ITransformAdapter>(); m_canvasAdapter = control.As<ICanvasAdapter>(); control.Paint += control_Paint; }