mirror of
https://github.com/vczh-libraries/Release.git
synced 2026-05-18 07:55:32 +08:00
Update GacUI_Controls\TextEditor demo
This commit is contained in:
@@ -4,6 +4,8 @@
|
||||
using namespace vl::collections;
|
||||
using namespace vl::stream;
|
||||
|
||||
#pragma comment(linker,"\"/manifestdependency:type='win32' name='Microsoft.Windows.Common-Controls' version='6.0.0.0' processorArchitecture='*' publicKeyToken='6595b64144ccf1df' language='*'\"")
|
||||
|
||||
int CALLBACK WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int CmdShow)
|
||||
{
|
||||
return SetupWindowsDirect2DRenderer();
|
||||
|
||||
@@ -16,7 +16,7 @@
|
||||
<Folder name="MainWindow">
|
||||
<Instance name="MainWindowResource">
|
||||
<Instance ref.CodeBehind="true" ref.Class="demo::MainWindow">
|
||||
<Window ref.Name="self" Text="TextEditor" ClientSize="x:480 y:320">
|
||||
<Window ref.Name="self" Text="TextEditor" ClientSize="x:480 y:320" ev.WindowClosing="window_Closing">
|
||||
<att.BoundsComposition-set PreferredMinSize="x:480 y:320"/>
|
||||
|
||||
<ToolstripCommand ref.Name="commandFileNewText" Text="Text File" Image-uri="res://Images/NewText.png">
|
||||
|
||||
@@ -40,6 +40,7 @@ namespace vl
|
||||
CLASS_MEMBER_GUIEVENT_HANDLER(commandFileOpen_Executed, vl::presentation::compositions::GuiEventArgs)
|
||||
CLASS_MEMBER_GUIEVENT_HANDLER(commandFileSaveAs_Executed, vl::presentation::compositions::GuiEventArgs)
|
||||
CLASS_MEMBER_GUIEVENT_HANDLER(commandFileSave_Executed, vl::presentation::compositions::GuiEventArgs)
|
||||
CLASS_MEMBER_GUIEVENT_HANDLER(window_Closing, vl::presentation::compositions::GuiRequestEventArgs)
|
||||
END_CLASS_MEMBER(demo::MainWindow)
|
||||
|
||||
#undef _
|
||||
|
||||
@@ -131,10 +131,7 @@ namespace demo
|
||||
|
||||
void MainWindow::commandFileExit_Executed(GuiGraphicsComposition* sender, vl::presentation::compositions::GuiEventArgs& arguments)
|
||||
{
|
||||
if (CanCloseFile())
|
||||
{
|
||||
Close();
|
||||
}
|
||||
Close();
|
||||
}
|
||||
|
||||
void MainWindow::commandFileNewText_Executed(GuiGraphicsComposition* sender, vl::presentation::compositions::GuiEventArgs& arguments)
|
||||
@@ -182,14 +179,34 @@ namespace demo
|
||||
SaveFile(false);
|
||||
}
|
||||
|
||||
void MainWindow::window_Closing(GuiGraphicsComposition* sender, vl::presentation::compositions::GuiRequestEventArgs& arguments)
|
||||
{
|
||||
arguments.cancel = !CanCloseFile();
|
||||
}
|
||||
|
||||
// #endregion CLASS_MEMBER_GUIEVENT_HANDLER
|
||||
|
||||
bool MainWindow::CanCloseFile()
|
||||
{
|
||||
return true;
|
||||
if (textBox->GetModified())
|
||||
{
|
||||
switch (dialogQueryClose->ShowDialog())
|
||||
{
|
||||
case INativeDialogService::MessageBoxButtonsOutput::SelectYes:
|
||||
return SaveFile(false);
|
||||
case INativeDialogService::MessageBoxButtonsOutput::SelectNo:
|
||||
return true;
|
||||
default:
|
||||
return false;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
void MainWindow::OpenFile(vint filterIndex)
|
||||
bool MainWindow::OpenFile(vint filterIndex)
|
||||
{
|
||||
if (CanCloseFile())
|
||||
{
|
||||
@@ -216,6 +233,7 @@ namespace demo
|
||||
{
|
||||
SetupTextConfig();
|
||||
}
|
||||
return true;
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -223,9 +241,10 @@ namespace demo
|
||||
}
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
void MainWindow::SaveFile(bool saveAs)
|
||||
bool MainWindow::SaveFile(bool saveAs)
|
||||
{
|
||||
WString targetFileName = fileName;
|
||||
if (saveAs || targetFileName == L"")
|
||||
@@ -237,7 +256,7 @@ namespace demo
|
||||
}
|
||||
else
|
||||
{
|
||||
return;
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -259,11 +278,13 @@ namespace demo
|
||||
{
|
||||
SetupTextConfig();
|
||||
}
|
||||
return true;
|
||||
}
|
||||
else
|
||||
{
|
||||
dialogCannotSave->ShowDialog();
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
void MainWindow::SetupTextConfig()
|
||||
|
||||
@@ -37,6 +37,7 @@ namespace demo
|
||||
void commandFileOpen_Executed(GuiGraphicsComposition* sender, vl::presentation::compositions::GuiEventArgs& arguments);
|
||||
void commandFileSaveAs_Executed(GuiGraphicsComposition* sender, vl::presentation::compositions::GuiEventArgs& arguments);
|
||||
void commandFileSave_Executed(GuiGraphicsComposition* sender, vl::presentation::compositions::GuiEventArgs& arguments);
|
||||
void window_Closing(GuiGraphicsComposition* sender, vl::presentation::compositions::GuiRequestEventArgs& arguments);
|
||||
// #endregion CLASS_MEMBER_GUIEVENT_HANDLER
|
||||
|
||||
private:
|
||||
@@ -44,8 +45,8 @@ namespace demo
|
||||
bool isXml = false;
|
||||
|
||||
bool CanCloseFile();
|
||||
void OpenFile(vint filterIndex);
|
||||
void SaveFile(bool saveAs);
|
||||
bool OpenFile(vint filterIndex);
|
||||
bool SaveFile(bool saveAs);
|
||||
void SetupTextConfig();
|
||||
void SetupXmlConfig();
|
||||
public:
|
||||
|
||||
Binary file not shown.
Binary file not shown.
Binary file not shown.
Reference in New Issue
Block a user