Exemplo n.º 1
0
Arquivo: VEd.cs Projeto: AVert/fcmd
        /// <summary>Load the file in the VE (with plugin autodetection)</summary>
        /// <param name="URL">The file's URL</param>
        /// <param name="FS">The file's filesystem</param>
        /// <param name="AllowEdit">Mode of VE: true=editor, false=viewer</param>
        public void LoadFile(string URL, pluginner.IFSPlugin FS, bool AllowEdit)
        {
            byte[]       ContentBytes = FS.GetFileContent(URL);
            string       content      = (ContentBytes != null && ContentBytes.Length > 0) ? Encoding.UTF8.GetString(ContentBytes) : "";
            pluginfinder pf           = new pluginfinder();

            try
            {
                string GottenHeaders;
                if (content.Length >= 20)
                {
                    GottenHeaders = content.Substring(0, 20);
                }
                else
                {
                    GottenHeaders = content;
                }
                LoadFile(URL, FS, pf.GetFCVEplugin("NAME=" + URL + "HEADERS=" + GottenHeaders), AllowEdit);
            }
            catch (pluginfinder.PluginNotFoundException ex)
            {
                Console.WriteLine("ERROR: VE plugin is not loaded: " + ex.Message + "\n" + ex.StackTrace);
                Xwt.MessageDialog.ShowError(Locale.GetString("FCVE_PluginNotFound"));
                LoadFile(URL, FS, new base_plugins.ve.PlainText(), AllowEdit);
            }
            catch (Exception ex)
            {
                Xwt.MessageDialog.ShowError(string.Format(Locale.GetString("FCVE_LoadError"), ex.Message));
                Console.WriteLine("ERROR: VE can't load file: " + ex.Message + "\n" + ex.StackTrace);
                return;
            }
        }
Exemplo n.º 2
0
        /// <summary>Load the file in the VE (with plugin autodetection)</summary>
        /// <param name="URL">The file's URL</param>
        /// <param name="FS">The file's filesystem</param>
        /// <param name="AllowEdit">Mode of VE: true=editor, false=viewer</param>
        public void LoadFile(string URL, IFSPlugin FS, bool AllowEdit)
        {
            try
            {
                byte[] ContentBytes = FS.GetFileContent(URL);
                string content = (ContentBytes != null && ContentBytes.Length > 0) ? Encoding.UTF8.GetString(ContentBytes) : "";
                pluginfinder pf = new pluginfinder();

                string GottenHeaders;
                if (content.Length >= 20) GottenHeaders = content.Substring(0, 20);
                else GottenHeaders = content;
                LoadFile(URL, FS, pf.GetFCVEplugin("NAME=" + URL + "HEADERS=" + GottenHeaders), AllowEdit);
            }
            catch (pluginfinder.PluginNotFoundException ex)
            {
            // ReSharper disable LocalizableElement
                Console.WriteLine("ERROR: VE plugin is not loaded: " + ex.Message + "\n" + ex.StackTrace);

                MessageDialog.ShowError(Localizator.GetString("FCVE_PluginNotFound"));
                LoadFile(URL, FS, new PlainText(), AllowEdit);
            }
            catch (Exception ex)
            {
                MessageDialog.ShowError(string.Format(Localizator.GetString("FCVE_LoadError"),ex.Message));
                Console.WriteLine("ERROR: VE can't load file: " + ex.Message + "\n" + ex.StackTrace);
            // ReSharper restore LocalizableElement
            }
        }