private void loginCommandExecute()
        {
            AuthEngine eng = new AuthEngine();

            this.Ok = eng.Check(this.Username, this.Password);

            if (this.Ok == true)
            {
                var msg = new OpenNewViewMessage();
                msg.ViewName = "MainMenu";
                msg.Modal    = false;
                Messenger.Default.Send <OpenNewViewMessage>(msg);
            }
            else
            {
                var msg = new QuestionMessage
                              ("Errore!", "Login fallito! Vuoi ritentare?");
                msg.Yes = () => {
                    this.Ok       = null;
                    this.Password = string.Empty;
                };
                msg.No = () => {
                    Messenger.Default.Send <CloseApplicationMessage>(
                        CloseApplicationMessage.Empty);
                };

                Messenger.Default.Send <QuestionMessage>(msg);
            }
        }
Esempio n. 2
0
        private async void loginCommandExecute()
        {
            this.IsBusy = true;

#if DEBUG
            await Task.Delay(2000);
#endif

            if (this.Username != "emmegisoft" && this.Password != "carpi")
            {
                // Login fallito
                this.Message = "Login fallito!";
            }
            else
            {
                // Login riuscito
                if (this.Remember)
                {
                    string content = $"{this.Username}  {this.Password}";
                    File.WriteAllText("E:\\Credentials.txt", content);
                }

                OpenNewViewMessage msg = new OpenNewViewMessage();
                msg.ViewName  = "MainMenu";
                msg.Modal     = true;
                msg.Maximized = true;
                Messenger.Default.Send <OpenNewViewMessage>(msg);
            }

            this.IsBusy = false;
        }
        private void openNewView(OpenNewViewMessage obj)
        {
            Window wnd = null;

            string name = "CorsoWpf.DigitalManager.WpfApp." + obj.WindowName + "Window";
            Type   t    = Type.GetType(name);

            if (t != null)
            {
                WindowCollection windows = Application.Current.Windows;

                wnd = Activator.CreateInstance(t) as Window;
            }

            if (wnd != null)
            {
                if (wnd.Resources.Contains("viewmodel"))
                {
                    var vm = wnd.Resources["viewmodel"] as ApplicationViewModelBase;
                }

                wnd.Closed += Wnd_Closed;

                if (obj.Modal)
                {
                    wnd.ShowDialog();
                }
                else
                {
                    wnd.Show();
                }
            }
        }
Esempio n. 4
0
        private void openNewView(OpenNewViewMessage msg)
        {
            var ns = Assembly.GetExecutingAssembly()
                     .GetModules().First().Name;

            ns = ns.Replace(".exe", string.Empty);
            string typeName = string.Concat(ns, ".", msg.ViewName, "Window");
            Type   type     = Type.GetType(typeName);

            if (type != null)
            {
                var wnd = Activator.CreateInstance(type) as Window;

                if (msg.Maximized)
                {
                    wnd.WindowState = WindowState.Maximized;
                }

                if (msg.Modal)
                {
                    wnd.ShowDialog();
                }
                else
                {
                    wnd.Show();
                }
            }
        }
        private void openNewView(OpenNewViewMessage obj)
        {
            Window wnd = null;

            Type type = Type.GetType(string.Format("AulePiu.CorsoOvernet.WpfApp.{0}Window, AulePiu.CorsoOvernet.WpfApp", obj.ViewName));

            if (type != null)
            {
                wnd = Activator.CreateInstance(type) as Window;

                if (wnd != null)
                {
                    if (obj.Modal)
                    {
                        wnd.ShowDialog();
                    }
                    else
                    {
                        wnd.Show();
                    }
                }
            }
        }