Skip to content

Commit 64b9e84

Browse files
committed
fix save bug
1 parent e9c68c1 commit 64b9e84

4 files changed

Lines changed: 16 additions & 18 deletions

File tree

Modules/XamlEditor/ViewModels/EditorControlViewModel.cs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ public class EditorControlViewModel : BindableBase
2929
public DelegateCommand DelayArrivedCommand { get; private set; }
3030

3131
public DelegateCommand CompileCommand { get; private set; }
32-
public DelegateCommand<bool?> SaveCommand { get; private set; }
32+
public DelegateCommand SaveCommand { get; private set; }
3333
public DelegateCommand RedoCommand { get; private set; }
3434
public DelegateCommand UndoCommand { get; private set; }
3535

@@ -62,7 +62,7 @@ private void InitCommand()
6262
CompileCommand = new DelegateCommand(Compile, CanCompile);
6363
_appCommands.CompileCommand.RegisterCommand(CompileCommand);
6464

65-
SaveCommand = new DelegateCommand<bool?>(Save, CanSave);
65+
SaveCommand = new DelegateCommand(Save, CanSave);
6666
_appCommands.SaveCommand.RegisterCommand(SaveCommand);
6767

6868
RedoCommand = new DelegateCommand(Redo, CanRedo);
@@ -277,17 +277,17 @@ public bool UseRegex
277277

278278
#region Command
279279

280-
private bool CanSave(bool? alreadySelectPath)
280+
private bool CanSave()
281281
{
282282
return !IsReadOnly;
283283
}
284284

285-
private void Save(bool? alreadySelectPath)
285+
private void Save()
286286
{
287287
Reset();
288288

289289
if (_eventAggregator != null)
290-
_eventAggregator.GetEvent<SaveTextEvent>().Publish(new TabInfo { Guid = _fileGuid, AlreadySelectPath = alreadySelectPath.HasValue && alreadySelectPath.Value, FileContent = _textEditor.Text });
290+
_eventAggregator.GetEvent<SaveTextEvent>().Publish(new TabInfo { Guid = _fileGuid, FileContent = _textEditor.Text });
291291
}
292292

293293
private bool CanRedo()

README.md

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -4,24 +4,23 @@ XAML Viewer is a lightweight XAML editor. 在编写文本的同时,能够实
44

55
![Preview](images/XAMLViewer.png)
66

7-
## Document Manager
8-
通过工具栏按钮(或快捷键)提供如下操作:
7+
## Document Manager
98
1. 支持创建,打开,保存,关闭等操作;
109
2. 支持拖动页签进行位置交换;
1110
3. 支持在 Active Files 下拉列表中针对已打开的文件进行快速选择。
1211

1312
<font color=red>_注意:在关闭软件时,只会自动保存已经存储在本地的文档,请务必在此之前,将需要保留的临时文档保存到本地。_</font>
1413

15-
## Automitic Compile
16-
通过 [Setting] >> [Compile] 修改相应的设置:
17-
1. Automitic Compile CheckBox,开启或关闭自动编译功能,但手动编译[F5],一直生效;
14+
## Automitic Compilation
15+
[Setting] >> [Compilation]
16+
1. Auto-Compile CheckBox,开启或关闭自动编译功能,但手动编译[F5],一直生效;
1817
2. Auto-Compile Delay Slider,在无任何输入的指定时间后自动执行编译。
1918

20-
## Custom Controls
21-
通过 [Setting] >> [Reference] >> [Add] 添加自定义控件库,可以在XAML中直接引用其中控件。
22-
请注意以下两点
19+
## Reference
20+
[Setting] >> [Reference] >> [Add]: 添加自定义控件库,可以在XAML中直接引用其中控件。
21+
注意
2322
1. 当前软件基于.Net Framework 4.5,只要系统中包含.Net Framework 4.X(X >= 5),即可引用基于4.0--4.X任意版本的控件库;
24-
2. 引用自定义控件库时,命名空间的申明只能是以下形式方能生效:</br>
23+
2. 引用自定义控件库时,请按照以下形式声明命名空间:</br>
2524
``` xml
2625
xmlns:controls="clr-namespace:MyControl.Controls;assembly=MyControl"
2726
```

XamlService/Payloads/TabInfo.cs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@ public class TabFlag
99
public class TabInfo : TabFlag
1010
{
1111
public string Guid { get; set; }
12-
public bool AlreadySelectPath { get; set; }
1312
public string FileContent { get; set; }
1413
}
1514
}

XamlViewer/ViewModels/TabViewModel.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -234,7 +234,7 @@ private void Close(bool? ignoreSelected)
234234

235235
//this--->Editor(text)--->this(Save)
236236
_closeAfterSaving = true;
237-
_appCommands.SaveCommand.Execute(true);
237+
_appCommands.SaveCommand.Execute(null);
238238
}
239239
else
240240
{
@@ -262,7 +262,7 @@ public void Save()
262262
}
263263

264264
//this--->Editor(text)--->this(Save)
265-
_appCommands.SaveCommand.Execute(true);
265+
_appCommands.SaveCommand.Execute(null);
266266
}
267267

268268
private bool CanCopyOrOpenPath(bool? isOpen)
@@ -314,7 +314,7 @@ private void OnSaveText(TabInfo tabInfo)
314314
if (tabInfo.Guid != _guid || !CanSave())
315315
return; ;
316316

317-
if (!tabInfo.AlreadySelectPath)
317+
if (!string.Equals(Path.GetFullPath(FileName), FileName, StringComparison.OrdinalIgnoreCase))
318318
{
319319
var fileName = Common.ShowSaveFileDialog(FileName);
320320
if (string.IsNullOrEmpty(fileName))

0 commit comments

Comments
 (0)