コード例 #1
0
        private void ParamsForm_Load(object sender, EventArgs e)
        {
            _ed = new EDncrypt(Path.GetDirectoryName(Assembly.GetEntryAssembly().Location) + "\\config.dat", "", SaveProgressBar);
            _ed.StartDncrypt();
            if (!string.IsNullOrEmpty(_ed.DeContent))
            {
                //读取配置信息并反序列化
                DataContractJsonSerializer serializer = new DataContractJsonSerializer(typeof(ParamsModel));
                MemoryStream mStream = new MemoryStream(Encoding.UTF8.GetBytes(_ed.DeContent));
                ParamsModel  _pm     = (ParamsModel)serializer.ReadObject(mStream);
                mStream.Close();
                mStream.Dispose();

                SouceSriptTextBox.Text  = _pm.ScriptsFolder;
                OutScriptTextBox.Text   = _pm.OutPutFolder;
                TargetType.SelectedItem = _pm.FileType;
                FlagsTextBox.Text       = _pm.Flags;

                if (_pm.ComplieAruments.Count > 0)
                {
                    if (flowLayoutPanel1.HasChildren)
                    {
                        foreach (Control item in flowLayoutPanel1.Controls)
                        {
                            if (item is CheckBox)
                            {
                                CheckBox cb = item as CheckBox;
                                cb.Checked = _pm.ComplieAruments.Where(a => a.Equals(cb.Text)).Any();
                            }
                        }
                    }
                }
                if (_pm.AssemblyAruments.Count > 0)
                {
                    if (flowLayoutPanel2.HasChildren)
                    {
                        foreach (Control item in flowLayoutPanel2.Controls)
                        {
                            if (item is CheckBox)
                            {
                                CheckBox cb = item as CheckBox;
                                cb.Checked = _pm.AssemblyAruments.Where(a => a.Equals(cb.Text)).Any();
                            }
                        }
                    }
                }
            }
        }
コード例 #2
0
        /// <summary>
        /// 验证参数个数及有效性
        /// </summary>
        /// <param name="args"></param>
        /// <param name="filepath"></param>
        static string PackageArguments(ParamsModel args)
        {
            StringBuilder sb = new StringBuilder();

            if (args.ComplieAruments.Count > 0)
            {
                foreach (var item in args.ComplieAruments)
                {
                    sb.Append(item);
                }
            }

            sb.Append(" -f=\"" + args.Flags + "\"");
            sb.Append(" -i=\"" + args.ScriptsFolder + "\"");
            sb.Append(" -o=\"" + args.OutPutFolder + "\"");

            return(sb.ToString());
        }
コード例 #3
0
        private void ListFileForm_Load(object sender, EventArgs e)
        {
            _ed = new EDncrypt(Path.GetDirectoryName(Assembly.GetEntryAssembly().Location) + "\\config.dat", "", null);
            _ed.StartDncrypt();

            if (!string.IsNullOrEmpty(_ed.DeContent))
            {
                //读取配置信息并反序列化
                DataContractJsonSerializer serializer = new DataContractJsonSerializer(typeof(ParamsModel));
                MemoryStream mStream = new MemoryStream(Encoding.UTF8.GetBytes(_ed.DeContent));
                ParamsModel  _pm     = (ParamsModel)serializer.ReadObject(mStream);
                mStream.Close();
                mStream.Dispose();

                if (!String.IsNullOrEmpty(_pm.ScriptsFolder))
                {
                    sourcescriptfolder = _pm.ScriptsFolder;
                    Thread t = new Thread(new ParameterizedThreadStart(GetAllFiles));
                    t.Start(_pm.ScriptsFolder);
                }
            }
        }
コード例 #4
0
        private void ParamsSaveButton_Click(object sender, EventArgs e)
        {
            ParamsModel pm = new ParamsModel
            {
                Flags         = FlagsTextBox.Text,
                ScriptsFolder = SouceSriptTextBox.Text,
                OutPutFolder  = OutScriptTextBox.Text,
                FileType      = TargetType.Items[TargetType.SelectedIndex].ToString()
            };

            if (flowLayoutPanel1.HasChildren)
            {
                foreach (Control item in flowLayoutPanel1.Controls)
                {
                    if (item is CheckBox)
                    {
                        CheckBox cb = item as CheckBox;
                        if (cb.Checked)
                        {
                            pm.ComplieAruments.Add(cb.Text);
                        }
                    }
                }
            }
            if (flowLayoutPanel2.HasChildren)
            {
                foreach (Control item in flowLayoutPanel2.Controls)
                {
                    if (item is CheckBox)
                    {
                        CheckBox cb = item as CheckBox;
                        if (cb.Checked)
                        {
                            pm.AssemblyAruments.Add(cb.Text);
                        }
                    }
                }
            }

            try
            {
                //序列化对象
                DataContractJsonSerializer serializer = new DataContractJsonSerializer(pm.GetType());
                MemoryStream stream = new MemoryStream();
                serializer.WriteObject(stream, pm);
                byte[] dataBytes = new byte[stream.Length];
                stream.Position = 0;
                stream.Read(dataBytes, 0, (int)stream.Length);
                stream.Close();
                stream.Dispose();
                Action _ac = delegate() {
                    _ed = new EDncrypt(Path.GetDirectoryName(Assembly.GetEntryAssembly().Location) + "\\config.dat", Encoding.UTF8.GetString(dataBytes), SaveProgressBar);
                    _ed.StartEncrypt();
                };
                this.Invoke(_ac);
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
        }
コード例 #5
0
        /// <summary>
        /// 编译器编译文件
        /// </summary>
        /// <param name="pm">参数实体</param>
        /// <param name="args">编译参数</param>
        internal void RunCompiler()
        {
            EDncrypt _ed = new EDncrypt(Path.GetDirectoryName(Assembly.GetEntryAssembly().Location) + "\\config.dat", "", null);

            _ed.StartDncrypt();

            string PapyrusCompilerEXE = Path.GetDirectoryName(Assembly.GetEntryAssembly().Location) + "\\" + PapyrusCompilerName;

            if (!File.Exists(PapyrusCompilerEXE))
            {
                richTextBox.Clear();
                richTextBox.AppendText("Papyrus Compiler: ERROR! Unable to find \"" + PapyrusCompilerName + "\" in \"" + PapyrusCompilerEXE.Substring(0, PapyrusCompilerEXE.LastIndexOf("\\") + 1) + "\"!");
                richTextBox.ScrollToCaret();
                return;
            }
            else if (string.IsNullOrEmpty(_ed.DeContent))
            {
                richTextBox.Clear();
                richTextBox.AppendText("Papyrus Compiler: Error! Unable to use compile function because no configuration information was found.");
                richTextBox.ScrollToCaret();
            }
            //else if (args.Length < minimumArgumentCount)
            //{
            //    twError.WriteLine("Papyrus Compiler: ERROR! Expecting at least " + minimumArgumentCount + " arguments, but received only " + args.Length + "!");
            //    return;
            //}
            else
            {
                DataContractJsonSerializer serializer = new DataContractJsonSerializer(typeof(ParamsModel));
                MemoryStream mStream = new MemoryStream(Encoding.UTF8.GetBytes(_ed.DeContent));
                ParamsModel  _pm     = (ParamsModel)serializer.ReadObject(mStream);
                mStream.Close();
                mStream.Dispose();

                string arguments = " " + _fileorfolder + " " + PackageArguments(_pm);

                if (!File.Exists(PapyrusCompilerEXE))
                {
                    twError.WriteLine("Papyrus Compiler: ERROR! Unable to find \"" + PapyrusCompilerName + "\" in \"" + PapyrusCompilerEXE.Substring(0, PapyrusCompilerEXE.LastIndexOf("\\") + 1) + "\"!");
                    return;
                }
                var proc = new Process
                {
                    StartInfo = new ProcessStartInfo
                    {
                        FileName               = PapyrusCompilerEXE,
                        Arguments              = arguments,
                        UseShellExecute        = false,
                        RedirectStandardOutput = true,
                        RedirectStandardError  = true,
                        CreateNoWindow         = true
                    }
                };
                proc.EnableRaisingEvents = true;
                proc.OutputDataReceived += new DataReceivedEventHandler(OutputWriter);
                proc.ErrorDataReceived  += new DataReceivedEventHandler(ErrorWriter);
                proc.Start();
                proc.BeginOutputReadLine();
                proc.BeginErrorReadLine();
                proc.WaitForExit();
                proc.Close();
                proc.Dispose();
            }
        }