コード例 #1
0
        public static void ShowPromptForm(Form parent, PromptState state, String message)
        {
            PromptForm pf = new PromptForm(state, message);

            //pf.TopLevel = false;
            //parent.Controls.Add(pf);
            //pf.Parent = parent;
            //pf.Location = new Point((parent.Width - pf.Width) / 2, (parent.Height - pf.Height) / 2);
            pf.StartPosition = FormStartPosition.CenterScreen;
            // pf.BringToFront();
            //pf.CenterToParent();
            pf.ShowDialog();
        }
コード例 #2
0
ファイル: Progress.cs プロジェクト: tiangtiang/autoUpdate
        //执行函数
        private void StartWork()
        {
            int count = 1;

            foreach (string name in update.UpdateList)
            {
                changeThisContent(String.Format("{0}/{1}: {2} 正在下载中...\n", count, update.UpdateList.Count, name));

                if (update.downloadFile(name))
                {      //下载文件
                    changeThisContent(String.Format("{0}/{1}: {2} 下载完成\n", count, update.UpdateList.Count, name));
                }
                else
                {
                    changeThisContent(String.Format("{0}/{1}: {2} 下载失败\n", count, update.UpdateList.Count, name));
                    FailedList.Add(name);
                }
                SetPos(count);
                count++;
            }
            SetPos(count);
            String messge = "";

            if (FailedList.Count == 0)
            {
                if (SuccessOrNot != null)
                {
                    SuccessOrNot(true);
                }
                messge = "更新完成";
            }
            else
            {
                if (SuccessOrNot != null)
                {
                    SuccessOrNot(false);
                }
                messge = "部分文件下载失败!将重新打开未更新前的系统";
            }
            UI.PromptForm promt  = new PromptForm(PromptState.Success, messge);
            DialogResult  result = promt.ShowDialog();

            if (result == DialogResult.Cancel)
            {
                update.closeConnect();
                closeThis();
            }
        }