Пример #1
0
 private void ctrlRemoveSelection_Click(object sender, EventArgs e)
 {
     if (lvApkList.SelectedItems.Count == 0)
     {
         return;
     }
     if (DialogResult.OK != MessageBox.Show(this, "确定要移除所选项吗?", "移除", MessageBoxButtons.OKCancel, MessageBoxIcon.Question))
     {
         return;
     }
     foreach (ListViewItem lvi in lvApkList.SelectedItems)
     {
         ApkList.Entry ae = (ApkList.Entry)lvi.Tag;
         apkList.Remove(ae);
     }
     RefreshCtrls();
 }
Пример #2
0
        private bool RefreshListView()
        {
            bool ok = true;

            lvApkList.BeginUpdate();
            try {
                lvApkList.Items.Clear();
                this.currentVersionCode = this.currentVersionName = null;
                ApkList.Entry firstEntry = null;
                foreach (ApkList.Entry entry in apkList)
                {
                    var lvItem = lvApkList.Items.Add(entry.Basename);
                    lvItem.Tag = entry;
                    lvItem.UseItemStyleForSubItems = false;
                    lvItem.SubItems.Add(entry.Directory);
                    lvItem.SubItems.Add((entry.FileSize / 1048576f).ToString("0.00 M"));
                    lvItem.SubItems.Add(entry.SignMD5);
                    lvItem.SubItems.Add(entry.MD5Hash);
                    lvItem.SubItems.Add(entry.AndriodManifest.VersionName);
                    lvItem.SubItems.Add(entry.AndriodManifest.VersionCode);
                    lvItem.SubItems.Add(entry.AndriodManifest.UmengChannel);
                    lvItem.SubItems.Add(entry.AndriodManifest.UmengKey);
                    lvItem.SubItems.Add(entry.AndriodManifest.JPushKey);
                    //
                    if (firstEntry == null)
                    {
                        firstEntry = entry;
                        this.currentVersionName = entry.AndriodManifest.VersionName;
                        this.currentVersionCode = entry.AndriodManifest.VersionCode;
                    }
                    if (IsEntryValid(firstEntry, entry, lvItem))
                    {
                        lvItem.ForeColor = Color.Green;
                    }
                    else
                    {
                        ok = false;
                    }
                }
            } finally {
                lvApkList.EndUpdate();
            }
            return(ok);
        }
Пример #3
0
        private static bool IsEntryValid(ApkList.Entry firstEntry, ApkList.Entry entry, ListViewItem lvItem)
        {
            bool result = true;
            //
            string signMD5 = entry.SignMD5;

            if (signMD5 == null || signMD5 != firstEntry.SignMD5 || !CheckEqualIfRequired(Config.Instance.ExpectedSignMD5, signMD5))
            {
                HighLightListViewSubItem(lvItem, 3);
                result = false;
            }
            string channel = entry.AndriodManifest.UmengChannel;

            if (channel == null)
            {
                HighLightListViewSubItem(lvItem, 7);
                result = false;
            }
            else if (!entry.Basename.Contains(channel))
            {
                lvItem.ForeColor = Color.Red;
                result           = false;
            }
            string versionName = entry.AndriodManifest.VersionName;

            if (versionName == null || versionName != firstEntry.AndriodManifest.VersionName)
            {
                HighLightListViewSubItem(lvItem, 5);
                result = false;
            }
            if (versionName != null && !entry.Basename.Contains(versionName))
            {
                lvItem.ForeColor = Color.Red;
                result           = false;
            }
            string versionCode = entry.AndriodManifest.VersionCode;

            if (versionCode == null || versionCode != firstEntry.AndriodManifest.VersionCode)
            {
                HighLightListViewSubItem(lvItem, 6);
                result = false;
            }
            if (versionCode != null && !entry.Basename.Contains(versionCode))
            {
                lvItem.ForeColor = Color.Red;
                result           = false;
            }
            string umengKey = entry.AndriodManifest.UmengKey;

            if (umengKey == null || umengKey != firstEntry.AndriodManifest.UmengKey || !CheckEqualIfRequired(Config.Instance.ExpectedUMengKey, umengKey))
            {
                HighLightListViewSubItem(lvItem, 8);
                result = false;
            }
            string jpushKey = entry.AndriodManifest.JPushKey;

            if (jpushKey == null || jpushKey != firstEntry.AndriodManifest.JPushKey || !CheckEqualIfRequired(Config.Instance.ExpectedJPushKey, jpushKey))
            {
                HighLightListViewSubItem(lvItem, 9);
                result = false;
            }
            return(result);
        }