Esempio n. 1
0
        private void ReadPresets(List <ProfilePreset> presets, XmlReader reader)
        {
            reader.Skip();
            int i = 0;

            while (reader.Read())
            {
                if (reader.NodeType != XmlNodeType.Element)
                {
                    continue;
                }
                if (reader.Name == "Preset")
                {
                    ProfilePreset pr;
                    if (i < presets.Count)
                    {
                        pr = presets[i];
                    }
                    else
                    {
                        pr = new ProfilePreset();
                        presets.Add(pr);
                    }
                    ReadPreset(pr, reader.ReadSubtree());
                    i++;
                }
            }
        }
Esempio n. 2
0
File: Profile.cs Progetto: bo3b/iZ3D
        public static Profile CreateDefaultProfile()
        {
            Profile p = new Profile();

            p._UserChangeProfileName = false;
            p._ShowFPS = false;
            p._ShowOnscreenMessages            = false;
            p._SeparationMode                  = 0;
            p._EnableClipping                  = false;
            p._ClippingWidth                   = 0.03f;
            p._PresenterSleepTime              = -2;
            p._WindowMode                      = 3;
            p._ForceVSyncOff                   = false;
            p._UseSimpleStereoProjectionMethod = false;
            p._SeparationScale                 = 1.0f;
            p._AutofocusWidth                  = 512;
            p._AutofocusHeight                 = 64;
            p._AutofocusSpeed                  = 1;
            p._AutofocusMaximumShift           = 0.2f;
            p._AutofocusVerticalPosition       = 0.495f;
            p._ShowWizard                      = true;
            p._SwapLnR          = false;
            p._DisableMouseLock = false;
            p.Keys.SetDefaultValues();
            for (int i = 0; i < 3; i++)
            {
                ProfilePreset preset = new ProfilePreset();
                preset.SetDefaultValues();
                p.Presets.Add(preset);
            }
            return(p);
        }
Esempio n. 3
0
        public object Clone()
        {
            ProfilePreset NewPreset = new ProfilePreset();

            NewPreset._AutoFocusEnable  = _AutoFocusEnable;
            NewPreset._One_div_ZPS      = _One_div_ZPS;
            NewPreset._StereoSeparation = _StereoSeparation;
            return(NewPreset);
        }
Esempio n. 4
0
 private void ReadPreset(ProfilePreset preset, XmlReader reader)
 {
     reader.Skip();
     while (reader.Read())
     {
         if (reader.NodeType != XmlNodeType.Element)
         {
             continue;
         }
         ProfileValueAttribute attr  = null;
         FieldInfo             field = GetFieldInfo(reader.Name, typeof(ProfilePreset), out attr);
         Debug.Assert(field != null);
         if (field == null)
         {
             continue;
         }
         reader.MoveToAttribute(0);
         field.SetValue(preset,
                        StringToValue(reader.Value, field.FieldType));
     }
 }
Esempio n. 5
0
        private void SavePreset(ProfilePreset preset, ProfilePreset defPreset, XmlNode node)
        {
            bool bDefPreset = (preset == defPreset);
            Type type       = typeof(ProfilePreset);

            foreach (FieldInfo field in type.GetFields(BindingFlags.NonPublic | BindingFlags.Instance))
            {
                ProfileValueAttribute attr = null;
                if (ProfileValueAttribute.IsProfileKey(field, out attr))
                {
                    bool bSetValue    = false;
                    bool bRemoveValue = false;
                    if (bDefPreset)
                    {
                        bSetValue = !attr.UserProfilesOnly;
                    }
                    else if (!attr.BaseProfileOnly)
                    {
                        if (defPreset == null)
                        {
                            bSetValue = true;
                        }
                        else
                        {
                            bSetValue    = !IsEqual(field.GetValue(preset), field.GetValue(defPreset));
                            bRemoveValue = true;
                        }
                    }
                    if (bSetValue)
                    {
                        SetValue(node, attr.Name, field.GetValue(preset));
                    }
                    else if (bRemoveValue)
                    {
                        RemoveValue(node, attr.Name);
                    }
                }
            }
        }
Esempio n. 6
0
        private void SavePresets(List <ProfilePreset> presets, List <ProfilePreset> defPresets, XmlNode node)
        {
            List <ProfilePreset> defaultPresets = DefaultProfile.Presets;
            bool bDefProfile = (presets == defaultPresets);

            XmlDocument doc        = node.OwnerDocument;
            XmlNode     InsideNode = FindNode(node.ChildNodes, "Presets");

            if (InsideNode == null)
            {
                InsideNode = doc.CreateElement("Presets", doc.DocumentElement.NamespaceURI);
                node.AppendChild(InsideNode);
            }

            XmlNode presetNode = FindNode(InsideNode.ChildNodes, "Preset");

            for (int i = 0; i < 3; i++)
            {
                if (i != 0)
                {
                    do
                    {
                        presetNode = presetNode.NextSibling;
                    } while (presetNode != null && String.Compare(presetNode.Name, "Preset") != 0);
                }
                ProfilePreset defPreset = i < defPresets.Count ? defPresets[i] : null;
                if (presetNode == null)
                {
                    presetNode = doc.CreateElement("Preset", doc.DocumentElement.NamespaceURI);
                    XmlAttribute attr = doc.CreateAttribute("Index");
                    attr.Value = i.ToString();
                    presetNode.Attributes.Append(attr);
                    InsideNode.AppendChild(presetNode);
                }
                SavePreset(presets[i], defPreset, presetNode);
            }
        }
Esempio n. 7
0
File: Profile.cs Progetto: bo3b/iZ3D
        public void ApplyValues(Profile profile)
        {
            Type type = typeof(Profile);

            foreach (FieldInfo field in type.GetFields(BindingFlags.NonPublic | BindingFlags.Instance))
            {
                ProfileValueAttribute attr = null;
                if (ProfileValueAttribute.IsProfileKey(field, out attr))
                {
                    object thisValue = field.GetValue(this);
                    object defValue  = field.GetValue(profile);
                    //Debug.Assert(defValue == null);
                    if (defValue != null && thisValue == null)
                    {
                        field.SetValue(this, defValue);
                    }
                }
            }

            // PRESETS SECTION
            for (int i = 0; i < 3; i++)
            {
                if (i >= profile.Presets.Count)
                {
                    break;
                }
                if (i >= _Presets.Count)
                {
                    ProfilePreset preset = new ProfilePreset();
                    _Presets.Add(preset);
                }
                bool bDefPreset = (_Presets[i] == profile.Presets[i]);
                type = typeof(ProfilePreset);
                foreach (FieldInfo field in type.GetFields(BindingFlags.NonPublic | BindingFlags.Instance))
                {
                    ProfileValueAttribute attr = null;
                    if (ProfileValueAttribute.IsProfileKey(field, out attr))
                    {
                        object thisValue = field.GetValue(_Presets[i]);
                        object defValue  = field.GetValue(profile.Presets[i]);
                        //Debug.Assert(defValue == null);
                        if (defValue != null && thisValue == null)
                        {
                            field.SetValue(_Presets[i], defValue);
                        }
                    }
                }
            }

            // KEYS SECTION
            ProfileKeys defaultKeys = profile.Keys;
            bool        bDefProfile = (profile.Keys == defaultKeys);

            type = typeof(ProfileKeys);
            foreach (FieldInfo field in type.GetFields(BindingFlags.NonPublic | BindingFlags.Instance))
            {
                ProfileValueAttribute attr = null;
                if (ProfileValueAttribute.IsProfileKey(field, out attr))
                {
                    object thisValue = field.GetValue(Keys);
                    object defValue  = field.GetValue(defaultKeys);
                    //Debug.Assert(defValue == null);
                    if (defValue != null && thisValue == null)
                    {
                        field.SetValue(Keys, defValue);
                    }
                }
            }
        }