Пример #1
0
 private void SetKataProgress(ProgressEvent progressEvent)
 {
     if (KataProgress != null)
     {
         KataProgress(this, new KataProgressEventArgs(progressEvent));
     }
 }
Пример #2
0
        private void Controller_OnLoginProgress(ProgressEvent e)
        {
            var stage = e.Done;

            LoginProgress.ProgressCaption = GameFacade.Strings.GetString("210", (stage + 3).ToString());
            LoginProgress.Progress        = 25 * stage;
        }
Пример #3
0
        private string CreateJsonObject(ProgressEvent progressEvent, string attemptName)
        {
            var kataStartTime       = progressEvent.KataStartTime;
            var attemptCreationTime = GetAttemptCreationTime(attemptName);

            if (kataStartTime == DateTime.MinValue)
            {
                kataStartTime = attemptCreationTime;
            }
            return(JsonConvert.SerializeObject(new
            {
                userName = GetUserName(),
                attemptName,
                timestamp = GetTimestamp(),
                attemptCreationTime,
                kataStartTime,
                appVersion = GetAppVersion(),
                kataName = _kataHelper.GetKataName(attemptName),
                progressEvent
            }, new JsonSerializerSettings
            {
                ContractResolver = new CamelCasePropertyNamesContractResolver(),
                NullValueHandling = NullValueHandling.Ignore
            }));
        }
Пример #4
0
        /// <summary>
        /// Performs the find request to the specified remote dicom server with the specified attributes.
        /// </summary>
        /// <param name="clientAETitle">The client AE title.</param>
        /// <param name="remoteAE">The remote AE.</param>
        /// <param name="remoteHost">The remote host.</param>
        /// <param name="remotePort">The remote port.</param>
        /// <param name="requestAttributeCollection">The request attribute collection.</param>
        /// <returns></returns>
        public IList <DicomAttributeCollection> Find(string clientAETitle, string remoteAE, string remoteHost, int remotePort, DicomAttributeCollection requestAttributeCollection)
        {
            if (requestAttributeCollection == null)
            {
                throw new ArgumentNullException("requestAttributeCollection");
            }

            _requestAttributeCollection = requestAttributeCollection;
            if (!ValidateQuery())
            {
                throw new InvalidOperationException(String.Format(CultureInfo.InvariantCulture, "Invalid query for SCU type {0}", GetType().FullName.Substring(GetType().FullName.LastIndexOf(".") + 1)));
            }

            _results = new List <DicomAttributeCollection>();

            if (ReuseAssociation && Status == ScuOperationStatus.Running)
            {
                ProgressEvent.Reset();

                SendFindRequest(_dicomClient, _associationParameters);

                ProgressEvent.WaitOne();
            }
            else
            {
                ClientAETitle = clientAETitle;
                RemoteAE      = remoteAE;
                RemoteHost    = remoteHost;
                RemotePort    = remotePort;

                Connect();
            }

            return(_results);
        }
Пример #5
0
        /// <summary>
        /// Another stage in the CityServer transition progress was done.
        /// </summary>
        /// <param name="e"></param>
        private void OnTransitionProgress(ProgressEvent e)
        {
            var stage = e.Done;

            m_LoginProgress.ProgressCaption = GameFacade.Strings.GetString("251", (stage + 4).ToString());
            m_LoginProgress.Progress        = 25 * stage;
        }
Пример #6
0
        /// <summary>
        /// Received a status update from the CityServer.
        /// Occurs after sending CharacterCreation packet.
        /// </summary>
        /// <param name="e">Status of character creation.</param>
        private void Controller_OnCharacterCreationStatus(CharacterCreationStatus CCStatus)
        {
            switch (CCStatus)
            {
            case CharacterCreationStatus.Success:
                if (m_Dead)
                {
                    return;
                }
                ProgressEvent Progress = new ProgressEvent(EventCodes.PROGRESS_UPDATE);
                Progress.Done  = 1;
                Progress.Total = 3;

                //Lord have mercy on the soul who figures out why commenting out the below line
                //causes the city to show...
                //OnTransitionProgress(Progress);
                GameFacade.Controller.ShowCity();
                m_Dead = true;
                break;

            case CharacterCreationStatus.GeneralError:
                Controller_OnNetworkError(new SocketException());
                break;
            }
        }
Пример #7
0
        public void progressChanged(ProgressEvent progressEvent)
        {
            int eventCode = progressEvent.getEventCode();

            if (eventCode == ProgressEvent.STARTED)
            {
                Console.WriteLine("Started.");
            }
            else if (eventCode == ProgressEvent.COMPLETED)
            {
                Console.WriteLine("Completed.");
            }
            else if (eventCode == ProgressEvent.FAILED)
            {
                Console.WriteLine("Failed.");
            }
            else if (eventCode == ProgressEvent.CANCELED)
            {
                Console.WriteLine("Cancled.");
            }
            else if (eventCode == ProgressEvent.TRANSFERRED)
            {
                this.completedSize += progressEvent.getBytesTransferred();
                int newRate = (int)((double)completedSize / size * 100 + 0.5);
                if (newRate > this.rate)
                {
                    this.rate = newRate;
                    Console.WriteLine("Processing ... " + this.rate + "%");
                }
            }
        } // end of progressChanged
Пример #8
0
        internal static bool SendProgressEvent(ProgressEvent evt, string arg)
        {
            bool sent = false;

            switch (evt)
            {
            case ProgressEvent.Begin:
                sent = tcpClient.SendChannelMessage("progress-event-begin", arg);
                break;

            case ProgressEvent.Report:
                sent = tcpClient.SendChannelMessage("progress-event-report", arg);
                break;

            case ProgressEvent.End:
                sent = tcpClient.SendChannelMessage("progress-event-end", arg);
                break;

            default:
                break;
            }

            if (!sent)
            {
                Log($"Status {evt} was NOT sent over tcp socket...");
            }
            else
            {
                Log($"Status {evt} sent to client...");
            }

            return(sent);
        }
Пример #9
0
 private void ConfigureProgress(MediaFileReader reader)
 {
     if (ProgressEvent != null)
     {
         reader.ProgressEvent += (sender, args) => ProgressEvent?.Invoke(sender, args);
     }
 }
Пример #10
0
        public void SetLatestResult_GivenResultsStartAtLevel1_ShouldCreateProgressEventAsNotCompleted()
        {
            //---------------Set up test pack-------------------
            var attemptGameState = CreateAttemptGameState(new List <Result>());

            attemptGameState.SetLatestResult(CreateResult(1, 1, "Green"));
            attemptGameState.SetLatestResult(CreateResult(1, 2, "Red"));
            attemptGameState.SetLatestResult(CreateResult(2, 2, "Green"));
            attemptGameState.SetLatestResult(CreateResult(2, 3, "Red"));
            var           progressEventCreated = false;
            ProgressEvent progressEvent        = null;

            attemptGameState.KataProgress += (sender, args) =>
            {
                progressEventCreated = true;
                progressEvent        = args.ProgressEvent;
            };
            //---------------Assert Precondition----------------
            Assert.IsFalse(progressEventCreated);
            //---------------Execute Test ----------------------
            attemptGameState.SetLatestResult(CreateResult(3, 3, "Green"));
            //---------------Test Result -----------------------
            Assert.IsNotNull(progressEvent);
            Assert.AreEqual("1,2,3", progressEvent.LevelsCompleted);
            Assert.IsFalse(progressEvent.KataCompleted);
            Assert.IsTrue(progressEvent.AllLevelsCompleted);
        }
Пример #11
0
        public ProgressArgs( ProgressEvent progressEvent,
			string message,
			Image image )
        {
            ProgressEvent = progressEvent ;
            Message = message ;
            Image = image ;
        }
Пример #12
0
 protected override void Run()
 {
     if (Interlocked.Read(ref work) != 0)
     {
         Repairing();
         ProgressEvent?.Invoke(owner);
     }
 }
Пример #13
0
 public RunForDuration(float _duration, ProgressEvent _progressEvent, Func <float> _timeScaleFunc = null)
 {
     progressEvent = _progressEvent;
     timeScaleFunc = _timeScaleFunc ?? (() => 1f);
     duration      = _duration;
     inverted      = false;
     t             = 0;
 }
Пример #14
0
 internal ProgressEvent InvokeEvent(ProgressEvent arg)
 {
     if (_api.ValidateEvent(arg))
     {
         Progress?.Invoke(_api, arg);
     }
     return(arg);
 }
Пример #15
0
        /// <summary>
        /// Calculates the progress based on the given from and to params.
        /// Caller must ensure that the to value is > 0.
        /// </summary>
        /// <param name="from"></param>
        /// <param name="to">Must be > 0.</param>
        /// <param name="text">Description of the current task.</param>
        public void OnProgress(int from, int to, string text)
        {
            int progress = (int)(from / (float)to * 100);

            _progress = progress;
            _text     = text;
            ProgressEvent?.Invoke(progress, text);
        }
Пример #16
0
 public void RemoveProgressEvent(ProgressEvent pEvent)
 {
     if (_progressEvents.Count == 0)
     {
         return;
     }
     _progressEvents.Remove(pEvent);
     _progressEvents.TrimExcess();
 }
Пример #17
0
 private void OnProgressEvent(string filename, string text, bool error = false)
 {
     ProgressEvent?.Invoke(this, new ProgressEventArgs
     {
         FileName     = filename,
         ProgressText = text,
         Error        = error
     });
 }
Пример #18
0
        private void Controller_OnLoginNotifyCity()
        {
            ProgressEvent Progress =
                new ProgressEvent(EventCodes.PROGRESS_UPDATE);

            Progress.Done  = 2;
            Progress.Total = 3;
            OnTransitionProgress(Progress);
        }
Пример #19
0
        public static void Initialize()
        {
            worker.DoWork += delegate(object s, DoWorkEventArgs args)
            {
                List <Package> paks = (List <Package>)args.Argument;

                CleanUpTempFiles(paks[0].list);  //TODO

                foreach (Package pak in paks)
                {
                    float progressChunk = (paks.IndexOf(pak) + 1) * progressChunksPerPackage;

                    worker.ReportProgress((int)progressChunk - 4, string.Format("Downloading {0}...", pak.name));
                    System.Threading.Thread.Sleep(10);
                    DownloadPackage(pak);

                    if (doFullInstall)
                    {
                        worker.ReportProgress((int)progressChunk - 3, "Unpacking archive...");
                        System.Threading.Thread.Sleep(10);
                        Unpack(pak);
                        worker.ReportProgress((int)progressChunk - 2, string.Format("Installing {0}...", pak.name));
                        System.Threading.Thread.Sleep(10);
                        InstallPackage(pak);
                        worker.ReportProgress((int)progressChunk - 1, "Cleaning up...");
                        System.Threading.Thread.Sleep(10);
                        DeleteArchive(pak);
                    }
                }

                worker.ReportProgress(GetProgressBarLength(paks.Count), "Done!");
            };

            worker.ProgressChanged += delegate(object s, ProgressChangedEventArgs args)
            {
                ProgressEvent.Invoke(null, new object[] { args.ProgressPercentage, args.UserState });
            };

            worker.RunWorkerCompleted += delegate(object s, RunWorkerCompletedEventArgs args)
            {
                if (args.Error != null)
                {
                    Log.Write(args.Error);
                    if (args.Error.InnerException != null)
                    {
                        Log.Write(args.Error.InnerException);
                    }

                    CompleteEvent.Invoke(null, false);
                    return;
                }
                else
                {
                    CompleteEvent.Invoke(null, true);
                }
            };
        }
Пример #20
0
        static void stream_progress(ProgressEvent e)
        {
            Download d = e.target as Download;

            if (d != null)
            {
                Read(d);
            }
        }
Пример #21
0
 /// <summary>
 /// Cancels the operation.
 /// </summary>
 public void Cancel()
 {
     if (LogInformation)
     {
         Platform.Log(LogLevel.Info, "Canceling...");
     }
     Status = ScuOperationStatus.Canceled;
     ProgressEvent.Set();
 }
 private async void PlayerOnProgressAsync(object sender, ProgressEvent e) =>
 await AddCommand(new SetCommanderRankPilot(RankType.Combat, (double)e.Combat / 100))
 .AddCommand(new SetCommanderRankPilot(RankType.Cqc, (double)e.Cqc / 100))
 .AddCommand(new SetCommanderRankPilot(RankType.Empire, (double)e.Empire / 100))
 .AddCommand(new SetCommanderRankPilot(RankType.Explore, (double)e.Explore / 100))
 .AddCommand(new SetCommanderRankPilot(RankType.Federation, (double)e.Federation / 100))
 .AddCommand(new SetCommanderRankPilot(RankType.Trade, (double)e.Trade / 100))
 .SendAsync()
 .ConfigureAwait(false);
Пример #23
0
        public void LoadRegion(GeoRegion region, ProgressEvent ev)
        {
            vis_tree.ClearTree();
            models.Clear();
            //
            setTreeBounds(region);
            //
            int      x, y, i = 0;
            int      max = REGION_SIZE * REGION_SIZE;
            GeoBlock block;
            Vector3  min = new Vector3();

            for (y = 0; y < REGION_SIZE; y++)
            {
                for (x = 0; x < REGION_SIZE; x++)
                {
                    block = region.getBlockByBlockXY(x, y);
                    foreach (GeoModel m in createBlock(block))
                    {
                        if (i == 0)
                        {
                            min = m.Position;
                        }
                        else
                        {
                            if (m.Position.X < min.X)
                            {
                                min.X = m.Position.X;
                            }
                            if (m.Position.Y > min.Y)
                            {
                                min.Y = m.Position.Y;
                            }
                            if (m.Position.Z < min.Z)
                            {
                                min.Z = m.Position.Z;
                            }
                        }
                        //
                        i++;
                    }
                    //
                    if (ev != null)
                    {
                        float p = (y * REGION_SIZE + x) / (float)max;
                        ev((int)(p * 100f));
                    }
                }
            }
            //
            Camera.Rotation.X = 45f;
            Camera.Position.X = min.X - 20f;
            Camera.Position.Z = min.Z - 20f;
            Camera.Position.Y = min.Y + 20f;
            Camera.UpdateWorldView();
        }
Пример #24
0
        //=========================

        public void Run(ProgressEvent on_progress)
        {
            ScriptCompiler compiler = new ScriptCompiler();

            compiler.ScriptMgr = ScriptMgr;
            compiler.Run();
            //
            CompilerResult = compiler.Result;
            if (!compiler.Result.IsSuccess)
            {
                return;
            }
            //
            ScriptMgr.Items.SortByLevel();
            int total = ScriptMgr.Count;
            //
            string filename = Paths.GetAIData();

            using (FileStream stream = File.Open(filename, FileMode.Create, FileAccess.Write))
                using (StreamWriter writer = new StreamWriter(stream, Encoding.Unicode)) {
                    int c = ScriptMgr.Header.Count;
                    for (int i = 0; i < c; i++)
                    {
                        if (i > 0)
                        {
                            writer.WriteLine();
                        }
                        writer.Write(ScriptMgr.Header[i].ToString(' '));
                    }
                    //
                    writer.WriteLine();
                    writer.WriteLine();
                    writer.WriteLine();
                    //
                    int index = 0;
                    foreach (ScriptItem script in ScriptMgr.Items)
                    {
                        script.IsModified = false;
                        //
                        if (index > 0)
                        {
                            writer.WriteLine();
                            writer.WriteLine();
                        }
                        //
                        writer.Write(script.Source);
                        //
                        index++;
                        int p = (int)(index / (float)total * 100f);
                        if (OnProgress != null)
                        {
                            OnProgress.Invoke(p);
                        }
                    }
                }
        }