Exemple #1
0
        private void InstallButton_Click(object sender, EventArgs e)
        {
            var random             = new Random();
            int CurrentProgressVal = 3;

            InstallButton.Hide();
            label1.Text          = "Installing...";
            label2.Text          = "Sit back and relax..........";
            PercentComplete.Text = "0% Complete";

            InstallProgressBar.Show();
            PercentComplete.Show();
            WarningMessage();

            PercentComplete.Text     = "3% complete";
            InstallProgressBar.Value = 3;
            WarningMessage();

            while (!(InstallProgressBar.Value >= 100))
            {
                CurrentProgressVal = random.Next(CurrentProgressVal, CurrentProgressVal + 20);
                if (CurrentProgressVal < 100)
                {
                    InstallProgressBar.Value = CurrentProgressVal;
                    PercentComplete.Text     = CurrentProgressVal + "% complete";
                }

                WarningMessage();
                Task.Delay(2000);
            }
        }
        // Module defining this command


        // Optional custom code for this activity


        /// <summary>
        /// Returns a configured instance of System.Management.Automation.PowerShell, pre-populated with the command to run.
        /// </summary>
        /// <param name="context">The NativeActivityContext for the currently running activity.</param>
        /// <returns>A populated instance of Sytem.Management.Automation.PowerShell</returns>
        /// <remarks>The infrastructure takes responsibility for closing and disposing the PowerShell instance returned.</remarks>
        protected override ActivityImplementationContext GetPowerShell(NativeActivityContext context)
        {
            System.Management.Automation.PowerShell invoker       = global::System.Management.Automation.PowerShell.Create();
            System.Management.Automation.PowerShell targetCommand = invoker.AddCommand(PSCommandName);

            // Initialize the arguments

            if (Activity.Expression != null)
            {
                targetCommand.AddParameter("Activity", Activity.Get(context));
            }

            if (Status.Expression != null)
            {
                targetCommand.AddParameter("Status", Status.Get(context));
            }

            if (ProgressId.Expression != null)
            {
                targetCommand.AddParameter("Id", ProgressId.Get(context));
            }

            if (PercentComplete.Expression != null)
            {
                targetCommand.AddParameter("PercentComplete", PercentComplete.Get(context));
            }

            if (SecondsRemaining.Expression != null)
            {
                targetCommand.AddParameter("SecondsRemaining", SecondsRemaining.Get(context));
            }

            if (CurrentOperation.Expression != null)
            {
                targetCommand.AddParameter("CurrentOperation", CurrentOperation.Get(context));
            }

            if (ParentId.Expression != null)
            {
                targetCommand.AddParameter("ParentId", ParentId.Get(context));
            }

            if (Completed.Expression != null)
            {
                targetCommand.AddParameter("Completed", Completed.Get(context));
            }

            if (SourceId.Expression != null)
            {
                targetCommand.AddParameter("SourceId", SourceId.Get(context));
            }


            return(new ActivityImplementationContext()
            {
                PowerShellInstance = invoker
            });
        }
Exemple #3
0
        public virtual string FormatText(bool html = false)
        {
            var text = String.Format("{0} {1}", Text, DisplayPercent ? PercentComplete.ToString("0.##%") : String.Empty);

            if (html && !String.IsNullOrWhiteSpace(text))
            {
                text = text.WrapUOHtmlColor(TextColor, false).WrapUOHtmlTag("center");
            }

            return(text);
        }
Exemple #4
0
 public override int GetHashCode()
 {
     unchecked
     {
         var hashCode = TimeRemaining.GetHashCode();
         hashCode = (hashCode * 397) ^ (int)State;
         hashCode = (hashCode * 397) ^ (Status != null ? Status.GetHashCode() : 0);
         hashCode = (hashCode * 397) ^ PercentComplete.GetHashCode();
         return(hashCode);
     }
 }
Exemple #5
0
 public Form1()
 {
     InitializeComponent();
     NameBox.Hide();
     NameInput.Hide();
     CompanyBox.Hide();
     CompanyInput.Hide();
     PurposeBox.Hide();
     PurposeInput.Hide();
     EmailBox.Hide();
     EmailInput.Hide();
     SubmitDetails.Hide();
     InstallButton.Hide();
     PercentComplete.Hide();
     InstallProgressBar.Hide();
 }
Exemple #6
0
        ///<inheritdoc/>
        public override int GetHashCode()
        {
            int hash = 17;

            // Overflow is fine, just wrap
            unchecked
            {
                hash = (hash * 29) + PercentComplete.GetHashCode();
                hash = (hash * 29) + Damage.GetHashCode();
                hash = (hash * 29) + Predistributed.GetHashCode();
                hash = (hash * 29) + State.GetHashCode();
                hash = (hash * 29) + Smoking.GetHashCode();
                hash = (hash * 29) + Flaming.GetHashCode();
            }

            return(hash);
        }
Exemple #7
0
 public ProgressNotifier(PercentComplete clientToNotify, int recordCount)
 {
     percentCompleteClient = clientToNotify;
     this.recordCount      = recordCount;
     UpdateProgress();
 }
 public ProgressNotifier(PercentComplete clientToNotify, int recordCount)
 {
     percentCompleteClient = clientToNotify;
     this.recordCount = recordCount;
     UpdateProgress();
 }
Exemple #9
0
    protected override void OnUpdate()
    {
        EntityCommandBuffer ecb = new EntityCommandBuffer(Allocator.Temp);

        var random   = m_Random;
        var roadInfo = GetSingleton <RoadInfo>();

        // can't use Burst if we set a shared component (even using ecb)
        // (not a big loss for spwaning on init)
        Entities.WithoutBurst().ForEach((Entity e, in AgentSpawner spawner) =>
        {
            var bufferEntity = ecb.CreateEntity();
            var buffer       = ecb.AddBuffer <SpawnPosition>(bufferEntity);

            for (int i = 0; i < roadInfo.MaxLanes; i++)
            {
                for (float j = 0; j < 1f; j += roadInfo.CarSpawningDistancePercent)
                {
                    buffer.Add(new SpawnPosition
                    {
                        Lane    = i,
                        Percent = j
                    });
                }
            }

            for (int i = 0; i < spawner.NumAgents; i++)
            {
                var spawnedEntity = ecb.Instantiate(spawner.Prefab);

                if (buffer.Length == 0)
                {
                    break;
                }

                int randomIndex = random.NextInt(buffer.Length - 1);
                var pos         = buffer[randomIndex];
                buffer.RemoveAt(randomIndex);

                LaneAssignment laneAssignment = new LaneAssignment()
                {
                    Value = pos.Lane
                };

                TargetSpeed targetSpeed = new TargetSpeed()
                {
                    Value = random.NextFloat(spawner.MinSpeed, spawner.MaxSpeed)
                };

                PercentComplete percentComplete = new PercentComplete()
                {
                    Value = pos.Percent
                };

                OvertakeSpeedIncrement osi = new OvertakeSpeedIncrement()
                {
                    Value = spawner.OvertakeIncrement
                };

                ecb.SetComponent(spawnedEntity, osi);
                ecb.SetComponent(spawnedEntity, percentComplete);
                ecb.SetComponent(spawnedEntity, targetSpeed);
                ecb.AddComponent(spawnedEntity, laneAssignment);
                //ecb.SetComponent(spawnedEntity, translation);
            }

            ecb.RemoveComponent <AgentSpawner>(e);
        }).Run();

        ecb.Playback(EntityManager);
        m_Random = random;
    }