Exemplo n.º 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);
 }
Exemplo n.º 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 + "号矩形已创建");
 }
Exemplo n.º 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]);
        }
Exemplo n.º 4
0
 /// <summary>
 /// 执行一次信号循环,进行一次信号处理
 /// </summary>
 public static void DoSignal() => RectThread.FromCurrent().StartLoop(2, null);
Exemplo n.º 5
0
 /// <summary>
 /// 开启信号循环
 /// </summary>
 /// <param name="rect">主rect</param>
 public static void Start(Rect rect) => RectThread.FromCurrent().StartLoop(1, rect);
Exemplo n.º 6
0
 protected override void OnPositionChanged(PositionChangedEventArgs e)
 {
     RectThread.SendSignal(Id, 1, e.Size, e.Location);
     base.OnPositionChanged(e);
 }