Skip to content

Commit 6be1d3b

Browse files
committed
Multiple: update to use new paths
1 parent b0c40ec commit 6be1d3b

37 files changed

+195
-1157
lines changed

Controls/DefaultSettings.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ void updatedefaultlist(object crap)
6060

6161
private void BUT_paramfileload_Click(object sender, EventArgs e)
6262
{
63-
string filepath = Application.StartupPath + Path.DirectorySeparatorChar + CMB_paramfiles.Text;
63+
string filepath = Settings.GetUserDataDirectory() + CMB_paramfiles.Text;
6464

6565
if (CMB_paramfiles.SelectedValue == null)
6666
{

Controls/PreFlight/CheckListControl.cs

+3-2
Original file line numberDiff line numberDiff line change
@@ -8,16 +8,17 @@
88
using System.Windows.Forms;
99
using System.IO;
1010
using System.Collections;
11+
using MissionPlanner.Utilities;
1112

1213
namespace MissionPlanner.Controls.PreFlight
1314
{
1415
public partial class CheckListControl : UserControl
1516
{
1617
public List<CheckListItem> CheckListItems = new List<CheckListItem>();
1718

18-
public string configfile = "checklist.xml";
19+
public string configfile = Settings.GetUserDataDirectory() + "checklist.xml";
1920

20-
public string configfiledefault = "checklistDefault.xml";
21+
public string configfiledefault = Settings.GetRunningDirectory() + "checklistDefault.xml";
2122

2223
int rowcount = 0;
2324

Controls/SITL.cs

+2-1
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
using System.Text;
1515
using System.Text.RegularExpressions;
1616
using System.Windows.Forms;
17+
using MissionPlanner.Utilities;
1718

1819
namespace MissionPlanner.Controls
1920
{
@@ -24,7 +25,7 @@ public partial class SITL : MyUserControl, IActivate
2425

2526
Uri sitlurl = new Uri("http://firmware.ardupilot.org/Tools/MissionPlanner/sitl/");
2627

27-
string sitldirectory = Application.StartupPath + Path.DirectorySeparatorChar + "sitl" +
28+
string sitldirectory = Settings.GetUserDataDirectory() + "sitl" +
2829
Path.DirectorySeparatorChar;
2930

3031
GMapOverlay markeroverlay;

ExtLibs/Grid/GridUI.cs

+7-7
Original file line numberDiff line numberDiff line change
@@ -179,9 +179,9 @@ public GridUI(GridPlugin plugin)
179179
kmlpolygonsoverlay.Routes.Add(new GMapRoute(temp.Points,""));
180180
}
181181

182-
xmlcamera(false, "camerasBuiltin.xml");
182+
xmlcamera(false, Settings.GetRunningDirectory() + "camerasBuiltin.xml");
183183

184-
xmlcamera(false);
184+
xmlcamera(false, Settings.GetUserDataDirectory() + "cameras.xml");
185185

186186
loading = false;
187187
}
@@ -479,15 +479,15 @@ void savesettings()
479479
plugin.Host.config["grid_min_lane_separation"] = NUM_Lane_Dist.Value.ToString();
480480
}
481481

482-
private void xmlcamera(bool write, string filename = "cameras.xml")
482+
private void xmlcamera(bool write, string filename)
483483
{
484-
bool exists = File.Exists(Path.GetDirectoryName(Application.ExecutablePath) + Path.DirectorySeparatorChar + filename);
484+
bool exists = File.Exists(filename);
485485

486486
if (write || !exists)
487487
{
488488
try
489489
{
490-
XmlTextWriter xmlwriter = new XmlTextWriter(Path.GetDirectoryName(Application.ExecutablePath) + Path.DirectorySeparatorChar + filename, Encoding.ASCII);
490+
XmlTextWriter xmlwriter = new XmlTextWriter(filename, Encoding.ASCII);
491491
xmlwriter.Formatting = Formatting.Indented;
492492

493493
xmlwriter.WriteStartDocument();
@@ -524,7 +524,7 @@ private void xmlcamera(bool write, string filename = "cameras.xml")
524524
{
525525
try
526526
{
527-
using (XmlTextReader xmlreader = new XmlTextReader(Path.GetDirectoryName(Application.ExecutablePath) + Path.DirectorySeparatorChar + filename))
527+
using (XmlTextReader xmlreader = new XmlTextReader(Settings.GetDataDirectory() + filename))
528528
{
529529
while (xmlreader.Read())
530530
{
@@ -1532,7 +1532,7 @@ private void BUT_save_Click(object sender, EventArgs e)
15321532

15331533
cameras[CMB_camera.Text] = camera;
15341534

1535-
xmlcamera(true);
1535+
xmlcamera(true, Settings.GetUserDataDirectory() + "cameras.xml");
15361536
}
15371537

15381538
private void BUT_Accept_Click(object sender, EventArgs e)

ExtLibs/MissionPlanner.Gridv2/GridUIv2.cs

+7-7
Original file line numberDiff line numberDiff line change
@@ -560,15 +560,15 @@ private void num_ValueChanged(object sender, EventArgs e)
560560
doCalc();
561561
}
562562

563-
private void xmlcamera(bool write, string filename = "cameras.xml")
563+
private void xmlcamera(bool write, string filename)
564564
{
565-
bool exists = File.Exists(Path.GetDirectoryName(Application.ExecutablePath) + Path.DirectorySeparatorChar + filename);
565+
bool exists = File.Exists(filename);
566566

567567
if (write || !exists)
568568
{
569569
try
570570
{
571-
XmlTextWriter xmlwriter = new XmlTextWriter(Path.GetDirectoryName(Application.ExecutablePath) + Path.DirectorySeparatorChar + filename, Encoding.ASCII);
571+
XmlTextWriter xmlwriter = new XmlTextWriter(filename, Encoding.ASCII);
572572
xmlwriter.Formatting = Formatting.Indented;
573573

574574
xmlwriter.WriteStartDocument();
@@ -605,7 +605,7 @@ private void xmlcamera(bool write, string filename = "cameras.xml")
605605
{
606606
try
607607
{
608-
using (XmlTextReader xmlreader = new XmlTextReader(Path.GetDirectoryName(Application.ExecutablePath) + Path.DirectorySeparatorChar + filename))
608+
using (XmlTextReader xmlreader = new XmlTextReader(Settings.GetDataDirectory() + filename))
609609
{
610610
while (xmlreader.Read())
611611
{
@@ -683,7 +683,7 @@ private void xmlaircraft(string filename = "aircraft.xml")
683683
{
684684
try
685685
{
686-
using (XmlTextReader xmlreader = new XmlTextReader(Path.GetDirectoryName(Application.ExecutablePath) + Path.DirectorySeparatorChar + filename))
686+
using (XmlTextReader xmlreader = new XmlTextReader(Settings.GetDataDirectory() + filename))
687687
{
688688
while (xmlreader.Read())
689689
{
@@ -817,9 +817,9 @@ private void CMB_camera_SelectedIndexChanged(object sender, EventArgs e)
817817

818818
private void GridUI_Load(object sender, EventArgs e)
819819
{
820-
xmlcamera(false, "camerasBuiltin.xml");
820+
xmlcamera(false, Settings.GetRunningDirectory() + "camerasBuiltin.xml");
821821

822-
xmlcamera(false);
822+
xmlcamera(false, Settings.GetUserDataDirectory() + "cameras.xml");
823823

824824
xmlaircraft();
825825

ExtLibs/MissionPlanner.Stats/StatsPlugin.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ public class StatsPlugin : MissionPlanner.Plugin.Plugin
1717
whattostat statsoverall = new whattostat();
1818
whattostat statssession = new whattostat();
1919

20-
string statsfile = System.Windows.Forms.Application.StartupPath + System.IO.Path.DirectorySeparatorChar + "stats.xml";
20+
string statsfile = Settings.GetUserDataDirectory() + "stats.xml";
2121

2222
DateTime display = DateTime.MinValue;
2323

ExtLibs/Utilities/tfr.cs

+2-2
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ public class tfr
1818

1919
public static event EventHandler GotTFRs;
2020

21-
static string tfrurl = "http://www.jepptech.com/tfr/Query.asp?UserID=Public";
21+
public static string tfrurl = "http://www.jepptech.com/tfr/Query.asp?UserID=Public";
2222

2323
public static List<tfritem> tfrs = new List<tfritem>();
2424

@@ -35,7 +35,7 @@ public class tfr
3535

3636
// R is inclusive, B is exclusive
3737

38-
static string tfrcache = System.Windows.Forms.Application.StartupPath + Path.DirectorySeparatorChar + "tfr.xml";
38+
public static string tfrcache = "tfr.xml";
3939

4040
public static void GetTFRs()
4141
{

GCSViews/ConfigurationView/ConfigFirmware.cs

+1-93
Original file line numberDiff line numberDiff line change
@@ -342,99 +342,7 @@ private void lbl_devfw_Click(object sender, EventArgs e)
342342
UpdateFWList();
343343
CMB_history.Visible = false;
344344
}
345-
346-
private void lbl_px4io_Click(object sender, EventArgs e)
347-
{
348-
CustomMessageBox.Show("Please save the px4io.bin file to your microsd card to insert into your px4.", "IO");
349-
350-
var baseurl = "http://firmware.ardupilot.org/PX4IO/latest/PX4IO/px4io.bin";
351-
352-
try
353-
{
354-
// Create a request using a URL that can receive a post.
355-
var request = WebRequest.Create(baseurl);
356-
request.Timeout = 10000;
357-
// Set the Method property of the request to POST.
358-
request.Method = "GET";
359-
// Get the request stream.
360-
Stream dataStream; //= request.GetRequestStream();
361-
// Get the response.
362-
var response = request.GetResponse();
363-
// Display the status.
364-
log.Info(((HttpWebResponse) response).StatusDescription);
365-
// Get the stream containing content returned by the server.
366-
dataStream = response.GetResponseStream();
367-
368-
var bytes = response.ContentLength;
369-
var contlen = bytes;
370-
371-
var buf1 = new byte[1024];
372-
373-
var fs =
374-
new FileStream(
375-
Path.GetDirectoryName(Application.ExecutablePath) + Path.DirectorySeparatorChar + @"px4io.bin",
376-
FileMode.Create);
377-
378-
lbl_status.Text = Strings.DownloadingFromInternet;
379-
380-
Refresh();
381-
Application.DoEvents();
382-
383-
dataStream.ReadTimeout = 30000;
384-
385-
while (dataStream.CanRead)
386-
{
387-
try
388-
{
389-
progress.Value = 50;
390-
// (int)(((float)(response.ContentLength - bytes) / (float)response.ContentLength) * 100);
391-
progress.Refresh();
392-
}
393-
catch
394-
{
395-
}
396-
var len = dataStream.Read(buf1, 0, 1024);
397-
if (len == 0)
398-
break;
399-
bytes -= len;
400-
fs.Write(buf1, 0, len);
401-
}
402-
403-
fs.Close();
404-
dataStream.Close();
405-
response.Close();
406-
407-
lbl_status.Text = "Done";
408-
Application.DoEvents();
409-
}
410-
catch
411-
{
412-
CustomMessageBox.Show("Error receiving firmware", Strings.ERROR);
413-
return;
414-
}
415-
416-
using (var sfd = new SaveFileDialog())
417-
{
418-
sfd.FileName = "px4io.bin";
419-
if (sfd.ShowDialog() == DialogResult.OK)
420-
{
421-
if (sfd.FileName != "")
422-
{
423-
if (File.Exists(sfd.FileName))
424-
File.Delete(sfd.FileName);
425-
426-
File.Copy(
427-
Path.GetDirectoryName(Application.ExecutablePath) + Path.DirectorySeparatorChar +
428-
@"px4io.bin", sfd.FileName);
429-
}
430-
}
431-
}
432-
433-
progress.Value = 100;
434-
435-
CustomMessageBox.Show(
436-
"Please eject the microsd card, place into the px4, hold down the ioboard safety button, power on,\nand wait 60 seconds for the automated upgrade to take place.\nA upgrade status is created on your microsd card.");
437-
}
345+
438346

439347
private void lbl_dlfw_Click(object sender, EventArgs e)
440348
{

GCSViews/ConfigurationView/ConfigRawParams.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -516,7 +516,7 @@ void filterList(string searchfor)
516516

517517
private void BUT_paramfileload_Click(object sender, EventArgs e)
518518
{
519-
var filepath = Application.StartupPath + Path.DirectorySeparatorChar + CMB_paramfiles.Text;
519+
var filepath = Settings.GetUserDataDirectory() + CMB_paramfiles.Text;
520520

521521
try
522522
{

GCSViews/ConfigurationView/ConfigRawParamsTree.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -436,7 +436,7 @@ void filterList(string searchfor)
436436

437437
private void BUT_paramfileload_Click(object sender, EventArgs e)
438438
{
439-
var filepath = Application.StartupPath + Path.DirectorySeparatorChar + CMB_paramfiles.Text;
439+
var filepath = Settings.GetUserDataDirectory() + CMB_paramfiles.Text;
440440

441441
try
442442
{

GCSViews/ConfigurationView/ConfigSimplePids.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ public void Activate()
3434

3535
y = 10;
3636

37-
LoadXML(Path.GetDirectoryName(Application.ExecutablePath) + Path.DirectorySeparatorChar + "acsimplepids.xml");
37+
LoadXML(Settings.GetRunningDirectory() + "acsimplepids.xml");
3838
}
3939

4040
private void ConfigSimplePids_Load(object sender, EventArgs e)

GCSViews/FlightData.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -281,7 +281,7 @@ public FlightData()
281281

282282
// config map
283283
log.Info("Map Setup");
284-
gMapControl1.CacheLocation = Path.GetDirectoryName(Application.ExecutablePath) + Path.DirectorySeparatorChar +
284+
gMapControl1.CacheLocation = Settings.GetDataDirectory() +
285285
"gmapcache" + Path.DirectorySeparatorChar;
286286
gMapControl1.MinZoom = 0;
287287
gMapControl1.MaxZoom = 24;

GCSViews/FlightPlanner.cs

+2-2
Original file line numberDiff line numberDiff line change
@@ -513,7 +513,7 @@ public FlightPlanner()
513513
InitializeComponent();
514514

515515
// config map
516-
MainMap.CacheLocation = Path.GetDirectoryName(Application.ExecutablePath) + Path.DirectorySeparatorChar +
516+
MainMap.CacheLocation = Settings.GetDataDirectory() +
517517
"gmapcache" + Path.DirectorySeparatorChar;
518518

519519
// map events
@@ -705,7 +705,7 @@ Dictionary<string, string[]> readCMDXML()
705705

706706
// do lang stuff here
707707

708-
string file = Path.GetDirectoryName(Application.ExecutablePath) + Path.DirectorySeparatorChar + "mavcmd.xml";
708+
string file = Settings.GetRunningDirectory() + "mavcmd.xml";
709709

710710
if (!File.Exists(file))
711711
{

GeoRef/georefimage.cs

+1-2
Original file line numberDiff line numberDiff line change
@@ -1796,8 +1796,7 @@ static ImageCodecInfo GetImageCodec(string mimetype)
17961796

17971797
private void BUT_networklinkgeoref_Click(object sender, EventArgs e)
17981798
{
1799-
System.Diagnostics.Process.Start(Path.GetDirectoryName(Application.ExecutablePath) +
1800-
Path.DirectorySeparatorChar + "m3u" + Path.DirectorySeparatorChar +
1799+
System.Diagnostics.Process.Start(Settings.GetRunningDirectory() + "m3u" + Path.DirectorySeparatorChar +
18011800
"GeoRefnetworklink.kml");
18021801
}
18031802

Joystick/Joystick.cs

+3-2
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
using log4net;
55
using System.Reflection;
66
using System.IO;
7+
using MissionPlanner.Utilities;
78
using SharpDX.DirectInput;
89

910
namespace MissionPlanner.Joystick
@@ -330,8 +331,8 @@ public void loadconfig(string joystickconfigbutton = "joystickbuttons.xml",
330331
log.Info("Loading joystick config files " + joystickconfigbutton + " " + joystickconfigaxis);
331332

332333
// save for later
333-
this.joystickconfigbutton = Application11.StartupPath + Path.DirectorySeparatorChar + joystickconfigbutton;
334-
this.joystickconfigaxis = Application11.StartupPath + Path.DirectorySeparatorChar + joystickconfigaxis;
334+
this.joystickconfigbutton = Settings.GetUserDataDirectory() + joystickconfigbutton;
335+
this.joystickconfigaxis = Settings.GetUserDataDirectory() + joystickconfigaxis;
335336

336337
// load config
337338
if (File.Exists(joystickconfigbutton) && File.Exists(joystickconfigaxis))

Log/LogBrowse.cs

+2-2
Original file line numberDiff line numberDiff line change
@@ -396,7 +396,7 @@ private void readmavgraphsxml()
396396

397397
using (
398398
XmlReader reader =
399-
XmlReader.Create(Application.StartupPath + Path.DirectorySeparatorChar + "mavgraphs.xml"))
399+
XmlReader.Create(Settings.GetRunningDirectory() + "mavgraphs.xml"))
400400
{
401401
while (reader.Read())
402402
{
@@ -800,7 +800,7 @@ private void dataGridView1_RowEnter(object sender, DataGridViewCellEventArgs e)
800800

801801
using (
802802
XmlReader reader =
803-
XmlReader.Create(Path.GetDirectoryName(Application.ExecutablePath) + Path.DirectorySeparatorChar +
803+
XmlReader.Create(Settings.GetRunningDirectory() +
804804
"dataflashlog.xml"))
805805
{
806806
reader.Read();

Log/LogOutput.cs

+2-2
Original file line numberDiff line numberDiff line change
@@ -334,7 +334,7 @@ public void writeKMLFirstPerson(string filename)
334334

335335
File.Delete(filename);
336336

337-
filename = Path.GetDirectoryName(Application.ExecutablePath) + Path.DirectorySeparatorChar +
337+
filename = Settings.GetRunningDirectory() +
338338
"block_plane_0.dae";
339339

340340
// entry 2
@@ -1010,7 +1010,7 @@ public void writeKML(string filename)
10101010

10111011
File.Delete(filename);
10121012

1013-
filename = Path.GetDirectoryName(Application.ExecutablePath) + Path.DirectorySeparatorChar +
1013+
filename = Settings.GetRunningDirectory() +
10141014
"block_plane_0.dae";
10151015

10161016
// entry 2

Log/MavlinkLog.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -339,7 +339,7 @@ private void writeKML(string filename, double basealt = 0)
339339

340340
File.Delete(filename);
341341

342-
filename = Path.GetDirectoryName(Application.ExecutablePath) + Path.DirectorySeparatorChar +
342+
filename = Settings.GetRunningDirectory() +
343343
"block_plane_0.dae";
344344

345345
// entry 2

0 commit comments

Comments
 (0)