Example #1
0
        private async void OpenCommandExecute()
        {
            var dialog = new OpenFileDialog
            {
                Multiselect     = false,
                Filter          = "tap files (*.tap)|*.tap|nc files (*.nc)|*.nc|text files (*.txt)|*.txt|cnc files (*.cnc)|*.cnc|All files (*.*)|*.*",
                CheckFileExists = true,
                CheckPathExists = true,
            };
            var result = dialog.ShowDialog();

            if (result ?? false)
            {
                await _machineSimulator.OpenFileAsync(dialog.FileName);
            }
        }
Example #2
0
        private async void OpenByDropCommandExecute(DragEventArgs param)
        {
            try
            {
                if (param?.Data == null || !(param.Data.GetData(DataFormats.FileDrop, false) is string[] strings))
                {
                    return;
                }
                var path = strings.FirstOrDefault();
                if (string.IsNullOrEmpty(path) || !File.Exists(path))
                {
                    return;
                }

                await _machineSimulator.OpenFileAsync(path);
            }
            catch (Exception ex)
            {
                _logger?.Log(ex.Message, Category.Exception, Priority.High);
                throw;
            }
        }