示例#1
0
        private void RunClicked(object sender, RoutedEventArgs e)
        {
            _query = GetQuery();
            if (TypeValueSaveReportCheckBox.IsChecked.Value)
            {
                string error;
                ClrtDisplayableType[] tosave = GetOrderedSelectionForSaving(out error);
                if (error != null)
                {
                    GuiUtils.ShowError(error, this);
                    return;
                }
                var tpName = Utils.BaseTypeName(tosave[0].TypeName);
                tpName = DumpFileMoniker.GetValidFileName(tpName);

                string spath   = _indexProxy.FileMoniker.OutputFolder + Path.DirectorySeparatorChar + "TypeValuesSetup." + tpName + ".tvr";
                int    pathNdx = 1;
                while (File.Exists(spath))
                {
                    var newTpName = tpName + "(" + pathNdx.ToString() + ")";
                    ++pathNdx;
                    spath = _indexProxy.FileMoniker.OutputFolder + Path.DirectorySeparatorChar + "TypeValuesSetup." + newTpName + ".tvr";
                }
                bool r = ClrtDisplayableType.SerializeArray(spath, tosave, out error);
                if (error != null)
                {
                    GuiUtils.ShowError(error, this);
                    return;
                }
            }
            DialogResult = _selection.Count > 0;
        }
示例#2
0
 private void SetAlternativeSiblings(TypeValueQuery qry)
 {
     qry.SetAlternativeSiblings();
     if (qry.HasChildren)
     {
         foreach (var child in qry.Children)
         {
             SetAlternativeSiblings(child);
         }
     }
 }
示例#3
0
        private void GetQueryHelper(ClrtDisplayableType disp, TypeValueQuery qry, Dictionary <long, List <ClrtDisplayableType> > dct)
        {
            var items = dct[disp.Id]; // has to be there

            for (int i = 0, icnt = items.Count; i < icnt; ++i)
            {
                var            item = items[i];
                TypeValueQuery q    = new TypeValueQuery(item.Id, qry, item.TypeName, item.TypeId, item.FieldName, item.FieldIndex, item.IsAlternative, item.Filter, item.GetValue);
                qry.AddChild(q);
                GetQueryHelper(item, q, dct);
            }
        }
示例#4
0
 private void SetValuesStore(TypeValueQuery qry, string[] data, ref int ndx, int width)
 {
     if (qry.GetValue)
     {
         qry.SetValuesStore(data, ndx, width);
         ++ndx;
     }
     if (qry.HasChildren)
     {
         foreach (var child in qry.Children)
         {
             SetValuesStore(child, data, ref ndx, width);
         }
     }
 }
示例#5
0
        private TypeValueQuery GetQuery()
        {
            int valCount = 1;
            var dct      = new Dictionary <long, List <ClrtDisplayableType> >(_selection.Count * 4);

            dct.Add(_typeInfo.Id, new List <ClrtDisplayableType>());
            var cmp = new ClrtDisplayableIdComparer();

            foreach (var sel in _selection)
            {
                if (sel.GetValue)
                {
                    ++valCount;
                }
                if (!dct.ContainsKey(sel.Id))
                {
                    dct.Add(sel.Id, new List <ClrtDisplayableType>());
                }
                var parent = sel.RealParent;
                var cursel = sel;
                while (parent != null)
                {
                    List <ClrtDisplayableType> lst;
                    if (dct.TryGetValue(parent.Id, out lst))
                    {
                        if (!lst.Contains(cursel, cmp))
                        {
                            lst.Add(cursel);
                        }
                    }
                    else
                    {
                        dct.Add(parent.Id, new List <ClrtDisplayableType>()
                        {
                            cursel
                        });
                    }
                    cursel = parent;
                    parent = parent.RealParent;
                }
            }

            TypeValueQuery root = new TypeValueQuery(_typeInfo.Id, null, _typeInfo.TypeName, _typeInfo.TypeId, "ADDRESS", Constants.InvalidIndex, false, null, true);

            GetQueryHelper(_typeInfo, root, dct);

            string[] values = new string[valCount * _typeInfo.Addresses.Length];
            root.SetValuesStore(values, 0, valCount);
            int dataNdx = 1;

            if (root.HasChildren)
            {
                foreach (var child in root.Children)
                {
                    SetValuesStore(child, values, ref dataNdx, valCount);
                    SetAlternativeSiblings(child);
                }
            }

            return(root);
        }