コード例 #1
0
        private async Task Save()
        {
            try
            {
                await DialogsHelper.ShowLoading("Salvando suas informações");

                if (!CanSave())
                {
                    return;
                }

                _person = new Person(Name.Value, PhoneNumber.Value, Email.Value, Password.Value, BirthDate.Value, _id);

                await _repository.SaveAsync(_person);

                await Navigation.PopAsync();
            }
            catch
            {
                await DialogsHelper.ShowToast("Erro ao salvar suas informações.");
            }
            finally
            {
                await DialogsHelper.HideLoading();
            }
        }
コード例 #2
0
        /// <summary>
        /// Function to handle successful Google Login
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        async void OnGoogleAuthCompleted(object sender, AuthenticatorCompletedEventArgs e)
        {
            var authenticator = sender as OAuth2Authenticator;

            if (authenticator != null)
            {
                authenticator.Completed -= OnGoogleAuthCompleted;
                authenticator.Error     -= OnGoogleAuthError;
            }

            if (e.IsAuthenticated)
            {
                DialogsHelper.ProgressDialog.Show();

                try
                {
                    var google_provider_authCredential = Plugin.FirebaseAuth.CrossFirebaseAuth.Current.GoogleAuthProvider.GetCredential(e.Account.Properties["id_token"], e.Account.Properties["access_token"]);
                    var result = await Plugin.FirebaseAuth.CrossFirebaseAuth.Current.Instance.SignInWithCredentialAsync(google_provider_authCredential);

                    await SaveUser(result);
                }
                catch (Plugin.FirebaseAuth.FirebaseAuthException ex)
                {
                    Debug.WriteLine(ex.Message);

                    DialogsHelper.HandleDialogMessage(DialogsHelper.Errors.UndefinedError);
                }

                DialogsHelper.ProgressDialog.Hide();
            }
        }
コード例 #3
0
ファイル: MainViewModel.cs プロジェクト: rus1st/LusikaCreator
 private async void ExitApp()
 {
     if (await DialogsHelper.ShowRequest("Выйти из программы?"))
     {
         Application.Current.Shutdown();
     }
 }
コード例 #4
0
        private string BuildExistingSchedulesHtml(IEnumerable <PublishSchedule> schedules)
        {
            if (schedules == null)
            {
                return(string.Empty);
            }

            PublishSchedule[] schedulesArray = schedules.ToArray();
            if (schedulesArray.Length == 0)
            {
                return(string.Empty);
            }

            StringBuilder sbTable = new StringBuilder(100);

            sbTable.Append("<table width=\"100%\">");
            sbTable.Append("<tr>");
            sbTable.Append("<td nowrap=\"nowrap\">Time</td>");
            sbTable.Append("<td nowrap=\"nowrap\">Action</td>");
            sbTable.Append("<td nowrap=\"nowrap\">Languages</td>");
            sbTable.Append("<td nowrap=\"nowrap\">Version</td>");
            sbTable.Append("<td nowrap=\"nowrap\">Recurrence</td>");
            sbTable.Append("</tr>");
            foreach (var schedule in schedulesArray)
            {
                string version;

                if (schedule.ItemToPublish != null)
                {
                    Item itemInVersion = schedule.ItemToPublish.Publishing.GetValidVersion(schedule.PublishDate, true, false);
                    if (itemInVersion != null)
                    {
                        sbTable.Append("<tr>");
                        version = itemInVersion.Version.Number.ToString();
                    }
                    else
                    {
                        sbTable.Append("<tr style='color: red'>");
                        version = Constants.NO_VALID_VERSION_TEXT;
                    }
                }
                else
                {
                    sbTable.Append("<tr>");
                    version = Constants.WEBSITE_PUBLISH_TEXT;
                }

                sbTable.AppendFormat("<td nowrap=\"nowrap\">{0}</td>", schedule.PublishDate.ToString(_culture));
                sbTable.AppendFormat("<td nowrap=\"nowrap\">{0}</td>", schedule.Unpublish ? Constants.UNPUBLISH_TEXT : Constants.PUBLISH_TEXT);
                sbTable.AppendFormat("<td nowrap=\"nowrap\">{0}</td>", string.Join(",", schedule.TargetLanguages.Select(x => x.Name)).TrimEnd(','));
                sbTable.AppendFormat("<td nowrap=\"nowrap\">{0}</td>", version);
                sbTable.AppendFormat("<td nowrap=\"nowrap\">{0}</td>", DialogsHelper.GetRecurrenceMessage(schedule.RecurrenceType, schedule.HoursToNextPublish));
                sbTable.Append("</tr>");
            }

            sbTable.Append("</table>");

            return(sbTable.ToString());
        }
コード例 #5
0
        private async void RemoveElement(object selected)
        {
            if (selected == null)
            {
                return;
            }
            if (selected is DirectoryItem)
            {
                var path      = ((DirectoryItem)selected).Path;
                var groupName = Path.GetFileName(path);

                if (!await DialogsHelper.ShowRequest(
                        $"Удалить группу \"{groupName}\" и все связанные с ней файлы?",
                        WindowType.TreeMenu))
                {
                    return;
                }

                var itemsCount = _itemProvider.GetItems(path).Count(t => t is FileItem);
                if (itemsCount > 0)
                {
                    if (!await DialogsHelper.ShowRequest(
                            $"Группа \"{groupName}\" содержит проекты ({itemsCount}).{Environment.NewLine}" +
                            "Удалить их без возможности восстановления?", WindowType.TreeMenu))
                    {
                        return;
                    }
                }

                if (!RemoveGroup(path))
                {
                    await DialogsHelper.ShowMessage("Ошибка удаления группы", WindowType.TreeMenu);

                    return;
                }
                FillItems();
            }
            else if (selected is FileItem)
            {
                var fileName = ((FileItem)selected).Path;
                var name     = Path.GetFileNameWithoutExtension(fileName);
                if (!await DialogsHelper.ShowRequest(
                        $"Удалить проект \"{name}\" без возможности восстановления?", WindowType.TreeMenu))
                {
                    return;
                }

                if (!RemoveFile(fileName))
                {
                    await DialogsHelper.ShowMessage("Ошибка удаления файла проекта", WindowType.TreeMenu);

                    return;
                }
                FillItems();
            }
        }
コード例 #6
0
ファイル: MainViewModel.cs プロジェクト: rus1st/LusikaCreator
        private void About()
        {
            var helpFile = Common.GetInstallPath + "help.pdf";

            if (!File.Exists(helpFile))
            {
                DialogsHelper.ShowNotification("Файл справки не найден.");
                return;
            }
            System.Diagnostics.Process.Start(helpFile);
        }
コード例 #7
0
 public override void OnBackPressed()
 {
     if (sidem.IsDrawerOpen(Android.Support.V4.View.GravityCompat.Start))
     {
         RunOnUiThread(() => { sidem.CloseDrawers(); });
     }
     else
     {
         DialogsHelper.ShowAskIfMenuOrExit(this);
     }
 }
コード例 #8
0
ファイル: MainViewModel.cs プロジェクト: rus1st/LusikaCreator
        private async void Open()
        {
            var fileName = DialogsHelper.OpenFileDialog(fileType: FileType.Xml);

            if (string.IsNullOrEmpty(fileName))
            {
                return;
            }

            await _projectRepository.OpenProject(fileName);

            RaisePropertyChanged(nameof(SelectedTabIndex));
        }
コード例 #9
0
ファイル: MainViewModel.cs プロジェクト: rus1st/LusikaCreator
        private async void Save()
        {
            var success = await _projectRepository.SaveProject();

            if (!string.IsNullOrEmpty(_projectRepository.ErrorMessage))
            {
                await DialogsHelper.ShowMessage($"Ошибка сохранения проекта: {_projectRepository.ErrorMessage}.");
            }
            else
            {
                DialogsHelper.ShowNotification(success ? "Проект сохранен." : "Сохранение отменено.");
            }
        }
コード例 #10
0
        /// <summary>
        /// Function to open share modal
        /// </summary>
        async Task ShareArticle()
        {
            try
            {
                await PopupNavigation.Instance.PopAsync();

                await DialogsHelper.ShareText($"Check out this article: \n\n {CurrentArticle.Url}");
            }
            catch (Exception ex)
            {
                Debug.WriteLine(ex.Message);
            }
        }
コード例 #11
0
ファイル: MainViewModel.cs プロジェクト: rus1st/LusikaCreator
        private async void Help()
        {
            var appInfo = $"Версия {Constants.Version}.{Environment.NewLine}Обновлено {Constants.LastUpdated}.";

            try
            {
                await DialogsHelper.ShowMessage(appInfo);
            }
            catch (Exception e)
            {
                DialogsHelper.ShowNotification(appInfo);
            }
        }
コード例 #12
0
        /// <summary>
        /// Event handler to capture Google Login error
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        void OnGoogleAuthError(object sender, AuthenticatorErrorEventArgs e)
        {
            Debug.WriteLine("Authentication error: " + e.Message);

            DialogsHelper.ProgressDialog.Hide();

            var authenticator = sender as OAuth2Authenticator;

            if (authenticator != null)
            {
                authenticator.Completed -= OnGoogleAuthCompleted;
                authenticator.Error     -= OnGoogleAuthError;
            }

            DialogsHelper.HandleDialogMessage(DialogsHelper.Errors.UndefinedError);
        }
コード例 #13
0
        private async void AddGroup(object selected)
        {
            var name = await GetName("Введите имя группы");

            if (name == null)
            {
                return;
            }

            if (selected == null)
            {
                // Add to empty root
                Directory.CreateDirectory(Path.Combine(_rootPath, name));
            }
            else if (selected is DirectoryItem)
            {
                var path = Path.Combine(((DirectoryItem)selected).Path, name);
                try
                {
                    Directory.CreateDirectory(path);
                }
                catch (Exception e)
                {
                    await DialogsHelper.ShowMessage($"Не удалось создать папку \"{path}\"{Environment.NewLine}" +
                                                    $"{e.Message}");

                    return;
                }
            }
            else if (selected is FileItem)
            {
                var selector = (FileItem)selected;
                var path     = Path.GetDirectoryName(selector.Path);
                if (path == null)
                {
                    return;
                }
                Directory.CreateDirectory(Path.Combine(path, name));
            }
            else
            {
                return;
            }

            FillItems();
        }
コード例 #14
0
        protected override void OnDestroy()
        {
            if (klk.Length > 0 && pathvalido == true)
            {
                SettingsHelper.SaveSetting("rutadescarga", klk);
            }
            SettingsHelper.SaveSetting("abrirserver", abrirserver);
            SettingsHelper.SaveSetting("ordenalfabeto", ordenalfabeto);
            SettingsHelper.SaveSetting("color", color);
            SettingsHelper.SaveSetting("video", calidad.ToString());
            SettingsHelper.SaveSetting("automatica", reprodautomatica);
            //  Toast.MakeText(this, "Guardado exitosamente", ToastLength.Long).Show();
            DialogsHelper.ShowAskIfMenuOrExit(this);


            base.OnDestroy();
        }
コード例 #15
0
        private async Task Delete()
        {
            try
            {
                var confirm = await DialogsHelper.ShowConfirm("Atenção", "Deseja excluir este registro?");

                if (!confirm)
                {
                    return;
                }

                await _repository.DeleteAsync(_person);

                await Navigation.PopAsync();
            }
            catch
            {
                await DialogsHelper.ShowAlert("Atenção", "Não foi possível excluir o registro");
            }
        }
コード例 #16
0
        private async void AddItem(object selected)
        {
            var name = await GetName("Введите имя проекта.");

            if (name == null)
            {
                return;
            }

            string fileName;
            var    ext = Constants.ExtName;

            if (selected == null)
            {
                fileName = _rootPath + $"\\{name}.{ext}";
            }
            else if (selected is DirectoryItem)
            {
                fileName = ((DirectoryItem)selected).Path + $"\\{name}.{ext}";
            }
            else if (selected is FileItem)
            {
                var path = Path.GetDirectoryName(((FileItem)selected).Path);
                fileName = path + $"\\{name}.{ext}";
            }
            else
            {
                return;
            }

            if (File.Exists(fileName))
            {
                DialogsHelper.ShowNotification($"Проект с именем \"{name}\" в этой группе уже существует.");
                return;
            }

            Close();
            _projectRepository.NewProject(fileName);
        }
コード例 #17
0
        void LoginWithGoogle()
        {
            try
            {
                var store = AccountStore.Create();

                var account = store.FindAccountsForService(Constants.AppName).FirstOrDefault();

                var authenticator = new OAuth2Authenticator(
                    GoogleClientId(),
                    string.Empty,
                    Constants.GoogleScope,
                    new Uri(Constants.GoogleAuthorizeUrl),
                    new Uri(GoogleRedirectUrl()),
                    new Uri(Constants.GoogleAccessTokenUrl),
                    null,
                    true)
                {
                    AllowCancel = true,
                    Title       = "Google Login"
                };

                authenticator.Completed += OnGoogleAuthCompleted;
                authenticator.Error     += OnGoogleAuthError;

                AuthenticationState.Authenticator = authenticator;

                var presenter = new Xamarin.Auth.Presenters.OAuthLoginPresenter();
                presenter.Login(authenticator);
            }
            catch (Exception ex)
            {
                Debug.WriteLine(ex.Message);
                DialogsHelper.HandleDialogMessage(DialogsHelper.Errors.UndefinedError);
            }
        }
コード例 #18
0
ファイル: MainViewModel.cs プロジェクト: rus1st/LusikaCreator
        private async void FillTemplate()
        {
            if (!_projectRepository.ProjectSettings.IsCompleted)
            {
                DialogsHelper.ShowNotification("Заполните все обязательные поля.");
                await DialogsHelper.OpenConfiguration(_dataProvider, 1);

                return;
            }

            //await DialogsManager.ShowProgress("Формирование файла...");
            if (!_dataProvider.ObjectsRepository.IsCompleted())
            {
                DialogsHelper.ShowNotification($"Заполните все обязательные поля ({_dataProvider.ObjectsRepository.ErrorMessage}).");
                return;
            }

            if (!_projectRepository.FillTemplate())
            {
                await DialogsHelper.ShowMessage(_projectRepository.ErrorMessage);
            }

            DialogsHelper.CloseProgress();
        }
コード例 #19
0
 private async Task <string> GetName(string text)
 {
     return(await DialogsHelper.GetValue(text, WindowType.TreeMenu));
 }
コード例 #20
0
ファイル: MainViewModel.cs プロジェクト: rus1st/LusikaCreator
 private async void ShowMenu()
 {
     await DialogsHelper.ShowMenu();
 }
コード例 #21
0
        /// <summary>
        /// Displays all current publishing schedules ordered by date and time
        /// </summary>
        private void RenderAllSchedules()
        {
            StringBuilder sbHeader = new StringBuilder();

            sbHeader.Append("<table width=\"100%\" cellpadding=\"4\" cellspacing=\"0\">");
            sbHeader.Append("<col />");
            sbHeader.Append("<col />");
            sbHeader.Append("<col />");
            sbHeader.Append("<col />");
            sbHeader.Append("<col />");
            sbHeader.Append("<col />");
            sbHeader.Append("<tr style=\"background:#e9e9e9\">");
            sbHeader.Append("<td nowrap=\"nowrap\"><b>" + "Item" + "</b></td>");
            sbHeader.Append("<td nowrap=\"nowrap\"><b>" + "Action" + "</b></td>");
            sbHeader.Append("<td nowrap=\"nowrap\"><b>" + "Subitems" + "</b></td>");
            sbHeader.Append("<td nowrap=\"nowrap\"><b>" + "Mode" + "</b></td>");
            sbHeader.Append("<td nowrap=\"nowrap\"><b>" + "Date" + "</b></td>");
            sbHeader.Append("<td nowrap=\"nowrap\"><b>" + "Delete" + "</b></td>");
            sbHeader.Append("</tr>");
            AllSchedules.Controls.Add(new LiteralControl(sbHeader.ToString()));

            IEnumerable <PublishSchedule> allSchedules;

            using (new LanguageSwitcher(LanguageManager.DefaultLanguage))
            {
                allSchedules = _scheduledPublishRepo.AllUnpublishedSchedules;
            }

            foreach (var schedule in allSchedules)
            {
                if (schedule.InnerItem != null)
                {
                    StringBuilder sbItem = new StringBuilder();
                    // Item name, path, recurrence
                    sbItem.Append("<tr style='background:#cedff2;border-bottom:1px solid #F0F1F2;'>");
                    Item scheduledItem = schedule.ItemToPublish;
                    sbItem.Append("<td>");
                    sbItem.Append("<b>" + scheduledItem.DisplayName + "</b>");
                    sbItem.Append("<br />" + scheduledItem.Paths.FullPath);
                    string recurrenceMessage =
                        DialogsHelper.GetRecurrenceMessage(schedule.RecurrenceType,
                                                           schedule.HoursToNextPublish);
                    if (!string.IsNullOrWhiteSpace(recurrenceMessage))
                    {
                        sbItem.Append("<br /> Recurrence: " + recurrenceMessage);
                    }
                    sbItem.Append("</td>");

                    // Is publishing/unpublishing
                    sbItem.Append("<td style='border-left:1px solid #F0F1F2;'>");
                    string isUnpublishing = schedule.Unpublish ? "Unpublish" : "Publish";
                    sbItem.Append(isUnpublishing);
                    sbItem.Append("</td><td style='border-left:1px solid #F0F1F2; text-align: center;'>");

                    // Subitems
                    string includeSubitems = schedule.PublishChildren ? "Yes" : "No";
                    sbItem.Append(includeSubitems);
                    sbItem.Append("</td><td style='border-left:1px solid #F0F1F2;'>");

                    // Publish mode
                    string publishMode = schedule.PublishMode.ToString();
                    sbItem.Append(publishMode);
                    sbItem.Append("</td><td style='border-left:1px solid #F0F1F2;'>");

                    // Current scheudled publish date and time
                    AllSchedules.Controls.Add(new LiteralControl(sbItem.ToString()));
                    DateTime pbDate = schedule.PublishDate;
                    AllSchedules.Controls.Add(new LiteralControl(pbDate.ToString(_culture)));

                    // Pick new date and time
                    DateTimePicker dtPicker = new DateTimePicker();
                    dtPicker.ID    = "dt_" + schedule.InnerItem.ID;
                    dtPicker.Width = new Unit(100.0, UnitType.Percentage);
                    dtPicker.Value = DateUtil.ToIsoDate(schedule.PublishDate);
                    AllSchedules.Controls.Add(dtPicker);
                    AllSchedules.Controls.Add(new LiteralControl("</td>"));

                    // Delete schedule
                    AllSchedules.Controls.Add(new LiteralControl("<td style='border-left:1px solid #F0F1F2;'>"));
                    Checkbox deleteCheckbox = new Checkbox();
                    deleteCheckbox.ID = "del_" + schedule.InnerItem.ID;
                    AllSchedules.Controls.Add(deleteCheckbox);

                    AllSchedules.Controls.Add(new LiteralControl("</td></tr>"));
                }
            }

            AllSchedules.Controls.Add(new LiteralControl("</table"));
        }
コード例 #22
0
ファイル: MainViewModel.cs プロジェクト: rus1st/LusikaCreator
 private async void OpenConfig()
 {
     await DialogsHelper.OpenConfiguration(_dataProvider);
 }
コード例 #23
0
        // Botão para salvar o projeto criado
        private void BtnSalvar_Click(object sender, RoutedEventArgs e)
        {
            if (!String.IsNullOrEmpty(txtProjeto.Text))
            {
                // Seleciona a pasta para criar o projeto
                string folderPath = DialogsHelper.getFolderPath("Selecione uma pasta para criar o projeto.\nObs: Para manter a integridade do projeto sempre utilize uma pasta vazia.");
                //Checa se o valor retornado contem um caminho
                // Caso retorne, procede ao algoritmo, caso retorne null, não realiza ação alguma
                if (!String.IsNullOrEmpty(folderPath))
                {
                    try
                    {
                        // Copia os arquivos base da pasta de instalação do software
                        XElement projectXML = new XElement("projeto",
                                                           new XElement("nome", txtProjeto.Text),
                                                           new XElement("descricao", txtDescricao.Text),
                                                           new XElement("responsavel", txtResponsavel.Text),
                                                           new XElement("cargo", txtCargo.Text),
                                                           new XElement("observacoes", txtObs.Text),
                                                           new XElement("razaosocial", txtRazaoSocial.Text),
                                                           new XElement("cnpj", txtCnpj.Text),
                                                           new XElement("endereco", txtEndereco.Text),
                                                           new XElement("telefone", txtTelefone.Text),
                                                           new XElement("email", txtEmail.Text),
                                                           new XElement("site", txtSite.Text)
                                                           );
                        string projectName = txtProjeto.Text.Replace(' ', '-');
                        // Salva o xml preenchido
                        projectXML.Save(Path.Combine(folderPath, projectName + ".xml"));

                        Directory.CreateDirectory(Path.Combine(Path.Combine(folderPath, "recursos")));
                        Directory.CreateDirectory(Path.Combine(Path.Combine(folderPath, "recursos", "relatorios")));
                        Directory.CreateDirectory(Path.Combine(Path.Combine(folderPath, "recursos", "logs")));
                        Directory.CreateDirectory(Path.Combine(Path.Combine(folderPath, "recursos", "dados")));
                        Directory.CreateDirectory(Path.Combine(Path.Combine(folderPath, "recursos", "imagens")));
                        File.Copy(Path.Combine(Directory.GetCurrentDirectory(), "Arquivos/Padrao/lab.db"), Path.Combine(Path.Combine(folderPath, "recursos", "dados", "lab.db")));
                        System.Windows.MessageBox.Show("Projeto criado com sucesso, abra o projeto para utilizar o sistema.", "Sucesso", MessageBoxButton.OK, MessageBoxImage.Information);
                        // Fecha a janela
                        this.Close();

                        if (!String.IsNullOrEmpty(pathToSelectedLogo))
                        {
                            Image  img          = Image.FromFile(pathToSelectedLogo);
                            Bitmap bitmap       = ImageProcessing.ResizeImage(img, 180, 150);
                            Image  resizedImage = (Image)bitmap;
                            resizedImage.Save(Path.Combine(folderPath, "recursos", "imagens", "logo.png"), System.Drawing.Imaging.ImageFormat.Png);
                        }


                        clearFields();
                    }
                    catch (Exception ex)
                    {
                        Directory.Delete(folderPath, true);
                        DialogsHelper.askUserToSeeError(ex);
                    }
                }
            }
            else
            {
                System.Windows.MessageBox.Show("O nome do projeto deve ser inserido.", "Erro", MessageBoxButton.OK, MessageBoxImage.Information);
            }
        }