Exemplo n.º 1
0
        protected override void OnClick(EventArgs e)
        {
            base.OnClick(e);
            FileDialog.InitialDirectory = CheckLinkedControlText();

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

            switch (FileDialog)
            {
            case CommonOpenFileDialog open:
            {
                Boolean separator = open.IsFolderPicker && AddSeparatorToPickedFolder;

                if (open.Multiselect)
                {
                    PathsBeenSelected?.Invoke(separator ? open.FileNames.Select(PathUtils.ConvertToFolder) : open.FileNames);
                }
                else
                {
                    PathBeenSelected?.Invoke(separator ? PathUtils.ConvertToFolder(open.FileName) : open.FileName);
                }

                break;
            }

            case CommonSaveFileDialog save:
                PathBeenSelected?.Invoke(save.FileName);
                break;
            }
        }
Exemplo n.º 2
0
        public AdvancedPathTextBox(DialogType dialog = DialogType.Open)
            : base(new FormatPathTextBox
        {
            Multiline = false,
            AutoSize  = false,
            TextAlign = HorizontalAlignment.Left,
            MaxLength = 255
        })
        {
            _pathTypeChangeButton = new Button
            {
                Text = @"R"
            };
            _pathFormatHelpButton = new Button();
            PathDialogButton      = new DialogButton(TextBox, dialog);

            TextBox.TextChanged += (sender, args) =>
            {
                TextChanged?.Invoke(sender, args);
                OnPathTextBox_TextChanged();
            };
            TextBox.AvailableFormatingPartsChanged += OnAvailableFormatingParts_Changed;

            _pathFormatHelpButton.Click += (sender, args) => FormatHelpButtonClicked?.Invoke(sender, args);

            _pathTypeChangeButton.Click += (sender, args) => OnRelativeButton_Click();

            PathDialogButton.PathBeenSelected  += str => PathBeenSelected?.Invoke(str);
            PathDialogButton.PathsBeenSelected += list => PathsBeenSelected?.Invoke(list);

            PathTypeChangeButtonChanged += boolean => OnSizeChanged(EventArgs.Empty);
            PathDialogButtonChanged     += boolean => OnSizeChanged(EventArgs.Empty);
            PathFormatHelpButtonChanged += boolean => OnSizeChanged(EventArgs.Empty);
            LocationChanged             += (sender, args) => OnSizeChanged(args);

            FormatHelpButtonClicked += OnFormatHelpButton_Click;

            PathTypeChangeToolTipChanged += OnPathTextBox_TextChanged;

            OnPathTextBox_TextChanged();

            Controls.Add(TextBox);
            Controls.Add(_pathTypeChangeButton);
            Controls.Add(_pathFormatHelpButton);
            Controls.Add(PathDialogButton);
        }
Exemplo n.º 3
0
        protected virtual void OpenPathDialog(Object sender, EventArgs e)
        {
            OpenFileDialog.InitialDirectory = CheckLinkedControlText();

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

            Boolean addSeparator = OpenFileDialog.IsFolderPicker && AddSeparatorToPickedFolder;

            if (OpenFileDialog.Multiselect)
            {
                PathsBeenSelected?.Invoke(addSeparator
                    ? OpenFileDialog.FileNames.Select(PathUtils.ConvertToFolder)
                    : OpenFileDialog.FileNames);
            }
            else
            {
                PathBeenSelected?.Invoke(addSeparator ? PathUtils.ConvertToFolder(OpenFileDialog.FileName) : OpenFileDialog.FileName);
            }
        }