コード例 #1
0
ファイル: frmUpdate.cs プロジェクト: xorle/MineEdit
 public void SetMax(int max)
 {
     if (pb.InvokeRequired)
     {
         pb.Invoke(new hurf(SetMax), max);
     }
     else
     {
         pb.Maximum = max;
     }
 }
コード例 #2
0
ファイル: Utils.cs プロジェクト: ayydriel/BetterDiscordApp
        public void StartDownload(ProgressBar pb, String url, String name)
        {

           

            Thread t = new Thread(() =>
            {
                WebClient webClient = new WebClient();
                webClient.Headers["User-Agent"] = "Mozilla/5.0";
                webClient.DownloadProgressChanged += delegate(object sender, DownloadProgressChangedEventArgs args)
                {                   
                    double percentage = (double.Parse(args.BytesReceived.ToString()) /double.Parse(args.TotalBytesToReceive.ToString())) * 100;
                    Debug.Print(percentage.ToString());
                    pb.Invoke((MethodInvoker) delegate
                    {
                        pb.Value = (int)Math.Truncate(percentage);
                    });

                };


                webClient.DownloadFile(new Uri(url), Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData) + "\\BetterDiscord\\temp\\" + name);

            });

            t.Start();
        }
コード例 #3
0
 public static void UpdatePbar(System.Windows.Forms.ProgressBar name, int step)
 {
     if (name.InvokeRequired)
     {
         object[] params_list = new object[] { name, step };
         name.Invoke(new UpdateProgressBar(UpdatePbar), params_list);
     }
     else
     {
         name.Increment(step);
     }
 }
コード例 #4
0
        public static Bitmap bmp_create(Bitmap BMP, int num_filtr, ProgressBar progressBar1, ProgressThread pr)
        {
            BMPFilters flr = new BMPFilters();
            byte[, ,] rs;
            rs = MatrixPixelReader.matrix(BMP);
            Bitmap BMP1 = new Bitmap(BMP.Width, BMP.Height);
            Color colorBMP1;//переменная, которая будет задавать цвет
            double red1 = 0, blue1 = 0, green1 = 0;
            byte red = 0, blue = 0, green = 0;
            flr.choose_filtr(num_filtr);

            if (flr.filtr.black)
            {
                for (int j = 0; j < BMP.Width; j++) BMP1.SetPixel(j, 0, Color.Black);
            }
            else
            {
                for (int j = 0; j < BMP.Width; j++) BMP1.SetPixel(j, 0, BMP.GetPixel(j, 0));
            }

            for (int i = 1; i < BMP.Height - 1; i++)
            {
                progressBar1.Invoke(pr.MyDelegate);
                if (flr.filtr.black) BMP1.SetPixel(0, i, Color.Black);
                for (int j = 1; j < BMP.Width - 1; j++)
                {
                    for (int p = 0; p < 3; p++)
                        for (int p1 = 0; p1 < 3; p1++)
                        {
                            red1 += flr.filtr.fl[p, p1] * rs[0, i + p - 1, j + p1 - 1];
                            green1 += flr.filtr.fl[p, p1] * rs[1, i + p - 1, j + p1 - 1];
                            blue1 += flr.filtr.fl[p, p1] * rs[2, i + p - 1, j + p1 - 1];
                        }
                    blue = (byte)(flr.filtr.bl ? (blue1 / flr.filtr.div) > 255 ? 255 : (blue1 / flr.filtr.div) < 0 ? 0 : (blue1 / flr.filtr.div) : blue1);
                    red = (byte)(flr.filtr.bl ? (red1 / flr.filtr.div) > 255 ? 255 : (red1 / flr.filtr.div) < 0 ? 0 : (red1 / flr.filtr.div) : red1);
                    green = (byte)(flr.filtr.bl ? (green1 / flr.filtr.div) > 255 ? 255 : (green1 / flr.filtr.div) < 0 ? 0 : (green1 / flr.filtr.div) : green1);
                    colorBMP1 = Color.FromArgb((int)red, (int)green, (int)blue);
                    BMP1.SetPixel(j, i, colorBMP1);
                    red1 = blue1 = green1 = 0;
                }
                if (flr.filtr.black) BMP1.SetPixel(BMP.Width - 1, i, Color.Black);
            }
            if (flr.filtr.black)
            {
                for (int j = 0; j < BMP.Width; j++) BMP1.SetPixel(j, BMP.Height - 1, Color.Black);
            }
            else
            {
                for (int j = 0; j < BMP.Width; j++) BMP1.SetPixel(j, BMP.Height - 1, Color.White);
            }
            return BMP1;
        }
コード例 #5
0
ファイル: main.cs プロジェクト: leejongseok/TeamProject
 private void webclient_UploadProgressChanged(object sender, long maxsize, long Downloaded, ProgressBar progress)
 {
     if(progress.InvokeRequired)
     {
         progress.Invoke(cssv, new object[] { sender, maxsize, Downloaded, progress });
     }
     else
     {
         float per = ((float)Downloaded / maxsize) * 100;
         progress.Value = (int)per;
         progress.Controls[0].Text = string.Format("{0}%", (int)per);
     }
 }
コード例 #6
0
ファイル: main.cs プロジェクト: leejongseok/TeamProject
 private void webclient_DownloadFileCompleted(object sender, ProgressBar progress)
 {
     if(progress.InvokeRequired)
     {
         progress.Invoke(cscp, new object[] { sender, progress });
     }
     else
     {
         MessageBox.Show("다운 완료");
         int index = downflowPanel.Controls.IndexOf(progress);
         downflowPanel.Controls.RemoveAt(index);
         down.Stop();
     }
 }
コード例 #7
0
 public static void SetMaxTS(this ProgressBar x, Int32 s)
 {
     if (x.InvokeRequired)
     {
         x.Invoke(new EventHandler(delegate(object o, EventArgs a)
         {
             x.SetMaxTS(s);
         }));
     }
     else
     {
         x.Maximum = s;
     }
 }
コード例 #8
0
        public static void PerformStep(ProgressBar progressBar)
        {
            MethodInvoker miPerformStep = delegate
            {
                progressBar.PerformStep();
            };

            if (progressBar.InvokeRequired)
            {
                progressBar.Invoke(miPerformStep);
            }
            else
            {
                miPerformStep();
            }
        }
コード例 #9
0
        public static void SetForeColor(ProgressBar progressBar, Color color)
        {
            MethodInvoker miSetForeColor = delegate
            {
                progressBar.ForeColor = color;
            };

            if (progressBar.InvokeRequired)
            {
                progressBar.Invoke(miSetForeColor);
            }
            else
            {
                miSetForeColor();
            }
        }
コード例 #10
0
        public static void SetMinimum(ProgressBar progressBar, int minimum)
        {
            MethodInvoker miSetMinimum = delegate
            {
                progressBar.Maximum = minimum;
            };

            if (progressBar.InvokeRequired)
            {
                progressBar.Invoke(miSetMinimum);
            }
            else
            {
                miSetMinimum();
            }
        }
コード例 #11
0
        public static void SetStep(ProgressBar progressBar, int step)
        {
            MethodInvoker miSetStep = delegate
            {
                progressBar.Step = step;
            };

            if (progressBar.InvokeRequired)
            {
                progressBar.Invoke(miSetStep);
            }
            else
            {
                miSetStep();
            }
        }
コード例 #12
0
 public static Int32 GetValueTS(this ProgressBar x)
 {
     if (x.InvokeRequired)
     {
         Int32 m_ret = 0;
         x.Invoke(new EventHandler(delegate(object o, EventArgs a)
         {
             m_ret = x.GetValueTS();
         }));
         return(m_ret);
     }
     else
     {
         return(x.Value);
     }
 }
コード例 #13
0
        public static void UpdateProgressBar(System.Windows.Forms.ProgressBar ProgressBarControl, int PBvalue)
        {
            if (ProgressBarControl == null)
            {
                return;
            }

            if (ProgressBarControl.InvokeRequired)
            {
                UpdateProgressBarCallback d = UpdateProgressBar;
                ProgressBarControl.Invoke(d, new object[] { ProgressBarControl, PBvalue });
            }
            else
            {
                ProgressBarControl.Value = PBvalue;
            }
        }
コード例 #14
0
        private static void UpdateProgressIndicators(long TotalFileBytesTransferred, long FileSize)
        {
            int i = (int)(TotalFileBytesTransferred * 100 / FileSize);

            if (pbCopyProgress != null)
            {
                if (pbCopyProgress.Minimum <= i && i <= pbCopyProgress.Maximum)
                {
                    pbCopyProgress.Invoke(new Action(() => pbCopyProgress.Value = i));
                }
                else
                {
                    String s = "Error in reporting progress" + System.Environment.NewLine;
                    s += "TotalFileBytesTransferred:" + TotalFileBytesTransferred + System.Environment.NewLine;
                    s += "FileSize:" + FileSize;
                    throw new System.Exception(s);
                }
            }

            int iTotal = (int)((TotalBytesCopied + TotalFileBytesTransferred) * 100 / TotalBytesToCopy);

            if (pbTotalCopyProgress != null)
            {
                if (pbTotalCopyProgress.Minimum <= iTotal && iTotal <= pbTotalCopyProgress.Maximum)
                {
                    pbTotalCopyProgress.Invoke(new Action(() => pbTotalCopyProgress.Value = iTotal));
                }
                else
                {
                    String s = "Error in reporting total progress" + System.Environment.NewLine;
                    s += "TotalBytesCopied:" + TotalBytesCopied + System.Environment.NewLine;
                    s += "TotalFileBytesTransferred:" + TotalFileBytesTransferred + System.Environment.NewLine;
                    s += "TotalBytesToCopy:" + TotalBytesToCopy;
                    throw new System.Exception(s);
                }
            }

            double TimeElapsedSec = (DateTime.Now.Ticks / TimeSpan.TicksPerMillisecond - StartTimeCopy) / 1000.0;

            if (TimeElapsedSec > 0.1 && lblMegaBytesPerSecond != null && TotalFileBytesTransferred > 0)
            {
                int iMbPerSec = (int)(TotalFileBytesTransferred / 1024 / 1024 / TimeElapsedSec);
                lblMegaBytesPerSecond.Invoke(new Action(() => lblMegaBytesPerSecond.Text = iMbPerSec + " MiB/s"));
            }
        }
コード例 #15
0
        private void BulkOrderUpload(object state)
        {
            int ctr          = 0;
            int totalRecords = 10500;

            //Read bulk order import file and initialize the values
            //such as total number of orders to import

            //start iterating individual order
            while (ctr < totalRecords)
            {
                //update progress bar control value
                //this needs to be done on UI thread
                uploadProgressBar.Invoke(new SetProgressBar(UpdateProgressBar),
                                         new object[] { ctr });
                ctr++;
            }
        }
コード例 #16
0
        public static void UpdateProgressBar(ProgressBar prg, int value)
        {
            try
            {
                if (prg.InvokeRequired)
                {
                    UpdateProgressBarCallback d = UpdateProgressBar;
                    prg.Invoke(d, prg, value);
                    return;
                }

                prg.Value = value;
            }
            catch
            {
                // This catch is simply here to avoid the OCCASIONAL crash of the application when closing it by pressing the stop button in visual studio while it is running tasks
            }
        }
コード例 #17
0
ファイル: UICommon.cs プロジェクト: Corprus/unilogviewer
 private void SetFullProgressLevel(ProgressBar progressBar, Label progressLabel, int current, int max, int min)
 {
     if (!progressBar.InvokeRequired)
     {
     progressBar.Maximum = max;
     progressBar.Minimum = min;
     if (current > max)
         current = max;
     progressBar.Value = current;
         progressLabel.Text = !((current == min) || (current == 0))
                                  ? string.Format("{0:%}", (current)/(max - min))
                                  : "0%";
     }
     else
     {
         if ((progressBar.IsDisposed || progressLabel.IsDisposed))
             return;
         var d = new SetFullProgressLevelCallback(SetFullProgressLevel);
         progressBar.Invoke(d, new object[] { progressBar, progressLabel, current, max, min });
     }
 }
コード例 #18
0
ファイル: FileHelper.cs プロジェクト: ByAgenT/JPEGCompressor
 public static void DecodeImages(String path, ProgressBar progressBar)
 {
     DirectoryInfo dir = new DirectoryInfo(path);
     IEnumerable<FileInfo> files;
     IEnumerable<DirectoryInfo> dirs;
     files = dir.EnumerateFiles().Where(f => extensions.Contains(f.Extension));
     dirs = dir.EnumerateDirectories();
     foreach (FileInfo f in files)
     {
         //JpegBitmapEncoder encoder = new JpegBitmapEncoder();
         //FileStream stream = new FileStream(@"" + f.FullName, FileMode.Open, FileAccess.Write);
         //encoder.Save(stream); //throw NotSupportedException
         progressBar.Invoke(new Action<double>(i =>
         {
             progressBar.Value += Convert.ToInt32(step);
         }), step);
     }
     foreach (DirectoryInfo d in dirs)
     {
         DecodeImages(d.FullName, progressBar);
     }
 }
コード例 #19
0
ファイル: CrossThread.cs プロジェクト: riguelbf/portalSureg
        public static void UpdateProgressBar(ProgressBar progressBar, int max, int value)
        {
            if (progressBar.InvokeRequired)
            {
                updateProgressBarDelegate del = new updateProgressBarDelegate(UpdateProgressBar);
                progressBar.Invoke(del, new object[] { progressBar, max, value });
            }
            else
            {
                if ((max == 0) && (value == 0))
                {
                    progressBar.Visible = false;

                }
                else
                {
                    if (max != 0)
                        progressBar.Maximum = max;

                    progressBar.Value = value;
                }
            }
        }
コード例 #20
0
ファイル: Mainform.cs プロジェクト: stephencox/RFID-Simulator
 private void setpbar(ProgressBar k, int count)
 {
     if (k.InvokeRequired) {
         k.Invoke (new setbard (setpbar), k, count);
     } else {
         k.Value = count;
     }
 }
コード例 #21
0
ファイル: CSVExport.cs プロジェクト: Rinsen/Tools
        public static String Memberships(ref enterprise ep, ProgressBar progressbar = null)
        {
            try
            {
                var all = new StringBuilder("MSSourcedID,MSourcedid,MIDType,MRoleStatus,MRoleRoleType,MRoleTimeFrameBegin,MRoleTimeFrameEnd\r\n");

                if (progressbar != null)
                {
                    int count = ep.group.ToList().Count - 1;
                    progressbar.Invoke(new Action(() => progressbar.Maximum = count));
                    progressbar.Invoke(new Action(() => progressbar.Value = 0));
                }

                foreach (membership membership in ep.membership)
                {
                    if (progressbar != null)
                        if (progressbar.Maximum > progressbar.Value)
                            progressbar.Invoke(new Action(() => progressbar.Value++));

                    all.Append(Membership(membership));
                }

                return all.ToString();
            }
            catch (Exception e)
            {
                throw e;
            }
        }
コード例 #22
0
        private static void SetStatus(int val, string text, ProgressBar pb, ToolStripItem status, Control statusStrip)
        {
            pb.Invoke((MethodInvoker) delegate
                                          {
                                              pb.Value = val;
                                              //status.Text = text;
                                          });

            statusStrip.Invoke((MethodInvoker)delegate
                                              {
                                                  //pb.Value = val;
                                                  status.Text = text;
                                              });
        }
 private void setProgressBar(ProgressBar control,int maxValue,int value)
 {
     if (control.InvokeRequired)
     {
         control.Invoke(new MethodInvoker(delegate
         {
             control.Maximum = maxValue;
             control.Value = value;
         }));
     }
     else
     {
         control.Maximum = maxValue;
         control.Value = value;
     }
 }
コード例 #24
0
 private void SetValue4Prg(ProgressBar Prg, int _Value)
 {
     try
     {
         if (Prg.InvokeRequired)
         {
             Prg.Invoke(new SetPrgValue(SetValue4Prg), new object[] {Prg, _Value});
         }
         else
         {
             if (Prg.Value + _Value <= Prg.Maximum) Prg.Value += _Value;
             Prg.Refresh();
         }
     }
     catch
     {
     }
 }
コード例 #25
0
        public void Run()
        {
            conn.Send("init");
            locker.WaitOne();
            owner     = false;
            Gcurrent1 = 0;
            bool drawblocks = false;
            //var inca = 0;
            //if (frames.Count == 1) inca = 0;
            //else inca = 1;
            List <string[]> diff = null;

            //restart:
            //for (int i = inca; i < frames.Count; i++)
            //{
            start = DateTime.Now;

            firstFrame = frames[0].Diff(remoteFrame);
            ModifyProgressBarColor.SetState(pb, 1);
            TaskbarProgress.SetState(afHandle, TaskbarProgress.TaskbarStates.Normal);
            var dt = System.DateTime.UtcNow;

            if (pb.InvokeRequired)
            {
                pb.Invoke((MethodInvoker) delegate { pb.Maximum = firstFrame.Count; });
            }
            else
            {
                pb.Maximum = firstFrame.Count;
            }
            epochStartTime = dt;

stopit:
            if (frames.Count == 1)
            {
                diff = frames[0].Diff(remoteFrame);
            }
            else
            {
                //diff = frames[i].Diff(remoteFrame);
            }
            if (MainForm.userdata.drawMixed)
            {
                Shuffle(diff);
            }
            if (!MainForm.userdata.drawMixed && MainForm.userdata.reverse)
            {
                diff.Reverse();
            }
            if (!MainForm.userdata.drawMixed && MainForm.userdata.random)
            {
                diff.Sort((a, b) => (a.ToString()[0].CompareTo(b.ToString()[0])));
            }
            Gtotal    = diff.Count;
            Gcurrent  = 0;
            maxBlocks = 0;
            int total = diff.Count;

            //OnStatusChanged("Uploading blocks to level. (Total: " + Gcurrent1 + "/" + Gtotal + ")", dt, false, Gtotal, Gcurrent);
            TaskbarProgress.SetValue(afHandle, Gcurrent, Gtotal); //Set TaskbarProgress.cs' values
            Queue <string[]> queue   = new Queue <string[]>(diff);
            List <string[]>  blocks1 = new List <string[]>(diff);
            List <object[]>  blocks  = new List <object[]>();

            //Set AnimateForm.cs' progressbar max value
            while (queue.Count > 0)
            {
                string[] cur = queue.Dequeue();
                int      x;
                int      y;
                if (cur[0] != null)
                {
                    x = Convert.ToInt32(cur[0]);
                    y = Convert.ToInt32(cur[1]);
                    if (MainForm.OpenWorld && !MainForm.OpenWorldCode)
                    {
                        if (y > 4)
                        {
                            drawblocks = true;
                        }
                        else
                        {
                            drawblocks = false;
                        }
                    }
                    else
                    {
                        drawblocks = true;
                    }
                    if (drawblocks)
                    {
                        OnStatusChanged("", epochStartTime, false, firstFrame.Count, Gcurrent1);
                        int type = Convert.ToInt32(cur[2]);
                        int at   = Convert.ToInt32(cur[3]);
                        uploaded += 1;
                        //Console.WriteLine(lastY + " " + y);
                        if (at == 0)
                        {
                            if (remoteFrame.Foreground[y, x] != type)
                            {
                                if (bdata.morphable.Contains(type))
                                {
                                    b = true;
                                }
                                else if (bdata.goal.Contains(type) && type != 83 && type != 77 && type != 1520)
                                {
                                    if (cur.Length == 5)
                                    {
                                        b = true;
                                    }
                                }
                                else if (bdata.rotate.Contains(type) && type != 385 && type != 374)
                                {
                                    if (cur.Length == 5)
                                    {
                                        b = true;
                                    }
                                }
                                else if (type == 385)
                                {
                                    if (cur.Length == 6)
                                    {
                                        b = true;
                                    }
                                }
                                else if (type == 374)
                                {
                                    if (cur.Length == 5)
                                    {
                                        b = true;
                                    }
                                }
                                else if (type == 83 || type == 77 || type == 1520)
                                {
                                    if (cur.Length == 5)
                                    {
                                        b = true;
                                    }
                                }
                                else if (bdata.portals.Contains(type))
                                {
                                    if (cur.Length == 7)
                                    {
                                        b = true;
                                    }
                                }
                                else
                                {
                                    b = true;
                                }
                            }
                            else if (remoteFrame.Foreground[y, x] == type)
                            {
                                if (bdata.morphable.Contains(type))
                                {
                                    if (cur.Length == 5)
                                    {
                                        if (remoteFrame.BlockData[y, x] != Convert.ToInt32(cur[4]))
                                        {
                                            b = true;
                                        }
                                    }
                                }
                                else if (bdata.goal.Contains(type) && type != 83 && type != 77 && type != 1520)
                                {
                                    if (cur.Length == 5)
                                    {
                                        if (remoteFrame.BlockData[y, x] != Convert.ToInt32(cur[4]))
                                        {
                                            b = true;
                                        }
                                    }
                                }
                                else if (bdata.rotate.Contains(type) && type != 385 && type != 374)
                                {
                                    if (cur.Length == 5)
                                    {
                                        if (remoteFrame.BlockData[y, x] != Convert.ToInt32(cur[4]))
                                        {
                                            b = true;
                                        }
                                    }
                                }
                                else if (type == 385)
                                {
                                    if (cur.Length == 6)
                                    {
                                        if (remoteFrame.BlockData3[y, x] != cur[5] || remoteFrame.BlockData[y, x] != Convert.ToInt32(cur[4]))
                                        {
                                            b = true;
                                        }
                                    }
                                }
                                else if (type == 374)
                                {
                                    if (cur.Length == 5)
                                    {
                                        if (remoteFrame.BlockData3[y, x] != cur[5])
                                        {
                                            b = true;
                                        }
                                    }
                                }
                                else if (type == 83 || type == 77 || type == 1520)
                                {
                                    if (cur.Length == 5)
                                    {
                                        if (remoteFrame.BlockData[y, x] != Convert.ToInt32(cur[4]))
                                        {
                                            b = true;
                                        }
                                    }
                                }
                                else if (bdata.portals.Contains(type))
                                {
                                    if (cur.Length == 7)
                                    {
                                        if (remoteFrame.BlockData[y, x] != Convert.ToInt32(cur[4]) || remoteFrame.BlockData1[y, x] != Convert.ToInt32(cur[5]) || remoteFrame.BlockData2[y, x] != Convert.ToInt32(cur[6]))
                                        {
                                            b = true;
                                        }
                                    }
                                }
                            }
                        }
                        if (at == 1)
                        {
                            if (remoteFrame.Background[y, x] != type)
                            {
                                b = true;
                            }
                        }
                        if (b)
                        {
                            if (bdata.morphable.Contains(type) && type != 385)
                            {
                                param = new object[] { at, x, y, type, Convert.ToInt32(cur[4]) };
                            }
                            else if (bdata.goal.Contains(type))
                            {
                                if (cur.Length == 5)
                                {
                                    param = new object[] { at, x, y, type, Convert.ToInt32(cur[4]) };
                                }
                            }
                            else if (bdata.rotate.Contains(type) && type != 385 && type != 374)
                            {
                                if (cur.Length == 5)
                                {
                                    param = new object[] { at, x, y, type, Convert.ToInt32(cur[4]) };
                                }
                            }
                            else if (type == 385)
                            {
                                if (cur.Length == 6)
                                {
                                    param = new object[] { at, x, y, type, cur[5], Convert.ToInt32(cur[4]) };
                                }
                            }
                            else if (type == 374)
                            {
                                if (cur.Length == 5)
                                {
                                    param = new object[] { at, x, y, type, cur[4] };
                                }
                            }
                            else if (type == 77 || type == 83 || type == 1520)
                            {
                                if (cur.Length == 5)
                                {
                                    param = new object[] { at, x, y, type, int.Parse(cur[4]) };
                                }
                            }
                            else if (bdata.portals.Contains(type))
                            {
                                if (cur.Length == 7)
                                {
                                    param = new object[] { at, x, y, type, Convert.ToInt32(cur[4]), Convert.ToInt32(cur[5]), Convert.ToInt32(cur[6]) };
                                }
                            }
                            else
                            {
                                if (MainForm.userdata.level.StartsWith("OW") && MainForm.userdata.levelPass.Length > 0)
                                {
                                    param = new object[] { at, x, y, type };
                                }
                                else if (MainForm.userdata.level.StartsWith("OW") && MainForm.userdata.levelPass.Length == 0)
                                {
                                    if (y > 4)
                                    {
                                        param = new object[] { at, x, y, type };
                                    }
                                }
                                else
                                {
                                    param = new object[] { at, x, y, type };
                                }
                            }
                            if (conn == null)
                            {
                                OnStatusChanged("Lost connection!", DateTime.MinValue, true, Gtotal, Gcurrent);
                                return;
                            }
                            maxBlocks += 1;
                            Max1000   += 1;
                            if (MainForm.userdata.saveWorldCrew)
                            {
                                if (AnimateForm.saveRights)
                                {
                                    if (Max1000 == 1000 && Max1000 < Gtotal)
                                    {
                                        conn.Send("save");
                                        Max1000 = 0;
                                    }
                                }
                            }
                            int progress = (int)Math.Round((double)(100 * Gcurrent) / Gtotal);
                            if (progress == 50)
                            {
                                goto stopit;
                            }
                            else if (progress == 90)
                            {
                                goto stopit;
                            }
                            if (restart)
                            {
                                restart = false; goto stopit;
                            }

                            if (param != null)
                            {
                                conn.Send("b", param);
                            }
                            Thread.Sleep(MainForm.userdata.uploadDelay);



                            if (Gcurrent1 >= firstFrame.Count)
                            {
                                break;
                            }
                            else
                            {
                                queue.Enqueue(cur);
                                //if (bdata.morphable.Contains(type) || bdata.rotate.Contains(type)) Gcurrent++;
                            }

                            //queue.Enqueue(cur);
                        }


                        else
                        {
                            if (Gcurrent1 >= firstFrame.Count)
                            {
                                break;
                            }
                            else
                            {
                                queue.Enqueue(cur);
                            }
                            OnStatusChanged("Uploading blocks to level. (Total: " + firstFrame.Count + "/" + Gcurrent + ")", epochStartTime, false, Gtotal, Gcurrent);
                            if (pb.InvokeRequired)
                            {
                                pb.Invoke((MethodInvoker) delegate { pb.Maximum = firstFrame.Count; });
                            }
                            TaskbarProgress.SetValue(afHandle, Gcurrent, firstFrame.Count);
                            blocks.Clear();
                            break;
                        }
                    }
                }
            }


            //}
            //if (frames.Count > 1) goto restart;
            OnStatusChanged("Level upload complete!", DateTime.MinValue, true, firstFrame.Count, Gcurrent1);
            Gcurrent1 = 0;
            TaskbarProgress.SetValue(afHandle, Gcurrent1, firstFrame.Count);
            if (MainForm.userdata.saveWorldCrew)
            {
                if (AnimateForm.saveRights)
                {
                    conn.Send("save");
                }
            }
            blocks.Clear();
        }
コード例 #26
0
ファイル: main.cs プロジェクト: leejongseok/TeamProject
 void up_StreamProgressCallback(object sender, long maxsize, long Downloaded, ProgressBar progress)
 {
     if(progress.InvokeRequired)
     {
         progress.Invoke(ussv, new object[] { sender, maxsize, Downloaded, progress });
     }
     else
     {
         float per = ((float)Downloaded / maxsize) * 100;
         progress.Value = (int)per;
         progress.Controls[0].Text = string.Format("{0}%", (int)per);
     }
 }
コード例 #27
0
ファイル: main.cs プロジェクト: leejongseok/TeamProject
        void down_StreamCompleteCallback(object sender, ProgressBar progress)
        {
            if (progress.InvokeRequired)
                progress.Invoke(SDC, new object[] { sender, progress });
            else
            {
                MessageBox.Show("다운 완료");
                int index = downflowPanel.Controls.IndexOf(progress);
                downflowPanel.Controls.RemoveAt(index);
                down.Stop();
            }

        }
コード例 #28
0
ファイル: Class1.cs プロジェクト: gcorthey/CrossThreadLib
 /// <summary>
 /// Reset progress bar.
 /// </summary>
 /// <param name="control"></param>
 public static void ResetProgressBar(ProgressBar control)
 {
     if (control.InvokeRequired)
     {
         control.Invoke((System.Action)(() =>
         {
             control.PerformStep();
         }));
     }
     else
     {
         control.PerformStep();
     }
 }
コード例 #29
0
ファイル: main.cs プロジェクト: leejongseok/TeamProject
 void up_StreamCompleteCallback(object sender, ProgressBar progress)
 {
     if(progress.InvokeRequired)
     {
         progress.Invoke(uscp, new object[] { sender, progress });
     }
     else
     {
         MessageBox.Show("업로드 완료");
         int index = uploadflowpanel.Controls.IndexOf(progress);
         uploadflowpanel.Controls.RemoveAt(index);
         up.Stop();
     }
 }
コード例 #30
0
ファイル: AES.cs プロジェクト: reserad/D.E.D
        public void EncryptFile(string[] files, byte[] passwordBytes, string[] destinations, ProgressBar pb, int bytesToAllocate)
        {
            DateTime dt = new DateTime();
            var before = DateTime.Now;
            var totalSize = 0.0;
            int bytesRead = 0;
            foreach (var file in files) 
            {
                FileInfo fd = new FileInfo(file);
                totalSize += fd.Length;
            }
            
            passwordBytes = SHA256.Create().ComputeHash(passwordBytes);
            int percentage = 0;
            for (int i = 0; i < files.Length; i++) 
            {
                using (Stream source = File.OpenRead(files[i]))
                using (Stream dest = File.Create(destinations[i]))
                {
                    byte[] buffer = new byte[bytesToAllocate];
                    int bytes;
                    while ((bytes = source.Read(buffer, 0, buffer.Length)) > 0)
                    {
                        dest.Write(encoded(buffer, passwordBytes), 0, bytes);
                        bytesRead += bytes;
                        percentage = Convert.ToInt32((double)bytesRead / (double)totalSize * (double)100);

                        // runs on UI thread
                        pb.Invoke((MethodInvoker)delegate
                        {
                            pb.Value = percentage;
                        });
                    }
                }
                LogData(files[i], before, true);
            }

        }
コード例 #31
0
ファイル: DoPatch.cs プロジェクト: Windriderking/ME3Patch
        public static unsafe int Patch(string hPatchs, string hSources, string    hDests,ProgressBar pBar,Label lab,int FileID)
        {
            try
            {
                if (pBar.InvokeRequired == true)
                {
                    SetValue PSetValue = new SetValue(DoSetValue);
                    SetText LSetText = new SetText(DoSetText);
                    pBar.Invoke(PSetValue, new Object[] { pBar, 0 });
                    lab.Invoke(LSetText, new Object[] { lab, "0%" });
                }
                UInt32 BLOCKSIZE = 16384;
                UInt32 temp = 0;
                UInt32 read;
                byte[] source_md5 = new byte[16];
                byte[] patch_dest_md5 = new byte[16];
                byte[] block = new byte[BLOCKSIZE];
                int MD5Mode = 0;
                UInt32 patches = 0;
                int already_uptodate = 0,j=1;
                double blocks;
                FILETIME targetModifiedTime;
                DateTime dte = new DateTime() ;
                //write回调方法
                FileStream Patchs = new FileStream(hPatchs, FileMode.Open, FileAccess.Read, FileShare.Read);
                FileStream Sources = new FileStream(hSources, FileMode.Open, FileAccess.Read, FileShare.Read);
                FileStream Dests = new FileStream(hDests, FileMode.Create, FileAccess.ReadWrite, FileShare.ReadWrite);
                Hashtable Data = Program.filehash;
                // special 'addition' for the dll: since the patch file is now
                // in a seperate file, the VPAT header might be right at the start
                // of the file, and a pointer at the end of the file is probably missing
                // (because all patch generator versions don't append it, the linker/gui
                //  does this).
                Patchs.Seek(0, SeekOrigin.Begin);
                temp = Patchs.ReadValueU32(); read = 4;
                // it's not at the start of file -> there must be a pointer at the end of
                // file then
                if (temp != 0x54415056)
                {
                    Patchs.Seek(-4, SeekOrigin.End);
                    temp = Patchs.ReadValueU32(); read = 4;
                    Patchs.Seek(temp, SeekOrigin.Begin);
                    temp = Patchs.ReadValueU32(); read = 4;
                    if (temp != 0x54415056)
                        return result.PATCH_CORRUPT;
                }

                // target file date is by default the current system time
                GetSystemTimeAsFileTime(&targetModifiedTime);

                // read the number of patches in the file
                patches = Patchs.ReadValueU32(); read = 4;
                if (Convert.ToBoolean(patches & 0x80000000)) MD5Mode = 1;
                // MSB is now reserved for future extensions, anyone wanting more than
                // 16 million patches in a single file is nuts anyway
                patches = patches & 0x00FFFFFF;

                if (!Convert.ToBoolean(MD5Mode))
                {
                    return result.PATCH_UNSUPPORTED;
                }
                else
                {
                    source_md5 = checksum.FileMD5(Sources, Data, FileID,Program.AdvMOD);
                    if (source_md5 == null)
                        return result.PATCH_ERROR;
                }

                //pBar.Maximum = Convert.ToInt32(patches);
                while (Convert.ToBoolean(patches--))
                {
                    int patch_blocks = 0, patch_size = 0;

                    // flag which needs to be set by one of the checksum checks
                    int currentPatchMatchesChecksum = 0;

                    // read the number of blocks this patch has
                    patch_blocks = Convert.ToInt32(Patchs.ReadValueU32()); blocks = patch_blocks; read = 4;
                    if (!Convert.ToBoolean(patch_blocks))
                    {
                        return result.PATCH_CORRUPT;
                    }
                    if (pBar.InvokeRequired == true)
                    {
                        SetValue PSetValue = new SetValue(DoSetMax);
                        pBar.Invoke(PSetValue, new Object[] { pBar, Convert.ToInt32(patch_blocks) });
                    }
                    // read checksums
                    if (!Convert.ToBoolean(MD5Mode))
                    {
                        return result.PATCH_UNSUPPORTED;
                    }
                    else
                    {
                        int md5index;
                        byte[] patch_source_md5 = new byte[16];
                        patch_source_md5 = Patchs.ReadBytes(16); read = 16;
                        if (patch_source_md5 == null)
                        {
                            return result.PATCH_CORRUPT;
                        }
                        patch_dest_md5 = Patchs.ReadBytes(16); read = 16;
                        if (patch_dest_md5 == null)
                        {
                            return result.PATCH_CORRUPT;
                        }
                        // check to see if it's already up-to-date for some patch
                        for (md5index = 0; md5index < 16; md5index++)
                        {
                            if (source_md5[md5index] != patch_dest_md5[md5index]) break;
                            if (md5index == 15) already_uptodate = 1;
                        }
                        for (md5index = 0; md5index < 16; md5index++)
                        {
                            if (source_md5[md5index] != patch_source_md5[md5index]) break;
                            if (md5index == 15) currentPatchMatchesChecksum = 1;
                        }
                    }
                    // read the size of the patch, we can use this to skip over it
                    patch_size = Convert.ToInt32(Patchs.ReadValueU32()); read = 4;
                    if (patch_size == null)
                    {
                        return result.PATCH_CORRUPT;
                    }

                    if (Convert.ToBoolean(currentPatchMatchesChecksum))
                    {
                        while (Convert.ToBoolean(patch_blocks--))
                        {
                            if (pBar.InvokeRequired == true)
                            {
                                SetValue PSetValue = new SetValue(DoSetValue);
                                SetText LSetText = new SetText(DoSetText);
                                pBar.Invoke(PSetValue, new Object[] { pBar, Convert.ToInt32(j++) });
                                var per = Convert.ToDouble(j-1)/Convert.ToDouble(blocks);
                                lab.Invoke(LSetText, new Object[] { lab, Convert.ToString(Math.Ceiling(per*100)) + "%" });
                                Application.DoEvents();
                            }
                            Byte blocktype = 0;
                            UInt32 blocksize = 0;
                            blocktype = Convert.ToByte(Patchs.ReadByte()); read = 1;
                            if (blocktype==null)
                            {
                                return result.PATCH_CORRUPT;
                            }
                            switch (blocktype)
                            {
                                case 1:
                                case 2:
                                case 3:
                                    if (blocktype == 1)
                                    {
                                        Byte x;
                                        x = Convert.ToByte(Patchs.ReadByte()); read = 1;
                                        blocksize = Convert.ToUInt32(Convert.ToBoolean(x) ? x : 0);
                                    }
                                    else if (blocktype == 2)
                                    {
                                        UInt16 x;
                                        x = Patchs.ReadValueU16(); read = 2;
                                        blocksize = Convert.ToUInt32(Convert.ToBoolean(x) ? x : 0);
                                    }
                                    else
                                    {
                                        UInt32 x;
                                        x = Patchs.ReadValueU32(); read = 4;
                                        blocksize = Convert.ToUInt32(Convert.ToBoolean(x) ? x : 0);
                                    }
                                    temp = Patchs.ReadValueU32(); read = 4;
                                    if (!Convert.ToBoolean(blocksize) || temp == null || read != 4)
                                        return result.PATCH_CORRUPT;
                                    Sources.Seek(temp, SeekOrigin.Begin);
                                    //SetFilePointer(hSource, temp, 0, EMoveMethod.Begin);

                                    do
                                    {
                                        Sources.Read(block, 0, Convert.ToInt32(Math.Min(BLOCKSIZE, blocksize))); read = Math.Min(BLOCKSIZE, blocksize);
                                        if (block == null)
                                        {
                                            return result.PATCH_ERROR;
                                        }
                                        //IAsyncResult writeResult = Dests.BeginWrite(block,0,Convert.ToInt32(read),writeCallBack,"Write Target File");
                                        //Dests.EndWrite(writeResult);
                                        Dests.Write(block, 0, Convert.ToInt32(read));
                                        temp = read;
                                        //WriteFile(hDest, block, read, &temp, NULL);
                                        if (temp != Math.Min(BLOCKSIZE, blocksize))
                                            return result.PATCH_ERROR;
                                        blocksize -= temp;
                                    } while (Convert.ToBoolean(temp));

                                    break;

                                case 5:
                                case 6:
                                case 7:
                                    if (blocktype == 5)
                                    {
                                        Byte x;
                                        x = Convert.ToByte(Patchs.ReadByte()); read = 1;
                                        blocksize = Convert.ToUInt32(Convert.ToBoolean(x) ? x : 0);
                                    }
                                    else if (blocktype == 6)
                                    {
                                        UInt16 x;
                                        x = Patchs.ReadValueU16(); read = 2;
                                        blocksize = Convert.ToUInt32(Convert.ToBoolean(x) ? x : 0);
                                    }
                                    else
                                    {
                                        UInt32 x;
                                        x = Patchs.ReadValueU32(); read = 4;
                                        blocksize = Convert.ToUInt32(Convert.ToBoolean(x) ? x : 0);
                                    }

                                    if (!Convert.ToBoolean(blocksize))
                                        return result.PATCH_CORRUPT;

                                    do
                                    {
                                        Patchs.Read(block, 0, Convert.ToInt32(Math.Min(BLOCKSIZE, blocksize))); read = Math.Min(BLOCKSIZE, blocksize);
                                        if (block == null)
                                        {
                                            return result.PATCH_CORRUPT;
                                        }
                                        //IAsyncResult writeResult = Dests.BeginWrite(block, 0, Convert.ToInt32(read), writeCallBack, "Write Target File");
                                        //Dests.EndWrite(writeResult);
                                        Dests.Write(block, 0, Convert.ToInt32(read));
                                        temp = read;
                                        //WriteFile(hDest, block, read, &temp, NULL);
                                        if (temp != Math.Min(BLOCKSIZE, blocksize))
                                            return result.PATCH_ERROR;
                                        blocksize -= temp;
                                    } while (Convert.ToBoolean(temp));

                                    break;

                                case 255:   // read the file modified time from the patch
                                    targetModifiedTime.dwLowDateTime = (int)Patchs.ReadValueU32();
                                    targetModifiedTime.dwHighDateTime = (int)Patchs.ReadValueU32();

                                    /////////////////////////////////////////////////////////////////            //from System.Runtime.InteropServices.FILETIME to System.DateTime            /////////////////////////////////////////////////////////////////
                                    long _Value = (long) targetModifiedTime.dwHighDateTime << 32 | (long)(uint)targetModifiedTime.dwLowDateTime;
                                    dte = DateTime.FromFileTimeUtc(_Value);
                                    read = Convert.ToUInt32(Marshal.SizeOf(targetModifiedTime));
                                    //if(targetModifiedTime) {
                                    //return result.PATCH_CORRUPT;
                                    //}
                                    break;

                                default:
                                    return result.PATCH_CORRUPT;
                            }
                        }
                        if (!Convert.ToBoolean(MD5Mode))
                        {
                            return result.PATCH_UNSUPPORTED;
                        }
                        else
                        {

                           //int md5index;
                            byte[] dest_md5 = new byte[16];
                            Dests.Close();
                            Patchs.Close();
                            Sources.Close();
                            File.Delete(hPatchs);
                            File.Delete(hSources);
                            File.Move(hDests, hSources);
                            File.SetLastWriteTime(hSources, dte);
                            //FileStream Dest = new FileStream(hSources, FileMode.Open, FileAccess.Read, FileShare.None);
                            //dest_md5 = checksum.FileMD5(Dest, Data, -1);
                            //Dest.Close();
                            //if (dest_md5 == null)
                            //{
                             //   return result.PATCH_ERROR;
                           // }
                            //for (md5index = 0; md5index < 16; md5index++)
                            //{
                             //   if (dest_md5[md5index] != patch_dest_md5[md5index]) return result.PATCH_ERROR;
                            //}
                        }
                        // set file time

                        //SetFileTime(hDest, NULL, NULL, &targetModifiedTime);
                        return result.PATCH_SUCCESS;
                    }
                    else
                    {
                        Patchs.Seek(patch_size, SeekOrigin.Current);
                        //SetFilePointer(hPatch, patch_size, NULL, EMoveMethod.Current);
                    }
                }

                // if already up to date, it doesn't matter that we didn't match
                if (Convert.ToBoolean(already_uptodate))
                {
                    return result.PATCH_UPTODATE;
                }
                else
                {
                    return result.PATCH_NOMATCH;
                }
            }
            catch (Exception Err)
            {
                MessageBox.Show("出现错误:" + Err.Message, "信息提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
                return result.PATCH_ERROR;
            }
        }
コード例 #32
0
ファイル: CSVExport.cs プロジェクト: Rinsen/Tools
        public static String Persons(ref enterprise ep, ProgressBar progressbar = null)
        {
            try
            {
                var all = new StringBuilder("SourcedID,userID1,userID2,FullName,NameGiven,NameFamily,Email,Tel1,Tel2,Tel3,PostCode,Street,Locailty,Birthday,Gender,InstitutionRoleType,SystemRoleType");

                all.Append(
                    ",AltAdrExtAdd,AltAdrLocality,AltAdrPcode,AltAdrStreet,emailwork,employmentend,employmentstart");
                all.Append(
                    ",municipalitycode,municipalityname,nativelanguage,populationcityadmin,populationcityarea");
                all.Append(
                    ",populationkeycode,privacy,programcode,schoolunitcode,signature,timestamp");

                all.Append("\r\n");

                if (progressbar != null)
                {
                    int count = ep.group.ToList().Count - 1;
                    progressbar.Invoke(new Action(() => progressbar.Maximum = count));
                    progressbar.Invoke(new Action(() => progressbar.Value = 0));
                }

                foreach (person person in ep.person)
                {
                    if (progressbar != null)
                        if (progressbar.Maximum > progressbar.Value)
                            progressbar.Invoke(new Action(() => progressbar.Value++));

                    all.Append(Person(person));
                }

                return all.ToString();
            }
            catch (Exception e)
            {
                throw e;
            }
        }
コード例 #33
0
ファイル: function.cs プロジェクト: Windriderking/ME3Patch
        public static string AnyscMD5(string filepath, ProgressBar pBar, Label lab)
        {
            FileStream fs = new FileStream(filepath, FileMode.Open, FileAccess.Read, FileShare.Read);
            int bufferSize = 1048576; // 缓冲区大小,1MB
            byte[] buff = new byte[bufferSize];
            double blockcount = Math.Ceiling(fs.Length / Convert.ToDouble(bufferSize));
            if (pBar.InvokeRequired == true)
            {
                SetText LSetText = new SetText(DoSetText);
                SetValue PSetValue = new SetValue(DoSetMax);
                pBar.Invoke(PSetValue, new Object[] { pBar, Convert.ToInt32(blockcount) });
                lab.Invoke(LSetText, new Object[] { lab, Convert.ToString(0) + "%" });
            }
            int i = 1;
            MD5CryptoServiceProvider md5 = new MD5CryptoServiceProvider();
            md5.Initialize();
            long offset = 0;
            while (offset < fs.Length)
            {
                long readSize = bufferSize;
                if (offset + readSize > fs.Length)
                {
                    readSize = fs.Length - offset;
                }

                fs.Read(buff, 0, Convert.ToInt32(readSize)); // 读取一段数据到缓冲区

                if (offset + readSize < fs.Length) // 不是最后一块
                {
                    md5.TransformBlock(buff, 0, Convert.ToInt32(readSize), buff, 0);
                }
                else // 最后一块
                {
                    md5.TransformFinalBlock(buff, 0, Convert.ToInt32(readSize));
                }
                offset += bufferSize;
                if (pBar.InvokeRequired == true)
                {
                    SetValue PSetValue = new SetValue(DoSetValue);
                    SetText LSetText = new SetText(DoSetText);
                    pBar.Invoke(PSetValue, new Object[] { pBar, Convert.ToInt32(i) });
                    lab.Invoke(LSetText, new Object[] { lab, Convert.ToString(Math.Ceiling((double)(i / blockcount) * 100)) + "%" });
                    i++;
                    Application.DoEvents();
                }
            }
            fs.Close();
            byte[] result = md5.Hash;
            md5.Clear();
            StringBuilder sb = new StringBuilder(32);
            for (int j = 0; j < result.Length; j++)
            {
                sb.Append(result[j].ToString("x2"));
            }
            return sb.ToString();
        }
コード例 #34
0
ファイル: frmSetUp.cs プロジェクト: san90279/UK_OAS
 public void SetProgressBarValue(ProgressBar bar, int value)
 {
     if (value > bar.Maximum)
         value = bar.Maximum % value;
     if (!this.Disposing)
     {
         if (bar.InvokeRequired)
         {
             SetProgressBarValueMethod call = delegate(ProgressBar bard, int valued)
             {
                 bard.Value = valued;
             };
             bar.Invoke(call, new object[] { bar, value });
         }
         else
         {
             bar.Value = value;
         }
     }
 }
コード例 #35
0
        public static void SetValue(ProgressBar progressBar, int value)
        {
            MethodInvoker miSetValue = delegate
            {
                progressBar.Value = value;
            };

            if (progressBar.InvokeRequired)
            {
                progressBar.Invoke(miSetValue);
            }
            else
            {
                miSetValue();
            }
        }
コード例 #36
0
ファイル: Interface.cs プロジェクト: narugo/SteamGrouper
 public static void UpdateProgress(ProgressBar progressBar, int percentage)
 {
     // If the current thread is not the UI thread, InvokeRequired will be true
     if (progressBar.InvokeRequired)
     {
         // If so, call Invoke, passing it a lambda expression which calls
         // UpdateText with the same label and text, but on the UI thread instead.
         progressBar.Invoke((Action)(() => UpdateProgress(progressBar, percentage)));
         return;
     }
     // If we're running on the UI thread, we'll get here, and can safely update
     // the label's text.
     progressBar.Value = percentage;
 }
コード例 #37
-1
ファイル: CSVExport.cs プロジェクト: Rinsen/Tools
/*
        private static group findExtensionGroup(List<group> groups)
        {
            foreach(group group in groups)
            {
                if (group.extension != null)
                    if (group.extension.Any != null)
                        if (group.extension.Any.Length != 0)
                            return group;
            }

            return null;
        }
*/
        public static String Groups(ref enterprise ep, ProgressBar progressbar = null)
        {
            try
            {

                var all = new StringBuilder("SourcedID,DescriptionShort,DescriptionLong,GroupType,TimeFrameBegin,TimeFrameEnd,CourseCode,Points,SubjectCode,code,point,hours,grade,governedby,municipality_code,municipality_name,phone,code,street,locality,web,area_name,area_code,manager_area");
                all.Append("\r\n");

                if (progressbar != null)
                {
                    int count = ep.group.ToList().Count - 1;
                    progressbar.Invoke(new Action(() => progressbar.Maximum = count));
                    progressbar.Invoke(new Action(() => progressbar.Value = 0));
                }

                foreach (group group in ep.group)
                {
                    if (progressbar != null)
                        if (progressbar.Maximum > progressbar.Value)
                            progressbar.Invoke(new Action(() => progressbar.Value++));

                    all.Append(Group(group));
                }

                return all.ToString();
            }
            catch (Exception e)
            {
                throw e;
            }
        }
コード例 #38
-16
ファイル: ProgressStream.cs プロジェクト: Earth2Me/WinMD5
        public ProgressStream(Stream fs, ProgressBar progressBar)
        {
            this.fs=fs;
            //	this.readnotifycount=readnotifycount;
            this.progressBar=progressBar;
            this.fileLength=fs.Length;
            this.readnotifycount=fileLength/fileLengthDivider/numNotifications;

            progressBar.Invoke(new EventHandler(SetMaximumPosition));
        }