Пример #1
0
        protected NumericTable _table = null; // графический элемент на котором осуществляется

        #endregion Fields

        #region Constructors

        /// <summary>
        /// Инициализирует новый экземпляр класса
        /// </summary>
        /// <param name="table"></param>
        public Panel(NumericTable table)
        {
            if (table != null)
            {
                _table = table;

                _table.Resize += new EventHandler(_table_Resize);
                _table.Paint += new System.Windows.Forms.PaintEventHandler(_table_Paint);

                items = new List<PanelItem>();
                i_slim = new ReaderWriterLockSlim(LockRecursionPolicy.SupportsRecursion);

                rect = new BoundingRectangle();

                d_mutex = new Mutex();
                drawter = new GraphicDrawter(_table.CreateGraphics(), _table.ClientRectangle);
            }
        }
Пример #2
0
        /// <summary>
        /// Изменился размер панели
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void _table_Resize(object sender, EventArgs e)
        {
            bool blocked = false;
            try
            {
                if (d_mutex.WaitOne(50))
                {
                    blocked = true;
                    if (!_table.Size.IsEmpty)
                    {
                        Point n_location = new Point();

                        n_location.X = Math.Abs((int)(_table.Width * k_left));
                        n_location.Y = Math.Abs((int)(_table.Height * k_top));

                        Size n_size = new Size();

                        n_size.Width = Math.Abs((int)(_table.Width - (_table.Width * k_left) - (_table.Width * k_right)));
                        n_size.Height = Math.Abs((int)(_table.Height - (_table.Height * k_top) - (_table.Height * k_bottom)));

                        rect = new BoundingRectangle(n_location, n_size);
                        drawter = new GraphicDrawter(_table.CreateGraphics(), _table.ClientRectangle);
                    }
                }
            }
            catch { }
            finally
            {
                if (blocked) d_mutex.ReleaseMutex();
            }
        }