示例#1
0
      public static int Compare(SwlVersion v1, SwlVersion v2) {
         if (v1.Major < v2.Major) {
            return -1;
         }

         if (v1.Major > v2.Major) {
            return 1;
         }

         if (v1.Minor < v2.Minor) {
            return -1;
         }

         if (v1.Minor > v2.Minor) {
            return 1;
         }

         if (v1.Release < v2.Release) {
            return -1;
         }

         if (v1.Release > v2.Release) {
            return 1;
         }

         return 0;
      }
示例#2
0
      public static SwlVersion FromVersion(Version ver) {
         SwlVersion v = new SwlVersion();

         v.Major = (byte)ver.Major;
         v.Minor = (byte)ver.Minor;
         v.Release = (UInt16)ver.Build;

         return v;
      }
示例#3
0
      public static SwlVersion FromUInt32(UInt32 versionNumber) {
         SwlVersion v = new SwlVersion();

         v.Major = (byte)(versionNumber & 0x000000FF);
         v.Minor = (byte)((versionNumber >> 8) & 0x000000FF);
         v.Release = (UInt16)((versionNumber >> 16) & 0x0000FFFF);

         return v;
      }
示例#4
0
      private void _btnAddOnClick(object sender, EventArgs e) {
         if (textConfigFile.Text == "") {
            MessageBox.Show(this, "Enter config package file", "Missing information", MessageBoxButtons.OK, MessageBoxIcon.Stop);
            return;
         }

         if (!File.Exists(textConfigFile.Text)) {
            MessageBox.Show(this, "Config package file not found", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
            return;
         }

         if (_installInfo.PlatformId.IsEmpty == true) {
            MessageBox.Show(this, "Select platform", "Missing information", MessageBoxButtons.OK, MessageBoxIcon.Stop);
            return;
         }

         if (textVersionNumber.Text == "") {
            MessageBox.Show(this, "Enter Version Number", "Missing information", MessageBoxButtons.OK, MessageBoxIcon.Stop);
            return;
         }

         var strs = textVersionNumber.Text.Split('.');
         if (strs.Length != 3) {
            MessageBox.Show(this, "Invalid version number", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
            return;
         }

         SwlVersion v = new SwlVersion();

         try {
            v.Major = byte.Parse(strs[0]);
            v.Minor = byte.Parse(strs[1]);
            v.Release = UInt16.Parse(strs[2]);
         } catch {
            MessageBox.Show(this, "Invalid version number", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
            return;
         }

         _installInfo.VersionNumber = v.ToInt32();
         if (_installInfo.VersionNumber == 0) {
            MessageBox.Show(this, "Invalid version number", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
            return;
         }

         if (textVersionDescription.Text == "") {
            MessageBox.Show(this, "Description is empty", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
            textVersionDescription.Focus();
            return;
         }

         _installInfo.Description = textVersionDescription.Text;

         _frmMsg = new FrmMsg("Copying new config...");
         _frmMsg.Owner = this;
         _frmMsg.Show(this);

         backgroundConfigAdd.RunWorkerAsync();
      }
示例#5
0
      private void _btnOpenOnClick(object sender, EventArgs e) {
         _imagePath = textVersionPath.Text;
         _imageFile = "";
         _platformID = 0;
         _version.Major = 0;
         _version.Minor = 0;
         _version.Release = 0;

         if (!Directory.Exists(_imagePath)) {
            MessageBox.Show(_imagePath, "SWL Image not found", MessageBoxButtons.OK, MessageBoxIcon.Stop);
            _imagePath = "";
            return;
         }

         _imageFile = Path.Combine(_imagePath, "SwlImage.bin");

         var imageHdr = Interop.GetImageHeader(_imageFile);
         if (imageHdr == null) {
            MessageBox.Show(_imagePath, "Problem to open SWL Image", MessageBoxButtons.OK, MessageBoxIcon.Stop);
            _imagePath = "";
            return;
         }

         textPlatformID.Text = string.Format("{0:X08}", imageHdr.Value.PlatformId);
         textPlatformVersion.Text = string.Format("{0}.{1}.{2}", imageHdr.Value.PlatformVersion.Major, imageHdr.Value.PlatformVersion.Minor, imageHdr.Value.PlatformVersion.Release);
         textPlatformName.Text = imageHdr.Value.PlatformName;

         textVersion.Text = string.Format("{0}.{1}.{2}", imageHdr.Value.Version.Major, imageHdr.Value.Version.Minor, imageHdr.Value.Version.Release);
         textDate.Text = string.Format("{0:0000}-{1:00}-{2:00} {3:00}:{4:00}", imageHdr.Value.Date.Year, imageHdr.Value.Date.Month, imageHdr.Value.Date.Day, imageHdr.Value.Date.Hour, imageHdr.Value.Date.Minute);
         textDescription.Text = imageHdr.Value.Desc;

         _platformID = imageHdr.Value.PlatformId;
         _version = imageHdr.Value.Version;

         btnAdd.Enabled = true;

         textCodeName.Enabled = true;
         textCodeName.Focus();
      }
示例#6
0
 public static bool CreatePackage(string masterPackageName, SwlVersion sourceVersion, string sourceDescriptor, string packageName) {
    return SwuApiMasterPackageCreatePackage(masterPackageName, sourceVersion, sourceDescriptor, packageName);
 }