예제 #1
0
파일: frmSAWItem.cs 프로젝트: stuart2w/SAW
 private void SetPreviewState(ButtonShape.States state)
 {
     foreach (Scriptable s in m_Scriptables)
     {
         s.State = state;
         s.NotifyIndirectChange(s, ChangeAffects.RepaintNeeded);
     }
 }
예제 #2
0
        public void lnkCopy9_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e)
        {
            // updates the other button states, where there are images of exactly the same size
            ButtonShape.States current = State;
            Size sz = Img.Sizes[m_ImageIndex];             // size of the currently selected image

            for (int change = 0; change <= 2; change++)
            {
                if (change != (int)current)
                {
                    ScalableImage scalable = m_Style.CustomImage[change];
                    for (int index = 0; index <= scalable.Sizes.Count - 1; index++)
                    {
                        if (scalable.Sizes[index].Equals(sz))
                        {
                            scalable.Slices[index] = Img.Slices[m_ImageIndex];
                        }
                    }
                }
            }
        }
예제 #3
0
파일: RunView.cs 프로젝트: stuart2w/SAW
 /// <summary>Changes the highlight state of the item.  Doesn't need to be the current one</summary>
 public void SetItemState(Scriptable item, ButtonShape.States state)
 {
     //Debug.WriteLine("SetItemState " + item.Description + " = " + state);
     item.State = state;
     m_Page.NotifyIndirectChange(item, ChangeAffects.RepaintNeeded, item.RefreshBounds());
 }
예제 #4
0
        protected void DrawInternalBackground(PaintEventArgs e, bool actionStyle)
        {
            // should be called as the first statement in OnPaint, or any overridden version of it
            ButtonShape.States state = ButtonShape.States.Normal;
            if (this.DesignMode && GUIUtilities.SystemDPI <= 1)
            {
                GUIUtilities.SystemDPI         = 96;
                GUIUtilities.SystemDPIRelative = 1;                 // NetCanvas requires these, but they are usually set during frmMenu_Load
            }
            using (Shape.DrawResources resources = new Shape.DrawResources(1, 255, 255, false, false, new NetCanvas(e.Graphics), StaticView.InvalidationBuffer.Base, 1))
            {
                if (!Enabled)
                {
                    state = ButtonShape.States.Disabled;
                }
                else if (m_SelectionDisplayFraction == 255 && m_Applicable && Enabled)
                {
                    state = ButtonShape.States.Selected;
                }
                else if (m_Hover || Focused)
                {
                    state = ButtonShape.States.Highlight;
                }
                else if (m_NoUser)
                {
                    resources.FillAlpha = 90;                     // Need to fade quite a lot, because it is only the background which fades.  Even 100 wasnt visible
                    resources.EdgeAlpha = 90;
                }
                ButtonStyle style;
                if (this.DesignMode)
                {
                    style = ButtonStyle.UserDefaultSelectionInstance;
                }
                else
                {
                    style = Config.UserUser.ButtonStyle[actionStyle ? 0 : 1];
                }
                style.PrepareResources(state, resources);
                RectangleF border     = new RectangleF(0, 0, Width, Height);
                var        styleState = state == ButtonShape.States.Disabled ? ButtonShape.States.Normal : state;          // The index for the actual style object used (there isn't one for disabled)
                // For the default backgrounds (only) it is also necessary to scale the graphics to work in (approximately) mm
                if (style.ImageType == ButtonStyle.ImageTypes.None)
                {
                    float scale = e.Graphics.DpiX / Geometry.INCH;
                    border.Width  = (border.Width - 1) / scale;                    // -1 because the graphics need the rectangle to be within the bounds for DrawRectangle
                    border.Height = (border.Height - 1) / scale;
                    // The standard border draws exactly ALONG the rectangle; we need to draw inside!
                    border.Inflate(-style.LineStyle[(int)styleState].Width / 2 - 1, -style.LineStyle[(int)styleState].Width / 2 - 1);
                    e.Graphics.ScaleTransform(scale, scale);
                }
                using (NetCanvas canvas = new NetCanvas(e.Graphics))
                {
                    style.Draw(canvas, resources, border, state);
                    if (m_SelectionDisplayFraction > 0 && m_SelectionDisplayFraction < 255 && m_Applicable && Enabled)
                    {
                        // fading in the selection colour
                        resources.FillAlpha = m_SelectionDisplayFraction;
                        resources.EdgeAlpha = m_SelectionDisplayFraction;
                        style.Draw(canvas, resources, border, ButtonShape.States.Selected);
                    }
                }

                e.Graphics.ResetTransform();
            }
        }
예제 #5
0
 public Preview(SAW.Item.ItemDisplayTypes style, ButtonShape.States state)
 {
     Style = style;
     State = state;
 }