Exemple #1
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="AfileName"></param>
        /// <returns></returns>
        public Boolean OpenCsvFile(String AfileName)
        {
            // We don't need to read the whole file for this because we will only display the first 5 lines
            bool hasBOM, isAmbiguousUTF;

            if (TTextFile.AutoDetectTextEncodingAndOpenFile(AfileName, out FFileContent, out FCurrentEncoding,
                                                            out hasBOM, out isAmbiguousUTF, out FRawBytes) == false)
            {
                return(false);
            }

            TTextFileEncoding.SetComboBoxProperties(cmbTextEncoding, hasBOM, isAmbiguousUTF, FCurrentEncoding);
            DisplayGrid();
            return(true);
        }
Exemple #2
0
        /// <summary>
        /// constructor
        /// TODO: select if first row contains captions? or use a parameter to avoid or request captions?
        /// </summary>
        public TDlgSelectCSVSeparator(bool AFileHasCaption)
        {
            FFileHasCaption = AFileHasCaption;

            //
            // The InitializeComponent() call is required for Windows Forms designer support.
            //
            InitializeComponent();
            #region CATALOGI18N

            // this code has been inserted by GenerateI18N, all changes in this region will be overwritten by GenerateI18N
            this.rbtComma.Text            = Catalog.GetString("Comma");
            this.rbtTabulator.Text        = Catalog.GetString("Tab");
            this.rbtOther.Text            = Catalog.GetString("Other Separator") + ":";
            this.rbtSemicolon.Text        = Catalog.GetString("Semicolon");
            this.btnCancel.Text           = Catalog.GetString("Cancel");
            this.btnOK.Text               = Catalog.GetString("OK");
            this.lblNumberFormat.Text     = Catalog.GetString("Number format") + ":";
            this.lblNumberFormatHint.Text = Catalog.GetString("Number format Hint") + ":";
            this.lblDateFormat.Text       = Catalog.GetString("Ambiguous dates") + ":";
            this.lblDateFormatHint.Text   = Catalog.GetString("Date format Hint") + ":";
            this.lblTextEncoding.Text     = Catalog.GetString("Text encoding") + ":";
            this.lblTextEncodingHint.Text = Catalog.GetString("Hint: Where a choice of encodings exists, a file exported from OpenPetra or Excel");
            this.Text = Catalog.GetString("Select CSV Separator");
            #endregion

            FSeparator = TAppSettingsManager.GetValue("CSVSeparator",
                                                      System.Globalization.CultureInfo.CurrentCulture.TextInfo.ListSeparator);

            System.Globalization.CultureInfo myCulture = System.Threading.Thread.CurrentThread.CurrentCulture;

            //if (!cmbDateFormat.Items.Contains(regionalDateString))
            //{
            //    cmbDateFormat.Items.Insert(0, regionalDateString);
            //}

            //cmbDateFormat.SelectedIndex = cmbDateFormat.Items.IndexOf(regionalDateString);

            DateFormat = myCulture.DateTimeFormat.ShortDatePattern;
            cmbNumberFormat.SelectedIndex = cmbNumberFormat.Items.IndexOf(myCulture.NumberFormat.NumberDecimalSeparator);

            TTextFileEncoding dataSource = new TTextFileEncoding();
            this.cmbTextEncoding.ValueMember   = TTextFileEncoding.ColumnCodeDbName;
            this.cmbTextEncoding.DisplayMember = TTextFileEncoding.ColumnDescriptionDbName;
            this.cmbTextEncoding.DataSource    = dataSource.DefaultView;

            UpdateRadioButtons();
        }