/// <summary> /// Область вывода изменила размер /// </summary> /// <param name="sender">Источник события</param> /// <param name="e">Параметры события</param> private void sheet_Resize(object sender, EventArgs e) { bool blocked = false; try { if (drawMutex.WaitOne(300)) { blocked = true; if (sheet != null) { if (sheet.Size.IsEmpty == false) { // общий графический объект на всю область вывода drawter = new GraphicDrawter(sheet.CreateGraphics(), sheet.ClientRectangle); if (Orientation == Orientation.Horizontal) { drawter.Graphics.RotateTransform(270.0f); drawter.Graphics.TranslateTransform(-sheet.ClientRectangle.Height, 0); } InitializePanel(); sheet.Invalidate(); } } } } finally { if (blocked) { drawMutex.ReleaseMutex(); } } }
/// <summary> /// Инициализирует новый экземпляр класса /// </summary> /// <param name="_sheet"></param> public Panel(GraphicsSheet _sheet) { try { bufRect = RectangleF.Empty; drawMutex = new Mutex(); locker = new ReaderWriterLockSlim(LockRecursionPolicy.SupportsRecursion); graphics = new List <Graphic>(); g_locker = new ReaderWriterLockSlim(LockRecursionPolicy.SupportsRecursion); if (_sheet != null) { sheet = _sheet; sheet.Resize += new EventHandler(sheet_Resize); sheet.Paint += new PaintEventHandler(sheet_Paint); interval = new TimeSpan(0, 3, 0); // интервал времени в одной клетке drawter = new GraphicDrawter(sheet.CreateGraphics(), sheet.ClientRectangle); panels = new List <IElement>(); panels.Add(CreateTimePanel()); panels.Add(CreateScalePanel()); panels.Add(CreateGraphicsPanel()); orientation = Orientation.Vertical; } } catch (Exception ex) { MessageBox.Show(ex.Message); } }
protected SizeF timeSizeF; // размер области в которую выводится метка времени #endregion Fields #region Constructors /// <summary> /// Инициализирует новый экземпляр класса /// </summary> /// <param name="_sheet"></param> public Panel(GraphicsSheet _sheet) { try { bufRect = RectangleF.Empty; drawMutex = new Mutex(); locker = new ReaderWriterLockSlim(LockRecursionPolicy.SupportsRecursion); graphics = new List<Graphic>(); g_locker = new ReaderWriterLockSlim(LockRecursionPolicy.SupportsRecursion); if (_sheet != null) { sheet = _sheet; sheet.Resize += new EventHandler(sheet_Resize); sheet.Paint += new PaintEventHandler(sheet_Paint); interval = new TimeSpan(0, 0, 10); // интервал времени в одной клетке drawter = new GraphicDrawter(sheet.CreateGraphics(), sheet.ClientRectangle); panels = new List<IElement>(); panels.Add(CreateTimePanel()); panels.Add(CreateScalePanel()); panels.Add(CreateGraphicsPanel()); orientation = Orientation.Vertical; } } catch (Exception ex) { MessageBox.Show(ex.Message); } }