private void pictureBox1_MouseDown(object sender, MouseEventArgs e) { if (e.Button == MouseButtons.Left) { openFileDialog1.Filter = "静态图片文件| *.jpg; *.png; *.jpeg; *.bmp"; openFileDialog1.FileName = ""; openFileDialog1.Title = "选择一张图片作为主窗口的背景"; DialogResult dialogResult = openFileDialog1.ShowDialog(); if (dialogResult == DialogResult.OK) { pictureBox1.Image = Image.FromFile(openFileDialog1.FileName); Settings.MainFormImage = openFileDialog1.FileName; StaticUtilFunctions.LoadingMainFormBackgroundPic(); } else if (dialogResult == DialogResult.Cancel) { pictureBox1.Image = Image.FromFile(Environment.CurrentDirectory + "\\Resources\\Pics\\Empty.png"); Settings.MainFormImage = ""; PublicControlers.mainForm.BackgroundImage = Image.FromFile(Environment.CurrentDirectory + "\\Resources\\Pics\\Empty.png"); } } else if (e.Button == MouseButtons.Right) { if (DialogResult.OK == colorDialog1.ShowDialog()) { pictureBox1.BackColor = colorDialog1.Color; Settings.SettingFormColor = String.Format("#{0:X2}{1:X2}{2:X2}", colorDialog1.Color.R, colorDialog1.Color.G, colorDialog1.Color.B); this.BackColor = colorDialog1.Color; } } }
static void Debug() { Application.EnableVisualStyles(); Application.SetCompatibleTextRenderingDefault(false); MainForm mainForm = new MainForm(); StaticUtilFunctions.SetFormMid(mainForm); Application.Run(mainForm); }
private void button2_Click(object sender, EventArgs e) { StaticUtilFunctions.FindNanoPad(); comboBox1.Items.Clear(); foreach (SayobotNanoPad Pad in UtilValues.PublicValue.nanoPads) { comboBox1.Items.Add(Pad.Name); } }
public Filter() { InitializeComponent(); FilterCheckBox.SearchType = skinPanel1.Controls; FilterCheckBox.Mode = skinPanel2.Controls; FilterCheckBox.MapStatus = skinPanel3.Controls; FilterCheckBox.Genre = skinPanel4.Controls; FilterCheckBox.Language = skinPanel5.Controls; StaticUtilFunctions.SetFormMid(this); }
private void button14_Click(object sender, EventArgs e) { UtilValues.DownloadInfo info = new UtilValues.DownloadInfo(); info.FileName = setInfo.sid.ToString() + " " + setInfo.artist + " - " + setInfo.title + ".png"; info.FileName = StaticUtilFunctions.RenameFile(info.FileName); info.URL = "https://txy1.sayobot.cn/maps/bg/" + setInfo.beatmapInfos[0].img_base64; info.type = UtilValues.DownloadFileType.PicFile; Thread DownloadThread = new Thread(new ParameterizedThreadStart(StaticUtilFunctions.DownloadFile)); DownloadThread.Start(info); DownloadThread.DisableComObjectEagerCleanup(); }
private void button12_Click(object sender, EventArgs e) { UtilValues.DownloadInfo info = new UtilValues.DownloadInfo(); info.URL = "https://txy1.sayobot.cn/maps/audio/" + setInfo.sid.ToString(); info.FileName = setInfo.sid.ToString() + " " + setInfo.artist + " - " + setInfo.title + ".mp3"; info.FileName = StaticUtilFunctions.RenameFile(info.FileName); info.type = UtilValues.DownloadFileType.MusicFile; Thread DownloadThread = new Thread(new ParameterizedThreadStart(StaticUtilFunctions.DownloadFile)); PublicControlers.notifyIcon.ShowBalloonTip(500, "SayobotMapDownloader", info.FileName + "开始下载", ToolTipIcon.Info); DownloadThread.Start(info); DownloadThread.DisableComObjectEagerCleanup(); }
private void timer2_Tick(object sender, EventArgs e) { double CurrentMemoryUsage = Process.GetCurrentProcess().WorkingSet64 / 1024.0 / 1024.0; UtilValues.PublicValue.ProgramRunTime += 1; if (Settings.MemoryUsageShown) { label2.Text = String.Format("运行时间:{0}s 内存占用:{1:f2}mb", UtilValues.PublicValue.ProgramRunTime, CurrentMemoryUsage); } if (CurrentMemoryUsage > Convert.ToDouble(Settings.MemoryLimit)) { StaticUtilFunctions.ClearMemory(); } }
private void dataGridView1_CellContentClick(object sender, DataGridViewCellEventArgs e) { if (e.ColumnIndex != 4 && e.ColumnIndex != 5) { return; } string sid = dataGridView1.Rows[e.RowIndex].Cells[1].Value.ToString(); string TitleArtist = dataGridView1.Rows[e.RowIndex].Cells[0].Value.ToString(); if (dataGridView1.Columns[e.ColumnIndex].Name == "DownloadButton" && e.RowIndex >= 0 && ((DataGridViewButtonCell)dataGridView1.CurrentCell).FormattedValue.ToString() == "√") { UtilValues.DownloadInfo info = new UtilValues.DownloadInfo(); vCell = (DataGridViewButtonCell)dataGridView1.CurrentCell; info.FileName = sid + " " + StaticUtilFunctions.RenameFile(TitleArtist) + ".osz"; info.URL = "https://osu.sayobot.cn/osu.php?s=" + sid + ".osz"; info.ClickedCell = (DataGridViewButtonCell)dataGridView1.CurrentCell; info.type = UtilValues.DownloadFileType.BeatmapFile; Thread DownloadThread = new Thread(new ParameterizedThreadStart(StaticUtilFunctions.DownloadFile)); notifyIcon1.ShowBalloonTip(500, "SayobotMapDownloader", info.FileName + "开始下载", ToolTipIcon.Info); DownloadThread.Start(info); DownloadThread.DisableComObjectEagerCleanup(); } else if (dataGridView1.Columns[e.ColumnIndex].Name == "Listening" && e.RowIndex >= 0 && ((DataGridViewButtonCell)dataGridView1.CurrentCell).FormattedValue.ToString() == "▶") { vCell = (DataGridViewButtonCell)dataGridView1.CurrentCell; for (int tmp = 0; tmp < dataGridView1.RowCount; tmp++) { dataGridView1.Rows[tmp].Cells[5].Value = "▶"; } axWindowsMediaPlayer1.URL = "https://txy1.sayobot.cn/preview/" + sid + ".mp3"; vCell.Value = "■"; vCell.Tag = true; } else if (dataGridView1.Columns[e.ColumnIndex].Name == "Listening" && e.RowIndex >= 0 && vCell.FormattedValue.ToString() == "■") { vCell = (DataGridViewButtonCell)dataGridView1.CurrentCell; vCell.Value = "▶"; vCell.Tag = true; axWindowsMediaPlayer1.URL = ""; } }
static void Release() { Application.EnableVisualStyles(); Application.SetCompatibleTextRenderingDefault(false); MainForm mainForm = new MainForm(); StaticUtilFunctions.SetFormMid(mainForm); SystemInfo.OSVersion = Environment.OSVersion.VersionString; SystemInfo.DeviceUniqueCode = StaticUtilFunctions.GetPCUniqueCode(); try { Application.Run(mainForm); } catch (Exception ex) { string osVersion = "OSVersion: " + Environment.OSVersion.VersionString; string AppVersion = "AppVersion: " + Application.ProductVersion.ToString(); var str = osVersion + "\r\n\r\n" + AppVersion + "\r\n\r\n" + string.Format("Type: {0}\r\n\r\nMessage: {1}\r\n\r\nInformation: \r\n{2}", ex.GetType().Name, ex.Message, ex.StackTrace); if (!Directory.Exists(Environment.CurrentDirectory + "\\ErrorLog")) { Directory.CreateDirectory(Environment.CurrentDirectory + "\\ErrorLog"); } var LogFileName = Environment.CurrentDirectory + "\\ErrorLog\\" + SystemInfo.DeviceUniqueCode + " " + DateTime.Now.ToString("yyyy-MM-dd HHmmss") + ".log"; using (var sw = new StreamWriter(LogFileName, true)) { sw.Write(str); sw.Close(); } ErrorReport errorReporter = new ErrorReport(); StaticUtilFunctions.SetFormMid(errorReporter); errorReporter.ErrorLogFilePath = LogFileName; errorReporter.ErrorLogInformation = str; errorReporter.ShowDialog(); } }
public static string Spawn_SearchHttpLink(string KeyWord, int offset) { StaticUtilFunctions.GetFilterValue(); string sources = String.Format("https://api.sayobot.cn/beatmaplist?0=200&1={0}&2=4&3={1}", offset, KeyWord); sources += UtilValues.FilterValue.SearchType != 0 ? String.Format("&4={0}", UtilValues.FilterValue.SearchType) : null; sources += UtilValues.FilterValue.Mode != 0 ? String.Format("&5={0}", UtilValues.FilterValue.Mode) : null; sources += UtilValues.FilterValue.MapStatus != 0 ? String.Format("&6={0}", UtilValues.FilterValue.MapStatus) : null; sources += UtilValues.FilterValue.Genre != 0 ? String.Format("&7={0}", UtilValues.FilterValue.Genre) : null; sources += UtilValues.FilterValue.Language != 0 ? String.Format("&8={0}", UtilValues.FilterValue.Language) : null; /* * sources += String.Format( * "star:{0}~{1},AR:{2}~{3},OD:{3}~{4},CS:{5}~{6},HP:{7}~{8},length:{9}~{10},BPM:{11}~{12},end", * UtilValues.FilterValue.Stars[0], UtilValues.FilterValue.Stars[1], * UtilValues.FilterValue.AR[0], UtilValues.FilterValue.AR[1], * UtilValues.FilterValue.OD[0], UtilValues.FilterValue.OD[1], * UtilValues.FilterValue.CS[0], UtilValues.FilterValue.CS[1], * UtilValues.FilterValue.HP[0], UtilValues.FilterValue.HP[1], * UtilValues.FilterValue.Length[0], UtilValues.FilterValue.Length[1], * UtilValues.FilterValue.BPM[0], UtilValues.FilterValue.BPM[1]); */ return(sources); }
public BeatmapDetailInfo() { InitializeComponent(); StaticUtilFunctions.SetFormMid(this); }
public void ReadingPadSettings() { HIDDevice Pad = new HIDDevice(devicePath, false); //读取按键信息 const int countKey = 6; padKeys = new PadKeys[countKey]; for (byte keyNo = 0; keyNo < countKey; keyNo++) { byte[] sendInformation = { 02, 06, 02, 00, keyNo }; Pad.write(StaticUtilFunctions.CalcSHA(sendInformation)); System.Threading.Thread.Sleep(100); byte[] receiveInformation = Pad.read(); byte ControlKey = receiveInformation[7]; byte CharKey = receiveInformation[8]; this.padKeys[keyNo].charKeys = (PadSetConstValue.Keys.CharKeys)CharKey; //解析Control按键 for (byte exp = 7; exp >= 0; exp--) { if (ControlKey >= (1 << exp)) { ControlKey -= (byte)(1 << exp); this.padKeys[keyNo].controlKeys.SetValue(true, exp); } } } //读取灯光信息 const int countLight = 5; padLights = new PadLights[countLight]; for (byte lightNo = 0; lightNo < countLight; lightNo++) { byte[] sendInformation = { 02, 07, 02, 00, lightNo }; Pad.write(StaticUtilFunctions.CalcSHA(sendInformation)); System.Threading.Thread.Sleep(100); byte[] receiveInformation = Pad.read(); byte LightData = receiveInformation[7]; this.padLights[lightNo].Speed = (PadSetConstValue.Light.Speed)(LightData << 6); byte LightMode = (byte)(LightData - (LightData << 6)); if (LightMode >= 0x3a) { padLights[lightNo].Mode = PadSetConstValue.Light.Mode.Unknown; padLights[lightNo].ColorMode = PadSetConstValue.Light.ColorMode.Unknown; padLights[lightNo].CustomColors = new Color[0]; } else { var PadSystemLightModes = Enum.GetValues(typeof(PadSetConstValue.Light.Mode)); for (int tmp = PadSystemLightModes.Length; tmp > 0; tmp--) { if (LightMode > (byte)PadSystemLightModes.GetValue(tmp - 1)) { padLights[lightNo].Mode = (PadSetConstValue.Light.Mode)PadSystemLightModes.GetValue(tmp - 1); try { padLights[lightNo].ColorMode = (PadSetConstValue.Light.ColorMode) LightMode - (byte)padLights[lightNo].Mode; } catch (Exception) { padLights[lightNo].ColorMode = PadSetConstValue.Light.ColorMode.Unknown; } } } } } }
public MainForm() { StaticUtilFunctions.SetFormMid(this); InitializeComponent(); }
public SettingForm() { InitializeComponent(); StaticUtilFunctions.SetFormMid(this); }
private void ErrorReport_Load(object sender, EventArgs e) { StaticUtilFunctions.SetFormMid(this); textBox1.Text = ErrorLogInformation; pictureBox1.Image = Image.FromFile(Environment.CurrentDirectory + "\\Resources\\Pics\\error.png"); }
private void Form2_Load(object sender, EventArgs e) { UtilValues.PublicValue.ProgramRunTime = 0; //Thread[] FormsLoad = { // new Thread(new ParameterizedThreadStart(ChildForms.LoadSettingsForm)), // new Thread(new ParameterizedThreadStart(ChildForms.LoadFilterForm))}; //var waits = new EventWaitHandle[2]; //int temp = 0; //foreach (Thread subThread in FormsLoad) //{ // var handler = new ManualResetEvent(false); // waits[temp]=handler; // subThread.Start(handler); // subThread.DisableComObjectEagerCleanup(); //} label1.BackColor = Color.Transparent; linkLabel1.BackColor = Color.Transparent; panel2.BackColor = Color.Transparent; menuStrip1.BackColor = Color.Transparent; panel1.BackColor = Color.Transparent; menuStrip1.BackColor = Color.Transparent; gmProgressBar1.XTheme = new Gdu.WinFormUI.ThemeProgressBarGreen(); dataGridView1.Visible = false; string SupportStatus = StaticUtilFunctions.JsonGet("https://api.sayobot.cn/support"); JavaScriptObject SupportStatusJson = (JavaScriptObject)JavaScriptConvert.DeserializeObject(SupportStatus); if (!SupportStatusJson.ContainsKey("data")) { MessageBox.Show("网络错误,请检查网络连接后重启程序", "SayobotBeatmapDownloader", MessageBoxButtons.OK, MessageBoxIcon.Error); Environment.Exit(-1); } JavaScriptObject Data = (JavaScriptObject)SupportStatusJson["data"]; gmProgressBar1.Percentage = (Int32)(Convert.ToDouble(Data["total"]) / Convert.ToDouble(Data["target"]) * 100.0); linkLabel1.Text = "投喂进度:$" + Data["total"].ToString() + "/$" + Data["target"].ToString(); linkLabel1.Links.Add(0, linkLabel1.Text.Length, "https://sayobot.cn/home"); PublicControlers.notifyIcon = notifyIcon1; PublicControlers.mediaPlayer = axWindowsMediaPlayer1; PublicControlers.dataGridView = dataGridView1; PublicControlers.mainForm = this; PublicControlers.settingForm = settingForm; PublicControlers.MemoryUsage = label2; StaticUtilFunctions.SetFormMid(settingForm); StaticUtilFunctions.SetFormMid(beatmapDetailInfo); StaticUtilFunctions.SetFormMid(filter); if (File.Exists(ConfigFile.inifilepath)) { ConfigFile.GetAllConfigsApply(); } else { /* * welcome = new Forms.Welcome(); * welcome.Show(); */ FileStream streamtmp = File.Create(ConfigFile.inifilename); streamtmp.Close(); ConfigFile.ResetAllConfigs(); } if (Settings.MainFormImage != "") { StaticUtilFunctions.LoadingMainFormBackgroundPic(); } StaticUtilFunctions.FindNanoPad(); if (UtilValues.PublicValue.nanoPads.Length != 0) { notifyIcon1.ShowBalloonTip(500, "SayobotBeatmapDownloader", "发现" + UtilValues.PublicValue.nanoPads.Length.ToString() + "个触盘", ToolTipIcon.Info); } //WaitHandle.WaitAll(waits); }
private void label1_TextChanged(object sender, EventArgs e) { pictureBox1.Image = Image.FromFile(Environment.CurrentDirectory + "\\Resources\\Pics\\loading.png"); pictureBox1.ImageLocation = "https://cdn.sayobot.cn:25225/beatmaps/" + label1.Text + "/covers/cover.jpg?0"; string GettedJsonString = StaticUtilFunctions.JsonGet("https://api.sayobot.cn/v2/beatmapinfo?0=" + label1.Text); JavaScriptObject Json = (JavaScriptObject)JavaScriptConvert.DeserializeObject(GettedJsonString); if (!Json.ContainsKey("status")) { MessageBox.Show("请求API失败", "网络错误", MessageBoxButtons.OK, MessageBoxIcon.Warning); return; } else if (Convert.ToInt32(Json["status"]) == -1) { MessageBox.Show("没有查询到数据", "SayobotBeatmapDownloader", MessageBoxButtons.OK, MessageBoxIcon.Information); return; } else { JavaScriptObject Data = (JavaScriptObject)Json["data"]; setInfo.approved = Convert.ToInt16(Data["approved"]); setInfo.approved_date = Convert.ToInt32(Data["approved_date"]); setInfo.artist = Convert.ToString(Data["artist"]); setInfo.beatmap_count = Convert.ToInt16(Data["bids_amount"]); setInfo.bpm = Convert.ToDouble(Data["bpm"]); setInfo.genre = Convert.ToInt16(Data["genre"]); setInfo.language = Convert.ToInt16(Data["language"]); setInfo.last_update = Convert.ToInt32(Data["last_update"]); setInfo.preview = Convert.ToInt16(Data["preview"]); setInfo.sid = Convert.ToInt32(Data["sid"]); setInfo.source = Convert.ToString(Data["source"]); setInfo.storyboard = Convert.ToInt16(Data["storyboard"]); setInfo.tags = Convert.ToString(Data["tags"]); setInfo.title = Convert.ToString(Data["title"]); setInfo.video = Convert.ToInt16(Data["video"]); setInfo.favorite = Convert.ToInt16(Data["favourite_count"]); JavaScriptArray mapArray = (JavaScriptArray)Data["bid_data"]; setInfo.beatmapInfos = new System.Collections.Generic.List <BeatmapInfo>(); for (int i = 0; i < setInfo.beatmap_count; i++) { JavaScriptObject singleMap = (JavaScriptObject)mapArray[i]; BeatmapInfo beatmap = new BeatmapInfo { ar = Convert.ToDouble(singleMap["AR"]), bid = Convert.ToInt32(singleMap["bid"]), creator = Convert.ToString(Data["creator"]), cs = Convert.ToDouble(singleMap["CS"]), hp = Convert.ToDouble(singleMap["HP"]), img_base64 = Convert.ToString(singleMap["img"]), maxcombo = Convert.ToInt32(singleMap["maxcombo"]), od = Convert.ToDouble(singleMap["OD"]), passcount = Convert.ToInt32(singleMap["passcount"]), playcount = Convert.ToInt32(singleMap["playcount"]), stars = Convert.ToDouble(singleMap["star"]), version = Convert.ToString(singleMap["version"]), length = Convert.ToInt16(singleMap["length"]) }; if (beatmap.passcount != 0) { beatmap.passrate = Convert.ToDouble(beatmap.passcount * 100) / beatmap.playcount; } else { beatmap.passrate = 0.0D; } setInfo.beatmapInfos.Add(beatmap); } DateTime startTime = TimeZone.CurrentTimeZone.ToLocalTime(new DateTime(1970, 1, 1)); string[] MapStatus = { "graveyard", "WIP", "pending", "ranked", "approved", "qualified", "loved" }; label2.Text = setInfo.beatmapInfos[0].version; label23.Text = Convert.ToString(setInfo.sid); label24.Text = MapStatus[setInfo.approved + 2]; label3.Text = setInfo.artist + " - " + setInfo.title; button8.Text = startTime.AddSeconds(setInfo.last_update + 8 * 3600).ToString("yyyy-MM-dd HH:mm:ss"); if (setInfo.approved_date > 0) { button9.Text = startTime.AddSeconds(setInfo.approved_date + 8 * 3600).ToString("yyyy-MM-dd HH:mm:ss"); } else { button9.Text = "null"; } button2.Text = Convert.ToString(setInfo.bpm); button5.Text = UtilValues.PublicValue.Language[setInfo.language]; button6.Text = UtilValues.PublicValue.Genre[setInfo.genre]; button7.Text = Convert.ToString(setInfo.favorite); toolTip1.SetToolTip(label8, setInfo.tags); toolTip1.SetToolTip(label12, setInfo.source); if (50 * setInfo.beatmap_count < 450) { panel2.Size = new Size(50 * setInfo.beatmap_count, 32); } else { panel2.Size = new Size(450, 32); } DrawRoundRectControl(panel2, Color.FromArgb(127, 216, 148, 139)); displayInfo(0); if (!this.Visible) { this.Show(); } } }
private void button1_Click(object sender, EventArgs e) { if (textBox1.Text != "" && button1.Text == "搜索") { dataGridView1.Rows.Clear(); DataTable table = new DataTable(); table.Columns.Add("艺术家 - 标题", typeof(string)); table.Columns.Add("sid", typeof(string)); table.Columns.Add("谱面状态", typeof(string)); table.Columns.Add("Mapper", typeof(string)); string GettedJsonString = StaticUtilFunctions.JsonGet(StaticUtilFunctions.Spawn_SearchHttpLink(textBox1.Text, 0)); JavaScriptObject GettedJson = (JavaScriptObject)JavaScriptConvert.DeserializeObject(GettedJsonString); if (!GettedJson.ContainsKey("status")) { MessageBox.Show("请求API失败", "网络错误", MessageBoxButtons.OK, MessageBoxIcon.Warning); return; } else if (Convert.ToInt32(GettedJson["status"]) == -1) { MessageBox.Show("没有查询到数据", "SayobotBeatmapDownloader", MessageBoxButtons.OK, MessageBoxIcon.Information); dataGridView1.Visible = false; label3.Visible = true; return; } label3.Visible = false; JavaScriptArray Data = (JavaScriptArray)GettedJson["data"]; for (int tmp = 0; tmp < Data.Count; ++tmp) { JavaScriptObject SingleMap = (JavaScriptObject)Data[tmp]; string BasicInfo = SingleMap["artist"].ToString() + " - " + SingleMap["title"].ToString(); table.Rows.Add(BasicInfo, SingleMap["sid"].ToString(), UtilValues.PublicValue.MapStatus[Convert.ToInt32(SingleMap["approved"]) + 2], SingleMap["creator"].ToString()); } while (Convert.ToInt32(GettedJson["endid"]) != 0 && table.Rows.Count < 1000) { var offset = Convert.ToInt32(GettedJson["endid"]); GettedJsonString = StaticUtilFunctions.JsonGet(StaticUtilFunctions.Spawn_SearchHttpLink(textBox1.Text, offset)); GettedJson = (JavaScriptObject)JavaScriptConvert.DeserializeObject(GettedJsonString); if (!GettedJson.ContainsKey("status")) { GettedJson.Add("endid", offset); continue; } Data = (JavaScriptArray)GettedJson["data"]; for (int tmp = 0; tmp < Data.Count; ++tmp) { JavaScriptObject SingleMap = (JavaScriptObject)Data[tmp]; string BasicInfo = SingleMap["artist"].ToString() + " - " + SingleMap["title"].ToString(); table.Rows.Add(BasicInfo, SingleMap["sid"].ToString(), UtilValues.PublicValue.MapStatus[Convert.ToInt32(SingleMap["approved"]) + 2], SingleMap["creator"].ToString()); } } if (29 + 23 * table.Rows.Count > 354) { dataGridView1.Height = 354; } else { dataGridView1.Height = 29 + 23 * table.Rows.Count; } foreach (DataRow row in table.Rows) { dataGridView1.Rows.Add(row.ItemArray[0], row.ItemArray[1], row.ItemArray[2], row.ItemArray[3]); } dataGridView1.Visible = true; table.Clear(); table.Dispose(); } else if (textBox1.Text != "" && button1.Text == "查找") { bool flag = false; foreach (DataGridViewRow row in dataGridView1.Rows) { for (int tmp = 0; tmp < 4; tmp++) { if (row.Cells[tmp].Value.ToString().Contains(textBox1.Text)) { flag = true; break; } } if (!flag) { row.Visible = false; } } } else if (button1.Text == "过滤器") { PublicControlers.SearchBtn = button1; filter.BackColor = ColorTranslator.FromHtml(Settings.MainFormColor); filter.Show(); } }