コード例 #1
0
        private async void Window_Loaded(object sender, RoutedEventArgs e)
        {
            try {
                restPkiClient = Util.GetRestPkiClient();
                PkiConfig.LoadLicense(Util.GetPkiSdkLicense());
            } catch (Exception ex) {
                MessageBox.Show($"{ex.Message}\r\n\r\nSigner will close.", "Configuration Error");
                addLog(ex.Message);
                //Application.Current.Shutdown();
            }
            addLog($"RestPKI token found");

            await listCertificatesWithKey();

            checkBoxSafeSign.IsChecked = false;
            checkBoxSafeNet.IsChecked  = false;
        }
コード例 #2
0
        protected override async void OnActivated(EventArgs e)
        {
            base.OnActivated(e);
            if (!init)
            {
                try {
                    restPkiClient = Util.GetRestPkiClient();
                } catch (Exception ex) {
                    await this.ShowMessageAsync("Configuration Error", $"{ex.Message}\r\n\r\nSigner will close.", MessageDialogStyle.Affirmative);

                    addLog($"RestPKI token not found");
                    Application.Current.Shutdown();
                }
                addLog($"RestPKI token found");
                init = true;
            }
        }
コード例 #3
0
        // This function is called by the Pades Signature Starter action (see PadesSignatureController.cs).
        // It contains examples of signature visual representation positionings.
        public static PadesVisualPositioning GetVisualPositioning(RestPkiClient client, int sampleNumber)
        {
            switch (sampleNumber)
            {
            case 1:
                // Example #1: automatic positioning on footnote. This will insert the signature, and future signatures,
                // ordered as a footnote of the last page of the document
                return(PadesVisualPositioning.GetFootnote(client));

            case 2:
                // Example #2: get the footnote positioning preset and customize it
                var footnotePosition = PadesVisualPositioning.GetFootnote(client);
                footnotePosition.Container.Left   = 2.54;
                footnotePosition.Container.Bottom = 2.54;
                footnotePosition.Container.Right  = 2.54;
                return(footnotePosition);

            case 3:
                // Example #3: automatic positioning on new page. This will insert the signature, and future signatures,
                // in a new page appended to the end of the document.
                return(PadesVisualPositioning.GetNewPage(client));

            case 4:
                // Example #4: get the "new page" positioning preset and customize it
                var newPagePos = PadesVisualPositioning.GetNewPage(client);
                newPagePos.Container.Left  = 2.54;
                newPagePos.Container.Top   = 2.54;
                newPagePos.Container.Right = 2.54;
                newPagePos.SignatureRectangleSize.Width  = 5;
                newPagePos.SignatureRectangleSize.Height = 3;
                return(newPagePos);

            case 5:
                // Example #5: manual positioning
                // The first parameter is the page number. Zero means the signature will be placed on a new page appended to the end of the document
                return(new PadesVisualManualPositioning(0, new PadesVisualRectangle()
                {
                    // define a manual position of 5cm x 3cm, positioned at 1 inch from  the left and bottom margins
                    Left = 2.54,
                    Bottom = 2.54,
                    Width = 5,
                    Height = 3
                }));

            case 6:
                // Example #6: custom auto positioning
                return(new PadesVisualAutoPositioning()
                {
                    PageNumber = -1,                             // negative values represent pages counted from the end of the document (-1 is last page)
                    // Specification of the container where the signatures will be placed, one after the other
                    Container = new PadesVisualRectangle()
                    {
                        // Specifying left and right (but no width) results in a variable-width container with the given margins
                        Left = 2.54,
                        Right = 2.54,
                        // Specifying bottom and height (but no top) results in a bottom-aligned fixed-height container
                        Bottom = 2.54,
                        Height = 12.31
                    },
                    // Specification of the size of each signature rectangle
                    SignatureRectangleSize = new PadesSize(5, 3),
                    // The signatures will be placed in the container side by side. If there's no room left, the signatures
                    // will "wrap" to the next row. The value below specifies the vertical distance between rows
                    RowSpacing = 1
                });

            default:
                return(null);
            }
        }