-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
7 changed files
with
237 additions
and
33 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,84 @@ | ||
using Microsoft.UI.Xaml; | ||
using Microsoft.UI.Xaml.Controls; | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
using System.Text; | ||
using System.Threading.Tasks; | ||
|
||
namespace VK_UI3.Views.Settings | ||
{ | ||
class CheckUpdate : Button | ||
{ | ||
public CheckUpdate() | ||
{ | ||
this.CornerRadius = new CornerRadius(8); | ||
Click += CheckUpdate_Click; | ||
Style style = Application.Current.Resources["DefaultButtonStyle"] as Style; | ||
this.Content = "Проверить обновления"; | ||
} | ||
|
||
private async void CheckUpdate_Click(object sender, RoutedEventArgs e) | ||
{ | ||
try | ||
{ | ||
this.IsEnabled = false; | ||
var a = await MainWindow.mainWindow.checkUpdate(); | ||
if (!a) | ||
{ | ||
|
||
MenuFlyout myFlyout = new MenuFlyout(); | ||
|
||
// Добавьте элементы в меню | ||
MenuFlyoutItem firstItem = new MenuFlyoutItem { Text = "Обновлений не найдено" }; | ||
|
||
myFlyout.Items.Add(firstItem); | ||
|
||
|
||
// Покажите всплывающее меню | ||
myFlyout.ShowAt(this); | ||
|
||
// Создайте таймер, который закроет меню через 5 секунд | ||
DispatcherTimer timer = new DispatcherTimer(); | ||
timer.Interval = TimeSpan.FromSeconds(10); | ||
timer.Tick += (s, e) => | ||
{ | ||
myFlyout.Hide(); | ||
timer.Stop(); | ||
this.IsEnabled = true; | ||
}; | ||
timer.Start(); | ||
} | ||
else | ||
{ | ||
this.IsEnabled = true; | ||
} | ||
} | ||
catch (Exception ex) | ||
{ | ||
MenuFlyout myFlyout = new MenuFlyout(); | ||
|
||
// Добавьте элементы в меню | ||
MenuFlyoutItem firstItem = new MenuFlyoutItem { Text = $"Произошла ошибка. Проверьте настройки сети.\n{ex.Message}" }; | ||
|
||
myFlyout.Items.Add(firstItem); | ||
|
||
|
||
// Покажите всплывающее меню | ||
myFlyout.ShowAt(this); | ||
|
||
// Создайте таймер, который закроет меню через 5 секунд | ||
DispatcherTimer timer = new DispatcherTimer(); | ||
timer.Interval = TimeSpan.FromSeconds(10); | ||
timer.Tick += (s, e) => | ||
{ | ||
myFlyout.Hide(); | ||
timer.Stop(); | ||
|
||
}; | ||
timer.Start(); | ||
this.IsEnabled = true; | ||
} | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
using Microsoft.UI.Xaml; | ||
using Microsoft.UI.Xaml.Controls; | ||
using Microsoft.UI.Xaml.Controls.Primitives; | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Diagnostics; | ||
using System.Linq; | ||
using System.Text; | ||
using System.Threading.Tasks; | ||
using vkPosterBot.DB; | ||
|
||
namespace VK_UI3.Views.Settings | ||
{ | ||
class PhotoCacheSize : Slider | ||
{ | ||
public PhotoCacheSize() | ||
{ | ||
this.ValueChanged += OnValueChanged; | ||
|
||
this.Minimum = 10; | ||
this.Maximum = 1000; | ||
this.StepFrequency = 10; | ||
|
||
|
||
this.Style = Application.Current.Resources["DefaultSliderStyle"] as Style; | ||
|
||
double val = 100; | ||
var set = SettingsTable.GetSetting("photoCacheSize"); | ||
if (set == null) | ||
{ | ||
SettingsTable.SetSetting("photoCacheSize", "100"); | ||
} | ||
else | ||
{ | ||
val = double.Parse(set.settingValue); | ||
} | ||
|
||
this.Value = val; | ||
} | ||
|
||
|
||
private void OnValueChanged(object sender, RangeBaseValueChangedEventArgs e) | ||
{ | ||
|
||
string a = e.NewValue.ToString(); | ||
Task.Run(() => | ||
{ | ||
SettingsTable.SetSetting("photoCacheSize", a); | ||
}); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters