Wednesday, November 30, 2011

Escaping XML

I found out about a neat function which can escape the XML content.

InnerXml = System.Security.SecurityElement.Escape(stringtoescape);
               
A simple inbuilt class like this can save you some time in trying to write your own function.


Tooltip in Windows Form Listbox Items

There was a request to provide tooltip for the items in the Listbox control.

The key idea is, selecting the listbox Index from the system point.

Here is the code.

Happy coding !

    private void listBoxControl_MouseMove(object sender, MouseEventArgs e)
    {
        if (this.listBoxControl.SelectedIndex == -1)
        {
            TurnOffTooltip();
            return;
        }
        if (sender is ListBox)
        {
            int selectedIndex = this.listBoxControl.SelectedIndex;
            ListBox listBox = (ListBox)sender;
            System.Drawing.Point point = new System.Drawing.Point(e.X, e.Y);
            int hoverIndex = listBox.IndexFromPoint(point);
            if (hoverIndex >= 0 && hoverIndex < listBox.Items.Count && hoverIndex == selectedIndex)
            {
                TurnOnTooltip();
            }
            else
            {
                TurnOffTooltip();
            }
        }
    }
 
    private void listBoxControl_MouseLeave(object sender, EventArgs e)
    {
        TurnOffTooltip();
    }
 
    private void TurnOffTooltip()
    {
        this.toolTip.SetToolTip(this.listBoxControl, "");
        this.toolTip.Hide(this.listBoxControl);
        return;
    }
 
    private void TurnOnTooltip()
    {
        SomeClass someClassObject = (SomeClass)this.listBoxControl.SelectedItem;
        DisplayTooltip(someClassObject);
    }
 
    private void DisplayTooltip(SomeClass someClassObject)
    {
        string toDisplay = "Overlay Item : " + someClassObject.m_ILAOverlayItem.Name;
        toDisplay = toDisplay + "\n" + "Impact Analysis Config : " + someClassObject.m_ILAimpactLayerConfig.ILConfigName;
        toDisplay = toDisplay + "\n" + "GIS Layer : " + someClassObject.m_ILAimpactLayerConfig.GetGISLayerName();
        toDisplay = toDisplay + "\n" + "Overlay Item : " + someClassObject.m_ILAOverlayItem.Name;
        toDisplay = toDisplay + "\n" + "Inside Status Code : " + someClassObject.m_ILAInsideStatusCode[0].ToString();
        toDisplay = toDisplay + "\n" + "Is Published : " + someClassObject.m_IsPublished.ToString();
        this.toolTip.SetToolTip(this.listBoxControl, toDisplay);
        this.toolTip.Show(toDisplay, this.listBoxControl);
    }
 
    private void listBoxControl_SelectedIndexChanged(object sender, EventArgs e)
    {
        if (this.listBoxControl.SelectedItem != null)
        {
            SomeClass someClassObject = (SomeClass)this.listBoxControl.SelectedItem;
            TurnOnTooltip();
        }
    }




ArcIMS Error 1722 during installation


When installing ArcIMS, I got the following error.


After some research I found the following solution

1. Goto Control Panel-> Services
2. Stop All ArcIMS /ArcGIS Services.
3. Stop Tomcat
4. Restart IIS.

Now install the ArcIMS Application /Service pack and the Error will not Repeat again.

Hope this saves some time for you.

All Blogs so far ...