コード例 #1
0
 public void RetrieveLicenses()
 {
     SplashScreenManagerService.Show();
     LicenseConfigVM = LicenseConfigViewModel.Create(SelectedProduct);
     LicenseConfigVM.SetParentViewModel(this);
     SplashScreenManagerService.Close();
 }
コード例 #2
0
        public void Generate()
        {
            var dialog    = NewLicenseViewModel.Create();
            var OkCommand = new UICommand
            {
                Id        = MessageBoxResult.OK,
                Caption   = "Generate",
                IsCancel  = false,
                IsDefault = true,
                Command   = new DelegateCommand <CancelEventArgs>(GenerateLicense, CanGenerate, true)
            };

            void GenerateLicense(CancelEventArgs ar)
            {
                SplashScreenManagerService.Show();

                var generatedLicenses = LicenseManager.GenerateLicense(dialog.LicensesCount,
                                                                       dialog.HardwareMode == HardwareMode.Locked, dialog.ExpireHour,
                                                                       dialog.LicenseMode == LicenseMode.Lifetime, dialog.CustomData, dialog.Comment);

                generatedLicenses.ForEach(l => Licenses.Add(new License(l)));

                SplashScreenManagerService.Close();
            }

            bool CanGenerate(CancelEventArgs ar)
            {
                if (dialog.LicensesCount == 0)
                {
                    return(false);
                }

                if (dialog.LicenseMode == LicenseMode.Subscription && dialog.ExpireHour == 0)
                {
                    return(false);
                }

                return(true);
            }

            var CancelCommand = new UICommand
            {
                Id = MessageBoxResult.Cancel, Caption = "Cancel", IsCancel = true, IsDefault = false
            };

            NewLicenseService.ShowDialog(
                new List <UICommand> {
                OkCommand, CancelCommand
            },
                "Generate Licenses Dialog",
                dialog);
        }
コード例 #3
0
        public void Copy()
        {
            var licenses = "";

            SplashScreenManagerService.Show();
            foreach (var license in SelectedLicenses)
            {
                licenses += license.Code + Environment.NewLine;
            }

            Clipboard.SetText(licenses);
            SplashScreenManagerService.Close();
        }
コード例 #4
0
        public void EditHours()
        {
            var dialog    = EditSingleValueViewModel.Create("Expire Hours");
            var OkCommand = new UICommand
            {
                Id        = MessageBoxResult.OK,
                Caption   = "Modify",
                IsCancel  = false,
                IsDefault = true,
                Command   = new DelegateCommand <CancelEventArgs>(EditHours, CanEditHours, true)
            };

            void EditHours(CancelEventArgs ar)
            {
                SplashScreenManagerService.Show();
                foreach (var license in SelectedLicenses)
                {
                    license.APILicense.ModifyHours(int.Parse(dialog.Input));
                    license.UpdateLicense(license.APILicense.RefreshData());
                }

                SplashScreenManagerService.Close();
            }

            bool CanEditHours(CancelEventArgs ar)
            {
                if (string.IsNullOrEmpty(dialog.Input))
                {
                    return(false);
                }

                if (int.TryParse(dialog.Input, out var hours))
                {
                    return(hours > 0 && hours < 99999);
                }

                return(false);
            }

            var CancelCommand = new UICommand
            {
                Id = MessageBoxResult.Cancel, Caption = "Cancel", IsCancel = true, IsDefault = false
            };

            EditDialogService.ShowDialog(
                new List <UICommand> {
                OkCommand, CancelCommand
            },
                "Edit Hours Dialog",
                dialog);
        }
コード例 #5
0
        public void Delete()
        {
            var result = MessageBoxService.Show("Deleted Selected Licenses", "Delete Confirmation",
                                                MessageBoxButton.OKCancel);

            if (result == MessageBoxResult.OK)
            {
                SplashScreenManagerService.Show();
                var count = SelectedLicenses.Count;
                for (var index = 0; index < count; index++)
                {
                    LicenseManager.DeleteLicense(SelectedLicenses[0].APILicense.License);
                    Licenses.Remove(SelectedLicenses[0]);
                }

                SplashScreenManagerService.Close();
            }
        }
コード例 #6
0
        public void ReleaseHardware()
        {
            var result = MessageBoxService.Show("Release Hardware for Selected Licenses", "Release Confirmation",
                                                MessageBoxButton.OKCancel);

            if (result == MessageBoxResult.OK)
            {
                SplashScreenManagerService.Show();
                foreach (var license in SelectedLicenses)
                {
                    if (!string.IsNullOrEmpty(license.HardwareId))
                    {
                        license.APILicense.ReleaseHardwareID();
                        license.UpdateLicense(license.APILicense.RefreshData());
                    }
                }

                SplashScreenManagerService.Close();
            }
        }
コード例 #7
0
        public void UnlockHardware()
        {
            var result = MessageBoxService.Show("Unlock Hardware for Selected Licenses", "Unlock Confirmation",
                                                MessageBoxButton.OKCancel);

            if (result == MessageBoxResult.OK)
            {
                SplashScreenManagerService.Show();
                foreach (var license in SelectedLicenses)
                {
                    if (license.HardwareMode == HardwareMode.Locked)
                    {
                        license.APILicense.SetHardwareLockStatus(false);
                        license.UpdateLicense(license.APILicense.RefreshData());
                    }
                }

                SplashScreenManagerService.Close();
            }
        }
コード例 #8
0
        public void Unban()
        {
            var result = MessageBoxService.Show("UnBan Selected Licenses", "UnBan Confirmation",
                                                MessageBoxButton.OKCancel);

            if (result == MessageBoxResult.OK)
            {
                SplashScreenManagerService.Show();
                foreach (var license in SelectedLicenses)
                {
                    if (license.BanStatus == BanStatus.Banned)
                    {
                        license.APILicense.Unban();
                        license.UpdateLicense(license.APILicense.RefreshData());
                    }
                }

                SplashScreenManagerService.Close();
            }
        }
コード例 #9
0
        public void EditCustomData()
        {
            var dialog    = EditSingleValueViewModel.Create("Modified Custom Data");
            var OkCommand = new UICommand
            {
                Id        = MessageBoxResult.OK,
                Caption   = "Modify",
                IsCancel  = false,
                IsDefault = true,
                Command   = new DelegateCommand <CancelEventArgs>(ModifyComment)
            };

            void ModifyComment(CancelEventArgs ar)
            {
                SplashScreenManagerService.Show();
                foreach (var license in SelectedLicenses)
                {
                    license.APILicense.ModifyCustomData(dialog.Input);
                    license.UpdateLicense(license.APILicense.RefreshData());
                }

                SplashScreenManagerService.Close();
            }

            var CancelCommand = new UICommand
            {
                Id = MessageBoxResult.Cancel, Caption = "Cancel", IsCancel = true, IsDefault = false
            };

            EditDialogService.ShowDialog(
                new List <UICommand> {
                OkCommand, CancelCommand
            },
                "Edit Custom Data Dialog Dialog",
                dialog);
        }