Ejemplo n.º 1
0
        private void openToolStripMenuItem_Click(object sender, EventArgs e)
        {
            var openFileDialog = new OpenFileDialog();

            openFileDialog.Filter           = "LAS files (*.las, *.LAS)|*.LAS;*.las|All files (*.*)|*.*";
            openFileDialog.Multiselect      = false;
            openFileDialog.InitialDirectory = AppDomain.CurrentDomain.BaseDirectory;

            var wasOpenedRecently = false;

            if (openFileDialog.ShowDialog() == DialogResult.OK)
            {
                foreach (var filename in openFileDialog.FileNames)
                {
                    var name = filename.Split('\\').Last();

                    foreach (var file in recentActiveFileList)
                    {
                        if (file.filename == name)
                        {
                            currentActiveFile = file;
                            wasOpenedRecently = true;
                            break;
                        }
                    }

                    if (!wasOpenedRecently)
                    {
                        if (recentActiveFileList.Count > 5)
                        {
                            recentActiveFileList.Remove(recentActiveFileList.First());
                        }
                        var lasDataObj = new LasData(filename);
                        currentActiveFile = lasDataObj;
                        recentActiveFileList.Add(lasDataObj);

                        recentlyOpenedToolStripMenuItem.Enabled = true;

                        var lastOpenedFileList = recentlyOpenedToolStripMenuItem;
                        var lastOpenedFile     = new ToolStripMenuItem {
                            Text = lasDataObj.filename
                        };

                        lastOpenedFile.Click  += LastOpenedFileOnClick;
                        lastOpenedFile.Enabled = true;

                        lastOpenedFileList.DropDownItems.Add(lastOpenedFile);
                        loadedFile = true;
                    }

                    adjustSelectionMenuForActiveChart();
                }
            }
        }
Ejemplo n.º 2
0
        private void LastOpenedFileOnClick(object sender, EventArgs eventArgs)
        {
            CurrentActiveChartsComboBox.Items.Clear();

            var menuItem = (ToolStripMenuItem)sender;

            foreach (var file in recentActiveFileList)
            {
                if (file.filename == menuItem.Text)
                {
                    currentActiveFile = file;
                }
            }

            adjustSelectionMenuForActiveChart();
        }