Пример #1
0
        /// <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);
        }
Пример #2
0
 /// <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);
 }
Пример #3
0
        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);
        }
Пример #4
0
        /// <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
        }
Пример #6
0
        /// <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);
        }
Пример #7
0
            /// <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);
            }
Пример #8
0
        /// <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);
        }
Пример #10
0
        /// <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);
        }
Пример #11
0
        /// <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;
        }
Пример #12
0
 /// <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>();
 }
Пример #13
0
        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);
        }
Пример #14
0
        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);
        }
Пример #15
0
        /// <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);
        }
Пример #16
0
        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);

        }
Пример #17
0
        /// <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);
        }
Пример #18
0
        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);
                }
            }
        }
Пример #19
0
        /// <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);
        }
Пример #20
0
        /// <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);
        }
Пример #21
0
        /// <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;
        }
Пример #22
0
 /// <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);
 }
Пример #23
0
        /// <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);
        }
Пример #24
0
        /// <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;
        }
Пример #25
0
        /// <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;
        }