예제 #1
0
        private void AddFileInfoLabels()
        {
            var verInfoList = new List <FileVersionInfo>();
            var strArray    = CorePaths.FullAppsSuitePathMap;
            var verArray    = new Version[strArray.Length];

            for (var i = 0; i < strArray.Length; i++)
            {
                foreach (var file in strArray[i])
                {
                    try
                    {
                        var fvi = FileVersionInfo.GetVersionInfo(file);
                        verArray[i] = FileEx.GetVersion(fvi.FileName);
                        verInfoList.Add(fvi);
                    }
                    catch (Exception ex)
                    {
                        Log.Write(ex);
                    }
                }
            }

            var bottom = 0;

            foreach (var fvi in verInfoList)
            {
                var description = fvi.FileDescription;
                if (description.StartsWithEx("7z"))
                {
                    description = description.Replace("7z", "7-Zip");
                }
                if (!description.Contains("(64"))
                {
                    if (PortableExecutable.Is64Bit(fvi.FileName))
                    {
                        description += " (64-bit)";
                    }
                }
                var name = new Label
                {
                    AutoSize  = true,
                    BackColor = Color.Transparent,
                    Font      = new Font("Segoe UI", 12.25f, FontStyle.Bold, GraphicsUnit.Point),
                    ForeColor = Color.PowderBlue,
                    Location  = new Point(aboutInfoLabel.Left, bottom == 0 ? 15 : bottom + 10),
                    Text      = description
                };
                mainPanel.Controls.Add(name);
                Version reqVer;
                var     fna = Path.GetFileName(fvi.FileName);
                if (fna.EqualsEx(strArray.Second().Select(Path.GetFileName).ToArray()))
                {
                    reqVer = verArray.Second();
                }
                else if (fna.EqualsEx("7zG.exe") || fna.EqualsEx("7z.dll"))
                {
                    reqVer = verArray.Third();
                }
                else
                {
                    reqVer = verArray.First();
                }
                var curVer = FileEx.GetVersion(fvi.FileName);
                var strVer = curVer.ToString();
                if (!fna.EqualsEx("7zG.exe") && !fna.EqualsEx("7z.dll"))
                {
                    reqVer = Version.Parse(reqVer.ToString(3));
                    curVer = Version.Parse(curVer.ToString(3));
                }
                var version = new Label
                {
                    AutoSize  = true,
                    BackColor = name.BackColor,
                    Font      = new Font(name.Font.FontFamily, 8.25f, FontStyle.Regular, name.Font.Unit),
                    ForeColor = reqVer == curVer ? Color.PaleGreen : Color.OrangeRed,
                    Location  = new Point(name.Left + 3, name.Bottom),
                    Text      = strVer
                };
                mainPanel.Controls.Add(version);
                var separator = new Label
                {
                    AutoSize  = true,
                    BackColor = name.BackColor,
                    Font      = version.Font,
                    ForeColor = copyrightLabel.ForeColor,
                    Location  = new Point(version.Right, name.Bottom),
                    Text      = @"|"
                };
                mainPanel.Controls.Add(separator);
                var path = new Label
                {
                    AutoSize  = true,
                    BackColor = name.BackColor,
                    Font      = version.Font,
                    ForeColor = version.ForeColor,
                    Location  = new Point(separator.Right, name.Bottom),
                    Text      = fvi.FileName.RemoveText(PathEx.LocalDir).TrimStart(Path.DirectorySeparatorChar)
                };
                mainPanel.Controls.Add(path);
                bottom = path.Bottom;
            }

            Height += bottom;
            if (StartPosition == FormStartPosition.CenterScreen)
            {
                Top -= (int)Math.Floor(bottom / 2d);
            }
        }