Beispiel #1
0
 private void buttonCancel_Clicked(object sender, EventArgs e)
 {
     this.result = null;
     this.Destroy();
     this.Dispose();
 }
Beispiel #2
0
 private void NewFileDialog_DeleteEvent(object o, DeleteEventArgs args)
 {
     this.result = null;
     this.Destroy();
     this.Dispose();
 }
Beispiel #3
0
        private void btnNew_Clicked(object sender, EventArgs e)
        {
            this.result = new FileDialogResult();
            FileTypeInfo fileTypeInfo = this.selectedItem.FileTypeInfo;
            double       value        = this.entryHeight.Value;
            double       value2       = this.entryWidth.Value;

            Xwt.Size size = new Xwt.Size(value2, value);
            if (RegexModel.IsHasSystemReserveName(this.entry_FileName.Text))
            {
                MessageBox.Show(LanguageInfo.MessageBox215_WindowsNameLimit, this, null, MessageBoxImage.Info);
                this.entry_FileName.SelectRegion(0, this.entry_FileName.Text.Length);
                this.entry_FileName.HasFocus = true;
                this.result.IsSuccessful     = false;
            }
            else
            {
                string text = this.entry_FileName.Text + fileTypeInfo.Extension;
                if (!Regex.IsMatch(text, "^[A-Za-z0-9,._-]+$") || Regex.IsMatch(text, "[\\*\\\\/:?<>|\"]"))
                {
                    MessageBox.Show(LanguageInfo.MessageBox216_FileNameLimit, this, null, MessageBoxImage.Info);
                    this.entry_FileName.SelectRegion(0, this.entry_FileName.Text.Length);
                    this.entry_FileName.HasFocus = true;
                    this.result.IsSuccessful     = false;
                }
                else if (!FileService.IsValidFileName(text))
                {
                    string info = LanguageInfo.NewFile_WrongName.Replace("<", "&lt;").Replace(">", "&gt;");
                    MessageBox.Show(info, this, null, MessageBoxImage.Info);
                    this.entry_FileName.SelectRegion(0, this.entry_FileName.Text.Length);
                    this.entry_FileName.HasFocus = true;
                    this.result.IsSuccessful     = false;
                }
                else
                {
                    string value3 = text.Substring(0, text.Length - fileTypeInfo.Extension.Length);
                    if (string.IsNullOrWhiteSpace(value3))
                    {
                        MessageBox.Show(LanguageInfo.MessageBox_Content110, this, null, MessageBoxImage.Info);
                        this.entry_FileName.HasFocus = true;
                        this.result.IsSuccessful     = false;
                    }
                    else
                    {
                        this.result.FileName = text;
                        this.result.Size     = size;
                        this.result.FileType = this.selectedItem.FileTypeInfo.FileType;
                        string path = System.IO.Path.Combine(this.parentDir, this.result.FileName);
                        if (File.Exists(path))
                        {
                            MessageBox.Show(LanguageInfo.NewFile_SameName, this, null, MessageBoxImage.Info);
                            this.entry_FileName.SelectRegion(0, this.entry_FileName.Text.Length);
                            this.entry_FileName.HasFocus = true;
                            this.result.IsSuccessful     = false;
                        }
                        else
                        {
                            this.Destroy();
                            this.Dispose();
                        }
                    }
                }
            }
        }