//页面初始布置 public MainWindow() { InitializeComponent(); rect0.Fill = new SolidColorBrush(MyColor.HSI(currentColorId)); rect1.Fill = new SolidColorBrush(MyColor.HSI(currentColorId + 72)); rect2.Fill = new SolidColorBrush(MyColor.HSI(currentColorId + 144)); rect3.Fill = new SolidColorBrush(MyColor.HSI(currentColorId - 144)); rect4.Fill = new SolidColorBrush(MyColor.HSI(currentColorId - 72)); }
//构造函数 public Message(JObject j) { this.id = int.Parse(j["id"].ToString()); this.content = j["content"].ToString(); this.father = int.Parse(j["father"].ToString()); this.senderName = j["senderName"].ToString(); this.colorId = int.Parse(j["colorId"].ToString()); this.hot = int.Parse(j["hot"].ToString()); this.place = int.Parse(j["place"].ToString()); this.color = MyColor.HSI(colorId); this.brush = new SolidColorBrush(this.color); this.RefreshSons((JArray)j["sons"]); }
//定时检查:动画控制+用户登录检查 private void timer1_Tick(object sender, EventArgs e) { //颜色动画控制 int d = currentColorId - tartgetColorId; if (d < -180) { d += 360; } else if (d > 180) { d -= 360; } if (d <= speedOfColor && d >= -speedOfColor) { currentColorId = tartgetColorId; } else if (d < 0) { currentColorId = (currentColorId + speedOfColor) % 360; } else { currentColorId = (currentColorId + 360 - speedOfColor) % 360; } rect0.Fill = new SolidColorBrush(MyColor.HSI(currentColorId)); rect1.Fill = new SolidColorBrush(MyColor.HSI(currentColorId + 72)); rect2.Fill = new SolidColorBrush(MyColor.HSI(currentColorId + 144)); rect3.Fill = new SolidColorBrush(MyColor.HSI(currentColorId - 144)); rect4.Fill = new SolidColorBrush(MyColor.HSI(currentColorId - 72)); //用户登录检查 if (User.WrongPassword) { MessageBox.Show("密码错误!"); } if (User.LoginFlag) { NextStage(); } }
//用户名框响应 private void TextBox_TextChanged_1(object sender, TextChangedEventArgs e) { string s = textBoxUserName.Text; tartgetColorId = MyColor.NameColorId(s); }