示例#1
0
        private void menuItem_deletePage_Click(object sender, EventArgs e)
        {
            _isPressedCtrl = false;

            if (SelectedPage == null)
            {
                return;
            }
            if (!MessageBoxUtil.Confirm(Resource.GetString(Key.PageDeleteConfirmMsg)))
            {
                return;
            }
            if (SelectedPage.PageName == "Main")
            {
                MessageBoxUtil.Error(Resource.GetString(Key.PageDeleteErrorMsg));
                return;
            }

            DeletePage(SelectedPage);
            SelectedPage = null;

            var tab = tabControl_pages.SelectedTab;

            if (tab == null)
            {
                return;
            }

            tabControl_pages.TabPages.Remove(tab);
            tab.Dispose();
        }
示例#2
0
        private void buttonImportExcel_Click(object sender, EventArgs e)
        {
            var ofd = new OpenFileDialog();

            ofd.AddExtension = true;
            ofd.Filter       = "Excel文件|*.xlsx";
            if (ofd.ShowDialog() == DialogResult.OK)
            {
                var excelFilepath = ofd.FileName;
                try
                {
                    dataGridView1.Rows.Clear();
                    dataGridView1.Columns.Clear();
                    dataList = ExcelUtility.GetFromExcel(excelFilepath);
                    Utility.LoadData(dataGridView1, dataList);
                    _colNames             = dataList[0];
                    buttonMapping.Enabled = true;
                    Text = _title + " 路径:" + excelFilepath;
                }
                catch (Exception ex)
                {
                    MessageBoxUtil.Error(ex.Message);
                }
            }
        }
示例#3
0
        //入口
        static void Main(string[] args)
        {
#if DEBUG
            HostConfig.Init(FilePathUtil.GetAbsolutePath("Test\\" + HostConfig.DEFAULT_NAME));
#else
            HostConfig.Init(args == null || args.Length < 1 || string.IsNullOrEmpty(args[0]) ? FilePathUtil.GetAbsolutePath(HostConfig.DEFAULT_NAME) : args[0]);
            //必须从临时目录启动
            if (!AppConfig.ExecutablePath.Equals(AppConfig.ExpectExecutablePath, StringComparison.OrdinalIgnoreCase))
            {
                try
                {
                    File.Copy(AppConfig.ExecutablePath, AppConfig.ExpectExecutablePath, true);
                    ProcessUtil.Start(AppConfig.ExpectExecutablePath, HostConfig.ExecutablePath);
                }
                catch (Exception e)
                {
                    MessageBoxUtil.Error(e.Message);
                }
                return;
            }
#endif
            //运行
            Application.EnableVisualStyles();
            Application.SetCompatibleTextRenderingDefault(false);
            Application.Run(new FrmUpdate());
        }
示例#4
0
 static async Task ExceptionWrapper(Func <Task> func, string errorMessage)
 {
     try
     {
         await func();
     }
     catch (Exception)
     {
         MessageBoxUtil.Error(errorMessage);
     }
 }
示例#5
0
        private void StartDownload()
        {
            using (_wc = new WebClient())
            {
                _wc.DownloadFileCompleted += delegate(object sender, AsyncCompletedEventArgs e)
                {
                    _wc = null;
                    if (e.Cancelled)
                    {
                        File.Delete(_savePath);
                        MessageBoxUtil.Error(Resource.GetString(Key.DownloadCancelMsg));
                        DialogResult = DialogResult.Cancel;
                    }
                    else
                    {
                        DialogResult = DialogResult.OK;
                    }
                };
                _wc.DownloadProgressChanged += delegate(object sender, DownloadProgressChangedEventArgs e)
                {
                    string title = string.Format(label_title.Tag as string, e.BytesReceived, e.TotalBytesToReceive);
                    label_title.Text  = title;
                    label_per.Text    = string.Format("{0}%", e.ProgressPercentage);
                    progressBar.Value = e.ProgressPercentage;
                    if (e.ProgressPercentage > 0)
                    {
                        progressBar.Value  = e.ProgressPercentage - 1;
                        progressBar.Value += 1;
                    }
                };

                try
                {
                    if (_url.StartsWith("https://"))
                    {
                        ServicePointManager.Expect100Continue = true;
                        ServicePointManager.ServerCertificateValidationCallback = delegate { return(true); };
                        ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls | SecurityProtocolType.Tls11 | SecurityProtocolType.Tls12 | SecurityProtocolType.Ssl3;
                    }
                    _wc.DownloadFileAsync(new Uri(_url), _savePath);
                }
                catch (Exception e)
                {
                    Logger.Error(e);
                    DialogResult = DialogResult.Cancel;
                }
            }
        }
示例#6
0
        private void button_create_Click(object sender, EventArgs e)
        {
            string pageName = textBox_pageName.Text;

            if (string.IsNullOrWhiteSpace(pageName))
            {
                MessageBoxUtil.Error(Resource.GetString(Key.PageNameInputErrorMsg));
                return;
            }
            if (_pageNames.Contains(pageName))
            {
                MessageBoxUtil.Error(Resource.GetString(Key.PageNameAlreadyErrorMsg));
                return;
            }

            PageName     = pageName;
            DialogResult = DialogResult.OK;
        }
示例#7
0
        private void StartProcess()
        {
            try
            {
                // SpecialFolder 경로 취득
                var matches = Regex.Matches(FilePath, @"\{(.*?)\}");
                foreach (Match m in matches)
                {
                    string origin = m.Groups[0].ToString();

                    Environment.SpecialFolder folder;
                    if (!Enum.TryParse(m.Groups[1].ToString(), true, out folder))
                    {
                        continue;
                    }
                    string realPath = Environment.GetFolderPath(folder);
                    FilePath = FilePath.Replace(origin, realPath);
                }

                var si = new ProcessStartInfo();
                si.FileName = FilePath;

                // 네트워크 연결
                if (!FilePath.Contains("://"))
                {
                    if (StartWithAdministrator)
                    {
                        si.UseShellExecute = true;
                        si.Verb            = "runas";
                    }
                    si.Arguments        = Arguments;
                    si.WorkingDirectory = Path.GetDirectoryName(FilePath);
                }

                var proc = new Process();
                proc.StartInfo = si;
                proc.Start();
            }
            catch (Exception ex)
            {
                MessageBoxUtil.Error(ex.Message);
            }
        }
示例#8
0
        public async Task SetupAsync()
        {
            try
            {
                if (!_eventsSetup)
                {
                    SetupRaceEvents();
                }
                _currentSkier = await _activeRaceService.GetCurrentSkier(RaceState.Race.Id);
                await LoadStartList();

                await CurrentSkierViewModel.InitializeAsync();

                await RankingViewModel.InitializeAsync();
            }
            catch (Exception)
            {
                MessageBoxUtil.Error("Fehler beim Laden der Daten");
            }
        }
示例#9
0
 private void _worker_RunWorkerCompleted(object sender, RunWorkerCompletedEventArgs e)
 {
     if (e.Error != null)
     {
         var log = TraceLog.GetLogger <MainForm>();
         log.TraceEvent(System.Diagnostics.TraceEventType.Error, 0, e.Error.Message + "\r\n" + e.Error.StackTrace);
         log.Close();
         MessageBoxUtil.Error("导入出错:" + e.Error.Message);
     }
     else if (e.Cancelled)
     {
         MessageBoxUtil.Exclamation("导入取消!");
     }
     else
     {
         var msg = "导入完成!";
         if (_errFiles.Count > 0)
         {
             msg += "有对象未能被导入,请查看输出文件!";
         }
         MessageBox.Show(msg);
     }
     if (_errFiles.Count > 0)
     {
         var tPath = Path.GetTempPath();
         var tFile = Path.Combine(tPath, "已存在或创建失败列表" + DateTime.Now.ToString("-yyyy-MM-dd-HH-mm") + ".txt");
         using (var sw = new StreamWriter(tFile, false, Encoding.Default))
         {
             foreach (var tf in _errFiles)
             {
                 var err = "第" + (tf.Item1 + 1) + "行数据" + "\t原因:" + tf.Item2;
                 sw.WriteLine(err);
             }
             sw.Close();
         }
         System.Diagnostics.Process.Start(tFile);
     }
     ResetProgressBar();
 }