Exemplo n.º 1
0
 private void OpenCsfFile(string fileName, bool readOnly)
 {
     if (this.Fs_CsfFile != null && this.Fs_CsfFile.Name == fileName)
     {
         this.ShowMessageBoxInformation("The file is already open.");
         return;
     }
     if (!this.OpenFileStream(fileName, FileMode.Open, readOnly ? FileAccess.Read : FileAccess.ReadWrite))
     {
         return;
     }
     try {
         this.SetIoStateTrueAndInitiateCsfFile(readOnly ? new ReadonlyCSFFile(this.Fs_CsfFile) : new CSFFile(this.Fs_CsfFile));
     }
     catch (Exception exception) {
         this.Fs_CsfFile.Close();
         this.Fs_CsfFile = null;
         this.CsfFile    = null;
         MessageBox.Show(this, this.GetMessageBoxErrorMessage("Bad file. Invalid CSF file format.", exception), string.Empty, MessageBoxButtons.OK, MessageBoxIcon.Error);
     }
 }
Exemplo n.º 2
0
 private void MnMnu_File_Close_Click(object sender, EventArgs e)
 {
     if (!this.TryActionShowMessageBoxErrorIfFail(this.Fs_CsfFile == null ? null : string.Format("Failed to close the file stream of the file '{0}'.", this.Fs_CsfFile.Name),
                                                  delegate {
         if (this.Fs_CsfFile != null)
         {
             this.Fs_CsfFile.Close();
             this.Fs_CsfFile = null;
         }
         this.CsfFile = null;
     }))
     {
         return;
     }
     this.SetCsfFilesHistoryEnabledState(null);
     this.SetIoState(false, true);
     this.StsStrp_Label_CsfFile_StringsCount.Text = Resources.StringsCount;
     this.StsStrp_Label_CsfFile_LabelsCount.Text  = Resources.LabelsCount;
     this.MnMnu_File_Save.Enabled   = false;
     this.MnMnu_File_SaveAs.Enabled = false;
     this.LstBox_CsfLabels.Items.Clear();
     this.CsfFile = null;
 }
Exemplo n.º 3
0
        private void SetIoStateTrueAndInitiateCsfFile(CSFFile csfFile)
        {
            this.SetIoState(true, csfFile.IsReadOnly);
            this.CsfFile = csfFile;
            this.StsStrp_Label_CsfFile_StringsCount.Text = Resources.StringsCount + csfFile.Labels.Count;
            {
                int             csfFile_stringsCount;
                List <CSFLabel> csfFile_labels;

                csfFile_stringsCount = 0;
                csfFile_labels       = new List <CSFLabel>(csfFile.Labels.Count);
                this.LstBox_CsfLabels.BeginUpdate();
                foreach (CSFLabel csfLabel in csfFile.Labels)
                {
                    if (this.LstBox_CsfLabels_SortByCsfLabelName)
                    {
                        this.LstBox_CsfLabels.Items.Add(csfLabel);
                    }
                    else
                    {
                        csfFile_labels.Add(csfLabel);
                    }
                    csfFile_stringsCount += csfLabel.Strings.Count;
                }
                if (this.LstBox_CsfLabels_SortByCsfLabelName)
                {
                    csfFile_labels.Sort((csfLabel1, csfLabel2) => string.Compare(csfLabel1.Name, csfLabel2.Name, StringComparison.Ordinal));
                    foreach (CSFLabel csfLabel in csfFile_labels)
                    {
                        this.LstBox_CsfLabels.Items.Add(csfLabel);
                    }
                }
                this.LstBox_CsfLabels.EndUpdate();
                this.StsStrp_Label_CsfFile_LabelsCount.Text  = Resources.LabelsCount + csfFile.Labels.Count;
                this.StsStrp_Label_CsfFile_StringsCount.Text = Resources.StringsCount + csfFile_stringsCount;
            }
        }