private void SetIcon(string text) { try { this.notifyIcon1.Text = text; if (text.Length > 0) { // 动态生成一个文字图标对象,用于托盘图标的显示 Icon icon = ImageCreater.CreateTrayIcon(text); if (icon != null) { notifyIcon1.Icon = icon; } } else { // 如果没有相关文字信息则使用主窗口图标作为托盘图标 notifyIcon1.Icon = Business_Cmpp.Properties.Resources.main; } } catch (Exception) { } }
private void frmPacman_Load(object sender, EventArgs e) { ImageCreater imageCreater = new ImageCreater(grpBox_GameScreen); thePacman = imageCreater.CreatePacman(); ghosts = imageCreater.CreateGhosts(); ordinaryFoods = imageCreater.CreateFoods(); mapObjectOperator = new MapObjectOperator(grpBox_GameScreen, ordinaryFoods); pacmanMover = new PacmanMover(thePacman, mapObjectOperator); ghostMovers = new GhostMover[ghosts.Length]; pacmanAI = new PacmanAIOperator(thePacman, ghosts, mapObjectOperator, 5, ordinaryFoods); for (int ghostRecorder = 0; ghostRecorder < ghosts.Length; ghostRecorder++) { ghostMovers[ghostRecorder] = new GhostMover(ghosts[ghostRecorder], mapObjectOperator); } LoadGhostMovementUtility(); LoadPacmanMovementUtility(); }