📄 room.cs
字号:
using System;
using System.Collections.Generic;
using System.Text;
using System.Threading;
using System.Collections;
using feiyun0112.cnblogs.com.CSDNReader.Functions;
using System.Windows.Forms;
using System.Net;
using System.Text.RegularExpressions;
namespace feiyun0112.cnblogs.com.CSDNReader.Model
{
public class Room
{
private int _ID ;
private int _RoomID ;
private string _name;
private string _URL="";
private DateTime _refreshTime;
private bool _blnManuleRefresh;
private List<Topic> _Topics = new List<Topic>();
private int _Items;
private int _UnreadItems;
private bool _IsGroup ;
private int _GroupID ;
private bool _blnInRefresh;
public Room()
{
this.Items = -1;
this.UnreadItems = -1;
DelegateFunc.CheckTopicExistEvent += new DelegateCheckTopicExist(CheckTopicExist);
}
public Room(string strName,string strURL):base()
{
this.Name = strName;
this.URL = strURL;
}
#region property
public int ID
{
get
{
return _ID;
}
set
{
_ID = value;
}
}
public int RoomID
{
get
{
if (_RoomID <= 0)
{
try
{
_RoomID = int.Parse(RegexFunc.GetMatch(this.URL, "&roomid=(.*)"));
}
catch
{
_RoomID = 0;
}
}
return _RoomID;
}
set
{
_RoomID = value;
}
}
public string Name
{
get
{
return _name;
}
set
{
_name = value;
}
}
public string URL
{
get
{
return _URL;
}
set
{
_URL = value;
if (!_URL.StartsWith("http://"))
{
_URL = "http://community.csdn.net" + _URL;
}
}
}
public DateTime RefreshTime
{
get
{
return _refreshTime;
}
set
{
_refreshTime = value;
}
}
public bool ManuleRefresh
{
get
{
return _blnManuleRefresh;
}
set
{
_blnManuleRefresh = value;
}
}
public List<Topic> Topics
{
get
{
if (_Topics == null)
_Topics = new List<Topic>();
return _Topics;
}
////set
////{
//// _Topics = value;
////}
}
public int Items
{
get
{
if (this.IsGroup)
{
//int intTot = 0;
//foreach (Room rChild in this.ChildRooms)
//{
// intTot += rChild.Items;
//}
//return intTot;
return 0;
}
else
{
if (_Items < 0)
{
_Items = Topics.Count;
//foreach (Topic t in Topics)
//{
// _Items++;
//}
}
return _Items;
}
}
set
{
_Items = value;
}
}
public int UnreadItems
{
get
{
if (this.IsGroup)
{
//int intTot=0;
//foreach (Room rChild in this.ChildRooms)
//{
// intTot += rChild.UnreadItems;
//}
//return intTot;
}
else
{
if (_UnreadItems < 0)
{
_UnreadItems = 0;
foreach (Topic t in Topics)
{
if (!t.HaveRead)
{
_UnreadItems++;
}
}
}
}
return _UnreadItems;
}
set
{
_UnreadItems = value;
}
}
public bool IsGroup
{
get
{
return _IsGroup;
}
set
{
_IsGroup = value;
}
}
public int GroupID
{
get
{
return _GroupID;
}
set
{
_GroupID = value;
}
}
public bool InRefresh
{
get
{
if (((TimeSpan)(DateTime.Now - this.RefreshTime)).TotalMinutes > Setting.RefreshMinutes)
{
_blnInRefresh = false;
}
return _blnInRefresh;
}
set
{
_blnInRefresh = value;
}
}
#endregion property
public static Room AddRoom()
{
frmRoom frm = new frmRoom();
frm.Text = "添加";
if (DialogResult.OK != frm.ShowDialog())
return null;
return frm.Room;
}
public static Room EditRoom(Room r)
{
frmRoom frm = new frmRoom();
frm.Text = "修改";
frm.Room = r;
if (DialogResult.OK != frm.ShowDialog())
return null;
return frm.Room;
}
#region Refrash Room
internal void RefreshRoom()
{
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -