Esempio n. 1
0
 public bool TryGetOpenEditorCallback(
     string path,
     out OpenEditorCallback openEditor)
 {
     return Associations.TryGetValue(
         path,
         out openEditor);
 }
Esempio n. 2
0
 public void OpenFile(
     IWin32Window owner,
     string path,
     OpenEditorCallback openEditor)
 {
     Owner = owner;
     OpenFile(path, openEditor);
 }
Esempio n. 3
0
 public void AddAssociation(
     string extension,
     string description,
     string editorClass,
     OpenEditorCallback openEditorCallback)
 {
     OpenWithForm.AddAssociation(
         extension,
         description,
         editorClass,
         openEditorCallback);
 }
Esempio n. 4
0
        public void OpenFile(OpenEditorCallback openEditor)
        {
            var files = UIChooseFiles();
            if (files is null)
            {
                return;
            }

            foreach (var file in files)
            {
                OpenFile(file, openEditor);
            }
        }
Esempio n. 5
0
        protected virtual bool TryOpenFile(
            string path,
            OpenEditorCallback openEditor,
            out IEditor editor)
        {
            if (openEditor is null)
            {
                editor = null;
                return false;
            }

        loop:
            try
            {
                editor = openEditor(path);
            }
            catch (IOException ex)
            {
                if (ExceptionHandler is null)
                {
                    throw ex;
                }

                if (ExceptionHandler.ShowExceptionAndRetry(ex))
                {
                    goto loop;
                }
                else
                {
                    editor = null;
                    return false;
                }
            }
            catch (Exception ex)
            {
                if (ExceptionHandler is null)
                {
                    throw ex;
                }

                ExceptionHandler.ShowException(ex);

                editor = null;
                return false;
            }

            return true;
        }
Esempio n. 6
0
        public void AddAssociation(
            string extension,
            string description,
            string editorClass,
            OpenEditorCallback openEditorCallback)
        {
            var association = new OpenFileAssociation()
            {
                Extension          = extension,
                Description        = description,
                EditorClass        = editorClass,
                OpenEditorCallback = openEditorCallback,
            };

            AddAssociation(association);
        }
Esempio n. 7
0
        public void OpenFile(string path, OpenEditorCallback openEditor)
        {
            if (openEditor is null)
            {
                throw new ArgumentNullException(
                    nameof(openEditor));
            }

            if (!TryOpenFile(path, openEditor, out var editor))
            {
                return;
            }

            if (editor is null)
            {
                return;
            }

            OnEditorOpened(new EditorEventArgs(editor));
        }
Esempio n. 8
0
 public void AddAssociation(
     string extension,
     OpenEditorCallback openEditorCallback)
 {
     Associations.Add(extension, openEditorCallback);
 }
Esempio n. 9
0
 public void OpenFile(IWin32Window owner, OpenEditorCallback openEditor)
 {
     Owner = owner;
     OpenFile(openEditor);
 }