示例#1
0
    // OnMouseUp is new position of slider.
    protected override void OnMouseUp(MouseEventArgs args)
    {
        if (rsDragging != null)
        {
            // Calculate new Value properties and trigger the event.
            if (rsDragging == rsLeftIndent || rsDragging == rsFirstIndent)
            {
                rsLeftIndent.Value  = PixelsToInches(rsLeftIndent.X - LeftMargin);
                rsFirstIndent.Value =
                    PixelsToInches(rsFirstIndent.X - rsLeftIndent.X);
                OnChange(new RulerEventArgs(rsDragging.RulerProperty));
            }
            else if (rsDragging == rsRightIndent || rsDragging == rsTextWidth)
            {
                rsTextWidth.Value   = PixelsToInches(rsTextWidth.X - LeftMargin);
                rsRightIndent.Value =
                    PixelsToInches(rsTextWidth.X - rsRightIndent.X);
                OnChange(new RulerEventArgs(rsTextWidth.RulerProperty));
                OnChange(new RulerEventArgs(rsRightIndent.RulerProperty));
            }

            else if (rsDragging is Tab)
            {
                rsDragging.Value = PixelsToInches(rsDragging.X - LeftMargin);
                OnChange(new RulerEventArgs(rsDragging.RulerProperty));
            }
            // Cease drag operation.
            rsDragging = null;
            DrawReversibleLine(xLineOverTextBox);
        }
    }
示例#2
0
 void CalculateDisplayOffsets2(RulerSlider rs, int xNew)
 {
     if (rs.X != xNew)
     {
         Invalidate(rs.Rectangle);
         rs.X = xNew;
         Invalidate(rs.Rectangle);
     }
 }
示例#3
0
    // OnMouseDown for moving sliders and creating tabs.
    protected override void OnMouseDown(MouseEventArgs args)
    {
        // Ignore if it's not the left button.
        if ((args.Button & MouseButtons.Left) == 0)
        {
            return;
        }

        // Loop through existing sliders looking for positive hit test.
        foreach (RulerSlider rs in rsCollection)
        {
            if (rs.HitTest(args.Location))
            {
                rsDragging = rs;
                ptDown     = args.Location;
                xOriginal  = rsDragging.X;

                if (rsDragging is TextWidth)
                {
                    Cursor.Current = Cursors.SizeWE;
                }

                DrawReversibleLine(xLineOverTextBox = args.X);
                return;
            }
        }
        // If no hit, create a new tab.
        rsDragging = new Tab();
        rsCollection.Add(rsDragging);
        ptDown    = args.Location;
        xOriginal = rsDragging.X = ptDown.X;

        Invalidate(rsDragging.Rectangle);
        DrawReversibleLine(xLineOverTextBox = args.X);
        return;
    }