Beispiel #1
0
 public void Rebind(ObjectTree tree)
 {
     if (tree.Contains(ObjectPath))
     {
         Rebind(tree.GetObject(ObjectPath));
     }
 }
Beispiel #2
0
 public void Rebind(ObjectTree tree)
 {
     foreach (ParameterValue parameter in ByPath.Values)
     {
         parameter.Rebind(tree);
     }
 }
Beispiel #3
0
 public void Attach(ObjectTree tree)
 {
     foreach (object reference in tree.GetAllObjects())
     {
         FieldInfo field = reference.GetType().GetField("Logger");
         if (field != null)
             field.SetValue(reference, new ActiveHook(this, tree.GetPath(reference)));
     }
 }
Beispiel #4
0
 public ParameterValue(string objectPath, ObjectTree tree, FieldInfo field)
 {
     ObjectPath = objectPath;
     ObjectReference = tree.GetObject(objectPath);
     FieldPath = objectPath + "." + field.Name;
     Field = field;
     foreach (object attribute in field.GetCustomAttributes(typeof(ParameterAttribute), true))
         Attribute = attribute as ParameterAttribute;
     ReadAttribute();
     ReadValue();
 }
Beispiel #5
0
 public ParameterValue(string objectPath, ObjectTree tree, FieldInfo field)
 {
     ObjectPath      = objectPath;
     ObjectReference = tree.GetObject(objectPath);
     FieldPath       = objectPath + "." + field.Name;
     Field           = field;
     foreach (object attribute in field.GetCustomAttributes(typeof(ParameterAttribute), true))
     {
         Attribute = attribute as ParameterAttribute;
     }
     ReadAttribute();
     ReadValue();
 }
Beispiel #6
0
 public void Adjust(object root, int dpi, Action function)
 {
     ObjectTree tree = new ObjectTree();
     tree.Scan(root, "Dpi");
     Initialize(tree);
     try
     {
         Adjust(dpi);
         function();
     }
     finally
     {
         Revert();
     }
 }
Beispiel #7
0
 public void Add(ObjectTree tree)
 {
     foreach (string objectPath in tree.GetAllPaths())
     {
         object objectReference = tree.GetObject(objectPath);
         foreach (FieldInfo field in objectReference.GetType().GetFields())
         {
             foreach (object attribute in field.GetCustomAttributes(typeof(ParameterAttribute), true))
             {
                 ParameterValue parameter = new ParameterValue(objectPath, tree, field);
                 ByPath[parameter.FieldPath] = parameter;
             }
         }
     }
 }
Beispiel #8
0
        public void Adjust(object root, int dpi, Action function)
        {
            ObjectTree tree = new ObjectTree();

            tree.Scan(root, "Dpi");
            Initialize(tree);
            try
            {
                Adjust(dpi);
                function();
            }
            finally
            {
                Revert();
            }
        }
Beispiel #9
0
 public void Initialize(ObjectTree tree)
 {
     Parameters.Clear();
     foreach (string path in tree.GetAllPaths())
     {
         object nested = tree.GetObject(path);
         foreach (FieldInfo field in nested.GetType().GetFields())
             foreach (object attribute in field.GetCustomAttributes(typeof(DpiAdjustedAttribute), true))
             {
                 Parameter parameter = new Parameter();
                 parameter.Value = new ParameterValue(path, tree, field);
                 parameter.OriginalValue = parameter.Value.Value.Double;
                 parameter.Attribute = attribute as DpiAdjustedAttribute;
                 Parameters.Add(parameter);
             }
     }
 }
Beispiel #10
0
 public void Initialize(ObjectTree tree)
 {
     Parameters.Clear();
     foreach (string path in tree.GetAllPaths())
     {
         object nested = tree.GetObject(path);
         foreach (FieldInfo field in nested.GetType().GetFields())
         {
             foreach (object attribute in field.GetCustomAttributes(typeof(DpiAdjustedAttribute), true))
             {
                 Parameter parameter = new Parameter();
                 parameter.Value         = new ParameterValue(path, tree, field);
                 parameter.OriginalValue = parameter.Value.Value.Double;
                 parameter.Attribute     = attribute as DpiAdjustedAttribute;
                 Parameters.Add(parameter);
             }
         }
     }
 }
Beispiel #11
0
 public static void CopyHooks(object original, object copy)
 {
     ObjectTree originalTree = new ObjectTree(original);
     ObjectTree copyTree = new ObjectTree(copy);
     foreach (object originalReference in originalTree.GetAllObjects())
     {
         FieldInfo field = originalReference.GetType().GetField("Logger");
         if (field != null)
         {
             object hook = field.GetValue(originalReference);
             if (hook is ActiveHook)
             {
                 string path = originalTree.GetPath(originalReference);
                 if (copyTree.Contains(path))
                 {
                     object copyReference = copyTree.GetObject(path);
                     field.SetValue(copyReference, (hook as ActiveHook).Clone());
                 }
             }
         }
     }
 }
Beispiel #12
0
 public ParameterSet(ObjectTree tree)
 {
     Add(tree);
 }
Beispiel #13
0
 public void Rebind(ObjectTree tree)
 {
     if (tree.Contains(ObjectPath))
         Rebind(tree.GetObject(ObjectPath));
 }