1 using System;
2 using System.Windows;
3
4 namespace FileExplorer
5 {
6 public System.Windows.Color DefaultPathDividerBackgroundColor()
7 {
8 return System.Windows.Color.White();
9 }
10
11 public System.Windows.Color DefaultPathDividerLineColor()
12 {
13 return System.Windows.Color(204u, 206u, 219u);
14 }
15
16 public ControlCreateParams& PathDividerControlCreateParams(ControlCreateParams& controlCreateParams)
17 {
18 return controlCreateParams.SetWindowClassName("FileExplorer.PathDivider").
19 SetWindowClassBackgroundColor(SystemColor.COLOR_WINDOW).
20 SetBackgroundColor(DefaultPathDividerBackgroundColor()).
21 SetSize(Size(1, 0)).SetDock(Dock.left);
22 }
23
24 public class PathDividerCreateParams
25 {
26 public PathDividerCreateParams(ControlCreateParams& controlCreateParams_) :
27 controlCreateParams(controlCreateParams_),
28 lineColor(DefaultPathDividerLineColor())
29 {
30 }
31 public PathDividerCreateParams& Defaults()
32 {
33 return *this;
34 }
35 public PathDividerCreateParams& SetLineColor(const System.Windows.Color& lineColor_)
36 {
37 lineColor = lineColor_;
38 return *this;
39 }
40 public ControlCreateParams& controlCreateParams;
41 public System.Windows.Color lineColor;
42 }
43
44 public class PathDivider : Control
45 {
46 public PathDivider(PathDividerCreateParams& createParams) :
47 base(createParams.controlCreateParams),
48 pen(createParams.lineColor)
49 {
50 }
51 protected override Result<bool> OnPaint(PaintEventArgs& args)
52 {
53 PointF start(0, 0);
54 Size sz = GetSize();
55 PointF end(0, sz.h);
56 auto result = args.graphics.DrawLine(pen, start, end);
57 if (result.Error())
58 {
59 return Result<bool>(ErrorId(result.GetErrorId()));
60 }
61 return Result<bool>(true);
62 }
63 private Pen pen;
64 }