Ejemplo n.º 1
0
 public ImageViewer(WindowSystem _winsys) : base(_winsys)
 {
     Title  = "Image Viewer";
     Width  = 640;
     Height = 480;
     AddChild(open);
     open.Click += (sender, e) => gui.AskForFile(false, (path) => load(path));
     img         = null;
 }
Ejemplo n.º 2
0
        /// <inheritdoc/>
        public TextEditorApp(WindowSystem _winsys) : base(_winsys)
        {
            Title  = "New document - Text Editor";
            Width  = 700;
            Height = 600;
            AddChild(_open);
            AddChild(_save);
            AddChild(_new);
            AddChild(_editor);


            _new.Click += (o, a) =>
            {
                _editor.Text = "";
                Title        = "New document - Text Editor";
                _path        = null;
            };
            _open.Click += (o, a) =>
            {
                _guiutils.AskForFile(false, (file) =>
                {
                    try
                    {
                        _editor.Text = _fs.ReadAllText(file);
                        Title        = $"{_futils.GetNameFromPath(file)} - Text Editor";
                        _path        = file;
                    }
                    catch (InvalidDataException)
                    {
                        _infobox.Show("Text Editor", $"'{file}' contains invalid characters and could not be opened.  Are you sure it's a text document?");
                    }
                });
            };
            _save.Click += (o, a) =>
            {
                _guiutils.AskForFile(true, (file) =>
                {
                    _fs.WriteAllText(file, _editor.Text);
                    Title = $"{_futils.GetNameFromPath(file)} - Text Editor";
                    _path = file;
                });
            };
        }