コード例 #1
0
        static void Test()
        {
            Application.Init();
            var top = Application.Top;

            CertificatesVM certificatesVM = new CertificatesVM();


            var win = Window("Certificate files util",
                             w => { w.Width = Dim.Fill() - 1; w.Height = Dim.Fill() - 1; }

                             , Button(" Scan folder",
                                      b =>
            {
                b.X       = 0; b.Y = 0;
                b.Clicked = () =>
                {
                    certificatesVM.ScanCurrentPath(true);
                };
            })

                             , Button("Import certificate by index",
                                      b =>
            {
                b.X       = 0; b.Y = 1;
                b.Clicked = () =>
                {
                    Dialog dialog = CreateCertificateImportDialog(top, certificatesVM);
                    Application.Run(dialog);
                };
            })

                             , Button("Create copies with standard names",
                                      b =>
            {
                b.X       = 32; b.Y = 1;
                b.Clicked = () =>
                {
                    certificatesVM.SetDefaultNamesForCertificateFiles();
                };
            })

                             , Button("Copy cert info to clipboard",
                                      b =>
            {
                b.X       = 70; b.Y = 1;
                b.Clicked = () =>
                {
                    certificatesVM.CopyCertificateInoToClipboard();
                };
            })

                             , TextField(
                                 f =>
            {
                f.X = 18; f.Y = 0; f.Width = Dim.Fill();
                BindTwoWay(f, el => el.Text,
                           certificatesVM, vm => vm.ScanPath,
                           (el, onChanged) => el.Changed += (o, e) => onChanged(((TextField)o).Text.ToString())
                           );
            })

                             , FrameView("Certificates",
                                         f => { f.Y = 2; f.Width = Dim.Fill(); f.Height = Dim.Fill(); }

                                         , TextView(
                                             tw => BindOneWay(certificatesVM, vm => vm.CertificatesListText,
                                                              (newText) => tw.Text = newText))
                                         )
                             );

            top.Add(win);

            Application.Run();
        }