Пример #1
0
        public static string Calculate(int digits, int startingAt)
        {
            System.ComponentModel.DoWorkEventArgs eventArgs = new System.ComponentModel.DoWorkEventArgs(digits);

            CalculatePi(typeof(PiCalculator), eventArgs, startingAt);
            return (string)eventArgs.Result;
        }
Пример #2
0
 public TVDBLoader(AbstractRepositoryFactory _repositories,
     System.ComponentModel.BackgroundWorker _worker,
     System.ComponentModel.DoWorkEventArgs _eventArgs)
 {
     repositories = _repositories;
     worker = _worker;
     eventArgs = _eventArgs;
 }
Пример #3
0
 public XLSLoader(string _filename,
     AbstractRepositoryFactory _factory,
     System.ComponentModel.BackgroundWorker _worker,
     System.ComponentModel.DoWorkEventArgs _eventArgs)
 {
     factory = _factory;
     filename = _filename;
     worker = _worker;
     eventArgs = _eventArgs;
 }
Пример #4
0
        private void bgwScan_DoWork(object sender, System.ComponentModel.DoWorkEventArgs e)
        {
            string ret = scanScreen();

            bgwScan.ReportProgress(0, ret);
        }
Пример #5
0
 private void installer_DoWork(object sender, DoWorkEventArgs e)
 {
     List<DownloadInfo> downloads = (List<DownloadInfo>)e.Argument;
        ProgressManager progress = new ProgressManager();
        progress.Total = downloads.Count;
        foreach (DownloadInfo download in downloads)
        {
     ++progress.Completed;
     try
     {
      installer_ProgressChanged(download,
       new ProgressChangedEventArgs(progress, null));
      download.Install();
      installer_ProgressChanged(download,
       new ProgressChangedEventArgs(progress, null));
     }
     catch (Exception ex)
     {
      installer_ProgressChanged(download,
       new ProgressChangedEventArgs(progress, ex));
     }
        }
        e.Result = e.Argument;
 }
 private void backgroundWorkerAddReferences_DoWork(object sender, System.ComponentModel.DoWorkEventArgs e)
 {
     AddMainFunctionAssemblyToProjectResolver();
 }
Пример #7
0
 private void effaceAsyncCall(object sender, System.ComponentModel.DoWorkEventArgs e)
 {
     e.Result = effaceData(([email protected])((Hashtable)(e.Argument))["connexionOpenERP"]);
 }
Пример #8
0
        private void exeSearcherSlave_DoWork(object sender, System.ComponentModel.DoWorkEventArgs e)
        {
            const string uninstallkey  = "SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Uninstall\\";
            const string uninstallkey2 = "SOFTWARE\\Wow6432Node\\Microsoft\\Windows\\CurrentVersion\\Uninstall\\";
            var          w3            = "";
            var          wcc           = "";

            try
            {
                Parallel.ForEach(Registry.LocalMachine.OpenSubKey(uninstallkey)?.GetSubKeyNames(), item =>
                {
                    var programName = Registry.LocalMachine.OpenSubKey(uninstallkey + item)
                                      ?.GetValue("DisplayName");
                    var installLocation = Registry.LocalMachine.OpenSubKey(uninstallkey + item)
                                          ?.GetValue("InstallLocation");
                    if (programName != null && installLocation != null)
                    {
                        if (programName.ToString().Contains("Witcher 3 Mod Tools"))
                        {
                            wcc = Directory.GetFiles(installLocation.ToString(), "wcc_lite.exe",
                                                     SearchOption.AllDirectories).First();
                        }

                        if (programName.ToString().Contains("The Witcher 3 - Wild Hunt") ||
                            programName.ToString().Contains("The Witcher 3: Wild Hunt"))
                        {
                            w3 = Directory.GetFiles(installLocation.ToString(), "witcher3.exe",
                                                    SearchOption.AllDirectories).First();
                        }
                    }

                    exeSearcherSlave.ReportProgress(0, new Tuple <string, string, int, int>(w3, wcc, 0, 0));
                });
                Parallel.ForEach(Registry.LocalMachine.OpenSubKey(uninstallkey2)?.GetSubKeyNames(), item =>
                {
                    var programName = Registry.LocalMachine.OpenSubKey(uninstallkey2 + item)
                                      ?.GetValue("DisplayName");
                    var installLocation = Registry.LocalMachine.OpenSubKey(uninstallkey2 + item)
                                          ?.GetValue("InstallLocation");
                    if (programName != null && installLocation != null)
                    {
                        if (programName.ToString().Contains("Witcher 3 Mod Tools"))
                        {
                            wcc = Directory.GetFiles(installLocation.ToString(), "wcc_lite.exe",
                                                     SearchOption.AllDirectories).First();
                        }

                        if (programName.ToString().Contains("The Witcher 3 - Wild Hunt") ||
                            programName.ToString().Contains("The Witcher 3: Wild Hunt"))
                        {
                            w3 = Directory.GetFiles(installLocation.ToString(), "witcher3.exe",
                                                    SearchOption.AllDirectories).First();
                        }
                    }

                    exeSearcherSlave.ReportProgress(0, new Tuple <string, string, int, int>(w3, wcc, 0, 0));
                });
            }
            catch (Exception ex)
            {
                Console.Error.WriteLine(ex.ToString());
            }
        }
Пример #9
0
 private void bgWorker2_DoWork(object sender, System.ComponentModel.DoWorkEventArgs e)
 {
     Invoke((MethodInvoker)PopulateCombobox);
 }
Пример #10
0
 /// <summary>
 /// This function runs when RunWorkerAsync() is called by the button state BackgroundWorker object.
 /// </summary>
 /// <param name="sender">
 /// The BackgroundWorker that triggered the event.
 /// </param>
 /// <param name="e">
 /// Data specific to this event.
 /// </param>
 private void DoButtonStateWork(object sender, System.ComponentModel.DoWorkEventArgs e)
 {
     this.UpdateUserAdministratorStatus();
 }
Пример #11
0
 private void backspeak_DoWork(object sender, System.ComponentModel.DoWorkEventArgs e)
 {
     Myhelper.Speak(hi.Text + ",请问你是谁?");
 }
Пример #12
0
        private void compareWorker_DoWork(object sender, System.ComponentModel.DoWorkEventArgs e)
        {
            var errorList = new List <string>();

            outputBox.Text = "";
            var settings = e.Argument as CompareSetting;

            if (settings == null)
            {
                return;
            }

            #region 加载原数据库信息

            List <DbTable> source;
            if (string.IsNullOrEmpty(settings.SrcFile))
            {
                source = DbHelper.GetDbTables(settings.SrcConnString, settings.SrcDbName);
                foreach (var table in source)
                {
                    table.LoadColumns(settings.SrcConnString, settings.SrcDbName);
                }
            }
            else
            {
                try
                {
                    source = JsonConvert.DeserializeObject <List <DbTable> >(File.ReadAllText(settings.SrcFile));
                }
                catch (Exception ex)
                {
                    e.Result = new WorkerResult
                    {
                        Success = false,
                        Message = "错误:" + ex.Message
                    };
                    return;
                }
            }

            #endregion

            #region 加载目标数据库

            var target = DbHelper.GetDbTables(settings.TargetConnString, settings.TargetDbName);
            foreach (var dbTable in target)
            {
                dbTable.LoadColumns(settings.TargetConnString, settings.TargetDbName);
            }

            #endregion

            #region 比较数据表

            foreach (var sTable in source)
            {
                var tTable = target.FirstOrDefault(x => x.TableName.Equals(sTable.TableName, StringComparison.InvariantCultureIgnoreCase));
                if (tTable == null)
                {
                    ShowError(ref errorList, $"数据表 \"{sTable.TableName}\" 在目标数据库中不存在。");
                    continue;
                }
                #region 比较每一列

                foreach (var sColumn in sTable.Columns)
                {
                    var tColumn = tTable.Columns.FirstOrDefault(x => x.ColumnName.Equals(sColumn.ColumnName, StringComparison.InvariantCultureIgnoreCase));
                    if (tColumn == null)
                    {
                        ShowError(ref errorList, $"数据表 \"{sTable.TableName}\" 中的列 \"{sColumn.ColumnName}\" 在目标数据库中不存在。");
                        continue;
                    }
                    if (sColumn.IsPrimaryKey != tColumn.IsPrimaryKey)
                    {
                        ShowError(ref errorList, $"数据表 \"{sTable.TableName}\" 中的列 \"{sColumn.ColumnName}\" 在原数据库中 '主键' 属性已被改变。原数据库主键:{sColumn.IsPrimaryKey},目标数据库主键:{tColumn.IsPrimaryKey}。");
                    }
                    if (sColumn.IsNullable != tColumn.IsNullable)
                    {
                        ShowError(ref errorList, $"数据表 \"{sTable.TableName}\" 中的列 \"{sColumn.ColumnName}\" 在原数据库中 '可为空' 属性已被改变。原数据库可为空:{sColumn.IsNullable},目标数据库可为空:{tColumn.IsNullable}。");
                    }
                    if (sColumn.DbType != tColumn.DbType)
                    {
                        ShowError(ref errorList, $"数据表 \"{sTable.TableName}\" 中的列 \"{sColumn.ColumnName}\" 在原数据库中 '数据类型' 属性已被改变。原数据库数据类型:{sColumn.DbType},目标数据库数据类型:{tColumn.DbType}。");
                    }
                }
                foreach (var tColumn in tTable.Columns)
                {
                    var sColumn = sTable.Columns.FirstOrDefault(x => x.ColumnName.Equals(tColumn.ColumnName, StringComparison.InvariantCultureIgnoreCase));
                    if (sColumn == null)
                    {
                        ShowError(ref errorList, $"数据表 \"{tTable.TableName}\" 中的列 \"{tColumn.ColumnName}\"  在原数据库中已被删除。");
                    }
                }
                #endregion
            }
            foreach (var tTable in target)
            {
                var sTable = source.FirstOrDefault(x => x.TableName.Equals(tTable.TableName, StringComparison.InvariantCultureIgnoreCase));
                if (sTable == null)
                {
                    ShowError(ref errorList, $"数据表 \"{tTable.TableName}\" 在原数据库中已被删除。");
                }
            }
            if (errorList.Count > 0)
            {
                var msg = string.Join("\r\n", errorList);
                e.Result = new WorkerResult
                {
                    Success    = false,
                    Message    = msg,
                    SourceConn = settings.SrcConnString,
                    TargetConn = settings.TargetConnString
                };
            }
            else
            {
                e.Result = new WorkerResult
                {
                    Success    = true,
                    Message    = "检测已完成,完全匹配!",
                    TargetConn = settings.TargetConnString,
                    SourceConn = settings.SrcConnString
                };
            }
            #endregion
        }
Пример #13
0
        void progress_DoWork(object sender, System.ComponentModel.DoWorkEventArgs e)
        {
            var moduleSprite = currently_editing_animation.Owner as ModuleSprite;

            if (moduleSprite != null)
            {
                var   ownerModule = moduleSprite.GetFirstModule <AnimationModule>();
                float x           = (target + 1) * currently_editing_animation.Width;
                float y           = 0;
                for (int i = 0; i < currently_editing_animation.Row; i++)
                {
                    y += ownerModule.Animations[i].Height;
                }

                float width  = currently_editing_animation.Width * currently_editing_animation.Frames;
                float height = y + currently_editing_animation.Height;

                var result     = new Bitmap((int)width + currently_editing_animation.Width, (int)height);
                int totalWidth = Math.Max(sprite.Texture.Bitmap.Width, result.Width);
                var final      = new Bitmap(totalWidth, sprite.Texture.Bitmap.Height);

                using (var g = Graphics.FromImage(result))
                {
                    //Move current frames over
                    g.DrawImage(sprite.Texture.Bitmap, new RectangleF(x + currently_editing_animation.Width, 0, width, currently_editing_animation.Height), new RectangleF(x, y, width, height), GraphicsUnit.Pixel);
                    progress.ReportProgress(25, null, "Moving frames over");

                    //Place new image
                    g.DrawImage(newImage, new RectangleF(x, 0, currently_editing_animation.Width, currently_editing_animation.Height), new RectangleF(0, 0, currently_editing_animation.Width, currently_editing_animation.Height), GraphicsUnit.Pixel);
                    progress.ReportProgress(50, null, "Placing new frame");

                    //Place all frames behind it
                    if (x > 0)
                    {
                        g.DrawImage(sprite.Texture.Bitmap, new RectangleF(0f, 0, x, height), new RectangleF(0f, y, x, height), GraphicsUnit.Pixel);
                    }
                }

                using (var finalG = Graphics.FromImage(final))
                {
                    //Draw entire texture to bitmap
                    finalG.DrawImage(sprite.Texture.Bitmap, new RectangleF(0, 0, sprite.Texture.Bitmap.Width, sprite.Texture.Bitmap.Height), new RectangleF(0, 0, sprite.Texture.Bitmap.Width, sprite.Texture.Bitmap.Height), GraphicsUnit.Pixel);

                    //Fill animation with nothing
                    finalG.CompositingMode = System.Drawing.Drawing2D.CompositingMode.SourceCopy;
                    using (var br = new System.Drawing.SolidBrush(System.Drawing.Color.FromArgb(0, 255, 255, 255)))
                    {
                        finalG.FillRectangle(br, x, y, width + currently_editing_animation.Width, height);
                    }

                    //Place new animation
                    finalG.DrawImage(result, new RectangleF(0, y, width + currently_editing_animation.Width, height), new RectangleF(0, 0, result.Width, result.Height), GraphicsUnit.Pixel);
                }

                progress.ReportProgress(75, null, "Saving image..");
                final.Save(this.image);

                progress.ReportProgress(100, null, "Reloading..");
                Dispatcher.Invoke(new Action(delegate
                {
                    RewriteJsonForFrames(1);
                    Button_Click(null, null);
                    Preview.IsSelected = true;
                    Thread.Sleep(1500);
                    TabEditor.IsSelected = true;
                }));
                result.Dispose();
            }
        }
Пример #14
0
        //后台线程执行
        private void bgw_DoWork(object sender, System.ComponentModel.DoWorkEventArgs e)
        {
            //根据本地ip地址获取局域网计算机列表
            //取 192.168.1. ip地址段
            ScanBtn.Enabled       = false;
            CancelScanBtn.Enabled = true;//激活终止扫描按钮
            string[] splitedIP = ips.GetSplitedIP(ips.GetLocalIP());
            //192.168.1.
            string IPblock = splitedIP[0] + "." + splitedIP[1] + "." + splitedIP[2] + ".";

            if (ips.GetLocalIP() == "127.0.0.1")
            {
                MessageBox.Show(this, "发生Ping异常,请检查您的网络连接,查看网线是否意外断开,或者禁用了本地连接等." + "\r\n" +
                                "如果遇到网络延迟值极高的问题,请联系网络管理员."
                                , "错误", MessageBoxButtons.OK, MessageBoxIcon.Error);
                IsWireConn            = false;
                ScanprogressBar.Value = 0;
                return;
            }
            //从1到255逐个ping
            for (int i = 1; i <= 255; i++)
            {
                ListViewItem items = new ListViewItem(); //列表项
                if (bgw.CancellationPending)             //如果CancelAsync()则取消操作
                {
                    return;
                }
                try
                {
                    if (ping.Send(IPblock + i.ToString(), 6).Status == IPStatus.Success)
                    {
                        result = IPblock + i.ToString();
                        items  = OnlinePCLstv.Items.Add(result);
                        //计算机名无法获取的情况
                        try
                        {
                            items.SubItems.Add(ips.GetRemoteHostNameByIP(result));
                        }
                        catch (Exception) { items.SubItems.Add("无法获取计算机名"); }
                        items.EnsureVisible();
                    }
                    bgw.ReportProgress(i);
                }
                catch (Exception)/*但是在扫描的时候可能会被断开网络连接,当断开时,提示*/
                {
                    //提示错误
                    MessageBox.Show(this, "发生Ping异常,请检查您的网络连接,查看网线是否意外断开,或者禁用了本地连接等." + "\r\n" +
                                    "如果遇到网络延迟值极高的问题,请联系网络管理员."
                                    , "错误", MessageBoxButtons.OK, MessageBoxIcon.Error);

                    ScanprogressBar.Value = 0;
                    //网线断开
                    IsWireConn = false;
                    mainFrm_Load(sender, e);
                    SelectedIPTxt.Clear();
                    return;
                }

                ProcLbl.Text = i.ToString();
            }
        }
Пример #15
0
        private void backgroundWorker_DoWork(object sender, System.ComponentModel.DoWorkEventArgs e)
        {
            var parms = (object[])e.Argument;

            var profile     = (MailboxProfile)parms[0];
            var storagePath = (String)parms[1];

            int total = 0, uploaded = 0;

            if (radioButtonMSG.Checked)
            {
                // Collect and upload msg files!!
                var files = Directory.GetFiles(textBoxPath.Text, "*.eml", SearchOption.AllDirectories)
                            .Concat(Directory.GetFiles(textBoxPath.Text, "*.msg", SearchOption.AllDirectories));

                progressBar.Invoke(new Action(() =>
                {
                    progressBar.Minimum = 0;
                    progressBar.Maximum = files.Count();
                    progressBar.Value   = 0;
                }));

                foreach (var file in files)
                {
                    total++;

                    if (UploadMessage(file, profile, storagePath))
                    {
                        uploaded++;
                    }

                    backgroundWorker.ReportProgress(0);
                }
            }
            else
            {
                // Process pst file
                using (PersonalStorage pst = PersonalStorage.FromFile(textBoxPath.Text, false))
                {
                    var inbox = pst.RootFolder.GetSubFolders().Where(f => f.DisplayName.ToUpper() == "INBOX").FirstOrDefault();

                    if (inbox != null)
                    {
                        var entries = inbox.EnumerateMessagesEntryId();

                        progressBar.Invoke(new Action(() =>
                        {
                            progressBar.Minimum = 0;
                            progressBar.Maximum = entries.Count();
                            progressBar.Value   = 0;
                        }));

                        try
                        {
                            foreach (var entry in entries)
                            {
                                total++;

                                pst.ExtractMessage(entry).Save("temp.msg");

                                if (UploadMessage("temp.msg", profile, storagePath))
                                {
                                    uploaded++;
                                }

                                backgroundWorker.ReportProgress(0);
                            }
                        }
                        finally
                        {
                            File.Delete("temp.msg");
                        }
                    }
                }
            }

            e.Result = new int[] { total, uploaded };
        }
Пример #16
0
 private void backlogin_DoWork(object sender, System.ComponentModel.DoWorkEventArgs e)
 {
     Myhelper.Speak(user.uname + "!欢迎使用仓库管理系统!");
 }
Пример #17
0
			public void InitializeBackgroundWorker(object sender, System.ComponentModel.DoWorkEventArgs args)
			{
				BgWorker = sender as System.ComponentModel.BackgroundWorker;
				BgWorkerArgs = args;
			}
Пример #18
0
        protected override void bgw_DoWork(object sender, System.ComponentModel.DoWorkEventArgs e)
        {
            try
            {
                using (DamWCFContext dam6Entities = new DamWCFContext(false))
                {
                    ResetConnectionString(dam6Entities);

                    using (EF5x.Models.DamDBContext dam5Entities = new EF5x.Models.DamDBContext())
                    {
                        ResetConnectionString(dam5Entities);
                        _allRowCnt = dam5Entities.ConstantParams.Count();
                        foreach (var item in dam5Entities.ConstantParams.AsNoTracking())
                        {
                            var id = (from i in dam6Entities.Apps.AsNoTracking()
                                      where i.AppName == item.appName
                                      select i).First().Id;

                            if (dam6Entities.ConstantParams.FirstOrDefault(i => i.Id == item.ConstantParamID) == null)
                            {
                                var newItem = new ConstantParam();

                                newItem.AppId       = id;
                                newItem.Id          = item.ConstantParamID;
                                newItem.Description = item.Description;

                                newItem.Order = item.Order == null?(byte)0:item.Order.Value;

                                newItem.ParamName   = item.ParamName;
                                newItem.ParamSymbol = item.ParamSymbol;

                                newItem.PrecisionNum = item.PrecisionNum == null ? (byte)0 : item.PrecisionNum.Value;

                                newItem.UnitSymbol = item.UnitSymbol;
                                newItem.Val        = item.Val.Value;


                                dam6Entities.ConstantParams.Add(newItem);


                                dam6Entities.SaveChanges();
                                dam6Entities.Entry(newItem).State = System.Data.Entity.EntityState.Detached;;
                            }
                            handledCnt++;
                            reportProgress();
                        }
                    }
                }
                reportProgress();

                bgwResult = "导入成功!";
            }
            catch (Exception ex)
            {
                if (ex.InnerException != null)
                {
                    bgwResult = ex.InnerException.Message;
                }
                else
                {
                    bgwResult = ex.Message;
                }
            }
        }
Пример #19
0
 protected virtual void OnDoWork(System.ComponentModel.DoWorkEventArgs e)
 {
 }
Пример #20
0
        private void Worker_DoWork(object sender, System.ComponentModel.DoWorkEventArgs e)
        {
            Image image   = (Image)e.Argument;
            var   minSize = new Size(3840, 2160);
            Size  newSize;

            if (image.Width < minSize.Width || image.Height < minSize.Height)
            {
                var ratio = Math.Max((double)minSize.Width / image.Width, (double)minSize.Height / image.Height);
                newSize = new Size((int)(ratio * image.Width), (int)(ratio * image.Height));
            }
            else
            {
                newSize = image.Size;
            }
            var newRect = new Rectangle(Point.Empty, newSize);

            Emgu.CV.Image <Emgu.CV.Structure.Bgr, byte> cvImage;
            using (var bitmap = new Bitmap(newSize.Width, newSize.Height, PixelFormat.Format24bppRgb)) {
                using (var graphics = Graphics.FromImage(bitmap)) {
                    graphics.CompositingQuality = CompositingQuality.HighQuality;
                    graphics.InterpolationMode  = InterpolationMode.HighQualityBicubic;
                    graphics.SmoothingMode      = SmoothingMode.HighQuality;
                    graphics.PixelOffsetMode    = PixelOffsetMode.HighQuality;

                    using (var wrapMode = new ImageAttributes()) {
                        wrapMode.SetWrapMode(WrapMode.TileFlipXY);
                        graphics.DrawImage(image, newRect, 0, 0, image.Width, image.Height, GraphicsUnit.Pixel, wrapMode);
                    }
                }

                Invoke(new Action(() => {
                    if (screenshotViewer == null)
                    {
                        screenshotViewer = new ScreenshotViewer(this)
                        {
                            Top = Top, Left = Right
                        }
                    }
                    ;
                    screenshotViewer.SetImage(new Bitmap(bitmap));
                    screenshotViewer.Show();
                }));

                var data   = bitmap.LockBits(newRect, ImageLockMode.ReadOnly, PixelFormat.Format24bppRgb);
                var nBytes = data.Stride * data.Height;
                cvImage = new Emgu.CV.Image <Emgu.CV.Structure.Bgr, byte>(newSize);
                unsafe {
                    Buffer.MemoryCopy(data.Scan0.ToPointer(), cvImage.Mat.DataPointer.ToPointer(), nBytes, nBytes);
                }
                bitmap.UnlockBits(data);
            }

            if (sift == null)
            {
                sift = new Emgu.CV.Features2D.SIFT(edgeThreshold: 25, sigma: 1.2);
            }
            if (matcher == null)
            {
                var use_bf = true;
                if (use_bf)
                {
                    matcher = new Emgu.CV.Features2D.BFMatcher(Emgu.CV.Features2D.DistanceType.L2);
                }
                else
                {
                    matcher = new Emgu.CV.Features2D.FlannBasedMatcher(new Emgu.CV.Flann.KdTreeIndexParams(5), new Emgu.CV.Flann.SearchParams());
                }
            }

            if (heroDescriptors == null)
            {
                Invoke(new Action(() => {
                    screenshotViewer.SetProgress(Stage.LoadingData);
                }));
                heroDescriptors   = loadDescriptors("portraits.zip");
                bgnameDescriptors = loadDescriptors("bgnames.zip");
            }

            int nTotal   = heroDescriptors.Count + bgnameDescriptors.Count;
            int nCurrent = 0;

            using (var kp = new Emgu.CV.Util.VectorOfKeyPoint())
                using (var des = new Emgu.CV.Mat()) {
                    Invoke(new Action(() => {
                        screenshotViewer.SetProgress(Stage.ProcessingImage);
                    }));
                    sift.DetectAndCompute(cvImage, null, kp, des, false);
                    cvImage.Dispose();

                    var searchResults = new List <SearchResult>();
                    Invoke(new Action(() => {
                        screenshotViewer.SetProgress(0.0);
                    }));
                    foreach (var kvp in heroDescriptors)
                    {
                        using (var vMatches = new Emgu.CV.Util.VectorOfVectorOfDMatch()) {
                            matcher.KnnMatch(kvp.Value, des, vMatches, 2);
                            const float maxdist = 0.7f;
                            var         matches = vMatches.ToArrayOfArray().Where(m => m[0].Distance < maxdist * m[1].Distance).ToList();
                            if (matches.Any())
                            {
                                searchResults.Add(new SearchResult(kvp.Key, matches, kp));
                            }
                        }
                        nCurrent++;
                        Invoke(new Action(() => {
                            screenshotViewer.SetProgress((double)nCurrent / nTotal);
                        }));
                    }
                    searchResults.Sort((a, b) => - a.Distance.CompareTo(b.Distance));
                    searchResults.RemoveAll(t => searchResults.Take(searchResults.IndexOf(t)).Select(u => u.Name).Contains(t.Name));
                    var bans_picks = searchResults.Take(16).OrderBy(t => t.Location.Y).ToList();
                    var bans       = bans_picks.Take(6).OrderBy(t => t.Location.X).ToList();
                    var picks      = bans_picks.Skip(6).OrderBy(t => t.Location.X).ToList();
                    var t1picks    = picks.Take(5).OrderBy(t => t.Location.Y).ToList();
                    var t2picks    = picks.Skip(5).OrderBy(t => t.Location.Y).ToList();

                    var bgSearchResults = new List <SearchResult>();
                    foreach (var kvp in bgnameDescriptors)
                    {
                        using (var vMatches = new Emgu.CV.Util.VectorOfVectorOfDMatch()) {
                            matcher.KnnMatch(kvp.Value, des, vMatches, 2);
                            const float maxdist = 0.7f;
                            var         matches = vMatches.ToArrayOfArray().Where(m => m[0].Distance < maxdist * m[1].Distance).ToList();
                            if (matches.Any())
                            {
                                bgSearchResults.Add(new SearchResult(kvp.Key, matches, kp));
                            }
                        }
                        nCurrent++;
                        Invoke(new Action(() => {
                            screenshotViewer.SetProgress((double)nCurrent / nTotal);
                        }));
                    }
                    var bgSearchResult = bgSearchResults.OrderBy(t => - t.Distance).First();
                    Invoke(new Action(() => {
                        screenshotViewer.SetProgress(Stage.Complete);
                        screenshotViewer.SetSearchResults(bans_picks.ToArray(), bgSearchResult);
                        c_bg.Text = bgSearchResult.Name;
                        screenshotViewer.Show();
                        Focus();
                    }));
                }
        }
Пример #21
0
 private void backgroundWorker1_DoWork(object sender, System.ComponentModel.DoWorkEventArgs e)
 {
     uh   = new UserHelper();
     user = uh.GetUser(textBox1.Text, StringCipher.Encrypt(textBox2.Text));
 }
Пример #22
0
 private void loadFile_backgroundWorker_DoWork(object sender, System.ComponentModel.DoWorkEventArgs e)
 {
     DisableControl();
     ExcelHelper.LoadFromFile(openFileDialog1.FileName);
 }
Пример #23
0
 /// <summary>
 /// This is a function that is executed on another thread. It is done to reduce loading main thread. This function call method PopulateMonthButtons so as to set 12 cubes.
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 private void bgWorker_DoWork(object sender, System.ComponentModel.DoWorkEventArgs e)
 {
     Invoke((MethodInvoker)PopulateMonthCubes);
 }
Пример #24
0
 private void loadHeader_backgroundWorker_DoWork(object sender, System.ComponentModel.DoWorkEventArgs e)
 {
     DisableControl();
     ExcelHelper.LoadHeader();
 }
Пример #25
0
 void worker_DoWork(object sender, System.ComponentModel.DoWorkEventArgs e)
 {
 }
Пример #26
0
        private void backgroundWorker1_DoWork(object sender, System.ComponentModel.DoWorkEventArgs e)
        {
            string datafilename;
            string inifilename;
            string projectFolderName;

            if (splitMDL == 0)
            {
                Console.WriteLine("Starting batch split for " + files.Count.ToString() + " file(s)" + System.Environment.NewLine);
                foreach (string file in files)
                {
                    SplitData splitdata = new SplitData();
                    splitdata.dataFile = file;
                    string folder_parent = Directory.GetParent(Path.GetDirectoryName(System.Diagnostics.Process.GetCurrentProcess().MainModule.FileName)).ToString();
                    templateFolder = Path.Combine(folder_parent, "GameConfig");
                    if (!Directory.Exists(templateFolder))
                    {
                        templateFolder = Path.Combine(Directory.GetParent(folder_parent).ToString(), "GameConfig");
                    }
                    List <string> inilist = FindRelevantINIFiles(file, splitTemplate);
                    foreach (string iniitem in inilist)
                    {
                        splitdata.iniFile = iniitem;
                        splitDataList.Add(splitdata);
                    }
                }

                foreach (SplitData CurrentSplitData in splitDataList)
                {
                    datafilename = CurrentSplitData.dataFile;
                    inifilename  = CurrentSplitData.iniFile;

                    Console.WriteLine("Splitting file: " + datafilename);
                    if (out_path == "")
                    {
                        projectFolderName = Path.GetDirectoryName(datafilename);
                    }
                    else
                    {
                        projectFolderName = out_path;
                    }

                    if (projectFolderName[projectFolderName.Length - 1] != '/')
                    {
                        projectFolderName = string.Concat(projectFolderName, '/');
                    }
                    Console.WriteLine("Output folder: " + projectFolderName);

                    if (!File.Exists(datafilename))
                    {
                        Console.WriteLine(datafilename + " not found. Aborting.");
                        continue;
                    }

                    if (!Directory.Exists(projectFolderName))
                    {
                        // try creating the directory
                        bool created = true;

                        try
                        {
                            // check to see if trailing charcter closes
                            Directory.CreateDirectory(projectFolderName);
                        }
                        catch
                        {
                            created = false;
                        }

                        if (!created)
                        {
                            // couldn't create directory.
                            Console.WriteLine("Output folder did not exist and couldn't be created.");
                            continue;
                        }
                    }

                    if (!File.Exists(inifilename))
                    {
                        if (inifilename.Length > 9 && File.Exists(inifilename.Substring(0, inifilename.Length - 9) + ".ini"))
                        {
                            inifilename = inifilename.Substring(0, inifilename.Length - 9) + ".ini";
                        }
                        else if (Path.GetExtension(datafilename).ToLowerInvariant() == ".nb")
                        {
                            Console.WriteLine("Splitting NB file without INI data");
                            inifilename = null;
                        }
                        else
                        {
                            Console.WriteLine(inifilename + " not found. Aborting.");
                            continue;
                        }
                    }
                    if (inifilename != null)
                    {
                        Console.WriteLine("Using split data: " + inifilename);
                    }
                    bool nmeta   = labelMode == 2; // If labels are stripped, run split with the nometa parameter
                    bool nlabels = labelMode != 1; // If labels are address-based or stripped, prevent split from loading the labels file if it exists
                    Console.WriteLine("Skip full labels: " + nlabels.ToString());
                    Console.WriteLine("Strip labels: " + nmeta.ToString());
                    switch (Path.GetExtension(datafilename).ToLowerInvariant())
                    {
                    case ".dll":
                        SplitTools.SplitDLL.SplitDLL.SplitDLLFile(datafilename, inifilename, projectFolderName, nmeta, nlabels);
                        break;

                    case ".nb":
                        SplitTools.Split.SplitNB.SplitNBFile(datafilename, false, projectFolderName, 0, inifilename);
                        break;

                    default:
                        SplitTools.Split.SplitBinary.SplitFile(datafilename, inifilename, projectFolderName, nmeta, nlabels);
                        break;
                    }
                }
            }
            else
            {
                Console.WriteLine("Starting split for " + files[0] + System.Environment.NewLine);
                Console.WriteLine("Output folder: " + out_path + System.Environment.NewLine);
                SplitTools.SAArc.sa2MDL.Split(splitMDL > 1, files[0], out_path, files.Skip(1).ToArray());
            }
            Console.WriteLine("Split job finished.");
        }
Пример #27
0
 public void sauveAsyncCallC(object sender, System.ComponentModel.DoWorkEventArgs e)
 {
     e.Result = sauveData((Clients.clientOpenERP)((Hashtable)(e.Argument))["clientOpenERP"], ([email protected])((Hashtable)(e.Argument))["context"]);
 }
Пример #28
0
 /* background worker that get the inactive design export table */
 private void backgroundWorkerTable_DoWork(object sender, System.ComponentModel.DoWorkEventArgs e)
 {
     // send table to table field
     table = designTable.GetTable();
 }
Пример #29
0
 private void effaceAsyncCallC(object sender, System.ComponentModel.DoWorkEventArgs e)
 {
     e.Result = effaceData((Clients.clientOpenERP)((Hashtable)(e.Argument))["clientOpenERP"]);
 }
        private void WorkerFetcherDoWork(object sender, System.ComponentModel.DoWorkEventArgs e)
        {
            if (dataGridView_task != null && dataGridView_task.RowCount > 1)
            {
                _errorRowCount = 0;

                //while validating, deactivate other buttons
                Invoke((MethodInvoker)(() => button_validate.Enabled = false));
                Invoke((MethodInvoker)(() => button_import.Enabled = false));
                Invoke((MethodInvoker)(() => button_clear.Enabled = false));
                Invoke((MethodInvoker)(() => button_taskSelectFile.Enabled = false));

                Invoke((MethodInvoker)(() => textBox_taskImportMessages.AppendText("Start time: " + DateTime.Now)));

                try
                {
                    foreach (DataGridViewRow _row in dataGridView_task.Rows)
                    {
                        if (WorkerFetcher.CancellationPending)
                        {
                            break;
                        }

                        _isMappingFieldValueToIDCorrect = true;
                        _isFirstTimeInvalidMapping      = true;

                        if (_row.DataBoundItem != null)
                        {
                            TaskCreateModel _newTask = new TaskCreateModel
                            {
                                ProjectID   = (int)MapFieldValueToID(ProjectNo, _row, false),
                                TaskNo      = TaskHandler.Instance.CheckAndGetString(dataGridView_task, TaskNo, _row),
                                TaskName    = TaskHandler.Instance.CheckAndGetString(dataGridView_task, TaskName, _row),
                                Description = TaskHandler.Instance.CheckAndGetString(dataGridView_task, Description, _row),
                                StartDate   = TaskHandler.Instance.CheckAndGetDate(dataGridView_task, StartDate, _row),
                                EndDate     = TaskHandler.Instance.CheckAndGetDate(dataGridView_task, EndDate, _row),
                                AdditionalTextIsRequired = TaskHandler.Instance.CheckAndGetBoolean(dataGridView_task, AdditionalTextIsRequired, _row),
                                BudgetHours             = TaskHandler.Instance.CheckAndGetDouble(dataGridView_task, BudgetHours, _row),
                                BudgetAmount            = TaskHandler.Instance.CheckAndGetDouble(dataGridView_task, BudgetAmount, _row),
                                ProjectSubContractID    = (int)MapFieldValueToID(ContractName, _row, false),
                                IsReadyForInvoicing     = TaskHandler.Instance.CheckAndGetBoolean(dataGridView_task, IsReadyForInvoicing, _row),
                                TaskTypeID              = MapFieldValueToID(TaskType, _row, true),
                                HourlyRateID            = MapFieldValueToID(ContractHourlyRate, _row, true),
                                ParentTaskID            = MapFieldValueToID(ParentTaskNo, _row, true),
                                IsBillable              = TaskHandler.Instance.CheckAndGetBoolean(dataGridView_task, IsBillable, _row),
                                PaymentRecognitionModel = (PaymentRecognitionModelTypes)(int)MapFieldValueToID(PaymentRecognitionModel, _row, false),
                                PaymentAmount           = TaskHandler.Instance.CheckAndGetDouble(dataGridView_task, PaymentAmount, _row),
                                TaskHourlyRate          = TaskHandler.Instance.CheckAndGetDouble(dataGridView_task, TaskHourlyRate, _row),
                                PaymentProductNo        = TaskHandler.Instance.CheckAndGetString(dataGridView_task, PaymentProductNo, _row),
                                PaymentName             = TaskHandler.Instance.CheckAndGetString(dataGridView_task, PaymentName, _row),
                                PaymentInvoiceDate      = TaskHandler.Instance.CheckAndGetNullableDate(dataGridView_task, PaymentInvoiceDate, _row)
                            };

                            if (_isMappingFieldValueToIDCorrect)
                            {
                                if (_senderButton.Name == button_validate.Name)
                                {
                                    var _defaultApiResponse = TaskHandler.Instance.ValidateTask(_newTask,
                                                                                                AuthenticationHandler.Instance.Token, out var _businessRulesApiResponse);

                                    _errorRowCount = ApiHelper.Instance.HandleApiResponse(_defaultApiResponse, _row, _businessRulesApiResponse,
                                                                                          textBox_taskImportMessages, _errorRowCount, WorkerFetcher, this);
                                }
                                else
                                {
                                    var _defaultApiResponse = TaskHandler.Instance.ImportTask(_newTask,
                                                                                              AuthenticationHandler.Instance.Token, out var _businessRulesApiResponse);

                                    _errorRowCount = ApiHelper.Instance.HandleApiResponse(_defaultApiResponse, _row, _businessRulesApiResponse,
                                                                                          textBox_taskImportMessages, _errorRowCount, WorkerFetcher, this);
                                }
                            }
                        }
                    }

                    TaskHandler.Instance.DisplayErrorRowCountAndSuccessMessage(_errorRowCount, button_import, button_validate, _senderButton, textBox_taskImportMessages, this);
                }
                catch (FormatException _ex)
                {
                    MessageBox.Show(_ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                }
                catch (Exception _ex)
                {
                    MessageBox.Show(_ex.ToString(), "Error", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                }

                //reactivate buttons after work is done
                Invoke((MethodInvoker)(() => button_validate.Enabled = true));
                Invoke((MethodInvoker)(() => button_clear.Enabled = true));
                Invoke((MethodInvoker)(() => button_taskSelectFile.Enabled = true));
            }
        }
Пример #31
0
 private void downloader_DoWork(object sender, DoWorkEventArgs e)
 {
     List<DownloadInfo> downloads = (List<DownloadInfo>)e.Argument;
        SteppedProgressManager overallProgress = new SteppedProgressManager();
        long totalDownloadSize = downloads.Sum(delegate(DownloadInfo download)
     {
      return download.FileSize;
     });
        foreach (DownloadInfo download in downloads)
        {
     ProgressManagerBase downloadProgress = null;
     ProgressChangedEventHandler localHandler =
      delegate(object sender2, ProgressChangedEventArgs e2)
      {
       DownloadInfo downloadInfo = (DownloadInfo)sender2;
       if (downloadProgress == null)
       {
        downloadProgress = e2.Progress;
        overallProgress.Steps.Add(new SteppedProgressManagerStep(
     e2.Progress, download.FileSize / (float)totalDownloadSize));
       }
       downloader_ProgressChanged(sender2,
        new ProgressChangedEventArgs(overallProgress, e2.UserState));
      };
     download.Download(localHandler);
        }
        e.Result = e.Argument;
 }
Пример #32
0
        /// <summary>Run the simulation. Will throw on error.</summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        /// <exception cref="System.Exception">
        /// </exception>
        public void Run(object sender, System.ComponentModel.DoWorkEventArgs e)
        {
            try
            {
                StartRun();
                DoRun(sender);
                CleanupRun(null);
            }
            catch (ApsimXException err)
            {
                DataStore store = new DataStore(this);

                string Msg = "ERROR in file: " + FileName + "\r\n" +
                             "Simulation name: " + Name + "\r\n";
                Msg += err.Message;
                if (err.InnerException != null)
                {
                    Msg += "\r\n" + err.InnerException.Message + "\r\n" + err.InnerException.StackTrace;
                }
                else
                {
                    Msg += "\r\n" + err.StackTrace;
                }

                string modelFullPath = string.Empty;
                if (err.model != null)
                {
                    modelFullPath = Apsim.FullPath(err.model);
                }
                store.WriteMessage(Name, Clock.Today, modelFullPath, err.Message, DataStore.ErrorLevel.Error);
                store.Disconnect();
                CleanupRun(Msg);
                throw new Exception(Msg);
            }
            catch (Exception err)
            {
                DataStore store = new DataStore(this);

                string Msg = "ERROR in file: " + FileName + "\r\n" +
                             "Simulation name: " + Name + "\r\n";
                Msg += err.Message;
                if (err.InnerException != null)
                {
                    Msg += "\r\n" + err.InnerException.Message + "\r\n" + err.InnerException.StackTrace;
                }
                else
                {
                    Msg += "\r\n" + err.StackTrace;
                }

                store.WriteMessage(Name, Clock.Today, "Unknown", err.Message, DataStore.ErrorLevel.Error);
                store.Disconnect();

                CleanupRun(Msg);
                throw new Exception(Msg);
            }
            if (e != null)
            {
                e.Result = this;
            }
        }
Пример #33
0
 private void updateListDownloader_DoWork(object sender, DoWorkEventArgs e)
 {
     e.Result = DownloadManager.GetDownloads(updateListDownloader_ProgressChanged);
 }
Пример #34
0
        private void BgwScriptPetDoWork(object sender, System.ComponentModel.DoWorkEventArgs e)
        {
            while (botRunning)
            {
                #region pet: BST
                if (PlayerInfo.MainJob == 9 || PlayerInfo.SubJob == 9)
                {
                    if (juguse.Checked && PetInfo.ID == 0 && jugpet.Text != "" &&
                        ItemQuantityByName(jugpet.Text) > 0)
                    {
                        #region Ammo/Ranged Slot
                        var rangedSlot = InventoryItems.Items.FirstOrDefault(x => x.Key == api.Inventory.GetEquippedItem(2).Id.ToString()).Value;
                        var ammoSlot   = InventoryItems.Items.FirstOrDefault(x => x.Key == api.Inventory.GetEquippedItem(3).Id.ToString()).Value;
                        #endregion

                        if (Recast.GetAbilityRecast(94) == 0)
                        {
                            WindowInfo.SendText("/equip Ammo \"" + jugpet.Text + "\"");
                            Thread.Sleep(TimeSpan.FromSeconds(1.0));
                            WindowInfo.SendText("/ja \"Bestial Loyalty\" <me>");
                            Thread.Sleep(TimeSpan.FromSeconds(2.0));
                        }
                        else if (Recast.GetAbilityRecast(104) == 0 && Recast.GetAbilityRecast(94) != 0)
                        {
                            WindowInfo.SendText("/equip Ammo \"" + jugpet.Text + "\"");
                            Thread.Sleep(TimeSpan.FromSeconds(1.0));
                            WindowInfo.SendText("/ja \"Call Beast\" <me>");
                            Thread.Sleep(TimeSpan.FromSeconds(2.0));
                        }

                        #region Re-Equip Ammo/Ranged
                        if (ammoSlot != null && ammoSlot != jugpet.Text)
                        {
                            WindowInfo.SendText("/equip Ammo \"" + ammoSlot + "\"");
                            Thread.Sleep(TimeSpan.FromSeconds(1.0));
                        }
                        else if (rangedSlot != null)
                        {
                            WindowInfo.SendText("/equip Range \"" + rangedSlot + "\"");
                            Thread.Sleep(TimeSpan.FromSeconds(1.0));
                        }
                        #endregion

                        if (TargetInfo.ID > 0 && TargetInfo.ID != PlayerInfo.ServerID && !TargetInfo.LockedOn)
                        {
                            WindowInfo.SendText("/lockon <t>");
                        }
                    }

                    if (PetInfo.Name != null)
                    {
                        pInfo();
                    }

                    if (PetInfo.ID > 0 && autoengage.Checked &&
                        PlayerInfo.Status == 1 && PetInfo.Status == 0 &&
                        TargetInfo.ID > 0)
                    {
                        WindowInfo.SendText("/ja \"Fight\" <t>");
                        Thread.Sleep(TimeSpan.FromSeconds(4.0));
                    }

                    if (petfooduse.Checked && ItemQuantityByName(usedpetfood.Text) > 0 &&
                        PetInfo.ID > 0 && usedpetfood.Text != "" && PetInfo.HPP < pethppfood.Value &&
                        Recast.GetAbilityRecast(103) == 0)
                    {
                        #region Ammo/Ranged Slot
                        var rangedSlot = InventoryItems.Items.FirstOrDefault(x => x.Key == api.Inventory.GetEquippedItem(2).Id.ToString()).Value;
                        var ammoSlot   = InventoryItems.Items.FirstOrDefault(x => x.Key == api.Inventory.GetEquippedItem(3).Id.ToString()).Value;
                        #endregion

                        WindowInfo.SendText("/equip Ammo \"" + usedpetfood.Text + "\"");
                        Thread.Sleep(TimeSpan.FromSeconds(2.0));
                        WindowInfo.SendText("/ja \"Reward\" <me>");
                        Thread.Sleep(TimeSpan.FromSeconds(2.0));

                        #region Re-Equip Ammo/Ranged
                        if (ammoSlot != null && ammoSlot != usedpetfood.Text)
                        {
                            WindowInfo.SendText("/equip Ammo \"" + ammoSlot + "\"");
                            Thread.Sleep(TimeSpan.FromSeconds(2.0));
                        }
                        else if (rangedSlot != null)
                        {
                            WindowInfo.SendText("/equip Range \"" + rangedSlot + "\"");
                            Thread.Sleep(TimeSpan.FromSeconds(2.0));
                        }
                        #endregion
                    }

                    if (PetJA.Items.Count == 0 && PetInfo.ID != 0)
                    {
                        BSTGetJA();
                    }

                    if (PetInfo.ID > 0 && PetJA.Items.Count > 0 && PetInfo.Status == 1 &&
                        PetInfo.TPP > 1000 && TargetInfo.ID > 0)
                    {
                        PetReadyJA();
                    }
                }
                #endregion
                #region pet: DRG
                if (PlayerInfo.MainJob == 14 || PlayerInfo.SubJob == 14)
                {
                    if (PetInfo.ID == 0 && CallWyvern.Checked &&
                        Recast.GetAbilityRecast(163) == 0)
                    {
                        WindowInfo.SendText("/ja \"Call Wyvern\" <me>");
                        Thread.Sleep(TimeSpan.FromSeconds(2.0));
                    }

                    if (PetInfo.ID != 0)
                    {
                        pInfo();
                    }

                    if (WyvernJA.Items.Count == 0 && PetInfo.ID > 0)
                    {
                        WyvernGetJA();
                    }

                    if (PetInfo.ID > 0 && WyvernJA.Items.Count > 0 &&
                        PlayerInfo.Status == 1 && !string.IsNullOrEmpty(TargetInfo.Name))
                    {
                        WyvernUseJA();
                    }
                }
                #endregion

                Thread.Sleep(TimeSpan.FromSeconds(0.1));
            }
        }
        public void Run_BackgroundWorkerOnDoWork_SetsFilesToEventResult()
        {
            // arrange
            var eventArgs = new System.ComponentModel.DoWorkEventArgs(null);

            // act
            _worker.Run(new RandomizerWorkerSettings(), (x) => { }, (y) => { }, () => { });
            _backgroundWorkerMock.Raise(x => { x.OnDoWork += null; }, null, eventArgs);

            // assert
            Assert.IsTrue(eventArgs.Result.GetType() == new List<AppFile>().GetType());
        }
Пример #36
0
 private void backgroundWorker2_DoWork(object sender, System.ComponentModel.DoWorkEventArgs e)
 {
     SyncUserAccounts();
 }
Пример #37
0
 private void backgroundWorker1_DoWork(object sender, System.ComponentModel.DoWorkEventArgs e)
 {
 }
Пример #38
0
        private void Worker_DoWork(object sender, System.ComponentModel.DoWorkEventArgs e)
        {
            // Do start conquer and inject
            Core.LogWritter.Write("Launching " + SelectedServer.ExecutableName + "...");
            string PathToConquerExe = Path.Combine(Application.StartupPath, SelectedServer.ExecutableName);
            string WorkingDir       = Path.GetDirectoryName(PathToConquerExe);

            if (File.Exists(PathToConquerExe))
            {
                string CheckPathEnvDX8 = Path.Combine(Application.StartupPath, "Env_DX8", SelectedServer.ExecutableName);
                string CheckPathEnvDX9 = Path.Combine(Application.StartupPath, "Env_DX9", SelectedServer.ExecutableName);
                Core.LogWritter.Write("Checking if existing path: " + CheckPathEnvDX8 + "...");
                if (File.Exists(CheckPathEnvDX8))
                {
                    Core.LogWritter.Write("Found Env_DX8 Folder. Setting the folder for run executable...");
                    PathToConquerExe = CheckPathEnvDX8;
                    WorkingDir       = Path.GetDirectoryName(PathToConquerExe);
                    string OutputCopyDll = Path.Combine(Application.StartupPath, "Env_DX8", HookINI);
                    if (File.Exists(OutputCopyDll))
                    {
                        File.Delete(OutputCopyDll);
                    }
                    File.Copy(Path.Combine(Application.StartupPath, HookINI), OutputCopyDll);
                }
                if (SelectedServer.UseDirectX9)
                {
                    if (File.Exists(CheckPathEnvDX9))
                    {
                        Core.LogWritter.Write("Found Env_DX9 Folder. Setting the folder for run executable...");
                        PathToConquerExe = CheckPathEnvDX9;
                        WorkingDir       = Path.GetDirectoryName(PathToConquerExe);
                        string OutputCopyDll = Path.Combine(Application.StartupPath, "Env_DX9", HookINI);
                        if (File.Exists(OutputCopyDll))
                        {
                            File.Delete(OutputCopyDll);
                        }
                        File.Copy(Path.Combine(Application.StartupPath, HookINI), OutputCopyDll);
                    }
                }
                Process conquerProc = Process.Start(new ProcessStartInfo()
                {
                    FileName = PathToConquerExe, WorkingDirectory = WorkingDir, Arguments = "blacknull"
                });
                if (conquerProc != null)
                {
                    Core.LogWritter.Write("Process launched!");
                    worker.ReportProgress(10);
                    CurrentConquerProcess = conquerProc;
                    int ConquerOpened = Process.GetProcessesByName(CurrentConquerProcess.ProcessName).Count();
                    Core.LogWritter.Write($"CLServer Enabled: {LoaderConfig.CLServer} . Processes of Conquer opened: {ConquerOpened} (Only connect if have less or equal to 1)");
                    if (LoaderConfig.CLServer && ConquerOpened <= 1) // Only if not have other Conquer.exe opened
                    {
                        Core.LogWritter.Write("Connecting to CLServer");
                        // Try connect to CLServer
                        try
                        {
                            SocketSystem.CurrentSocketClient = new CLClient(SelectedServer.LoginHost, 8000);
                            Core.LogWritter.Write(string.Format("CLClient connected at CLServer with port {0}.", 8000));
                        }
                        catch (Exception ex) // Prevent break process of loader
                        {
                            Console.WriteLine("Cannot connect to CLServer: {0}", ex);
                        }
                    }
                    LoaderEvents.ConquerLaunchedStartEvent(new List <Parameter>
                    {
                        new Parameter()
                        {
                            Id = "ConquerProcessId", Value = CurrentConquerProcess.Id.ToString()
                        },
                        new Parameter()
                        {
                            Id = "GameServerIP", Value = SelectedServer.GameHost
                        }
                    });
                    Core.LogWritter.Write("Injecting DLL...");
                    worker.ReportProgress(20);
                    if (SelectedServer.ServerVersion >= 6187)
                    {
                        conquerProc.WaitForInputIdle(35000);
                    }
                    if (!Injector.StartInjection(Application.StartupPath + @"\" + HookDLL, (uint)conquerProc.Id, worker))
                    {
                        Core.LogWritter.Write("Injection failed!");
                        MetroFramework.MetroMessageBox.Show(this, $"[{SelectedServer.ServerName}] Cannot inject " + HookDLL, this.ProductName, MessageBoxButtons.OK, MessageBoxIcon.Warning);
                    }
                    else
                    {
                        Core.LogWritter.Write("Injected successfully!");
                    }
                }
                else
                {
                    Core.LogWritter.Write("Cannot launch " + SelectedServer.ExecutableName + "");
                    MetroFramework.MetroMessageBox.Show(this, $"[{SelectedServer.ServerName}] Cannot start {SelectedServer.ExecutableName}", this.ProductName, MessageBoxButtons.OK, MessageBoxIcon.Warning);
                }
            }
            else
            {
                Core.LogWritter.Write("Path for Executable not found: " + PathToConquerExe);
            }
        }