コード例 #1
0
        private void butOK_Click(object sender, EventArgs e)
        {
            // Test if everything is 'ok'
            if (!NgParameterInfo.TriggerIsValid(_level.Settings, TestTrigger))
            {
                if (DarkMessageBox.Show(this, "The currently selected trigger data is not valid for the engine.",
                                        "Trigger invalid", MessageBoxButtons.OKCancel, MessageBoxIcon.Exclamation) != DialogResult.OK)
                {
                    return;
                }
            }

            // Store some values like we have not NG triggers
            _trigger.TriggerType = TriggerType;
            _trigger.TargetType  = TargetType;
            _trigger.Target      = paramTarget.Parameter;
            _trigger.Timer       = paramTimer.Parameter;
            _trigger.Extra       = paramExtra.Parameter;
            _trigger.CodeBits    = CodeBits;
            _trigger.OneShot     = cbOneShot.Checked;

            // Close
            DialogResult = DialogResult.OK;
            Close();
        }
コード例 #2
0
        private void button_AddProgram_Click(object sender, EventArgs e)
        {
            using (OpenFileDialog dialog = new OpenFileDialog())
            {
                dialog.Title  = "Select the .exe file of the program you want to add";
                dialog.Filter = "Executable Files|*.exe|Batch Files|*.bat";

                if (dialog.ShowDialog(this) == DialogResult.OK)
                {
                    try
                    {
                        // Check for duplicates
                        foreach (DarkButton button in panel_Programs.Controls.OfType <DarkButton>())
                        {
                            if (button.Tag.ToString().ToLower() == dialog.FileName.ToLower())
                            {
                                throw new ArgumentException("Program shortcut already exists.");
                            }
                        }

                        AddProgramButton(dialog.FileName, true);
                    }
                    catch (Exception ex)
                    {
                        DarkMessageBox.Show(this, ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    }
                }
            }
        }
コード例 #3
0
        private void UpdateDataGrid()
        {
            dataGrid.Columns.Clear();

            try
            {
                string xmlPath = Path.Combine(DefaultPaths.GetReferencesPath(), comboBox_References.SelectedItem + ".xml");

                using (XmlReader reader = XmlReader.Create(xmlPath))
                    using (DataSet dataSet = new DataSet())
                    {
                        dataSet.ReadXml(reader);

                        DataTable dataTable = dataSet.Tables[0];

                        if (comboBox_References.SelectedIndex == 0)
                        {
                            DataTable pluginMnemonicTable = GetPluginMnemonicTable();

                            foreach (DataRow row in pluginMnemonicTable.Rows)
                            {
                                dataTable.Rows.Add(row.ItemArray[0].ToString(), row.ItemArray[1].ToString(), row.ItemArray[2].ToString());
                            }
                        }

                        DataColumn dcRowString = dataTable.Columns.Add("_RowString", typeof(string));

                        foreach (DataRow dataRow in dataTable.Rows)
                        {
                            StringBuilder builder = new StringBuilder();

                            for (int i = 0; i < dataTable.Columns.Count - 1; i++)
                            {
                                builder.Append(dataRow[i].ToString());
                                builder.Append("\t");
                            }

                            dataRow[dcRowString] = builder.ToString();
                        }

                        string filter = string.Empty;

                        if (!string.IsNullOrWhiteSpace(textBox_Search.Text) && textBox_Search.Text != "Search references...")
                        {
                            filter = textBox_Search.Text.Trim();
                        }

                        dataTable.DefaultView.RowFilter = "[_RowString] LIKE '%" + filter + "%'";

                        dataGrid.DataSource = dataTable;
                        dataGrid.Columns["_RowString"].Visible = false;

                        SetFriendlyColumnHeaders();
                    }
            }
            catch (Exception ex)
            {
                DarkMessageBox.Show(this, ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
コード例 #4
0
        public void Execute()
        {
            Util.Tic();
            var polygons = LoadPolygons();
            //Console.WriteLine("  Polygons: {0} (took {1}ms to load)", polygons.Count, Util.Toc());
            string loadingPolygons = $"Polygons: {polygons.Count} (took {Util.Toc()}ms to load)";

            Util.Tic();
            var sequentialInfo = RunSequential(polygons);
            //Console.WriteLine("Sequential: {0}ms", Util.Toc());
            string sequential = $"Sequential: {Util.Toc()}ms";

            Util.Tic();
            var parallelInfo = RunParallel(polygons);
            //Console.WriteLine("  Parallel: {0}ms", Util.Toc());
            string parallel = $"Parallel: {Util.Toc()}ms";
            //var dummymesh = new Mesh(new Configuration());
            var mesher = new GenericMesher(new Configuration());

            DarkMessageBox.Show($"{Name} - {Description}", $"{loadingPolygons}\n{sequential} {sequentialInfo} \n{parallel} {parallelInfo}");

            foreach (var poly in polygons)
            {
                InputGenerated(mesher.Triangulate(poly), EventArgs.Empty);
                DarkMessageBox.Show("Just showing all the read poly files", "Show next");
            }
        }
コード例 #5
0
        private void UpdatePreview()
        {
            try
            {
                string splashImagePath = Path.Combine(_ide.Project.EnginePath, "splash.bmp");

                if (File.Exists(splashImagePath))
                {
                    using (Image image = Image.FromFile(Path.Combine(_ide.Project.EnginePath, "splash.bmp")))
                    {
                        if ((image.Width == 1024 && image.Height == 512) ||
                            (image.Width == 768 && image.Height == 384) ||
                            (image.Width == 512 && image.Height == 256))
                        {
                            panel_Preview.BackgroundImage = ImageHandling.ResizeImage(image, 460, 230);
                            label_Blank.Visible           = false;
                        }
                        else
                        {
                            label_Blank.Visible = true;
                        }
                    }
                }
                else
                {
                    label_Blank.Visible = true;
                }
            }
            catch (Exception ex)
            {
                DarkMessageBox.Show(this, ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
コード例 #6
0
        private void button_Reset_Click(object sender, EventArgs e)
        {
            DialogResult result = DarkMessageBox.Show(this, "Are you sure you want to restore the default icon?", "Are you sure?",
                                                      MessageBoxButtons.YesNo, MessageBoxIcon.Question);

            if (result == DialogResult.Yes)
            {
                string icoFilePath = string.Empty;

                if (_ide.Project.GameVersion == TRVersion.Game.TR4 || _ide.Project.GameVersion == TRVersion.Game.TRNG)
                {
                    if (_ide.Project.GameVersion == TRVersion.Game.TRNG && File.Exists(Path.Combine(_ide.Project.EnginePath, "flep.exe")))
                    {
                        icoFilePath = Path.Combine(DefaultPaths.GetDefaultTemplatesPath(_ide.Project.GameVersion), "FLEP.ico");
                    }
                    else
                    {
                        icoFilePath = Path.Combine(DefaultPaths.GetDefaultTemplatesPath(_ide.Project.GameVersion), _ide.Project.GameVersion + ".ico");
                    }
                }
                else if (_ide.Project.GameVersion == TRVersion.Game.TR5Main)
                {
                    icoFilePath = Path.Combine(DefaultPaths.GetDefaultTemplatesPath(_ide.Project.GameVersion), _ide.Project.GameVersion + ".ico");
                }

                ApplyIconToExe(icoFilePath);
            }
        }
コード例 #7
0
        private bool IsValidGameLauncher()
        {
            // Check if the launcher file exists, if not, then try to find it
            if (!File.Exists(_selectedProject.LaunchFilePath))
            {
                try
                {
                    string launchFilePath = FileFinder.GetLauncherPathFromProject(_selectedProject);

                    _selectedProject.LaunchFilePath = launchFilePath;
                    _selectedProject.Save();

                    return(true);
                }
                catch (Exception ex)
                {
                    DarkMessageBox.Show(this, ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    return(false);
                }
            }
            else
            {
                return(true);
            }
        }
コード例 #8
0
        private void button_UseBlank_Click(object sender, EventArgs e)
        {
            DialogResult result = DarkMessageBox.Show(this, "Are you sure you want to apply a blank image?", "Are you sure?",
                                                      MessageBoxButtons.YesNo, MessageBoxIcon.Question);

            if (result == DialogResult.Yes)
            {
                try
                {
                    Bitmap bitmap = new Bitmap(512, 256);

                    using (Graphics graphics = Graphics.FromImage(bitmap))
                    {
                        Rectangle imageSize = new Rectangle(0, 0, 512, 256);
                        graphics.FillRectangle(Brushes.Black, imageSize);
                    }

                    string pakFilePath  = Path.Combine(_ide.Project.EnginePath, @"data\uklogo.pak");
                    byte[] rawImageData = ImageHandling.GetRawDataFromBitmap(bitmap);

                    PakFile.SavePakFile(pakFilePath, rawImageData);
                    UpdatePreview();
                }
                catch (Exception ex)
                {
                    DarkMessageBox.Show(this, ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
            }
        }
コード例 #9
0
        private void butOK_Click(object sender, EventArgs e)
        {
            short ocb;

            if (!short.TryParse(tbOCB.Text, out ocb))
            {
                DarkMessageBox.Show(this, "The value of OCB field is not valid", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }

            _editor.UndoManager.PushObjectPropertyChanged(_movable);

            byte CodeBits = 0;

            CodeBits         |= (byte)(cbBit1.Checked ? 1 << 0 : 0);
            CodeBits         |= (byte)(cbBit2.Checked ? 1 << 1 : 0);
            CodeBits         |= (byte)(cbBit3.Checked ? 1 << 2 : 0);
            CodeBits         |= (byte)(cbBit4.Checked ? 1 << 3 : 0);
            CodeBits         |= (byte)(cbBit5.Checked ? 1 << 4 : 0);
            _movable.CodeBits = CodeBits;

            _movable.Invisible = cbInvisible.Checked;
            _movable.ClearBody = cbClearBody.Checked;

            _movable.Ocb = ocb;

            DialogResult = DialogResult.OK;
            Close();
        }
コード例 #10
0
        private void ButtonAddApplication_Click(object sender, EventArgs e)
        {
            var appName      = TextBoxFileName.Text;
            var fileLocation = TextBoxFileLocation.Text;

            if (string.IsNullOrWhiteSpace(appName))
            {
                _ = DarkMessageBox.Show(this, "You must enter a name for this application.", "Empty Name",
                                        MessageBoxIcon.Exclamation);
                return;
            }

            if (string.IsNullOrWhiteSpace(fileLocation))
            {
                _ = DarkMessageBox.Show(this, "You must enter the file path for this application.",
                                        "Empty File Location", MessageBoxIcon.Exclamation);
                return;
            }

            if (!File.Exists(fileLocation))
            {
                _ = DarkMessageBox.Show(this,
                                        "The file for this application doesn't exist on your computer. Please choose another file.",
                                        "File Doesn't Exist", MessageBoxIcon.Exclamation);
                return;
            }

            MainWindow.Settings.UpdateApplication(appName, fileLocation);
            LoadExternalApplications();
        }
コード例 #11
0
        public void DeleteConsoleItem()
        {
            try
            {
                if (DarkMessageBox.Show(this, "Do you really want to delete the selected item?", "Delete", MessageBoxButtons.YesNo, MessageBoxIcon.Warning) == DialogResult.Yes)
                {
                    var type = DgvConsoleFiles.CurrentRow.Cells[0].Value.ToString();
                    var name = DgvConsoleFiles.CurrentRow.Cells[2].Value.ToString();

                    var itemPath = TextBoxConsolePath.Text + name;

                    if (type.Equals("folder"))
                    {
                        SetConsoleStatus($"Deleting folder: {itemPath}");

                        FtpExtensions.DeleteDirectory(FtpClient, itemPath);

                        SetConsoleStatus("Successfully deleted folder.");
                    }
                    else if (type.Equals("file"))
                    {
                        SetConsoleStatus($"Deleting file: {itemPath}");
                        FtpExtensions.DeleteFile(FtpClient, itemPath);
                        SetConsoleStatus("Successfully deleted file.");
                    }

                    DgvConsoleFiles.Rows.RemoveAt(DgvConsoleFiles.CurrentRow.Index);
                }
            }
            catch (Exception ex)
            {
                SetConsoleStatus($"Unable to delete item. Error: {ex.Message}", ex);
            }
        }
コード例 #12
0
        public void ErrorNewMessageBox(string title, string message)
        {
            DarkMessageBox msgResized = new DarkMessageBox(title, message);

            msgResized.StartPosition = FormStartPosition.CenterScreen;
            msgResized.Show();
        }
コード例 #13
0
        private void FormKeyboardLayout_KeyUp(object sender, KeyEventArgs e)
        {
            if (!listenKeys.Visible)
            {
                return;
            }
            if ((_listeningKeys & Keys.KeyCode) == Keys.None)
            {
                return;
            }

            if (Hotkey.ReservedCameraKeys.Contains(_listeningKeys))
            {
                DarkMessageBox.Show(this, "This key is reserved for camera movement. Please define another key.", "Reserved key", MessageBoxButtons.OK, MessageBoxIcon.Error);
                StopListening();
                return;
            }

            if (_listeningClearAfterwards)
            {
                _currConfig[_listeningDestination.Name]?.Clear();
            }
            _currConfig[_listeningDestination.Name].Add(_listeningKeys);

            RedrawList();
            StopListening();
        }
コード例 #14
0
        private void button_Apply_Click(object sender, EventArgs e)
        {
            try
            {
                string newName = PathHelper.RemoveIllegalPathSymbols(textBox_NewName.Text).Trim();

                if (string.IsNullOrWhiteSpace(newName))
                {
                    throw new ArgumentException("Invalid name.");
                }

                if (newName.Equals(Path.GetFileName(_targetItemPath), StringComparison.OrdinalIgnoreCase))
                {
                    DialogResult = DialogResult.Cancel;
                }
                else
                {
                    string newPath = Path.Combine(Path.GetDirectoryName(_targetItemPath), newName + Path.GetExtension(_targetItemPath));

                    if (File.Exists(_targetItemPath))
                    {
                        File.Move(_targetItemPath, newPath);
                    }
                    else
                    {
                        Directory.Move(_targetItemPath, newPath);
                    }
                }
            }
            catch (Exception ex)
            {
                DarkMessageBox.Show(this, ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                DialogResult = DialogResult.None;
            }
        }
コード例 #15
0
        private void ButtonAddGame_Click(object sender, EventArgs e)
        {
            if (ComboBoxGameTitle.SelectedIndex == -1)
            {
                _ = DarkMessageBox.Show(this, "You must first specify a game title.", "No Game Title",
                                        MessageBoxIcon.Exclamation);
                return;
            }

            if (ComboBoxGameRegion.SelectedIndex == -1)
            {
                _ = DarkMessageBox.Show(this, "You must specify a game region.", "No Game Region",
                                        MessageBoxIcon.Exclamation);
                return;
            }

            var gameTitle  = ComboBoxGameTitle.GetItemText(ComboBoxGameTitle.SelectedItem);
            var gameRegion = ComboBoxGameRegion.GetItemText(ComboBoxGameRegion.SelectedItem);

            var gameId = MainWindow.Database.Categories.GetCategoryByTitle(gameTitle).Id;

            DgvGameRegions.Rows.Add(gameTitle, gameRegion);
            MainWindow.Settings.UpdateGameRegion(gameId, gameRegion);
            LoadSavedRegions();
        }
コード例 #16
0
        private void button_Reset_Click(object sender, EventArgs e)
        {
            DialogResult result = DarkMessageBox.Show(this, "Are you sure you want to restore the default image?", "Are you sure?",
                                                      MessageBoxButtons.YesNo, MessageBoxIcon.Question);

            if (result == DialogResult.Yes)
            {
                try
                {
                    string sourcePakPath = string.Empty;

                    if (_ide.Project.GameVersion == TRVersion.Game.TR4 || _ide.Project.GameVersion == TRVersion.Game.TRNG)
                    {
                        sourcePakPath = Path.Combine(DefaultPaths.GetDefaultTemplatesPath(_ide.Project.GameVersion), "uklogo.pak");
                    }
                    else if (_ide.Project.GameVersion == TRVersion.Game.TR5Main)
                    {
                        sourcePakPath = Path.Combine(DefaultPaths.GetDefaultTemplatesPath(_ide.Project.GameVersion), "uklogo.pak");
                    }

                    string destPakPath = Path.Combine(_ide.Project.EnginePath, @"data\uklogo.pak");

                    File.Copy(sourcePakPath, destPakPath, true);
                    UpdatePreview();
                }
                catch (Exception ex)
                {
                    DarkMessageBox.Show(this, ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
            }
        }
コード例 #17
0
        private void ButtonSaveAll_Click(object sender, EventArgs e)
        {
            foreach (DataGridViewRow row in DgvGameRegions.Rows)
            {
                var gameTitle  = row.Cells[0].Value.ToString();
                var gameRegion = row.Cells[1].Value.ToString();

                var gameId = MainWindow.Database.Categories.GetCategoryByTitle(gameTitle).Id;

                if (MainWindow.Database.Categories.GetGameRegions(gameId).Contains(gameRegion))
                {
                    MainWindow.Settings.UpdateGameRegion(gameId, gameRegion);
                }
                else
                {
                    _ = DarkMessageBox.Show(this,
                                            $"Region: {gameRegion} is not supported for Game: {gameTitle}\nPlease change the region to one that is supported for this game.", "Invalid Region",
                                            MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                    return;
                }
            }

            _ = DarkMessageBox.Show(this, "All game regions have now been saved.", "Saved",
                                    MessageBoxButtons.OK, MessageBoxIcon.Information);
            Close();
        }
コード例 #18
0
        private void ButtonBackupSave_Click(object sender, EventArgs e)
        {
            if (string.IsNullOrWhiteSpace(TextBoxLocalPath.Text) ||
                TextBoxLocalPath.Text.IndexOfAny(Path.GetInvalidPathChars()) != -1)
            {
                _ = DarkMessageBox.Show(this, "You must include a local file path for the game file backup.",
                                        "Empty Local Path", MessageBoxIcon.Exclamation);
                return;
            }

            if (string.IsNullOrWhiteSpace(TextBoxConsolePath.Text))
            {
                _ = DarkMessageBox.Show(this,
                                        "You must include a console path for for the game file backup. This is where the file will be restored at on the console.",
                                        "Empty Console Path", MessageBoxIcon.Exclamation);
                return;
            }

            BackupFile.CategoryId  = TextBoxGameId.Text;
            BackupFile.FileName    = Path.GetFileName(TextBoxConsolePath.Text);
            BackupFile.LocalPath   = TextBoxLocalPath.Text;
            BackupFile.InstallPath = TextBoxConsolePath.Text;

            Close();
        }
コード例 #19
0
        private void butPlay_Click(object sender, EventArgs e)
        {
            if (_soundId == -1)
            {
                return;
            }

            var soundInfo = _soundInfos.FirstOrDefault(soundInfo_ => soundInfo_.Id == _soundId);

            if (soundInfo == null)
            {
                DarkMessageBox.Show(this, "This sound is missing.", "Unable to play sound.", MessageBoxIcon.Information);
                return;
            }

            try
            {
                WadSoundPlayer.PlaySoundInfo(_editor.Level, soundInfo);
            }
            catch (Exception exc)
            {
                logger.Warn(exc, "Unable to play sample");
                DarkMessageBox.Show(this, "Playing sound failed. " + exc, "Unable to play sound.", MessageBoxIcon.Information);
            }
        }
コード例 #20
0
        private string GetFlagDescription(string flag, ReferenceType type)
        {
            string result = string.Empty;

            try
            {
                result = GetDescriptionFromRDDA(flag, type);

                if (string.IsNullOrEmpty(result) && type == ReferenceType.Mnemonics)
                {
                    result = GetDescriptionFromPlugin(flag);
                }

                if (!string.IsNullOrEmpty(result))
                {
                    result = Regex.Replace(result, @"\r\n?|\n", "\n");
                }
            }
            catch (Exception ex)
            {
                DarkMessageBox.Show(this, ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }

            return(result);
        }
コード例 #21
0
            /// <summary>
            ///     Return the user's game region, either automatically by searching existing console directories or prompt
            ///     the user to select one.
            /// </summary>
            /// <param name="owner">Parent form</param>
            /// <param name="gameId">Game Id</param>
            /// <returns></returns>
            public string GetGameRegion(Form owner, string gameId)
            {
                if (MainWindow.Settings.RememberGameRegions)
                {
                    var gameRegion = MainWindow.Settings.GetGameRegion(gameId);

                    if (!string.IsNullOrEmpty(gameRegion))
                    {
                        return(gameRegion);
                    }
                }

                if (MainWindow.Settings.AutoDetectGameRegion)
                {
                    var foundRegions = Regions.Where(region => MainWindow.FtpConnection.DirectoryExists($"/dev_hdd0/game/{region}")).ToList();

                    foreach (var region in foundRegions.Where(region => DarkMessageBox.Show(MainWindow.Window,
                                                                                            $"Game Region: {region} has been found for: {Title}\nIs this correct?", "Found Game Region",
                                                                                            MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes))
                    {
                        return(region);
                    }

                    _ = DarkMessageBox.Show(MainWindow.Window,
                                            "Could not find any regions on your console for this game title. You must install the game update for this title first.",
                                            "No Game Update", MessageBoxIcon.Error);
                    return(null);
                }

                return(DialogExtensions.ShowListInputDialog(owner, "Game Regions", Regions.ToList()));
            }
コード例 #22
0
        private void button_Apply_Click(object sender, EventArgs e)
        {
            try
            {
                string newName = PathHelper.RemoveIllegalPathSymbols(textBox_NewName.Text.Trim());

                if (string.IsNullOrWhiteSpace(newName))
                {
                    throw new ArgumentException("Invalid file name.");
                }

                if (newName == Path.GetFileName(_ide.Project.LaunchFilePath))
                {
                    DialogResult = DialogResult.Cancel;
                }
                else
                {
                    string newPath = Path.Combine(Path.GetDirectoryName(_ide.Project.LaunchFilePath), newName + ".exe");

                    File.Move(_ide.Project.LaunchFilePath, newPath);

                    _ide.Project.LaunchFilePath = newPath;
                    _ide.Project.Save();
                }
            }
            catch (Exception ex)
            {
                DarkMessageBox.Show(this, ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                DialogResult = DialogResult.None;
            }
        }
コード例 #23
0
 private static void CurrentDomain_UnhandledException(object sender, UnhandledExceptionEventArgs e)
 {
     MainWindow.Window.SetStatus($"An unknown error occurred: {((Exception) e.ExceptionObject).Message}",
                                 (Exception)e.ExceptionObject);
     _ = DarkMessageBox.Show(MainWindow.Window,
                             $"An unknown error occurred: {((Exception) e.ExceptionObject).Message}. If you keep receiving this issue when then report it on GitHub so we can investigate.");
 }
コード例 #24
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="backupFile"></param>
        public void RestoreGameFile(BackupFile backupFile)
        {
            try
            {
                if (!File.Exists(backupFile.LocalPath))
                {
                    _ = DarkMessageBox.Show(this,
                                            "This file backup doesn't exist on your computer. If your game doesn't have mods installed, then I would suggest you backup the original files.",
                                            "No File Found", MessageBoxIcon.Information);
                    return;
                }

                FtpExtensions.UploadFile(MainWindow.FtpConnection, backupFile.LocalPath, backupFile.InstallPath);
                _ = DarkMessageBox.Show(this,
                                        $"Successfully restored file: {backupFile.FileName} to path: {backupFile.InstallPath}",
                                        "Success", MessageBoxIcon.Information);
            }
            catch (Exception ex)
            {
                Program.Log.Error("There was an issue attempting to restore file.", ex);
                _ = DarkMessageBox.Show(this,
                                        "There was an issue restoring file. Make sure the local file exists on your computer.",
                                        "Error", MessageBoxIcon.Error);
            }
        }
コード例 #25
0
        private void OpenSelectedResource()
        {
            if (treeView_Resources.SelectedNodes.Count == 0)
            {
                return;
            }

            // Check if the clicked node is not a default node
            if (treeView_Resources.Nodes.Contains(treeView_Resources.SelectedNodes[0]))
            {
                return;
            }

            try
            {
                ProcessStartInfo startInfo = new ProcessStartInfo();

                if (treeView_Resources.SelectedNodes[0].ParentNode == treeView_Resources.Nodes[1])                 // Wad handling
                {
                    startInfo.FileName  = Path.Combine(DefaultPaths.GetProgramDirectory(), "WadTool.exe");
                    startInfo.Arguments = "\"" + treeView_Resources.SelectedNodes[0].Text + "\"";
                }
                else
                {
                    startInfo.FileName = treeView_Resources.SelectedNodes[0].Text;
                }

                Process.Start(startInfo);
            }
            catch (Exception ex)
            {
                DarkMessageBox.Show(this, ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
コード例 #26
0
        void OnDispatcherUnhandledException(object sender, System.Windows.Threading.DispatcherUnhandledExceptionEventArgs e)
        {
            string errorMessage = string.Format("An unhandled exception occurred: {0}", e.Exception.Message);

            DarkMessageBox.Show(errorMessage, "Error", MessageBoxButton.OK, MessageBoxImage.Error);
            e.Handled = true;
        }
コード例 #27
0
        private void button_Create_Click(object sender, EventArgs e)
        {
            try
            {
                string newFileName = PathHelper.RemoveIllegalPathSymbols(textBox_NewFileName.Text).Trim();

                if (string.IsNullOrWhiteSpace(newFileName))
                {
                    throw new ArgumentException("Invalid file name.");
                }

                newFileName += GetSelectedExtension();

                string targetDirectory = ((DirectoryInfo)treeView.SelectedNodes[0].Tag).FullName;

                foreach (string file in Directory.GetFiles(targetDirectory, "*.*", SearchOption.TopDirectoryOnly))
                {
                    if (newFileName.Equals(Path.GetFileName(file), StringComparison.OrdinalIgnoreCase))
                    {
                        throw new ArgumentException("A file with the same name already exists in that directory.");
                    }
                }

                // // // //
                NewFilePath = Path.Combine(targetDirectory, newFileName);
                // // // //
            }
            catch (Exception ex)
            {
                DarkMessageBox.Show(this, ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                DialogResult = DialogResult.None;
            }
        }
コード例 #28
0
        private void DeleteItem()
        {
            DarkTreeNode selectedNode = treeView.SelectedNodes[0];

            string message;

            if (IsDirectoryNode(selectedNode))
            {
                message = "Are you sure you want to move the \"" + treeView.SelectedNodes[0].Text + "\" folder into the recycle bin?";
            }
            else if (IsFileNode(selectedNode))
            {
                message = "Are you sure you want to move the \"" + treeView.SelectedNodes[0].Text + "\" file into the recycle bin?";
            }
            else
            {
                return;
            }

            DialogResult result = DarkMessageBox.Show(this, message, "Are you sure?", MessageBoxButtons.YesNo, MessageBoxIcon.Question);

            if (result == DialogResult.Yes)
            {
                if (IsDirectoryNode(selectedNode))
                {
                    FileSystem.DeleteDirectory(GetItemPathFromNode(selectedNode), UIOption.AllDialogs, RecycleOption.SendToRecycleBin);
                }
                else
                {
                    FileSystem.DeleteFile(GetItemPathFromNode(selectedNode), UIOption.AllDialogs, RecycleOption.SendToRecycleBin);
                }
            }
        }
コード例 #29
0
        private void button_Save_Click(object sender, EventArgs e)
        {
            try
            {
                string newName = RemoveIllegalPathSymbols(textBox_Name.Text).Trim();

                if (string.IsNullOrWhiteSpace(newName))
                {
                    throw new ArgumentException("Invalid name.");
                }

                string schemeFilePath = null;

                switch (_schemeType)
                {
                case ColorSchemeType.ClassicScript:
                {
                    string schemeFolderPath = DefaultPaths.GetClassicScriptColorConfigsPath();

                    foreach (string file in Directory.GetFiles(schemeFolderPath, "*.cssch", SearchOption.TopDirectoryOnly))
                    {
                        if (Path.GetFileNameWithoutExtension(file).Equals(newName, StringComparison.OrdinalIgnoreCase))
                        {
                            throw new ArgumentException("A scheme with the same name already exists.");
                        }
                    }

                    schemeFilePath = Path.Combine(schemeFolderPath, newName + ".cssch");
                    break;
                }

                case ColorSchemeType.Lua:
                {
                    string schemeFolderPath = DefaultPaths.GetLuaColorConfigsPath();

                    foreach (string file in Directory.GetFiles(schemeFolderPath, "*.luasch", SearchOption.TopDirectoryOnly))
                    {
                        if (Path.GetFileNameWithoutExtension(file).Equals(newName, StringComparison.OrdinalIgnoreCase))
                        {
                            throw new ArgumentException("A scheme with the same name already exists.");
                        }
                    }

                    schemeFilePath = Path.Combine(schemeFolderPath, newName + ".luasch");
                    break;
                }
                }

                // // // //
                SchemeFilePath = schemeFilePath;
                // // // //
            }
            catch (Exception ex)
            {
                DarkMessageBox.Show(this, ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                DialogResult = DialogResult.None;
            }
        }
コード例 #30
0
 private void ToolItemDeleteBackup_Click(object sender, EventArgs e)
 {
     if (DarkMessageBox.Show(this, "Do you really want to delete the selected item?", "Delete",
                             MessageBoxButtons.YesNo, MessageBoxIcon.Warning) == DialogResult.Yes)
     {
         MainWindow.Settings.BackupFiles.RemoveAt(DgvBackups.CurrentRow.Index);
         LoadBackupFiles();
     }
 }