コード例 #1
0
ファイル: GHUtil.cs プロジェクト: PawelBee/Guanaco
        public override bool Read(GH_IReader reader)
        {
            int mode = 1;

            reader.TryGetInt32("UIMode", ref mode);
            reader.TryGetInt32("ListMode", ref mode);
            this.ListMode = (GH_ValueListMode)mode;
            int count = reader.GetInt32("ListCount");
            int cache = 0;

            reader.TryGetInt32("CacheCount", ref cache);
            this.m_userItems.Clear();
            int arg_52_0 = 0;
            int num      = count - 1;

            for (int i = arg_52_0; i <= num; i++)
            {
                GH_IReader chunk = reader.FindChunk("ListItem", i);
                if (chunk == null)
                {
                    reader.AddMessage("Missing chunk for List Value: " + i.ToString(), GH_Message_Type.error);
                }
                else
                {
                    string itemName       = chunk.GetString("Name");
                    string itemExpression = chunk.GetString("Expression");
                    bool   itemSelected   = false;
                    chunk.TryGetBoolean("Selected", ref itemSelected);
                    Type            t = JsonConvert.DeserializeObject <Type>(chunk.GetString("Type"));
                    object          deserializedExpression = JsonConvert.DeserializeObject(itemExpression, t);
                    GuanacoListItem item = new GuanacoListItem(itemName, deserializedExpression);
                    item.Selected = itemSelected;
                    this.m_userItems.Add(item);
                }
            }
            if (reader.ItemExists("ListIndex"))
            {
                int idx = reader.GetInt32("ListIndex");
                if (idx >= 0 && idx < this.m_userItems.Count)
                {
                    this.m_userItems[idx].Selected = true;
                }
            }
            return(base.Read(reader));
        }
コード例 #2
0
        public override bool Read(GH_IReader reader)
        {
            int num1 = 1;

            reader.TryGetInt32("UIMode", ref num1);
            reader.TryGetInt32("ListMode", ref num1);
            ListMode = (GH_ValueListMode)num1;
            int int32 = reader.GetInt32("ListCount");
            int num2  = 0;

            reader.TryGetInt32("CacheCount", ref num2);
            m_userItems.Clear();
            int num3 = 0;
            int num4 = int32 - 1;

            for (int index = num3; index <= num4; ++index)
            {
                GH_IReader chunk = reader.FindChunk("ListItem", index);
                if (chunk == null)
                {
                    reader.AddMessage("Missing chunk for List Value: " + index.ToString(), GH_Message_Type.error);
                }
                else
                {
                    string name       = chunk.GetString("Name");
                    string expression = chunk.GetString("Expression");
                    bool   flag       = false;
                    chunk.TryGetBoolean("Selected", ref flag);
                    m_userItems.Add(new GH_ValueListItem(name, expression)
                    {
                        Selected = flag
                    });
                }
            }
            return(base.Read(reader));
        }