mirror of
https://github.com/chibicitiberiu/rainmeter-studio.git
synced 2024-02-24 04:33:31 +00:00
Fixed bug where save and close document commands were enabled/disabled badly.
This commit is contained in:
parent
93b2e4918f
commit
425d7d62f1
@ -121,13 +121,13 @@ namespace RainmeterStudio.UI.Controller
|
|||||||
DocumentSaveAllCommand = new Command("DocumentSaveAll", SaveAll, () => ProjectManager.ActiveProject != null);
|
DocumentSaveAllCommand = new Command("DocumentSaveAll", SaveAll, () => ProjectManager.ActiveProject != null);
|
||||||
DocumentCloseCommand = new Command("DocumentClose", () => Close(), HasActiveDocumentEditor);
|
DocumentCloseCommand = new Command("DocumentClose", () => Close(), HasActiveDocumentEditor);
|
||||||
|
|
||||||
ProjectManager.ActiveProjectChanged += new EventHandler((obj, e) =>
|
ProjectManager.ActiveProjectChanged += new EventHandler((sender, e) =>
|
||||||
{
|
{
|
||||||
DocumentCreateCommand.NotifyCanExecuteChanged();
|
DocumentCreateCommand.NotifyCanExecuteChanged();
|
||||||
DocumentSaveAllCommand.NotifyCanExecuteChanged();
|
DocumentSaveAllCommand.NotifyCanExecuteChanged();
|
||||||
});
|
});
|
||||||
|
|
||||||
ActiveDocumentEditorChanged += new EventHandler((obj, e) =>
|
ActiveDocumentEditorChanged += new EventHandler((sender, e) =>
|
||||||
{
|
{
|
||||||
DocumentSaveCommand.NotifyCanExecuteChanged();
|
DocumentSaveCommand.NotifyCanExecuteChanged();
|
||||||
DocumentSaveAsCommand.NotifyCanExecuteChanged();
|
DocumentSaveAsCommand.NotifyCanExecuteChanged();
|
||||||
@ -135,7 +135,7 @@ namespace RainmeterStudio.UI.Controller
|
|||||||
DocumentCloseCommand.NotifyCanExecuteChanged();
|
DocumentCloseCommand.NotifyCanExecuteChanged();
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
private bool HasActiveDocumentEditor()
|
private bool HasActiveDocumentEditor()
|
||||||
{
|
{
|
||||||
return ActiveDocumentEditor != null;
|
return ActiveDocumentEditor != null;
|
||||||
@ -305,6 +305,11 @@ namespace RainmeterStudio.UI.Controller
|
|||||||
|
|
||||||
// Close
|
// Close
|
||||||
DocumentManager.Close(editor);
|
DocumentManager.Close(editor);
|
||||||
|
|
||||||
|
// Update ActiveDocument
|
||||||
|
if (editor == ActiveDocumentEditor)
|
||||||
|
ActiveDocumentEditor = null;
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -315,14 +320,7 @@ namespace RainmeterStudio.UI.Controller
|
|||||||
/// <remarks>Shows the 'are you sure' prompt if there are unsaved edits.</remarks>
|
/// <remarks>Shows the 'are you sure' prompt if there are unsaved edits.</remarks>
|
||||||
public bool Close()
|
public bool Close()
|
||||||
{
|
{
|
||||||
// Show the 'are you sure' prompt if necesary
|
return Close(ActiveDocumentEditor);
|
||||||
if (Close(ActiveDocumentEditor))
|
|
||||||
{
|
|
||||||
ActiveDocumentEditor = null;
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
return false;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
@ -120,6 +120,18 @@
|
|||||||
Style="{StaticResource CommandButtonStyle}">
|
Style="{StaticResource CommandButtonStyle}">
|
||||||
<Image Width="16" Height="16" Source="{Binding Icon}" />
|
<Image Width="16" Height="16" Source="{Binding Icon}" />
|
||||||
</Button>
|
</Button>
|
||||||
|
<Button DataContext="{Binding DocumentController.DocumentOpenCommand}"
|
||||||
|
Style="{StaticResource CommandButtonStyle}">
|
||||||
|
<Image Width="16" Height="16" Source="{Binding Icon}" />
|
||||||
|
</Button>
|
||||||
|
<Button DataContext="{Binding DocumentController.DocumentSaveCommand}"
|
||||||
|
Style="{StaticResource CommandButtonStyle}">
|
||||||
|
<Image Width="16" Height="16" Source="{Binding Icon}" />
|
||||||
|
</Button>
|
||||||
|
<Button DataContext="{Binding DocumentController.DocumentSaveAllCommand}"
|
||||||
|
Style="{StaticResource CommandButtonStyle}">
|
||||||
|
<Image Width="16" Height="16" Source="{Binding Icon}" />
|
||||||
|
</Button>
|
||||||
</ToolBar>
|
</ToolBar>
|
||||||
</ToolBarTray>
|
</ToolBarTray>
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user