示例#1
0
    /// <summary>
    /// Main Constructor for this class, pre-setting vital properties right away
    /// </summary>
    /// <param name="Name">File Name (String)</param>
    /// <param name="FullPath">Full Path of File (String)</param>
    /// <param name="Format">File Format as <see cref="FFormats"/></param>
    /// <param name="FTyp">Optional File Type as <see cref="FTypes"/>, Default = 'FTypes.ASCII'</param>
    /// <remarks></remarks>
    public FileListItem(string Name, string FullPath, FFormats Format, FTypes FTyp = FTypes.ASCII)
    {
        this.m_Name     = Name;
        this.m_FullPath = FullPath;
        this.m_Format   = Format;
        switch (Format)
        {
        case FFormats.us_ascii:
            this.m_Color = Color.Black;
            break;

        case FFormats.utf_16:
            this.m_Color = Color.Blue;
            break;

        case FFormats.utf_8:
            this.m_Color = Color.Red;
            break;

        default:
            this.m_Color = Color.Black;
            break;
        }
        this.m_Label           = new System.Windows.Forms.Label();
        this.m_Label.Text      = this.m_Name;
        this.m_Label.ForeColor = this.m_Color;
        this.m_Label.BackColor = Color.White;
        this.m_FType           = FTyp;
        MForm.Controls.Add(this.Label);
        //AddHandler Me.m_Label.Click, AddressOf filelistitem_click
        this.m_Selected = false;
        MForm.Controls.Add(this);
        ToolTipAndEvents(this, this.FullPath);
        ToolTipAndEvents(this.Label, this.FullPath);
    }
示例#2
0
    private static void AddFile(string sFile)
    {
        bool bAdd = true;

        sFile = Path.GetFullPath(sFile);
        if (sFile != "")
        {
            if (File.Exists(sFile) == false)
            {
                bAdd = false;
            }
            else
            {
                if (ConverterSupport.InputOutput.GetFileSizeNum(sFile) == 0)
                {
                    bAdd = false;
                }
            }
        }
        else
        {
            bAdd = false;
        }
        if (Data.ListInputFiles.Count > 0 & bAdd == true)
        {
            for (int a = 0; a <= Data.ListInputFiles.Count - 1; a++)
            {
                if (Data.ListInputFiles[a].FullPath.Equals(sFile))
                {
                    bAdd = false;
                }
            }
        }
        if (bAdd == true)
        {
            FFormats ff = (FFormats)ConverterSupport.InputOutput.checkFileFormat(sFile);
            FTypes   ft;
            if (ff == FFormats.us_ascii)
            {
                ft = (FTypes)ConverterSupport.InputOutput.DetermineFileType(sFile);
            }
            else
            {
                ft = FTypes.Unicode;
            }
            if (ft != iOutFormat)
            {
                aFTCounts[(int)ft] += 1;
                Data.ListInputFiles.Add(new FileListItem(Path.GetFileName(sFile), sFile, (global::FFormats)ff, (global::FTypes)ft));
            }
        }
    }
示例#3
0
 //New
 /// <summary>
 /// Default constructor without any pre-set parameters
 /// </summary>
 /// <remarks></remarks>
 public FileListItem()
 {
     this.m_Name            = "";
     this.m_FullPath        = "";
     this.m_Format          = FFormats.us_ascii;
     this.m_Color           = Color.Red;
     this.m_Label           = new System.Windows.Forms.Label();
     this.m_Label.Text      = this.m_Name;
     this.m_Label.ForeColor = this.m_Color;
     this.m_Label.BackColor = Color.White;
     this.m_FType           = FTypes.ASCII;
     //AddHandler Me.m_Label.Click, AddressOf filelistitem_click
     this.m_Selected = false;
     MForm.Controls.Add(this.Label);
     MForm.Controls.Add(this);
     ToolTipAndEvents(this, this.FullPath);
     ToolTipAndEvents(this.Label, this.FullPath);
 }
示例#4
0
        public static FFormats checkFileFormat(string sFile)
        {
            int ReadTo = 3;

            byte[] Buf = new byte[] {
                0,
                0,
                0
            };
            FFormats   sRes = FFormats.us_ascii;
            int        i    = 0;
            FileStream ofile;

            if (File.Exists(sFile))
            {
                if (GetFileSizeNum(sFile) > 0)
                {
                    ofile = File.Open(sFile, FileMode.Open, FileAccess.Read);
                    ofile.Seek(0, SeekOrigin.Begin);
                    while (i < ReadTo)
                    {
                        Buf[i] = (byte)ofile.ReadByte();
                        i     += 1;
                    }
                    ofile.Close();
                    if (Buf[0] == 239 & Buf[1] == 187 & Buf[2] == 191)
                    {
                        sRes = FFormats.utf_8;
                    }
                    else
                    {
                        if (Buf[0] == 255 & Buf[1] == 254)
                        {
                            sRes = FFormats.utf_16;
                        }
                    }
                }
            }
            return(sRes);
        }