private void SendMessageToMainThread(string Message, DStatus Status, long FullSize, long CurrentBytes, TimeSpan TLeft) { try { // ISSUE: reference to a compiler-generated field if (this.UpdateStatusEvent == null) { return; } object[] objArray = new object[5] { (object)Message, (object)Status, (object)FullSize, (object)CurrentBytes, (object)TLeft }; if (this.ParentFormRef != null) { // ISSUE: reference to a compiler-generated field this.ParentFormRef.Invoke((Delegate)this.UpdateStatusEvent, objArray); } else { // ISSUE: reference to a compiler-generated field this.UpdateStatusEvent(Message, Status, FullSize, CurrentBytes, TLeft); } } catch { } }
protected override void EventCaller(string Message, DStatus Status, long FullSize, long CurrentBytes, TimeSpan EstimatedTimeLeft, double Speed) { if (StatusUpdateEvent != null) { StatusUpdateEvent(Message, Status, FullSize, CurrentBytes, EstimatedTimeLeft, Speed); } }
public Door(DStatus stat, INames opener, RNames leadsToRoom) { // Position = pos; Status = stat; CanBeOpenWith = opener; this.LeadsToRoom = leadsToRoom; }
// Original, Expected, Value, Target private static void Set(string o, string e, string[] l, ref List <DStatus> t) { if (o == e) { string[] x = string.Join(":", l).Split(' '); string evt = x[x.Length - 2]; string icn = x[x.Length - 1]; bool exist = false; foreach (var i in t) { if (i.Event == x[0]) { exist = true; } } if (!exist) { var d = new DStatus(); d.Event = evt; d.IcannURl = icn; t.Add(d); } } }
/// <summary> /// drop index form packet (convert DStatus to DStatusPacket) /// </summary> /// <param name="src"></param> /// <returns></returns> private static DStatusPacket dropIndexFromPacket(DStatus src) { DStatusPacket dst = new DStatusPacket(); dst.ID = src.ID; dst.Attributes = src.Attributes; return(dst); }
/// <summary> /// add index of database to DStatusPacket @src /// </summary> /// <param name="index"></param> /// <param name="src"></param> /// <returns></returns> private static DStatus addIndexToPacket(int index, DStatusPacket src) { DStatus dst = new DStatus(); dst.Index = index; dst.ID = src.ID; dst.Attributes = src.Attributes; return(dst); }
public void Start() { this.ThreadStop = false; this.AbortFlag = false; this.fThread = new Thread(new ThreadStart(this.Worker_Thread_01)); this.fThread.Priority = ThreadPriority.BelowNormal; this.fThread.IsBackground = true; this.fThread.Start(); this.CurrStatus = DStatus.started; this.TimeoutTimer.Start(); }
public void Start() { ThreadStop = false; AbortFlag = false; ThreadStart thr_start_func = new ThreadStart(Worker_Thread_01); fThread = new Thread(thr_start_func); fThread.Priority = ThreadPriority.BelowNormal; fThread.IsBackground = true; fThread.Start(); CurrStatus = DStatus.started; _TimeoutTimer.Start(); }
/// <summary> /// 更新上传进度条 /// </summary> /// <param name="Message"></param> /// <param name="Status"></param> /// <param name="FullSize"></param> /// <param name="CurrentBytes"></param> /// <param name="EstimatedTimeLeft"></param> /// <param name="Speed"></param> private void FtpClientCtrl_StatusUpdateEvent(string Message, DStatus Status, long FullSize, long CurrentBytes, TimeSpan EstimatedTimeLeft, double Speed) { toolStripLabelStatus.Text = Status.ToString(); label_mess.Text = Message; toolStripLabelTime.Text = BaseDownloader.TimeSpanToString(EstimatedTimeLeft); toolStripLabelSpeed.Text = Speed.ToString("F1") + " Kb/s"; isUpLoading = true; if (Status == DStatus.complete || Status == DStatus.error) { isUpLoading = false; if (Status == DStatus.complete) { listViewData.AppendLog(new string[] { image.FileName, Status.ToString() }); } } }
protected virtual void UpdateLocal(string Message, DStatus Status, long FullSize, long CurrentBytes, TimeSpan EstimatedTimeLeft, double Speed) { EventCaller(Message, Status, FullSize, CurrentBytes, EstimatedTimeLeft, Speed); if (FullSize != 0 && FullSize != -1) { if (_ProgrBar != null) { int Val = (int)(((double)CurrentBytes / (double)FullSize) * 100); if (Val > 100) { Val = 100; } _ProgrBar.Value = Val; } if (_ToolStripProgressBar != null) { int Val = (int)(((double)CurrentBytes / (double)FullSize) * 100); if (Val > 100) { Val = 100; } _ToolStripProgressBar.Value = Val; _ToolStripProgressBar.Owner.Refresh(); } if (_ProgressLabel != null) { _ProgressLabel.Text = CurrentBytes.ToString() + " Kb of " + FullSize.ToString() + " Kb"; } if (_TimeLabel != null) { _TimeLabel.Text = EstimatedTimeLeft.ToString(); } } }
private void _FileDownloader_UpdateStatusEvent(string Message, DStatus Status, long FullSize, long CurrentBytes, TimeSpan EstimatedTimeLeft) { this.label_status.Text = Message + "\n" + Status.ToString(); if (FullSize != 0L && FullSize != -1L) { this.progressBarControl1.EditValue = (int)((double)CurrentBytes / (double)FullSize * 100.0); this.label_curr_bytes.Text = CurrentBytes.ToString() + " Kb of " + FullSize.ToString() + " Kb"; } if (Status != DStatus.complete && Status != DStatus.failed) { ; } if (EstimatedTimeLeft.TotalMilliseconds <= 0.0) { return; } string str = EstimatedTimeLeft.ToString(); str.Substring(0, str.IndexOf('.')); }
// Methods // Take in the Direction and returns a Message to GameHandler // to help the player making next move // *********************************************************************** // NOTE !!ALL THE OUTPUT MESSAGES SHOULD BE PUT in an Array or Dictionary // so the Method GO and all the others need to return ONLY // ********************************************************************** public string Go(Dir dir) { // Note (int) because dir is enum. DStatus doorStatus = LoadGame.rooms[CurRoom].ExitDoors[(int)dir].Status; // Check first if I can move any direction (if there is a door or a wall) // I need the following regardless the position N,E, W,E. // if (doorStatus == DStatus.WALL) { msg = "I am sorry, but you hit a Wall!"; } else if (doorStatus == DStatus.Closed) { msg = "You find a door which is Closed. What would you like to do?"; } else { msg = "You find a door which is Open towards next room. What would you like to do?"; } return(msg); }
private void TimeoutTimer_Elapsed(object sender, ElapsedEventArgs e) { try { try { this.fs.Close(); } catch { } this.StopTimer.Stop(); this.TimeoutTimer.Stop(); this.AbortFlag = true; this.ThreadStop = true; Thread.Sleep(200); this.CurrStatus = DStatus.failed; this.SendMessageToMainThread("Timeout", this.CurrStatus, this.FileLength, this.BytesCounter); this.fThread.Abort(); } catch { } }
protected virtual void EventCaller(string Message, DStatus Status, long FullSize, long CurrentBytes, TimeSpan EstimatedTimeLeft, double Speed) { }
private void SendMessageToMainThread(string Message, DStatus Status, long FullSize, long CurrentBytes) { this.SendMessageToMainThread(Message, Status, FullSize, CurrentBytes, TimeSpan.Zero); }
// Methods // Take in the Direction and returns a Message to GameHandler // to help the player making next move // public string Go(Dir dir) { // Note (int) because dir is enum. DStatus doorStatus = LoadGame.rooms[CurRoom].exitDoors[(int)dir].Status; // Check first if I can move any direction (if there is a door or a wall) // I need the following regardless the position N,E, W,E. // if (doorStatus == DStatus.WALL) { msg = "I am sorry, but you hit a Wall!"; } else if (doorStatus == DStatus.Closed) { msg = "You find a door which is Locked. What would you like to do?"; } // If the players tries to move through an open door, the following will take place else { Console.Clear(); // NOTE - A bit confusing CurRoom as index and then assigned ;-)) CurRoom = LoadGame.rooms[CurRoom].exitDoors[(int)dir].LeadsToRoom; // Reads from list of rooms to find out where to go //ENDROOM if (LoadGame.rooms[CurRoom].EndPoint) { // Player has completed the game Console.Clear(); //string msg1 = "The medallion starts to glow and suddenly you start to levitate."; //string msg2 = "Congratulations you have solved the mystery and will now be set free."; string[] msg = { "You decide to walk through the newly opened doorway, entering the blinding light.", "You're finally able to leave this cursed mansion.", "Congratulations " + Name + ", you solved the mystery!" }; for (int i = 0; i < msg.Count(); i++) { GFXText.PrintTxt(-1, 5 + i * 2, Globals.TextTrail, Globals.TextDelay, msg[i], false, false); System.Threading.Thread.Sleep(Globals.SleepTime); } Console.ReadKey(); Environment.Exit(0); } //END OF ENDROOM if (LoadGame.rooms[CurRoom].Visited) // If the new room already visited (player backtracking), text will be printed instantly { GFXText.PrintTxt(Globals.RoomNameXPos, Globals.RoomNameYPos, 0, 0, LoadGame.rooms[CurRoom].Name, true, false); //GFXText.PrintTextWithHighlights(LoadGame.rooms[CurRoom].name, Globals.RoomNameXPos, Globals.RoomNameYPos, false); GFXText.PrintTextWithHighlights(LoadGame.rooms[CurRoom].Description, Globals.RoomDescriptionXPos, Globals.RoomDescriptionYPos, false); } else { GFXText.PrintTxt(Globals.RoomNameXPos, Globals.RoomNameYPos, Globals.TextTrail, Globals.TextDelay * 5, LoadGame.rooms[CurRoom].Name, false, false); //GFXText.PrintTextWithHighlights(LoadGame.rooms[CurRoom].name, Globals.RoomNameXPos, Globals.RoomNameYPos, true); // If the new room is not visited, text will be printed slowly GFXText.PrintTextWithHighlights(LoadGame.rooms[CurRoom].Description, Globals.RoomDescriptionXPos, Globals.RoomDescriptionYPos, true); LoadGame.rooms[CurRoom].Visited = true; } return(null); } return(msg); }
private void HttpConnect(string Url) { WebProxy webProxy = (WebProxy)null; try { switch (this._ProxyState) { case UseProxy.UseDefaultProxy: webProxy = WebProxy.GetDefaultProxy(); break; case UseProxy.UseProxy: webProxy = new WebProxy(this._proxyUri, this._ByPassLocal); webProxy.Credentials = (ICredentials) new NetworkCredential(this._UserName, this._UserPassword, this._Domain); break; } this.OutFileName = this._LocalFilePath; this.DNTWebRequest = (HttpWebRequest)WebRequest.Create(Url); this.DNTWebRequest.Proxy = (IWebProxy)webProxy; this.SendMessageToMainThread("trying to GetResponse()", DStatus.connecting, -1L, -1L, TimeSpan.Zero); this.DNTWebResponse = (HttpWebResponse)this.DNTWebRequest.GetResponse(); this.SendMessageToMainThread("Response received", DStatus.connected, -1L, -1L, TimeSpan.Zero); this.fs = new FileStream(this.OutFileName, FileMode.OpenOrCreate, FileAccess.Write); this.FileLength = this.DNTWebResponse.ContentLength; if (this.FileLength == -1L) { this.FileLength = 1L; } string contentType = this.DNTWebResponse.ContentType; this.SendMessageToMainThread("Download started", DStatus.started, this.FileLength, 0L, TimeSpan.Zero); Stream responseStream = this.DNTWebResponse.GetResponseStream(); this.TimeStart = DateTime.Now; int count1 = 10000; byte[] buffer = new byte[count1]; while (!this.ThreadStop) { int count2 = responseStream.Read(buffer, 0, count1); switch (count2) { case -1: case 0: goto label_10; default: this.fs.Write(buffer, 0, count2); this.SendMessageToMainThread("Downloading OK ", this.CurrStatus, this.FileLength, this.BytesCounter, this.CalcTimeLeft(this.TimeStart, this.FileLength, this.BytesCounter)); this.TimeoutTimer.Stop(); this.TimeoutTimer.Start(); this.BytesCounter = this.BytesCounter + (long)count2; this.CurrStatus = DStatus.downloading; continue; } } label_10: this.fs.Flush(); this.fs.Close(); } catch (Exception ex) { this.CurrStatus = DStatus.failed; this.SendMessageToMainThread(ex.Message, this.CurrStatus, this.FileLength, this.BytesCounter); this.TimeoutTimer.Stop(); return; } if (this.AbortFlag) { this.CurrStatus = DStatus.aborted; this.SendMessageToMainThread("download aborted", this.CurrStatus, this.FileLength, this.BytesCounter); } else { this.CurrStatus = DStatus.complete; this.SendMessageToMainThread(this.OutFileName, this.CurrStatus, this.FileLength, this.BytesCounter); } this.TimeoutTimer.Stop(); }
protected void UpdateStatusEventHandler(string Message, DStatus Status, long FullSize, long CurrentBytes, TimeSpan EstimatedTimeLeft, double Speed) { Invoke(new UpdateDelegate(UpdateLocal), new object[] { Message, Status, FullSize, CurrentBytes, EstimatedTimeLeft, Speed }); }
/// <summary> /// drop index form packet (convert DStatus to DStatusPacket) /// </summary> /// <param name="src"></param> /// <returns></returns> private static DStatusPacket dropIndexFromPacket(DStatus src) { DStatusPacket dst = new DStatusPacket(); dst.ID = src.ID; dst.Attributes = src.Attributes; return dst; }
/// <summary> /// add index of database to DStatusPacket @src /// </summary> /// <param name="index"></param> /// <param name="src"></param> /// <returns></returns> private static DStatus addIndexToPacket(int index, DStatusPacket src) { DStatus dst = new DStatus(); dst.Index = index; dst.ID = src.ID; dst.Attributes = src.Attributes; return dst; }
public static string Banco() { string n = DStatus.Obter().NomeBanco.ToString(); return(n); }
} // A door show a description when INSPECTED // Constructor // the values in the param list must be constrained to the enum above public Door(DStatus stat, INames opener) { // Position = pos; Status = stat; CanBeOpenWith = opener; }