Beispiel #1
0
        private void Save(bool setFileName)
        {
            if (string.IsNullOrEmpty(FilePath) || setFileName)
            {
                var dlg = new FileDialog(FileDialogMode.SaveFile)
                {
                    Filter = "*.ui"
                };

                if (!string.IsNullOrEmpty(FilePath))
                {
                    dlg.FilePath = FilePath;
                }
                else if (!string.IsNullOrEmpty(_lastFolder))
                {
                    dlg.Folder = _lastFolder;
                }

                dlg.ShowModal(_desktop);

                dlg.Closed += (s, a) =>
                {
                    if (dlg.Result)
                    {
                        ProcessSave(dlg.FilePath);
                    }
                };
            }
            else
            {
                ProcessSave(FilePath);
            }
        }
Beispiel #2
0
        private void OpenItemOnClicked(object sender, EventArgs eventArgs)
        {
            var dlg = new FileDialog(FileDialogMode.OpenFile)
            {
                Filter = "*.ui"
            };

            if (!string.IsNullOrEmpty(FilePath))
            {
                dlg.Folder = Path.GetDirectoryName(FilePath);
            }
            else if (!string.IsNullOrEmpty(_lastFolder))
            {
                dlg.Folder = _lastFolder;
            }

            dlg.Closed += (s, a) =>
            {
                if (!dlg.Result)
                {
                    return;
                }

                var filePath = dlg.FilePath;
                if (string.IsNullOrEmpty(filePath))
                {
                    return;
                }

                Load(filePath);
            };

            dlg.ShowModal(_desktop);
        }