1 using System;
  2 using System.Windows;
  3 
  4 namespace FileExplorer
  5 {
  6     public nothrow System.Windows.Color DefaultPathBarBackgroundColor()
  7     {
  8         return System.Windows.Color.White();
  9     }
 10 
 11     public nothrow System.Windows.Color DefaultPathBarFrameColor()
 12     {
 13         return System.Windows.Color(204u206u219u);
 14     }
 15 
 16     public nothrow ControlCreateParams& PathBarControlCreateParams(ControlCreateParams& controlCreateParams)
 17     {
 18         return controlCreateParams.SetWindowClassName("FileExplorer.PathBar").
 19             SetWindowClassBackgroundColor(SystemColor.COLOR_WINDOW).
 20             SetBackgroundColor(DefaultPathBarBackgroundColor());
 21     }
 22 
 23     public class PathBarCreateParams
 24     {
 25         public nothrow PathBarCreateParams(ControlCreateParams& controlCreateParams_) : 
 26             controlCreateParams(controlCreateParams_)
 27             frameColor(DefaultPathBarFrameColor())
 28         {
 29         }
 30         public nothrow PathBarCreateParams& Defaults()
 31         {
 32             return *this;
 33         }
 34         public nothrow PathBarCreateParams& SetFrameColor(const System.Windows.Color& frameColor_)
 35         {
 36             frameColor = frameColor_;
 37             return *this;
 38         }
 39         public ControlCreateParams& controlCreateParams;
 40         public System.Windows.Color frameColor;
 41     }
 42 
 43     public class PathBar : ContainerControl
 44     {
 45         public PathBar(PathBarCreateParams& createParams
 46             ControlCreateParams& emptyViewCreateParams
 47             ParentPathSelectorCreateParams& parentPathSelectorCreateParams
 48             PathDividerCreateParams& pathDividerCreateParams
 49             PathViewCreateParams& pathViewCreateParams) : 
 50             base(createParams.controlCreateParams)
 51         {
 52             UniquePtr<EmptyView> emptyViewPtr(new EmptyView(emptyViewCreateParams));
 53             emptyView = emptyViewPtr.Get();
 54             AddChild(emptyViewPtr.Release());
 55             UniquePtr<PathDivider> pathDivider1Ptr(new PathDivider(pathDividerCreateParams));
 56             pathDivider1 = pathDivider1Ptr.Get();
 57             AddChild(pathDivider1Ptr.Release());
 58             UniquePtr<ParentPathSelector> parentPathSelectorPtr(new ParentPathSelector(parentPathSelectorCreateParams));
 59             parentPathSelector = parentPathSelectorPtr.Get();
 60             parentPathSelector->SetDoubleBuffered();
 61             AddChild(parentPathSelectorPtr.Release());
 62             UniquePtr<PathDivider> pathDivider2Ptr(new PathDivider(pathDividerCreateParams));
 63             pathDivider2 = pathDivider2Ptr.Get();
 64             AddChild(pathDivider2Ptr.Release());
 65             UniquePtr<PathView> pathViewPtr(new PathView(pathViewCreateParams));
 66             pathView = pathViewPtr.Get();
 67             pathView->SetDoubleBuffered();
 68             AddChild(pathViewPtr.Release());
 69         }
 70         public nothrow void SetEmptyViewWidth(int width)
 71         {
 72             Size sz = emptyView->GetSize();
 73             sz.w = width + 4;
 74             emptyView->SetSize(sz);
 75             Size pathDivider1Size = pathDivider1->GetSize();
 76             sz.w = sz.w + pathDivider1Size.w;
 77             sz.w = sz.w + 32;
 78             Size pathDivider2Size = pathDivider2->GetSize();
 79             sz.w = sz.w + pathDivider2Size.w;
 80             Size pvSize = pathView->GetSize();
 81             sz.w = sz.w + pvSize.w;
 82             sz.h = Max(sz.hpvSize.h);
 83             SetSize(sz);
 84         }
 85         public nothrow void SetPathViewMaxWidth(int width)
 86         {
 87             Size sz = emptyView->GetSize();
 88             pathView->SetMaxWidth(width);
 89             Size pathDivider1Size = pathDivider1->GetSize();
 90             sz.w = sz.w + pathDivider1Size.w;
 91             sz.w = sz.w + 32;
 92             Size pathDivider2Size = pathDivider2->GetSize();
 93             sz.w = sz.w + pathDivider2Size.w;
 94             Size pvSize = pathView->GetSize();
 95             sz.w = sz.w + pvSize.w;
 96             sz.h = Max(sz.hpvSize.h);
 97             SetSize(sz);
 98         }
 99         public nothrow void SetCurrentNode(Node* currentNode_)
100         {
101             pathView->Clear();
102             currentNode = currentNode_;
103             Node* node = currentNode;
104             while (node != null)
105             {
106                 if (!node->IsRootDirectory())
107                 {
108                     pathView->PushPathComponent(node->Name()node);
109                 }
110                 node = node->Parent();
111             }
112             Invalidate();
113         }
114         public inline nothrow Node* CurrentNode() const
115         {
116             return currentNode;
117         }
118         public nothrow ParentPathSelector* GetParentPathSelector() const
119         {
120             return parentPathSelector;
121         }
122         public nothrow PathView* GetPathView() const
123         {
124             return pathView;
125         }
126         protected override void OnPaint(PaintEventArgs& args)
127         {
128             if (emptyView != null)
129             {
130                 emptyView->Invalidate();
131             }
132             if (pathDivider1 != null)
133             {
134                 pathDivider1->Invalidate();
135             }
136             if (parentPathSelector != null)
137             {
138                 parentPathSelector->Invalidate();
139             }
140             if (pathDivider2 != null)
141             {
142                 pathDivider2->Invalidate();
143             }
144             if (pathView != null)
145             {
146                 pathView->Invalidate();
147             }
148             base->OnPaint(args);
149         }
150         protected override void OnSizeChanged(uint windowState)
151         {
152             base->OnSizeChanged(windowState);
153             DockChildren();
154         }
155         private EmptyView* emptyView;
156         private PathDivider* pathDivider1;
157         private ParentPathSelector* parentPathSelector;
158         private PathDivider* pathDivider2;
159         private PathView* pathView;
160         private Node* currentNode;
161     }
162 }
163