.NET Tutorials, Forums, Interview Questions And Answers
Welcome :Guest
Sign In
Win Surprise Gifts!!!

Top 5 Contributors of the Month
Gaurav Pal
Post New Web Links

WPF RichTextBox and Images(Emoticons)

Posted By:      Posted Date: May 22, 2011    Points: 0   Category :JQuery

Hi all,

I have been writing an IM client with WPF and have gotten stuck when I wanted to add emoticons. As input box(where the user types his/hers instant message) I use and RichTextBox. The problem I face is how to insert and emoticon at the CaretPosition when the user selects en emoticon from a ComboxBox in the UI.

I have three cases where I want to insert the emoticons relative to a Inline:

1. The CaretPosition is at the start of an Inline and I want to insert before the Inline

2. The CaretPosition is at the end of an Inline and I want to insert after the Inline

3. The CaretPosition is inside an Inline. In this I want to split the Inline at the CaretPosition and insert an InlineUIContainer(Emoticon) and create 2 new Inlines before and after and then remove the original inline.

The code pasted I pasted is throwing two types of exception when the third case is true:


'start' not expected after 'end'.

'Run' PreviousSibling does not belong to this TextElementCollection.


Here's the code. Can anyone help me on this?




     public ICommand InsertEmoticonCommand

View Complete Post

More Related Resource Links

WPF RichTextBox - saving images


Hi all.


1. Create RichTextBox control and type some text inside

2. Draw anything e.g. in the Paint

3. Copy some part of image to the clipboard

4. Paste it into the RTB (it appears correctly, all seems to be good)

5. Save contents with:

     MemoryStream Src = new MemoryStream();
     new TextRange(RTB.Document.ContentStart, RTB.Document.ContentEnd).Save(Src, System.Windows.DataFormats.Rtf);

6. Load it using:

     new TextRange(RTB.Document.ContentStart, RTB.Document.ContentEnd).Load(Src, System.Windows.DataFormats.Rtf);

7. Image is lost while text is still present.

The same story is with DataFormats.Xaml at least.

Can anybody say how to save RTF with image from WPF RTB? Thanx in advance.




Images in WPF

How to create a Thumbnail of an Image. How to automatically crop an image. The following method allows you to automatically crop an image to it's content.

Reading and Writing Images From a Windows Mobile Database using UltraLite 10(C#)

Periodically I get a request for information on how to read and write binary data to a database running on Windows Mobile. If you search the Internet you can typically find examples that are available on Windows Desktops or allow you to read and write to a local file system. The problem is that it can take a bit of work to get this code to work on Windows Mobile accessing a database.

Ultimately you might be asking, why would I want to store and image in a database? Well in an environment where you synchronizing data between a local mobile database and a consolidated (central) database this can be extremely useful. Imagine if an insurance adjuster went to an accident scene, took a picture of a damaged car, loaded it into his Windows Mobile database and then replicated that image up to the Insurance headquarters for approval. All of this could be done in a very short period of time when using images in the database. Another good example might be a doctor who was waiting for a patient chart to become available. If you could store the image in a database this chart could be sent down to the doctor's device once it became available.

For this article I am not going to get into how to synchronize the images to and from a remote and central database as this is typically fairly straightforward when using a data synchronization technologies like MobiLink

Save images to SQL CE

Storing binary objects (such as image, office document etc.) into database is a little cumbersome when it comes to retrieval. Hence the most commonly accepted way is only store the file path in the database, and to store the documents on a file share.

Store and Display Images from MS Access Database Using C#

There is only the difference of coding syntax to stream the binary data of image content type to upload it into MS Access Database using C#/VB in ASP.Net 2.0

Namespaces required:-
using System.Data.OleDb;

OleDb is used to connect the web site forms with MS Access Database using Microsoft.Jet.OLEDB.4.0

Open File Print File Excel

Batch print many Excel files without having to open each one at a time. Quickly print mass amounts of xls files at once with this program. You must have Excel installed on your machine..

The Free Barcode Creator produces barcode images one at a time, and allows easy saving to a file or

The Free Barcode Creator produces barcode images one at a time, and allows easy saving to a file or pasting into an application. 2D versions are also available:

Browsing all Images in Directory ... ?! asp.net & C#


Hi every one ... How are you ??

OK ... I want to make album ... I try to make it using buttons( next & pre ) using imageButton control and variable (i)

So ... each next (++i) & pre ( --i) to show allimages in directory ("photo")

Here my code in C#  ::

using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using System.Xml.Linq;
using System.IO;
using System.Collections.Generic;

namespace iThinkerWebSite
    public partial class photos : System.Web.UI.Page

       // LinkedList<string> names = admin.getNames();
        DirectoryInfo dir;
        FileInfo[] files;
        static int i = -1;
        static int l = 0;

        protected void Page_Load(object sender, EventArgs e)
            dir = new DirectoryInfo(MapPath("photo"));
            files = dir.GetFiles();
            //l = (int)names.LongCount();
            l = files.Length;
            if (l == 0)
                Label2.Text = "No Photo to Display !!";
            Image2.ImageUrl = "images/ith.png";

Displaying Dicom images..........



Please guide

  1. How to display Dicom images in .net web apllications.
  2. How can i convert Dicom images to Jpeg.
  3. Can uplease provide me with a sample web application??

css and images gone on url rewriting


 I have a program which rewrites a url to a form     website.com/Default.aspx/name/articleid

The Program works fine ,but after URL rewriting my css sheet and images are gone . 

I am new to this and I have read that I should map my css and images to root. 

So ,I hav done some change to the path files of css and images but it stilll doesnt work .

Plz help me over this ...... 

<%@ Page Language="C#" AutoEventWireup="true" CodeFile="TBV.aspx.cs" Inherits="TBV" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title>Article Page</title>
    <link rel="index" href="~/" title="Home" />
    <link rel="Stylesheet" media="screen,projection" type="text/css" href="~/css/main.css" />
    <link rel="stylesheet" media="print" type="text/css" href="~/css/print.css" />
    <link rel="stylesheet"

image.save not saving images


I have a piece of code that writes string into an image and save it. It works on one of my site and but not the other. The image.save is not working. If this is a permission problem, which account should I change? I use win server 2003 and IIS 6, and have given ASPNET, NETWORK SERVICE, and anonymous user write access.

Vector Graphics: Build Flexible, Lightweight XML-Based Images for ASP.NET Using Scalable Vector Grap


Scalable Vector Graphics (SVG), a W3C graphics standard built around XML, is one of several vector graphics technologies that allows fast, lightweight drawings such as charts and graphs to be rendered on the fly in an appropriate viewer. There are many advantages to such vector graphics, including conservation of bandwidth and storage media, and flexibility. This article explains these benefits and shows you how to easily add powerful, dynamic, interactive visual elements to your Web applications.

Dennis Forbes

MSDN Magazine July 2003

ASP.NetWindows Application  .NET Framework  C#  VB.Net  ADO.Net  
Sql Server  SharePoint  Silverlight  Others  All   

Hall of Fame    Twitter   Terms of Service    Privacy Policy    Contact Us    Archives   Tell A Friend