Example #1
0
        async void ServerVersionItem_Click(object sender, RoutedEventArgs e)
        {
            var version = await NetworkUtils.CheckVersion();

            if (version != null)
            {
                MessageBox.Show($"Успешно! Версия сервера:\n{version}");
            }
        }
Example #2
0
        void ApplyFilter()
        {
            if (StatementsLV != null)
            {
                StatementsLV.Items.Filter = c =>
                {
                    var statement = (Statement)c;
                    return(!(EnableFiltersCB.IsChecked ?? false) ||
                           statement.StatementNumber.ToString().Contains(StatementNumberFilterTB.Text) &&
                           (StatementTypeFilterCB.SelectedIndex == 0 || statement.StatementType == (StatementType)(StatementTypeFilterCB.SelectedIndex - 1)));
                }
            }
            ;
        }

        #endregion
        #region Help
        void HelpItem_Click(object sender, RoutedEventArgs e)
        {
            HelpPanel.Visibility = Visibility.Visible;
            AddButton.Visibility = Visibility.Collapsed;
        }

        void CloseHelpButton_Click(object sender, RoutedEventArgs e)
        {
            HelpPanel.Visibility = Visibility.Collapsed;
            AddButton.Visibility = Visibility.Visible;
        }

        void HelpCategoryButton_Click(object sender, RoutedEventArgs e)
        {
            if (sender is Button buttonSender)
            {
                ShowInfo(InfoTag(buttonSender.Name.Split(new[] { "HelpButton" }, StringSplitOptions.RemoveEmptyEntries)[0]));
            }
        }

        void ShowInfo((string open, string close) tag)
        {
            HelpContentTB.Text = Properties.Resources.MainWindow_Help
                                 .Split(new[] { tag.open }, StringSplitOptions.RemoveEmptyEntries)[1]
                                 .Split(new[] { tag.close }, StringSplitOptions.RemoveEmptyEntries)[0];
        }

        (string open, string close) InfoTag(string name)
        {
            return($"[{name}]", $"[/{name}]");
        }

        #endregion
        #region Other menu items
        async void DictionariesItem_Click(object sender, RoutedEventArgs e)
        {
            int itemIndex = ((MenuItem)(((MenuItem)sender).Parent)).Items.IndexOf(sender);

            if (itemIndex == 0)
            {
                new AttestationTypesWindow().ShowDialog();
            }
            else
            {
                new StudyObjectsWindow(itemIndex - 1).ShowDialog();
            }
            await UpdateData();
        }

        async void UpdateItem_Click(object sender, RoutedEventArgs e)
        {
            await UpdateData();
        }

        async void CheckVersionItem_Click(object sender, RoutedEventArgs e)
        {
            MessageBox.Show(await NetworkUtils.CheckVersion());
        }

        async void OpenItem_Click(object sender, RoutedEventArgs e)
        {
            var dialog = new OpenFileDialog
            {
                Filter           = "Токен авторизации|*.token|Конфигурация клиента|*.json",
                InitialDirectory = CommonVariables.DataDirectory
            };

            if (dialog.ShowDialog() ?? false)
            {
                if (dialog.FileName.EndsWith(".token"))
                {
                    App.Token = File.ReadAllText(dialog.FileName);
                }
                else if (dialog.FileName.EndsWith(".json"))
                {
                    ClientConfiguration.Instance = Newtonsoft.Json.JsonConvert.DeserializeObject <ClientConfiguration>(File.ReadAllText(dialog.FileName));
                }
            }
            await UpdateData();
        }

        void ExitItem_Click(object sender, RoutedEventArgs e)
        {
            Close();
        }

        void AboutItem_Click(object sender, RoutedEventArgs e)
        {
            new AboutWindow().ShowDialog();
        }

        void LogItem_Click(object sender, RoutedEventArgs e)
        {
            new LogWindow().ShowDialog();
        }

        #endregion

        void SettingsItem_Click(object sender, RoutedEventArgs e)
        {
            new SettingsWindow().ShowDialog();
        }
    }