コード例 #1
0
ファイル: AddInsForm.cs プロジェクト: ivan45654/Gurux.Common
        /// <summary>
        /// Initializes a new instance of the AddIns form.
        /// </summary>
        public AddInsForm(GXAddInList addIns, bool showAddins, bool onlyNew)
        {
            InitializeComponent();
            //Update resources.
            this.CancelBtn.Text   = Resources.CancelTxt;
            this.NameCH.Text      = Resources.NameTxt;
            this.StateCH.Text     = Resources.State;
            this.InstalledCH.Text = Resources.Installed;
            this.AvailableCH.Text = Resources.Available;
            this.DownloadMnu.Text = Resources.Download;
            this.EnableMnu.Text   = Resources.Enable;
            this.Text             = Resources.AvailableAddIns;

            ShowAddins   = showAddins;
            AddIns       = addIns;
            OnlyNewItems = onlyNew;
            if (onlyNew)
            {
                this.Text = Resources.AvailableUpdatesTxt;
            }
            else
            {
                this.Text = Resources.ProtocolsTxt;
            }
            if (addIns.Count == 0)
            {
                listView1.Items.Add(Resources.FindingProtocols);
                OKBtn.Enabled = listView1.Enabled = false;
            }
            foreach (GXAddIn it in addIns)
            {
                //Show only new AddIns.
                if (onlyNew && (it.State != AddInStates.Available && it.State != AddInStates.Update))
                {
                    continue;
                }
                if (!ShowAddins && it.Type == GXAddInType.AddIn)
                {
                    continue;
                }
                //If installed protocols are shown.
                if (!onlyNew && it.Type == GXAddInType.Application)
                {
                    continue;
                }
                if (it.Type == GXAddInType.Application && string.Compare(it.Name, System.IO.Path.GetFileNameWithoutExtension(Application.ExecutablePath), true) != 0)
                {
                    continue;
                }
                if (onlyNew && !GXUpdateChecker.IsNewVersion(it.Version, it.InstalledVersion))
                {
                    continue;
                }
                ListViewItem li = listView1.Items.Add(it.Name);
                li.SubItems.Add(it.State.ToString());
                li.SubItems.Add(it.InstalledVersion);
                li.SubItems.Add(it.Version);
                li.Tag = it;
                UpdateState(li, it.State);
            }
            ThreadPool.QueueUserWorkItem(CheckUpdates, this);
        }
コード例 #2
0
ファイル: AddInsForm.cs プロジェクト: ivan45654/Gurux.Common
 void OnCheckUpdatesDone(GXAddInList list)
 {
     //If done first time.
     if (!listView1.Enabled)
     {
         listView1.Items.Clear();
         OKBtn.Enabled = listView1.Enabled = true;
         foreach (GXAddIn it in list)
         {
             //Show only new AddIns.
             if (OnlyNewItems && (it.State != AddInStates.Available && it.State != AddInStates.Update))
             {
                 continue;
             }
             if (!ShowAddins && it.Type == GXAddInType.AddIn)
             {
                 continue;
             }
             //If installed protocols are shown.
             if (!OnlyNewItems && it.Type == GXAddInType.Application)
             {
                 continue;
             }
             if (it.Type == GXAddInType.Application && string.Compare(it.Name, System.IO.Path.GetFileNameWithoutExtension(Application.ExecutablePath), true) != 0)
             {
                 continue;
             }
             if (!GXUpdateChecker.IsNewVersion(it.Version, it.InstalledVersion))
             {
                 continue;
             }
             ListViewItem li = listView1.Items.Add(it.Name);
             li.SubItems.Add(it.State.ToString());
             li.SubItems.Add(it.InstalledVersion);
             li.SubItems.Add(it.Version);
             li.Tag = it;
             UpdateState(li, it.State);
         }
     }
     else //Update exist items...
     {
         foreach (GXAddIn it in list)
         {
             //Show only new AddIns.
             if (OnlyNewItems && it.State != AddInStates.Available)
             {
                 continue;
             }
             if (!ShowAddins && it.Type == GXAddInType.AddIn)
             {
                 continue;
             }
             //If installed protocols are shown.
             if (!OnlyNewItems && it.Type == GXAddInType.Application)
             {
                 continue;
             }
             if (it.Type == GXAddInType.Application && string.Compare(it.Name, System.IO.Path.GetFileNameWithoutExtension(Application.ExecutablePath), true) != 0)
             {
                 continue;
             }
             if (!GXUpdateChecker.IsNewVersion(it.Version, it.InstalledVersion))
             {
                 continue;
             }
             ListViewItem item = null;
             foreach (ListViewItem li in listView1.Items)
             {
                 if (string.Compare(li.Text, it.Name, true) == 0)
                 {
                     item = li;
                     break;
                 }
             }
             if (item == null)
             {
                 item = listView1.Items.Add(it.Name);
                 item.SubItems.Add(it.InstalledVersion);
                 item.SubItems.Add(it.Version);
                 item.Tag = it;
             }
             else
             {
                 GXAddIn t = item.Tag as GXAddIn;
                 t.State = it.State;
             }
             UpdateState(item, it.State);
         }
     }
 }