// <snippet4>
        public AnchorGlyph(
            AnchorStyles anchorStyle,
            BehaviorService behaviorService,
            IComponentChangeService changeService,
            ISelectionService selectionService,
            IDesigner relatedDesigner,
            Adorner anchorAdorner)
            : base(new AnchorBehavior(relatedDesigner))
        {
            // Cache references for convenience.
            this.anchorStyle      = anchorStyle;
            this.behaviorService  = behaviorService;
            this.changeService    = changeService;
            this.selectionService = selectionService;
            this.relatedDesigner  = relatedDesigner;
            this.anchorAdorner    = anchorAdorner;

            // Cache a reference to the control being designed.
            this.relatedControl =
                this.relatedDesigner.Component as Control;

            // Hook the SelectionChanged event.
            this.selectionService.SelectionChanged +=
                new EventHandler(selectionService_SelectionChanged);

            // Hook the ComponentChanged event so the anchor glyphs
            // can correctly track the control's bounds.
            this.changeService.ComponentChanged +=
                new ComponentChangedEventHandler(changeService_ComponentChanged);
        }
示例#2
0
        internal override void ShowContextMenu(int x, int y)
        {
            ToolStripKeyboardHandlingService service = (ToolStripKeyboardHandlingService)this.GetService(typeof(ToolStripKeyboardHandlingService));

            if (service != null)
            {
                if (!service.ContextMenuShownByKeyBoard)
                {
                    BehaviorService service2 = (BehaviorService)this.GetService(typeof(BehaviorService));
                    Point           empty    = Point.Empty;
                    if (service2 != null)
                    {
                        empty = service2.ScreenToAdornerWindow(new Point(x, y));
                    }
                    if (this.GetGlyphBounds().Contains(empty))
                    {
                        this.DesignerContextMenu.Show(x, y);
                    }
                }
                else
                {
                    service.ContextMenuShownByKeyBoard = false;
                    this.DesignerContextMenu.Show(x, y);
                }
            }
        }
 private void PaintInsertionMark(ToolStripItem item)
 {
     if ((ToolStripDesigner.LastCursorPosition == Point.Empty) || (ToolStripDesigner.LastCursorPosition != Cursor.Position))
     {
         ToolStripKeyboardHandlingService keyBoardHandlingService = this.GetKeyBoardHandlingService(item);
         if (((keyBoardHandlingService == null) || !keyBoardHandlingService.TemplateNodeActive) && ((item != null) && (item.Site != null)))
         {
             ToolStripDesigner.LastCursorPosition = Cursor.Position;
             IDesignerHost service = (IDesignerHost)item.Site.GetService(typeof(IDesignerHost));
             if (service != null)
             {
                 Rectangle       paintingBounds  = GetPaintingBounds(service, item);
                 BehaviorService behaviorService = this.GetBehaviorService(item);
                 if (behaviorService != null)
                 {
                     using (Graphics graphics = behaviorService.AdornerWindowGraphics)
                     {
                         using (Pen pen = new Pen(new SolidBrush(Color.Black)))
                         {
                             pen.DashStyle = DashStyle.Dot;
                             graphics.DrawRectangle(pen, paintingBounds);
                         }
                     }
                 }
             }
         }
     }
 }
示例#4
0
 public void GetGlyphs(ref GlyphCollection glyphs, System.Windows.Forms.Design.Behavior.Behavior standardBehavior)
 {
     if (this.ImmediateParent != null)
     {
         Rectangle glyphBounds = this.GetGlyphBounds();
         ToolStripDesignerUtils.GetAdjustedBounds(this.ToolStripItem, ref glyphBounds);
         BehaviorService service = (BehaviorService)this.GetService(typeof(BehaviorService));
         if (service.ControlRectInAdornerWindow((Control)this.ImmediateParent).Contains(glyphBounds.Left, glyphBounds.Top))
         {
             if (this.ToolStripItem.IsOnDropDown)
             {
                 ToolStrip currentParent = this.ToolStripItem.GetCurrentParent();
                 if (currentParent == null)
                 {
                     currentParent = this.ToolStripItem.Owner;
                 }
                 if ((currentParent != null) && currentParent.Visible)
                 {
                     glyphs.Add(new MiniLockedBorderGlyph(glyphBounds, SelectionBorderGlyphType.Top, standardBehavior, true));
                     glyphs.Add(new MiniLockedBorderGlyph(glyphBounds, SelectionBorderGlyphType.Bottom, standardBehavior, true));
                     glyphs.Add(new MiniLockedBorderGlyph(glyphBounds, SelectionBorderGlyphType.Left, standardBehavior, true));
                     glyphs.Add(new MiniLockedBorderGlyph(glyphBounds, SelectionBorderGlyphType.Right, standardBehavior, true));
                 }
             }
             else
             {
                 glyphs.Add(new MiniLockedBorderGlyph(glyphBounds, SelectionBorderGlyphType.Top, standardBehavior, true));
                 glyphs.Add(new MiniLockedBorderGlyph(glyphBounds, SelectionBorderGlyphType.Bottom, standardBehavior, true));
                 glyphs.Add(new MiniLockedBorderGlyph(glyphBounds, SelectionBorderGlyphType.Left, standardBehavior, true));
                 glyphs.Add(new MiniLockedBorderGlyph(glyphBounds, SelectionBorderGlyphType.Right, standardBehavior, true));
             }
         }
     }
 }
示例#5
0
        private bool _selectionChanging;                   //we dont want the OnSelectionChanged to be recursively called.

        /// <summary>
        /// Constructor.  Here we query for necessary services and cache them for perf. reasons. We also hook to Component Added/Removed/Changed notifications so we can keep in sync when the designers' components change.  Also, we create our custom Adorner and add it to the BehaviorService.
        /// </summary>
        public SelectionManager(IServiceProvider serviceProvider, BehaviorService behaviorService)
        {
            _prevSelectionBounds  = null;
            _prevPrimarySelection = null;
            _behaviorService      = behaviorService;
            _serviceProvider      = serviceProvider;
            _selSvc       = (ISelectionService)serviceProvider.GetService(typeof(ISelectionService));
            _designerHost = (IDesignerHost)serviceProvider.GetService(typeof(IDesignerHost));
            if (_designerHost == null || _selSvc == null)
            {
                Debug.Fail("SelectionManager - Host or SelSvc is null, can't continue");
            }

            _rootComponent = (Control)_designerHost.RootComponent;
            //create and add both of our adorners, one for selection, one for bodies
            _selectionAdorner = new Adorner();
            _bodyAdorner      = new Adorner();
            behaviorService.Adorners.Add(_bodyAdorner);
            behaviorService.Adorners.Add(_selectionAdorner);//adding this will cause the adorner to get setup with a ptr to the beh.svc.
            _componentToDesigner = new Hashtable();
            // designeraction UI
            if (_designerHost.GetService(typeof(DesignerOptionService)) is DesignerOptionService options)
            {
                PropertyDescriptor p = options.Options.Properties["UseSmartTags"];
                if (p != null && p.PropertyType == typeof(bool) && (bool)p.GetValue(null))
                {
                    _designerActionUI = new DesignerActionUI(serviceProvider, _selectionAdorner);
                    behaviorService.DesignerActionUI = _designerActionUI;
                }
            }
        }
 public RibbonPanelGlyph(BehaviorService behaviorService, RibbonTabDesigner designer, RibbonTab tab)
     : base(new RibbonPanelGlyphBehavior(designer, tab), behaviorService)
 {
     _componentDesigner = designer;
     _tab = tab;
     size = new Size(60, 16);
 }
示例#7
0
 public DragDropHandler(Control control, BehaviorService behaviorService, IDesignerHost designerHost)
 {
     this.control          = control;
     this.behaviorService  = behaviorService;
     this.designerHost     = designerHost;
     control.ControlAdded += new ControlEventHandler(control_ControlAdded);
 }
        /// <summary>
        /// Initializes the designer with the specified component.
        /// </summary>
        /// <param name="component">The IComponent to associate with the designer.</param>
        public override void Initialize(IComponent component)
        {
            // Let base class do standard stuff
            base.Initialize(component);

            Debug.Assert(component != null);

            // The resizing handles around the control need to change depending on the
            // value of the AutoSize and AutoSizeMode properties. When in AutoSize you
            // do not get the resizing handles, otherwise you do.
            AutoResizeHandles = true;

            // Acquire service interfaces
            _designerHost     = (IDesignerHost)GetService(typeof(IDesignerHost));
            _selectionService = (ISelectionService)GetService(typeof(ISelectionService));
            _behaviorService  = (BehaviorService)GetService(typeof(BehaviorService));

            // Remember the actual control being designed
            _splitContainer = component as KryptonSplitContainer;

            // Create a new adorner and add our splitter glyph
            _adorner = new Adorner();
            _adorner.Glyphs.Add(new KryptonSplitContainerGlyph(_selectionService, _behaviorService, _adorner, this));
            _behaviorService.Adorners.Add(_adorner);

            // Let the two panels in the container be designable
            if (_splitContainer != null)
            {
                EnableDesignMode(_splitContainer.Panel1, "Panel1");
                EnableDesignMode(_splitContainer.Panel2, "Panel2");
            }
        }
示例#9
0
 private void OnRightToLeftLayoutChanged(object sender, EventArgs e)
 {
     if (BehaviorService != null)
     {
         BehaviorService.SyncSelection();
     }
 }
示例#10
0
 public RibbonTabGlyph(BehaviorService behaviorService, RibbonDesigner designer, Ribbon ribbon)
     : base(new RibbonTabGlyphBehavior(designer, ribbon), behaviorService)
 {
     _componentDesigner = designer;
     _ribbon            = ribbon;
     size = new Size(60, 16);
 }
示例#11
0
 /// <summary>
 /// Initializes a new instance of the CaptionGlyph class.
 /// </summary>
 /// <param name="behaviorService"></param>
 /// <param name="xpanderPanel"></param>
 public XPanderPanelCaptionGlyph(BehaviorService behaviorService, XPanderPanel xpanderPanel)
     :
     base(new XPanderPanelCaptionClickBehavior(xpanderPanel))
 {
     this.m_behaviorService = behaviorService;
     this.m_xpanderPanel    = xpanderPanel;
 }
 public RibbonQuickAccessToolbarGlyph(BehaviorService behaviorService, RibbonDesigner designer, Ribbon ribbon)
     : base(new RibbonQuickAccessGlyphBehavior(designer, ribbon))
 {
     _behaviorService   = behaviorService;
     _componentDesigner = designer;
     _ribbon            = ribbon;
 }
示例#13
0
 public WaitingCircleGlyph(BehaviorService service, XWaitingCircle control, Adorner adorner)
     : base(new WaitingCircleBehavior())
 {
     _bsService  = service;
     _waitCircle = control;
     _adorner    = adorner;
 }
示例#14
0
 public RibbonOrbAdornerGlyph(BehaviorService behaviorService, RibbonDesigner designer, Ribbon ribbon)
     : base(new RibbonOrbAdornerGlyphBehavior())
 {
     _behaviorService   = behaviorService;
     _componentDesigner = designer;
     _ribbon            = ribbon;
 }
示例#15
0
 /// <summary>
 ///  For controls, we sync their property changed event so our component can track their location.
 /// </summary>
 private void OnControlPropertyChanged(object sender, EventArgs e)
 {
     if (BehaviorService != null)
     {
         BehaviorService.SyncSelection();
     }
 }
示例#16
0
 public ToolStripEditorManager(IComponent comp)
 {
     // get the parent
     _comp            = comp;
     _behaviorService = (BehaviorService)comp.Site.GetService(typeof(BehaviorService));
     _designerHost    = (IDesignerHost)comp.Site.GetService(typeof(IDesignerHost));
 }
示例#17
0
 private void ClearInsertionCursorGlyphAndInvalidate()
 {
     if (_insertionAdorner.Glyphs.Count > 0 &&
         _insertionAdorner.Glyphs[0] is StackInsertionCursorGlyph glyph)
     {
         _insertionAdorner.Glyphs.Clear();
         BehaviorService.Invalidate(glyph.Bounds);
     }
 }
示例#18
0
 /// <summary>
 /// 用给定的 <see cref="T:System.Windows.Forms.Design.Behavior.BehaviorService"/> 初始化 <see cref="T:System.Windows.Forms.Design.Behavior.Behavior"/> 类的新实例。
 /// </summary>
 /// <param name="callParentBehavior">如果应该调用父行为(如果存在),则为 true;否则为 false。</param><param name="behaviorService">要使用的 <see cref="T:System.Windows.Forms.Design.Behavior.BehaviorService"/>。  </param><exception cref="T:System.ArgumentNullException"><paramref name="callParentBehavior"/> 为 true 且 <paramref name="behaviorService"/> 为 null。</exception>
 protected MyBehavior(bool callParentBehavior, BehaviorService behaviorService)
 {
     if (callParentBehavior && behaviorService == null)
     {
         throw new ArgumentException("behaviorService");
     }
     this.callParentBehavior = callParentBehavior;
     this.bhvSvc             = behaviorService;
 }
示例#19
0
        /// <summary>
        /// HACK: Checks that the behaviour service otherwise we get a null
        /// reference exception. The behaviour service is created when a control
        /// is added to the design surface or if the DocumentDesigner is used
        /// instead of the ParentControlDesigner. We cannot use the DocumentDesigner
        /// since nothing seems to be shown in the design surface when we
        /// create an object. Until the designer code is reworked this hack
        /// fixes the problem.
        /// </summary>
        protected override void OnMouseDragBegin(int x, int y)
        {
            BehaviorService behaviourService = (BehaviorService)GetService(typeof(BehaviorService));

            if (behaviourService != null)
            {
                base.OnMouseDragBegin(x, y);
            }
        }
        public MasterBehavior[] GetBehaviors([FromBody] BehaviorFilter data)
        {
            //int categoryId; int behaviorTypeId; int majorGroupId; int orgId;

            //int.TryParse(data.Get("categoryId"), out categoryId);
            //int.TryParse(data.Get("behaviorTypeId"), out behaviorTypeId);
            //int.TryParse(data.Get("majorGroupId"), out majorGroupId);
            //int.TryParse(data.Get("orgId"), out orgId);
            return(BehaviorService.GetBehaviors(data.CategoryId, data.BehaviorTypeId, data.MajorGroupId, data.OrgId).ToArray());
        }
示例#21
0
 public CaptionGlyph(BehaviorService behaviorSvc, Control control)
     : base(new PreventDropBehavior())
 {
     _control     = control as ToolWindowOld;
     _behaviorSvc = behaviorSvc;
     if (control == null)
     {
         throw new ArgumentException("control");
     }
 }
示例#22
0
 public override void Initialize(IComponent component)
 {
     base.Initialize(component);
     _iss = (ISelectionService)GetService(typeof(ISelectionService));
     _iss.SelectionChanged += new EventHandler(OnComponentSelectionChanged);
     _bs      = (BehaviorService)GetService(typeof(BehaviorService));
     _adorner = new Adorner();
     _bs.Adorners.Add(_adorner);
     _adorner.Glyphs.Add(new WaitingCircleGlyph(_bs, (XWaitingCircle)Control, _adorner));
 }
 public int AddUpdateBehavior([FromBody] MasterBehavior behavior)
 {
     if (behavior.Behavior_ID <= 0)
     {
         return(BehaviorService.AddBehavior(behavior));
     }
     else
     {
         return(BehaviorService.UpdateBehavior(behavior));
     }
 }
 // Gets the Behavior Service.
 private BehaviorService GetBehaviorService(ToolStripItem item)
 {
     Debug.Assert(item != null, "Item passed is null, BehaviorService cannot be obtained");
     if (item.Site != null)
     {
         BehaviorService behaviorSvc = (BehaviorService)item.Site.GetService(typeof(BehaviorService));
         Debug.Assert(behaviorSvc != null, "Failed to get Behavior Service!");
         return(behaviorSvc);
     }
     return(null);
 }
示例#25
0
 protected override void Dispose(bool disposing)
 {
     if (disposing && myAdorner != null)
     {
         BehaviorService b = BehaviorService;
         if (b != null)
         {
             b.Adorners.Remove(myAdorner);
         }
     }
 }
示例#26
0
        public TabHostGlyph(BehaviorService behaviorSvc, Control control,
                            Adorner glyphAdorner, ISelectionService selectionService)
            : base(new TabHostBehavior())
        {
            service = behaviorSvc;
            tabHost = control as TabHost;
            adorner = glyphAdorner;
            this.selectionService = selectionService;

            // add events
            selectionService.SelectionChanged += OnSelectionChanged;
        }
 protected override void Dispose(bool disposing)
 {
     if (disposing)
     {
         this.PopBehavior();
         if (this.selectionService != null)
         {
             this.selectionService.SelectionChanged -= new EventHandler(this.selectionService_SelectionChanged);
         }
         this.selectionService = null;
         this.behaviorService  = null;
     }
 }
示例#28
0
        public Rectangle GetGlyphBounds()
        {
            BehaviorService service = (BehaviorService)this.GetService(typeof(BehaviorService));
            Rectangle       empty   = Rectangle.Empty;

            if ((service != null) && (this.ImmediateParent != null))
            {
                Point pos = service.ControlToAdornerWindow((Control)this.ImmediateParent);
                empty = this.ToolStripItem.Bounds;
                empty.Offset(pos);
            }
            return(empty);
        }
示例#29
0
        ///
        ///     Standard constructor that caches services and clears values.
        ///
        internal ResizeBehavior(Control control, IServiceProvider serviceProvider)
        {
            this.control         = control;
            this.serviceProvider = serviceProvider;
            behaviorService      = serviceProvider.GetService(typeof(BehaviorService)) as BehaviorService;

            if (behaviorService == null)
            {
                Debug.Fail("BehaviorService could not be found!");
                return;
            }
            pushedBehavior = false;
            lastMouseLoc   = Point.Empty;
        }
示例#30
0
 private void OnItemPaint(object sender, PaintEventArgs e)
 {
     if (((this.ToolStripItem.GetCurrentParent() is ToolStripDropDown) && (this.selSvc != null)) && (!this.IsEditorActive && this.ToolStripItem.Equals(this.selSvc.PrimarySelection)))
     {
         BehaviorService service = (BehaviorService)this.GetService(typeof(BehaviorService));
         if (service != null)
         {
             Point     pos    = service.ControlToAdornerWindow((Control)this.ImmediateParent);
             Rectangle bounds = this.ToolStripItem.Bounds;
             bounds.Offset(pos);
             bounds.Inflate(2, 2);
             service.ProcessPaintMessage(bounds);
         }
     }
 }
	// Constructors
	public BehaviorServiceAdornerCollection(BehaviorService behaviorService) {}