Ejemplo n.º 1
0
        private void DropDownColumnBody(GridMemoBox box)
        {
            try
            {
                //DataRowView record = GetCurrentGridRow();

                object record = GetCurrentRowObject();
                if (record == null)
                {
                    return;
                }
                //string key = Types.NZ(record.Row[0], null);
                //if (key == null)
                //{
                //    return;
                //}

                //object val= Types.NZ(record.Row[1], null);
                //if (val == null)
                //{
                //    return;
                //}

                Type type = record.GetType();

                if (type == typeof(PersistItem))
                {
                    PersistItem pi = (PersistItem)record;
                    if (pi.body.GetType() == typeof(byte[]))
                    {
                        var item = BinarySerializer.Deserialize <IQueueItem>((byte[])pi.body);
                        box.Text = item.ToJson();
                    }
                    else if (pi.body.GetType() == typeof(IQueueItem))
                    {
                        box.Text = ((IQueueItem)pi.body).ToJson();
                    }
                }
                else if (type == typeof(IQueueItem))
                {
                    box.Text = ((IQueueItem)record).ToJson();
                }
            }
            catch (Exception ex)
            {
                MsgBox.ShowError(ex.Message, "Cache Management");
            }
        }
Ejemplo n.º 2
0
        //called when data for any output pin is requested
        public void Evaluate(int SpreadMax)
        {
            if (FReset[0] || FIndexVectorSize.IsChanged || FValueVectorSize.IsChanged || dict == null)
            {
                dict = new SortedDictionary <string, PersistItem>();
            }

            SpreadMax = Math.Max((int)Math.Ceiling(FIDInput.SliceCount / (double)FIndexVectorSize[0]), FColorIn.SliceCount);
            SpreadMax = Math.Max((int)Math.Ceiling(FValueIn.SliceCount / (double)FValueVectorSize[0]), SpreadMax);
            SpreadMax = Math.Max(FStringIn.SliceCount, SpreadMax);

            for (int i = 0; i < SpreadMax; i++)
            {
                string key = "";
                char   pad = '-';
                int    id;
                for (int j = 0; j < FIndexVectorSize[0]; j++)
                {
                    id = FIDInput[i * FIndexVectorSize[0] + j];
                    if (id < 0)
                    {
                        id  = int.MaxValue - id;
                        pad = '-';
                    }
                    else
                    {
                        pad = '0';
                    }
                    string snippet = id.ToString();
                    snippet = pad + snippet.PadLeft(int.MaxValue.ToString().Length, '0');
                    key    += snippet + " ";
                }

                if (!dict.ContainsKey(key))
                {
                    dict[key] = new PersistItem();
                }
                if (dict[key].key == null)
                {
                    dict[key].key = new List <int>();
                }
                else
                {
                    dict[key].key.Clear();
                }
                for (int j = 0; j < FIndexVectorSize[0]; j++)
                {
                    dict[key].key.Add(FIDInput[i * FIndexVectorSize[0] + j]);
                }
                dict[key].name  = FStringIn[i];
                dict[key].color = FColorIn[i];


                if (dict[key].values == null)
                {
                    dict[key].values = new List <double>();
                }
                else
                {
                    dict[key].values.Clear();
                }
                for (int j = 0; j < FValueVectorSize[0]; j++)
                {
                    dict[key].values.Add(FValueIn[i * FValueVectorSize[0] + j]);
                }
            }

            SpreadMax = (int)Math.Ceiling(FGetID.SliceCount / (double)FIndexVectorSize[0]);

            FIDOutput.SliceCount  = 0;
            FValueOut.SliceCount  = 0;
            FStringOut.SliceCount = 0;
            FColorOut.SliceCount  = 0;

//			FIDOutput.SliceCount = SpreadMax * FIndexVectorSize[0];
//			FValueOut.SliceCount = SpreadMax * FValueVectorSize[0];
//			FStringOut.SliceCount = SpreadMax;

            for (int i = 0; i < SpreadMax; i++)
            {
                string key = "";
                char   pad = '-';
                int    id;
                for (int j = 0; j < FIndexVectorSize[0]; j++)
                {
                    id = FGetID[i * FIndexVectorSize[0] + j];
                    if (id < 0)
                    {
                        id  = int.MaxValue - id;
                        pad = '-';
                    }
                    else
                    {
                        pad = '0';
                    }
                    string snippet = id.ToString();
                    snippet = pad + snippet.PadLeft(int.MaxValue.ToString().Length, '0');
                    key    += snippet + " ";
                }

                if (dict.ContainsKey(key))
                {
                    PersistItem item = dict[key];
                    for (int j = 0; j < FIndexVectorSize[0]; j++)
                    {
                        FIDOutput.Add(item.key[j]);
                    }
                    for (int j = 0; j < FValueVectorSize[0]; j++)
                    {
                        FValueOut.Add(item.values[j]);
                    }
                    FColorOut.Add(item.color);
                    FStringOut.Add(item.name);
                }
            }
        }