Example #1
0
 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
     {
     }
 }
Example #2
0
 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);
     }
 }
Example #3
0
 public Door(DStatus stat, INames opener, RNames leadsToRoom)
 {
     // Position = pos;
     Status           = stat;
     CanBeOpenWith    = opener;
     this.LeadsToRoom = leadsToRoom;
 }
Example #4
0
        // 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);
                }
            }
        }
Example #5
0
        /// <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);
        }
Example #6
0
        /// <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);
        }
Example #7
0
 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();
 }
Example #8
0
        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();
        }
Example #9
0
 /// <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() });
         }
     }
 }
Example #10
0
        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();
                }
            }
        }
Example #11
0
        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('.'));
        }
Example #12
0
        // 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);
        }
Example #13
0
 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
     {
     }
 }
Example #14
0
 protected virtual void EventCaller(string Message, DStatus Status, long FullSize, long CurrentBytes, TimeSpan EstimatedTimeLeft, double Speed)
 {
 }
Example #15
0
 private void SendMessageToMainThread(string Message, DStatus Status, long FullSize, long CurrentBytes)
 {
     this.SendMessageToMainThread(Message, Status, FullSize, CurrentBytes, TimeSpan.Zero);
 }
Example #16
0
        // 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);
        }
Example #17
0
        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();
        }
Example #18
0
 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;
 }
Example #21
0
        public static string Banco()
        {
            string n = DStatus.Obter().NomeBanco.ToString();

            return(n);
        }
Example #22
0
        }                                                       // 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;
        }