Пример #1
0
        private void btnAddFilter_Click(object sender, EventArgs e)
        {
            string text      = textBoxName.Text;
            Filter hasFilter = ProjectUtils.GetFilter(text);

            if (hasFilter != null)
            {
                InfoDialog.ShowDialog(this, "This filter already exists!", "Error!");
                return;
            }

            if (Globals.IsStringValid(text))
            {
                TreeNode newNode = new TreeNode(text);
                newNode.ContextMenuStrip = _filterStrip;
                newNode.ImageIndex       = newNode.SelectedImageIndex = newNode.StateImageIndex = 1;
                _node.Nodes.Add(newNode);
                Filter newSubFilter = _filter.AddSubFilter(text);
                string fullPath     = string.Format("{0}\\{1}", ProjectUtils.GetProjectDirectory(), newSubFilter.GetFilterDirectory());
                Directory.CreateDirectory(fullPath);

                _node.ExpandAll();
                Close();
            }
        }
        private void btnReverse_Click(object sender, EventArgs e)
        {
            string inputFile  = textBoxInput.Text;
            string outputFile = textBoxOutput.Text;

            if (string.IsNullOrEmpty(inputFile) || string.IsNullOrEmpty(outputFile))
            {
                return;
            }

            if (!File.Exists(inputFile))
            {
                return;
            }

            SMDParser smdFile = new SMDParser(inputFile);

            if (smdFile.ParseSMDFile())
            {
                smdFile.ReverseAnimation(outputFile);
                InfoDialog.ShowDialog(this, string.Format("Successfully reversed the animation!\nPath: {0}", outputFile), "Success!");
                Close();
            }
        }
Пример #3
0
        private void btnAddFile_Click(object sender, EventArgs e)
        {
            string fileName = textBoxName.Text;
            string path     = fileName;

            if (File.Exists(fileName))
            {
                path = string.Format("{0}\\{1}", _filter.GetFilterDirectory(), Path.GetFileName(fileName));
                QCParser importedQC = new QCParser(fileName);
                if (!importedQC.ImportDependenciesToPath(string.Format("{0}\\{1}", ProjectUtils.GetProjectDirectory(), Path.GetDirectoryName(path))))
                {
                    try
                    {
                        File.Copy(fileName, string.Format("{0}\\{1}", ProjectUtils.GetProjectDirectory(), path), true);
                    }
                    catch
                    {
                        LoggingUtils.LogEvent("Failed to import a file!");
                    }
                }
            }
            else
            {
                if (!Globals.IsStringValid(fileName))
                {
                    return;
                }

                path = string.Format("{0}\\{1}", _filter.GetFilterDirectory(), fileName);
            }

            if (!fileName.EndsWith(".qc", StringComparison.InvariantCultureIgnoreCase) && !fileName.EndsWith(".qci", StringComparison.InvariantCultureIgnoreCase))
            {
                InfoDialog.ShowDialog(this, "Invalid file extension!", "Error!");
                return;
            }

            string hasFile = ProjectUtils.GetFilePathForTreeNodeItem(_filter.GetName(), Path.GetFileName(path));

            if (!string.IsNullOrEmpty(hasFile))
            {
                InfoDialog.ShowDialog(this, "This file already exists in the choosen filter!", "Error!");
                return;
            }

            string fullPath = string.Format("{0}\\{1}", ProjectUtils.GetProjectDirectory(), path);

            if (!File.Exists(fullPath))
            {
                Directory.CreateDirectory(Path.GetDirectoryName(fullPath));
                File.WriteAllText(fullPath, "");
            }

            _filter.AddFile("local", path);

            TreeNode newNode = new TreeNode(Path.GetFileName(path));

            newNode.ContextMenuStrip = _fileStrip;
            newNode.ImageIndex       = newNode.SelectedImageIndex = newNode.StateImageIndex = 0;
            _node.Nodes.Add(newNode);
            _node.ExpandAll();

            Close();
        }