예제 #1
0
        private void OpenExecute(object param)
        {
            string fileName = param as string;

            if (String.IsNullOrEmpty(fileName))
            {
                OpenFileDialog dialog = new OpenFileDialog();
                dialog.Filter = "Assembly Files (*.asm)|*.asm|Include Files (*.inc)|*.inc|All Files(*.*)|*.*";
                if (dialog.ShowDialog() != DialogResult.OK)
                {
                    return;
                }
                fileName = dialog.FileName;
            }
            // If the file is opened try to find it and activate
            for (int i = 0; i < Sources.Count; i++)
            {
                if (string.Equals(Sources[i].Document.FileName, fileName, StringComparison.OrdinalIgnoreCase))
                {
                    SelectedSourceIndex = i;
                    return;
                }
            }
            var source = new SourceViewModel(fileName);

            Sources.Add(source);
            SelectedSourceIndex = Sources.Count - 1;
        }
예제 #2
0
        private void NewExecute(object param)
        {
            SaveFileDialog dialog = new SaveFileDialog
            {
                Title           = "New File",
                DefaultExt      = "asm",
                OverwritePrompt = true,
                FileName        = "file.asm",
                Filter          = "Assembly File (*.asm)|*.asm|Include File (*.inc)|*.inc"
            };

            if (dialog.ShowDialog() == DialogResult.OK)
            {
                var source = new SourceViewModel(dialog.FileName);
                Sources.Add(source);
                SelectedSourceIndex = Sources.Count - 1;
            }
        }