Inheritance: MonoBehaviour
示例#1
0
        public void OfType_Doesnt_Match_Control_Of_Wrong_Type()
        {
            var control = new Control2();
            var target = new Selector().OfType<Control1>();

            Assert.False(target.Match(control).ImmediateResult);
        }
示例#2
0
 public override XPoint AddToPath(XGraphicsPath path, XPoint cursor, Base lastPathCommand = null)
 {
     path.AddBezier(cursor, Control1.ToXPoint(), Control2.ToXPoint(), End.ToXPoint());
     return(End.ToXPoint());
 }
        // fillWt specifies that the control should be vertically expanded if there is extra
        // height available. There are two different modes:
        // 1) The last opened content that has fillWt > 0 will receive any extra height.
        //    All other opened contents appear at their preferred size.
        // 2) The extra height is distributed between open contents that have fillWt > 0
        //    and are not locked by the user. The fillWt divided by the sum of open-unlocked
        //    fillWts determines the exact distribution.
        public void Add(Control c, String text, String toolTip = null, double fillWt = 0, bool expand = false)
        {
            String da = GetDownArrow();
            String ua = GetUpArrow();

            // AutoSize must be true or the text will wrap under and be hidden
            var cb = new CheckBox {
                Appearance = Appearance.Button, Text = da + text, AutoSize = true
            };

            cb.Anchor = AnchorStyles.Left | AnchorStyles.Right; // cb.Dock = DockStyle.Fill also works.
            cb.Margin = new Padding(0);                         // otherwise there are gaps between the buttons

            var c2 = new Control2(cb, c, fillWt)
            {
                Dock = DockStyle.Fill
            };

            if (ContentPadding.HasValue)
            {
                c2.Padding = ContentPadding.Value;
            }

            if (!String.IsNullOrEmpty(toolTip))
            {
                tips.SetToolTip(cb, toolTip);
            }

            host.Controls.Add(cb);
            host.Controls.Add(c2);

            cb.MouseHover += delegate {
                if (ShowToolMenu && cb.Checked && c2.fillWt > 0 && !toolBox.Visible)
                {
                    var p1 = cb.PointToClient(Control.MousePosition);
                    if (p1.X >= cb.Width - toolBox.Width)
                    {
                        Point p = new Point {
                            X = cb.Width - toolBox.Width, Y = cb.Height
                        };
                        toolBox.Current = c2;
                        toolBox.Show(cb, p);
                    }
                }
            };

            cb.MouseUp += (o, e) => {
                if (ShowToolMenu && cb.Checked && c2.fillWt > 0 && e.Button == MouseButtons.Right)
                {
                    var p1 = cb.PointToClient(Control.MousePosition);
                    int w  = toolBox.Width;
                    p1.X           -= w / 2;
                    p1.Y           -= w / 2;
                    toolBox.Current = c2;
                    toolBox.Show(cb, p1);
                }
            };

            DateTime leaveTime;

            toolBox.MouseLeave += delegate {
                // the tooltip of a menu item causes a mouse leave, so
                // confirm the mouse is outside of the bounds before hiding
                leaveTime = DateTime.Now;
                new System.Threading.Thread((o) => {
                    // allow the mouse to leave for up to 1 second before closing
                    System.Threading.Thread.Sleep(1000);
                    if ((DateTime)o != leaveTime)
                    {
                        return;
                    }

                    toolBox.BeginInvoke((Action) delegate {
                        if (!toolBox.Bounds.Contains(Control.MousePosition))
                        {
                            toolBox.Hide();
                        }
                    });
                }).Start(leaveTime);
            };

            cb.MouseLeave += delegate {
                if (toolBox.Visible)
                {
                    // since toolBox has no parent, its bounds are in screen coordinates
                    if (!toolBox.Bounds.Contains(Control.MousePosition))
                    {
                        toolBox.Hide();
                    }
                }
            };

            cb.CheckedChanged += delegate {
                String a = (cb.Checked ? GetUpArrow() : GetDownArrow());
                cb.Text = a + text;         // must set text regardless of isAdjusting

                if (cb.Checked)
                {
                    c2.lastClicked = DateTime.Now;
                }

                if (isAdjusting)
                {
                    return;
                }

                // for some reason, when the scrollbar first appears, it scrolls an
                // amount equal to the ContentPadding.Left to the right. Also, the scroll
                // value resets to 0 right before the checkbox is changed, so it's not
                // easy to know what the previous value is.
                //int hsorig = 0;
                //if (host.HorizontalScroll.Visible)
                //	hsorig = host.HorizontalScroll.Value;

                if (OpenOneOnly)
                {
                    if (lastChecked != null && cb.Checked && c2 != lastChecked)
                    {
                        isAdjusting            = true;
                        lastChecked.cb.Checked = false;
                        isAdjusting            = false;
                    }
                }

                lastChecked = c2;
                host.UpdateDeltaHeights();
                host.AutoScroll = false;         // forces proper refresh
                host.AutoScroll = true;
                host.Invalidate(true);
                host.PerformLayout();
                GetFirstFocus(c).Focus();

                if (host.HorizontalScroll.Visible)
                {
                    // something causes the scrollbar to scroll to the right by an amount equal
                    // to the ContentPadding.Left value.
                    host.AutoScrollPosition = Point.Empty;
                }
            };

            // wait for all controls to be added before expanding if currently not visible
            if (expand)
            {
                if (this.Visible)
                {
                    cb.Checked = true;
                }
                else
                {
                    this.HandleCreated += delegate {
                        cb.Checked = true;
                    }
                };
            }
        }
            public void UpdateDeltaHeights(bool fillLastOpened, bool fillModeGrowOnly, bool fillResetOnCollapse)
            {
                Size r  = getPreferredSizeNoDH();
                Size cs = this.ClientSize;

                double totalWt = 0;
                int    mh      = 0; // minus height

                foreach (Control c in this.Controls)
                {
                    if (c is Control2)
                    {
                        Control2 c2 = (Control2)c;
                        if (c2.cb.Checked)
                        {
                            if (c2.isLocked)
                            {
                                mh += c2.dh;
                            }
                            else
                            {
                                totalWt += c2.fillWt;
                            }
                        }
                    }
                }

                int eh = Math.Max(0, (cs.Height - r.Height) - mh);

                if (fillLastOpened)
                {
                    Control2 fc = getFillControl();

                    foreach (Control c in this.Controls)
                    {
                        if (c is Control2)
                        {
                            Control2 c2 = (Control2)c;
                            if (c2.isLocked)                     // height is locked, do nothing
                            {
                                continue;
                            }

                            if (c2 == fc)
                            {
                                if (fillModeGrowOnly)
                                {
                                    if (eh > c2.dh)
                                    {
                                        c2.dh = eh;
                                    }
                                }
                                else
                                {
                                    c2.dh = eh;
                                }
                            }
                            else
                            {
                                if (fillResetOnCollapse)
                                {
                                    c2.dh = 0;
                                }
                            }
                        }
                    }
                }
                else
                {
                    double pixels = 0;             // pixel perfect
                    foreach (Control c in this.Controls)
                    {
                        if (c is Control2)
                        {
                            Control2 c2 = (Control2)c;
                            if (c2.isLocked)                     // height is locked, do nothing
                            {
                                continue;
                            }

                            // if totalWt is zero, that means no controls with a fillWt are currently open
                            // thus if fillResetOnCollapse is true, then their dh values should be reset to zero
                            if (c2.cb.Checked && totalWt > 0)
                            {
                                double ddh = c2.fillWt * eh / totalWt;
                                int    dh  = (int)ddh;
                                pixels += ddh % 1;
                                if (pixels >= 0.5)
                                {
                                    dh++;
                                    pixels--;
                                }
                                if (fillModeGrowOnly)
                                {
                                    if (dh > c2.dh)
                                    {
                                        c2.dh = dh;
                                    }
                                    else
                                    {
                                    }                                   // do nothing
                                }
                                else
                                {
                                    c2.dh = dh;
                                }
                            }
                            else
                            {
                                if (fillResetOnCollapse)
                                {
                                    c2.dh = 0;
                                }
                            }
                        }
                    }
                }
            }
示例#5
0
 private void CloseUI(GameObject UI, Control1 _control1, Control2 _control2)
 {
     UI.SetActive(false);
     control1 = _control1;
     control2 = _control2;
 }
示例#6
0
 private void OpenUI(GameObject UI, Control1 _control1, Control2 _control2)
 {
     UI.SetActive(true);
     control1 = _control1;
     control2 = _control2;
 }
示例#7
0
    private void S()
    {
        switch (control1)
        {
        case Control1.Camera:
            switch (DecorationRoomCamera.instance.viewMode)
            {
            case DecorationRoomCamera.ViewMode.lookDrone:
            case DecorationRoomCamera.ViewMode.lookCharacter:
                DecorationRoomCamera.instance.viewMode = DecorationRoomCamera.ViewMode.lookDefault;

                SoundEffect.instance.audioSource.PlayOneShot(highlight);

                UpdateControlGuide();         // 조작 가이드 업데이트
                return;

            case DecorationRoomCamera.ViewMode.lookDefault:
                switch (Recorder.instance.previousScene)
                {
                case "My Room":
                    LoadingManager.LoadScene("My Room", SceneManager.GetActiveScene().name);
                    break;

                default:
                    LoadingManager.LoadScene("IngameScene", SceneManager.GetActiveScene().name);
                    break;
                }

                SoundEffect.instance.audioSource.PlayOneShot(closeMenu);

                return;
            }
            return;

        case Control1.UI:
            switch (control2)
            {
            case Control2.Drone:
                if (inputDelay <= 0)
                {
                    CloseUI(droneDecortationUI, Control1.Camera); // 꾸미기 UI를 닫고 카메라를 조종 시작
                    DecorationRoomCamera.instance.viewMode = DecorationRoomCamera.ViewMode.lookDefault;
                    UpdateControlGuide();                         // 조작 가이드 업데이트

                    SoundEffect.instance.audioSource.PlayOneShot(closeMenu);
                }
                return;

            case Control2.Operator:
                if (inputDelay <= 0)
                {
                    control2 = Control2.Drone;
                    droneShop.GetComponent <Animator>().SetBool("reveal", true);
                    operatorShop.GetComponent <Animator>().SetBool("reveal", false);
                    UpdateScaleOfItem();         // 현재 선택 중인 아이템을 크게 표시해주는 함수
                    SetDelay(0.25f);
                    UpdateControlGuide();        // 조작 가이드 업데이트

                    SoundEffect.instance.audioSource.PlayOneShot(highlight);
                }
                return;
            }
            return;
        }
    }
示例#8
0
 private void SetStyle(Control2 control, MessageBoxTextParameters paramters)
 {
     control.Text = paramters.Text;
     if (paramters.Font != null) control.Font = paramters.Font;
     if (paramters.ForeColor.HasValue) control.ForeColor = paramters.ForeColor.Value;
     if (paramters.BackColor.HasValue) control.BackColor = paramters.BackColor.Value;
 }
示例#9
0
 private void Awake()
 {
     instance = this;
     Input.multiTouchEnabled = true;//开启多点触碰
 }
示例#10
0
            public void SetPoint(DotType type, Point pos)
            {
                if (type == DotType.Control1)
                {
                    Control1.SetValue(Canvas.LeftProperty, pos.X - HalfEllipseWidth);
                    Control1.SetValue(Canvas.TopProperty, pos.Y - HalfEllipseWidth);
                    BezierSegment.Point1 = pos;
                }
                else if (type == DotType.Control2)
                {
                    Control2.SetValue(Canvas.LeftProperty, pos.X - HalfEllipseWidth);
                    Control2.SetValue(Canvas.TopProperty, pos.Y - HalfEllipseWidth);
                    BezierSegment.Point2 = pos;
                }
                else if (type == DotType.Start)
                {
                    var hasPrev = Previous != null;
                    if (hasPrev)
                    {
                        if ((pos.X - HalfEllipseWidth) <= Previous.PathFigure.StartPoint.X)
                        {
                            return;
                        }
                    }

                    if ((pos.X - HalfEllipseWidth) >= BezierSegment.Point3.X)
                    {
                        return;
                    }

                    Start.SetValue(Canvas.LeftProperty, pos.X - HalfEllipseWidth);
                    Start.SetValue(Canvas.TopProperty, pos.Y - HalfEllipseWidth);
                    PathFigure.StartPoint = pos;
                    if (hasPrev)
                    {
                        Previous.BezierSegment.Point3 = pos;
                        Previous.End.SetValue(Canvas.LeftProperty, pos.X - HalfEllipseWidth);
                        Previous.End.SetValue(Canvas.TopProperty, pos.Y - HalfEllipseWidth);
                        Previous.SetLines();
                    }
                }
                else if (type == DotType.End)
                {
                    var hasNext = Next != null;
                    if (hasNext)
                    {
                        if ((pos.X - HalfEllipseWidth) >= Next.BezierSegment.Point3.X)
                        {
                            return;
                        }
                    }

                    if ((pos.X - HalfEllipseWidth) <= PathFigure.StartPoint.X)
                    {
                        return;
                    }

                    End.SetValue(Canvas.LeftProperty, pos.X - HalfEllipseWidth);
                    End.SetValue(Canvas.TopProperty, pos.Y - HalfEllipseWidth);
                    BezierSegment.Point3 = pos;

                    if (hasNext)
                    {
                        Next.PathFigure.StartPoint = pos;
                        Next.Start.SetValue(Canvas.LeftProperty, pos.X - HalfEllipseWidth);
                        Next.Start.SetValue(Canvas.TopProperty, pos.Y - HalfEllipseWidth);
                        Next.SetLines();
                    }
                }
                this.SetLines();
            }