<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
		>
<channel>
	<title>Comments on: Code Snippets in Windows Live Writer</title>
	<atom:link href="http://www.ytechie.com/2008/05/code-snippets-in-windows-live-writer.html/feed" rel="self" type="application/rss+xml" />
	<link>http://www.ytechie.com/2008/05/code-snippets-in-windows-live-writer.html</link>
	<description>Productive software development using ASP.NET, C#, Adobe Flex, and other technologies and tools.</description>
	<lastBuildDate>Mon, 26 Jul 2010 02:01:44 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.9.2</generator>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
		<item>
		<title>By: shailesh</title>
		<link>http://www.ytechie.com/2008/05/code-snippets-in-windows-live-writer.html/comment-page-1#comment-1675</link>
		<dc:creator>shailesh</dc:creator>
		<pubDate>Sat, 02 Jan 2010 12:54:08 +0000</pubDate>
		<guid isPermaLink="false">http://www.ytechie.com/2008/05/code-snippets-in-windows-live-writer.html#comment-1675</guid>
		<description>Hi,

   Actually I am developing one plug for windows live writer. for that I made this class
using System;
using System.Windows.Forms;
using WindowsLive.Writer.Api;
using System.Net;
using System.Reflection;
using System.IO;
using System.Collections.Generic;
using System.Text;
using System.Collections;
using WindowsLive.Writer.BlogClient;
using WindowsLive.Writer.CoreServices.Settings;
using Microsoft.Win32;
using WindowsLive.Writer.BlogClient.Clients;
using WindowsLive.Writer.CoreServices;
using WindowsLive.Writer.Mshtml;
using System.Configuration;
using System.Text.RegularExpressions;
using System.Drawing;
using System.Drawing.Imaging;
namespace SamplePlugIn
{
    [WriterPlugin(&quot;a285f0bc-81ba-44ef-b1e0-70700cf62ef0&quot;, &quot;Gallery Plugin&quot;,        
         Description = &quot;Server Gallery pictures.&quot;,
- Show quoted text -

         HasEditableOptions = false)]
    //ImagePath = &quot;Images.writer_thumb.png&quot;,

    [InsertableContentSource(&quot;Picture Gallery&quot;, SidebarText = &quot;Picture Gallery&quot;)]

    public class  Plugin : SmartContentSource
    {
        public override DialogResult CreateContent(IWin32Window dialogOwner, ISmartContent content)
        {
            DialogResult result = DialogResult.Cancel;
            try
            {
                RegistrySettingsPersister persister = new RegistrySettingsPersister(Registry.CurrentUser, &quot;Software\\Microsoft\\Windows Live\\Writer\\Weblogs&quot;);

                string[] names = persister.GetSubSettings();
                for (int i = 0; i &lt; names.Length; i++)
                {
                    ISettingsPersister blogPersister = persister.GetSubSettings(names[i]);

                    SettingsPersisterHelper settings = new SettingsPersisterHelper(blogPersister);

                    CredentialsDomain domain = new CredentialsDomain(&quot;name&quot;, &quot;description&quot;, null, null);

                    BlogCredentials creds = new BlogCredentials(settings, domain);

                    string blogName = blogPersister.Get(&quot; BlogName &quot;) as string;
                    string apiurl = blogPersister.Get(&quot;PostApiUrl&quot;).ToString();
                    if (apiurl == Global.MetaUrl)
                    {
                        Global.userid = creds.Username;
                        break;
                    }

                }

                if (Global.userid != &quot;&quot;)
                {
                    PluginSettings settings = new PluginSettings(content.Properties);
                    using (frmMain form = new frmMain(content))
                    {
                        result = form.ShowDialog();                          
                    }
                }
                else
                {
                    result = DialogResult.Cancel;
                }
            }

            catch (Exception ex)
            {
                PluginDiagnostics.DisplayError(&quot;CreateContent&quot;, ex.Message);
            }
            return result;
        }
      
        public override string GeneratePublishHtml(ISmartContent content, IPublishingContext publishingContext)
        {
            string str = &quot;&quot;;
            try
            {               
                str += &quot;&quot;;           
            }
            catch (Exception ex)
            {
                PluginDiagnostics.DisplayError(&quot;Generate Html&quot;, ex.Message);
            }
            return str;

        }
     
        public override SmartContentEditor CreateEditor(ISmartContentEditorSite editorSite)
        {
            return new ContextEditor();           
        }     
    } 
}

Its actually one picture upload plugin but when GeneratePublishHtml method return, it add default tag in between my generated html tag which i dont want and due to that it is not going to call  MediaObjectInfo IMetaWeblog.NewMediaObject(...) from metaweblog api so that picture is not going to be save on my server....



I have the same problem as described in this link which i got yesterday when i was finding a solution for above problem..
http://social.msdn.microsoft.com/Forums/en/wlwdev/thread/f555955a-b96d-4e13-a078-f12df240393d

Thanks for help....</description>
		<content:encoded><![CDATA[<p>Hi,</p>
<p>   Actually I am developing one plug for windows live writer. for that I made this class<br />
using System;<br />
using System.Windows.Forms;<br />
using WindowsLive.Writer.Api;<br />
using System.Net;<br />
using System.Reflection;<br />
using System.IO;<br />
using System.Collections.Generic;<br />
using System.Text;<br />
using System.Collections;<br />
using WindowsLive.Writer.BlogClient;<br />
using WindowsLive.Writer.CoreServices.Settings;<br />
using Microsoft.Win32;<br />
using WindowsLive.Writer.BlogClient.Clients;<br />
using WindowsLive.Writer.CoreServices;<br />
using WindowsLive.Writer.Mshtml;<br />
using System.Configuration;<br />
using System.Text.RegularExpressions;<br />
using System.Drawing;<br />
using System.Drawing.Imaging;<br />
namespace SamplePlugIn<br />
{<br />
    [WriterPlugin("a285f0bc-81ba-44ef-b1e0-70700cf62ef0", "Gallery Plugin",<br />
         Description = "Server Gallery pictures.",<br />
- Show quoted text -</p>
<p>         HasEditableOptions = false)]<br />
    //ImagePath = &#8220;Images.writer_thumb.png&#8221;,</p>
<p>    [InsertableContentSource("Picture Gallery", SidebarText = "Picture Gallery")]</p>
<p>    public class  Plugin : SmartContentSource<br />
    {<br />
        public override DialogResult CreateContent(IWin32Window dialogOwner, ISmartContent content)<br />
        {<br />
            DialogResult result = DialogResult.Cancel;<br />
            try<br />
            {<br />
                RegistrySettingsPersister persister = new RegistrySettingsPersister(Registry.CurrentUser, &#8220;Software\\Microsoft\\Windows Live\\Writer\\Weblogs&#8221;);</p>
<p>                string[] names = persister.GetSubSettings();<br />
                for (int i = 0; i &lt; names.Length; i++)<br />
                {<br />
                    ISettingsPersister blogPersister = persister.GetSubSettings(names[i]);</p>
<p>                    SettingsPersisterHelper settings = new SettingsPersisterHelper(blogPersister);</p>
<p>                    CredentialsDomain domain = new CredentialsDomain(&quot;name&quot;, &quot;description&quot;, null, null);</p>
<p>                    BlogCredentials creds = new BlogCredentials(settings, domain);</p>
<p>                    string blogName = blogPersister.Get(&quot; BlogName &quot;) as string;<br />
                    string apiurl = blogPersister.Get(&quot;PostApiUrl&quot;).ToString();<br />
                    if (apiurl == Global.MetaUrl)<br />
                    {<br />
                        Global.userid = creds.Username;<br />
                        break;<br />
                    }</p>
<p>                }</p>
<p>                if (Global.userid != &quot;&quot;)<br />
                {<br />
                    PluginSettings settings = new PluginSettings(content.Properties);<br />
                    using (frmMain form = new frmMain(content))<br />
                    {<br />
                        result = form.ShowDialog();<br />
                    }<br />
                }<br />
                else<br />
                {<br />
                    result = DialogResult.Cancel;<br />
                }<br />
            }</p>
<p>            catch (Exception ex)<br />
            {<br />
                PluginDiagnostics.DisplayError(&quot;CreateContent&quot;, ex.Message);<br />
            }<br />
            return result;<br />
        }</p>
<p>        public override string GeneratePublishHtml(ISmartContent content, IPublishingContext publishingContext)<br />
        {<br />
            string str = &quot;&#8221;;<br />
            try<br />
            {<br />
                str += &#8220;&#8221;;<br />
            }<br />
            catch (Exception ex)<br />
            {<br />
                PluginDiagnostics.DisplayError(&#8220;Generate Html&#8221;, ex.Message);<br />
            }<br />
            return str;</p>
<p>        }</p>
<p>        public override SmartContentEditor CreateEditor(ISmartContentEditorSite editorSite)<br />
        {<br />
            return new ContextEditor();<br />
        }<br />
    }<br />
}</p>
<p>Its actually one picture upload plugin but when GeneratePublishHtml method return, it add default tag in between my generated html tag which i dont want and due to that it is not going to call  MediaObjectInfo IMetaWeblog.NewMediaObject(&#8230;) from metaweblog api so that picture is not going to be save on my server&#8230;.</p>
<p>I have the same problem as described in this link which i got yesterday when i was finding a solution for above problem..<br />
<a href="http://social.msdn.microsoft.com/Forums/en/wlwdev/thread/f555955a-b96d-4e13-a078-f12df240393d" rel="nofollow" onclick="pageTracker._trackPageview('/outgoing/social.msdn.microsoft.com/Forums/en/wlwdev/thread/f555955a-b96d-4e13-a078-f12df240393d?referer=');">http://social.msdn.microsoft.com/Forums/en/wlwdev/thread/f555955a-b96d-4e13-a078-f12df240393d</a></p>
<p>Thanks for help&#8230;.</p>
]]></content:encoded>
	</item>
</channel>
</rss>
