Ok hello sharpcorner
i been having a issue now for ages and cant seem to find out why its causing me issues but here is a lines of the code
Ok main form1
- elfenlied_program_settings elf;
- addingweapons elf_weap;
- Parser elfenliedl;
- gscadding elfy1;
- //Parser parser = new Parser("model1887_sp");
- public Form1()
- {
- InitializeComponent();
- updater1.CheckForUpdates();
- listBoxAdv1.Visible = false;
- elf = new elfenlied_program_settings(listBoxAdv1,elfenliedl);
- elf_weap = new addingweapons(richTextBoxEx1);
- elfenliedl = new Parser("model1887_sp");
- elfy1 = new gscadding(this, elf_weap);
- elfy1.elfygsc = this;
- timer1.Start();
- elf.buttonX2 = buttonX2;
- elf.elfenform = this;
- // elfe.elfgsc = this;
- buttonX2.Visible = false;
- buttonX3.Enabled = true;
- textBoxX6.Enabled = false;
- elfenliedl.buttonX1 = buttonX1;
- // last thing to add hopfully
- if (Properties.Settings.Default.root.Equals("First"))
- {
- if (Directory.Exists(wawpath))
- {
- Properties.Settings.Default.root.Equals(wawpath);
- string rootsave = wawpath;
- Properties.Settings.Default.root = rootsave;
- Properties.Settings.Default.Save();
- listBoxAdv1.Visible = true;
- root = Properties.Settings.Default.root;
- buttonX2.Visible = true;
- elf.newlistbox();
- elf.listboxfunction();
- updatesettings();
- }
- }
- else
- {
- MessageBox.Show("we did not hit it");
- }
- }
the methord i want to reach in form1
- public void updatesettings()
- {
- mods = Properties.Settings.Default.mods + "//maps//_zombiemode_weapons.gsc";
- dlc3code = Properties.Settings.Default.mods + "//maps//dlc3_code.gsc";
- zombiemodeweapons = Properties.Settings.Default.mods + "//maps//_zombiemode_weapons.gsc";
- }
and what im trying to do is get gscadder to revrence form 1 to update string paths as follows here
gscadding
and i want here to revrence updatesettings in form1
and i want here to revrence updatesettings in form1
- public SoundAlis sounds;
- public addingweapons dlc3gsc;
- public Form1 elfygsc;
- public gscadding(addingweapons dlc3)
- {
- dlc3gsc = dlc3;
- }
- public gscadding(Form1 elfygsc,addingweapons dlc3)
- {
- this.elfygsc = elfygsc;
- }
- ///
- /// MODEL 1887 DLC3....
- ///
- public void dlcexists()
- {
- elfygsc.updatesettings();
- if (dlc3gsc.Model1887 == true)
- {
- if (File.Exists(dlc3code))
- {
- MessageBox.Show("exists");
- }
- else
- {
- DialogResult dialogResult = MessageBox.Show("Dlc3code.gsc is not found in mods do you wish to copy.", "Dlc3_code.gsc not found in mods", MessageBoxButtons.YesNo);
- if (dialogResult == DialogResult.Yes)
- {
- File.Copy(Properties.Settings.Default.root + "\\raw\\maps\\dlc3_code.gsc", Properties.Settings.Default.mods + "//maps//dlc3_code.gsc", true);
- {
- string s = "include_weapon( \"model1887_sp\");"; //string s = "include_weapon( \"hk416_zm\");";
- string file = modspath1 + "//maps//dlc3_code.gsc";
- List<string> lines = new List<string>(System.IO.File.ReadAllLines(file));
- int index = lines.FindLastIndex(item => item.Contains(("include_weapon(")));
- if (index != -1)
- {
- lines.Insert(index + 1, s);//""
- }
- System.IO.File.WriteAllLines(file, lines);
- MessageBox.Show("done");
- }
- }
- else if (dialogResult == DialogResult.No)
- {
- MessageBox.Show("No Files Copied To Add files to the mystery box you will need to add lines later");
- }
- }
- }
addingweapons.cs
- SoundAlis sounds;
- gscadding elfgscadd;
- public bool M27 { get; set; }
- public bool Model1887 { get; set; }
- // copying files
- private void DirectoryCopy(
- string sourceDirName, string destDirName, bool copySubDirs)
- {
- DirectoryInfo dir = new DirectoryInfo(sourceDirName);
- DirectoryInfo[] dirs = dir.GetDirectories();
- // If the source directory does not exist, throw an exception.
- if (!dir.Exists)
- {
- throw new DirectoryNotFoundException(
- "Source directory does not exist or could not be found: "
- + sourceDirName);
- }
- // If the destination directory does not exist, create it.
- if (!Directory.Exists(destDirName))
- {
- Directory.CreateDirectory(destDirName);
- }
- // Get the file contents of the directory to copy.
- FileInfo[] files = dir.GetFiles();
- foreach (FileInfo file in files)
- {
- // Create the path to the new copy of the file.
- string temppath = Path.Combine(destDirName, file.Name);
- // Copy the file.
- file.CopyTo(temppath, true);
- }
- // If copySubDirs is true, copy the subdirectories.
- if (copySubDirs)
- {
- foreach (DirectoryInfo subdir in dirs)
- {
- // Create the subdirectory.
- string temppath = Path.Combine(destDirName, subdir.Name);
- // Copy the subdirectories.
- DirectoryCopy(subdir.FullName, temppath, copySubDirs);
- }
- }
- }
- public addingweapons(DevComponents.DotNetBar.Controls.RichTextBoxEx richtextboxelf)
- {
- richTextBoxEx1 = richtextboxelf;
- // opnwep = new Parser(this);
- elfgscadd = new gscadding(this);
- sounds = new SoundAlis(this, elfgscadd);
- elfgscadd.sounds = sounds;
- // textboxes
- }
Thank you in advance Saito
Vinoth RajendranPosted Jan 4, 2016, 2:23 PM
Saito HiragaPosted Jan 4, 2016, 2:17 PM
Vinoth RajendranPosted Jan 4, 2016, 1:38 PM
elfy1.elfygsc = this;
Saito HiragaPosted Jan 4, 2016, 1:01 PM
Vinoth RajendranPosted Jan 4, 2016, 12:29 PM
Saito HiragaPosted Jan 4, 2016, 12:03 PM
Vinoth RajendranPosted Jan 3, 2016, 11:40 PM
{
this.elfygsc = elfygsc;
dlc3gsc = dlc3;
}
add this try again (same step in last reply your image) , still facing problem , send the code , Will fix it
Saito HiragaPosted Jan 3, 2016, 4:44 PM
Vinoth RajendranPosted Jan 3, 2016, 1:25 PM
Problem you are not passing the object for this.elfygsc in the addingweapons.cs file
public addingweapons(DevComponents.DotNetBar.Controls.RichTextBoxEx richtextboxelf)
where is elfygsc value assigning - I hope here is a problem , that's what you get the object null reference
Saito HiragaPosted Jan 3, 2016, 12:57 PM
Vinoth RajendranPosted Jan 3, 2016, 1:47 AM