Exemple #1
0
 private bool TryGetPropItemParent
 (
     WeakReference <PSAccessServiceInternalInterface> propStoreAccessService_Internal_wr,
     PropNode sourcePropNode,
     out WeakRefKey <IPropBag> propItemParentPropBag_wr
 )
 {
     if (propStoreAccessService_Internal_wr.TryGetTarget(out PSAccessServiceInternalInterface storeAcessor_internal))
     {
         if (storeAcessor_internal.TryGetParentPropBagProxy(sourcePropNode, out propItemParentPropBag_wr))
         {
             return(true);
         }
         else
         {
             propItemParentPropBag_wr = new WeakRefKey <IPropBag>(null);
             return(false);
         }
         //WeakReference<IPropBagInternal> propItemParentPropBag_internal_wr = storeAcessor_internal.GetPropBagProxy(sourcePropNode);
         //WeakReference<IPropBag> propItemParentPropBag_wr = storeAcessor_internal.GetPublicInterface(propItemParentPropBag_internal_wr);
         //return propItemParentPropBag_wr;
     }
     else
     {
         propItemParentPropBag_wr = new WeakRefKey <IPropBag>(null);
         return(false);
     }
 }
Exemple #2
0
        public PropNode ReadPropNode(IntPtr handle, uint address)
        {
            PropNode p = new PropNode();

            p.propID   = ReadDWORD(handle, address) & 0xFFFF;
            p.namePtr  = ReadDWORD(handle, address + 4);
            p.subCount = ReadDWORD(handle, address + 8);
            p.listPtr  = ReadDWORD(handle, address + 12);
            p.unk1     = ReadDWORD(handle, address + 16);
            p.unk2     = ReadDWORD(handle, address + 20);
            p.unk3     = ReadDWORD(handle, address + 24);
            p.unk4     = ReadDWORD(handle, address + 28);
            if (p.namePtr != 0)
            {
                p.name = ReadCString(handle, p.namePtr);
            }
            else
            {
                p.name = "";
            }
            string s = p.propID.ToString("X4") + " " + p.name;

            Log(s);
            listBox1.Items.Add(s);
            p.list = new List <PropNode>();
            if (p.listPtr != 0)
            {
                for (int i = 0; i < p.subCount; i++)
                {
                    p.list.Add(ReadPropNode(handle, (uint)(p.listPtr + i * 0x20)));
                }
            }
            return(p);
        }
Exemple #3
0
        private long EvalEnum(EnumNode enode, PropNode prop)
        {
            long number = 0;

            foreach (Symbol sym in prop.Default)
            {
                long n   = 0;
                var  val = (sym as WeakSymbol).Identifier;

                if (new Regex("^[-0-9]+$|^0x[-0-9a-fA-F]+$").IsMatch(val))
                {
                    int bas = 10;
                    if (val.StartsWith("0x", StringComparison.Ordinal))
                    {
                        bas = 16;
                        val = val.Substring(2);
                    }
                    n = Convert.ToInt64(val, bas);
                }
                else
                {
                    var otherNode = enode.childNodes.Single(o => o is PropNode && (o as PropNode).Name == val) as PropNode;
                    n = EvalEnum(enode, otherNode);
                }
                number = number | n;
            }
            return(number);
        }
Exemple #4
0
 private void AddPropNode(TreeNode t, PropNode p)
 {
     t.Text = p.propID.ToString("X4") + " " + p.name;
     foreach (PropNode sp in p.list)
     {
         TreeNode nt = new TreeNode();
         AddPropNode(nt, sp);
         t.Nodes.Add(nt);
     }
 }
Exemple #5
0
        /// <summary>
        /// 增加属性节点
        /// </summary>
        /// <param name="key">属性</param>
        /// <param name="handler">处理函数为null时将用默认FormatPropertyValue函数,否则用附加的函数处理</param>
        /// <returns></returns>
        private void AddKeyFunction(string propName, RETURN_TYPE returnType = RETURN_TYPE.Int, PropEventHanlder handler = null, int precision = 0)
        {
            PropNode node = new PropNode();

            node.key        = propName;
            node.returnType = returnType;
            node.handler    = handler;
            node.precision  = precision;
            m_nodeList.Add(propName, node);
        }
Exemple #6
0
        private bool NotifyReceiverWithStartingValue(PropNode sourcePropNode)
        {
            bool result;

            switch (_notificationKind)
            {
            case PropStoreNotificationKindEnum.PropBag:
            {
                if (TryGetPropItemParent(_propStoreAccessService_wr, sourcePropNode, out WeakRefKey <IPropBag> propItemParent_wr))
                {
                    result = NotifyReceiver(_storeNodeUpdateReceiver_PropBag, propItemParent_wr);
                }
                else
                {
                    // TODO: consider not making the notification.
                    // TODO: consider retrieving the value from the sourcePropNode without using the storeAcessor.
                    result = NotifyReceiver(_storeNodeUpdateReceiver_PropBag, new WeakRefKey <IPropBag>(null));
                }
                break;
            }

            case PropStoreNotificationKindEnum.PropNode:
            {
                result = NotifyReceiver(_storeNodeUpdateReceiver_PropNode, _sourcePropNode);
                break;
            }

            case PropStoreNotificationKindEnum.Value:
            {
                IProp propItem = sourcePropNode.PropData_Internal.TypedProp;
                if (propItem.ValueIsDefined)
                {
                    result = NotifyReceiver(_storeNodeUpdateReceiver_Value, (T)propItem.TypedValueAsObject);
                }
                else
                {
                    result = NotifyReceiver(_storeNodeUpdateReceiver_Value);
                }
                break;
            }

            default:
            {
                throw new InvalidOperationException($"The PropStoreNotificationKind of {_notificationKind} is not supported or is not recognized.");
            }
            }

            return(result);
        }
Exemple #7
0
 private void readPropModListToolStripMenuItem_Click(object sender, EventArgs e)
 {
     try
     {
         ClearAll();
         GetHandle();
         GetStartAddress();
         if (handle == IntPtr.Zero || address == 0)
         {
             return;
         }
         GRPStaticList list = new GRPStaticList();
         Log("Count            = " + (list.count = ReadDWORD(handle, address + 4)));
         Log("Capacity         = " + (list.capacity = ReadDWORD(handle, address + 8)));
         Log("List Pointer     = " + (list.pList = ReadDWORD(handle, address + 12)).ToString("X8"));
         if (list.capacity > 100)
         {
             throw new Exception("Unexpected huge capacity!");
         }
         if (list.count > list.capacity)
         {
             list.count = list.capacity;
         }
         list.elements = new uint[list.capacity];
         Log("Elements");
         Log("========");
         for (uint i = 0; i < list.capacity; i++)
         {
             list.elements[i] = ReadDWORD(handle, list.pList + i * 4);
             if (list.elements[i] == 0)
             {
                 continue;
             }
             PropNode p = ReadPropNode(handle, list.elements[i]);
             TreeNode t = new TreeNode();
             AddPropNode(t, p);
             treeView1.Nodes.Add(t);
         }
     }
     catch (Exception ex)
     {
         Log("Error : " + ex.Message);
     }
 }
Exemple #8
0
        private void EmitEnumStringer(EnumNode enode, StringBuilder sb)
        {
            sb.AppendLine("func (e " + enode.Name + ") String() string {");
            sb.AppendLine("    switch e {");

            // go does not allow duplicate cases, so we filter duplicte ones out
            var uniqueNodes = new List <PropNode>();

            {
                var allValues = new List <long>();
                for (int i = 0; i < enode.childNodes.Count; i++)
                {
                    Node node = enode.childNodes[i];
                    if (!(node is PropNode))
                    {
                        continue;
                    }
                    PropNode prop = node as PropNode;
                    long     val  = EvalEnum(enode, prop);
                    if (allValues.Contains(val))
                    {
                        continue;
                    }
                    allValues.Add(val);
                    uniqueNodes.Add(prop);
                }
            }

            foreach (PropNode prop in uniqueNodes)
            {
                sb.AppendLine("    case " + enode.Name + "_" + prop.Name + ":");
                sb.AppendLine("        return \"" + enode.Name + "_" + prop.Name + "\"");
            }
            sb.AppendLine("    default:");
            sb.AppendLine("        return \"INVALID\"");
            sb.AppendLine("    }");
            sb.AppendLine("}");
            sb.AppendLine();
        }
Exemple #9
0
 public unsafe void QueueForPropagation(PropNode node, byte lightLevel)
 {
     *node.LightLevel((int)Channel) = lightLevel;
     QueueForPropagation(node);
 }
Exemple #10
0
        public override CswNbtNode CopyNode(bool IsNodeTemp = false, Action <CswNbtNode> OnCopy = null)
        {
            // Copy NodeType
            string NewNodeTypeName = "Copy Of " + NodeTypeName.Text;
            Int32  CopyInt         = 1;

            while (null != _CswNbtResources.MetaData.getNodeType(NewNodeTypeName))
            {
                CopyInt++;
                NewNodeTypeName = "Copy " + CopyInt.ToString() + " Of " + NodeTypeName.Text;
            }

            CswNbtObjClassDesignNodeType NodeTypeCopy = base.CopyNodeImpl(IsNodeTemp, delegate(CswNbtNode NewNode)
            {
                ((CswNbtObjClassDesignNodeType)NewNode).InternalCreate    = true;
                ((CswNbtObjClassDesignNodeType)NewNode).NodeTypeName.Text = NewNodeTypeName;
                if (null != OnCopy)
                {
                    OnCopy(NewNode);
                }
            });

            // Copy Tabs
            Dictionary <Int32, CswNbtObjClassDesignNodeTypeTab> TabMap = new Dictionary <Int32, CswNbtObjClassDesignNodeTypeTab>();

            foreach (CswNbtObjClassDesignNodeTypeTab TabNode in getTabNodes())
            {
                CswNbtObjClassDesignNodeTypeTab TabCopy = TabNode.CopyNode(IsNodeTemp, delegate(CswNbtNode CopiedNode)
                {
                    ((CswNbtObjClassDesignNodeTypeTab)CopiedNode).NodeTypeValue.RelatedNodeId = NodeTypeCopy.NodeId;
                    ((CswNbtObjClassDesignNodeTypeTab)CopiedNode).TabName.Text = TabNode.TabName.Text;
                });

                TabMap.Add(TabNode.RelationalId.PrimaryKey, TabCopy);
            }

            // case 31518 - props won't be able to see the tab if we don't do this
            _CswNbtResources.MetaData.refreshAll();

            // Copy Props
            Collection <CswNbtObjClassDesignNodeTypeProp>        PropNodes = getPropNodes();
            Dictionary <Int32, CswNbtObjClassDesignNodeTypeProp> PropMap   = new Dictionary <Int32, CswNbtObjClassDesignNodeTypeProp>();

            foreach (CswNbtObjClassDesignNodeTypeProp PropNode in PropNodes)
            {
                CswNbtObjClassDesignNodeTypeProp PropCopy = PropNode.CopyNode(IsNodeTemp, delegate(CswNbtNode CopiedNode)
                {
                    ((CswNbtObjClassDesignNodeTypeProp)CopiedNode).NodeTypeValue.RelatedNodeId = NodeTypeCopy.NodeId;
                    ((CswNbtObjClassDesignNodeTypeProp)CopiedNode).PropName.Text = PropNode.PropName.Text;
                });
                PropMap.Add(PropNode.RelationalId.PrimaryKey, PropCopy);

                // Fix layout
                if (PropCopy.PropName.Text.Equals(CswNbtObjClass.PropertyName.Save))
                {
                    foreach (CswNbtObjClassDesignNodeTypeTab NewTab in TabMap.Values)
                    {
                        //Case 29181 - Save prop on all tabs except identity
                        if (NewTab.RelationalId.PrimaryKey != NodeTypeCopy.RelationalNodeType.getIdentityTab().TabId)
                        {
                            _CswNbtResources.MetaData.NodeTypeLayout.updatePropLayout(CswEnumNbtLayoutType.Edit, NodeTypeCopy.RelationalId.PrimaryKey, PropCopy.RelationalNodeTypeProp, false, NewTab.RelationalId.PrimaryKey, Int32.MaxValue, 1);
                        }
                    }
                }
                else
                {
                    foreach (CswEnumNbtLayoutType LayoutType in CswEnumNbtLayoutType._All)
                    {
                        Dictionary <Int32, CswNbtMetaDataNodeTypeLayoutMgr.NodeTypeLayout> OriginalLayouts = _CswNbtResources.MetaData.NodeTypeLayout.getLayout(LayoutType, PropNode.RelationalNodeTypeProp, null);
                        foreach (CswNbtMetaDataNodeTypeLayoutMgr.NodeTypeLayout OriginalLayout in OriginalLayouts.Values)
                        {
                            if (OriginalLayout != null)
                            {
                                Int32 NewTabId = Int32.MinValue;
                                if (LayoutType == CswEnumNbtLayoutType.Edit)
                                {
                                    NewTabId = TabMap[OriginalLayout.TabId].RelationalId.PrimaryKey;
                                }
                                _CswNbtResources.MetaData.NodeTypeLayout.updatePropLayout(LayoutType, NodeTypeCopy.RelationalId.PrimaryKey, PropCopy.RelationalNodeTypeProp, true, NewTabId, OriginalLayout.DisplayRow, OriginalLayout.DisplayColumn);
                            }
                        }
                    } // foreach( CswEnumNbtLayoutType LayoutType in CswEnumNbtLayoutType._All )
                }
            }         // foreach( CswNbtObjClassDesignNodeTypeProp PropNode in getPropNodes() )


            // Fix Conditional Props (case 22328)
            foreach (CswNbtObjClassDesignNodeTypeProp PropNode in PropNodes)
            {
                if (CswTools.IsPrimaryKey(PropNode.DisplayConditionProperty.RelatedNodeId))
                {
                    CswNbtObjClassDesignNodeTypeProp PropCopy             = PropMap[PropNode.RelationalId.PrimaryKey];
                    CswNbtObjClassDesignNodeTypeProp DisplayConditionProp = PropNodes.FirstOrDefault(p => p.NodeId == PropNode.DisplayConditionProperty.RelatedNodeId);
                    if (null != DisplayConditionProp)
                    {
                        CswNbtObjClassDesignNodeTypeProp DisplayConditionPropCopy = PropMap[DisplayConditionProp.RelationalId.PrimaryKey];
                        PropCopy.DisplayConditionProperty.RelatedNodeId = DisplayConditionPropCopy.NodeId;
                    }
                }
            }

            // Fix the name template, now that properties are in place
            NodeTypeCopy.postChanges(true);

            //if( OnCopyNodeType != null )
            //    OnCopyNodeType( OldNodeType, NewNodeType );

            return(NodeTypeCopy.Node);
        } // CopyNode()
Exemple #11
0
        /// <summary>
        /// 格式化属性值
        /// </summary>
        /// <param name="match"></param>
        /// <returns></returns>
        private string FormatPropertyValue(Match match, PropNode propNode)
        {
            if (match == null)
            {
                return("");
            }

            // 正则键值
            string strKeyText = match.Groups[1].ToString();

            // 这个值为20或20*5之类的形式
            string strOldValue1 = match.Groups[2].ToString();
            float  foldValue    = 1.0f;

            float.TryParse(strOldValue1, out foldValue);
            // 获取属性值
            float fPropVal = getPropertyValue(strKeyText);

            // 取得属性转换值
            float fShowNum = fPropVal * foldValue / 100.0f;
            // 处理附加数值,进行合并
            string strOpt = match.Groups[3].ToString();

            if (!string.IsNullOrEmpty(strOpt))
            {
                // 附加数值
                string strOldValue2 = match.Groups[4].ToString();
                float  addition     = 0.0f;
                if (float.TryParse(strOldValue2, out addition))
                {
                    // 进行附加数值运算
                    switch (strOpt)
                    {
                    case "+":
                    {
                        fShowNum += addition;
                    }
                    break;

                    case "-":
                    {
                        fShowNum -= addition;
                    }
                    break;

                    case "*":
                    {
                        fShowNum *= addition;
                    }
                    break;

                    case "/":
                    {
                        // 处理0,除数不能为0
                        if (addition >= -float.Epsilon && addition <= float.Epsilon)
                        {
                            addition = 1.0f;
                        }
                        fShowNum /= addition;
                    }
                    break;

                    default:
                        break;
                    }
                }
            }

            return(propNode.returnType == RETURN_TYPE.Int ? string.Format("{0:D1}", (int)fShowNum) : string.Format("{0:F" + propNode.precision + "}", fShowNum));
        }
Exemple #12
0
 public void QueueForPropagation(PropNode node)
 {
     _propQueue.Enqueue(node);
 }
        public override void update()
        {
            CswTableUpdate jctUpdate = _CswNbtSchemaModTrnsctn.makeCswTableUpdate( "29311_jctddntp_update", "jct_dd_ntp" );
            DataTable jctTable = jctUpdate.getEmptyTable();

            // Set up Sequence Nodetype
            CswNbtMetaDataObjectClass SequenceOC = _CswNbtSchemaModTrnsctn.MetaData.getObjectClass( CswEnumNbtObjectClass.DesignSequenceClass );
            CswNbtMetaDataNodeType SequenceNT = _CswNbtSchemaModTrnsctn.MetaData.makeNewNodeTypeNew( new CswNbtWcfMetaDataModel.NodeType( SequenceOC )
                {
                    NodeTypeName = "Design Sequence",
                    Category = "Design",
                    IconFileName = "wrench.png"
                } );
            //SequenceNT.addNameTemplateText( CswNbtObjClassDesignSequence.PropertyName.Name );
            SequenceNT._DataRow["nametemplate"] = CswNbtMetaData.TemplateTextToTemplateValue( SequenceNT.getNodeTypeProps(), CswNbtMetaData.MakeTemplateEntry( CswNbtObjClassDesignSequence.PropertyName.Name ) );

            Int32 TabId = SequenceNT.getFirstNodeTypeTab().TabId;

            CswNbtMetaDataNodeTypeProp SeqNameNTP = SequenceNT.getNodeTypePropByObjectClassProp( CswNbtObjClassDesignSequence.PropertyName.Name );
            CswNbtMetaDataNodeTypeProp SeqNextValueNTP = SequenceNT.getNodeTypePropByObjectClassProp( CswNbtObjClassDesignSequence.PropertyName.NextValue );
            CswNbtMetaDataNodeTypeProp SeqPadNTP = SequenceNT.getNodeTypePropByObjectClassProp( CswNbtObjClassDesignSequence.PropertyName.Pad );
            CswNbtMetaDataNodeTypeProp SeqPostNTP = SequenceNT.getNodeTypePropByObjectClassProp( CswNbtObjClassDesignSequence.PropertyName.Post );
            CswNbtMetaDataNodeTypeProp SeqPreNTP = SequenceNT.getNodeTypePropByObjectClassProp( CswNbtObjClassDesignSequence.PropertyName.Pre );

            // Edit Layout
            SeqNameNTP.updateLayout( CswEnumNbtLayoutType.Edit, true, TabId, DisplayRow: 1, DisplayColumn: 1 );
            SeqPreNTP.updateLayout( CswEnumNbtLayoutType.Edit, true, TabId, DisplayRow: 2, DisplayColumn: 1 );
            SeqPostNTP.updateLayout( CswEnumNbtLayoutType.Edit, true, TabId, DisplayRow: 3, DisplayColumn: 1 );
            SeqPadNTP.updateLayout( CswEnumNbtLayoutType.Edit, true, TabId, DisplayRow: 4, DisplayColumn: 1 );
            SeqNextValueNTP.updateLayout( CswEnumNbtLayoutType.Edit, true, TabId, DisplayRow: 5, DisplayColumn: 1 );

            // Add Layout
            SeqNameNTP.updateLayout( CswEnumNbtLayoutType.Add, false, Int32.MinValue, DisplayRow: 1, DisplayColumn: 1 );
            SeqPreNTP.updateLayout( CswEnumNbtLayoutType.Add, false, Int32.MinValue, DisplayRow: 2, DisplayColumn: 1 );
            SeqPostNTP.updateLayout( CswEnumNbtLayoutType.Add, false, Int32.MinValue, DisplayRow: 3, DisplayColumn: 1 );
            SeqPadNTP.updateLayout( CswEnumNbtLayoutType.Add, false, Int32.MinValue, DisplayRow: 4, DisplayColumn: 1 );
            SeqNextValueNTP.removeFromLayout( CswEnumNbtLayoutType.Add );

            // Populate nodes
            // Very important that this happens BEFORE we map to the nodetypes table, or else we'll end up duplicating rows!
            Dictionary<Int32, CswNbtObjClassDesignSequence> SequenceNodeMap = new Dictionary<int, CswNbtObjClassDesignSequence>();
            CswTableSelect SequencesTableSelect = _CswNbtSchemaModTrnsctn.makeCswTableSelect( "29311_sequencetable_select", "sequences" );
            DataTable SequencesTable = SequencesTableSelect.getTable();
            foreach( DataRow SeqRow in SequencesTable.Rows )
            {
                CswNbtObjClassDesignSequence node = _CswNbtSchemaModTrnsctn.Nodes.makeNodeFromNodeTypeId( SequenceNT.NodeTypeId, OverrideUniqueValidation: true, OnAfterMakeNode: delegate( CswNbtNode NewNode )
                    {
                        CswNbtObjClassDesignSequence NewSeqNode = NewNode;
                        NewSeqNode.Name.Text = SeqRow["sequencename"].ToString();
                        NewSeqNode.Pad.Value = CswConvert.ToInt32( SeqRow["pad"] );
                        NewSeqNode.Post.Text = SeqRow["post"].ToString();
                        NewSeqNode.Pre.Text = SeqRow["prep"].ToString();
                    } );
                node.RelationalId = new CswPrimaryKey( "sequences", CswConvert.ToInt32( SeqRow["sequenceid"] ) );
                node.postChanges( false );
                SequenceNodeMap.Add( node.RelationalId.PrimaryKey, node );
            }

            // Here's where the extra special super-secret magic comes in

            //SequenceNT.TableName = "sequences";
            SequenceNT._DataRow["tablename"] = "sequences";

            _addJctRow( jctTable, SeqNameNTP, SequenceNT.TableName, "sequencename" );
            _addJctRow( jctTable, SeqPadNTP, SequenceNT.TableName, "pad" );
            _addJctRow( jctTable, SeqPostNTP, SequenceNT.TableName, "post" );
            _addJctRow( jctTable, SeqPreNTP, SequenceNT.TableName, "prep" );
            jctUpdate.update( jctTable );

            // Set up existing relationships to sequences
            Dictionary<Int32, CswNbtObjClassDesignSequence> SequenceValueMap = new Dictionary<Int32, CswNbtObjClassDesignSequence>();
            string Sql = @"select n.nodeid, r.sequenceid
                             from nodetype_props p
                             join nodetypes t on p.nodetypeid = t.nodetypeid
                             join nodes n on t.nodetypeid = n.nodetypeid
                             join nodetype_props r on n.relationalid = r.nodetypepropid
                            where p.propname = 'Sequence' and t.nodetypename like 'Design%'";
            CswArbitrarySelect ExistingSequenceIdSelect = _CswNbtSchemaModTrnsctn.makeCswArbitrarySelect( "getExistingSequenceIds", Sql );
            DataTable ExistingSequenceIdTable = ExistingSequenceIdSelect.getTable();
            foreach( DataRow row in ExistingSequenceIdTable.Rows )
            {
                Int32 thisSeqId = CswConvert.ToInt32( row["sequenceid"] );
                if( Int32.MinValue != thisSeqId && SequenceNodeMap.ContainsKey( thisSeqId ) )
                {
                    SequenceValueMap.Add( CswConvert.ToInt32( row["nodeid"] ), SequenceNodeMap[thisSeqId] );
                }
            }

            foreach( CswEnumNbtFieldType ft in new CswEnumNbtFieldType[] { CswEnumNbtFieldType.Barcode, CswEnumNbtFieldType.Sequence } )
            {
                CswNbtMetaDataNodeType PropNT = _CswNbtSchemaModTrnsctn.MetaData.getNodeType( CswNbtObjClassDesignNodeTypeProp.getNodeTypeName( ft ) );
                //CswNbtFieldTypeRuleSequence Rule = (CswNbtFieldTypeRuleSequence) _CswNbtSchemaModTrnsctn.MetaData.getFieldTypeRule( ft );
                //CswNbtFieldTypeAttribute SequenceAttribute = Rule.getAttributes().FirstOrDefault( a => a.Name == CswEnumNbtPropertyAttributeName.Sequence );
                CswNbtMetaDataNodeTypeProp SequenceNTP = PropNT.getNodeTypeProp( CswEnumNbtPropertyAttributeName.Sequence );
                SequenceNTP.SetFKDeprecated( CswEnumNbtViewRelatedIdType.ObjectClassId.ToString(), SequenceOC.ObjectClassId );

                CswNbtViewId ViewId = SequenceNTP.DesignNode.AttributeProperty[CswNbtFieldTypeRuleRelationship.AttributeName.View].AsViewReference.ViewId;
                CswNbtView View = _CswNbtSchemaModTrnsctn.ViewSelect.restoreView( ViewId );
                CswNbtFieldTypeRuleDefaultImpl.setDefaultView( _CswNbtSchemaModTrnsctn.MetaData, SequenceNTP.DesignNode, View, CswEnumNbtViewRelatedIdType.ObjectClassId.ToString(), SequenceOC.ObjectClassId, false );

                foreach( CswNbtObjClassDesignNodeTypeProp PropNode in PropNT.getNodes( false, true ) )
                {
                    if( SequenceValueMap.ContainsKey( PropNode.NodeId.PrimaryKey ) )
                    {
                        CswNbtObjClassDesignSequence SeqNode = SequenceValueMap[PropNode.NodeId.PrimaryKey];
                        if( null != SeqNode )
                        {
                            PropNode.Node.Properties[SequenceNTP].AsRelationship.RelatedNodeId = SeqNode.NodeId;
                            PropNode.postChanges( false );
                        }
                    }
                }
            } // foreach( CswEnumNbtFieldType ft in new CswEnumNbtFieldType[] {CswEnumNbtFieldType.Barcode, CswEnumNbtFieldType.Sequence} )

        } // update()
Exemple #14
0
        /// <summary>
        /// 属性格式化
        /// </summary>
        /// <param name="reg"></param>
        /// <param name="strText"></param>
        /// <returns></returns>
        public string Property_Callbak(RegexInfo reg, string strText)
        {
            MatchCollection matchs = reg.r.Matches(strText);

            // 没有匹配的直接返回原值
            if (matchs.Count == 0)
            {
                return(strText);
            }

            // 先将正则出来的结果进行帅选出来进行细化定位(KEY=开始位置)
            List <Match> result = new List <Match>();

            foreach (Match m in matchs)
            {
                result.Add(m);
            }
            // 将位置将序排下顺序,后面的优先处理
            List <Match> sortList = result.OrderByDescending(p => p.Index).ToList();

            StringBuilder builder = new StringBuilder(strText);

            // 将结果中的项目通过指定的函数进行格式化并替换值
            foreach (Match node in sortList)
            {
                if (node.Groups.Count == 0)
                {
                    continue;
                }

                // 获取到键值
                string strKey = node.Groups[1].ToString();
                // 对象容器中没有注册此键值
                if (!m_nodeList.ContainsKey(strKey))
                {
                    continue;
                }

                // 正则出来字符串
                string strOldText = node.Groups[0].ToString();

                PropNode prop       = m_nodeList[strKey];
                string   strNewText = "";
                // 处理值
                if (prop.handler != null)
                {
                    strNewText = prop.handler(node);
                }
                else
                {
                    strNewText = FormatPropertyValue(node, prop);
                }

                // 有变化将进行替换
                if (!strNewText.Equals(strOldText))
                {
                    // 本正则出来字符串在源字符串的起始位置
                    int nStartPos = node.Index;
                    // 正则出来字符串的长度
                    int nTextLength = node.Length;

                    // 替换
                    builder.Replace(strOldText, strNewText, nStartPos, nTextLength);
                }
            }

            return(builder.ToString());
        }
Exemple #15
0
        private bool TryGetChildProp(BagNode objectNode /*, IPropBag propBag*/, string propertyName, out PropNode child)
        {
            //// TODO: Add additional type checking and throw exceptions if neccessary.
            //// TODO: IPBI- Store Accessor Internal

            ////IPropBagInternal propBag_Internal = (IPropBagInternal)propBag;
            ////PSAccessServiceInternalInterface storeAccess_Internal = (PSAccessServiceInternalInterface)propBag_Internal.ItsStoreAccessor;

            if (_propStoreAccessService_wr.TryGetTarget(out PSAccessServiceInternalInterface storeAccess_Internal))
            {
                if (storeAccess_Internal.TryGetChildPropNode(objectNode, propertyName, out child))
                {
                    return(true);
                }
                else
                {
                    child = null;
                    return(false);
                }
            }
            else
            {
                System.Diagnostics.Debug.WriteLine("Could not get ChildProp because our StoreAccessor has expired.");
                child = null;
                return(false);
            }
        }
Exemple #16
0
        private bool UpdateTargetWithStartingValue(WeakRefKey <IPropBag> bindingTarget, PropNode sourcePropNode)
        {
            IProp typedProp            = sourcePropNode.PropData_Internal.TypedProp;
            PropStorageStrategyEnum ss = typedProp.PropTemplate.StorageStrategy;

            switch (ss)
            {
            case PropStorageStrategyEnum.Internal:
            {
                T    newValue = (T)typedProp.TypedValueAsObject;
                bool result   = UpdateTarget(bindingTarget, newValue);
                return(result);
            }

            case PropStorageStrategyEnum.External:
                goto case PropStorageStrategyEnum.Internal;

            // This property has no backing store, there is no concept of a starting value.
            case PropStorageStrategyEnum.Virtual:
                return(false);

            default:
                throw new InvalidOperationException($"{ss} is not a recognized or supported Prop Storage Strategy when used as a source for a local binding.");
            }
        }
Exemple #17
0
 public void OnPropStoreNodeUpdated(PropNode sourcePropNode, T newValue)
 {
     _localBinder.UpdateTarget(_localBinder._targetObject, newValue);
     //DoUpdate(sourcePropNode);
 }
Exemple #18
0
 // PropNode (PropItem) -- no old value.
 private bool NotifyReceiver(IReceivePropStoreNodeUpdates_PropNode <T> propStoreUpdateReceiver, PropNode propNode)
 {
     propStoreUpdateReceiver.OnPropStoreNodeUpdated(propNode);
     return(true);
 }
Exemple #19
0
            public void OnPropStoreNodeUpdated(PropNode sourcePropNode)
            {
                _localBinder.UpdateTargetWithStartingValue(_localBinder._targetObject, sourcePropNode);

                //DoUpdate(sourcePropNode);
            }
Exemple #20
0
        private bool DataSourceHasChanged_Handler(ObservableSource <T> signalingNode, DataSourceChangeTypeEnum changeType, out PropNode sourcePropNode)
        {
            sourcePropNode = null;
            bool isComplete = false;

            BagNode next;

            switch (signalingNode.SourceKind)
            {
            case SourceKindEnum.AbsRoot:
            {
                System.Diagnostics.Debug.Assert(changeType == DataSourceChangeTypeEnum.ParentHasChanged,
                                                $"Received a DataSourceChanged event from on a node of kind = AbsRoot. " +
                                                $"The DataSourceChangeType should be {nameof(DataSourceChangeTypeEnum.ParentHasChanged)}, but is {changeType}.");

                System.Diagnostics.Debug.Assert(ReferenceEquals(signalingNode, _rootListener),
                                                "Received a ParentHasChanged on a node of kind = AbsRoot and the signaling node is not the _rootListener.");

                System.Diagnostics.Debug.Assert(_isPathAbsolute,
                                                "Received a ParentHasChanged on a node of kind = AbsRoot, but our 'PathIsAbsolute' property is set to false.");

                // We have a new root, start at the beginning.
                next = _ourNode.Root;
                if (next == null)
                {
                    System.Diagnostics.Debug.WriteLine("OurNode's root is null when processing update to AbsRoot.");
                    return(isComplete);
                }

                int nPtr = 0;
                isComplete = HandleNodeUpdate(next, _pathElements, _pathListeners, nPtr, out sourcePropNode);
                break;
            }

            case SourceKindEnum.Up:
            {
                System.Diagnostics.Debug.Assert(changeType == DataSourceChangeTypeEnum.ParentHasChanged, $"DataSourceHasChanged is processing a observable source of kind = {signalingNode.SourceKind}, but the ChangeType does not equal {nameof(DataSourceChangeTypeEnum.ParentHasChanged)}.");

                if (GetChangedNode(_ourNode, signalingNode, _isPathAbsolute, _pathElements, out next, out int nPtr))
                {
                    System.Diagnostics.Debug.Assert(nPtr < _pathElements.Length - 1, "GetChangedNode for 'up' PropertyChanged event returned with nPtr beyond next to last node.");
                    isComplete = HandleNodeUpdate(next, _pathElements, _pathListeners, nPtr, out sourcePropNode);
                }

                break;
            }

            case SourceKindEnum.Down:
            {
                System.Diagnostics.Debug.Assert(changeType == DataSourceChangeTypeEnum.PropertyChanged, $"DataSourceHasChanged is processing a observable source of kind = {signalingNode.SourceKind}, but the ChangeType does not equal {nameof(DataSourceChangeTypeEnum.PropertyChanged)}.");

                if (GetChangedNode(_ourNode, signalingNode, _isPathAbsolute, _pathElements, out next, out int nPtr))
                {
                    System.Diagnostics.Debug.Assert(nPtr < _pathElements.Length - 1, "GetChangedNode for 'down' PropertyChanged event returned with nPtr beyond next to last node.");
                    isComplete = HandleNodeUpdate(next, _pathElements, _pathListeners, nPtr, out sourcePropNode);
                }

                break;
            }

            case SourceKindEnum.TerminalNode:
            {
                System.Diagnostics.Debug.Assert(Complete, "The Complete flag should be set when responding to Terminal node updates.");
                System.Diagnostics.Debug.WriteLine("Beginning to proccess property changed event raised from the Terminal node of the source path.");

                if (GetChangedNode(_ourNode, signalingNode, _isPathAbsolute, _pathElements, out next, out int nPtr))
                {
                    isComplete = HandleTerminalNodeUpdate(next, _pathElements, nPtr, out sourcePropNode);
                }

                break;
            }

            default:
            {
                throw new InvalidOperationException($"The SourceKind: {signalingNode.SourceKind} is not recognized or is not supported.");
            }
            }
            return(isComplete);
        }
Exemple #21
0
        private bool HandleTerminalNodeUpdate(BagNode next, string[] pathElements, int nPtr, out PropNode child)
        {
            System.Diagnostics.Debug.Assert(nPtr == pathElements.Length - 1, $"The counter variable: nPtr should be {pathElements.Length - 1}, but is {nPtr} instead.");

            if (TryGetPropBag(next, out IPropBag propBag))
            {
                string pathComp = pathElements[nPtr];

                if (TryGetChildProp(next, /*propBag,*/ pathComp, out child))
                {
                    if (NotifyReceiverWithStartingValue(child))
                    {
                        System.Diagnostics.Debug.WriteLine($"The receiver has been notified during refresh. " +
                                                           $"Source: {((IPropBag)propBag).FullClassName}, {pathComp}");
                        return(true);
                    }
                    else
                    {
                        System.Diagnostics.Debug.WriteLine("The binding source has been reached, but the receiver was not notified during refresh. " +
                                                           $"Source: {((IPropBag)propBag).FullClassName}, {pathComp}");
                        return(false);
                    }
                }
                else
                {
                    System.Diagnostics.Debug.WriteLine("Could not get reference to the PropItem's PropStoreNode during binding update.");
                    return(false);
                }
            }
            else
            {
                System.Diagnostics.Debug.WriteLine("The weak reference to the PropBag refers to a ProBag which 'is no longer with us.'");
                child = null;
                return(false);
            }
        }
Exemple #22
0
        private bool HandleNodeUpdate(BagNode next,
                                      string[] pathElements, OSCollection <T> pathListeners, int nPtr, out PropNode sourcePropNode)
        {
            bool complete = false;

            sourcePropNode = null;

            // Process each step, except for the last.
            for (; next != null && nPtr < pathElements.Length - 1; nPtr++)
            {
                string pathComp = pathElements[nPtr];
                if (pathComp == "..")
                {
                    bool   listenerWasAdded = AddOrUpdateListener(next, pathComp, SourceKindEnum.Up, pathListeners, nPtr);
                    string mg = listenerWasAdded ? "added" : "updated";
                    System.Diagnostics.Debug.WriteLine($"The Listener for step: {pathComp} was {mg}.");

                    next = next.Parent?.Parent;
                }
                else
                {
                    if (TryGetPropBag(next, out IPropBag propBag))
                    {
                        bool   listenerWasAdded = AddOrUpdateListener(propBag, next.CompKey, pathComp, SourceKindEnum.Down, pathListeners, nPtr);
                        string mg = listenerWasAdded ? "added" : "updated";
                        System.Diagnostics.Debug.WriteLine($"The Listener for step: {pathComp} was {mg}.");

                        if (TryGetChildProp(next, /*propBag, */ pathComp, out PropNode child))
                        {
                            next = child.Child;
                        }
                        else
                        {
                            System.Diagnostics.Debug.WriteLine("Could not get reference to the PropItem's PropStoreNode during binding update.");
                            next = null;
                        }
                    }
                    else
                    {
                        System.Diagnostics.Debug.WriteLine("The weak reference to the PropBag refers to a ProBag which 'is no longer with us.'");
                        next = null;
                    }
                }
            }

            // Add the terminal node.
            if (next != null)
            {
                System.Diagnostics.Debug.Assert(nPtr == pathElements.Length - 1, $"The counter variable: nPtr should be {pathElements.Length - 1}, but is {nPtr} instead.");

                if (TryGetPropBag(next, out IPropBag propBag))
                {
                    string pathComp = pathElements[nPtr];

                    bool   listenerWasAdded = AddOrUpdateListener(propBag, next.CompKey, pathComp, SourceKindEnum.TerminalNode, pathListeners, nPtr);
                    string mg = listenerWasAdded ? "added" : "updated";
                    System.Diagnostics.Debug.WriteLine($"The Listener for terminal step: {pathComp} was {mg}.");

                    // We have created or updated the listener for this step, advance the pointer.
                    nPtr++;

                    // We have subscribed to the property that is the source of the binding.
                    complete = true;

                    // Let's try to get the value of the property for which we just started listening to changes.
                    if (TryGetChildProp(next, /*propBag,*/ pathComp, out sourcePropNode))
                    {
                        if (NotifyReceiverWithStartingValue(sourcePropNode))
                        {
                            System.Diagnostics.Debug.WriteLine($"The receiver has been notified during refresh. " +
                                                               $"Source: {((IPropBag)propBag).FullClassName}, {pathComp}");
                        }
                        else
                        {
                            System.Diagnostics.Debug.WriteLine("The binding source has been reached, but the receiver was not notified during refresh. " +
                                                               $"Source: {((IPropBag)propBag).FullClassName}, {pathComp}");
                        }
                    }
                    else
                    {
                        System.Diagnostics.Debug.WriteLine("Could not get reference to the PropItem's PropStoreNode during binding update.");
                    }
                }
                else
                {
                    System.Diagnostics.Debug.WriteLine("The weak reference to the PropBag refers to a ProBag which 'is no longer with us.'");
                }
            }

            for (; nPtr < pathListeners.Count; nPtr++)
            {
                ObservableSource <T> listener = pathListeners[nPtr];
                listener.Dispose();
                pathListeners.RemoveAt(nPtr);
            }

            return(complete);
        }
Exemple #23
0
        private bool StartBinding(string[] pathElements, OSCollection <T> pathListeners, bool pathIsAbsolute, out PropNode sourcePropNode)
        {
            bool    isComplete = false;
            BagNode next;

            if (pathIsAbsolute)
            {
                next = _ourNode.Root;
                if (next == null)
                {
                    System.Diagnostics.Debug.WriteLine("OurNode's root is null when starting the local binding.");
                    sourcePropNode = null;
                    return(isComplete);
                }
            }
            else
            {
                next = _ourNode;
            }

            int nPtr = 0;

            isComplete = HandleNodeUpdate(next, pathElements, pathListeners, nPtr, out sourcePropNode);
            return(isComplete);
        }
Exemple #24
0
        public void UpdateRenderTargets()
        {
            List <Geometry3D> ReflectionUpdateList = new List <Geometry3D>();
            List <Geometry3D> RefractionUpdateList = new List <Geometry3D>();
            List <Geometry3D> DepthUpdateList      = new List <Geometry3D>();

            if (ReflectionRenderTarget != null)
            {
                ReflectionUpdateList.AddRange(ReflectionRenderTarget.GeometryUpdateList);
                Render.DetachRenderTarget(ReflectionRenderTarget);
                //ReflectionRenderTarget.Dispose();
            }
            if (RefractionRenderTarget != null)
            {
                RefractionUpdateList.AddRange(RefractionRenderTarget.GeometryUpdateList);
                Render.DetachRenderTarget(RefractionRenderTarget);
                //RefractionRenderTarget.Dispose();
            }
            if (DepthMapRenderTarget != null)
            {
                DepthUpdateList.AddRange(DepthMapRenderTarget.GeometryUpdateList);
                Render.DetachRenderTarget(DepthMapRenderTarget);
                //DepthMapRenderTarget.Dispose();
            }


            Settings = FileManager.MasteryFile.Settings;

            PropStructureContainer = new WorldPropStructureContainer(Render);

            List <Geometry3D> PropBatches = PropStructureContainer.GetGeometries(-1);

            RenderNode.AttachRange(PropBatches);
            ReflectionNode.AttachRange(PropBatches);
            RefractionNode.AttachRange(PropBatches);
            PropNode.AttachRange(PropBatches);

            ReflectionRenderTarget = new SceneRenderTarget("ReflectionMap", ReflectionNode, Render.Graphics, Render.Camera.Position, Settings.CameraClosePlane, Settings.CameraFarPlane, Settings.WaterReflectionPlaneDirection, Settings.WaterReflectionResolutionX, Settings.WaterReflectionResolutionY, SceneRenderTarget.RenderType.SingleColor);
            RefractionRenderTarget = new SceneRenderTarget("RefractionMap", RefractionNode, Render.Graphics, Render.Camera.Position, Settings.CameraClosePlane, Settings.CameraFarPlane, Settings.WaterRefractionPlaneDirection, Settings.WaterReflectionResolutionX, Settings.WaterReflectionResolutionY, SceneRenderTarget.RenderType.SingleColor);
            DepthMapRenderTarget   = new SceneRenderTarget("DepthMap", RefractionNode, Render.Graphics, Render.Camera.Position, Settings.CameraClosePlane, Settings.CameraFarPlane, Settings.WaterRefractionPlaneDirection, Settings.WaterReflectionResolutionX, Settings.WaterReflectionResolutionY, SceneRenderTarget.RenderType.SingleDepth);


            FromBelowDepthTarget = new SceneRenderTarget("DepthMap", RefractionNode, Render.Graphics, new Vector3(), Settings.FromBelowClosePlane, Settings.FromBelowFarPlane, 0,
                                                         Settings.FromBelowResolutionX, Settings.FromBelowResolutionY, SceneRenderTarget.RenderType.SingleDepth, Settings.ChunkSize, Settings.ChunkSize);


            ReflectionRenderTarget.ClipOffset = Settings.ClipOffset;
            RefractionRenderTarget.ClipOffset = Settings.ClipOffset;
            DepthMapRenderTarget.ClipOffset   = Settings.ClipOffset;

            FromBelowDepthTarget.DebugTextureName = "SceneColorDebug";
            //DepthMapRenderTarget.DebugTextureName = "SceneDepthDebug";

            Render.AddRenderTarget(ReflectionRenderTarget);
            Render.AddRenderTarget(RefractionRenderTarget);
            Render.AddRenderTarget(DepthMapRenderTarget);
            Render.AddRenderTarget(FromBelowDepthTarget);

            ReflectionRenderTarget.AttachRange(ReflectionUpdateList);
            RefractionRenderTarget.AttachRange(RefractionUpdateList);
            DepthMapRenderTarget.AttachRange(DepthUpdateList);
        }
Exemple #25
0
 // PropNode (PropItem) -- with old value.
 private bool NotifyReceiver(IReceivePropStoreNodeUpdates_PropNode <T> propStoreUpdateReceiver, PropNode propNode, PcTypedEventArgs <T> e)
 {
     if (e.NewValueIsUndefined)
     {
         propStoreUpdateReceiver.OnPropStoreNodeUpdated(propNode);
     }
     else
     {
         propStoreUpdateReceiver.OnPropStoreNodeUpdated(propNode, e.NewValue);
     }
     return(true);
 }