Skip to content

Commit

Permalink
一回コミット
Browse files Browse the repository at this point in the history
  • Loading branch information
Budobudou committed Sep 3, 2024
1 parent 5c29c15 commit 59a6d81
Show file tree
Hide file tree
Showing 5 changed files with 320 additions and 167 deletions.
173 changes: 124 additions & 49 deletions MainWindow.cs
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,12 @@ public class MainWindow : Window
[UI] private Image _thum = null;
[UI] private Image _live_icon = null;
[UI] private Image texteditoricon = null;
[UI] private Image browsericon = null;
[UI] private ProgressBar _progress = null;
[UI] private Box packagelistbox = null;
[UI] private ComboBoxText texteditorcombo = null;
[UI] private ComboBoxText browsercombo = null;

[UI] private TextView eulaview = null;
[UI] private ScrolledWindow windoweulaview = null;
[UI] private CheckButton toggleswitch = null;
Expand All @@ -37,6 +40,8 @@ public class MainWindow : Window
private int eulaviewed = 0;
// インストールするパッケージの指定用変数
private XElement texteditorlistroot = null!;
private XElement browserlistroot = null!;

//
public MainWindow() : this(new Builder("MainWindow.glade")) { }

Expand Down Expand Up @@ -235,13 +240,14 @@ private async Task setAsync(object sender, EventArgs a)
Console.WriteLine(_state);
if (_state == 0){
_label2.Text = "Welcome to PioneOS!";
_label1.Text = "このプロセスでは PioneOS を設定するお手伝いをします\n続けるには「次へ」をクリックしてください。";
_label1.Text = "このプロセスでは PioneOS を使う準備をします\n続けるには「次へ」をクリックしてください。";
_thum.File = "/usr/share/pioneos/oobe/Assets/pioneos.png";
_infomationbar.Visible = true;
// アイコン設定
_live_icon.IconName = "face-smile";
_live_icon.PixelSize = 48;
_live_icon.Visible = true;
_button1.Sensitive = _button2.Sensitive = true;
//
_pionever.Visible = true;
_bypass_network++;
Expand All @@ -258,7 +264,7 @@ private async Task setAsync(object sender, EventArgs a)
}
}
else if (_state == 1){
_label2.Text = "1.インターネットへの接続";
_label2.Text = "インターネットへの接続";
_button1.Visible = _button2.Visible = true;
_navigationbar.Visible = true;
_thum.Visible = true;
Expand All @@ -277,9 +283,8 @@ private async Task setAsync(object sender, EventArgs a)
//
}
else if (_state == 2){
_button1.Visible = _button2.Visible = false;
_button1.Sensitive = _button2.Sensitive = false;
_label1.Text = "インターネット接続を確認中です。\nしばらくお待ちください。";
await Task.Delay(50);
try{
var connectcheck = new HttpClient();
await connectcheck.GetAsync("http://ospio.net");
Expand All @@ -295,13 +300,15 @@ private async Task setAsync(object sender, EventArgs a)
await setAsync(sender, a);
}
else if (_state == 3){
_button1.Visible = _button2.Visible = true;
_label2.Text = "2.エンドユーザー ライセンスの確認";
_navigationbar.Visible = false;
_button1.Sensitive = _button2.Sensitive = true;
_label2.Text = "エンドユーザー ライセンスの確認";
toggleswitch.Visible = false;
_label1.Text = "エンドユーザー ライセンスを読んで同意してください。\n同意しない場合は、PioneOS をご利用できません。";
_thum.Visible = false;
eulaview.Visible = true;
packagelistbox.Visible = false;
_progresscircle.Visible = false;
_button1.Sensitive = _button2.Sensitive = false;
_button1.Label = "同意>";
_button2.Label = "<拒否";
windoweulaview.Visible = true;
Expand Down Expand Up @@ -338,7 +345,7 @@ private async Task setAsync(object sender, EventArgs a)
}
//行数分ループ
}
_navigationbar.Visible = true;
_button1.Sensitive = _button2.Sensitive = true;
}

catch (Exception e){
Expand All @@ -349,40 +356,12 @@ private async Task setAsync(object sender, EventArgs a)
await setAsync(sender, a);
}
}
else if (_state == 4){
_label2.Text = "3.Windows とのデュアルブート環境向けの設定";
_button1.Visible = true;
_button2.Visible = true;
toggleswitch.Visible = true;
_progresscircle.Visible = false;
toggleswitch.Label = "デュアルブート向け設定を適用する";
_thum.Visible = false;
eulaview.Visible = false;
windoweulaview.Visible = false;
packagelistbox.Visible = false;
_label1.Text = "上のチェックを入れると、PioneOS と Windows をデュアルブートする環境向けに以下の設定を適用します。\n1. 時刻ズレを修正するためにシステム時刻をローカル時刻へセット\n2.Windows で再起動するアイコンを作成";
_button1.Label = "次へ>";
_button2.Label = "<戻る";
_thum.PixelSize = 196;
// アイコン設定
_live_icon.IconName = "distributor-logo-windows";
_live_icon.PixelSize = 48;
_live_icon.Visible = true;
//
if (windowstimesync == true){
toggleswitch.Active = true;
}
else{
toggleswitch.Active = false;
}
}
else if(_state == 5){
_label2.Text = "4.ソフトウェアの選択";
else if(_state == 4){
_label2.Text = "ソフトウェアの選択";
_button1.Visible = true;
_button2.Visible = true;
toggleswitch.Visible = false;
_thum.Visible = false;
_progresscircle.Visible = true;
eulaview.Visible = false;
windoweulaview.Visible = false;
_button1.Label = "次へ>";
Expand All @@ -392,16 +371,19 @@ private async Task setAsync(object sender, EventArgs a)
_live_icon.IconName = "downloader";
_live_icon.PixelSize = 48;
_live_icon.Visible = true;
_button1.Sensitive = _button2.Sensitive = false;
// インストールするパッケージィの設定
if (packagelisted == false)
{
texteditorcombo.AppendText("nano&vim");
texteditorcombo.Active = 0;
//Console.WriteLine("texteditorcombo is alive!");
browsercombo.AppendText("Chromium");
browsercombo.Active = 0;
//テキストエディタリスト
var connectcheck2 = new HttpClient();
connectcheck2.Timeout = TimeSpan.FromSeconds(10);
var texteditorlistget = await connectcheck2.GetAsync("https://store.ospio.net/texteditorlist.xml");
if (texteditorlistget.IsSuccessStatusCode == true){
try{
_progresscircle.Visible = true;
var texteditorlistget = await connectcheck2.GetAsync("http://ospio.net/packagelists/texteditorlist.xml");
string texteditorlist = await texteditorlistget.Content.ReadAsStringAsync();
XDocument texteditorlistxml = XDocument.Parse(texteditorlist);
texteditorlistroot = texteditorlistxml.Element("data");
Expand All @@ -410,14 +392,54 @@ private async Task setAsync(object sender, EventArgs a)
Console.WriteLine(textitem.Element("id").Value);
texteditorcombo.AppendText(textitem.Element("name").Value);
}
}
var browserlistget = await connectcheck2.GetAsync("http://ospio.net/packagelists/browserlist.xml");
string browserlist = await browserlistget.Content.ReadAsStringAsync();
XDocument browserlistxml = XDocument.Parse(browserlist);
browserlistroot = browserlistxml.Element("data");
foreach (XElement textitem in browserlistroot.Elements("item"))
{
Console.WriteLine(textitem.Element("id").Value);
browsercombo.AppendText(textitem.Element("name").Value);
}
packagelistbox.Visible = true;
}
catch{
Console.WriteLine("package list error");
}
connectcheck2.Dispose();
packagelisted = true;
}
_button1.Sensitive = _button2.Sensitive = true;
_progresscircle.Visible = false;
texteditorcombo.Visible = true;
packagelistbox.Visible = true;
}
else if (_state == 5){
_label2.Text = "Windows とのデュアルブート環境向けの設定";
_button1.Visible = true;
_button2.Visible = true;
toggleswitch.Visible = true;
_progresscircle.Visible = false;
toggleswitch.Label = "デュアルブート向け設定を適用する";
_thum.Visible = false;
eulaview.Visible = false;
windoweulaview.Visible = false;
packagelistbox.Visible = false;
_label1.Text = "このチェックを入れると、PioneOS と Windows をデュアルブートする環境向けに以下の設定を適用します。\n1. 時刻ズレを修正するためにシステム時刻をローカル時刻へセット\n2.Windows で再起動するアイコンを作成";
_button1.Label = "次へ>";
_button2.Label = "<戻る";
_thum.PixelSize = 196;
// アイコン設定
_live_icon.IconName = "distributor-logo-windows";
_live_icon.PixelSize = 48;
_live_icon.Visible = true;
//
if (windowstimesync == true){
toggleswitch.Active = true;
}
else{
toggleswitch.Active = false;
}
}
else if(_state == 6){
_label1.Text = "PioneOS を快適にご利用いただくための最終処理を行っています。\n自動で再起動するまでこのまましばらくお待ちください!";
_button1.Visible = false;
Expand Down Expand Up @@ -470,19 +492,59 @@ private async Task setAsync(object sender, EventArgs a)
{
FileName = "sudo",
UseShellExecute = true,
Arguments = "/usr/share/pioneos/oobe/instremo.sh" + " " + packageinstall + " " + packageuninstall
Arguments = "/usr/share/pioneos/oobe/texteditor.sh" + " " + packageinstall + " " + packageuninstall
};
_pionever.Text = "進捗状況:必要なパッケージのインストール中...";
_pionever.Text = "進捗状況:テキストブラウザのインストール中...";
using (Process pwatch = Process.Start(processInfo_textedit)){if (pwatch != null){await pwatch.WaitForExitAsync();}}
Console.WriteLine(packageinstall + "をインストールしました。");
}
}
}
//ブラウザをインストール
if(browsercombo.Active == 0)
{
Console.WriteLine("ブラウザはデフォルトのままです");
}
else
{
// 選択された ID からアイテムを取得し、install をインストール
XElement installerbrowser = browserlistroot.Elements("item").FirstOrDefault(item => (string)item.Element("id") == browsercombo.Active.ToString());
string packageinstall = installerbrowser.Element("install").Value;
string packageuninstall = installerbrowser.Element("uninstall").Value;
string packagehowto = installerbrowser.Element("howto").Value;
string packagegpg = "";
string packagerepo = "";
string packagemanage = "";
if (installerbrowser != null)
{
if (packagehowto == "dpkg"){
packagegpg = installerbrowser.Element("url").Value;
}
else{
packagerepo = installerbrowser.Element("repo").Value;
packagegpg = installerbrowser.Element("gpg").Value;
packagemanage = installerbrowser.Element("manage").Value;
}
//インストール開始
if(installerbrowser.Element("howto").Value == "apt")
{
await Task.Delay(50);
var processInfo_browser = new ProcessStartInfo
{
FileName = "sudo",
UseShellExecute = true,
Arguments = "/usr/share/pioneos/oobe/browser.sh" + " " + packageinstall + " " + packageuninstall + " " + packagehowto + " " + packagegpg + " " + packagerepo + " " + packagemanage
};
_pionever.Text = "進捗状況:Web ブラウザのインストール中...";
using (Process pwatch = Process.Start(processInfo_browser)){if (pwatch != null){await pwatch.WaitForExitAsync();}}
Console.WriteLine(packageinstall + "をインストールしました。");
}
}
}
//時間同期など
_pionever.Text = "進捗状況:設定の最適化中...";
if (windowstimesync == true){
Console.WriteLine("windowstimesync.sh を実行します。");
await Task.Delay(50);
var processInfo_windowstimesync = new ProcessStartInfo
{
FileName = "sudo",
Expand All @@ -502,7 +564,7 @@ private async Task setAsync(object sender, EventArgs a)
};
Console.WriteLine("fini.sh を実行します。");
using (Process pwatch = Process.Start(process2Info)){if (pwatch != null){await pwatch.WaitForExitAsync();}}
await Task.Delay(50);
await Task.Delay(10);
var processInfo = new ProcessStartInfo
{
FileName = "sudo",
Expand Down Expand Up @@ -553,7 +615,20 @@ private void settexteditor(object sender, EventArgs a)
texteditoricon.IconName = "mousepad";
}


}
private void setbrowser(object sender, EventArgs a)
{
if(browsercombo.Active != 0)
{
Console.WriteLine(browsercombo.Active + "番のブラウザが選択されました");
XElement installertext = browserlistroot.Elements("item").FirstOrDefault(item => (string)item.Element("id") == browsercombo.Active.ToString());
browsericon.IconName = installertext.Element("icon").Value;
}
else
{
browsericon.IconName = "chromium";
}

}
}
}
Loading

0 comments on commit 59a6d81

Please sign in to comment.