Пример #1
0
        private void editToolStripMenuItem_Click(object sender, EventArgs e)
        {
            if (linuxListView.FocusedItem == null)
            {
                return;
            }
            Config.LinuxAlias la = cfg.GetLinuxAlias((int)linuxListView.FocusedItem.Tag);
            if (la == null)
            {
                return;
            }
            LinuxAliasChooser lac = new LinuxAliasChooser(la);

            if (lac.ShowDialog(this) == DialogResult.OK)
            {
                // We must delete the alias involved, however it will not be updated
                string filename = Path.Combine(aliases_location, _normalizeAliasName(la.name));
                try { File.Delete(filename); } catch { }

                la.name           = lac.Alias;
                la.command        = lac.Command;
                la.load_profile   = lac.LoadProfile;
                la.convert_args   = lac.ConvertArgs;
                la.convert_input  = lac.ConvertInput;
                la.convert_output = lac.ConvertOutput;

                // We must delete the alias involved, however it will not be updated
                filename = Path.Combine(aliases_location, _normalizeAliasName(la.name));
                try { File.Delete(filename); } catch { }

                _saveConfig();
                _updateLists();
                _updateAliases();
            }
        }
Пример #2
0
 public LinuxAliasChooser(Config.LinuxAlias la)
 {
     InitializeComponent();
     if (la != null)
     {
         name.Text             = la.name;
         command.Text          = la.command == null ? "" : la.command;
         loadProfile.Checked   = la.load_profile;
         convertArgs.Checked   = la.convert_args;
         convertInput.Checked  = la.convert_input;
         convertOutput.Checked = la.convert_output;
     }
 }
Пример #3
0
        public static string MakeLinuxAlias(string output, Config.LinuxAlias la)
        {
            string temp_dir = "temp";

            try
            {
                Directory.CreateDirectory(temp_dir);
                string exe_path      = Path.Combine(temp_dir, "alias.exe");
                string manifest_path = Path.Combine(temp_dir, "manifest.xml");

                File.WriteAllText(manifest_path, Properties.Resources.LimitedManifest);
                CompilerParameters parameters = new CompilerParameters()
                {
                    GenerateExecutable      = true,
                    TreatWarningsAsErrors   = false,
                    CompilerOptions         = "/win32manifest:" + manifest_path + " /platform:anycpu /target:exe",
                    IncludeDebugInformation = false,
                    GenerateInMemory        = false,
                    OutputAssembly          = exe_path
                };
                parameters.ReferencedAssemblies.Add("System.dll");

                string code = Properties.Resources.LinuxAlias;
                if (la.convert_input || la.convert_output)
                {
                    code = Properties.Resources.LinuxAliasAlt;
                }

                code = code.Replace("[COMMAND]", CodeOfStr(la.command));
                code = code.Replace("[LOAD_PROFILE]", CodeOfBool(la.load_profile));
                code = code.Replace("[CONVERT_ARGS]", CodeOfBool(la.convert_args));
                code = code.Replace("[CONVERT_INPUT]", CodeOfBool(la.convert_input));
                code = code.Replace("[CONVERT_OUTPUT]", CodeOfBool(la.convert_output));

                CSharpCodeProvider provider = new CSharpCodeProvider(new Dictionary <string, string> {
                    { "CompilerVersion", "v4.0" }
                });
                CompilerResults compiler = provider.CompileAssemblyFromSource(parameters, code);
                if (compiler.Errors.Count > 0)
                {
                    throw new Exception(compiler.Errors[0].ErrorText);
                }
                File.Move(exe_path, output);
            }
            catch (Exception e) { return(e.Message); }
            finally { try { Directory.Delete(temp_dir, true); } catch { } }
            return(null);
        }
Пример #4
0
        private void deleteToolStripMenuItem_Click(object sender, EventArgs e)
        {
            if (linuxListView.FocusedItem == null)
            {
                return;
            }
            Config.LinuxAlias la = cfg.GetLinuxAlias((int)linuxListView.FocusedItem.Tag);
            if (la == null)
            {
                return;
            }
            cfg.DeleteLinuxAlias(la.ID);

            // We must delete the alias involved, however it will not be updated
            string filename = Path.Combine(aliases_location, _normalizeAliasName(la.name));

            try { File.Delete(filename); } catch { }

            _saveConfig();
            _updateLists();
            _updateAliases();
        }
Пример #5
0
        private void newToolStripMenuItem_Click(object sender, EventArgs e)
        {
            LinuxAliasChooser lac = new LinuxAliasChooser();

            if (lac.ShowDialog(this) == DialogResult.OK)
            {
                Config.LinuxAlias la = new Config.LinuxAlias();
                la.enabled        = false;
                la.ID             = cfg.NextID();
                la.name           = lac.Alias;
                la.command        = lac.Command;
                la.load_profile   = lac.LoadProfile;
                la.convert_args   = lac.ConvertArgs;
                la.convert_input  = lac.ConvertInput;
                la.convert_output = lac.ConvertOutput;
                cfg.linux_aliases.Add(la);

                _saveConfig();
                _updateLists();
                _updateAliases();
            }
        }
Пример #6
0
        private void linuxListView_ItemCheck(object sender, ItemCheckEventArgs e)
        {
            if (e.CurrentValue == CheckState.Indeterminate || e.NewValue == CheckState.Indeterminate)
            {
                return;
            }

            Config.LinuxAlias la = cfg.GetLinuxAlias((int)linuxListView.Items[e.Index].Tag);
            if (la != null && la.enabled != (e.NewValue == CheckState.Checked))
            {
                la.enabled = (e.NewValue == CheckState.Checked);

                if (e.NewValue == CheckState.Unchecked)
                {
                    // We must delete the alias involved, however it will not be updated
                    string filename = Path.Combine(aliases_location, _normalizeAliasName(la.name));
                    try { File.Delete(filename); } catch { }
                }

                _saveConfig();
                _updateAliases();
            }
        }