diff --git a/Core/Models/AppModel.cs b/Core/Models/AppModel.cs
index d08a3f6..f01cc67 100644
--- a/Core/Models/AppModel.cs
+++ b/Core/Models/AppModel.cs
@@ -22,6 +22,10 @@ public class AppModel
///
public string Name { get; set; }
///
+ /// 别名
+ ///
+ public string Alias { get; set; }
+ ///
/// 描述
///
public string Description { get; set; }
diff --git a/Core/Models/Db/WebSiteModel.cs b/Core/Models/Db/WebSiteModel.cs
index 4e94fb4..3cf3519 100644
--- a/Core/Models/Db/WebSiteModel.cs
+++ b/Core/Models/Db/WebSiteModel.cs
@@ -25,6 +25,10 @@ public class WebSiteModel
///
public string Domain { get; set; }
///
+ /// 别名
+ ///
+ public string Alias { get; set; }
+ ///
/// 分类ID
///
public int CategoryID { get; set; }
diff --git a/Core/Properties/AssemblyInfo.cs b/Core/Properties/AssemblyInfo.cs
index 22a9b89..e56a8ab 100644
--- a/Core/Properties/AssemblyInfo.cs
+++ b/Core/Properties/AssemblyInfo.cs
@@ -32,5 +32,5 @@
//可以指定所有这些值,也可以使用“生成号”和“修订号”的默认值
//通过使用 "*",如下所示:
// [assembly: AssemblyVersion("1.0.*")]
-[assembly: AssemblyVersion("1.1.0.5")]
-[assembly: AssemblyFileVersion("1.1.0.5")]
+[assembly: AssemblyVersion("1.1.0.7")]
+[assembly: AssemblyFileVersion("1.1.0.7")]
diff --git a/Core/Servicers/Instances/AppData.cs b/Core/Servicers/Instances/AppData.cs
index de50c91..8d7bf8a 100644
--- a/Core/Servicers/Instances/AppData.cs
+++ b/Core/Servicers/Instances/AppData.cs
@@ -48,6 +48,7 @@ select app
File = m.File,
IconFile = m.IconFile,
Name = m.Name,
+ Alias = m.Alias,
TotalTime = m.TotalTime
})
.ToList();
@@ -73,12 +74,13 @@ public void UpdateApp(AppModel app_)
app.Description = app_.Description;
app.File = app_.File;
app.CategoryID = app_.CategoryID;
+ app.Alias = app_.Alias;
db.SaveChanges();
}
_databse.CloseWriter();
}
}
- catch(Exception e)
+ catch (Exception e)
{
Logger.Error(e.ToString());
}
@@ -119,7 +121,8 @@ public void AddApp(AppModel app)
}
_databse.CloseWriter();
}
- }catch(Exception e)
+ }
+ catch (Exception e)
{
Logger.Error(e.ToString());
}
diff --git a/Core/Servicers/Instances/WebData.cs b/Core/Servicers/Instances/WebData.cs
index 518457d..5f7a23e 100644
--- a/Core/Servicers/Instances/WebData.cs
+++ b/Core/Servicers/Instances/WebData.cs
@@ -278,11 +278,12 @@ public List GetDateRangeWebSiteList(DateTime start, DateTime end,
.GroupBy(m => m.SiteId)
.Select(s => new
{
- Title = s.FirstOrDefault().Site.Title,
- Domain = s.FirstOrDefault().Site.Domain,
- CategoryID = s.FirstOrDefault().Site.CategoryID,
- IconFile = s.FirstOrDefault().Site.IconFile,
- ID = s.FirstOrDefault().Site.ID,
+ //Title = s.FirstOrDefault().Site.Title,
+ //Domain = s.FirstOrDefault().Site.Domain,
+ //CategoryID = s.FirstOrDefault().Site.CategoryID,
+ //IconFile = s.FirstOrDefault().Site.IconFile,
+ //ID = s.FirstOrDefault().Site.ID,
+ Site = s.FirstOrDefault().Site,
Duration = s.Sum(m => m.Duration),
});
@@ -302,7 +303,18 @@ public List GetDateRangeWebSiteList(DateTime start, DateTime end,
{
data = data.OrderByDescending(m => m.Duration);
}
- var result = JsonConvert.DeserializeObject>(JsonConvert.SerializeObject(data.ToList()));
+ var list = data.Select(s => new
+ {
+ Alias = s.Site.Alias,
+ Title = s.Site.Title,
+ Domain = s.Site.Domain,
+ CategoryID = s.Site.CategoryID,
+ IconFile = s.Site.IconFile,
+ ID = s.Site.ID,
+ Duration = s.Duration,
+ }).ToList();
+
+ var result = JsonConvert.DeserializeObject>(JsonConvert.SerializeObject(list));
return result;
}
}
@@ -777,6 +789,7 @@ from nc in newCategory.DefaultIfEmpty()
IconFile = s.FirstOrDefault().Site.IconFile,
CategoryID = s.FirstOrDefault().Site.CategoryID,
Category = s.FirstOrDefault().Category,
+ Alias = s.FirstOrDefault().Site.Alias,
}).ToList();
//var result = query.Select(s => new WebSiteModel
@@ -840,5 +853,25 @@ public void Export(string dir_, DateTime start_, DateTime end_)
}
}
}
+
+ public WebSiteModel Update(WebSiteModel website_)
+ {
+ using (var db = _database.GetWriterContext())
+ {
+ var website = db.WebSites.FirstOrDefault(m => m.ID == website_.ID);
+ if (website != null)
+ {
+ website.Alias = website_.Alias;
+ website.Domain = website_.Domain;
+ website.Title = website_.Title;
+ db.SaveChanges();
+ _database.CloseWriter();
+ }
+ return website;
+ //string sql = $"update WebSiteModels set CategoryID={categoryId_} where ID in ({string.Join(",", siteIds_)})";
+ //db.Database.ExecuteSqlCommand(sql);
+ //db.SaveChanges();
+ }
+ }
}
}
\ No newline at end of file
diff --git a/Core/Servicers/Interfaces/IWebData.cs b/Core/Servicers/Interfaces/IWebData.cs
index 08277bd..37d6f15 100644
--- a/Core/Servicers/Interfaces/IWebData.cs
+++ b/Core/Servicers/Interfaces/IWebData.cs
@@ -168,5 +168,10 @@ public interface IWebData
/// 开始时间
/// 结束时间
void Export(string dir_, DateTime start_, DateTime end_);
+ ///
+ /// 更新站点数据
+ ///
+ ///
+ WebSiteModel Update(WebSiteModel website_);
}
}
diff --git a/UI/Controls/Charts/ChartsItemTypeCard.cs b/UI/Controls/Charts/ChartsItemTypeCard.cs
index 61fb866..7bc9803 100644
--- a/UI/Controls/Charts/ChartsItemTypeCard.cs
+++ b/UI/Controls/Charts/ChartsItemTypeCard.cs
@@ -120,7 +120,7 @@ private void Render()
isRendering = true;
//对部分程序未获取程序名的程序使用路径中名字作为程序名
- NameTextObj.Text = Data.Name;
+ //NameTextObj.Text = Data.Name;
//if (Data.Name.Trim() == "" && Data.PopupText.Trim() != "")
//{
// FileInfo fi = new FileInfo(Data.PopupText);
diff --git a/UI/Controls/Charts/ChartsItemTypeList.cs b/UI/Controls/Charts/ChartsItemTypeList.cs
index 4548a23..180a8c8 100644
--- a/UI/Controls/Charts/ChartsItemTypeList.cs
+++ b/UI/Controls/Charts/ChartsItemTypeList.cs
@@ -162,7 +162,7 @@ private void Render()
return;
}
isRendering = true;
- NameTextObj.Text = Data.Name;
+ //NameTextObj.Text = Data.Name;
//对部分程序未获取程序名的程序使用路径中名字作为程序名
//if (Data.Name.Trim() == "" && Data.PopupText.Trim() != "")
//{
diff --git a/UI/Controls/Charts/Model/ChartsDataModel.cs b/UI/Controls/Charts/Model/ChartsDataModel.cs
index 8a0c00a..3f8b924 100644
--- a/UI/Controls/Charts/Model/ChartsDataModel.cs
+++ b/UI/Controls/Charts/Model/ChartsDataModel.cs
@@ -9,10 +9,11 @@ namespace UI.Controls.Charts.Model
{
public class ChartsDataModel : UINotifyPropertyChanged
{
+ private string Name_;
///
/// 名称
///
- public string Name { get; set; }
+ public string Name { get { return Name_; } set { Name_ = value; OnPropertyChanged(); } }
///
/// 值
diff --git a/UI/Controls/Window/DefaultWindow.cs b/UI/Controls/Window/DefaultWindow.cs
index 71813cb..d4280a0 100644
--- a/UI/Controls/Window/DefaultWindow.cs
+++ b/UI/Controls/Window/DefaultWindow.cs
@@ -9,6 +9,7 @@
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
+using System.Windows.Data;
using System.Windows.Input;
using System.Windows.Interop;
using System.Windows.Media;
@@ -16,6 +17,7 @@
using System.Windows.Media.Imaging;
using System.Windows.Threading;
using UI.Controls.Button;
+using UI.Controls.Input;
namespace UI.Controls.Window
{
@@ -43,6 +45,17 @@ public string DialogMessage
set { SetValue(DialogMessageProperty, value); }
}
#endregion
+ #region InputModal
+ public static readonly DependencyProperty InputModalValueProperty = DependencyProperty.Register("InputModalValue", typeof(string), typeof(DefaultWindow));
+ ///
+ /// Dialog title
+ ///
+ public string InputModalValue
+ {
+ get { return (string)GetValue(InputModalValueProperty); }
+ set { SetValue(InputModalValueProperty, value); }
+ }
+ #endregion
public static readonly DependencyProperty IsShowToastDeproperty = DependencyProperty.Register("IsShowToast", typeof(bool), typeof(DefaultWindow), new PropertyMetadata(false, new PropertyChangedCallback(OnIsShowToastChanged)));
public bool IsShowToast { get { return (bool)GetValue(IsShowToastDeproperty); } set { SetValue(IsShowToastDeproperty, value); } }
private static void OnIsShowToastChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
@@ -209,12 +222,15 @@ private static void OnIsCanBackChanged(DependencyObject d, DependencyPropertyCha
///
public bool IsWindowClosed { get { return IsWindowClosed_; } }
- private Border ToastBorder, Masklayer, DialogBorder;
+ private Border ToastBorder, Masklayer, DialogBorder, InputModalBorder;
private Grid ToastGrid;
private DispatcherTimer toastTimer;
private bool IsDialogConfirm;
- private bool IsShowConfirmDialog;
- private Button.Button CancelBtn, ConfirmBtn;
+ private bool IsShowConfirmDialog, IsShowInputModal;
+ private Button.Button CancelBtn, ConfirmBtn, InputModalCancelBtn, InputModalConfirmBtn;
+ private InputBox InputModalInputBox;
+ private string InputValue;
+ private Func InputModalValidFnc;
#region 3.初始化
public DefaultWindow()
{
@@ -306,6 +322,10 @@ public override void OnApplyTemplate()
DialogBorder = GetTemplateChild("DialogBorder") as Border;
CancelBtn = GetTemplateChild("CancelBtn") as Button.Button;
ConfirmBtn = GetTemplateChild("ConfirmBtn") as Button.Button;
+ InputModalBorder = GetTemplateChild("InputModalBorder") as Border;
+ InputModalCancelBtn = GetTemplateChild("InputModalCancelBtn") as Button.Button;
+ InputModalConfirmBtn = GetTemplateChild("InputModalConfirmBtn") as Button.Button;
+ InputModalInputBox = GetTemplateChild("InputModalInputBox") as InputBox;
if (PageContainer != null)
{
@@ -337,6 +357,36 @@ public override void OnApplyTemplate()
HideDialog();
};
}
+
+ if (InputModalCancelBtn != null)
+ {
+ InputModalCancelBtn.Click += (e, c) =>
+ {
+ IsDialogConfirm = false;
+ HideInputModal();
+ };
+ }
+
+ if (InputModalConfirmBtn != null)
+ {
+ InputModalConfirmBtn.Click += (e, c) =>
+ {
+ if (InputModalValidFnc != null && !InputModalValidFnc(InputValue))
+ {
+ return;
+ }
+ IsDialogConfirm = true;
+ HideInputModal();
+ };
+ }
+
+ if (InputModalInputBox != null)
+ {
+ InputModalInputBox.TextChanged += (e, c) =>
+ {
+ InputValue = InputModalInputBox.Text;
+ };
+ }
}
@@ -400,6 +450,10 @@ private void ShowToast()
{
ToastGrid.Visibility = Visibility.Visible;
DialogBorder.Visibility = Visibility.Collapsed;
+ if (!IsShowInputModal)
+ {
+ InputModalBorder.Visibility = Visibility.Collapsed;
+ }
ToastBorder.Visibility = Visibility.Visible;
Storyboard storyboard = new Storyboard();
@@ -424,7 +478,10 @@ private void ShowToast()
ToastGrid.MouseLeftButtonDown += ToastGrid_MouseLeftButtonDown;
};
storyboard.Children.Add(scrollAnimation);
- storyboard.Children.Add(opacityAnimation);
+ if (!IsShowInputModal)
+ {
+ storyboard.Children.Add(opacityAnimation);
+ }
storyboard.Begin();
}
@@ -455,14 +512,19 @@ private void HideToast()
opacityAnimation.Duration = new Duration(TimeSpan.FromSeconds(0.25));
storyboard.Children.Add(scrollAnimation);
- storyboard.Children.Add(opacityAnimation);
- storyboard.Completed += (e, c) =>
+ if (!IsShowInputModal)
{
- ToastGrid.Visibility = Visibility.Collapsed;
- };
+ storyboard.Children.Add(opacityAnimation);
+ storyboard.Completed += (e, c) =>
+ {
+ ToastGrid.Visibility = Visibility.Collapsed;
+ };
+ }
+
storyboard.Begin();
}
+
#region Dialog
public Task ShowConfirmDialogAsync(string title_, string message_)
{
@@ -470,6 +532,7 @@ public Task ShowConfirmDialogAsync(string title_, string message_)
ToastGrid.Visibility = Visibility.Visible;
ToastBorder.Visibility = Visibility.Collapsed;
DialogBorder.Visibility = Visibility.Visible;
+ InputModalBorder.Visibility = Visibility.Collapsed;
DialogMessage = message_;
DialogTitle = title_;
@@ -536,6 +599,91 @@ private void HideDialog()
}
#endregion
+ #region InputModal
+ public Task ShowInputModalAsync(string title_, string message_, string value_, Func validFnc_)
+ {
+ IsShowInputModal = true;
+ ToastGrid.Visibility = Visibility.Visible;
+ ToastBorder.Visibility = Visibility.Collapsed;
+ DialogBorder.Visibility = Visibility.Collapsed;
+ InputModalBorder.Visibility = Visibility.Visible;
+
+ DialogMessage = message_;
+ DialogTitle = title_;
+ InputModalValue = value_;
+ InputModalValidFnc = validFnc_;
+
+ InputModalInputBox.Text = InputModalValue;
+
+ Storyboard storyboard = new Storyboard();
+
+ DoubleAnimation scrollAnimation = new DoubleAnimation();
+ scrollAnimation.From = -150;
+ scrollAnimation.To = 10;
+
+ scrollAnimation.EasingFunction = new SineEase() { EasingMode = EasingMode.EaseIn };
+ Storyboard.SetTarget(scrollAnimation, InputModalBorder);
+ Storyboard.SetTargetProperty(scrollAnimation, new PropertyPath("RenderTransform.Children[0].Y"));
+ scrollAnimation.Duration = new Duration(TimeSpan.FromSeconds(0.15));
+
+ DoubleAnimation opacityAnimation = new DoubleAnimation();
+ opacityAnimation.To = 0.6;
+ opacityAnimation.EasingFunction = new SineEase() { EasingMode = EasingMode.EaseIn };
+ Storyboard.SetTarget(opacityAnimation, Masklayer);
+ Storyboard.SetTargetProperty(opacityAnimation, new PropertyPath("Opacity"));
+ opacityAnimation.Duration = new Duration(TimeSpan.FromSeconds(0.15));
+ storyboard.Children.Add(scrollAnimation);
+ storyboard.Children.Add(opacityAnimation);
+ storyboard.Begin();
+
+ return Task.Run(() =>
+ {
+
+ while (IsShowInputModal)
+ {
+ Thread.Sleep(10);
+ }
+
+ if (IsDialogConfirm)
+ {
+ return InputValue;
+ }
+ else
+ {
+ throw new Exception("Input cancel");
+ }
+ });
+ }
+ private void HideInputModal()
+ {
+ Storyboard storyboard = new Storyboard();
+
+ DoubleAnimation scrollAnimation = new DoubleAnimation();
+ scrollAnimation.To = -150;
+
+ scrollAnimation.EasingFunction = new SineEase() { EasingMode = EasingMode.EaseIn };
+ Storyboard.SetTarget(scrollAnimation, InputModalBorder);
+ Storyboard.SetTargetProperty(scrollAnimation, new PropertyPath("RenderTransform.Children[0].Y"));
+ scrollAnimation.Duration = new Duration(TimeSpan.FromSeconds(0.12));
+
+ DoubleAnimation opacityAnimation = new DoubleAnimation();
+ opacityAnimation.To = 0;
+ opacityAnimation.EasingFunction = new SineEase() { EasingMode = EasingMode.EaseIn };
+ Storyboard.SetTarget(opacityAnimation, Masklayer);
+ Storyboard.SetTargetProperty(opacityAnimation, new PropertyPath("Opacity"));
+ opacityAnimation.Duration = new Duration(TimeSpan.FromSeconds(0.15));
+
+ storyboard.Children.Add(scrollAnimation);
+ storyboard.Children.Add(opacityAnimation);
+ storyboard.Completed += (e, c) =>
+ {
+ ToastGrid.Visibility = Visibility.Collapsed;
+ IsShowInputModal = false;
+ };
+ storyboard.Begin();
+ }
+ #endregion
+
#region 6.事件
protected override void OnSourceInitialized(EventArgs e)
diff --git a/UI/Properties/AssemblyInfo.cs b/UI/Properties/AssemblyInfo.cs
index b81c92e..50b49ce 100644
--- a/UI/Properties/AssemblyInfo.cs
+++ b/UI/Properties/AssemblyInfo.cs
@@ -51,5 +51,5 @@
//可以指定所有这些值,也可以使用“生成号”和“修订号”的默认值
//通过使用 "*",如下所示:
// [assembly: AssemblyVersion("1.0.*")]
-[assembly: AssemblyVersion("1.5.0.5")]
-[assembly: AssemblyFileVersion("1.5.0.5")]
+[assembly: AssemblyVersion("1.5.0.6")]
+[assembly: AssemblyFileVersion("1.5.0.6")]
diff --git a/UI/Servicers/AppContextMenuServicer.cs b/UI/Servicers/AppContextMenuServicer.cs
index a9c954b..63aab66 100644
--- a/UI/Servicers/AppContextMenuServicer.cs
+++ b/UI/Servicers/AppContextMenuServicer.cs
@@ -7,6 +7,7 @@
using System.Linq;
using System.Text;
using System.Threading.Tasks;
+using System.Windows;
using System.Windows.Controls;
using System.Windows.Media;
using UI.Controls.Charts.Model;
@@ -22,6 +23,7 @@ public class AppContextMenuServicer : IAppContextMenuServicer
private readonly IAppData appData;
private readonly IAppConfig appConfig;
private readonly IThemeServicer theme;
+ private readonly IUIServicer _uIServicer;
private ContextMenu menu;
private MenuItem setCategory;
private MenuItem setLink;
@@ -29,13 +31,20 @@ public class AppContextMenuServicer : IAppContextMenuServicer
MenuItem _whiteList = new MenuItem();
- public AppContextMenuServicer(MainViewModel main, ICategorys categorys, IAppData appData, IAppConfig appConfig, IThemeServicer theme)
+ public AppContextMenuServicer(
+ MainViewModel main,
+ ICategorys categorys,
+ IAppData appData,
+ IAppConfig appConfig,
+ IThemeServicer theme,
+ IUIServicer uIServicer_)
{
this.main = main;
this.categorys = categorys;
this.appData = appData;
this.appConfig = appConfig;
this.theme = theme;
+ this._uIServicer = uIServicer_;
}
@@ -65,6 +74,10 @@ private void CreateMenu()
setCategory = new MenuItem();
setCategory.Header = "设置分类";
+ MenuItem editAlias = new MenuItem();
+ editAlias.Header = "编辑别名";
+ editAlias.Click += EditAlias_ClickAsync;
+
setLink = new MenuItem();
setLink.Header = "添加关联";
@@ -78,6 +91,7 @@ private void CreateMenu()
menu.Items.Add(new Separator());
menu.Items.Add(setCategory);
menu.Items.Add(setLink);
+ menu.Items.Add(editAlias);
menu.Items.Add(new Separator());
menu.Items.Add(openDir);
@@ -87,6 +101,49 @@ private void CreateMenu()
menu.ContextMenuOpening += SetCategory_ContextMenuOpening;
}
+ private async void EditAlias_ClickAsync(object sender, RoutedEventArgs e)
+ {
+ var data = menu.Tag as ChartsDataModel;
+ var log = data.Data as DailyLogModel;
+ var app = log != null ? log.AppModel : null;
+
+ if (log == null)
+ {
+ app = (data.Data as HoursLogModel).AppModel;
+ }
+
+ try
+ {
+ string input = await _uIServicer.ShowInputModalAsync("修改别名", "请输入别名", app.Alias, (val) =>
+ {
+ if (string.IsNullOrEmpty(val))
+ {
+ main.Error("请输入别名");
+ return false;
+ }
+ else if (val.Length > 10)
+ {
+ main.Error("别名最大长度为10位字符");
+ return false;
+ }
+ return true;
+ });
+
+ // 开始更新别名
+ var editApp = appData.GetApp(app.ID);
+ editApp.Alias = input;
+ appData.UpdateApp(editApp);
+ data.Name = input;
+
+ main.Success("别名已更新");
+ Debug.WriteLine("输入内容:" + input);
+ }
+ catch
+ {
+ // 输入取消,无需处理异常
+ }
+ }
+
private void _whiteList_Click(object sender, System.Windows.RoutedEventArgs e)
{
var data = menu.Tag as ChartsDataModel;
@@ -215,6 +272,8 @@ private void UpdateCategory()
setCategory.Items.Add(categoryMenu);
}
+ setCategory.IsEnabled = setCategory.Items.Count > 0;
+
}
private void UpdateLinks()
diff --git a/UI/Servicers/IUIServicer.cs b/UI/Servicers/IUIServicer.cs
index 91b1dfc..8fe8bf7 100644
--- a/UI/Servicers/IUIServicer.cs
+++ b/UI/Servicers/IUIServicer.cs
@@ -11,5 +11,7 @@ public interface IUIServicer
{
Task ShowConfirmDialogAsync(string title_, string message_);
void InitWindow(DefaultWindow window_);
+ Task ShowInputModalAsync(string title_, string placeholder_, string value_ = null, Func validFnc_ = null);
+
}
}
diff --git a/UI/Servicers/UIServicer.cs b/UI/Servicers/UIServicer.cs
index 34faf99..879be3e 100644
--- a/UI/Servicers/UIServicer.cs
+++ b/UI/Servicers/UIServicer.cs
@@ -24,5 +24,11 @@ public Task ShowConfirmDialogAsync(string title_, string message_)
{
return _window.ShowConfirmDialogAsync(title_, message_);
}
+
+ public Task ShowInputModalAsync(string title_, string placeholder_, string value_ = null, Func validFnc_ = null)
+ {
+ return _window.ShowInputModalAsync(title_, placeholder_, value_, validFnc_);
+
+ }
}
}
diff --git a/UI/Servicers/WebSiteContextMenuServicer.cs b/UI/Servicers/WebSiteContextMenuServicer.cs
index 048479f..ea1628e 100644
--- a/UI/Servicers/WebSiteContextMenuServicer.cs
+++ b/UI/Servicers/WebSiteContextMenuServicer.cs
@@ -9,6 +9,7 @@
using System.Linq;
using System.Text;
using System.Threading.Tasks;
+using System.Windows;
using System.Windows.Controls;
using System.Windows.Documents;
using System.Windows.Media;
@@ -24,6 +25,8 @@ public class WebSiteContextMenuServicer : IWebSiteContextMenuServicer
private readonly IAppConfig _appConfig;
private readonly IThemeServicer _theme;
private readonly IWebData _webData;
+ private readonly IUIServicer _uIServicer;
+
private ContextMenu _menu;
private MenuItem _setCategory;
private MenuItem _block;
@@ -34,12 +37,14 @@ public WebSiteContextMenuServicer(
MainViewModel main_,
IAppConfig appConfig_,
IThemeServicer theme_,
- IWebData webData_)
+ IWebData webData_,
+ IUIServicer uIServicer_)
{
_main = main_;
_appConfig = appConfig_;
_theme = theme_;
_webData = webData_;
+ _uIServicer = uIServicer_;
}
public void Init()
@@ -65,6 +70,10 @@ private void CreateMenu()
_setCategory = new MenuItem();
_setCategory.Header = "设置分类";
+ MenuItem editAlias = new MenuItem();
+ editAlias.Header = "编辑别名";
+ editAlias.Click += EditAlias_ClickAsync;
+
_block = new MenuItem();
_block.Header = "忽略此网站";
_block.Click += Block_Click;
@@ -76,11 +85,50 @@ private void CreateMenu()
_menu.Items.Add(open);
_menu.Items.Add(new Separator());
_menu.Items.Add(_setCategory);
+ _menu.Items.Add(editAlias);
_menu.Items.Add(new Separator());
_menu.Items.Add(_block);
_menu.ContextMenuOpening += _menu_ContextMenuOpening;
}
+ private async void EditAlias_ClickAsync(object sender, RoutedEventArgs e)
+ {
+ var data = _menu.Tag as ChartsDataModel;
+ var site = data.Data as WebSiteModel;
+
+ try
+ {
+ string input = await _uIServicer.ShowInputModalAsync("修改别名", "请输入别名", site.Alias, (val) =>
+ {
+ if (string.IsNullOrEmpty(val))
+ {
+ _main.Error("请输入别名");
+ return false;
+ }
+ else if (val.Length > 10)
+ {
+ _main.Error("别名最大长度为10位字符");
+ return false;
+ }
+ return true;
+ });
+
+ // 开始更新别名
+
+ data.Name = input;
+ site.Alias = input;
+
+ _webData.Update(site);
+
+ _main.Success("别名已更新");
+ Debug.WriteLine("输入内容:" + input);
+ }
+ catch
+ {
+ // 输入取消,无需处理异常
+ }
+ }
+
private void _menu_ContextMenuOpening(object sender, ContextMenuEventArgs e)
{
if (_menu.Tag == null)
diff --git a/UI/Themes/Charts/ChartsItemTypeCard.xaml b/UI/Themes/Charts/ChartsItemTypeCard.xaml
index 93c8f86..c2d0252 100644
--- a/UI/Themes/Charts/ChartsItemTypeCard.xaml
+++ b/UI/Themes/Charts/ChartsItemTypeCard.xaml
@@ -54,7 +54,7 @@
-
+
diff --git a/UI/Themes/Charts/ChartsItemTypeList.xaml b/UI/Themes/Charts/ChartsItemTypeList.xaml
index 16ac831..0f2d462 100644
--- a/UI/Themes/Charts/ChartsItemTypeList.xaml
+++ b/UI/Themes/Charts/ChartsItemTypeList.xaml
@@ -31,7 +31,7 @@
-
+
diff --git a/UI/Themes/Window/DefaultWindow.xaml b/UI/Themes/Window/DefaultWindow.xaml
index 3c41e82..503f55b 100644
--- a/UI/Themes/Window/DefaultWindow.xaml
+++ b/UI/Themes/Window/DefaultWindow.xaml
@@ -1,7 +1,8 @@
+ xmlns:base="clr-namespace:UI.Controls.Base"
+ xmlns:input="clr-namespace:UI.Controls.Input">