#include <xtd/forms/application>
#include <xtd/forms/button>
#include <xtd/forms/form>
#include <xtd/forms/message_box>
#include <xtd/forms/save_file_dialog>
#include <xtd/forms/text_box>
#include <xtd/io/stream_writer>
#include <xtd/timers/timer>
#include <xtd/date_time>
#include <xtd/startup>
#include <memory>
namespace timer_example {
class form1 :
public form {
public:
static void main() {
}
form1() {
initialize_component();
text(
"Quick Text Editor");
text_box1.multiline(true);
save_file_dialog1.filter("txt files (*.txt)|*.txt|All files (*.*)|*.*");
save_file_dialog1.restore_directory(true);
timer.elapsed += {*
this, &form1::prompt_for_save};
timer.synchronizing_object(*
this);
}
private:
void initialize_component() {
form_closing += {*this, &form1::form1_form_closing};
controls().push_back_range({text_box1,
button1});
button1.click += {*
this, &form1::button1_click};
text_box1.text_changed += {*this, &form1::text_box1__text_changed};
}
if (has_changed && !dialog_is_open) {
elapsed_minutes++;
dialog_is_open = true;
if (
message_box::show(string::format(
"{0} minutes have elapsed since the text was saved. Save it now? ",
elapsed_minutes), "Save Text",
}
dialog_is_open = false;
}
void button1_click(
object& sender,
const event_args&
e) {
}
txt = text_box1.text();
has_changed = false;
}
sw->write(txt);
sw->close();
}
}
void text_box1__text_changed(
object& sender,
const event_args&
e) {
has_changed = true;
}
bool dialog_is_open = false;
int elapsed_minutes = 0;
bool has_changed = false;
string txt;
};
}
bool is_empty() const noexcept
Definition basic_string.hpp:1503
Represents the base class for classes that contain event data, and provides a value to use for events...
Definition event_args.hpp:18
static const event_args empty
Provides a value to use with events that do not have event data.
Definition event_args.hpp:25
Represents a standard Windows text box.
Definition text_box.hpp:31
Provides data for the xtd::timers::timer::elapsed event.
Definition elapsed_event_args.hpp:18
Generates an event after a set interval, with an option to generate recurring events.
Definition timer.hpp:50
#define startup_(main_method)
Defines the entry point to be called when the application loads. Generally this is set either to the ...
Definition startup.hpp:167
null_ptr null
Represents a null pointer value.
xtd::sptr< type_t > ptr
The xtd::ptr object is a shared pointer.
Definition ptr.hpp:27
ptr< type_t > new_ptr(args_t &&... args)
The xtd::new_ptr operator creates a xtd::ptr object.
Definition new_ptr.hpp:24
@ e
The E key.
Definition console_key.hpp:96
The xtd::io namespace contains types that allow reading and writing to files and data streams,...
Definition binary_reader.hpp:17
Contains classes that represent ASCII and Unicode character encodings; abstract base classes for conv...
Definition basic_string_builder.hpp:16
Provides the xtd::timers::timer component, which allows you to raise an event on a specified interval...
Definition elapsed_event_args.hpp:11
The xtd namespace contains all fundamental classes to access Hardware, Os, System,...
Definition abstract_object.hpp:8