Archive for Agosto 4th, 2008

HSCObjectParamRules.OnClick()

CodeKeep C# Feed Agosto 4th, 2008

Description: with OEM00001122 modifications

Link: http://www.codekeep.net/snippets/9cb8189a-9955-4449-a92a-656d0b84b273.aspx

public void OnClick()
        {
            bool isProjectModified = SystemInstances.Engine.Projects.PrimaryProject.Dirty;
            isProjectModified = true;

            IHardwareObject hwdObject = _editorFrame.GetHardwareObject(false);
            if (hwdObject != null)
            {
                IDeviceObject device;
                if(isProjectModified)
                    device = hwdObject.GetDeviceObjectToModify();
                else
                    device = hwdObject.GetDeviceObjectToRead();

                hwdObject = _editorFrame.GetHardwareObject(false);

                if (device != null)
                {
                    if (isProjectModified)
                    {
                        SystemInstances.ObjectMgr.SetObject(
                                device.MetaObject,
                                true,
                                ((HSCObjectEditor)_editorFrame).ConnectorEditorFrame);

                        hwdObject = _editorFrame.GetHardwareObject(false);
                    }
                    
                    IMetaObject parentMetaObject = SystemInstances.ObjectMgr.GetObjectToRead(SystemInstances.Engine.Projects.PrimaryProject.Handle, device.MetaObject.ParentObjectGuid);
                    IOSummaryView form = new IOSummaryView();
                    form.Initialize(parentMetaObject);
                    form.ShowDialog();
                    form.Dispose();
                }
            }

            hwdObject = _editorFrame.GetHardwareObject(false);
        }

Get the index of the string within another string without match case

CodeKeep C# Feed Agosto 4th, 2008

Description: using CompareInfo.IndexOf() in System.Globalization name space. The old way is first make it all ToTower(), then index.

Link: http://www.codekeep.net/snippets/876944a4-1bf9-4e93-9831-70cc365acadd.aspx

using System.Globalization;

string strParent = "The Codeproject site is very informative.";

string strChild = "codeproject";
// We create a object of CompareInfo class for a neutral culture or a culture insensitive object
CompareInfo Compare = CultureInfo.InvariantCulture.CompareInfo;

int i = Compare.IndexOf(strParent,strChild,CompareOptions.IgnoreCase);

Remove selected items from listBox

CodeKeep C# Feed Agosto 4th, 2008

Description: Remove selected items from listBox (SelectionMode=MultiExtended)

Link: http://www.codekeep.net/snippets/fde27fe2-efd6-4483-8bac-769242a6ac35.aspx

while (list.SelectedItems.Count > 0)
{
   list.Items.Remove(list.SelectedItems[0]);
}

Remove items from listBox

CodeKeep C# Feed Agosto 4th, 2008

Description: Remove selected items from listBox (SelectionMode=MultiExtended)

Link: http://www.codekeep.net/snippets/236b8886-2474-439d-8bb0-7b68d266d5a2.aspx

while (list.SelectedItems.Count > 0)
{
   list.Items.Remove(list.SelectedItems[0]);
}