How to get Website Thumbnail in C#

How to get Website Thumbnail in C# | Codality

« New week, new toy
UpTime.Net »
How to get Website Thumbnail in C#

[Edit: I’ve posted it on CodeProject and there are some greatl people commenting on it that did the investigation on ho to wrap it in a STA Thread and make it a part of your ASP.Net solution – really cool stuff!]

An interesting use case. Darek (our beloved sys admin – we all bow to him and worship his skills) has recently asked if it’s possible to write a .net application to make a thumbnail of a website. Which is pretty trivial with Windows forms actually.

All you really need to do is drop a WebBrowser on your form and once it’s loaded the page call:

IECapt

IECapt – A Internet Explorer Web Page Rendering Capture Utility

IECapt

IECapt is a small command-line utility to capture Internet Explorer’s rendering of a web page into a BMP, JPEG or PNG image file. The C++ version also has experimental support for Enhanced Metafile vector graphic output. IECapt is available in a C++ and a C# version.

See CutyCapt for a Qt and WebKit (Safari) based cross-platform alternative to IECapt.

VB.Net Tutorial on Webpage Screen capture


VB.Net Tutorial on Webpage Screen capture

Website Screen Capture [ VB .Net Tutorial ]

Again taking the screenshot of the given webpage is much easier using the built in function DrawToBitmap of Web Browser component which yields a bitmap image. This image can be either saved in the hard disk or can be forced into the response stream for displaying in another webpage.
Source Code for the Tutorial
Imports Microsoft.VisualBasic
Imports System.Threading
Imports System.Drawing
Imports System.Windows.Forms

Public Class ImageFromHtml
Private PageUrl As String
Private ConvertedImage As Bitmap

Private m_intHeight As Integer
Public Property Height() As Integer
Get
Return m_intHeight
End Get
Set(ByVal value As Integer)
m_intHeight = value
End Set
End Property

Private m_intWidth As Integer
Public Property Width() As Integer
Get
Return m_intWidth
End Get
Set(ByVal value As Integer)
m_intWidth = value
End Set
End Property

Public Function ConvertPage(ByVal PageUrl As String) As Bitmap
Me.PageUrl = PageUrl
Dim thrCurrent As New Thread(New ThreadStart(AddressOf CreateImage))
thrCurrent.SetApartmentState(ApartmentState.STA)
thrCurrent.Start()
thrCurrent.Join()
Return ConvertedImage
End Function
Private Sub CreateImage()

Dim BrowsePage As New WebBrowser()
BrowsePage.ScrollBarsEnabled = False
BrowsePage.Navigate(PageUrl)
AddHandler BrowsePage.DocumentCompleted, AddressOf _
WebBrowser_DocumentCompleted

While BrowsePage.ReadyState <> WebBrowserReadyState.Complete
Application.DoEvents()
End While
BrowsePage.Dispose()
End Sub

Private Sub WebBrowser_DocumentCompleted(ByVal sender As Object, ByVal e As _
WebBrowserDocumentCompletedEventArgs)
Dim BrowsePage As WebBrowser = DirectCast(sender, WebBrowser)
BrowsePage.ClientSize = New Size(Width, Height)
BrowsePage.ScrollBarsEnabled = False
ConvertedImage = New Bitmap(Width, Height)
BrowsePage.BringToFront()
BrowsePage.DrawToBitmap(ConvertedImage, BrowsePage.Bounds)
End Sub

End Class

Cascading ExtJs combobox

Cascading ExtJs combobox

Below is the way it works.

//function that gets city store
function getCityStore()
{
var store = new Ext.data.JsonStore({
url: ‘get-city-by-country-id’,
//baseParams: countryId:countryIdVar,
fields: [
{name:’cityId’, type:’int’},
‘cityName’
]
});
return store;
}

//than I have a countries combo
var countries = new Ext.form.ComboBox({
id:’country’,
store: getCountryStore(),
typeAhead: true,
triggerAction: ‘all’,
emptyText: ‘…’,
listeners: {
select: {
fn:function(combo, value) {
var modelDest = Ext.getCmp(‘city’);
//set and disable cities
modelDest.setDisabled(true);
modelDest.setValue(“);
modelDest.store.removeAll();
//reload region store and enable region
modelDest.store.reload({
params: { countryId: combo.getValue() }
});
modelReg.setDisabled(false);
}
}
}
})

Hope it will help someone … :)

I am creating a form dynamically from the fields returned from server using json

extjs add plugins to dynamic form fields – Stack Overflow

0 down vote favorite

I am creating a form dynamically from the fields returned from server using json e.g. data is

“items": [
{“xtype": “textfield", “fieldLabel": “Name", “name": “name"},
{“xtype": “textfield", “fieldLabel": “Description", “name": “description"},
{“xtype": “textarea", “fieldLabel": “Text", “name": “text"}
],

Now I want to add a custom plugin to each field usually on client side I do this

plugins:new Ext.ux.plugins.MyPlugin()

but as my form fields are coming from server, how can I add plugin to field e.g. something like this (but that doesn’t work)

“plugins": “Ext.ux.plugins.MyPlugin"

forms extjs
link|flag

asked Mar 29 at 7:00
Anurag Uniyal
10.3k21836

91% accept rate

1 Answer
oldest newest votes
up vote 1 down vote accepted

You can also register plugins with a “ptype":

MyPlug = Ext.extend(Object, {
init : function(c){
console.log(‘fire’);
}
});
Ext.preg(‘myplug’, MyPlug);

new Ext.Component({
plugins: [{ptype: ‘myplug’}]
});

How do I determine if a particular object is a view and not a table?

SQL Server Helper – Frequently Asked Questions – SQL Server Views

To determine if a particular object is a view, you have to use the OBJECTPROPERTY metadata function.

OBJECTPROPERTY ( id, property )

The OBJECTPROPERTY metadata function, which returns information about objects in the current database, accepts two parameters, namely the id, which is the ID of the object in the current database, and the property, which is the information to be returned for the object specified by id. To determine if an object is a view, you will use the IsView property.

IF OBJECTPROPERTY( OBJECT_ID( ‘[dbo].[Customers]’ ), ‘IsView’ ) = 1
PRINT ‘Object is a view’

In this script, the OBJECTPROPERY metadata function will return a value of 1 if the object is a view. Otherwise, it will return a value of 0. If the object passed to the function is not a valid object in the current database, the function will return a value of NULL.

Force focus on invalid field after form validation

Force focus on invalid field after form validation

事實上, 要這麼寫:
if (this.getForm().isValid() == false){
        var firstInvalid ;
        this.getForm().items.each(function(f){
        if(!f.isValid(true)){
                firstInvalid = f;
            }
        });
        if (firstInvalid) {
            alert (firstInvalid ‘欄位不得為空白2’);
            firstInvalid.focus();
        }
           //alert (‘欄位不得為空白’)
           return;
        }
        alert (‘存檔完成’)

App Inventor for Android,寫手機程式真簡單

App Inventor for Android,寫手機程式真簡單 | T客邦 – 我只推薦好東西

開發iPhone程式雖然不難,但是你要搞懂Object-C是什麼,同時還要花一筆錢才能加入iPhone開發者會員,才能做上架或是實機測試。Google不但推出App Inventor for Android免費開發工具,而且操作直覺,只要拖拉就可以完成簡單的Android程式,標榜不懂程式也沒問題。

QtdSync:Windows、Linux通通交給我備份

QtdSync:Windows、Linux通通交給我備份 | T客邦 – 我只推薦好東西

常用命令列管理Linux系統的人,一定對Linux上的rsync程式印象深刻。因為它是Linux上最常使用的備份、同步程式。rsync的功能強大,它不但可以同步本機資料夾,更厲害的是可以同步遠端伺服器上的資料夾,而還可以透過SSH加密保護你的同步資料。這麼好用的程式Windows沒有嗎?行!