public NavigationButtonViewModel(PanaceaServices core, DeveloperPanelPlugin plugin)
 {
     ClickCommand = new RelayCommand(args =>
     {
         if (core.TryGetUiManager(out IUiManager ui))
         {
             ui.Navigate(new MagicPinViewModel(plugin, core), false);
         }
     });
 }
Exemplo n.º 2
0
        public MagicPinViewModel(DeveloperPanelPlugin plugin, PanaceaServices core)
        {
            _core = core;

            MachineName        = Environment.MachineName;
            ShowDevPageCommand = new RelayCommand(args =>
            {
                plugin.ShowDevPage();
            });
            StartLauncherCommand = new RelayCommand(args =>
            {
                try
                {
                    var path = Path.Combine(
                        Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location),
                        "Updater",
                        "Support",
                        "Launcher",
                        "PanaceaLauncher");

                    Process.Start(path, "/show");
                }
                catch (Exception ex)
                {
                }
            });
            UnlockCommand = new RelayCommand(args =>
            {
                try
                {
                    var now    = DateTime.Now;
                    var first  = now.Date.Month + now.Hour;
                    var second = now.Date.Day + now.Minute;
                    var pin    = first * 100 + second;
                    var input  = Int32.Parse(Pin);
                    if (input >= pin - 1 && input <= pin + 1)
                    {
                        Unlocked = true;
                        Pin      = "";
                        return;
                    }
                    Pin   = "";
                    Error = "No!";
                }
                catch
                {
                    Error = "Oops! Something went wrong. Shame on us...";
                }
            },
                                             args => Pin?.Length >= 4);
        }