Example #1
0
        private void OpenToolStripMenuItem_Click(object sender, EventArgs e)
        {
            OpenFileDialog dialog;
            Uri            map_path;
            Uri            current_path;

            dialog = new OpenFileDialog();
            dialog.InitialDirectory = System.IO.Directory.GetCurrentDirectory();

            dialog.Filter = "map files (*.map)|*.map";
            if (dialog.ShowDialog(this) != DialogResult.OK)
            {
                return;
            }

            current_path   = new Uri(System.IO.Directory.GetCurrentDirectory() + "\\");
            _Map_File_Name = dialog.FileName;

            if (_Map_File_Manager != null)
            {
                _Map_File_Manager.Close();
            }

            _Map_File_Manager = new MapFileManager(_Map_File_Name);

            map_path = new Uri(_Map_File_Name);
            _Ini_File.SetKeyValue("Map", "FilePath", current_path.MakeRelativeUri(map_path).ToString());

            this.Text = App.Name + " " + App.Version + " - " + _Map_File_Name;
        }
Example #2
0
        private void MainForm_Load(object sender, EventArgs e)
        {
            OpenFileDialog dialog;
            string         buffer;
            int            width;
            int            height;
            int            id;
            Uri            map_path;
            Uri            current_path;

            current_path = new Uri(System.IO.Directory.GetCurrentDirectory() + "\\");

            try
            {
                _Ini_File.Load(_Ini_File_Name);
            }
            catch
            {
                MessageBox.Show(this, "Unable to open/create " + _Ini_File_Name, "Fatal error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                Close();

                return;
            }

            CrossReferenceDataGridView.SetupFromIni(_Ini_File);
            RemovedSymbolDataGridView.SetupFromIni(_Ini_File);
            MaximumStackUsageDataGridView.SetupFromIni(_Ini_File);
            StackUsageDataGridView.SetupFromIni(_Ini_File);
            MutuallyRecursiveDataGridView.SetupFromIni(_Ini_File);
            FunctionPointerDataGridView.SetupFromIni(_Ini_File);
            LocalSymbolDataGridView.SetupFromIni(_Ini_File);
            GlobalSymbolDataGridView.SetupFromIni(_Ini_File);
            MemoryMapImageDataGridView.SetupFromIni(_Ini_File);
            ImageComponentSizeDataGridView.SetupFromIni(_Ini_File);

            current_path = new Uri(System.IO.Directory.GetCurrentDirectory() + "\\");

            try
            {
                _Map_File_Name = Uri.UnescapeDataString(_Ini_File.GetKeyValue("Map", "FilePath"));
                if (String.IsNullOrEmpty(_Map_File_Name))
                {
                    if (String.IsNullOrEmpty(_Ini_File_Path))
                    {
                        map_path       = new Uri(Path.Combine(System.IO.Directory.GetCurrentDirectory() + "\\", ("Application.map")));
                        _Map_File_Name = map_path.LocalPath;
                    }
                    else
                    {
                        map_path       = new Uri(Path.GetFullPath(Path.Combine(_Ini_File_Path + "\\", ("Application.map"))));
                        _Map_File_Name = map_path.LocalPath;
                    }
                }
                else
                {
                    _Map_File_Name = new Uri(current_path, _Map_File_Name).LocalPath;
                }
            }
            catch
            {
                _Map_File_Name = "";
            }

            if (!File.Exists(_Map_File_Name))
            {
                dialog = new OpenFileDialog();
                dialog.InitialDirectory = System.IO.Directory.GetCurrentDirectory();

                dialog.Filter = "map files (*.map)|*.map";
                if (dialog.ShowDialog(this) != DialogResult.OK)
                {
                    Close();

                    return;
                }

                _Map_File_Name = dialog.FileName;
            }

            _Map_File_Manager = new MapFileManager(_Map_File_Name);

            try
            {
                System.IO.File.ReadAllLines(_Map_File_Name);
            }
            catch
            {
                MessageBox.Show(this, "Unable to open " + _Map_File_Name, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                Close();

                return;
            }

            try
            {
                map_path = new Uri(current_path, _Map_File_Name);
                _Ini_File.SetKeyValue("Map", "FilePath", current_path.MakeRelativeUri(map_path).ToString());
            }
            catch
            {
            }

            buffer = _Ini_File.GetKeyValue("Window", "Width");
            try
            {
                width = int.Parse(buffer);
            }
            catch
            {
                width = 1000;
            }

            buffer = _Ini_File.GetKeyValue("Window", "Height");
            try
            {
                height = int.Parse(buffer);
            }
            catch
            {
                height = 600;
            }

            this.Size = new System.Drawing.Size(width, height);

            buffer = _Ini_File.GetKeyValue("Tab", "Selected");
            try
            {
                id = int.Parse(buffer);
            }
            catch
            {
                id = 0;
            }

            MainTabs.SelectedIndex = id;

            this.Text = App.Name + " " + App.Version + " - " + _Map_File_Name;
        }