Beispiel #1
0
 private void OnEnable()
 {
     foreach (var filePath in Directory.EnumerateFiles(@"./Presets", @"*.csv"))
     {
         var button = Instantiate(_buttonPrefab, _buttonRoot, false);
         button.ButtonText = filePath;
         button.OnClick   += () =>
         {
             OnFileSelected?.Invoke(filePath);
             gameObject.SetActive(false);
         };
     }
 }
        public override void Execute()
        {
            if (!CanExecute())
            {
                throw new CannotExecuteCommandException(GetType());
            }

            var openFolderDialog = new CommonOpenFileDialog {
                IsFolderPicker = false, EnsurePathExists = true, EnsureFileExists = true, Multiselect = false
            };
            var result = openFolderDialog.ShowDialog();

            if (result != CommonFileDialogResult.Ok)
            {
                return;
            }

            var directoryPath = openFolderDialog.FileNames.Single();

            OnFileSelected?.Invoke(directoryPath);
        }
Beispiel #3
0
        protected override void OnInitialized()
        {
            Root.Children.Add(new Component()
            {
                Width    = "100%",
                Height   = "100%",
                Padding  = "10px",
                Layout   = LayoutType.Column,
                Children = new List <Component>()
                {
                    new Component()
                    {
                        Width         = "100%",
                        AutosizeY     = true,
                        CenterContent = true,
                        Children      = new List <Component>()
                        {
                            new Button()
                            {
                                Padding  = "10px",
                                Children = new List <Component>()
                                {
                                    new Icon(Icons.AngleUp)
                                },
                                Name = "up_btn"
                            },
                            new TextBox()
                            {
                                Expand = true,
                                Margin = "0px 10px",
                                Height = "0px",
                                Name   = "directory_box"
                            },
                            new Dropdown()
                            {
                                Width = "100px",
                                Name  = "drives",
                                Items = Directory.GetLogicalDrives().ToList()
                            }
                        }
                    },
                    new Panel()
                    {
                        Width     = "100%",
                        MarginTop = "10px",
                        Padding   = "5px 1px",
                        Expand    = true,
                        Name      = "files_panel",
                        Layout    = LayoutType.Column,
                        Overflow  = OverflowType.Scroll
                    },
                    new Component()
                    {
                        Width     = "100%",
                        AutosizeY = true,
                        Reversed  = true,
                        MarginTop = "10px",
                        Children  = new List <Component>()
                        {
                            new Button("Otwórz")
                            {
                                Appearance = Button.ButtonStyle.Filled,
                                Name       = "ok_btn"
                            },
                            new Button("Anuluj")
                            {
                                MarginRight = "5px",
                                Name        = "close_btn"
                            }
                        }
                    }
                }
            });

            Root.FindChild("dropdown_button").Padding = "10px";

            Root.FindChild("close_btn").Clicked += (object sender) =>
            {
                Window.Close();
            };

            Root.FindChild("up_btn").Clicked += Up;

            Window.KeyReleased += (object sender, KeyEventArgs e) =>
            {
                if (e.Code == Keyboard.Key.Enter)
                {
                    Navigate(CurrentPath);
                }
            };

            (Root.FindChild("drives") as Dropdown).OnSelected += (object sender, string text, int id) =>
            {
                Navigate(text);
            };

            Root.FindChild("ok_btn").Clicked += (object sender) =>
            {
                OnFileSelected?.Invoke(this, new FSEntry(CurrentPath));
                Window.Close();
            };

            Navigate(StartDirectory);
        }
Beispiel #4
0
 public void HandleFileSelected(UploadFile file)
 {
     OnFileSelected?.Invoke(file);
     Console.WriteLine(nameof(HandleFileSelected) + ": " + file.Name + " ");
 }
Beispiel #5
0
        private void Initialize()
        {
            string style = @"<hss><style name=""drives""><size-ease>instant</size-ease></style></hss>";

            StyleBank.LoadFromString(style);

            _internalApp = new HlyssApp(Window);

            _internalApp.Root.Children.Add(new Component()
            {
                Width    = "100%",
                Height   = "100%",
                Padding  = "10px",
                Layout   = LayoutType.Column,
                Children = new List <Component>()
                {
                    new Component()
                    {
                        Width         = "100%",
                        AutosizeY     = true,
                        CenterContent = true,
                        Children      = new List <Component>()
                        {
                            new Button()
                            {
                                Padding  = "10px",
                                Children = new List <Component>()
                                {
                                    new Icon(Icons.AngleUp)
                                },
                                Name = "up_btn"
                            },
                            new TextBox()
                            {
                                Expand = true,
                                Margin = "0px 10px",
                                Height = "0px",
                                Name   = "directory_box"
                            },
                            new Dropdown()
                            {
                                Width = "100px",
                                Name  = "drives",
                                Items = DriveInfo.GetDrives().Select(o => o.Name).ToList()
                            }
                        }
                    },
                    new Panel()
                    {
                        Width     = "100%",
                        MarginTop = "10px",
                        Padding   = "5px 1px",
                        Expand    = true,
                        Name      = "files_panel",
                        Layout    = LayoutType.Column,
                        Overflow  = OverflowType.Scroll
                    },
                    new Component()
                    {
                        Width     = "100%",
                        AutosizeY = true,
                        Reversed  = true,
                        MarginTop = "10px",
                        Children  = new List <Component>()
                        {
                            new Button("Otwórz")
                            {
                                Appearance = Button.ButtonStyle.Filled,
                                Name       = "ok_btn"
                            },
                            new Button("Anuluj")
                            {
                                MarginRight = "5px",
                                Name        = "close_btn"
                            }
                        }
                    }
                }
            });

            _internalApp.Root.FindChild("dropdown_menu").Slot.Style = "drives";
            _internalApp.Root.FindChild("dropdown_button").Padding  = "10px";

            _internalApp.Root.FindChild("close_btn").Clicked += (object sender) =>
            {
                _internalApp.Window.Close();
            };

            _internalApp.Root.FindChild("up_btn").Clicked += Up;

            _internalApp.Window.KeyReleased += (object sender, KeyEventArgs e) =>
            {
                if (e.Code == Keyboard.Key.Enter)
                {
                    Navigate(CurrentPath);
                }
            };

            (_internalApp.Root.FindChild("drives") as Dropdown).OnSelected += (object sender, string text, int id) =>
            {
                Navigate(text);
            };

            _internalApp.Root.FindChild("ok_btn").Clicked += (object sender) =>
            {
                OnFileSelected?.Invoke(this, new FSEntry(CurrentPath));
                _internalApp.Window.Close();
            };

            Navigate(StartDirectory);
        }