Example #1
0
 public static CustomRenderer Create()
 {
     self = new CustomRenderer();
     return self;
 }
Example #2
0
 public CustomRenderer()
 {
     self = this;
 }
Example #3
0
 public static CustomRenderer Create()
 {
     self = new CustomRenderer();
     return(self);
 }
Example #4
0
 public CustomRenderer()
 {
     self = this;
 }
        public void Start(string szURL, IInternetProtocolSink sink, IInternetBindInfo pOIBindInfo, uint grfPI, uint dwReserved)
        {
            //Debug.WriteLine("xxHelpAsyncPluggableProtocolHandler.Start(" + szURL + ")");

            String mimeType = "text/html";
                // type = "text" / "image" / "audio" / "video" / "application" / extension-token
                //type/subtype eg. "text/html", "image/png", "image/gif", "video/mpeg", "text/css", and "audio/basic"

            if (MsxhelpProtocol.Catalog == null || !MsxhelpProtocol.Catalog.IsOpen)
            {
                _stream = null;
            }
            else
            {
                try
                {
                    if (_customRenderer == null)
                        _customRenderer = CustomRenderer.Create();

                    String topicID;
                    Boolean isTopicUrl = _customRenderer.IsTopicUrl(szURL, out topicID);

                    // -----------------------------------------------------------------------
                    // debug - Host wants to see raw HTML from .mshc

                    if (MsxhelpProtocol .RawCodeHandler != null)
                    {
                        try
                        {
                            if (isTopicUrl && String.IsNullOrEmpty(MsxhelpProtocol.UserTopicText))  // Topic with no text overload
                            {
                                _stream = _customRenderer.UrlToStream(szURL, false);  // false = No Render.
                                if (this._stream != null)
                                {
                                    _stream.Position = 0;
                                    StreamReader reader = new StreamReader(_stream);
                                    String text = reader.ReadToEnd();
                                    MsxhelpProtocol.RawCodeHandler(text);    //send text to main form
                                    this._stream.Close();
                                    this._stream = null;
                                }
                            }
                        }
                        catch
                        {
                            //suck it up.. the next bit is the important part
                        }
                    }

                    // -----------------------------------------------------------------------
                    // render - Web browser wants rendered code

            //                    if (MsxhelpProtocol.RenderUsingVS)  // Requires VS 11 DLL (Microsoft.VisualStudio.Help.DLL)
            //                    {
            //                        if (_vsRenderer == null)                      //will crash if VS not installed
            //                            _vsRenderer = new TopicRenderer();

             //                       _stream = (Stream)_vsRenderer.ProcessLink(szURL, (ICatalog)MsxhelpProtocol.Catalog, null/*_renderParameters*/);
            //                    }
            //                    else  // basic render code supplied with this SDK -- Good for Win 8 where VS 11 not installed
                    {
                        _stream = _customRenderer.UrlToStream(szURL);
                        _stream.Position = 0;
                    }
                }
                catch
                {
                    _stream = null;
                }
            }

            if (_stream != null)
            {
                //Set Mime type
                uint BINDSTATUS_MIMETYPEAVAILABLE = 13;
                if (mimeType != "")
                    sink.ReportProgress(BINDSTATUS_MIMETYPEAVAILABLE, mimeType);

                sink.ReportData(BSCF.LASTDATANOTIFICATION | BSCF.DATAFULLYAVAILABLE, (uint)_stream.Length, (uint)_stream.Length);
                sink.ReportResult((uint)HRESULT.S_OK, 200, null);
            }
            else
                sink.ReportResult((uint)HRESULT.INET_E_OBJECT_NOT_FOUND, 404, "Cannot find the goods");
        }