コード例 #1
0
 public Rect()
 {
     Id       = int.Parse(DateTime.Today.ToString("yyddmmss"));
     Text     = string.Empty;
     Size     = new Size(100, 100);
     Location = new Point(100, 100);
     Alive    = true;
     RectThread.FromCurrent().AddRect(this);
 }
コード例 #2
0
 public Rect(int id, string text, Size size, Point location)
 {
     Id       = id;
     Text     = text;
     Size     = size;
     Location = location;
     Alive    = true;
     RectThread.FromCurrent().AddRect(this);
     Console.WriteLine(Id + "号矩形已创建");
 }
コード例 #3
0
        /// <summary>
        /// 获取与当前线程相关的RectThread对象
        /// </summary>
        /// <returns></returns>
        public static RectThread FromCurrent()
        {
            var id = Thread.CurrentThread.ManagedThreadId;

            if (_allRectThreads.ContainsKey(id))
            {
                return(_allRectThreads[id]);
            }

            var thread = new RectThread();

            _allRectThreads.Add(id, thread);
            return(_allRectThreads[id]);
        }
コード例 #4
0
 /// <summary>
 /// 执行一次信号循环,进行一次信号处理
 /// </summary>
 public static void DoSignal() => RectThread.FromCurrent().StartLoop(2, null);
コード例 #5
0
 /// <summary>
 /// 开启信号循环
 /// </summary>
 /// <param name="rect">主rect</param>
 public static void Start(Rect rect) => RectThread.FromCurrent().StartLoop(1, rect);
コード例 #6
0
 protected override void OnPositionChanged(PositionChangedEventArgs e)
 {
     RectThread.SendSignal(Id, 1, e.Size, e.Location);
     base.OnPositionChanged(e);
 }