IPAddressControlDesigner.cs 2.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  1. // Copyright (c) 2007-2012 Michael Chapman
  2. // http://ipaddresscontrollib.googlecode.com
  3. // Permission is hereby granted, free of charge, to any person obtaining
  4. // a copy of this software and associated documentation files (the
  5. // "Software"), to deal in the Software without restriction, including
  6. // without limitation the rights to use, copy, modify, merge, publish,
  7. // distribute, sublicense, and/or sell copies of the Software, and to
  8. // permit persons to whom the Software is furnished to do so, subject to
  9. // the following conditions:
  10. // The above copyright notice and this permission notice shall be
  11. // included in all copies or substantial portions of the Software.
  12. // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
  13. // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
  14. // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
  15. // IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
  16. // CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
  17. // TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
  18. // SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
  19. using System;
  20. using System.Collections;
  21. using System.Windows.Forms.Design;
  22. using System.Windows.Forms.Design.Behavior;
  23. namespace IPAddressControlLib
  24. {
  25. class IPAddressControlDesigner : ControlDesigner
  26. {
  27. public override SelectionRules SelectionRules
  28. {
  29. get
  30. {
  31. IPAddressControl control = (IPAddressControl)Control;
  32. if ( control.AutoHeight )
  33. {
  34. return SelectionRules.Moveable | SelectionRules.Visible | SelectionRules.LeftSizeable | SelectionRules.RightSizeable;
  35. }
  36. else
  37. {
  38. return SelectionRules.AllSizeable | SelectionRules.Moveable | SelectionRules.Visible;
  39. }
  40. }
  41. }
  42. public override IList SnapLines
  43. {
  44. get
  45. {
  46. IPAddressControl control = (IPAddressControl)Control;
  47. IList snapLines = base.SnapLines;
  48. snapLines.Add( new SnapLine( SnapLineType.Baseline, control.Baseline ) );
  49. return snapLines;
  50. }
  51. }
  52. }
  53. }