Exemplo n.º 1
0
        void AddGuestCoin(string coinName, byte addresstype, bool isWIFstupid)
        {
            walletprint.CoinDef newCoin = new walletprint.CoinDef(coinName, addresstype, isWIFstupid);
            coindefs.Add(newCoin);

            ddlCoinSelect.DataSource = null;

            ddlCoinSelect.DataSource = coindefs;

            ddlCoinSelect.SelectedItem = newCoin;
        }
Exemplo n.º 2
0
        walletprint.WalletTemplate SaveTemplate()
        {
            walletprint.WalletTemplate t = new walletprint.WalletTemplate();

            t.TemplateDescription = txtTemplateDescription.Text;

            walletprint.CoinDef coin = (walletprint.CoinDef)ddlCoinSelect.SelectedItem;
            t.CoinName        = coin.Name;
            t.CoinAddressType = coin.Version;
            t.CoinIsWIFstupid = coin.isWIFstupid;

            t.pagePrintPaperSize = (PdfSharp.PageSize)ddlPaperSize.SelectedItem;

            bool IsOk = true;

            //page
            IsOk = IsOk & ParseOrComplainDouble(txtPageLeftMargin, ref t.pagePrintLeftMarginMM, "Page Left Margin");
            IsOk = IsOk & ParseOrComplainDouble(txtPageTopMargin, ref t.pagePrintTopMarginMM, "Page Top Margin");
            IsOk = IsOk & ParseOrComplainInt(txtPageCols, ref t.pagePrintCols, "Page Columns");
            IsOk = IsOk & ParseOrComplainInt(txtPageRows, ref t.pagePrintRows, "Page Rows");
            IsOk = IsOk & ParseOrComplainDouble(txtPageGapCols, ref t.pagePrintColGap, "Page Gap Between Columns");
            IsOk = IsOk & ParseOrComplainDouble(txtPageGapRows, ref t.pagePrintRowGap, "Page Gap Between Rows");

            // wallet
            IsOk = IsOk & ParseOrComplainDouble(txtWalletWidth, ref t.widthMM, "Wallet Width");
            IsOk = IsOk & ParseOrComplainDouble(txtWalletHeight, ref t.heightMM, "Wallet Height");

            // address
            IsOk = IsOk & ParseOrComplainDouble(txtAddressQrLeft, ref t.addressQrLeftMM, "Address QR Left");
            IsOk = IsOk & ParseOrComplainDouble(txtAddressQrTop, ref t.addressQrTopMM, "Address QR Top");
            IsOk = IsOk & ParseOrComplainDouble(txtAddressQrSize, ref t.addressQrSizeMM, "Address QR Size");

            IsOk = IsOk & ParseOrComplainDouble(txtAddressTextLeft, ref t.addressTextLeftMM, "Address Text Left");
            IsOk = IsOk & ParseOrComplainDouble(txtAddressTextTop, ref t.addressTextTopMM, "Address Text Top");
            IsOk = IsOk & ParseOrComplainDouble(txtAddressTextWidth, ref t.addressTextWidthMM, "Address Text Width");
            IsOk = IsOk & ParseOrComplainDouble(txtAddressTextHeight, ref t.addressTextHeightMM, "Address Text Height");

            t.addressTextFontName = (string)ddlAddressTextFont.SelectedItem;
            IsOk = IsOk & ParseOrComplainDouble(txtAddressTextSize, ref t.addressTextFontSize, "Address Text Font Size");
            IsOk = IsOk & ParseOrComplainInt(txtAddressTextLineLength, ref t.addressTextCharsPerLine, "Address Text Line Length");

            t.addressTextColour    = (walletprint.LimitedColourPallete)ddlAddressTextColour.SelectedItem;
            t.addressTextFontStyle = (PdfSharp.Drawing.XFontStyle)ddlAddressTextStyle.SelectedItem;
            t.addressTextRotation  = (walletprint.TextRotation)ddlAddressTextRotation.SelectedItem;

            if (rbFullAddress.Checked)
            {
                t.addressTextContentVariant = walletprint.AddressPrintVariant.FullAddress;
            }
            else if (rbOneLineAddress.Checked)
            {
                t.addressTextContentVariant = walletprint.AddressPrintVariant.OneLine;
            }
            else if (rbTimestampAndSerialInstead.Checked)
            {
                t.addressTextContentVariant = walletprint.AddressPrintVariant.TimestampInstead;
            }

            // privkey
            IsOk = IsOk & ParseOrComplainDouble(txtPrivkeyQrLeft, ref t.privkeyQrLeftMM, "Private Key QR Left");
            IsOk = IsOk & ParseOrComplainDouble(txtPrivkeyQrTop, ref t.privkeyQrTopMM, "Private Key QR Top");
            IsOk = IsOk & ParseOrComplainDouble(txtPrivkeyQrSize, ref t.privkeyQrSizeMM, "Private Key QR Size");

            IsOk = IsOk & ParseOrComplainDouble(txtPrivkeyTextLeft, ref t.privkeyTextLeftMM, "Private Key Text Left");
            IsOk = IsOk & ParseOrComplainDouble(txtPrivkeyTextTop, ref t.privkeyTextTopMM, "Private Key Text Top");
            IsOk = IsOk & ParseOrComplainDouble(txtPrivkeyTextWidth, ref t.privkeyTextWidthMM, "Private Key Text Width");
            IsOk = IsOk & ParseOrComplainDouble(txtPrivkeyTextHeight, ref t.privkeyTextHeightMM, "Private Key Text Height");

            t.privkeyTextFontName = (string)ddlPrivkeyTextFont.SelectedItem;
            IsOk = IsOk & ParseOrComplainDouble(txtPrivkeyTextSize, ref t.privkeyTextFontSize, "Private Key Text Font Size");
            IsOk = IsOk & ParseOrComplainInt(txtPrivkeyTextLineLength, ref t.privkeyTextCharsPerLine, "Private Key Text Line Length");

            t.privkeyTextColour    = (walletprint.LimitedColourPallete)ddlPrivkeyTextColour.SelectedItem;
            t.privkeyTextFontStyle = (PdfSharp.Drawing.XFontStyle)ddlPrivkeyTextStyle.SelectedItem;
            t.privkeyTextRotation  = (walletprint.TextRotation)ddlPrivkeyTextRotation.SelectedItem;


            if (IsOk)
            {
                return(t);
            }
            else
            {
                return(null);
            }
        }
Exemplo n.º 3
0
        void LoadTemplate(walletprint.WalletTemplate template)
        {
            txtTemplateDescription.Text = template.TemplateDescription;

            // try to identify the stored Coin as being one of the existing entries...

            walletprint.CoinDef matchedCoin = coindefs.Where(c => c.Version == template.CoinAddressType && c.isWIFstupid == template.CoinIsWIFstupid && c.Name.ToLower() == template.CoinName.ToLower()).FirstOrDefault();

            if (matchedCoin != null)
            {
                ddlCoinSelect.SelectedItem = matchedCoin;
            }
            else
            {
                AddGuestCoin(template.CoinName, template.CoinAddressType, template.CoinIsWIFstupid);
            }

            //page
            ddlPaperSize.SelectedItem = template.pagePrintPaperSize;
            txtPageLeftMargin.Text    = template.pagePrintLeftMarginMM.ToString();
            txtPageTopMargin.Text     = template.pagePrintTopMarginMM.ToString();
            txtPageCols.Text          = template.pagePrintCols.ToString();
            txtPageRows.Text          = template.pagePrintRows.ToString();
            txtPageGapCols.Text       = template.pagePrintColGap.ToString();
            txtPageGapRows.Text       = template.pagePrintRowGap.ToString();

            txtWalletWidth.Text  = template.widthMM.ToString();
            txtWalletHeight.Text = template.heightMM.ToString();

            //Address
            txtAddressQrLeft.Text = template.addressQrLeftMM.ToString();
            txtAddressQrTop.Text  = template.addressQrTopMM.ToString();
            txtAddressQrSize.Text = template.addressQrSizeMM.ToString();

            txtAddressTextLeft.Text   = template.addressTextLeftMM.ToString();
            txtAddressTextTop.Text    = template.addressTextTopMM.ToString();
            txtAddressTextWidth.Text  = template.addressTextWidthMM.ToString();
            txtAddressTextHeight.Text = template.addressTextHeightMM.ToString();


            switch (template.addressTextContentVariant)
            {
            case walletprint.AddressPrintVariant.FullAddress:
                rbFullAddress.Checked = true;
                break;

            case walletprint.AddressPrintVariant.OneLine:
                rbOneLineAddress.Checked = true;
                break;

            case walletprint.AddressPrintVariant.TimestampInstead:
                rbTimestampAndSerialInstead.Checked = true;
                break;
            }

            IList <string> fontNames = FontFamily.Families.Select(f => f.Name).ToList();

            if (fontNames.Contains(template.addressTextFontName))
            {
                ddlAddressTextFont.SelectedItem = template.addressTextFontName;
            }
            else
            {
                MessageBox.Show("This template uses a font '" + template.addressTextFontName + "' which you don't have! Please select alternative font for Address Text.", "Address Text Font missing", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
            }


            txtAddressTextSize.Text       = template.addressTextFontSize.ToString();
            txtAddressTextLineLength.Text = template.addressTextCharsPerLine.ToString();

            ddlAddressTextColour.SelectedItem   = template.addressTextColour;
            ddlAddressTextStyle.SelectedItem    = template.addressTextFontStyle;
            ddlAddressTextRotation.SelectedItem = template.addressTextRotation;

            //Privkey
            txtPrivkeyQrLeft.Text = template.privkeyQrLeftMM.ToString();
            txtPrivkeyQrTop.Text  = template.privkeyQrTopMM.ToString();
            txtPrivkeyQrSize.Text = template.privkeyQrSizeMM.ToString();

            txtPrivkeyTextLeft.Text   = template.privkeyTextLeftMM.ToString();
            txtPrivkeyTextTop.Text    = template.privkeyTextTopMM.ToString();
            txtPrivkeyTextWidth.Text  = template.privkeyTextWidthMM.ToString();
            txtPrivkeyTextHeight.Text = template.privkeyTextHeightMM.ToString();

            if (fontNames.Contains(template.addressTextFontName))
            {
                ddlPrivkeyTextFont.SelectedItem = template.privkeyTextFontName;
            }
            else
            {
                MessageBox.Show("This template uses a font '" + template.privkeyTextFontName + "' which you don't have! Please select alternative font for Private Key Text.", "Private Key Text Font missing", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
            }


            txtPrivkeyTextSize.Text       = template.privkeyTextFontSize.ToString();
            txtPrivkeyTextLineLength.Text = template.privkeyTextCharsPerLine.ToString();

            ddlPrivkeyTextColour.SelectedItem   = template.privkeyTextColour;
            ddlPrivkeyTextStyle.SelectedItem    = template.privkeyTextFontStyle;
            ddlPrivkeyTextRotation.SelectedItem = template.privkeyTextRotation;
        }