示例#1
0
        void SetFileEntry(bool isDir)
        {
            if (_choose != null)
            {
                _choose.Hide();
            }

            if (isDir)
            {
                _choose = new FileChooserButton(_("Open..."),
                                                FileChooserAction.SelectFolder);
                _choose.SelectionChanged += delegate
                {
                    string directory = _choose.Filename;
                    if (directory.Length > 0)
                    {
                        _loader.Value = new DirImageProviderFactory(directory,
                                                                    _recursive.Value);
                    }
                };
            }
            else
            {
                _choose = new FileChooserButton(_("Open..."),
                                                FileChooserAction.Open);
                _choose.SelectionChanged += delegate
                {
                    string fileName = _choose.Filename;
                    if (fileName.Length > 0)
                    {
                        _loader.Value = new FileImageProviderFactory(fileName);
                    }
                };
            }

            _choose.Show();
            Table.Attach(_choose, 1, 2, 1, 2, AttachOptions.Shrink,
                         AttachOptions.Fill, 0, 0);
        }