1 using System;
2 using System.Windows;
3
4 namespace FileExplorer
5 {
6 public nothrow System.Windows.Color DefaultContentViewFrameColor()
7 {
8 return System.Windows.Color(204u, 206u, 219u);
9 }
10
11 public class ContentView : ContainerControl
12 {
13 public ContentView(ImageList* imageList_) : base(ControlCreateParams().SetWindowClassName("FileExplorer.ContentView").
14 SetWindowClassBackgroundColor(SystemColor.COLOR_WINDOW).SetBackgroundColor(Color.White()).SetDock(Dock.fill)),
15 imageList(imageList_)
16 {
17 AddChild(MakeFramedControl(new EmptyView(EmptyViewControlCreateParams(ControlCreateParams().Defaults()))));
18 }
19 public nothrow void SetMainWindow(MainWindow* mainWindow_)
20 {
21 mainWindow = mainWindow_;
22 }
23 public nothrow void ViewContent(Node* node)
24 {
25 if (framedChild != null)
26 {
27 RemoveChild(framedChild);
28 framedChild = null;
29 child = null;
30 }
31 Control* view = node->CreateView(imageList);
32 if (view == null)
33 {
34 view = new EmptyView(EmptyViewControlCreateParams(ControlCreateParams().Defaults()));
35 }
36 UniquePtr<Control> framedView = MakeFramedControl(view);
37 AddChild(framedView.Release());
38 }
39 protected override void OnPaint(PaintEventArgs& args)
40 {
41 child->Invalidate();
42 framedChild->Invalidate();
43 base->OnPaint(args);
44 }
45 private Control* MakeFramedControl(Control* child_)
46 {
47 child = child_;
48 child->SetScrollSubject();
49 PaddedControl* paddedControl = new PaddedControl(PaddedControlCreateParams(PaddedControlControlCreateParams(
50 ControlCreateParams().Defaults(), child), child).Defaults());
51 BorderedControl* borderedControl = new BorderedControl(BorderedControlCreateParams(BorderedControlControlCreateParams(
52 ControlCreateParams().Defaults(), paddedControl), paddedControl).SetNormalBorderColor(DefaultContentViewFrameColor()));
53 ScrollableControl* scrollableControl = new ScrollableControl(ScrollableControlCreateParams(ScrollableControlControlCreateParams(
54 ControlCreateParams().SetDock(Dock.fill), borderedControl), borderedControl).Defaults());
55 framedChild = scrollableControl;
56 return scrollableControl;
57 }
58 private ImageList* imageList;
59 private MainWindow* mainWindow;
60 private Control* framedChild;
61 private Control* child;
62 }
63 }
64
65