Example #1
0
 public void RestoreBounds(Point offset, ButtonViewInfo buttonViewInfo, Rectangle buttonRect, Rectangle textRect)
 {
     buttonRect.Offset(-offset.X, -offset.Y);
     textRect.Offset(-offset.X, -offset.Y);
     buttonViewInfo.Bounds     = buttonRect;
     buttonViewInfo.TextBounds = textRect;
 }
        protected override void OnMouseDown(MouseEventArgs e)
        {
            base.OnMouseDown(e);
            ReminderHitInfo hitInfo = CalcHitInfo(e.Location);

            HotTrackButtonInfo = null;
            UpdateButton(hitInfo, State.Pressed);
            if (HotTrackButtonInfo != null)
            {
                ButtonClickEventArgs eventArgs = new ButtonClickEventArgs()
                {
                    Handled = false, Button = HotTrackButtonInfo.Owner
                };
                RaiseButtonClick(this, eventArgs);
                if (!eventArgs.Handled)
                {
                    if (eventArgs.Button.Kind == ButtonKind.HeaderAdd)
                    {
                        Notes.AddNote("New Note", DateTime.Now, RepeatMode.EveryDay);
                        ReminderListBox.SelectedIndex = ReminderListBox.Items.Count - 1;
                    }
                    else if (eventArgs.Button.Kind == ButtonKind.Note)
                    {
                        View = ViewKind.Edit;
                    }
                    else
                    {
                        View = ViewKind.View;
                    }
                }
            }
        }
        protected override void OnMouseUp(MouseEventArgs e)
        {
            base.OnMouseUp(e);
            ReminderHitInfo hitInfo = CalcHitInfo(e.Location);

            HotTrackButtonInfo = null;
            UpdateButton(hitInfo, State.Normal);
        }
 protected virtual void DrawBorder(System.Drawing.Graphics graphics, ButtonViewInfo viewInfo)
 {
     if (viewInfo.Owner.ButtonBorderStyle == ButtonBorderStyle.Normal)
     {
         Pen pen = GetBorderPen(viewInfo);
         graphics.DrawRectangle(pen, viewInfo.Bounds);
     }
 }
Example #5
0
        public ButtonViewInfo Clone()
        {
            ButtonViewInfo viewInfo = new ButtonViewInfo(Owner);

            viewInfo.Bounds     = Bounds;
            viewInfo.TextBounds = TextBounds;
            return(viewInfo);
        }
Example #6
0
 public void CalcButton(Graphics graphics)
 {
     NoteButton.CalcViewInfo(graphics, ClientRectangle);
     ButtonsInfo.Clear();
     for (int i = 0; i < Items.Count; i++)
     {
         ButtonViewInfo viewInfo = NoteButton.ButtonViewInfo.Clone();
         ButtonsInfo.Add(viewInfo);
     }
 }
        private Brush GetGlyphBrush(ButtonViewInfo viewInfo)
        {
            Brush brush = Brushes.White;

            if (viewInfo.ButtonState == State.Hot)
            {
                brush = Brushes.Orange;
            }
            if (viewInfo.ButtonState == State.Pressed)
            {
                brush = Brushes.Green;
            }
            return(brush);
        }
        private Brush GetButtonBrush(ButtonViewInfo viewInfo)
        {
            Brush brush = Brushes.Indigo;

            if (viewInfo.ButtonState == State.Hot)
            {
                brush = Brushes.Blue;
            }
            if (viewInfo.ButtonState == State.Pressed)
            {
                brush = Brushes.White;
            }
            return(brush);
        }
        private Pen GetBorderPen(ButtonViewInfo viewInfo)
        {
            Pen pen = Pens.White;

            if (viewInfo.ButtonState == State.Hot)
            {
                pen = Pens.Orange;
            }
            if (viewInfo.ButtonState == State.Pressed)
            {
                pen = Pens.Green;
            }
            return(pen);
        }
 private void InvalidateButtons(ButtonViewInfo buttonViewInfo)
 {
     if (buttonViewInfo.Owner.Kind == ButtonKind.HeaderAdd)
     {
         Invalidate(ViewInfo.HeaderBounds);
     }
     else
     {
         int index = ReminderListBox.ButtonsInfo.IndexOf(buttonViewInfo);
         if (index == -1)
         {
             return;
         }
         Rectangle itemRect = ReminderListBox.GetItemRectangle(index);
         ReminderListBox.Invalidate(itemRect);
     }
 }
Example #11
0
        protected virtual void DrawNoteButton(DrawItemEventArgs e, ReminderControl reminderControl)
        {
            Button          noteButton = reminderControl.NoteButton;
            ReminderListBox listBox    = reminderControl.ReminderListBox;

            if (e.Index < listBox.ButtonsInfo.Count)
            {
                ButtonViewInfo buttonViewInfo = listBox.ButtonsInfo[e.Index];
                Rectangle      buttonRect     = buttonViewInfo.Bounds;
                Rectangle      textRect       = buttonViewInfo.TextBounds;

                buttonViewInfo.OffsetBounds(e.Bounds.Location, buttonViewInfo, buttonRect, textRect);

                noteButton.ButtonPainter.Draw(e.Graphics, buttonViewInfo);

                buttonViewInfo.RestoreBounds(e.Bounds.Location, buttonViewInfo, buttonRect, textRect);
            }
        }
 private void UpdateButton(ReminderHitInfo hitInfo, State state)
 {
     if (hitInfo.HitInfoType == HitInfoType.HeaderAddButton)
     {
         HeaderButton.ButtonViewInfo.ButtonState = state;
         HotTrackButtonInfo = HeaderButton.ButtonViewInfo;
     }
     else if (hitInfo.HitInfoType == HitInfoType.HeaderBackButton)
     {
         BackButton.ButtonViewInfo.ButtonState = state;
         HotTrackButtonInfo = BackButton.ButtonViewInfo;
     }
     else if (hitInfo.HitInfoType == HitInfoType.NoteButton)
     {
         ButtonViewInfo buttonViewInfo = ReminderListBox.ButtonsInfo[hitInfo.NoteIndex];
         buttonViewInfo.ButtonState = state;
         HotTrackButtonInfo         = buttonViewInfo;
     }
     else
     {
         HotTrackButtonInfo = null;
     }
 }
Example #13
0
 protected internal void CalcViewInfo(Graphics graphics, Rectangle headerTextBounds)
 {
     ButtonViewInfo.CalcViewInfo(graphics, headerTextBounds);
 }
        protected virtual void DrawGlyph(System.Drawing.Graphics graphics, ButtonViewInfo viewInfo)
        {
            Brush brush = GetGlyphBrush(viewInfo);

            graphics.DrawString(viewInfo.Owner.Text, viewInfo.DefaultFont, brush, viewInfo.TextBounds);
        }
        protected virtual void DrawButton(System.Drawing.Graphics graphics, ButtonViewInfo viewInfo)
        {
            Brush brush = GetButtonBrush(viewInfo);

            graphics.FillRectangle(brush, viewInfo.Bounds);
        }
 public virtual void Draw(System.Drawing.Graphics graphics, ButtonViewInfo viewInfo)
 {
     DrawButton(graphics, viewInfo);
     DrawGlyph(graphics, viewInfo);
     DrawBorder(graphics, viewInfo);
 }