private async Task ApplyFilters()
        {
            if (AllCards != null && !_suspendFilters)
            {
                var filtered =
                    from c in AllCards
                    where (!FilteredByFaction || (FactionFilter != Faction.UNALIGNED && c.ValidFactions.Contains(FactionFilter) && c.ValidFactions.Count() != FACTION_COUNT) ||
                           (FactionFilter == Faction.UNALIGNED && c.Faction == Faction.UNALIGNED && c.ValidFactions.Count() == FACTION_COUNT)) &&
                    (!FilteredByType || c.Type == TypeFilter) &&
                    (CostFilter == MAX_COSTS_FILTER || ((CostFilter == MAX_COSTS_FILTER - 1 && c.Cost >= CostFilter) || c.Cost == CostFilter)) &&
                    (RarityFilter == 0 || (int)c.Rarity == RarityFilter) &&
                    ((TraitFilter == null || !TraitFilter.Any()) || TraitFilter.Intersect(c.Traits).Any()) &&
                    (CurrentDeck == null || !FilterByDeck || CurrentDeck.Contains(c) || CurrentDeck.Champion == c) &&
                    (string.IsNullOrEmpty(CardSetFilter) || CardSetFilter == _CARD_SET_FILTER_DEFAULT || c.CardSet == (CardSet)Enum.Parse(typeof(CardSet), CardSetFilter)) &&
                    (string.IsNullOrEmpty(SearchText) ||
                     c.Text.ToLower().Contains(SearchText.ToLower()) ||
                     c.Name.ToLower().Contains(SearchText.ToLower()) ||
                     c.Race.ToString().ToLower().Contains(SearchText.ToLower()) ||
                     SearchText.ToUpper().Contains(c.CardSet.ToString()))
                    orderby c.Rarity == Rarity.TOKEN, c.Type == CardType.CHAMPION descending, c.Faction descending, c.Cost, c.Name
                select c;

                IsBusy = true;
                var newList = await Task.Run(() => filtered.ToList());

                FilteredCards = newList;
                IsBusy        = false;
                UpdateStatus();

                ResetFiltersCommand.RaiseCanExecuteChanged();
            }
        }
        /// <summary>
        /// Changes the layout to the specified index in the project
        /// </summary>
        /// <param name="nIdx"></param>
        protected void ChangeExportLayoutIndex(int nIdx)
        {
            // based on the currently loaded project get the layout based on the index
            var zLayout = ProjectManager.Instance.LoadedProject.Layout[nIdx];

            CurrentDeck.SetAndLoadLayout(zLayout ?? CurrentDeck.CardLayout, true);
        }
Example #3
0
 public void Show(Deck deckToShow, OnNameChangeDelegate nameChangeCallback = null, OnDeckSavedDelegate deckSaveCallback = null, bool overwrite = false)
 {
     gameObject.SetActive(true);
     transform.SetAsLastSibling();
     CurrentDeck         = deckToShow ?? new Deck(CardGameManager.Current);
     NameChangeCallback  = nameChangeCallback;
     DeckSaveCallback    = deckSaveCallback;
     DoesAutoOverwrite   = overwrite;
     nameInputField.text = CurrentDeck.Name;
     textOutputArea.text = CurrentDeck.ToString();
 }
    private IEnumerator StealCard()
    {
        for (int i = 0; i < amountToSteal; i++)
        {
            if (myHolder.side == CardHolder.Side.Enemy)
            {
                //Debug.Log("test");
                CurrentDeck playerDeck = FightManager.instance.myDeck;

                int  randomCardToSteal = Random.Range(0, playerDeck.inHand.Count);
                Card toSteal           = playerDeck.inHand[randomCardToSteal];

                GameObject toStealObject = playerDeck.inhandie[randomCardToSteal];

                playerDeck.inhandie[randomCardToSteal].GetComponent <Animator>().SetBool("Steal", true);
                playerDeck.inhandie[randomCardToSteal].GetComponent <Animator>().SetTrigger("Highlighted");
                yield return(new WaitForSeconds(playerDeck.inhandie[randomCardToSteal].GetComponent <Animator>().GetCurrentAnimatorStateInfo(0).length));

                yield return(new WaitForSeconds(1f));

                playerDeck.inHand.Remove(toSteal);
                playerDeck.inhandie.Remove(toStealObject);
                Object.Destroy(toStealObject);

                FightManager.instance.enemyCurrentDeck.GetSpecificCard(toSteal);
            }
            else if (myHolder.side == CardHolder.Side.Player)
            {
                //Debug.Log("test2");
                CurrentDeck enemyDeck = FightManager.instance.enemyCurrentDeck;

                int  randomCardToSteal = Random.Range(0, enemyDeck.inHand.Count);
                Card toSteal           = enemyDeck.inHand[randomCardToSteal];

                GameObject toStealObject = enemyDeck.inhandie[randomCardToSteal];

                enemyDeck.inhandie[randomCardToSteal].GetComponent <Animator>().SetTrigger("Highlighted");
                yield return(new WaitForSeconds(enemyDeck.inhandie[randomCardToSteal].GetComponent <Animator>().GetCurrentAnimatorStateInfo(0).length));

                enemyDeck.inhandie[randomCardToSteal].GetComponent <Animator>().SetTrigger("Pressed");
                yield return(new WaitForSeconds(1f));

                enemyDeck.inhandie[randomCardToSteal].GetComponent <Animator>().SetBool("Steal", true);
                yield return(new WaitForSeconds(enemyDeck.inhandie[randomCardToSteal].GetComponent <Animator>().GetCurrentAnimatorStateInfo(0).length));

                enemyDeck.inHand.Remove(toSteal);
                enemyDeck.inhandie.Remove(toStealObject);
                Object.Destroy(toStealObject);

                FightManager.instance.myDeck.GetSpecificCard(toSteal);
            }
        }
    }
Example #5
0
        /// <summary>
        /// Changes the layout to the specified index in the project
        /// </summary>
        /// <param name="nIdx"></param>
        protected void ChangeExportLayoutIndex(int nIdx)
        {
            // based on the currently loaded project get the layout based on the index
            var zLayout = ProjectManager.Instance.LoadedProject.Layout[nIdx];

            CurrentDeck.SetAndLoadLayout(zLayout ?? CurrentDeck.CardLayout, true,
                                         new ProgressReporterProxy()
            {
                ProgressIndex     = ProgressReporter.GetProgressIndex(ProgressName.REFERENCE_DATA),
                ProgressReporter  = ProgressReporter,
                ProxyOwnsReporter = false
            });
        }
Example #6
0
        public override void ExportThread()
        {
            var progressLayoutIdx = ProgressReporter.GetProgressIndex(ProgressName.LAYOUT);
            var progressCardIdx   = ProgressReporter.GetProgressIndex(ProgressName.CARD);

            ProgressReporter.ProgressReset(progressLayoutIdx, 0, ExportLayoutIndices.Length, 0);
            ChangeExportLayoutIndex(ExportLayoutIndices[0]);
            ProgressReporter.ProgressReset(progressCardIdx, 0, CurrentDeck.CardCount, 0);

            UpdateBufferBitmap(CurrentDeck.CardLayout.width, CurrentDeck.CardLayout.height);

            var zGraphics = Graphics.FromImage(m_zExportCardBuffer);
            var nCardIdx  = m_nImageExportIndex;

            zGraphics.Clear(CurrentDeck.CardLayout.exportTransparentBackground ?
                            CardMakerConstants.NoColor :
                            Color.White);
            CurrentDeck.ResetDeckCache();
            CurrentDeck.CardPrintIndex = nCardIdx++;
            CardRenderer.DrawPrintLineToGraphics(zGraphics, 0, 0, !CurrentDeck.CardLayout.exportTransparentBackground);
            m_zExportCardBuffer.SetResolution(CurrentDeck.CardLayout.dpi, CurrentDeck.CardLayout.dpi);

            ProgressReporter.ProgressStep(progressLayoutIdx);

            try
            {
                ProcessRotateExport(m_zExportCardBuffer, CurrentDeck.CardLayout, false);
                var thread = new Thread(() => Clipboard.SetImage(m_zExportCardBuffer));
                thread.SetApartmentState(ApartmentState.STA); //Set the thread to STA
                thread.Start();
                thread.Join();                                //Wait for the thread to end
            }
            catch (Exception)
            {
                Logger.AddLogLine("Error copying layout image to clipboard.");
                ProgressReporter.ThreadSuccess = false;
                ProgressReporter.Shutdown();
                return;
            }

            ProgressReporter.ProgressStep(progressCardIdx);

            ProgressReporter.ThreadSuccess = true;
            ProgressReporter.Shutdown();
        }
Example #7
0
        /// <summary>
        /// Starts or restarts the blackjack
        /// game.
        /// </summary>
        public override void Start()
        {
            base.Start();

            _playerPointer = Players.Count - 1;

            Dealer.Hand.Clear();

            for (int i = 0; i < Players.Count; i++)
            {
                BlackjackPlayer player = (BlackjackPlayer)Players[i];
                player.State = PlayerStateEnum.Playing;
                player.Hand.Clear();
            }
            Players[_playerPointer].State = PlayerStateEnum.Turn;
            CurrentDeck.Shuffle();
            dealToEveryone();
        }
Example #8
0
        public void ExportThread()
        {
            var zWait = WaitDialog.Instance;

            zWait.ProgressReset(0, 0, ExportLayoutEndIndex - ExportLayoutStartIndex, 0);
            ChangeExportLayoutIndex(ExportLayoutStartIndex);
            zWait.ProgressReset(1, 0, CurrentDeck.CardCount, 0);

            UpdateBufferBitmap(CurrentDeck.CardLayout.width, CurrentDeck.CardLayout.height);

            var zGraphics = Graphics.FromImage(m_zExportCardBuffer);
            var nCardIdx  = m_nImageExportIndex;

            zGraphics.Clear(CurrentDeck.CardLayout.exportTransparentBackground ?
                            CardMakerConstants.NoColor :
                            Color.White);
            CurrentDeck.ResetDeckCache();
            CurrentDeck.CardPrintIndex = nCardIdx++;
            CardRenderer.DrawPrintLineToGraphics(zGraphics, 0, 0, !CurrentDeck.CardLayout.exportTransparentBackground);
            m_zExportCardBuffer.SetResolution(CurrentDeck.CardLayout.dpi, CurrentDeck.CardLayout.dpi);

            zWait.ProgressStep(1);

            try
            {
                ProcessRotateExport(m_zExportCardBuffer, CurrentDeck.CardLayout, false);
                var thread = new Thread(() => Clipboard.SetImage(m_zExportCardBuffer));
                thread.SetApartmentState(ApartmentState.STA); //Set the thread to STA
                thread.Start();
                thread.Join();                                //Wait for the thread to end
            }
            catch (Exception)
            {
                Logger.AddLogLine("Error copying layout image to clipboard.");
                zWait.ThreadSuccess = false;
                zWait.CloseWaitDialog();
                return;
            }

            zWait.ProgressStep(0);

            zWait.ThreadSuccess = true;
            zWait.CloseWaitDialog();
        }
Example #9
0
    private IEnumerator StealCard()
    {
        CurrentDeck enemyDeck = FightManager.instance.enemyCurrentDeck;

        int  randomCardToSteal = Random.Range(0, enemyDeck.inHand.Count);
        Card toSteal           = enemyDeck.inHand[randomCardToSteal];

        GameObject toStealObject = enemyDeck.inhandie[randomCardToSteal];

        enemyDeck.inhandie[randomCardToSteal].GetComponent <Animator>().SetTrigger("Highlighted");
        yield return(new WaitForSeconds(enemyDeck.inhandie[randomCardToSteal].GetComponent <Animator>().GetCurrentAnimatorStateInfo(0).length));

        enemyDeck.inhandie[randomCardToSteal].GetComponent <Animator>().SetTrigger("Pressed");
        yield return(new WaitForSeconds(1f));

        enemyDeck.inhandie[randomCardToSteal].GetComponent <Animator>().SetBool("Steal", true);
        yield return(new WaitForSeconds(enemyDeck.inhandie[randomCardToSteal].GetComponent <Animator>().GetCurrentAnimatorStateInfo(0).length));

        enemyDeck.inHand.Remove(toSteal);
        enemyDeck.inhandie.Remove(toStealObject);
        Destroy(toStealObject);

        FightManager.instance.myDeck.GetSpecificCard(toSteal);
    }
Example #10
0
        public void ExportThread()
        {
            var zWait = WaitDialog.Instance;

            zWait.ProgressReset(0, 0, ExportLayoutEndIndex - ExportLayoutStartIndex, 0);
            ChangeExportLayoutIndex(ExportLayoutStartIndex);
            var nPadSize = CurrentDeck.CardCount.ToString(CultureInfo.InvariantCulture).Length;

            zWait.ProgressReset(1, 0, CurrentDeck.CardCount, 0);

            UpdateBufferBitmap(CurrentDeck.CardLayout.width, CurrentDeck.CardLayout.height);

            var zGraphics = Graphics.FromImage(m_zExportCardBuffer);
            var nCardIdx  = m_nImageExportIndex;

            zGraphics.Clear(CurrentDeck.CardLayout.exportTransparentBackground ?
                            CardMakerConstants.NoColor :
                            Color.White);
            CurrentDeck.ResetDeckCache();
            CurrentDeck.CardPrintIndex = nCardIdx++;
            CardRenderer.DrawPrintLineToGraphics(zGraphics, 0, 0, !CurrentDeck.CardLayout.exportTransparentBackground);
            m_zExportCardBuffer.SetResolution(CurrentDeck.CardLayout.dpi, CurrentDeck.CardLayout.dpi);

            zWait.ProgressStep(1);

            string sFileName;

            // NOTE: nCardIdx at this point is 1 more than the actual index ... how convenient for export file names...

            if (!string.IsNullOrEmpty(m_sOverrideStringFormat))
            {
                // check for the super override
                sFileName = CurrentDeck.TranslateFileNameString(m_sOverrideStringFormat, nCardIdx, nPadSize);
            }
            else if (!string.IsNullOrEmpty(CurrentDeck.CardLayout.exportNameFormat))
            {
                // check for the per layout override
                sFileName = CurrentDeck.TranslateFileNameString(CurrentDeck.CardLayout.exportNameFormat, nCardIdx, nPadSize);
            }
            else // default
            {
                sFileName = CurrentDeck.CardLayout.Name + "_" + (nCardIdx).ToString(CultureInfo.InvariantCulture).PadLeft(nPadSize, '0');
            }
            try
            {
                ProcessRotateExport(m_zExportCardBuffer, CurrentDeck.CardLayout, false);
                m_zExportCardBuffer.Save(
                    m_sExportFolder + sFileName +
                    "." + m_eImageFormat.ToString().ToLower(),
                    m_eImageFormat);
                ProcessRotateExport(m_zExportCardBuffer, CurrentDeck.CardLayout, true);
            }
            catch (Exception)
            {
                Logger.AddLogLine("Invalid Filename or IO error: " + sFileName);
                zWait.ThreadSuccess = false;
                zWait.CloseWaitDialog();
                return;
            }

            zWait.ProgressStep(0);

            zWait.ThreadSuccess = true;
            zWait.CloseWaitDialog();
        }
Example #11
0
        public override void ExportThread()
        {
            var progressLayoutIdx = ProgressReporter.GetProgressIndex(ProgressName.LAYOUT);
            var progressCardIdx   = ProgressReporter.GetProgressIndex(ProgressName.CARD);

            ProgressReporter.ProgressReset(progressLayoutIdx, 0, ExportLayoutIndices.Length, 0);
            ChangeExportLayoutIndex(ExportLayoutIndices[0]);
            var nPadSize = CurrentDeck.CardCount.ToString(CultureInfo.InvariantCulture).Length;

            ProgressReporter.ProgressReset(progressCardIdx, 0, CurrentDeck.CardCount, 0);

            UpdateBufferBitmap(CurrentDeck.CardLayout.width, CurrentDeck.CardLayout.height);

            var zGraphics = Graphics.FromImage(m_zExportCardBuffer);
            var nCardIdx  = m_nImageExportIndex;

            zGraphics.Clear(CurrentDeck.CardLayout.exportTransparentBackground ?
                            CardMakerConstants.NoColor :
                            Color.White);
            CurrentDeck.ResetDeckCache();
            CurrentDeck.CardPrintIndex = nCardIdx++;
            CardRenderer.DrawPrintLineToGraphics(zGraphics, 0, 0, !CurrentDeck.CardLayout.exportTransparentBackground);
            m_zExportCardBuffer.SetResolution(CurrentDeck.CardLayout.dpi, CurrentDeck.CardLayout.dpi);

            ProgressReporter.ProgressStep(progressCardIdx);

            string sFileName;

            // NOTE: nCardIdx at this point is 1 more than the actual index ... how convenient for export file names...

            if (!string.IsNullOrEmpty(m_sOverrideStringFormat))
            {
                // check for the super override
                sFileName = CurrentDeck.TranslateFileNameString(m_sOverrideStringFormat, nCardIdx, nPadSize);
            }
            else if (!string.IsNullOrEmpty(CurrentDeck.CardLayout.exportNameFormat))
            {
                // check for the per layout override
                sFileName = CurrentDeck.TranslateFileNameString(CurrentDeck.CardLayout.exportNameFormat, nCardIdx, nPadSize);
            }
            else // default
            {
                sFileName = CurrentDeck.CardLayout.Name + "_" + (nCardIdx).ToString(CultureInfo.InvariantCulture).PadLeft(nPadSize, '0');
            }
            try
            {
                ProcessRotateExport(m_zExportCardBuffer, CurrentDeck.CardLayout, false);
                m_zExportCardBuffer.Save(
                    m_sExportFolder + sFileName +
                    "." + m_eImageFormat.ToString().ToLower(),
                    m_eImageFormat);
                ProcessRotateExport(m_zExportCardBuffer, CurrentDeck.CardLayout, true);
            }
            catch (Exception e)
            {
                ProgressReporter.AddIssue("Invalid Filename or IO error: {0} {1}".FormatString(sFileName, e.Message));
                ProgressReporter.ThreadSuccess = false;
                ProgressReporter.Shutdown();
                return;
            }

            ProgressReporter.ProgressStep(progressLayoutIdx);

            ProgressReporter.ThreadSuccess = true;
            ProgressReporter.Shutdown();
        }
Example #12
0
        public void ExportThread()
        {
            var zWait = WaitDialog.Instance;

#if !MONO_BUILD
            Bitmap zBuffer = null;
#endif

            zWait.ProgressReset(0, 0, ExportLayoutEndIndex - ExportLayoutStartIndex, 0);
            for (var nIdx = ExportLayoutStartIndex; nIdx < ExportLayoutEndIndex; nIdx++)
            {
                ChangeExportLayoutIndex(nIdx);
                if (CurrentDeck.EmptyReference)
                {
                    // empty reference layouts are not exported
                    zWait.ProgressStep(0);
                    continue;
                }

                zWait.ProgressReset(1, 0, CurrentDeck.CardCount, 0);

                ConfigurePointSizes(CurrentDeck.CardLayout);

                // necessary tracking for which index of the layout is to be exported (this is NOT necessarily the index of the card due to the page back functionality)
                var nNextExportIndex = 0;

                if (0 < nIdx)
                {
                    if (CardMakerSettings.PrintLayoutsOnNewPage)
                    {
                        AddPage();
                    }

                    if (CardMakerSettings.PrintAutoHorizontalCenter ||
                        (m_dDrawX + m_dLayoutPointWidth > m_dPageMarginEndX)) // this is the case where a layout won't fit in the remaining space of the row
                    {
                        MoveToNextRow(nNextExportIndex);
                    }
                }

                // should be adjusted after the above move to next row
                m_dNextRowYAdjust = Math.Max(m_dNextRowYAdjust, m_dLayoutPointHeight + m_dBufferY);

                if (CardMakerSettings.PrintAutoHorizontalCenter)
                {
                    CenterLayoutPositionOnNewRow(nNextExportIndex);
                }

#if !MONO_BUILD
                zBuffer?.Dispose();
                zBuffer = new Bitmap(CurrentDeck.CardLayout.width, CurrentDeck.CardLayout.height);

                float fOriginalXDpi = zBuffer.HorizontalResolution;
                float fOriginalYDpi = zBuffer.VerticalResolution;
#endif

                foreach (var nCardIdx in GetExportIndices())
                {
                    CurrentDeck.ResetDeckCache();

                    CurrentDeck.CardPrintIndex = nCardIdx;

#if MONO_BUILD
                    // mono build won't support the optimization so re-create the buffer
                    Bitmap zBuffer = new Bitmap(CurrentDeck.CardLayout.width, CurrentDeck.CardLayout.height);
#endif

#if !MONO_BUILD
                    // minor optimization, reuse the same bitmap (for drawing sake the DPI has to be reset)
                    zBuffer.SetResolution(fOriginalXDpi, fOriginalYDpi);
#endif
                    if (nCardIdx == -1)
                    {
                        Graphics.FromImage(zBuffer).FillRectangle(Brushes.White, 0, 0, zBuffer.Width, zBuffer.Height);
                        // note: some oddities were observed where the buffer was not flood filling
                    }
                    else
                    {
                        CardRenderer.DrawPrintLineToGraphics(Graphics.FromImage(zBuffer));
                    }

                    // apply any export rotation
                    ProcessRotateExport(zBuffer, CurrentDeck.CardLayout, false);

                    // before rendering to the PDF bump the DPI to the desired value
                    zBuffer.SetResolution(CurrentDeck.CardLayout.dpi, CurrentDeck.CardLayout.dpi);

                    var xImage = XImage.FromGdiPlusImage(zBuffer);

                    EvaluatePagePosition(nNextExportIndex);

                    m_zPageGfx.DrawImage(xImage, m_dDrawX, m_dDrawY);

                    MoveToNextColumnPosition();

                    // undo any export rotation
                    ProcessRotateExport(zBuffer, CurrentDeck.CardLayout, true);

                    nNextExportIndex++;

                    zWait.ProgressStep(1);
                }
                zWait.ProgressStep(0);
            }

#if !MONO_BUILD
            zBuffer?.Dispose();
#endif

            try
            {
                m_zDocument.Save(m_sExportFile);
                zWait.ThreadSuccess = true;
            }
            catch (Exception ex)
            {
                Logger.AddLogLine("Error saving PDF (is it open?) " + ex.Message);
                zWait.ThreadSuccess = false;
            }

            zWait.CloseWaitDialog();
        }
Example #13
0
        public override void ExportThread()
        {
            var progressLayoutIdx = ProgressReporter.GetProgressIndex(ProgressName.LAYOUT);
            var progressCardIdx   = ProgressReporter.GetProgressIndex(ProgressName.CARD);

            ProgressReporter.ProgressReset(progressLayoutIdx, 0, ExportLayoutIndices.Length, 0);
            foreach (var nIdx in ExportLayoutIndices)
            {
                ChangeExportLayoutIndex(nIdx);
                if (CurrentDeck.EmptyReference)
                {
                    // empty reference layouts are not exported
                    ProgressReporter.ProgressStep(progressLayoutIdx);
                    continue;
                }
                var nPadSize = CurrentDeck.CardCount.ToString(CultureInfo.InvariantCulture).Length;
                ProgressReporter.ProgressReset(progressCardIdx, 0, CurrentDeck.CardCount, 0);

                var exportWidth = CurrentDeck.CardLayout.exportWidth == 0
                    ? CurrentDeck.CardLayout.width : CurrentDeck.CardLayout.exportWidth;

                var exportHeight = CurrentDeck.CardLayout.exportHeight == 0
                    ? CurrentDeck.CardLayout.height : CurrentDeck.CardLayout.exportHeight;

                if (CurrentDeck.CardLayout.width > exportWidth ||
                    CurrentDeck.CardLayout.height > exportHeight)
                {
                    Logger.AddLogLine(
                        $"ERROR: Layout: [{CurrentDeck.CardLayout.Name}] exportWidth and/or exportHeight too small! (Skipping export)");
                    continue;
                }

                UpdateBufferBitmap(exportWidth, exportHeight);
                var zGraphics        = Graphics.FromImage(m_zExportCardBuffer);
                var arrayCardIndices = GetCardIndicesArray(CurrentDeck);
                for (var nCardArrayIdx = 0; nCardArrayIdx < arrayCardIndices.Length; nCardArrayIdx++)
                {
                    var nCardId = arrayCardIndices[nCardArrayIdx];
                    var nX      = 0;
                    var nY      = 0;
                    var nCardsExportedInImage = 0;
                    zGraphics.Clear(CurrentDeck.CardLayout.exportTransparentBackground ?
                                    CardMakerConstants.NoColor :
                                    Color.White);
                    do
                    {
                        CurrentDeck.ResetDeckCache();
                        // HACK - the printcard index is 0 based but all other uses of nCardId are 1 based (so ++ it!)
                        CurrentDeck.CardPrintIndex = nCardId++;
                        nCardsExportedInImage++;
                        CardRenderer.DrawPrintLineToGraphics(zGraphics, nX, nY, !CurrentDeck.CardLayout.exportTransparentBackground);
                        m_zExportCardBuffer.SetResolution(CurrentDeck.CardLayout.dpi, CurrentDeck.CardLayout.dpi);

                        ProgressReporter.ProgressStep(progressCardIdx);

                        int nMoveCount = 1;
                        if (m_nSkipStitchIndex > 0)
                        {
                            var x = ((nCardsExportedInImage + 1) % m_nSkipStitchIndex);
                            if (x == 0)
                            {
                                // shift forward an extra spot to ignore the dummy index
                                nMoveCount = 2;
                            }
                        }

                        var bOutOfSpace = false;
                        for (int nShift = 0; nShift < nMoveCount; nShift++)
                        {
                            nX += CurrentDeck.CardLayout.width + CurrentDeck.CardLayout.buffer;
                            if (nX + CurrentDeck.CardLayout.width > exportWidth)
                            {
                                nX  = 0;
                                nY += CurrentDeck.CardLayout.height + CurrentDeck.CardLayout.buffer;
                            }
                            if (nY + CurrentDeck.CardLayout.height > exportHeight)
                            {
                                // no more space
                                bOutOfSpace = true;
                                break;
                            }
                        }

                        if (bOutOfSpace)
                        {
                            break;
                        }
                    } while (nCardArrayIdx < CurrentDeck.CardCount);

                    string sFileName;

                    // NOTE: nCardId at this point is 1 more than the actual index ... how convenient for export file names...

                    if (!string.IsNullOrEmpty(m_sOverrideStringFormat))
                    {
                        // check for the super override
                        sFileName = CurrentDeck.TranslateFileNameString(m_sOverrideStringFormat, nCardId, nPadSize);
                    }
                    else if (!string.IsNullOrEmpty(CurrentDeck.CardLayout.exportNameFormat))
                    {
                        // check for the per layout override
                        sFileName = CurrentDeck.TranslateFileNameString(CurrentDeck.CardLayout.exportNameFormat, nCardId, nPadSize);
                    }
                    else // default
                    {
                        sFileName = CurrentDeck.CardLayout.Name + "_" + (nCardId).ToString(CultureInfo.InvariantCulture).PadLeft(nPadSize, '0');
                    }
                    try
                    {
                        ProcessRotateExport(m_zExportCardBuffer, CurrentDeck.CardLayout, false);
                        m_zExportCardBuffer.Save(
                            m_sExportFolder + sFileName +
                            "." + m_eImageFormat.ToString().ToLower(),
                            m_eImageFormat);
                        ProcessRotateExport(m_zExportCardBuffer, CurrentDeck.CardLayout, true);
                    }
                    catch (Exception ex)
                    {
                        ProgressReporter.AddIssue("Invalid Filename or IO error: " + sFileName + " :: " + ex.Message);
                        ProgressReporter.ThreadSuccess = false;
                        ProgressReporter.Shutdown();
                        return;
                    }
                }
                ProgressReporter.ProgressStep(progressLayoutIdx);
            }

            ProgressReporter.ThreadSuccess = true;
            ProgressReporter.Shutdown();
        }
Example #14
0
        public void ExportThread()
        {
            var zWait = WaitDialog.Instance;

#if !MONO_BUILD
            Bitmap zBuffer = null;
#endif

            zWait.ProgressReset(0, 0, ExportLayoutEndIndex - ExportLayoutStartIndex, 0);
            for (var nIdx = ExportLayoutStartIndex; nIdx < ExportLayoutEndIndex; nIdx++)
            {
                ChangeExportLayoutIndex(nIdx);
                zWait.ProgressReset(1, 0, CurrentDeck.CardCount, 0);

                ConfigurePointSizes(CurrentDeck.CardLayout);

                if (0 < nIdx)
                {
                    if (CardMakerSettings.PrintLayoutsOnNewPage)
                    {
                        AddPage();
                    }

                    if (CardMakerSettings.PrintAutoHorizontalCenter ||
                        (m_dDrawX + m_dLayoutPointWidth > m_dMarginEndX)) // this is the case where a layout won't fit in the remaining space of the row
                    {
                        MoveToNextRow();
                    }
                }

                // should be adjusted after the above move to next row
                m_dNextRowYAdjust = Math.Max(m_dNextRowYAdjust, m_dLayoutPointHeight + m_dBufferY);

                if (CardMakerSettings.PrintAutoHorizontalCenter)
                {
                    CenterLayoutPositionOnNewRow();
                }

#if !MONO_BUILD
                if (null != zBuffer)
                {
                    zBuffer.Dispose();
                }
                zBuffer = new Bitmap(CurrentDeck.CardLayout.width, CurrentDeck.CardLayout.height);

                float fOriginalXDpi = zBuffer.HorizontalResolution;
                float fOriginalYDpi = zBuffer.VerticalResolution;
#endif

                for (var nCardIdx = 0; nCardIdx < CurrentDeck.CardCount; nCardIdx++)
                {
                    CurrentDeck.ResetDeckCache();
                    CurrentDeck.CardPrintIndex = nCardIdx;

                    // minor optimization, reuse the same bitmap (for drawing sake the DPI has to be reset)
#if MONO_BUILD
                    Bitmap zBuffer = new Bitmap(CurrentDeck.CardLayout.width, CurrentDeck.CardLayout.height);
#endif

#if !MONO_BUILD
                    zBuffer.SetResolution(fOriginalXDpi, fOriginalYDpi);
#endif

                    CardRenderer.DrawPrintLineToGraphics(Graphics.FromImage(zBuffer));

                    // apply any export rotation
                    ProcessRotateExport(zBuffer, CurrentDeck.CardLayout, false);

                    // before rendering to the PDF bump the DPI to the desired value
                    zBuffer.SetResolution(CurrentDeck.CardLayout.dpi, CurrentDeck.CardLayout.dpi);

                    var xImage = XImage.FromGdiPlusImage(zBuffer);

                    EvaluatePagePosition();

                    m_zPageGfx.DrawImage(xImage, m_dDrawX, m_dDrawY);

                    MoveToNextColumnPosition();

                    // undo any export rotation
                    ProcessRotateExport(zBuffer, CurrentDeck.CardLayout, true);

                    zWait.ProgressStep(1);
                }
                zWait.ProgressStep(0);
            }

#if !MONO_BUILD
            if (null != zBuffer)
            {
                zBuffer.Dispose();
            }
#endif

            try
            {
                m_zDocument.Save(m_sExportFile);
                zWait.ThreadSuccess = true;
            }
            catch (Exception ex)
            {
                Logger.AddLogLine("Error saving PDF (is it open?) " + ex.Message);
                zWait.ThreadSuccess = false;
            }

            zWait.CloseWaitDialog();
        }
Example #15
0
        public void DrawCard(int nX, int nY, Graphics zGraphics, DeckLine zDeckLine, bool bExport, bool bDrawBackground)
        {
            // Custom Graphics Setting
            zGraphics.TextRenderingHint = TextRenderingHint.AntiAliasGridFit;
            zGraphics.SmoothingMode     = SmoothingMode.AntiAlias;
            //zGraphics.SmoothingMode = SmoothingMode.HighQuality;

            var matrixOriginal = zGraphics.Transform;

            // Zoom does not apply to export
            if (!bExport)
            {
                zGraphics.ScaleTransform(ZoomLevel, ZoomLevel);
                // Custom Graphics Setting

                zGraphics.InterpolationMode = 1.0f != ZoomLevel
                    ? InterpolationMode.NearestNeighbor
                    : InterpolationMode.Bilinear;
            }

            // draw the card background
            if (bDrawBackground)
            {
                zGraphics.FillRectangle(Brushes.White, nX, nY, CurrentDeck.CardLayout.width,
                                        CurrentDeck.CardLayout.height);
            }

            // All drawing is handled in reverse element order

            if (null != CurrentDeck.CardLayout.Element)
            {
                for (var nIdx = CurrentDeck.CardLayout.Element.Length - 1; nIdx > -1; nIdx--)
                {
                    var zElement = CurrentDeck.CardLayout.Element[nIdx];
                    if (zElement.enabled) // only add enabled items to draw
                    {
                        IssueManager.Instance.FireChangeElementEvent(zElement.name);

                        // get override Element (overrides based on data source) (this is a copy!)
                        // This takes place before translation to cover the odd case where the variable field is override in the data source
                        var zDrawElement = CurrentDeck.GetOverrideElement(zElement, zDeckLine, bExport);

                        // translate any index values in the csv
                        var zElementString = CurrentDeck.TranslateString(zDrawElement.variable, zDeckLine, zDrawElement, bExport);

                        // get override Element (based on any overrides in the element variable string)
                        zDrawElement = CurrentDeck.GetVariableOverrideElement(zDrawElement, zElementString.OverrideFieldToValueDictionary);

                        // enabled is re-checked due to possible override of the enabled value
                        if (!zElementString.DrawElement || !zDrawElement.enabled)
                        {
                            continue;
                        }

                        // initialize the translated fields on the element to draw
                        zDrawElement.InitializeTranslatedFields();

                        DrawElement(zGraphics, CurrentDeck, zDrawElement, nX, nY, zElementString.String, bExport);
                        if (!bExport)
                        {
                            zGraphics.ScaleTransform(ZoomLevel, ZoomLevel);
                        }
                    }
                }

                if (!bExport)
                {
                    // draw all selections and element borders after everything else
                    for (var nIdx = CurrentDeck.CardLayout.Element.Length - 1; nIdx > -1; nIdx--)
                    {
                        ProjectLayoutElement zElement = CurrentDeck.CardLayout.Element[nIdx];
                        if (zElement.enabled) // only add enabled items to draw
                        {
                            DrawElementDebugBorder(zGraphics, zElement, nX, nY, ElementManager.Instance.GetSelectedElement() == zElement);
                        }
                    }
                }
            }

            DrawLayoutDividers(zGraphics, bExport);

            // draw the card border
            if ((bExport && CardMakerSettings.PrintLayoutBorder) ||
                (!bExport && CurrentDeck.CardLayout.drawBorder))
            {
                // note that the border is inclusive in the width/height consuming 2 pixels (0 to total-1)
                zGraphics.DrawRectangle(Pens.Black, nX, nY, CurrentDeck.CardLayout.width - 1, CurrentDeck.CardLayout.height - 1);
            }

            zGraphics.Transform = matrixOriginal;
        }
Example #16
0
        public void DrawCard(int nX, int nY, Graphics zGraphics, DeckLine zDeckLine, bool bExport, bool bDrawBackground)
        {
            List <string> listLine = zDeckLine.LineColumns;

            // Custom Graphics Setting
            zGraphics.TextRenderingHint = System.Drawing.Text.TextRenderingHint.AntiAliasGridFit;
            zGraphics.SmoothingMode     = SmoothingMode.AntiAlias;
            //zGraphics.SmoothingMode = SmoothingMode.HighQuality;

            var matrixOriginal = zGraphics.Transform;

            // Zoom does not apply to export
            if (!bExport)
            {
                zGraphics.ScaleTransform(ZoomLevel, ZoomLevel);
                // Custom Graphics Setting

                zGraphics.InterpolationMode = 1.0f != ZoomLevel
                    ? InterpolationMode.NearestNeighbor
                    : InterpolationMode.Bilinear;
            }

            //Logger.Clear();
            ProjectLayoutElement zSelectedElement = null;

            if (!bExport)
            {
                zSelectedElement = ElementManager.Instance.GetSelectedElement();
            }

            // draw the background
            if (bDrawBackground)
            {
                zGraphics.FillRectangle(Brushes.White, nX, nY, CurrentDeck.CardLayout.width,
                                        CurrentDeck.CardLayout.height);
            }

            // All drawing is handled in reverse element order

            if (null != CurrentDeck.CardLayout.Element)
            {
                for (var nIdx = CurrentDeck.CardLayout.Element.Length - 1; nIdx > -1; nIdx--)
                {
                    var zElement = CurrentDeck.CardLayout.Element[nIdx];
                    if (zElement.enabled) // only add enabled items to draw
                    {
                        IssueManager.Instance.FireChangeElementEvent(zElement.name);

                        // get override Element
                        ProjectLayoutElement zOverrideElement = CurrentDeck.GetOverrideElement(zElement, listLine, zDeckLine, bExport);
                        var zDrawElement = zOverrideElement;

                        // translate any index values in the csv
                        var zElementString = CurrentDeck.TranslateString(zDrawElement.variable, zDeckLine, zDrawElement, bExport);

                        // enabled is re-checked due to possible override of the enabled value
                        if (!zElementString.DrawElement || !zDrawElement.enabled)
                        {
                            continue;
                        }

                        var eType = DrawItem.GetElementType(zDrawElement.type);

                        //NOTE: removed transform backup (draw element resets it anyway...)
                        //if (!bExport) // backup is only necessary for zoomed canvas
                        //{
                        //matrixPrevious = zGraphics.Transform;
                        //}
                        DrawItem.DrawElement(zGraphics, CurrentDeck, zDrawElement, eType, nX, nY, zElementString.String, bExport);
                        if (!bExport)
                        {
                            //zGraphics.Transform = matrixPrevious;
                            zGraphics.ScaleTransform(ZoomLevel, ZoomLevel);
                        }
                    }
                }

                if (!bExport)
                {
                    // draw all selections and element borders after everything else
                    for (var nIdx = CurrentDeck.CardLayout.Element.Length - 1; nIdx > -1; nIdx--)
                    {
                        ProjectLayoutElement zElement = CurrentDeck.CardLayout.Element[nIdx];
                        if (zElement.enabled) // only add enabled items to draw
                        {
                            var bDrawSelection = zSelectedElement == zElement;

                            if (CardMakerInstance.DrawElementBorder)
                            {
                                var matrixPrevious = zGraphics.Transform;
                                DrawItem.DrawElementDebugBorder(zGraphics, zElement, nX, nY, bDrawSelection);
                                zGraphics.Transform = matrixPrevious;
                            }
                        }
                    }
                }
            }
            // draw the card border
            if ((bExport && CardMakerSettings.PrintLayoutBorder) || (!bExport && CurrentDeck.CardLayout.drawBorder))
            {
                // note that the border is inclusive in the width/height consuming 2 pixels (0 to total-1)
                zGraphics.DrawRectangle(Pens.Black, nX, nY, CurrentDeck.CardLayout.width - 1, CurrentDeck.CardLayout.height - 1);
            }

            zGraphics.Transform = matrixOriginal;
        }
Example #17
0
        public override void ExportThread()
        {
            if (File.Exists(m_sExportFile))
            {
                try
                {
                    File.Delete(m_sExportFile);
                }
                catch (Exception)
                {
                    ProgressReporter.AddIssue("Failed to delete PDF before export: {0}".FormatString(m_sExportFile));
                }

                if (File.Exists(m_sExportFile))
                {
                    DisplayError();
                    ProgressReporter.Shutdown();
                    return;
                }
            }

#if !MONO_BUILD
            Bitmap zBuffer = null;
#endif

            var progressLayoutIdx = ProgressReporter.GetProgressIndex(ProgressName.LAYOUT);
            var progressCardIdx   = ProgressReporter.GetProgressIndex(ProgressName.CARD);

            ProgressReporter.ProgressReset(progressLayoutIdx, 0, ExportLayoutIndices.Length, 0);
            foreach (var nIdx in ExportLayoutIndices)
            {
                ChangeExportLayoutIndex(nIdx);
                if (CurrentDeck.EmptyReference)
                {
                    // empty reference layouts are not exported
                    ProgressReporter.ProgressStep(progressLayoutIdx);
                    continue;
                }

                ProgressReporter.ProgressReset(progressCardIdx, 0, CurrentDeck.CardCount, 0);

                var rectCrop = CurrentDeck.CardLayout.getExportCropDefinition();

                ConfigurePointSizes(CurrentDeck.CardLayout, rectCrop);

                // necessary tracking for which index of the layout is to be exported (this is NOT necessarily the index of the card due to the page back functionality)
                var nNextExportIndex = 0;

                if (0 < nIdx)
                {
                    if (CardMakerSettings.PrintLayoutsOnNewPage)
                    {
                        AddPage();
                    }

                    if (CardMakerSettings.PrintAutoHorizontalCenter ||
                        (m_dDrawX + m_dLayoutPointWidth > m_dPageMarginEndX)) // this is the case where a layout won't fit in the remaining space of the row
                    {
                        MoveToNextRow(nNextExportIndex);
                    }
                }

                // should be adjusted after the above move to next row
                m_dNextRowYAdjust = Math.Max(m_dNextRowYAdjust, m_dLayoutPointHeight + m_dBufferY);

                if (CardMakerSettings.PrintAutoHorizontalCenter)
                {
                    CenterLayoutPositionOnNewRow(nNextExportIndex);
                }

#if !MONO_BUILD
                zBuffer?.Dispose();
                zBuffer = createExportBuffer(CurrentDeck.CardLayout, rectCrop);

                float fOriginalXDpi = zBuffer.HorizontalResolution;
                float fOriginalYDpi = zBuffer.VerticalResolution;
#endif

                foreach (var nCardIdx in GetExportIndices())
                {
                    CurrentDeck.ResetDeckCache();

                    CurrentDeck.CardPrintIndex = nCardIdx;

#if MONO_BUILD
                    // mono build won't support the optimization so re-create the buffer
                    Bitmap zBuffer = createExportBuffer(CurrentDeck.CardLayout, rectCrop);
#endif

#if !MONO_BUILD
                    // minor optimization, reuse the same bitmap (for drawing sake the DPI has to be reset)
                    zBuffer.SetResolution(fOriginalXDpi, fOriginalYDpi);
#endif
                    if (nCardIdx == -1)
                    {
                        Graphics.FromImage(zBuffer).FillRectangle(Brushes.White, 0, 0, zBuffer.Width, zBuffer.Height);
                        // note: some oddities were observed where the buffer was not flood filling
                    }
                    else
                    {
                        CardRenderer.DrawPrintLineToGraphics(Graphics.FromImage(zBuffer), -rectCrop.X, -rectCrop.Y, true);
                        // if cropping the border needs to be drawn to the cropped size
                        if (rectCrop != Rectangle.Empty)
                        {
                            CardRenderer.DrawBorder(Graphics.FromImage(zBuffer), 0, 0, zBuffer.Width, zBuffer.Height, CurrentDeck.CardLayout, true);
                        }
                    }

                    // apply any export rotation
                    ProcessRotateExport(zBuffer, CurrentDeck.CardLayout, false);

                    // before rendering to the PDF bump the DPI to the desired value
                    zBuffer.SetResolution(CurrentDeck.CardLayout.dpi, CurrentDeck.CardLayout.dpi);

                    var xImage = XImage.FromGdiPlusImage(zBuffer);

                    EvaluatePagePosition(nNextExportIndex);

                    m_zPageGfx.DrawImage(xImage, m_dDrawX, m_dDrawY);

                    MoveToNextColumnPosition();

                    // undo any export rotation
                    ProcessRotateExport(zBuffer, CurrentDeck.CardLayout, true);

                    nNextExportIndex++;

                    ProgressReporter.ProgressStep(progressCardIdx);
                }
                ProgressReporter.ProgressStep(progressLayoutIdx);
            }

#if !MONO_BUILD
            zBuffer?.Dispose();
#endif

            try
            {
                m_zDocument.Save(m_sExportFile);
                ProgressReporter.ThreadSuccess = true;
            }
            catch (Exception ex)
            {
                DisplayError(ex.Message);
                ProgressReporter.ThreadSuccess = false;
            }

            ProgressReporter.Shutdown();
        }
Example #18
0
        public void ExportThread()
        {
            var zWait = WaitDialog.Instance;

            zWait.ProgressReset(0, 0, ExportLayoutEndIndex - ExportLayoutStartIndex, 0);
            for (var nIdx = ExportLayoutStartIndex; nIdx < ExportLayoutEndIndex; nIdx++)
            {
                ChangeExportLayoutIndex(nIdx);
                var nPadSize = CurrentDeck.CardCount.ToString(CultureInfo.InvariantCulture).Length;
                zWait.ProgressReset(1, 0, CurrentDeck.CardCount, 0);

                var exportWidth = CurrentDeck.CardLayout.exportWidth == 0
                    ? CurrentDeck.CardLayout.width : CurrentDeck.CardLayout.exportWidth;

                var exportHeight = CurrentDeck.CardLayout.exportHeight == 0
                    ? CurrentDeck.CardLayout.height : CurrentDeck.CardLayout.exportHeight;

                if (CurrentDeck.CardLayout.width > exportWidth ||
                    CurrentDeck.CardLayout.height > exportHeight)
                {
                    Logger.AddLogLine(
                        $"ERROR: Layout: [{CurrentDeck.CardLayout.Name}] exportWidth and/or exportHeight too small! (Skipping export)");
                    continue;
                }

                UpdateBufferBitmap(exportWidth, exportHeight);
                var zGraphics = Graphics.FromImage(m_zExportCardBuffer);
                var nCardIdx  = 0;
                do
                {
                    var nX = 0;
                    var nY = 0;
                    var nCardsExportedInImage = 0;
                    zGraphics.Clear(CurrentDeck.CardLayout.exportTransparentBackground ?
                                    Color.FromArgb(0, 0, 0, 0) :
                                    Color.White);
                    do
                    {
                        CurrentDeck.ResetDeckCache();
                        CurrentDeck.CardPrintIndex = nCardIdx++;
                        nCardsExportedInImage++;
                        CardRenderer.DrawPrintLineToGraphics(zGraphics, nX, nY, !CurrentDeck.CardLayout.exportTransparentBackground);
                        m_zExportCardBuffer.SetResolution(CurrentDeck.CardLayout.dpi, CurrentDeck.CardLayout.dpi);

                        zWait.ProgressStep(1);

                        int nMoveCount = 1;
                        if (m_nSkipStitchIndex > 0)
                        {
                            var x = ((nCardsExportedInImage + 1) % m_nSkipStitchIndex);
                            if (x == 0)
                            {
                                // shift forward an extra spot to ignore the dummy index
                                nMoveCount = 2;
                            }
                        }

                        var bOutOfSpace = false;
                        for (int nShift = 0; nShift < nMoveCount; nShift++)
                        {
                            nX += CurrentDeck.CardLayout.width + CurrentDeck.CardLayout.buffer;
                            if (nX + CurrentDeck.CardLayout.width > exportWidth)
                            {
                                nX  = 0;
                                nY += CurrentDeck.CardLayout.height + CurrentDeck.CardLayout.buffer;
                            }
                            if (nY + CurrentDeck.CardLayout.height > exportHeight)
                            {
                                // no more space
                                bOutOfSpace = true;
                                break;
                            }
                        }

                        if (bOutOfSpace)
                        {
                            break;
                        }
                    } while (nCardIdx < CurrentDeck.CardCount);

                    string sFileName;

                    // NOTE: nCardIdx at this point is 1 more than the actual index ... how convenient for export file names...

                    if (!string.IsNullOrEmpty(m_sOverrideStringFormat))
                    {
                        // check for the super override
                        sFileName = CurrentDeck.TranslateFileNameString(m_sOverrideStringFormat, nCardIdx, nPadSize);
                    }
                    else if (!string.IsNullOrEmpty(CurrentDeck.CardLayout.exportNameFormat))
                    {
                        // check for the per layout override
                        sFileName = CurrentDeck.TranslateFileNameString(CurrentDeck.CardLayout.exportNameFormat, nCardIdx, nPadSize);
                    }
                    else // default
                    {
                        sFileName = CurrentDeck.CardLayout.Name + "_" + (nCardIdx).ToString(CultureInfo.InvariantCulture).PadLeft(nPadSize, '0');
                    }
                    try
                    {
                        ProcessRotateExport(m_zExportCardBuffer, CurrentDeck.CardLayout, false);
                        m_zExportCardBuffer.Save(
                            m_sExportFolder + sFileName +
                            "." + m_eImageFormat.ToString().ToLower(),
                            m_eImageFormat);
                        ProcessRotateExport(m_zExportCardBuffer, CurrentDeck.CardLayout, true);
                    }
                    catch (Exception)
                    {
                        Logger.AddLogLine("Invalid Filename or IO error: " + sFileName);
                        zWait.ThreadSuccess = false;
                        zWait.CloseWaitDialog();
                        return;
                    }
                } while (nCardIdx < CurrentDeck.CardCount);
                zWait.ProgressStep(0);
            }

            zWait.ThreadSuccess = true;
            zWait.CloseWaitDialog();
        }
Example #19
0
        public void SetUpGameInPlay()
        {
            var flag = false;

            PokerForm[] Forms = new PokerForm[3];
            TurnPlayerForm.CopyTo(Forms);
            if (!Folded)
            {
                TurnPlayerForm.RemoveAt(0);
            }
            Folded = false;
            if (Forms[0] != null)
            {
                Forms[0].LockControls();
            }
            // Forms[0].ShowMin();
            if (TurnPlayerForm.Count > 0)
            {
                foreach (PokerForm form in TurnPlayerForm)
                {
                    if (!flag)
                    {
                        form.ShowMin();
                        form.SetUpNewGame();
                        flag = true;
                    }
                    else
                    {
                        form.LockControls();
                    }
                }
            }
            else
            {
                gameState++;
                MinBetAmount = 0;
                foreach (Player p in players)
                {
                    p.ClearBet();
                }
                // FormTurn = 0;
                TurnPlayerForm = new List <PokerForm>(PlayerForms);
                //if(gameState == PokerGame.GameState.TURN)// in order to add another gambling round you need to this
                //TurnPlayerForm.AddRange(PlayerForms);
                var first = TurnPlayerForm[0];
                int j     = 0;
                foreach (PokerForm form in TurnPlayerForm)
                {
                    form.FormIndex = j;
                    j++;
                    form.SetTextBox(gameState.ToString());
                    form.ShowBankValue();
                    if (first == form)
                    {
                        form.SetUpNewGame();
                    }
                    else
                    {
                        form.LockControls();
                    }
                }
                switch (gameState)
                {
                case PokerGame.GameState.FLOP:
                    // gameOverTextBox.Text = "Flop";
                    for (int i = 0; i < 3; i++)
                    {
                        Card flopCard = CurrentDeck.Draw();
                        TableCards.Add(flopCard);
                    }


                    break;

                case PokerGame.GameState.TURN:
                    // gameOverTextBox.Text = "Turn";
                    Card turnCard = CurrentDeck.Draw();
                    TableCards.Add(turnCard);

                    break;

                case PokerGame.GameState.RIVER:
                    // gameOverTextBox.Text = "River";
                    Card riverCard = CurrentDeck.Draw();
                    TableCards.Add(riverCard);


                    break;

                case PokerGame.GameState.ENDGAME:
                    GameOver();
                    break;

                    //case PokerGame.GameState.NewStage: // To Add another level of the game you need to add another enum on gamestate & to the above switch case
                    //    Card newStage = CurrentDeck.Draw();
                    //    TableCards.Add(newStage);
                    //    break;
                }
                foreach (PokerForm form in PlayerForms)
                {
                    switch (gameState)
                    {
                    case PokerGame.GameState.FLOP:

                        form.updateTableCards();
                        break;

                    case PokerGame.GameState.TURN:


                        form.updateTableCards();
                        break;

                    case PokerGame.GameState.RIVER:


                        form.updateTableCards();

                        break;
                        // To Add another level of the game you need to add another enum on gamestate & to the above switch case
                    }
                }
            }
        }