Esempio n. 1
0
        private void finalize()
        {
            if (player1cards.InvokeRequired && player2cards.InvokeRequired &&
                tableCard.InvokeRequired && p1c1.InvokeRequired && p1c2.InvokeRequired &&
                p2c1.InvokeRequired && p2c2.InvokeRequired &&
                tc1.InvokeRequired && tc2.InvokeRequired &&
                tc3.InvokeRequired && tc4.InvokeRequired && tc5.InvokeRequired)
            {
                Finalize f = new Finalize(finalize);
                Invoke(f, new object[] { });
            }
            else
            {
                isAllIn            = false;
                player1cards.Text  = "";
                player2cards.Text  = "";
                tableCard.Text     = "Card on table:";
                winner.Text        = "Winners: ";
                msg_action         = "";
                p1c1.ImageLocation = null;
                p1c2.ImageLocation = null;

                p2c1.ImageLocation = null;
                p2c2.ImageLocation = null;

                tc1.ImageLocation = null;
                tc2.ImageLocation = null;

                tc3.ImageLocation = null;
                tc4.ImageLocation = null;
                tc5.ImageLocation = null;
            }
        }
Esempio n. 2
0
        protected async override Task RunAsync(Execution <HandleContext> execution)
        {
            try
            {
                using (IHandlerInstance handler = await CreateHandler.RunAsync(execution.Context).ConfigureAwait(false))
                {
                    var handleContext = new HandlerContext(execution.Context.Message.Payload, handler.Current, execution.Context.Message);
                    await BeginHandle.RunAsync(handleContext).ConfigureAwait(false);

                    await ActualHandle.RunAsync(handleContext).ConfigureAwait(false);

                    await EndHandle.RunAsync(handleContext).ConfigureAwait(false);
                }
            }
            catch (Exception ex)
            {
                var context = new ErrorContext(ex, execution.Context.Message, execution.Context.HandlerType);
                context.AssignPropertySafely <IWorkflowContextWithServiceProvider>(prop => prop.ServiceProvider = execution.Context.ServiceProvider);
                await Error.RunAsync(context).ConfigureAwait(false);

                throw;
            }
            finally
            {
                await Finalize.RunAsync(execution.Context).ConfigureAwait(false);
            }
        }
Esempio n. 3
0
 //opens new form to confirm queue
 private void QueueBut_Click(object sender, EventArgs e)
 {
     //makes sure at least one row is selected
     if (businessDataGridView.SelectedRows.Count != 0)
     {
         //grabs username from row selected
         DataGridViewRow row   = businessDataGridView.SelectedRows[0];
         Finalize        queue = new Finalize(row.Cells["Here"].Value.ToString(), username);
         queue.Show();
     }
     else
     {
         MessageBox.Show("Please select a business to queue for");
     }
 }
        public async Task ArrayToTableString(byte[] output, int outputLenth = 0)
        {
            if (output.Length == 0)
            {
                throw new ArgumentException("File is empty");
            }

            if (OutputActionAsync.GetInvocationList() == null || OutputActionAsync.GetInvocationList().Length == 0)
            {
                isProgressAsync = false;
            }
            else
            {
                isProgressAsync = true;
            }

            var writingLenth = outputLenth != 0 ? outputLenth : output.Length;

            for (int i = 0; i < writingLenth; i++)
            {
                if (i % byteLineWidth == 0 && i != 0)
                {
                    if (isProgressAsync)
                    {
                        await OutputActionAsync?.Invoke("|\n");

                        await OutputActionAsync?.Invoke($"{RowLine}\n");
                    }
                    else
                    {
                        OutputAction?.Invoke("|\n");
                        OutputAction?.Invoke($"{RowLine}\n");
                    }
                }
                if (isProgressAsync)
                {
                    await OutputActionAsync?.Invoke(AlignCentre(output[i]));
                }
                else
                {
                    OutputAction?.Invoke(AlignCentre(output[i]));
                }

                WritingProgess = (double)(i + 1) / writingLenth;
            }

            Finalize?.Invoke();
        }
        public async Task ArrayToTableString(bool[] output, int outputLenth = 0)
        {
            if (output.Length == 0)
            {
                throw new ArgumentException("File is empty");
            }

            var writingLenth = outputLenth != 0 ? outputLenth : output.Length;

            for (int i = 0; i < writingLenth; i++)
            {
                if (i % binaryLineWidth == 0 && i != 0)
                {
                    if (isProgressAsync)
                    {
                        await OutputActionAsync?.Invoke("|\n");

                        await OutputActionAsync?.Invoke($"{RowLine}\n");
                    }
                    else
                    {
                        OutputAction?.Invoke("|\n");
                        OutputAction?.Invoke($"{RowLine}\n");
                    }
                }
                if (isProgressAsync)
                {
                    await OutputActionAsync?.Invoke($"| {Convert.ToInt16(output[i])} ");
                }
                else
                {
                    OutputAction?.Invoke($"| {Convert.ToInt16(output[i])} ");
                }

                WritingProgess = (double)(i + 1) / writingLenth;
            }

            Finalize?.Invoke();
        }
Esempio n. 6
0
        protected override void Run(Execution <HandleContext> execution)
        {
            try
            {
                using (IHandlerInstance handler = CreateHandler.Run(execution.Context))
                {
                    var handleContext = new HandlerContext(execution.Context.Message.Payload, handler.Current, execution.Context.Message);
                    BeginHandle.Run(handleContext);
                    new DiagnosticsWorkflow <HandlerContext>(ActualHandle).Run(handleContext);
                    EndHandle.Run(handleContext);
                }
            }

            catch (Exception ex)
            {
                Error.Run(new ErrorContext(ex, execution.Context.Message, execution.Context.HandlerType));
                throw;
            }
            finally
            {
                Finalize.Run(execution.Context);
            }
        }
Esempio n. 7
0
 private void dataGridView1_CellClick(object sender, DataGridViewCellEventArgs e)
 {
     if (Convert.ToString(dataGridView1[e.ColumnIndex, e.RowIndex].Value) == "")
     {
         dataGridView1[e.ColumnIndex, e.RowIndex].Value = num;
         Numb.Remove(num);
         count++;
         Bot.Step(Convert.ToInt32(label6.Text));
     }
     else
     {
         MessageBox.Show("Значения ячеек неизменны");
         return;
     }
     if (count < 25)
     {
         num         = Numb[random.Next(Numb.Count)];
         label6.Text = Convert.ToString(num);
     }
     if (count == 25)
     {
         int[,] table1 = new int[5, 5];
         int[,] table2 = new int[5, 5];
         for (int i = 0; i < 5; i++)
         {
             for (int j = 0; j < 5; j++)
             {
                 table1[i, j] = Convert.ToInt32(dataGridView1.Rows[i].Cells[j].Value);
                 table2[i, j] = Convert.ToInt32(dataGridView2.Rows[i].Cells[j].Value);
             }
         }
         Finalize Fin = new Finalize(table1);
         label7.Text = Fin.K + " = " + Convert.ToString(Fin.Res);
         Fin         = new Finalize(table2);
         label8.Text = Fin.K + " = " + Convert.ToString(Fin.Res);
     }
 }
Esempio n. 8
0
        public NayukiSHA256(int buffersize = 1024 * 500)
        {
            if (buffersize % 64 != 0)
            {
                throw new ArgumentException("Buffer size must be divisible by 64");
            }

            cstate = new UInt32[] {
                SHA256_IV_0,
                SHA256_IV_1,
                SHA256_IV_2,
                SHA256_IV_3,
                SHA256_IV_4,
                SHA256_IV_5,
                SHA256_IV_6,
                SHA256_IV_7
            };

            buffer = new byte[buffersize];

            this._Compute       = nayuki_io_sha256;
            this._ComputeBlocks = nayuki_io_sha256_computeblocks;
            this._Finalize      = nayuki_io_sha256_finalize;
        }
Esempio n. 9
0
        /// <summary>
        /// See <see cref="IReducible.Reduce(double, ProcessEntry, ProcessZeros, Reduction.Finalize)"/>.
        /// </summary>
        public double Reduce(double identityValue, ProcessEntry processEntry, ProcessZeros processZeros, Finalize finalize)
        {
            // no zeros implied
            double accumulator = identityValue;

            accumulator = processEntry(data[0], accumulator);
            accumulator = processEntry(data[1], accumulator);
            accumulator = processEntry(data[2], accumulator);
            return(finalize(accumulator));
        }
Esempio n. 10
0
        public void StartWorkers(int workerCount, ConsumeWorker method, Construct construct, Finalize finalize)
        {
            for (int i = 0; i < workerCount; i++)
            {
                tasks.Add(
                    System.Threading.Tasks.Task.Factory.StartNew(() =>
                {
                    W w = construct();

                    foreach (T t in queue.GetConsumingEnumerable())
                    {
                        method(w, t);
                    }

                    finalize(ref w);
                })
                    );
            }
        }
Esempio n. 11
0
        /// <summary>
        /// See <see cref="IReducible.Reduce(double, ProcessEntry, ProcessZeros, Reduction.Finalize)"/>.
        /// </summary>
        public double Reduce(double identityValue, ProcessEntry processEntry, ProcessZeros processZeros, Finalize finalize)
        {
            double aggregator = identityValue;
            int    nnz        = values.Length;

            for (int i = 0; i < nnz; ++i)
            {
                aggregator = processEntry(values[i], aggregator);
            }
            aggregator = processZeros(NumRows * NumColumns - nnz, aggregator);
            return(finalize(aggregator));
        }
Esempio n. 12
0
 protected virtual void OnFinalize(CancelEventArgs e)
 {
     Finalize.Raise(this, e);
 }
Esempio n. 13
0
 public void Finalize(Guid id, Finalize state)
 {
     wrappedContext.Finalize(id, state);
 }
Esempio n. 14
0
        /// <summary>
        /// See <see cref="IReducible.Reduce(double, ProcessEntry, ProcessZeros, Reduction.Finalize)"/>.
        /// </summary>
        public double Reduce(double identityValue, ProcessEntry processEntry, ProcessZeros processZeros, Finalize finalize)
        {
            double aggregator  = identityValue;
            double accumulator = identityValue; // no zeros implied

            accumulator = processEntry(data[0, 0], processEntry(data[0, 1],
                                                                processEntry(data[1, 0], processEntry(data[1, 1], accumulator))));
            return(finalize(accumulator));
        }
Esempio n. 15
0
        public void UpdateModel(Models.OnlandVisualTrashAssessment onlandVisualTrashAssessment,
                                ICollection <OnlandVisualTrashAssessmentPreliminarySourceIdentificationType> allOnlandVisualTrashAssessmentPreliminarySourceIdentificationTypes)
        {
            if (Finalize.GetValueOrDefault())
            {
                onlandVisualTrashAssessment.OnlandVisualTrashAssessmentScoreID = ScoreID;
                onlandVisualTrashAssessment.Notes                = Notes;
                onlandVisualTrashAssessment.CompletedDate        = AssessmentDate;
                onlandVisualTrashAssessment.IsProgressAssessment = IsProgressAssessment;

                // create the assessment area
                if (onlandVisualTrashAssessment.AssessingNewArea.GetValueOrDefault())
                {
                    var onlandVisualTrashAssessmentAreaGeometry2771 =
                        onlandVisualTrashAssessment
                        .DraftGeometry;

                    var onlandVisualTrashAssessmentArea = new Models.OnlandVisualTrashAssessmentArea(AssessmentAreaName,
                                                                                                     onlandVisualTrashAssessment.StormwaterJurisdiction,
                                                                                                     onlandVisualTrashAssessmentAreaGeometry2771)
                    {
                        OnlandVisualTrashAssessmentAreaGeometry4326 = CoordinateSystemHelper.ProjectCaliforniaStatePlaneVIToWebMercator(onlandVisualTrashAssessment.DraftGeometry)
                    };

                    HttpRequestStorage.DatabaseEntities.SaveChanges();

                    onlandVisualTrashAssessment.OnlandVisualTrashAssessmentAreaID =
                        onlandVisualTrashAssessmentArea.OnlandVisualTrashAssessmentAreaID;
                    onlandVisualTrashAssessment.DraftGeometry        = null;
                    onlandVisualTrashAssessment.DraftAreaDescription = null;
                }

                onlandVisualTrashAssessment.OnlandVisualTrashAssessmentStatusID =
                    OnlandVisualTrashAssessmentStatus.Complete.OnlandVisualTrashAssessmentStatusID;

                HttpRequestStorage.DatabaseEntities.SaveChanges();

                onlandVisualTrashAssessment.OnlandVisualTrashAssessmentArea.AssessmentAreaDescription =
                    AssessmentAreaDescription;

                onlandVisualTrashAssessment.OnlandVisualTrashAssessmentArea.OnlandVisualTrashAssessmentBaselineScoreID =
                    onlandVisualTrashAssessment.OnlandVisualTrashAssessmentArea.CalculateScoreFromBackingData(false)?
                    .OnlandVisualTrashAssessmentScoreID;

                if (IsProgressAssessment)
                {
                    onlandVisualTrashAssessment.OnlandVisualTrashAssessmentArea
                    .OnlandVisualTrashAssessmentProgressScoreID =
                        onlandVisualTrashAssessment.OnlandVisualTrashAssessmentScoreID;
                }

                if (onlandVisualTrashAssessment.OnlandVisualTrashAssessmentArea.TransectLine == null && onlandVisualTrashAssessment.OnlandVisualTrashAssessmentObservations.Count >= 2)
                {
                    var transect = onlandVisualTrashAssessment.GetTransect();
                    onlandVisualTrashAssessment.OnlandVisualTrashAssessmentArea.TransectLine = transect;
                    onlandVisualTrashAssessment.IsTransectBackingAssessment = true;

                    var transectBackingAssessment = onlandVisualTrashAssessment.OnlandVisualTrashAssessmentArea.GetTransectBackingAssessment();
                    if (transectBackingAssessment != null)
                    {
                        transectBackingAssessment.IsTransectBackingAssessment = false;
                    }
                }
            }
            else
            {
                onlandVisualTrashAssessment.OnlandVisualTrashAssessmentScoreID = ScoreID;
                onlandVisualTrashAssessment.Notes                = Notes;
                onlandVisualTrashAssessment.DraftAreaName        = AssessmentAreaName;
                onlandVisualTrashAssessment.DraftAreaDescription = AssessmentAreaDescription;
            }

            var onlandVisualTrashAssessmentPreliminarySourceIdentificationTypesToUpdate = PreliminarySourceIdentifications.Where(x => x.Has).Select(x =>
                                                                                                                                                    new OnlandVisualTrashAssessmentPreliminarySourceIdentificationType(
                                                                                                                                                        OnlandVisualTrashAssessmentID.GetValueOrDefault(),
                                                                                                                                                        x.PreliminarySourceIdentificationTypeID.GetValueOrDefault())
            {
                ExplanationIfTypeIsOther = x.ExplanationIfTypeIsOther
            }).ToList();

            onlandVisualTrashAssessment.OnlandVisualTrashAssessmentPreliminarySourceIdentificationTypes.Merge(onlandVisualTrashAssessmentPreliminarySourceIdentificationTypesToUpdate,
                                                                                                              allOnlandVisualTrashAssessmentPreliminarySourceIdentificationTypes,
                                                                                                              (z, w) => z.OnlandVisualTrashAssessmentID == w.OnlandVisualTrashAssessmentID && z.PreliminarySourceIdentificationTypeID == w.PreliminarySourceIdentificationTypeID,
                                                                                                              (z, w) => z.ExplanationIfTypeIsOther = w.ExplanationIfTypeIsOther
                                                                                                              );

            // bug?: why are we nulling these unconditionally?
            onlandVisualTrashAssessment.DraftAreaDescription = null;
            onlandVisualTrashAssessment.DraftAreaName        = null;
            onlandVisualTrashAssessment.DraftGeometry        = null;
        }
Esempio n. 16
0
 /// <summary>
 /// 唯一のコンストラクタ
 /// </summary>
 /// <param name="function">ファイナライズする時に実行するデリゲートメソッド</param>
 public FinalizeManager(Finalize function)
 {
     _func = function;
 }
Esempio n. 17
0
        /// <summary>
        /// See <see cref="IReducible.Reduce(double, ProcessEntry, ProcessZeros, Reduction.Finalize)"/>.
        /// </summary>
        public double Reduce(double identityValue, ProcessEntry processEntry, ProcessZeros processZeros, Finalize finalize)
        {
            double accumulator = identityValue;

            for (int i = 0; i < data.Length; ++i)
            {
                accumulator = processEntry(data[i], accumulator);
            }
            // no zeros implied
            return(finalize(accumulator));
        }
Esempio n. 18
0
 private void Finalize(Guid id, Finalize state) => Update(id, message =>
 {
     message.Completed = true;
     message.Suspended = state == Shard.DataAccess.Finalize.Terminated;
     storage.Delete(id);
 });