private void btnAdduser_MouseDown(object sender, MouseButtonEventArgs e)
        {
            if (!this.tUserName.Text.Trim().Equals(""))
            {
                if (!this.tPassword.Text.Trim().Equals(""))
                {
                    if (this.lListDestinoUserGroup.Items.Count > 0) {

                        QuestionDialog pregunta = new QuestionDialog("Realmente desea Agregar estos privilegios a " + this.tUserName.Text, main);
                        pregunta.ShowDialog();
                        if (pregunta.DialogResult == true)
                        {
                            foreach (ListBoxItem UserGroups in this.lListDestinoUserGroup.Items)
                            {
                                User_Group ug = new User_Group(new User_Group(UserGroups.Content.ToString()).getIdByName());
                                if (new Login(this.tUserName.Text.Trim(),this.tPassword.Text.Trim(),ug).save()>0)//si no existe el privilegio
                                {

                                    this.llenaListLogin();
                                    this.lListLogin.IsEnabled = true;
                                }
                            }
                        }
                    }
                    else new Dialog("Seleccione un grupo de usuario a asignar.", main).ShowDialog();
                }
                else new Dialog("Rellene campo Password", main).ShowDialog();
            }
            else new Dialog("Rellene campo User Name", main).ShowDialog();
        }
 private void ShopItemDisplay_onClick(InventoryItem item)
 {
     if(InstanceQuestionDialog == null)
     {
         InstanceQuestionDialog = Instantiate(dialogCanvasPrefab);
         InstanceQuestionDialog.Message.text = string.Format("Deseja comprar {0}?", item.DisplayName);
     }
 }
        //INGRESA NUEVO USUARIO
        public void btnAddUser_Click(object sender, MouseButtonEventArgs e)
        {
            this.tRut.IsEnabled = true;
            main.iAddUser.IsEnabled = true;
            QuestionDialog pregunta = new QuestionDialog("Desea agregar a esta persona?", main);
            pregunta.ShowDialog();
            if (pregunta.DialogResult == true && validacionAddUser())
            {
                byte[] foto = File.ReadAllBytes(path.Content.ToString());
                listDpto = new Departamento().findAll();
                listAfp = new Afp().findAll();
                listSalud = new Salud().findAll();
                listReg = new Regiones().findAll();
                listCom = new Comunas().FindByidReg(this.Regi.SelectedIndex + 1);
                listBank = new Banco().findAll();

                Personal per = new Personal(this.tRut.Text.Trim(), this.tName.Text.Trim(), this.tSurname.Text.Trim(),
                                            int.Parse(this.tYear.Text.Trim()), foto, this.tPhone.Text.Trim(), this.Tdireccion.Text.Trim(),
                                            this.tEmail.Text.Trim(), this.tCtaBancaria.Text.Trim(), this.tNacionalidad.Text.Trim(),
                                            this.tDateNaci.Text.Trim(), listCom[this.Comu.SelectedIndex].id_comuna, listReg[this.Regi.SelectedIndex].id_region,
                                            listAfp[this.cAfp.SelectedIndex].id, listSalud[this.cSalud.SelectedIndex].id

                                            );

                if (per.Save() > 0)
                {
                    Personal_Departamento pd = new Personal_Departamento(new Personal(this.tRut.Text.Trim()).get_idPersonal(), listDpto[this.cDepto.SelectedIndex].id);
                    Banco_Personal bp = new Banco_Personal(listBank[this.tBank.SelectedIndex].id, new Personal(this.tRut.Text.Trim()).get_idPersonal(), tCtaBancaria.Text.Trim());
                    if (pd.save() > 0 && bp.save() > 0)
                    {
                        main.listAutocomplet = new Clases.Personal().findAll(0);
                        main.cBusqueda.IsEnabled = true;
                        this.iPerfil.IsEnabled = false;
                        this.btnCancelAdd.Visibility = Visibility.Hidden;
                        this.btnUpdateReg.Visibility = Visibility.Visible;
                        this.btnDeleteReg.Visibility = Visibility.Visible;
                        QuestionDialog pregunta2 = new QuestionDialog("¿Desea contratar a este nuevo personal?", main);
                        pregunta2.ShowDialog();
                        if (pregunta2.DialogResult == true)
                        {
                            this.tabControl1.SelectedIndex = 1;
                            cargarDatosPersonal(this.tRut.Text, "rut");
                        }
                        else cargarDatosPersonal(this.tRut.Text, "rut");
                    }
                }
                else
                {
                    new Dialog("Personal no pudo ser ingresado", main).ShowDialog();
                }
            }
        }
Exemple #4
0
        static bool Shutdown()
        {
            var dialog = new QuestionDialog("Are you sure?", "Shutdown EV3");

            if (dialog.Show())
            {
                Lcd.Instance.Clear();
                Lcd.Instance.WriteText(Font.MediumFont, new Point(0, 0), "Shutting down...", true);
                Lcd.Instance.Update();

                Buttons.Instance.LedPattern(2);
                ProcessHelper.RunAndWaitForProcess("/sbin/shutdown", "-h now");
                Thread.Sleep(120000);
            }
            return(false);
        }
Exemple #5
0
        private static void linkOnAnswerHint(string utterance, GraphDisambiguatedLinker linker, QuestionDialogDatasetReader dataset)
        {
            var utteranceWords = utterance.ToLowerInvariant().Split(' ').Distinct();

            QuestionDialog dialogToLink = null;

            foreach (var dialog in dataset.Dialogs)
            {
                if (!dialog.HasCorrectAnswer)
                {
                    continue;
                }

                var questionWords = dialog.Question.ToLowerInvariant().Split(' ');
                if (utteranceWords.Except(questionWords).Count() == 0)
                {
                    dialogToLink = dialog;
                }

                foreach (var turn in dialog.AnswerTurns)
                {
                    var words = turn.InputChat.ToLowerInvariant().Split(' ').Distinct();
                    if (utteranceWords.Except(words).Count() == 0)
                    {
                        dialogToLink = dialog;
                        break;
                    }
                }

                if (dialogToLink != null)
                {
                    break;
                }
            }

            Console.WriteLine(dialogToLink.Question);

            var answerPhrase   = getAnswerPhrase(dialogToLink);
            var linkedQuestion = linker.LinkUtterance(dialogToLink.Question);

            Console.WriteLine(linkedQuestion);

            var contextEntities = linkedQuestion.Parts.SelectMany(p => p.Entities).ToArray();
            var result          = linker.LinkUtterance(answerPhrase, contextEntities);

            Console.WriteLine(result);
        }
        //ELIMINA UN CONTRATO ASOCIADO A UN EMPLEADO
        private void btnEndContract_Click(object sender, MouseButtonEventArgs e)
        {
            string         rut_per  = this.tRut.Text.Trim();
            QuestionDialog pregunta = new QuestionDialog("Desea borrar el contrato asociado al rut: " + rut_per + " ?", main);

            pregunta.ShowDialog();
            if (pregunta.DialogResult == true)
            {
                if (new Clases.Contratos().DeleteByRut(new Personal(rut_per)) > 0)
                {
                    this.limpiarTexbox();
                    this.loadDataContract(rut_per);
                    this.cargarDatosPersonal(rut_per, "rut");
                    new Dialog("Se cancelo el contrato a empleado con rut " + rut_per + ".", main).ShowDialog(); //MessageBox.Show("Se elimino el contrato con exito");
                }
            }
        }
Exemple #7
0
 private void btnDeletePrivilegio_Click(object sender, MouseButtonEventArgs e)
 {
     try {
         if (this.comboGrupos.SelectedItem != null) //si selecciono algun grupo de usuario
         {
             if (this.List2.Items.Count > 0)        //si ahi al menos un privilegio en la lista 2
             {
                 String NamePrivilegio = ((ListBoxItem)this.List2.Items[this.List2.SelectedIndex]).Content.ToString();
                 if (NamePrivilegio != null)//si no selecciono ningun privilegio a eliminar
                 {
                     QuestionDialog pregunta = new QuestionDialog("Realmente desea eliminar este privilegio de " + this.comboGrupos.SelectedItem, main);
                     pregunta.ShowDialog();
                     if (pregunta.DialogResult == true)
                     {
                         Privilegio p = new Privilegio(new Privilegio(NamePrivilegio).getIdByName());
                         if (new User_Group_Privilegios(p).deleteByIdPrivilegio() > 0)
                         {
                             Thread.Sleep(100);
                             LoadPrivilegio_UserGroup();
                             llenaTreeView();
                         }
                         Thread.Sleep(100);
                         LoadAllPrivilegios();
                         LoadPrivilegio_UserGroup();
                     }
                 }
                 else
                 {
                     new Dialog("Seleccione un privilegio a eliminar.", main).ShowDialog();
                 }
             }
             else
             {
                 new Dialog("No hay ningun privilegio asignado previamente.", main).ShowDialog();
             }
         }
         else
         {
             new Dialog("Seleccione un Grupo de usuario", main).ShowDialog();
         }
     }
     catch (ArgumentOutOfRangeException ex) {
         new Dialog("Seleccione un privilegio a elimnar", main).ShowDialog();
     }
 }
        public void Run()
        {
            var dialog = new QuestionDialog("Staat de robot op de startpositie?", "Positie", "Ja", "Nee", false);

            while (!dialog.IsPositiveSelected)
            {
                dialog.Show();
            }


            RobotControl.Hefvork.Reset();
            RobotControl.Hefvork.MoveDown(70);

            RobotControl.Movement.Backward(200);

            RobotControl.Hefvork.Reset();

            RobotControl.Movement.Backward(3450);

            RobotControl.Movement.Right(60);

            RobotControl.Movement.Backward(300);

            RobotControl.Movement.Right(60);

            RobotControl.Movement.Backward(300);

            RobotControl.Movement.Right(60);


            RobotControl.Hefvork.MoveDown(60);


            // go back
            RobotControl.Movement.Forward(150);

            RobotControl.Movement.Left(80);

            RobotControl.Movement.Forward(350);

            RobotControl.Movement.Left(55);

            RobotControl.Movement.Forward(3450);
        }
Exemple #9
0
    public QuestionDialog CreateQuestionDialog(string title, string message)
    {
        FindCanvas();

        QuestionDialog questionDialog = Instantiate(questionDialogPrefab, canvas.transform);

        injector.Inject(questionDialog);
        questionDialog.GetComponent <RectTransform>().anchoredPosition = Vector2.zero;
        if (title != null)
        {
            questionDialog.Title = title;
        }
        if (message != null)
        {
            questionDialog.Message = message;
        }

        dialogs.Add(questionDialog);
        return(questionDialog);
    }
        private static IEnumerable <string> getQuestionNgrams(QuestionDialog dialog, int n, CachedLinker linker)
        {
            var result = new HashSet <string>();

            for (var i = 2; i <= n; ++i)
            {
                var question = dialog.Question;
                //result.UnionWith(getNgrams(question, n));

                var linkedQuestion = linker.LinkUtterance(question);
                result.UnionWith(linkedQuestion.GetNgrams(i));

                /*
                 * foreach (var explanation in dialog.ExplanationTurns)
                 * {
                 *  result.UnionWith(getNgrams(explanation.InputChat, i));
                 * }*/
            }

            return(result);
        }
Exemple #11
0
        static bool Shutdown(Lcd lcd, Buttons btns)
        {
            var dialog = new QuestionDialog(Font.MediumFont, lcd, btns, "Are you sure?", "Shutdown EV3");

            dialog.Show();
            if (dialog.IsPositiveSelected)
            {
                lcd.Clear();
                lcd.WriteText(font, new Point(0, 0), "Shutting down...", true);
                lcd.Update();

                using (UnixDevice dev = new UnixDevice("/dev/lms_power"))
                {
                    dev.IoCtl(0, new byte[0]);
                }
                btns.LedPattern(2);
                MenuAction = () => ProcessHelper.RunAndWaitForProcess("/lejos/bin/exit");
                return(true);
            }
            return(false);
        }
Exemple #12
0
 private void btnAdduser_MouseDown(object sender, MouseButtonEventArgs e)
 {
     if (!this.tUserName.Text.Trim().Equals(""))
     {
         if (!this.tPassword.Text.Trim().Equals(""))
         {
             if (this.lListDestinoUserGroup.Items.Count > 0)
             {
                 QuestionDialog pregunta = new QuestionDialog("Realmente desea Agregar estos privilegios a " + this.tUserName.Text, main);
                 pregunta.ShowDialog();
                 if (pregunta.DialogResult == true)
                 {
                     foreach (ListBoxItem UserGroups in this.lListDestinoUserGroup.Items)
                     {
                         User_Group ug = new User_Group(new User_Group(UserGroups.Content.ToString()).getIdByName());
                         if (new Login(this.tUserName.Text.Trim(), this.tPassword.Text.Trim(), ug).save() > 0)//si no existe el privilegio
                         {
                             this.llenaListLogin();
                             this.lListLogin.IsEnabled = true;
                         }
                     }
                 }
             }
             else
             {
                 new Dialog("Seleccione un grupo de usuario a asignar.", main).ShowDialog();
             }
         }
         else
         {
             new Dialog("Rellene campo Password", main).ShowDialog();
         }
     }
     else
     {
         new Dialog("Rellene campo User Name", main).ShowDialog();
     }
 }
Exemple #13
0
 private void btnDeleteUser_MouseDown(object sender, MouseButtonEventArgs e)
 {
     try
     {
         if (this.lListLogin.Items.Count > 0)//si ahi al menos un privilegio en la lista 2
         {
             String userName = this.lListLogin.Items[this.lListLogin.SelectedIndex].ToString();
             Console.WriteLine(userName);
             if (userName != null)//si no selecciono ningun privilegio a eliminar
             {
                 QuestionDialog pregunta = new QuestionDialog("Realmente desea eliminar el Usuario " + userName, main);
                 pregunta.ShowDialog();
                 if (pregunta.DialogResult == true)
                 {
                     Login l = new Login(new Login(userName).getIdByName().id);
                     if (l.deleteById() > 0)
                     {
                         this.Clear();
                         this.llenaListLogin();
                     }
                 }
             }
             else
             {
                 new Dialog("Seleccione un Usuario a eliminar.", main).ShowDialog();
             }
         }
         else
         {
             new Dialog("No hay ningun usuario en la lista.", main).ShowDialog();
         }
     }
     catch (ArgumentOutOfRangeException ex)
     {
         this.llenaListLogin();
         Console.WriteLine(ex.Message);
     }
 }
Exemple #14
0
        public void Run()
        {
            var dialog = new QuestionDialog("Staat de robot op de startpositie?", "Positie", "Ja", "Nee", false);

            while (!dialog.IsPositiveSelected)
            {
                dialog.Show();
            }

            RobotControl.Movement.Forward(1000);

            RobotControl.Movement.Left(36);

            RobotControl.Movement.Forward(550);

            RobotControl.Movement.Right(45);

            RobotControl.Movement.Forward(250);

            RobotControl.Movement.Backward(20);

            RobotControl.Movement.Right(45);
        }
 public async Task Delete()
 {
     try
     {
         var dialog = new QuestionDialog("Do you really want to delete this Project (" + Name + ")?");
         dialog.ShowDialog();
         if (dialog.DialogResult.HasValue && dialog.DialogResult.Value)
         {
             using (var context = new NeoTrackerContext())
             {
                 var data = GetModel();
                 context.Entry(data).State = EntityState.Deleted;
                 App.vm.Projects.Remove(this);
                 await context.SaveChangesAsync();
             }
             EndEdit();
         }
     }
     catch (Exception e)
     {
         App.vm.UserMsg = e.Message.ToString();
     }
 }
 //INGRESA UN CONTRATO A UN EMPLEADO
 private void btnInsertNewContract_Click(object sender, MouseButtonEventArgs e)
 {
     try
     {
         String         rut_per  = this.tRut.Text.Trim();
         QuestionDialog pregunta = new QuestionDialog("Desea asignar el contrato al rut: " + rut_per + " ?", main);
         pregunta.ShowDialog();
         if (pregunta.DialogResult == true && validacionAddContract())
         {
             listCargo        = new Cargo().findAll(this.cTypeContract.SelectedIndex + 1);
             listTipoContrato = new TipoContrato().findAll();
             listJornada      = new tipo_jornada().findforCargo(this.cCargo.Text);
             Clases.Contratos contrato = new Contratos(rut_per, this.tDateInit.Text, this.tDateEnd.Text, this.tStat.Text.ToUpper(),
                                                       listTipoContrato[this.cTypeContract.SelectedIndex].id.ToString(), listCargo[this.cCargo.SelectedIndex].id.ToString(),
                                                       listJornada[this.cJornada.SelectedIndex].id_tipo_jornada.ToString());
             if (contrato.save() > 0)
             {
                 loadDataContract(rut_per);
                 new Dialog("Se ingreso contrato a empleado con rut " + rut_per + ".", main).ShowDialog(); //MessageBox.Show("Contrato ingresado exitosamente.");
                 this.tDateInit.IsEnabled     = false;
                 this.tDateEnd.IsEnabled      = false;
                 this.tStat.IsEnabled         = false;
                 this.cTypeContract.IsEnabled = false;
                 this.cCargo.IsEnabled        = false;
             }
             else
             {
                 new Dialog("Ocurrio un error al ingresar contrato a persona con rut " + rut_per + ".", main).Show();
             }
         }
     }
     catch (Exception ex)
     {
         Console.WriteLine("MainWindow.btnInsertNewContract_Click() " + ex.Message.ToString());
     }
 }
        /// <summary>
        /// Get a handler thumb
        /// </summary>
        /// <returns></returns>
        private Thumb GetMoveThumb()
        {
            Thumb thumb = new Thumb();

            thumb.Style = FindResource("MoveThumbStyle") as Style;
            // move operation
            thumb.DragDelta += (s, e) => {
                ModelItem elem = AdornedElement as ModelItem;
                if (elem == null)
                {
                    return;
                }
#if DEBUG_ON
                System.Console.WriteLine("{0},Drag Test: elem.Positon {1}, Change {2},{3}", System.DateTime.Now.Millisecond, elem.Position, e.HorizontalChange, e.VerticalChange);
#endif
                elem.Position += new Vector(e.HorizontalChange, e.VerticalChange);
            };
            // remove operation
            thumb.MouseDoubleClick += (s, e) => {
                ModelItem elem = AdornedElement as ModelItem;
                if (elem == null)
                {
                    return;
                }
                // confirm
                QuestionDialog dialog = new QuestionDialog("Are you sure to remove this model from current diagram?");
                dialog.ShowDialog();
                if (!dialog.Answer)
                {
                    return;
                }
                Diagram diagram = Project.Current.Children.FindByCanvas(elem.ContainerCanvas);
                diagram.Children.Remove(elem.ContentObject);
            };
            return(thumb);
        }
Exemple #18
0
        /// <summary>
        /// Open a new project
        /// </summary>
        private void OpenProject()
        {
            QuestionDialog dialog = new QuestionDialog("Are you sure to open another project?\nUnsaved progress could be LOST!!!");

            dialog.ShowDialog();
            CurrentStatus.Text   = "Opening a data file...";
            WinStatus.Background = Red;
            try {
                using (Stream s = FileManager.Open()) {
                    WinStatus.Background = Green;
                    CurrentStatus.Text   = "Project opened";
                    if (s == null)  // user cancel the operation
                    {
                        return;
                    }
                    ReloadProject(DataSerializer <Project> .Load(s));
                }
            }
            catch (Exception e) {
                CurrentStatus.Text = "Error!";
                ReloadProject(null);
                new ErrorHandler("Project cannot be opened!", e).Show();
            }
        }
Exemple #19
0
        static bool ShowWiFiMenu(Lcd lcd, Buttons btns)
        {
            List <IMenuItem> items = new List <IMenuItem> ();
            var ssidItem           = new MenuItemWithCharacterInput(lcd, btns, "SSID", "Enter SSID", settings.WiFiSettings.SSID);

            ssidItem.OnDialogExit += delegate(string text) {
                new Thread(delegate() {
                    settings.WiFiSettings.SSID = text;
                    settings.Save();
                }).Start();
            };
            var passwordItem = new MenuItemWithCharacterInput(lcd, btns, "Password", "Password", settings.WiFiSettings.Password, true);

            passwordItem.OnDialogExit += delegate(string text) {
                new Thread(delegate() {
                    settings.WiFiSettings.Password = text;
                    settings.Save();
                }).Start();
            };
            var encryptionItem = new MenuItemWithOptions <string>(lcd, "Encryption", new string[] { "None", "WPA/2" }, settings.WiFiSettings.Encryption ? 1 : 0);

            encryptionItem.OnOptionChanged += delegate(string newOpstion) {
                new Thread(delegate() {
                    if (newOpstion == "None")
                    {
                        settings.WiFiSettings.Encryption = false;
                    }
                    else
                    {
                        settings.WiFiSettings.Encryption = true;
                    }
                    settings.Save();
                }).Start();
            };
            var connectItem = new MenuItemWithCheckBox(lcd, "Connect", WiFiDevice.IsLinkUp(),
                                                       delegate(bool WiFiOn)
            {
                bool isOn      = WiFiOn;
                var infoDialog = new InfoDialog(font, lcd, btns, "Creating Configuration file", false);
                infoDialog.Show();
                WriteWpaSupplicantConfiguration(settings.WiFiSettings.SSID, settings.WiFiSettings.Password, settings.WiFiSettings.Encryption);
                if (WiFiOn)
                {
                    var dialog = new InfoDialog(font, lcd, btns, "Shutting down WiFi", false);
                    dialog.Show();
                    WiFiDevice.TurnOff();
                    dialog = new InfoDialog(font, lcd, btns, "WiFi Disabled!!", true);
                    dialog.Show();
                    isOn = false;
                }
                else
                {
                    var dialog = new InfoDialog(font, lcd, btns, "Connecting to WiFi Network Please Wait", false);
                    dialog.Show();
                    if (WiFiDevice.TurnOn(60000))
                    {
                        if (settings.WiFiSettings.ConnectAtStartUp == false)
                        {
                            var question = new QuestionDialog(font, lcd, btns, "Do you want to connect at start-up?", "Settings");
                            question.Show();
                            if (question.IsPositiveSelected)
                            {
                                new Thread(delegate() {
                                    settings.WiFiSettings.ConnectAtStartUp = true;
                                    settings.Save();
                                }).Start();
                            }
                        }
                        dialog = new InfoDialog(font, lcd, btns, "Connected Successfully " + WiFiDevice.GetIpAddress(), true);
                        dialog.Show();
                        isOn = true;
                    }
                    else
                    {
                        dialog = new InfoDialog(font, lcd, btns, "Failed to connect to WiFI Network", true);
                        dialog.Show();
                        isOn = false;
                    }
                }
                return(isOn);
            }
                                                       );

            items.Add(ssidItem);
            items.Add(passwordItem);
            items.Add(encryptionItem);
            items.Add(connectItem);
            //Show the menu
            Menu m = new Menu(font, lcd, btns, "WiFi Connection", items);

            m.Show();
            return(false);
        }
Exemple #20
0
        public void Activate()
        {
            Task taskDeleteOldCollection             = null;
            Task taskGatherExistentSpecies           = null;
            Dictionary <string, int> existentSpecies = new Dictionary <string, int>();

            ImageCollection arkiveCollection = TaxonImages.Manager.GetByName("Arkive");

            if (arkiveCollection != null)
            {
                QuestionDialog dlg = new QuestionDialog
                                     (
                    "Arkive collection already exists !\nWhat do you want to do ?",
                    "Confirm ... ",
                    new TaxonDialog.AnswersDesc().
                    Add("Delete", "delete all content of old arkive collection", 0).
                    Add("Merge", "import only image for species newly found", 1).
                    Add("Cancel", "stop the generation of collection", 2)
                                     );
                dlg.ShowDialog();
                OneAnswerDesc answer = dlg.Answer;

                if (answer == null || answer.ID == 2)
                {
                    return;
                }

                /*string message = "Arkive collection exist, remove it ?";
                 * DialogResult result = MessageBox.Show(message, "Confirm ...", MessageBoxButtons.OKCancel, MessageBoxIcon.Question);
                 * if (result == DialogResult.Cancel)
                 *  return;*/

                if (answer.ID == 0)
                {
                    taskDeleteOldCollection = Task.Factory.StartNew(() => Directory.Delete(arkiveCollection.Path, true));
                }
                else
                {
                    taskGatherExistentSpecies = Task.Factory.StartNew(() =>
                    {
                        foreach (string file in Directory.EnumerateFiles(arkiveCollection.Path))
                        {
                            string species = Path.GetFileNameWithoutExtension(file).Split('_')[0];
                            if (!existentSpecies.ContainsKey(species))
                            {
                                existentSpecies[species] = 0;
                            }
                            existentSpecies[species] = existentSpecies[species] + 1;
                        }
                    });
                }
            }

            string folderArkive;

            using (var fbd = new FolderBrowserDialog())
            {
                fbd.Description  = "Select Folder where Arkive images are stored";
                fbd.SelectedPath = TaxonUtils.GetTaxonPath();
                DialogResult result = fbd.ShowDialog();
                if (result != DialogResult.OK || string.IsNullOrWhiteSpace(fbd.SelectedPath))
                {
                    return;
                }
                folderArkive = fbd.SelectedPath;
            }

            int lengthFolderArkive = folderArkive.Length;

            using (ProgressDialog progressDlg = new ProgressDialog())
            {
                progressDlg.StartPosition = FormStartPosition.CenterScreen;
                progressDlg.Show();

                ProgressItem piInitSearch = progressDlg.Add("Initialize searching", "", 0, 2);
                TaxonSearch  searching    = new TaxonSearch(TaxonUtils.OriginalRoot, true, true);
                piInitSearch.Update(1);
                string[] foldersLevel1 = Directory.GetDirectories(folderArkive);
                piInitSearch.Update(2);
                piInitSearch.End();

                Dictionary <string, string>        unknownFolder = new Dictionary <string, string>();
                Dictionary <string, TaxonTreeNode> knownFolder   = new Dictionary <string, TaxonTreeNode>();
                int missedPhotos          = 0;
                int importedPhotos        = 0;
                int alreadyImportedPhotos = 0;
                int newlyImportedPhotos   = 0;

                ProgressItem piParse = progressDlg.Add("Parse arkive folders", "", 0, foldersLevel1.Length);
                for (uint i = 0; i < foldersLevel1.Length; i++)
                {
                    piParse.Update(i, foldersLevel1[i].Substring(lengthFolderArkive + 1));
                    int folder1Length = foldersLevel1[i].Length + 1;

                    string[] foldersLevel2 = Directory.GetDirectories(foldersLevel1[i]);
                    foreach (string folder2 in foldersLevel2)
                    {
                        //if (folder2.ToLower().Contains("acropora"))
                        //    Console.WriteLine(folder2);

                        string[] photos = Directory.GetFiles(folder2, "*.jpg");
                        if (photos.Length == 0)
                        {
                            continue;
                        }

                        string        name = folder2.Substring(folder1Length).Replace('-', ' ').ToLower().Trim();
                        TaxonTreeNode node = searching.FindOne(name);
                        if (node == null)
                        {
                            unknownFolder[folder2] = name;
                            missedPhotos          += photos.Length;
                        }
                        else
                        {
                            knownFolder[folder2] = node;
                        }
                    }
                }
                piParse.Update(piParse.Max, knownFolder.Count.ToString() + " found, " + unknownFolder.Count.ToString() + " not.");

                if (taskDeleteOldCollection != null && !taskDeleteOldCollection.IsCompleted)
                {
                    ProgressItem piClean = progressDlg.Add("Clean old collection", "", 0, 1);
                    taskDeleteOldCollection.Wait();
                    piClean.Update(1);
                    piClean.End();
                }

                if (taskGatherExistentSpecies != null && !taskGatherExistentSpecies.IsCompleted)
                {
                    ProgressItem piAnalyseOld = progressDlg.Add("Analyse old collection", "", 0, 1);
                    taskGatherExistentSpecies.Wait();
                    piAnalyseOld.Update(1);
                    piAnalyseOld.End();
                }

                arkiveCollection = TaxonImages.Manager.GetOrCreateCollection("Arkive");
                if (arkiveCollection == null)
                {
                    return;
                }
                arkiveCollection.Desc  = "Collection generated from images taken from Arkive site : http://www.arkive.org";
                arkiveCollection.Desc += "Generated date : " + DateTime.Now.ToString();
                arkiveCollection.SaveInfos();
                ProgressItem piPopulate = progressDlg.Add("Populate collection", "", 0, knownFolder.Count);
                foreach (KeyValuePair <string, TaxonTreeNode> pair in knownFolder)
                {
                    string speciesName = pair.Value.Desc.RefMultiName.Main;
                    piPopulate.Update(piPopulate.Current + 1, speciesName);

                    string[] photos = Directory.GetFiles(pair.Key, "*.jpg");
                    importedPhotos += photos.Length;

                    if (existentSpecies.ContainsKey(speciesName))
                    {
                        if (existentSpecies[speciesName] == photos.Length)
                        {
                            alreadyImportedPhotos += photos.Length;
                            continue;
                        }
                        File.Delete(arkiveCollection.Path + Path.DirectorySeparatorChar + speciesName + "*.*");
                    }

                    newlyImportedPhotos += photos.Length;

                    for (int index = 0; index < photos.Length; index++)
                    {
                        string newName = speciesName + "_" + index.ToString() + ".jpg";
                        File.Copy(photos[index], arkiveCollection.Path + Path.DirectorySeparatorChar + newName);
                    }
                }
                piPopulate.Update(piPopulate.Max, importedPhotos.ToString() + " photos imported.");

                string message0 = (unknownFolder.Count + knownFolder.Count).ToString() + " total folders found\n";
                string message1 = knownFolder.Count.ToString() + " with associated taxons ( " + importedPhotos.ToString() + " photos imported )";
                if (newlyImportedPhotos != importedPhotos)
                {
                    message1 += " ( merging : " + newlyImportedPhotos + " new photos";
                }
                string message2 = unknownFolder.Count.ToString() + " names not found ( " + missedPhotos.ToString() + " photos left behind )";
                string message  = message0 + "\n" + message1 + "\n" + message2 + "\n\n" + "for more details, look at GenerateArkiveCollection.log file";
                if (unknownFolder.Count > 0)
                {
                    message += "\nA list of taxons is generated with all name not found : " + Path.Combine(TaxonList.GetFolder(), "ArkiveNames.txt");
                }
                Loggers.WriteInformation(LogTags.Data, message);

                try
                {
                    List <KeyValuePair <string, string> > unknowns = unknownFolder.ToList();
                    unknowns.Sort((x, y) => x.Value.CompareTo(y.Value));

                    string file = Path.Combine(TaxonUtils.GetLogPath(), "GenerateArkiveCollection.log");
                    if (File.Exists(file))
                    {
                        File.Delete(file);
                    }
                    using (StreamWriter outfile = new StreamWriter(file))
                    {
                        outfile.WriteLine("GenerateArkiveCollection results:");
                        outfile.WriteLine();
                        outfile.WriteLine("  " + message0);
                        outfile.WriteLine("  " + message1);
                        outfile.WriteLine("  " + message2);
                        outfile.WriteLine();
                        if (unknowns.Count > 0)
                        {
                            outfile.WriteLine("List of not found names:");
                            outfile.WriteLine();

                            int maxLength = 0;
                            foreach (KeyValuePair <string, string> pair in unknowns)
                            {
                                maxLength = Math.Max(maxLength, pair.Value.Length);
                            }
                            foreach (KeyValuePair <string, string> pair in unknowns)
                            {
                                outfile.WriteLine("  " + pair.Value.PadRight(maxLength) + " => " + pair.Key);
                            }
                            outfile.WriteLine();
                        }
                    }

                    if (unknowns.Count > 0)
                    {
                        file = Path.Combine(TaxonList.GetFolder(), "ArkiveNames.txt");
                        if (File.Exists(file))
                        {
                            File.Delete(file);
                        }
                        using (StreamWriter outfile = new StreamWriter(file))
                        {
                            foreach (KeyValuePair <string, string> pair in unknowns)
                            {
                                outfile.WriteLine(pair.Value);
                            }
                        }
                    }
                }
                catch (Exception e)
                {
                    string error = "Exception while saving results in GenerateArkiveCollection.log: \n\n";
                    error += e.Message;
                    if (e.InnerException != null)
                    {
                        error += "\n" + e.InnerException.Message;
                    }
                    Loggers.WriteError(LogTags.Data, error);
                }
            }
        }
Exemple #21
0
 public void OnExit(QuestionDialog dialog)
 {
     Console.WriteLine("Do you like MonoBrick is set to " + dialog.IsPositiveSelected);
 }
 private void btnDeleteUser_MouseDown(object sender, MouseButtonEventArgs e)
 {
     try
     {
         if (this.lListLogin.Items.Count > 0)//si ahi al menos un privilegio en la lista 2
         {
             String userName = this.lListLogin.Items[this.lListLogin.SelectedIndex].ToString();
             Console.WriteLine(userName);
             if (userName != null)//si no selecciono ningun privilegio a eliminar
             {
                 QuestionDialog pregunta = new QuestionDialog("Realmente desea eliminar el Usuario " + userName, main);
                 pregunta.ShowDialog();
                 if (pregunta.DialogResult == true)
                 {
                     Login l = new Login(new Login(userName).getIdByName().id);
                     if (l.deleteById() > 0)
                     {
                         this.Clear();
                         this.llenaListLogin();
                     }
                 }
             }
             else new Dialog("Seleccione un Usuario a eliminar.", main).ShowDialog();
         }
         else new Dialog("No hay ningun usuario en la lista.", main).ShowDialog();
     }
     catch (ArgumentOutOfRangeException ex)
     {
         this.llenaListLogin();
         Console.WriteLine(ex.Message);
     }
 }
 private void btnDeletePrivilegio_Click(object sender, MouseButtonEventArgs e)
 {
     try {
         if (this.comboGrupos.SelectedItem != null)//si selecciono algun grupo de usuario
         {
             if (this.List2.Items.Count > 0)//si ahi al menos un privilegio en la lista 2
             {
                 String NamePrivilegio = ((ListBoxItem)this.List2.Items[this.List2.SelectedIndex]).Content.ToString();
                 if (NamePrivilegio != null)//si no selecciono ningun privilegio a eliminar
                 {
                     QuestionDialog pregunta = new QuestionDialog("Realmente desea eliminar este privilegio de " + this.comboGrupos.SelectedItem, main);
                     pregunta.ShowDialog();
                     if (pregunta.DialogResult == true)
                     {
                         Privilegio p = new Privilegio(new Privilegio(NamePrivilegio).getIdByName());
                         if (new User_Group_Privilegios(p).deleteByIdPrivilegio() > 0)
                         {
                             Thread.Sleep(100);
                             LoadPrivilegio_UserGroup();
                             llenaTreeView();
                         }
                         Thread.Sleep(100);
                         LoadAllPrivilegios();
                         LoadPrivilegio_UserGroup();
                     }
                 }
                 else new Dialog("Seleccione un privilegio a eliminar.", main).ShowDialog();
             }
             else new Dialog("No hay ningun privilegio asignado previamente.", main).ShowDialog();
         }
         else new Dialog("Seleccione un Grupo de usuario", main).ShowDialog();
     }
     catch (ArgumentOutOfRangeException ex) {
         new Dialog("Seleccione un privilegio a elimnar", main).ShowDialog();
     }
 }
 //boton para agregar privilegio a userGroup
 private void btnAddPrivilegio_Click(object sender, MouseButtonEventArgs e)
 {
     if (this.comboGrupos.SelectedItem!=null)//si selecciono algun grupo de usuario
     {
         if (this.List2.Items.Count>0)//si ahi al menos un privilegio en la lista 2
         {
             QuestionDialog pregunta = new QuestionDialog("Realmente desea Agregar estos privilegios a " + this.comboGrupos.SelectedItem, main);
             pregunta.ShowDialog();
             if (pregunta.DialogResult == true)
             {
                 foreach (ListBoxItem privilegio in this.List2.Items)
                 {
                     Privilegio p = new Privilegio(new Privilegio(privilegio.Content.ToString()).getIdByName());
                     User_Group ug = new User_Group(this.comboGrupos.SelectedIndex + 1);
                     if (new User_Group_Privilegios(ug, p).ifExistPrivilegio() < 1)//si no existe el privilegio
                     {
                         new User_Group_Privilegios(ug, p).save();
                     }
                     Thread.Sleep(100);
                 }
                 LoadAllPrivilegios();
                 LoadPrivilegio_UserGroup();
                 llenaTreeView();
             }
         }
         else new Dialog("Agrege a lo menos un privilegio ", main).ShowDialog();
     }
     else new Dialog("Seleccione un Grupo de usuario", main).ShowDialog();
 }
        public override IEnumerator <YieldInstruction> EndGame(ResultType result, ZoneLoc nextArea, bool display, bool fanfare)
        {
            bool recorded = DataManager.Instance.RecordingReplay;

            //if lose, end the play, display plaque, and go to title
            if (result != ResultType.Cleared)
            {
                if (GameManager.Instance.CurrentScene == GroundScene.Instance)
                {
                    Location = ZoneManager.Instance.CurrentGround.GetSingleLineName();
                }
                else if (GameManager.Instance.CurrentScene == DungeonScene.Instance)
                {
                    Location = ZoneManager.Instance.CurrentMap.GetSingleLineName();
                }

                Outcome = result;

                DataManager.Instance.MsgLog.Clear();
                //end the game with a recorded ending
                string recordFile = DataManager.Instance.EndPlay(this, null);

                MenuBase.Transparent = false;
                //save to the main file
                GameState  state       = DataManager.Instance.LoadMainGameState();
                List <int> newRecruits = new List <int>();
                if (state != null)
                {
                    newRecruits = MergeDexTo(state.Save);
                    DataManager.Instance.SaveGameState(state);
                }


                if (recorded && display)
                {
                    GameProgress ending = DataManager.Instance.GetRecord(Data.DataManager.REPLAY_PATH + recordFile);

                    if (fanfare)
                    {
                        if (result != ResultType.Cleared)
                        {
                            GameManager.Instance.Fanfare("Fanfare/MissionFail");
                        }
                        else
                        {
                            GameManager.Instance.Fanfare("Fanfare/MissionClear");
                        }
                    }
                    else
                    {
                        GameManager.Instance.SE("Menu/Skip");
                    }

                    FinalResultsMenu menu = new FinalResultsMenu(ending);
                    yield return(CoroutineManager.Instance.StartCoroutine(MenuManager.Instance.ProcessMenuCoroutine(menu)));

                    Dictionary <int, List <RecordHeaderData> > scores = RecordHeaderData.LoadHighScores();
                    yield return(CoroutineManager.Instance.StartCoroutine(MenuManager.Instance.ProcessMenuCoroutine(new ScoreMenu(scores, ZoneManager.Instance.CurrentZoneID, DataManager.REPLAY_PATH + recordFile))));
                }

                if (newRecruits.Count > 0)
                {
                    yield return(new WaitForFrames(10));

                    GameManager.Instance.Fanfare("Fanfare/NewArea");
                    yield return(CoroutineManager.Instance.StartCoroutine(MenuManager.Instance.SetDialogue(Text.FormatKey("DLG_NEW_CHARS"))));
                }

                yield return(new WaitForFrames(20));

                GameManager.Instance.SceneOutcome = GameManager.Instance.RestartToTitle();
            }
            else
            {
                int completedZone = ZoneManager.Instance.CurrentZoneID;

                MidAdventure = true;
                ClearDungeonItems();

                //  if there isn't a next area, end the play, display the plaque, return to title screen
                //GameManager.Instance.Fanfare("Fanfare/MissionClear");
                Location = ZoneManager.Instance.CurrentZone.Name.ToLocal();

                Outcome = result;

                DataManager.Instance.MsgLog.Clear();
                //end the game with a recorded ending
                string recordFile = DataManager.Instance.EndPlay(this, null);

                MenuBase.Transparent = false;

                //save to the main file
                GameState state = DataManager.Instance.LoadMainGameState();
                if (state != null)
                {
                    MergeDexTo(state.Save);
                    state.Save.DungeonUnlocks[completedZone] = UnlockState.Completed;
                    DataManager.Instance.SaveGameState(state);
                }



                if (recorded)
                {
                    GameProgress ending = DataManager.Instance.GetRecord(DataManager.REPLAY_PATH + recordFile);

                    if (fanfare)
                    {
                        if (result != ResultType.Cleared)
                        {
                            GameManager.Instance.Fanfare("Fanfare/MissionFail");
                        }
                        else
                        {
                            GameManager.Instance.Fanfare("Fanfare/MissionClear");
                        }
                    }
                    else
                    {
                        GameManager.Instance.SE("Menu/Skip");
                    }

                    FinalResultsMenu menu = new FinalResultsMenu(ending);
                    yield return(CoroutineManager.Instance.StartCoroutine(MenuManager.Instance.ProcessMenuCoroutine(menu)));

                    Dictionary <int, List <RecordHeaderData> > scores = RecordHeaderData.LoadHighScores();
                    yield return(CoroutineManager.Instance.StartCoroutine(MenuManager.Instance.ProcessMenuCoroutine(new ScoreMenu(scores, ZoneManager.Instance.CurrentZoneID, DataManager.REPLAY_PATH + recordFile))));
                }

                //ask to transfer if the dungeon records progress, and it is NOT a seeded run.
                if (state != null && Stakes != DungeonStakes.None && !Seeded)
                {
                    bool           allowTransfer = false;
                    QuestionDialog question      = MenuManager.Instance.CreateQuestion(Text.FormatKey("DLG_TRANSFER_ASK"),
                                                                                       () => { allowTransfer = true; }, () => { });
                    yield return(CoroutineManager.Instance.StartCoroutine(MenuManager.Instance.ProcessMenuCoroutine(question)));

                    if (allowTransfer)
                    {
                        MainProgress mainSave = state.Save as MainProgress;
                        //put the new recruits into assembly
                        foreach (Character character in ActiveTeam.Players)
                        {
                            if (!(character.Dead && DataManager.Instance.GetSkin(character.BaseForm.Skin).Challenge))
                            {
                                mainSave.CharsToStore.Add(new CharData(character));
                            }
                        }
                        foreach (Character character in ActiveTeam.Assembly)
                        {
                            if (!(character.Dead && DataManager.Instance.GetSkin(character.BaseForm.Skin).Challenge))
                            {
                                mainSave.CharsToStore.Add(new CharData(character));
                            }
                        }

                        //put the new items into the storage
                        foreach (InvItem item in ActiveTeam.EnumerateInv())
                        {
                            mainSave.ItemsToStore.Add(item);
                        }
                        foreach (InvItem item in ActiveTeam.BoxStorage)
                        {
                            mainSave.ItemsToStore.Add(item);
                        }

                        mainSave.StorageToStore = ActiveTeam.Storage;

                        mainSave.MoneyToStore = state.Save.ActiveTeam.Money + state.Save.ActiveTeam.Bank;
                    }

                    DataManager.Instance.SaveGameState(state);

                    if (allowTransfer)
                    {
                        yield return(CoroutineManager.Instance.StartCoroutine(MenuManager.Instance.SetDialogue(Text.FormatKey("DLG_TRANSFER_COMPLETE"))));
                    }
                }



                yield return(new WaitForFrames(20));
            }
        }
Exemple #26
0
        static bool ShowProgramOptions(ProgramInformation program)
        {
            var dialog = new SelectDialog <string> (new string[] {
                "Run Program",
                "Run In AOT",
                "AOT Compile",
                "Delete Program",
            }, "Options", true);

            dialog.Show();
            if (!dialog.EscPressed)
            {
                Action programAction = null;
                switch (dialog.GetSelectionIndex())
                {
                case 0:
                    Lcd.Instance.Clear();
                    Lcd.Instance.DrawBitmap(monoLogo, new Point((int)(Lcd.Width - monoLogo.Width) / 2, 5));
                    Rectangle textRect = new Rectangle(new Point(0, Lcd.Height - (int)Font.SmallFont.maxHeight - 2), new Point(Lcd.Width, Lcd.Height - 2));
                    Lcd.Instance.WriteTextBox(Font.SmallFont, textRect, "Running...", true, Lcd.Alignment.Center);
                    Lcd.Instance.Update();
                    programAction = () => ProgramManager.Instance.StartProgram(program, false);
                    break;

                case 1:
                    if (!program.IsAOTCompiled)
                    {
                        if (AOTCompileAndShowDialog(program))
                        {
                            programAction = () => ProgramManager.Instance.StartProgram(program, true);
                        }
                    }
                    else
                    {
                        programAction = () => ProgramManager.Instance.StartProgram(program, true);
                    }
                    break;

                case 3:

                    if (program.IsAOTCompiled)
                    {
                        var questionDialog = new QuestionDialog("Progran already compiled. Recompile?", "AOT recompile");
                        if (questionDialog.Show())
                        {
                            AOTCompileAndShowDialog(program);
                        }
                    }
                    else
                    {
                        AOTCompileAndShowDialog(program);
                    }
                    break;

                case 4:
                    var question = new QuestionDialog("Are you sure?", "Delete");
                    if (question.Show())
                    {
                        var step           = new StepContainer(() => { ProgramManager.Instance.DeleteProgram(program); return(true); }, "Deleting ", "Error deleting program");
                        var progressDialog = new ProgressDialog("Program", step);
                        progressDialog.Show();
                        updateProgramList = true;
                    }
                    break;
                }
                if (programAction != null)
                {
                    Console.WriteLine("Starting application");
                    programAction();
                    Console.WriteLine("Done running application");
                }
                return(updateProgramList);
            }
            return(false);
        }
        //INGRESA UN CONTRATO A UN EMPLEADO
        private void btnInsertNewContract_Click(object sender, MouseButtonEventArgs e)
        {
            try
            {
                String rut_per = this.tRut.Text.Trim();
                QuestionDialog pregunta = new QuestionDialog("Desea asignar el contrato al rut: " + rut_per + " ?", main);
                pregunta.ShowDialog();
                if (pregunta.DialogResult == true && validacionAddContract())
                {
                    listCargo = new Cargo().findAll(this.cTypeContract.SelectedIndex + 1);
                    listTipoContrato = new TipoContrato().findAll();
                    listJornada = new tipo_jornada().findforCargo(this.cCargo.Text);
                    Clases.Contratos contrato = new Contratos(rut_per, this.tDateInit.Text, this.tDateEnd.Text, this.tStat.Text.ToUpper(),
                                                    listTipoContrato[this.cTypeContract.SelectedIndex].id.ToString(), listCargo[this.cCargo.SelectedIndex].id.ToString(),
                                                    listJornada[this.cJornada.SelectedIndex].id_tipo_jornada.ToString());
                    if (contrato.save() > 0)
                    {
                        loadDataContract(rut_per);
                        new Dialog("Se ingreso contrato a empleado con rut " + rut_per + ".", main).ShowDialog(); //MessageBox.Show("Contrato ingresado exitosamente.");
                        this.tDateInit.IsEnabled = false;
                        this.tDateEnd.IsEnabled = false;
                        this.tStat.IsEnabled = false;
                        this.cTypeContract.IsEnabled = false;
                        this.cCargo.IsEnabled = false;

                    }
                    else new Dialog("Ocurrio un error al ingresar contrato a persona con rut " + rut_per + ".", main).Show();
                }
            }
            catch (Exception ex)
            {
                Console.WriteLine("MainWindow.btnInsertNewContract_Click() " + ex.Message.ToString());
            }
        }
 //ELIMINA UN CONTRATO ASOCIADO A UN EMPLEADO
 private void btnEndContract_Click(object sender, MouseButtonEventArgs e)
 {
     string rut_per = this.tRut.Text.Trim();
     QuestionDialog pregunta = new QuestionDialog("Desea borrar el contrato asociado al rut: " + rut_per + " ?", main);
     pregunta.ShowDialog();
     if (pregunta.DialogResult == true)
     {
         if (new Clases.Contratos().DeleteByRut(new Personal(rut_per)) > 0)
         {
             this.limpiarTexbox();
             this.loadDataContract(rut_per);
             this.cargarDatosPersonal(rut_per, "rut");
             new Dialog("Se cancelo el contrato a empleado con rut " + rut_per + ".", main).ShowDialog(); //MessageBox.Show("Se elimino el contrato con exito");
         }
     }
 }
 //ELIMINA UN EMPLEADO
 public void btnDeleteReg_Click(object sender, MouseButtonEventArgs e)
 {
     try
     {
         this.tabControl1.SelectedIndex = 0;
         String rut_per = this.tRut.Text.Trim();
         QuestionDialog pregunta = new QuestionDialog("Desea borrar el personal con rut: " + rut_per + " ?", main);
         pregunta.ShowDialog();
         if (pregunta.DialogResult == true)
         {
             if (new Clases.Personal(rut_per).DeleteByRrut() > 0)
             {
                 this.limpiarTexbox();
                 main.cBusqueda.Text = "";
                 main.cBusqueda.Focus();
                 main.WorkSpace.IsEnabled = false;
                 new Dialog("El empleado con rut " + rut_per + " fue eliminado satisfactoriamente.", main).ShowDialog();
             }
             else new Dialog("Ocurrio algo inesperado al eliminar al empleado con rut " + rut_per + ".", main).ShowDialog();
         }
     }
     catch (Exception ex)
     {
         MessageBox.Show("Error en eliminar personal" + ex.Message);
     }
 }
Exemple #30
0
        public IEnumerator <YieldInstruction> travelMenuFlow(LuaTable dungeons, LuaTable grounds)
        {
            ZoneLoc chosenDest = ZoneLoc.Invalid;

            List <int> availableDungeons         = new List <int>();
            List <Tuple <int, int[]> > goodsList = new List <Tuple <int, int[]> >();

            foreach (object key in dungeons.Keys)
            {
                int entry = (int)(Int64)dungeons[key];
                availableDungeons.Add(entry);
            }

            List <ZoneLoc> availableGrounds = new List <ZoneLoc>();

            foreach (object key in grounds.Keys)
            {
                LuaTable entry      = grounds[key] as LuaTable;
                int      zone       = (int)(Int64)entry["Zone"];
                int      id         = (int)(Int64)entry["ID"];
                int      entryPoint = (int)(Int64)entry["Entry"];
                availableGrounds.Add(new ZoneLoc(zone, new SegLoc(-1, id), entryPoint));
            }

            if (availableDungeons.Count + availableGrounds.Count == 1)
            {
                if (availableDungeons.Count == 1)
                {
                    //ask directly if the player wants to enter the one dungeon possible
                    yield return(CoroutineManager.Instance.StartCoroutine(askDungeonQuestion(availableDungeons[0], () => { chosenDest = new ZoneLoc(availableDungeons[0], new SegLoc(0, 0)); }, () => { })));
                }
                if (availableGrounds.Count == 1)
                {
                    ZoneData       zone     = DataManager.Instance.GetZone(availableGrounds[0].ID);
                    QuestionDialog question = MenuManager.Instance.CreateQuestion(Text.FormatKey("DLG_ASK_ENTER_GROUND", DataManager.Instance.GetGround(zone.GroundMaps[availableGrounds[0].StructID.ID]).GetSingleLineName()),
                                                                                  () => { chosenDest = availableGrounds[0]; }, () => { });
                    yield return(CoroutineManager.Instance.StartCoroutine(MenuManager.Instance.ProcessMenuCoroutine(question)));
                }
            }
            else if (availableDungeons.Count + availableGrounds.Count > 1)
            {
                //give the player the choice between all the possible dungeons
                yield return(CoroutineManager.Instance.StartCoroutine(MenuManager.Instance.ProcessMenuCoroutine(new DungeonsMenu(availableDungeons, availableGrounds,
                                                                                                                                 (int choice) => { chosenDest = new ZoneLoc(availableDungeons[choice], new SegLoc(0, 0)); },
                                                                                                                                 (int choice) => { chosenDest = new ZoneLoc(availableGrounds[choice].ID, new SegLoc(-1, availableGrounds[choice].StructID.ID), availableGrounds[choice].EntryPoint); }))));
            }

            if (chosenDest.IsValid())
            {
                GameManager.Instance.BGM("", true);
                yield return(CoroutineManager.Instance.StartCoroutine(GameManager.Instance.FadeOut(false)));

                if (chosenDest.StructID.Segment > -1)
                {
                    yield return(CoroutineManager.Instance.StartCoroutine(GameManager.Instance.BeginGameInSegment(chosenDest, GameProgress.DungeonStakes.Risk, true, false)));
                }
                else
                {
                    GameManager.Instance.SceneOutcome = GameManager.Instance.MoveToZone(chosenDest);
                }
            }
        }
 private void btnUpdate_Click(object sender, MouseButtonEventArgs e)
 {
     QuestionDialog pregunta = new QuestionDialog("Realmente desea modificar los datos?", main);
     pregunta.ShowDialog();
     if (pregunta.DialogResult == true)
     {
         if (new Privilegio(int.Parse(this.tId.Text), this.tName.Text).update() > 0)
         {
             this.data.ItemsSource = new Privilegio().findAll();
         }
     }
 }
 private void btnDelete_Click(object sender, MouseButtonEventArgs e)
 {
     QuestionDialog pregunta = new QuestionDialog("Realmente desea eliminar este dato?", main);
     pregunta.ShowDialog();
     if (pregunta.DialogResult == true)
     {
         if (new Departamento(int.Parse(this.tId.Text)).Delete() > 0)
         {
             this.data.ItemsSource = new Departamento().findAll_administrativo();
             limpaCampos();
         }
     }
 }
        private void btnUpdate_Click(object sender, MouseButtonEventArgs e)
        {
            QuestionDialog pregunta = new QuestionDialog("Realmente desea modificar los datos?", main);
            pregunta.ShowDialog();
            if (pregunta.DialogResult == true)
            {
                Personal per = new Personal(this.tRut.Text);
                if (new Departamento(int.Parse(this.tId.Text), this.tName.Text, per.get_idPersonal().ToString()).update() > 0)
                {
                    this.data.ItemsSource = new Departamento().findAll_administrativo();

                }
            }
        }
Exemple #34
0
        static bool ShowWiFiMenu()
        {
            List <IMenuItem> items = new List <IMenuItem> ();
            var ssidItem           = new MenuItemWithCharacterInput("SSID", "Enter SSID", settings.WiFiSettings.SSID);

            ssidItem.OnDialogExit += delegate(string text) {
                new Thread(delegate() {
                    settings.WiFiSettings.SSID = text;
                    settings.Save();
                }).Start();
            };
            var passwordItem = new MenuItemWithCharacterInput("Password", "Password", settings.WiFiSettings.Password, true);

            passwordItem.OnDialogExit += delegate(string text) {
                new Thread(delegate() {
                    settings.WiFiSettings.Password = text;
                    settings.Save();
                }).Start();
            };
            var encryptionItem = new MenuItemWithOptions <string>("Encryption", new string[] { "None", "WPA/2" }, settings.WiFiSettings.Encryption ? 1 : 0);

            encryptionItem.OnOptionChanged += delegate(string newOpstion) {
                new Thread(delegate() {
                    if (newOpstion == "None")
                    {
                        settings.WiFiSettings.Encryption = false;
                    }
                    else
                    {
                        settings.WiFiSettings.Encryption = true;
                    }
                    settings.Save();
                }).Start();
            };
            var connectItem = new MenuItemWithCheckBox("Connect", WiFiDevice.IsLinkUp(),
                                                       delegate(bool WiFiOn)
            {
                bool isOn          = WiFiOn;
                var createFileStep = new StepContainer
                                     (
                    delegate()
                {
                    WriteWpaSupplicantConfiguration(settings.WiFiSettings.SSID, settings.WiFiSettings.Password, settings.WiFiSettings.Encryption);
                    return(true);
                },
                    "Creating file", "Error creating WPA file"
                                     );
                var progressDialog = new ProgressDialog("WiFi", createFileStep);
                progressDialog.Show();
                if (WiFiOn)
                {
                    var turnOffStep = new StepContainer(
                        delegate()
                    {
                        WiFiDevice.TurnOff();
                        return(true);
                    },
                        "Turning Off", "Error turning off WiFi", "WiFi Disabled");
                    var dialog = new ProgressDialog("WiFi", turnOffStep);
                    dialog.Show();
                    isOn = false;
                }
                else
                {
                    var turnOnStep = new StepContainer(
                        delegate()
                    {
                        return(WiFiDevice.TurnOn(60000));
                    },
                        "Connecting", "Failed to connect");
                    Dialog dialog = new ProgressDialog("WiFi", turnOnStep);
                    if (dialog.Show())
                    {
                        if (settings.WiFiSettings.ConnectAtStartUp == false)
                        {
                            var question = new QuestionDialog("Do you want to connect at start-up?", "Settings");
                            if (question.Show())
                            {
                                new Thread(delegate() {
                                    settings.WiFiSettings.ConnectAtStartUp = true;
                                    settings.Save();
                                }).Start();
                            }
                        }
                        dialog = new InfoDialog("Connected Successfully " + WiFiDevice.GetIpAddress(), true, "WiFi");
                        dialog.Show();
                        isOn = true;
                    }
                    else
                    {
                        isOn = false;
                    }
                }
                return(isOn);
            }
                                                       );

            items.Add(ssidItem);
            items.Add(passwordItem);
            items.Add(encryptionItem);
            items.Add(connectItem);
            //Show the menu
            Menu m = new Menu("WiFi Connection", items);

            m.Show();
            return(false);
        }
Exemple #35
0
 static bool ShowUpdatesDialogs()
 {
     if (WiFiDevice.IsLinkUp())
     {
         bool        newImage       = false;
         bool        newFirmwareApp = false;
         bool        newAddin       = false;
         VersionInfo versionInfo    = null;
         var         step           = new StepContainer(
             delegate() {
             try {
                 versionInfo         = VersionHelper.AvailableVersions();
                 newImage            = versionInfo.Image != VersionHelper.CurrentImageVersion();
                 newFirmwareApp      = versionInfo.Fimrware != firmwareVersion;
                 string addInVersion = VersionHelper.CurrentAddInVersion();
                 if (addInVersion != null)
                 {
                     newAddin = versionInfo.AddIn != VersionHelper.CurrentAddInVersion();
                 }
             } catch {
                 return(false);
             }
             return(true);
         },
             "Checking server", "Failed to check for Updates");
         var dialog = new ProgressDialog("Updates", step);
         dialog.Show();
         if (newImage)
         {
             var visitWebsiteDialog = new InfoDialog("New image available. Download it at monobrick.dk", true);
             visitWebsiteDialog.Show();
         }
         else
         {
             if (newFirmwareApp)
             {
                 var updateQuestion = new QuestionDialog("New firmware available. Update?", "New Fiwmware");
                 if (updateQuestion.Show())
                 {
                     var          updateHelper = new UpdateHelper(versionInfo.Fimrware);
                     List <IStep> steps        = new List <IStep> ();
                     steps.Add(new StepContainer(updateHelper.DownloadFirmware, "Downloading...", "Failed to download files"));
                     steps.Add(new StepContainer(updateHelper.UpdateBootFile, "Updating system", "Failed to update boot file"));
                     var updateDialog = new StepDialog("Updating", steps);
                     if (updateDialog.Show())
                     {
                         for (int seconds = 10; seconds > 0; seconds--)
                         {
                             var rebootDialog = new InfoDialog("Update completed. Rebooting in  " + seconds, false);
                             rebootDialog.Show();
                             System.Threading.Thread.Sleep(1000);
                         }
                         ProcessHelper.RunAndWaitForProcess("/sbin/shutdown", "-h now");
                         Thread.Sleep(120000);
                         var whyAreYouHereDialog = new InfoDialog("Cut the power", false, "Reboot failed");
                         whyAreYouHereDialog.Show();
                         new ManualResetEvent(false).WaitOne();
                     }
                 }
             }
             else
             {
                 if (newAddin)
                 {
                     var visitWebsiteDialog = new InfoDialog("New Xamarin Add-in. Download it at monobrick.dk", true);
                     visitWebsiteDialog.Show();
                 }
                 else
                 {
                     var noUpdateDialog = new InfoDialog("No updates available", true);
                     noUpdateDialog.Show();
                 }
             }
         }
     }
     else
     {
         var dialog = new InfoDialog("WiFi device is not pressent", true);
         dialog.Show();
     }
     return(false);
 }
        private string getAnswerHint(QuestionDialog dialog)
        {
            var answerTurn = dialog.AnswerTurns.Last();

            return(answerTurn.InputChat);
        }
Exemple #37
0
        static bool ShowProgramOptions(string programFolder)
        {
            string fileName = "";

            try {
                fileName = Directory.EnumerateFiles(programFolder, "*.exe").First();
            } catch {
                var info = new InfoDialog(programFolder + "is not executable", true, "Program");
                info.Show();
                Directory.Delete(programFolder, true);
                updateProgramList = true;
                return(true);
            }

            var dialog = new SelectDialog <string> (new string[] {
                "Run Program",
                "Debug Program",
                "Run In AOT",
                "AOT Compile",
                "Delete Program",
            }, "Options", true);

            dialog.Show();
            if (!dialog.EscPressed)
            {
                Action programAction = null;
                switch (dialog.GetSelectionIndex())
                {
                case 0:
                    Lcd.Instance.Clear();
                    Lcd.Instance.DrawBitmap(monoLogo, new Point((int)(Lcd.Width - monoLogo.Width) / 2, 5));
                    Rectangle textRect = new Rectangle(new Point(0, Lcd.Height - (int)Font.SmallFont.maxHeight - 2), new Point(Lcd.Width, Lcd.Height - 2));
                    Lcd.Instance.WriteTextBox(Font.SmallFont, textRect, "Running...", true, Lcd.Alignment.Center);
                    Lcd.Instance.Update();
                    programAction = () => RunAndWaitForProgram(fileName, ExecutionMode.Normal);
                    break;

                case 1:
                    programAction = () => RunAndWaitForProgram(fileName, ExecutionMode.Debug);
                    break;

                case 2:
                    if (!AOTHelper.IsFileCompiled(fileName))
                    {
                        if (AOTCompileAndShowDialog(programFolder))
                        {
                            programAction = () => RunAndWaitForProgram(fileName, ExecutionMode.AOT);
                        }
                    }
                    else
                    {
                        programAction = () => RunAndWaitForProgram(fileName, ExecutionMode.AOT);
                    }
                    break;

                case 3:

                    if (AOTHelper.IsFileCompiled(fileName))
                    {
                        var questionDialog = new QuestionDialog("Progran already compiled. Recompile?", "AOT recompile");
                        if (questionDialog.Show())
                        {
                            AOTCompileAndShowDialog(programFolder);
                        }
                    }
                    else
                    {
                        AOTCompileAndShowDialog(programFolder);
                    }
                    break;

                case 4:
                    var question = new QuestionDialog("Are you sure?", "Delete");
                    if (question.Show())
                    {
                        var step = new StepContainer(() => {
                            Directory.Delete(programFolder, true);
                            return(true);
                        }, "Deleting ", "Error deleting program");
                        var progressDialog = new ProgressDialog("Program", step);
                        progressDialog.Show();
                        updateProgramList = true;
                    }
                    break;
                }
                if (programAction != null)
                {
                    Console.WriteLine("Starting application");
                    programAction();
                    Console.WriteLine("Done running application");
                }
                return(updateProgramList);
            }
            return(false);
        }
 internal IEnumerable <EntityInfo> ExtractAnswerEntity(QuestionDialog dialog)
 {
     return(ExtractAnswerEntity(dialog.Question, getAnswerHint(dialog)));
 }