private void btnUpdateCond_Click(object sender, EventArgs e)
        {
            CompBase selComp = null;

            if (treeComponents.SelectedNode == null)
            {
                selComp = _transitionItem;
            }
            else
            {
                selComp = treeComponents.SelectedNode.Tag as CompBase;
            }

            //Prevent incorrect added
            if (!(selComp is SMSubCond))
            {
                return;
            }

            if (ConditionaValue == "")
            {
                MessageBox.Show("Please sepicify condition value.");
                return;
            }


            SMSubCond subCond       = selComp as SMSubCond;
            string    backCondID    = subCond.ConditionID;
            string    backCondValue = subCond.ConditionValueString;

            try
            {
                subCond.ConditionValueString = ConditionaValue;
                subCond.ConditionID          = smPropID.ID;
                subCond.OperatorString       = cbOperator.Text;

                subCond.Rebuild();
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.ToString());
                subCond.ConditionValueString = backCondValue;
                subCond.ConditionID          = backCondID;
            }

            treeComponents.Nodes.Clear();
            Rebuild();
            smPropID.PrimaryStatement.Clear();

            DummyID          = String.Empty;
            smPropID.ScopeID = _transitionItem.ParentContainer.ScopeID;
            smPropID.BindTwoWay(() => DummyID);

            ConditionaValue   = String.Empty;
            smValueID.ScopeID = _transitionItem.ParentContainer.ScopeID;
            smValueID.BindTwoWay(() => ConditionaValue);

            cbOperator.SelectedIndex = 0;
        }
        private void treeComponents_NodeMouseClick(object sender, TreeNodeMouseClickEventArgs e)
        {
            if (e.Node.Tag is SMTransition)
            {
                _currentTransitionItem = e.Node.Tag as SMTransition;

                if (_currentTransitionItem.TransitionTargetID != "")
                {
                    cmbTransitionID.SelectedItem = _currentTransitionItem.TransitionTargetID;
                }
                return;
            }

            SMSubCondBase selSubCond = e.Node.Tag as SMSubCondBase;

            if (!(selSubCond is SMSubCond))
            {
                return;
            }
            SMSubCond subCond = selSubCond as SMSubCond;

            DummyID = subCond.ConditionID;
            smPropID.UnBind();
            //smPropID.ScopeID = _transitionItem.ParentContainer.ScopeID;
            smPropID.BindTwoWay(() => DummyID);
            cbOperator.SelectedItem = subCond.OperatorString;

            ConditionaValue = subCond.ConditionValueString;
            smValueID.UnBind();
            //smValueID.ScopeID = _transitionItem.ParentContainer.ScopeID;
            smValueID.BindTwoWay(() => ConditionaValue);

            _currentTransitionItem = GetTransitionParent(selSubCond);
            if (_currentTransitionItem.TransitionTargetID != "")
            {
                cmbTransitionID.SelectedItem = _currentTransitionItem.TransitionTargetID;
            }

            //if (!ConditionaValue.Contains("(Object)"))
            //{
            //    smValueID.UnBind();
            //    smValueID.BindTwoWay(() => ConditionaValue);
            //    smValueID.ReturnType = MCore.Controls.MPIDCtl.eTypes.Object;
            //}
            //else
            //{
            //    smValueID.UnBind();
            //    smValueID.BindTwoWay(() => ConditionaValue);
            //    smValueID.ReturnType = MCore.Controls.MPIDCtl.eTypes.Object;
            //}
        }
        private void AddSubCondition()
        {
            if (smPropID.ID == null || smPropID.ID == "")
            {
                return;
            }

            CompBase selComp = null;

            if (treeComponents.SelectedNode == null)
            {
                selComp = _transitionItem;
            }
            else
            {
                selComp = treeComponents.SelectedNode.Tag as CompBase;
            }

            //Prevent incorrect added
            if ((selComp == _transitionItem && (_transitionItem.ChildArray != null && _transitionItem.ChildArray.Length != 0)) ||
                selComp is SMSubCond)
            {
                return;
            }


            if (ConditionaValue == "")
            {
                MessageBox.Show("Please sepicify condition value.");
                return;
            }

            //System.Reflection.PropertyInfo propInfo = U.GetPropertyInfo(smPropID.ID);
            //Type propType = propInfo.PropertyType;

            //try
            //{
            //    TypeDescriptor.GetConverter(propType).ConvertFromString(ConditionaValue);
            //}
            //catch(Exception ex)
            //{
            //    MessageBox.Show(ex.ToString());
            //    return;
            //}


            SMSubCond subCond = new SMSubCond();

            subCond.ConditionID          = smPropID.ID;
            subCond.ConditionValueString = ConditionaValue;
            subCond.OperatorString       = cbOperator.Text;

            try
            {
                subCond.Rebuild();
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.ToString());
                return;
            }


            selComp.AppendAt(null, subCond);

            treeComponents.Nodes.Clear();
            Rebuild();

            smPropID.PrimaryStatement.Clear();
            DummyID          = String.Empty;
            smPropID.ScopeID = _transitionItem.ParentContainer.ScopeID;
            smPropID.BindTwoWay(() => DummyID);

            smValueID.PrimaryStatement.Clear();
            ConditionaValue   = String.Empty;
            smValueID.ScopeID = _transitionItem.ParentContainer.ScopeID;
            smValueID.BindTwoWay(() => ConditionaValue);

            cbOperator.SelectedIndex = 0;
        }