LayoutDocumentPaneControl.cs 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109
  1. /*************************************************************************************
  2. Extended WPF Toolkit
  3. Copyright (C) 2007-2013 Xceed Software Inc.
  4. This program is provided to you under the terms of the Microsoft Public
  5. License (Ms-PL) as published at http://wpftoolkit.codeplex.com/license
  6. For more features, controls, and fast professional support,
  7. pick up the Plus Edition at http://xceed.com/wpf_toolkit
  8. Stay informed: follow @datagrid on Twitter or Like http://facebook.com/datagrids
  9. ***********************************************************************************/
  10. using System;
  11. using System.Collections.Generic;
  12. using System.Linq;
  13. using System.Text;
  14. using System.Windows;
  15. using System.Collections.ObjectModel;
  16. using System.Windows.Controls;
  17. using System.Windows.Data;
  18. using Xceed.Wpf.AvalonDock.Layout;
  19. namespace Xceed.Wpf.AvalonDock.Controls
  20. {
  21. public class LayoutDocumentPaneControl : TabControl, ILayoutControl//, ILogicalChildrenContainer
  22. {
  23. static LayoutDocumentPaneControl()
  24. {
  25. FocusableProperty.OverrideMetadata(typeof(LayoutDocumentPaneControl), new FrameworkPropertyMetadata(false));
  26. }
  27. internal LayoutDocumentPaneControl(LayoutDocumentPane model)
  28. {
  29. if (model == null)
  30. throw new ArgumentNullException("model");
  31. _model = model;
  32. SetBinding(ItemsSourceProperty, new Binding("Model.Children") { Source = this });
  33. SetBinding(FlowDirectionProperty, new Binding("Model.Root.Manager.FlowDirection") { Source = this });
  34. this.LayoutUpdated += new EventHandler(OnLayoutUpdated);
  35. }
  36. void OnLayoutUpdated(object sender, EventArgs e)
  37. {
  38. var modelWithAtcualSize = _model as ILayoutPositionableElementWithActualSize;
  39. modelWithAtcualSize.ActualWidth = ActualWidth;
  40. modelWithAtcualSize.ActualHeight = ActualHeight;
  41. }
  42. protected override void OnGotKeyboardFocus(System.Windows.Input.KeyboardFocusChangedEventArgs e)
  43. {
  44. base.OnGotKeyboardFocus(e);
  45. System.Diagnostics.Trace.WriteLine( string.Format( "OnGotKeyboardFocus({0}, {1})", e.Source, e.NewFocus ) );
  46. //if (_model.SelectedContent != null)
  47. // _model.SelectedContent.IsActive = true;
  48. }
  49. protected override void OnSelectionChanged(SelectionChangedEventArgs e)
  50. {
  51. base.OnSelectionChanged(e);
  52. if (_model.SelectedContent != null)
  53. _model.SelectedContent.IsActive = true;
  54. }
  55. List<object> _logicalChildren = new List<object>();
  56. protected override System.Collections.IEnumerator LogicalChildren
  57. {
  58. get
  59. {
  60. return _logicalChildren.GetEnumerator();
  61. }
  62. }
  63. LayoutDocumentPane _model;
  64. public ILayoutElement Model
  65. {
  66. get { return _model; }
  67. }
  68. protected override void OnMouseLeftButtonDown(System.Windows.Input.MouseButtonEventArgs e)
  69. {
  70. base.OnMouseLeftButtonDown(e);
  71. if (!e.Handled && _model.SelectedContent != null)
  72. _model.SelectedContent.IsActive = true;
  73. }
  74. protected override void OnMouseRightButtonDown(System.Windows.Input.MouseButtonEventArgs e)
  75. {
  76. base.OnMouseRightButtonDown(e);
  77. if (!e.Handled && _model.SelectedContent != null)
  78. _model.SelectedContent.IsActive = true;
  79. }
  80. }
  81. }