예제 #1
0
 void SaveTree()
 {
     Directory.CreateDirectory(Path.GetDirectoryName(FoldersXmlPath));
     File.WriteAllText(FoldersXmlPath, TreeToXml());
     if (mainForm != null)
     {
         for (int i = 1; i < mainForm.listViewGames.Items.Count; i++)
         {
             if (deletedGames.Contains(mainForm.listViewGames.Items[i].Tag as NesApplication))
             {
                 mainForm.listViewGames.Items[i].Checked = false;
             }
         }
         ConfigIni.Save();
     }
 }
예제 #2
0
        bool FlashOriginalKernel()
        {
            var workerForm = new WorkerForm();

            workerForm.Task       = WorkerForm.Tasks.FlashKernel;
            workerForm.KernelDump = KernelDump;
            workerForm.Mod        = null;
            workerForm.Start();
            var result = workerForm.DialogResult == DialogResult.OK;

            if (result)
            {
                ConfigIni.CustomFlashed = false;
                ConfigIni.Save();
            }
            return(result);
        }
예제 #3
0
        bool FlashCustomKernel()
        {
            var workerForm = new WorkerForm();

            workerForm.Task       = WorkerForm.Tasks.FlashKernel;
            workerForm.KernelDump = KernelDump;
            workerForm.Mod        = "mod_kernel";
            workerForm.Start();
            var result = workerForm.DialogResult == DialogResult.OK;

            if (result)
            {
                ConfigIni.CustomFlashed = true;
                ConfigIni.Save();
            }
            return(result);
        }
예제 #4
0
        private void SaveSelectedGames()
        {
            var selected = new List <string>();

            foreach (var game in checkedListBoxGames.CheckedItems)
            {
                if (game is NesGame)
                {
                    selected.Add((game as NesGame).Code);
                }
                else
                {
                    selected.Add("default");
                }
            }
            ConfigIni.SelectedGames = string.Join(";", selected.ToArray());
            ConfigIni.Save();
        }
예제 #5
0
        void SaveTree()
        {
            Directory.CreateDirectory(Path.GetDirectoryName(FoldersXmlPath));
            File.WriteAllText(FoldersXmlPath, TreeToXml());
            if (mainForm != null)
            {
                List <string> codes = new List <string>();
                foreach (INesMenuElement elem in deletedGames)
                {
                    codes.Add(elem.Code);
                }
                if (codes.Count() > 0)
                {
                    Manager.GameManager.GetInstance().Unselect(codes.ToArray());
                }


                ConfigIni.Save();
            }
        }
예제 #6
0
 void SaveTree()
 {
     File.WriteAllText(FoldersXmlPath, TreeToXml());
     if (mainForm != null)
     {
         for (int i = 0; i < mainForm.checkedListBoxGames.Items.Count; i++)
         {
             if (deletedGames.Contains(mainForm.checkedListBoxGames.Items[i] as NesMiniApplication))
             {
                 mainForm.checkedListBoxGames.SetItemChecked(i, false);
             }
         }
         for (int i = 0; i < mainForm.checkedListBoxDefaultGames.Items.Count; i++)
         {
             if (deletedGames.Contains(mainForm.checkedListBoxDefaultGames.Items[i] as NesDefaultGame))
             {
                 mainForm.checkedListBoxDefaultGames.SetItemChecked(i, false);
             }
         }
         ConfigIni.Save();
     }
 }
예제 #7
0
        void SaveTree()
        {
            Directory.CreateDirectory(Path.GetDirectoryName(FoldersXmlPath));
            File.WriteAllText(FoldersXmlPath, TreeToXml());
            if (mainForm != null)
            {
                for (int i = 1; i < mainForm.listViewGames.Items.Count; i++)
                {
                    if (deletedGames.Contains(mainForm.listViewGames.Items[i].Tag as NesApplication))
                    {
                        mainForm.listViewGames.Items[i].Checked = false;
                    }
                }

                switch (comboBoxBackPosition.SelectedIndex)
                {
                case 0: ConfigIni.Instance.BackFolderPosition = NesMenuFolder.Priority.LeftBack; break;

                case 1: ConfigIni.Instance.BackFolderPosition = NesMenuFolder.Priority.Back; break;
                }
                ConfigIni.Instance.HomeFolder = checkBoxAddHome.Checked;
                ConfigIni.Save();
            }
        }
예제 #8
0
 private void CustomBorderManager_FormClosing(object sender, FormClosingEventArgs e)
 {
     SaveSelectedBorders();
     ConfigIni.Save();
 }
예제 #9
0
        private void buttonSync_Click(object sender, EventArgs e)
        {
            const string src_backgroundPath  = "/var/lib/hakchi/squashfs/usr/share/backgrounds";
            const string dest_backgroundPath = "/var/lib/hakchi/rootfs/usr/share/backgrounds";
            var          clovershell         = MainForm.Clovershell;
            string       bgDirectory         = BorderElement.BackgroundsDirectory;

            SaveSelectedBorders();
            ConfigIni.Save();
            string baseDirectoryInternal = Program.BaseDirectoryInternal;
            string tempDirectory;

#if DEBUG
            tempDirectory = Path.Combine(baseDirectoryInternal, "temp");
#else
            tempDirectory = Path.Combine(Path.GetTempPath(), "hakchi-temp");
#endif
            string tempBordersDirectory = Path.Combine(tempDirectory, "borders");
            Directory.CreateDirectory(tempDirectory);
            Directory.CreateDirectory(tempBordersDirectory);
            labelSyncing.Text       = "Making sync";
            progressBarSync.Value   = 0;
            labelSyncing.Visible    = true;
            progressBarSync.Visible = true;
            labelSyncing.Refresh();
            progressBarSync.Refresh();

            if (clovershell.IsOnline)
            {
                this.Enabled = false;
                try
                {
                    /*labelSyncing.Text = "Deleting a file";
                     * labelSyncing.Refresh();
                     * progressBarSync.Value = 10;
                     * progressBarSync.Refresh();
                     * string del_cmd = $"rm /etc/preinit.d/p8173_ownbgs";
                     * clovershell.ExecuteSimple(del_cmd, 3000);
                     * Thread.Sleep(1000);
                     * labelSyncing.Text = "Reboot...";
                     * labelSyncing.Refresh();
                     * progressBarSync.Value = 20;
                     * progressBarSync.Refresh();
                     * clovershell.ExecuteSimple("reboot", 3000);
                     * Thread.Sleep(2000);
                     * labelSyncing.Text = "Waiting reboot...";
                     * labelSyncing.Refresh();
                     * progressBarSync.Value = 30;
                     * progressBarSync.Refresh();
                     * while (!(clovershell.IsOnline))
                     * {
                     *  Debug.WriteLine("Wait reboot");
                     *  Thread.Sleep(2000);
                     * }
                     */
                    labelSyncing.Text = "Creating directory...";
                    labelSyncing.Refresh();
                    progressBarSync.Value = 10;
                    progressBarSync.Refresh();
                    string command = $"src=\"{src_backgroundPath}\" && " +
                                     $"dst=\"{dest_backgroundPath}\" && " +
                                     $"rm -rf \"$dst\" && " +
                                     $"mkdir -p \"$dst\"";
                    clovershell.ExecuteSimple(command, 10000, true);

                    foreach (ListViewItem border in listViewBorders.CheckedItems)
                    {
                        if (border.Tag is BorderElement)
                        {
                            string        repName  = (border.Tag as BorderElement).Name;
                            DirectoryInfo diSource = new DirectoryInfo(bgDirectory + "/" + repName);
                            DirectoryInfo diTarget = new DirectoryInfo(tempBordersDirectory + "/" + repName);
                            CopyAll(diSource, diTarget);
                        }
                    }
                    string[] lines = { "overmount /usr/share/backgrounds/", "" };
                    System.IO.File.WriteAllLines(tempBordersDirectory + "/" + "p8173_ownbgs", lines);

                    labelSyncing.Text = "Uploading user borders...";
                    labelSyncing.Refresh();
                    progressBarSync.Value = 20;
                    progressBarSync.Refresh();

                    using (var bordersTar = new TarStream(tempBordersDirectory))
                    {
                        if (bordersTar.Length > 0)
                        {
                            bordersTar.OnReadProgress += delegate(long pos, long len)
                            {
                                Debug.WriteLine("SetProgress(" + pos.ToString() + ", " + len.ToString());
                            };

                            clovershell.Execute(string.Format("tar -xvC {0}", dest_backgroundPath), bordersTar, null, null, 30000, true);
                        }
                    }

                    string move_cmd = $"mv {dest_backgroundPath}/p8173_ownbgs /etc/preinit.d/";
                    clovershell.ExecuteSimple(move_cmd, 3000, true);

                    labelSyncing.Text = "Managing default borders...";
                    labelSyncing.Refresh();
                    progressBarSync.Value = 80;
                    progressBarSync.Refresh();

                    if (listViewBorders.Items[0].Checked)
                    {
                        var selected = new List <string>();
                        foreach (DefaultBorder border in checkedListBoxDefaultBorders.CheckedItems)
                        {
                            selected.Add(border.Name);
                        }
                        foreach (string bordername in selected)
                        {
                            string cmd = $"src=\"{src_backgroundPath}/{bordername}\" && " +
                                         $"dst=\"{dest_backgroundPath}/{bordername}\" && " +
                                         $"ln -s \"$src\" \"$dst\"";
                            clovershell.ExecuteSimple(cmd, 10000, true);
                        }
                    }
                }
                finally
                {
                    try
                    {
                        labelSyncing.Text = "Reboot...";
                        labelSyncing.Refresh();
                        progressBarSync.Value = 100;
                        progressBarSync.Refresh();
                        Directory.Delete(tempDirectory, true);
                        if (clovershell.IsOnline)
                        {
                            clovershell.ExecuteSimple("reboot", 100);
                        }
                    }
                    catch { }
                    MessageBox.Show(this, "work is done", "Custom borders", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    this.Enabled = true;
                    this.Close();
                }
            }
        }