/// #NAME#: #DESCRIPTION#
        public void f_Renombrar_programa()
        {
            //INI CODE PRCGUID: Renombrar programa

            TreeView ArbolProgramas   = (TreeView)view.getCtrl("ArbolProgramas");
            TreeNode N_ProgramaActivo = ArbolProgramas.SelectedNode;

            ARQODE_UI.ARQODE_UI.CInputDialog CInputDialog = new ARQODE_UI.ARQODE_UI.CInputDialog(vm);
            CInputDialog.InputDialog.AcceptButton = CInputDialog.BAceptar;
            CInputDialog.InputDialog.CancelButton = CInputDialog.BCancelar;
            CInputDialog.InputDialog.Text         = "Renombrar carpeta";
            CInputDialog.Label1.Text   = "Nombre de la carpeta";
            CInputDialog.textBox1.Text = N_ProgramaActivo.Text;

            vm.Cancel_events = false;
            DialogResult dr = CInputDialog.InputDialog.ShowDialog();

            if (dr == DialogResult.OK)
            {
                ARQODE_UI.GestorProgramas.CVentanaProgramas CVentanaProgramas = new ARQODE_UI.GestorProgramas.CVentanaProgramas(vm);
                CInputDialog.textBox1.Text = CInputDialog.textBox1.Text.Replace("\r\n", "");
                String di_antiguo = Path.Combine(App_globals.AppDataSection(dPATH.CODE).FullName, N_ProgramaActivo.FullPath);
                String di_nuevo   = Path.Combine(App_globals.AppDataSection(dPATH.CODE).FullName,
                                                 N_ProgramaActivo.FullPath.Substring(0, N_ProgramaActivo.FullPath.LastIndexOf("\\")));

                if (N_ProgramaActivo.Text.EndsWith(".json"))
                {
                    String nombre_f = (CInputDialog.textBox1.Text.ToLower().EndsWith(".json")) ? CInputDialog.textBox1.Text : CInputDialog.textBox1.Text + ".json";
                    di_nuevo = Path.Combine(di_nuevo, nombre_f);

                    CStructModifications csmod = new CStructModifications(sys, App_globals);
                    String from_path           = N_ProgramaActivo.FullPath.Replace(dPROGRAM.FOLDER + "\\", "").Replace("\\", ".").Replace(".json", "");
                    String to_path             = Path.Combine(N_ProgramaActivo.FullPath.Substring(0, N_ProgramaActivo.FullPath.LastIndexOf("\\")), nombre_f).Replace(dPROGRAM.FOLDER + "\\", "").Replace("\\", ".").Replace(".json", "");
                    csmod.MoveProgram(from_path, to_path);

                    File.Move(di_antiguo, di_nuevo);
                    N_ProgramaActivo.Text = nombre_f;
                }
                else
                {
                    di_nuevo = Path.Combine(di_nuevo, CInputDialog.textBox1.Text);
                    if (di_nuevo != di_antiguo)
                    {
                        if (Directory.Exists(di_antiguo))
                        {
                            DirectoryInfo di_ant = new DirectoryInfo(di_antiguo);
                            di_ant.MoveTo(di_nuevo);
                        }
                        else
                        {
                            Directory.CreateDirectory(di_nuevo);
                        }
                        N_ProgramaActivo.Text = CInputDialog.textBox1.Text;
                    }
                }
            }
            //END CODE PRCGUID: Renombrar programa
        }
Beispiel #2
0
        /// #NAME#: #DESCRIPTION#
        public void f_439a02f9_bfb8_467a_8443_6607ca19b912()
        {
            //INI CODE PRCGUID: 439a02f9-bfb8-467a-8443-6607ca19b912

            String I_Fichero_importaciones = Input_str("Fichero importaciones");

            Ionic.Zip.ZipFile zf          = new Ionic.Zip.ZipFile(I_Fichero_importaciones);
            JToken            ImportConvs = null;

            foreach (Ionic.Zip.ZipEntry ze in zf.Entries)
            {
                #region get import convs data
                if (ze.FileName.Contains("ImportConvs.json"))
                {
                    MemoryStream ms = new MemoryStream();
                    ze.Extract(ms);
                    byte[] entry_data   = ms.ToArray();
                    String file_content = System.Text.Encoding.Default.GetString(entry_data);
                    ms.Close();
                    ImportConvs = JArray.Parse(file_content);
                }
                #endregion
                #region Extract progrmas & processes
                else
                {
                    ze.Extract(App_globals.AppDataSection(dPATH.CODE).FullName);
                }
                #endregion
            }

            #region Update imported programs namespaces

            if (ImportConvs != null)
            {
                CStructModifications csmod = new CStructModifications(sys, App_globals);
                foreach (JObject jImp in ImportConvs as JArray)
                {
                    JProperty jprop = (JProperty)jImp.First;
                    csmod.MoveProgram(jprop.Name,
                                      jprop.Value.ToString()
                                      .Replace("\\", ".")
                                      .Replace(dPROGRAM.FOLDER + ".", ""));
                }
            }
            MessageBox.Show("Program imported successfully");

            #endregion

            //END CODE PRCGUID: 439a02f9-bfb8-467a-8443-6607ca19b912
        }
        /// #NAME#: #DESCRIPTION#
        public void f_1ff83da1_817c_4c05_bf34_579e43091bb0()
        {
            //INI CODE PRCGUID: 1ff83da1-817c-4c05-bf34-579e43091bb0

            ARQODE_UI.GestorProgramas.CVentanaProgramas CVentanaProgramas = new ARQODE_UI.GestorProgramas.CVentanaProgramas(vm);

            if (CVentanaProgramas.ArbolProgramas.SelectedNode.FullPath.Contains(dPROGRAM.FOLDER + "\\"))
            {
                String        Origin_path      = Clipboard.GetText();
                DirectoryInfo pprog            = App_globals.AppDataSection(dPATH.PROGRAM);
                String        Origin_full_path = Path.Combine(pprog.FullName, Origin_path.Replace(".", "\\") + ".json");

                if (File.Exists(Origin_full_path))
                {
                    FileInfo fi = new FileInfo(Origin_full_path);
                    String   Target_full_path = Path.Combine(Path.Combine(App_globals.AppDataSection(dPATH.CODE).FullName, CVentanaProgramas.ArbolProgramas.SelectedNode.FullPath), fi.Name);
                    String   Target_path      = (CVentanaProgramas.ArbolProgramas.SelectedNode.FullPath.Replace(dPROGRAM.FOLDER + "\\", "") + "." + fi.Name).Replace(".json", "").Replace("\\", ".");

                    // Replace old program path ocurrencies
                    CStructModifications csmod = new CStructModifications(sys, App_globals);
                    csmod.MoveProgram(Origin_path, Target_path);

                    // File move
                    File.Move(Origin_full_path, Target_full_path);

                    CVentanaProgramas.contextMenu_Programas.Items[2].Enabled = false;
                }
                else
                {
                    MessageBox.Show("Debe cortar un programa del árbol de programas antes de pegarlo");
                }
            }
            else
            {
                MessageBox.Show("Debe pegar el programa dentro del árbol de programas");
            }


            //END CODE PRCGUID: 1ff83da1-817c-4c05-bf34-579e43091bb0
        }