コード例 #1
0
ファイル: EditorViewModel.cs プロジェクト: csuffyy/Sumerics
        public EditorViewModel(Kernel kernel, IConsole console, IMathInputService service)
        {
            _kernel  = kernel;
            _console = console;
            _service = service;
            _files   = new ObservableCollection <EditorFileViewModel>();
            _files.Add(new EditorFileViewModel(this, kernel));
            _create = new RelayCommand(x =>
            {
                var newfile = new EditorFileViewModel(this, _kernel);
                Files.Add(newfile);
                SelectedFile = newfile;
            });
            _open = new RelayCommand(x =>
            {
                var context = new OpenFileViewModel();
                context.AddFilter(Messages.AllFiles + " (*.*)", "*.*");
                context.AddFilter(Messages.YampScript + " (*.ys)", "*.ys");
                var dialog = new OpenFileWindow
                {
                    DataContext = context,
                    Title       = Messages.OpenFile
                };
                dialog.ShowDialog();

                if (context.Accepted)
                {
                    OpenFile(context.SelectedFile.FullName);
                }
            });
        }
コード例 #2
0
        private void tfenglishtxtToolStripMenuItem_Click(object sender, EventArgs e)
        {
            string ret = "";

            using (var diag = new OpenFileWindow())
            {
                Cursor = Cursors.WaitCursor;
                ret    = diag.ShowWindow("tf_english.txt", @"\tf\resource\");
            }
            Cursor = Cursors.Arrow;
            if (!String.IsNullOrEmpty(ret))
            {
                wait           = true;
                Cursor.Current = Cursors.WaitCursor;
                englishParser  = new ValveFormatParser(ret);
                englishParser.LoadFile();
                Cursor.Current = Cursors.Arrow;
                if (englishParser.RootNode.Key != "lang")
                {
                    MessageBox.Show("That is not tf_english.txt.\r\nPlease select tf_english.txt!",
                                    "TF2 Items Editor",
                                    MessageBoxButtons.OK,
                                    MessageBoxIcon.Error);
                    englishParser = null;
                    wait          = false;
                    return;
                }
                stripTxt.Text                 = "";
                stripTxt.Image                = null;
                groupTips.Enabled             = true;
                comboTipClasses.SelectedIndex = 0;
                wait = false;
            }
        }
コード例 #3
0
        private void itemsgametxtToolStripMenuItem_Click(object sender, EventArgs e)
        {
            string ret;

            using (var diag = new OpenFileWindow())
            {
                Cursor = Cursors.WaitCursor;
                ret    = diag.ShowWindow("items_game.txt", @"\tf\scripts\items\");
            }
            Cursor = Cursors.Arrow;
            if (!String.IsNullOrEmpty(ret))
            {
                Cursor.Current = Cursors.WaitCursor;
                itemsParser    = new ValveFormatParser(ret);
                itemsParser.LoadFile();
                Cursor.Current = Cursors.Arrow;
                if (itemsParser.RootNode.Key != "items_game")
                {
                    MessageBox.Show("That is not items_game.txt.\r\nPlease select items_game.txt!",
                                    "TF2 Items Editor",
                                    MessageBoxButtons.OK,
                                    MessageBoxIcon.Error);
                    itemsParser = null;
                    return;
                }
                LoadItems();
                stripTxt.Text  = "Edit->Attributes to open the attributes window!";
                stripTxt.Image = images.Images["Info"];
            }
        }
コード例 #4
0
ファイル: MainWindow.cs プロジェクト: Ahatornn/clforms
        private void OpenMenuItemClick(object sender, System.EventArgs e)
        {
            if (!SaveIfHasChanged())
            {
                return;
            }

            var dialogWnd = new OpenFileWindow {
                TargetFolder = targetMapFolder
            };

            if (dialogWnd.ShowDialog() == DialogResult.OK)
            {
                string[] mazeString;
                try
                {
                    mazeString = File.ReadAllLines(dialogWnd.FileName);
                }
                catch (Exception exception)
                {
                    MessageBox.ShowError(exception.Message);
                    return;
                }

                rowCount = mazeString.Length;
                colCount = mazeString[0].Length;

                var mazeCells = new int[rowCount, colCount];
                for (var rowIndex = 0; rowIndex < rowCount; rowIndex++)
                {
                    for (var colIndex = 0; colIndex < colCount; colIndex++)
                    {
                        var mazeCellValue = Convert.ToInt32(mazeString[rowIndex][colIndex].ToString());
                        mazeCells[rowIndex, colIndex] = mazeCellValue;
                        if (mazeCellValue == (int)MapItem.StartPoint)
                        {
                            startPoint = new Point(colIndex, rowIndex);
                        }

                        if (mazeCellValue == (int)MapItem.EndPoint)
                        {
                            endPoint = new Point(colIndex, rowIndex);
                        }
                    }
                }

                var mapWnd = new MapViewerWindow(mazeCells)
                {
                    panel1 = { Parent = panel1 }
                };
                PrepareStatusBar(new Size(colCount, rowCount));
                MapViewerWindowPrepare(mapWnd);
                fileName = Path.GetFileNameWithoutExtension(dialogWnd.FileName);
                SetWindowTitle();
            }
        }
コード例 #5
0
ファイル: MainWindow.xaml.cs プロジェクト: TomGnill/NYSS
        private void OpenFileWindow_Click(Object sender, RoutedEventArgs e)
        {
            OpenFileWindow openFileWindow = new OpenFileWindow();

            openFileWindow.Show();
        }
コード例 #6
0
ファイル: MainWindow.cs プロジェクト: Ahatornn/clforms
        private void OpenMenuItemClick(object sender, EventArgs e)
        {
            var dialogWnd = new OpenFileWindow {
                TargetFolder = targetMapFolder
            };

            if (dialogWnd.ShowDialog() == DialogResult.OK)
            {
                coins    = 0;
                keyCount = 0;
                steps    = 0;
                string[] mazeString;
                try
                {
                    var fileName = Path.GetFileNameWithoutExtension(dialogWnd.FileName);
                    if (fileName?.StartsWith('<') == true)
                    {
                        var assembly     = Assembly.GetExecutingAssembly();
                        var resourceName = assembly.GetManifestResourceNames()
                                           .Single(str => str.EndsWith($"{fileName.Substring(2, fileName.Length - 4)}.mmf"));
                        using var stream = assembly.GetManifestResourceStream(resourceName);
                        using var reader = new StreamReader(stream);
                        var resourceAllText = reader.ReadToEnd();

                        mazeString = Regex.Split(resourceAllText, "\r\n|\r|\n");
                    }
                    else
                    {
                        mazeString = File.ReadAllLines(dialogWnd.FileName);
                    }
                }
                catch (Exception exception)
                {
                    MessageBox.ShowError(exception.Message);
                    return;
                }

                rowCount = mazeString.Length;
                colCount = mazeString[0].Length;

                var mazeCells = new int[rowCount, colCount];
                for (var rowIndex = 0; rowIndex < rowCount; rowIndex++)
                {
                    for (var colIndex = 0; colIndex < colCount; colIndex++)
                    {
                        var mazeCellValue = Convert.ToInt32(mazeString[rowIndex][colIndex].ToString());
                        mazeCells[rowIndex, colIndex] = mazeCellValue;
                        if (mazeCellValue == (int)MapItem.StartPoint)
                        {
                            startPoint = new Point(colIndex, rowIndex);
                        }
                    }
                }
                var mapWnd = new MapDiscoverWindow(mazeCells, startPoint)
                {
                    panel1 = { Parent = panel1 }
                };
                MapDiscoverWindowPrepare(mapWnd);
                PrepareStatusBar(new Size(colCount, rowCount));
                currentFileName = Path.GetFileNameWithoutExtension(dialogWnd.FileName);
                SetWindowTitle(currentFileName);
            }
        }