public Form_log(string message, string title, DPI dpi) { Width = 450; Height = 500; ShowIcon = false; TopMost = true; Text = title; Width = (int)(Width * dpi.DpiX / 100); Height = (int)(Height * dpi.DpiY / 100); MaximizeBox = false; MinimizeBox = false; StartPosition = FormStartPosition.CenterParent; foreach (var tmp in message.Split('\n')) { tb.Text += string.Format(" {0}\n", tmp); } tb.Width = ClientSize.Width; tb.Height = ClientSize.Height; tb.Select(0, 0); tb.ScrollToCaret(); Controls.Add(tb); SizeChanged += (object sender, EventArgs e) => { tb.Width = ClientSize.Width; tb.Height = ClientSize.Height; }; }
public Form_rename(string name, DPI dpi) { InitializeComponent(); #region Dpi调整组建大小 float dx = dpi.DpiX / 100; float dy = dpi.DpiY / 100; Width = (int)(Width * dx); Height = (int)(Height * dy); textBox_name.Width = (int)(textBox_name.Width * dx); button_ok.Width = (int)(button_ok.Width * dx); textBox_name.Top = (ClientSize.Height - textBox_name.Height) / 2; textBox_name.Left = (ClientSize.Width - textBox_name.Width - button_ok.Width - 6) / 2; button_ok.Left = textBox_name.Right + 6; #endregion OldName = name; textBox_name.Text = name; Text += " \"" + name + "\""; }
public Form_about(DPI dpi) { InitializeComponent(); this.dpi = dpi; Width = (int)(Width * dpi.DpiX / 100); Height = (int)(Height * dpi.DpiY / 100); }
public Form_create(int gamever, DPI dpi) { InitializeComponent(); #region Dpi调整组建大小 float dx = dpi.DpiX / 100; float dy = dpi.DpiY / 100; Width = (int)(Width * dx); Height = (int)(Height * dy); textBox_name.Width = (int)(textBox_name.Width * dx); button_ok.Width = (int)(button_ok.Width * dx); textBox_name.Top = (ClientSize.Height - textBox_name.Height) / 2; textBox_name.Left = (ClientSize.Width - textBox_name.Width - button_ok.Width - 6) / 2; button_ok.Left = textBox_name.Right + 6; #endregion string name; switch (gamever) { case PVZVersion.STEAM: name = "Steam"; break; case PVZVersion.ZOO_JP: name = "日文版"; break; default: name = "存档"; break; } for (int i = 1; true; i++) { string tmp = i.ToString(); while (tmp.Length < 3) { tmp = "0" + tmp; } tmp = string.Format("{0} - {1}", name, tmp); if (!Directory.Exists(MyString.Path_backups + @"\" + tmp)) { name = tmp; break; } } textBox_name.Text = name; }
public Form_selectVersion(DPI dpi) { InitializeComponent(); #region DPI调整组件大小 float dx = dpi.DpiX / 100; float dy = dpi.DpiY / 100; int i = (int)((button_original.Left - label_info.Right) * dx); int j = (int)((button_steam.Top - button_original.Bottom) * dy); Width = (int)(Width * dx); Height = (int)(Height * dy); button_original.Width = (int)(button_original.Width * dx); button_original.Height = (int)(button_original.Height * dy); button_steam.Width = button_original.Width; button_steam.Height = button_original.Height; button_zoo_jp.Width = button_original.Width; button_zoo_jp.Height = button_original.Height; button_original.Left = ClientSize.Width - button_original.Width - (int)(12 * dx); button_steam.Left = button_original.Left; button_zoo_jp.Left = button_steam.Left; button_original.Top = (ClientSize.Height - button_original.Height * 3 - j * 2) / 2; button_steam.Top = button_original.Bottom + j; button_zoo_jp.Top = button_steam.Bottom + j; label_info.Left = (int)(12 * dx); label_info.Top = (int)(12 * dy); label_info.Width = button_original.Left - label_info.Left - i; checkBox_remember.Left = (int)(15 * dx); checkBox_remember.Top = ClientSize.Height - checkBox_remember.Height - (int)(12 * dy); label_info.Height = checkBox_remember.Top - label_info.Top - j; #endregion }
private void Form_main_Load(object sender, EventArgs e) { #region 加入item for (int i = list.Count - 1; i >= 0; i--) { if (Directory.Exists(Path_backups + @"\" + list[i])) { listBox_backups.Items.Insert(0, list[i]); } else { list.RemoveAt(i); } } foreach (var tmp in Directory.GetDirectories(Path_backups)) { string name = tmp.Substring(tmp.LastIndexOf('\\') + 1); if (!list.Contains(name)) { if (Directory.Exists(tmp + @"\userdata")) { list.Add(name); listBox_backups.Items.Add(name); } else { Dir.Delete(tmp); } } } #endregion #region Dpi调整组件大小 dpi = Dpi.GetDpi(this); float dx = dpi.DpiX / 100; float dy = dpi.DpiY / 100; button_create.Width = (int)(button_create.Width * dx); button_create.Height = (int)(button_create.Height * dy); button_restore.Width = (int)(button_restore.Width * dx); button_restore.Height = (int)(button_restore.Height * dy); button_restore.Left = button_create.Right + 6; listBox_backups.Top = button_create.Bottom + 6; #endregion ListBox_backups_SelectedIndexChanged(null, null); Form_main_SizeChanged(null, null); Activate(); #region 恢复上一次关闭时的窗口位置 int[] ws = new int[4] { conf.GetObject <int>("WindowState", "x"), conf.GetObject <int>("WindowState", "y"), conf.GetObject <int>("WindowState", "w"), conf.GetObject <int>("WindowState", "h"), }; bool available = true; foreach (int tmp in ws) { if (tmp == -1) { available = false; break; } } if (available) { if (ws[0] < 0) { ws[0] = 0; } else if (ws[0] + ws[2] > Screen.PrimaryScreen.Bounds.Width) { ws[0] = Screen.PrimaryScreen.Bounds.Width - ws[2]; } if (ws[1] < 0) { ws[1] = 0; } else if (ws[1] + ws[3] > Screen.PrimaryScreen.Bounds.Height) { ws[1] = Screen.PrimaryScreen.Bounds.Height - ws[3]; } Left = ws[0]; Top = ws[1]; Width = ws[2]; Height = ws[3]; } #endregion TopMost = conf.GetObject <bool>("var", "TopMost"); justStartUp = false; #region 添加DEBUG按钮(此部分代码只在debug下执行) #if DEBUG button_debug = new LinkLabel { Text = "DEBUG", AutoSize = true, Left = button_restore.Right + 6, Top = button_restore.Top }; button_debug.Click += (object sender_, EventArgs e_) => { string output = string.Empty; output += string.Format("【文件夹路径】\n{0}\n{1}\n{2}\n{3}\n{4}\n{5}\n\n", Path_AppData, Path_BKdata, Path_backups, PATH_PVZUSERDATA_ORIGINAL, PATH_PVZUSERDATA_STEAM, PATH_PVZUSERDATA_ZOO_JP ); output += string.Format("【DPI】\nDpiX: {0}\nDpiY: {1}\n\n", dpi.DpiX, dpi.DpiY); output += string.Format("【当前】\nOS version (major): {0}\ngamever: {1}\npath_userdata: {2}", Environment.OSVersion.Version.Major, gamever, path_userdata); MessageBox.Show(output, "DEBUG"); }; Controls.Add(button_debug); #endif #endregion }