Ejemplo n.º 1
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
            }
        }
Ejemplo n.º 2
0
        public void OpenFile(string url, IFSPlugin fsplugin)
        {
            doc.LoadXml( Encoding.Default.GetString(fsplugin.GetFileContent(url)));

            if (doc.ChildNodes.Count > 0)
            {
                int deep = 0;
                foreach (XmlNode n in doc.ChildNodes)
                {
                    if (n.NodeType != XmlNodeType.XmlDeclaration) //skip "<?xml version=... codepage=..."
                    {
                        XmlDisplay child_xd = new XmlDisplay(n, ht) { Tag = n, MarginLeft = ((deep > 0) ? 12 : 0) };
                        layout.PackStart(child_xd); //обеспечивается рекурсивность
                    }
                }
                sw = new ScrollView(layout);
            }
            else
            {
                XmlDisplay xd = new XmlDisplay(doc.ChildNodes[0], ht);
                sw = new ScrollView(xd);
            }
        }