What's new
  • Visit Rebornbuddy
  • Visit Panda Profiles
  • Visit LLamamMagic
  • Visit Resources
  • Visit Downloads
  • Visit Portal

Settings not saving, i don't get why!

  • Thread starter Thread starter weischbier
  • Start date Start date
W

weischbier

Guest
Ok, i try very hard to do this on my own.
I read through CodenameGamma's Guide carefully.
But i can't get the CC to save the Settings you can make in the GUI.

Here's the Code i use:

PHP:
using System.IO;
using Styx;
using Styx.Helpers;

namespace Necrophilia
{
    public class NecrophiliaSettings : Settings
    {
        public static readonly NecrophiliaSettings Instance = new NecrophiliaSettings();

        public NecrophiliaSettings()
            : base(Path.Combine(Logging.ApplicationPath, string.Format(@"CustomClasses/Config/MrBones-Settings-{0}.xml", StyxWoW.Me.Name)))

        {
        }
        ///////////////////////////////////////////////////////
        ///////////////////////////////////////////////////////
        /////////////////   <<General>>   /////////////////////
        ///////////////////////////////////////////////////////
        ///////////////////////////////////////////////////////
        //Spec Radio Box
        [Setting, DefaultValue(false)]
        public bool UseF { get; set; }//Frost PvE

        [Setting, DefaultValue(false)]
        public bool UseU { get; set; }//Frost PvP

        [Setting, DefaultValue(false)]
        public bool UsePvE { get; set; }//Unholy PvE

        [Setting, DefaultValue(false)]
        public bool UsePvP { get; set; }//Unholy PvP
        ///////////////////////////////////////////////////////
        ///////////////////////////////////////////////////////
        /////////////////   <<Frost>>   ///////////////////////
        ///////////////////////////////////////////////////////
        ///////////////////////////////////////////////////////
        

    }
}

PHP:
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using Styx.Helpers;

namespace Necrophilia
{
    public partial class NecrophiliaGUI : Form
    {
        public NecrophiliaGUI()
        {
            InitializeComponent();
        }

        private void NecrophiliaGUI_Load(object sender, EventArgs e)
        {
            NecrophiliaSettings.Instance.Load();
            UsecbF.Checked = NecrophiliaSettings.Instance.UseF;
            UsecbU.Checked = NecrophiliaSettings.Instance.UseU;
            UsecbPvE.Checked = NecrophiliaSettings.Instance.UsePvE;
            UsecbPvP.Checked = NecrophiliaSettings.Instance.UsePvP;
        }

        private void NecrophiliaGUI_FormClosing(object sender, FormClosingEventArgs e)
        {
            //General
            NecrophiliaSettings.Instance.UseF = UsecbF.Checked;
            NecrophiliaSettings.Instance.UseU = UsecbU.Checked;
            NecrophiliaSettings.Instance.UsePvP = UsecbPvE.Checked;
            NecrophiliaSettings.Instance.UsePvE = UsecbPvP.Checked;   
            Deathknight.Instance.Settings.Save();
        }

        private void button1_Click(object sender, EventArgs e)
        {
            this.Close();
        }

        private void UsecbF_CheckedChanged(object sender, EventArgs e)
        {
            NecrophiliaSettings.Instance.UseF = UsecbF.Checked;
        }

        private void UsecbU_CheckedChanged(object sender, EventArgs e)
        {
            NecrophiliaSettings.Instance.UseU = UsecbU.Checked;
        }

        private void UsecbPvE_CheckedChanged(object sender, EventArgs e)
        {
            NecrophiliaSettings.Instance.UsePvE = UsecbPvE.Checked;
        }

        private void UsecbPvP_CheckedChanged(object sender, EventArgs e)
        {
            NecrophiliaSettings.Instance.UsePvP = UsecbPvP.Checked;
        }
    }
}

if anybody notice what i'm doing wrong, i would be happiest person on this planet!
because i'm at a point where it gets me frustrated...


greetz

weischbier
 
dont use FourmClose, make an actuily save button and only have the save in there. since Currently your basically setting the buttons back to whats in your save file before you save it.
 
this is what it should, look like

Code:
<code><code>[COLOR=#000000][COLOR=#007700]
        private [/COLOR][COLOR=#0000bb]void NecrophiliaGUI_FormClosing[/COLOR][COLOR=#007700]([/COLOR][COLOR=#0000bb]object sender[/COLOR][COLOR=#007700], [/COLOR][COLOR=#0000bb]FormClosingEventArgs e[/COLOR][COLOR=#007700]) 
        { 
            [/COLOR][COLOR=#ff8000]//heres where the problem lies
            [/COLOR][COLOR=#0000bb]//NecrophiliaSettings[/COLOR][COLOR=#007700].[/COLOR][COLOR=#0000bb]Instance[/COLOR][COLOR=#007700].[/COLOR][COLOR=#0000bb]UseF [/COLOR][COLOR=#007700]= [/COLOR][COLOR=#0000bb]UsecbF[/COLOR][COLOR=#007700].[/COLOR][COLOR=#0000bb]Checked[/COLOR][COLOR=#007700]; 
            //[/COLOR][COLOR=#0000bb]NecrophiliaSettings[/COLOR][COLOR=#007700].[/COLOR][COLOR=#0000bb]Instance[/COLOR][COLOR=#007700].[/COLOR][COLOR=#0000bb]UseU [/COLOR][COLOR=#007700]= [/COLOR][COLOR=#0000bb]UsecbU[/COLOR][COLOR=#007700].[/COLOR][COLOR=#0000bb]Checked[/COLOR][COLOR=#007700]; 
            [/COLOR][COLOR=#0000bb]//NecrophiliaSettings[/COLOR][COLOR=#007700].[/COLOR][COLOR=#0000bb]Instance[/COLOR][COLOR=#007700].[/COLOR][COLOR=#0000bb]UsePvP [/COLOR][COLOR=#007700]= [/COLOR][COLOR=#0000bb]UsecbPvE[/COLOR][COLOR=#007700].[/COLOR][COLOR=#0000bb]Checked[/COLOR][COLOR=#007700]; 
            [/COLOR][COLOR=#0000bb]//NecrophiliaSettings[/COLOR][COLOR=#007700].[/COLOR][COLOR=#0000bb]Instance[/COLOR][COLOR=#007700].[/COLOR][COLOR=#0000bb]UsePvE [/COLOR][COLOR=#007700]= [/COLOR][COLOR=#0000bb]UsecbPvP[/COLOR][COLOR=#007700].[/COLOR][COLOR=#0000bb]Checked[/COLOR][COLOR=#007700];    
            [/COLOR][COLOR=#007700]
        } 

        private [/COLOR][COLOR=#0000bb]void button1_Click[/COLOR][COLOR=#007700]([/COLOR][COLOR=#0000bb]object sender[/COLOR][COLOR=#007700], [/COLOR][COLOR=#0000bb]EventArgs e[/COLOR][COLOR=#007700]) 
        { 
//dont know why you where trying to save DeathKnightSettings when your settings file is NerophilliaSettings
[/COLOR][/COLOR]</code></code><code><code></code></code><code><code>[COLOR=#000000][COLOR=#0000bb]NecrophiliaSettings[/COLOR][/COLOR]</code></code><code><code>[COLOR=#000000][COLOR=#007700].[/COLOR][COLOR=#0000bb]Instance[/COLOR][COLOR=#007700].[/COLOR][COLOR=#0000bb]Settings[/COLOR][COLOR=#007700].[/COLOR][COLOR=#0000bb]Save[/COLOR][COLOR=#007700](); [/COLOR][/COLOR]</code></code>
//To Help make sure that this button works correctly. 
Logging.Write("Settings Saved!");
<code><code>[COLOR=#000000][COLOR=#0000bb]this[/COLOR][COLOR=#007700].[/COLOR][COLOR=#0000bb]Close[/COLOR][COLOR=#007700](); 
        } 
[/COLOR][/COLOR]

</code></code>
 
Last edited:
THANK YOU VERY MUCH!!!!

I really would like to press the star but i need to spread some rep around first.

anyway, thank you Sir!

greetz Weischbier
 
Back
Top