Esempio n. 1
0
        private void CreateControls()
        {
            SuspendLayout();

            #region 패널
            //분리선
            separator           = new Panel();
            separator.Location  = new Point(139, 12);
            separator.Size      = new Size(1, 352);
            separator.BackColor = Color.FromArgb(202, 202, 202);
            separator.Enabled   = false;

            //컨텐츠영역
            contentArea           = new Panel();
            contentArea.Location  = new Point(18, 21);
            contentArea.Size      = new Size(636, 343);
            contentArea.BackColor = Color.White;

            //닫기버튼
            closeBtn          = new PictureBox();
            closeBtn.Cursor   = Cursors.Hand;
            closeBtn.SizeMode = PictureBoxSizeMode.AutoSize;
            closeBtn.Image    = Resources.Option_CloseBtn;
            closeBtn.Location = new Point(30, 364);
            closeBtn.SetMouseEvent(Color.White, Color.White.Lighting(-10), Color.White.Lighting(-20));
            closeBtn.Click += (object sender, EventArgs e) => {
                Close();
            };

            //버튼
            const int btnPadding = 10;
            const int btnHeight  = 31;
            buttons    = new MenuButton[3];
            buttons[0] = new MenuButton(Resources.Option_SystemBtn_on, Resources.Option_SystemBtn_off);
            buttons[1] = new MenuButton(Resources.Option_DisplayBtn_on, Resources.Option_DisplayBtn_off);
            buttons[2] = new MenuButton(Resources.Option_DataBtn_on, Resources.Option_DataBtn_off);
            for (int i = 0; i < buttons.Length; i++)
            {
                buttons[i].Cursor   = Cursors.Hand;
                buttons[i].Location = new Point(5, (btnHeight + btnPadding) * i);
                contentArea.Controls.Add(buttons[i]);

                int index = i;
                buttons[i].Click += (object sender, EventArgs e) => {
                    ScrollTo(index);
                };
            }

            //스크롤바
            scrollBar          = new PictureBox();
            scrollBar.SizeMode = PictureBoxSizeMode.AutoSize;
            scrollBar.Image    = Resources.Option_ScrollBar;
            scrollBar.Location = new Point(642 - contentArea.Location.X, 27);

            //패널
            const int itemPadding = 10;
            scrollArea          = new Panel();
            scrollArea.Location = new Point(125, 0);

            panels    = new ScrollItem[3];
            panels[0] = new ScrollItem(Resources.Option_SystemPanel);
            panels[1] = new ScrollItem(Resources.Option_DisplayPanel);
            panels[2] = new ScrollItem(Resources.Option_DataPanel);
            for (int i = 0; i < buttons.Length; i++)
            {
                panels[i].SizeMode = PictureBoxSizeMode.AutoSize;
                panels[i].Location = new Point(0, heightStack);
                heightStack       += panels[i].Height + itemPadding;
                scrollArea.Controls.Add(panels[i]);
            }
            scrollArea.Size = new Size(500, heightStack + contentArea.Height - panels.Last().Height - itemPadding);

            //마우스 휠 이벤트
            scrollArea.MouseWheel += (object sender, MouseEventArgs e) => {
                scroller.scrollMode = ScrollMode.Manual;
                scroller.speedY    += e.Delta / 120 * 15;
                Renderer.AddRenderQueue(scroller);
            };
            #endregion

            //시스템
            startProcessCheckbox          = new CheckBox();
            startProcessCheckbox.Location = new Point(27, 105);
            topMostCheckbox          = new CheckBox();
            topMostCheckbox.Location = new Point(27, 133);

            panels[0].Controls.Add(startProcessCheckbox);
            panels[0].Controls.Add(topMostCheckbox);

            startProcessCheckbox.OnSelected += (bool isChecked) => {
                Option.System.startProcess = isChecked;
                Option.OnOptionChanged();
            };
            topMostCheckbox.OnSelected += (bool isChecked) => {
                Option.System.topMost = isChecked;
                Option.OnOptionChanged();
            };
            //알림
            alertCheckbox               = new CheckBox();
            alertCheckbox.Location      = new Point(27, 222);
            alertSoundCheckbox          = new CheckBox();
            alertSoundCheckbox.Location = new Point(27, 247);
            alert_comCheckbox           = new CheckBox();
            alert_comCheckbox.Location  = new Point(27, 296);
            alert_1hCheckbox            = new CheckBox();
            alert_1hCheckbox.Location   = new Point(213, 296);
            alert_1dCheckbox            = new CheckBox();
            alert_1dCheckbox.Location   = new Point(425, 296);
            panels[0].Controls.Add(alertCheckbox);
            panels[0].Controls.Add(alertSoundCheckbox);
            panels[0].Controls.Add(alert_comCheckbox);
            panels[0].Controls.Add(alert_1hCheckbox);
            panels[0].Controls.Add(alert_1dCheckbox);

            alertCheckbox.OnSelected += (bool isChecked) => {
                Option.System.alert = isChecked;
                Option.OnOptionChanged();
            };
            alertSoundCheckbox.OnSelected += (bool isChecked) => {
                Option.System.alertSound = isChecked;
                Option.OnOptionChanged();
            };
            alert_comCheckbox.OnSelected += (bool isChecked) => {
                Option.System.alert_com = isChecked;
                Option.OnOptionChanged();
            };
            alert_1hCheckbox.OnSelected += (bool isChecked) => {
                Option.System.alert_1h = isChecked;
                Option.OnOptionChanged();
            };
            alert_1dCheckbox.OnSelected += (bool isChecked) => {
                Option.System.alert_1d = isChecked;
                Option.OnOptionChanged();
            };



            //화면
            //투명도
            const int opacityBarY = 101;
            opacityBar          = new DragBar(180);
            opacityBar.Location = new Point(26, opacityBarY);
            panels[1].Controls.Add(opacityBar);

            //폰트
            const int fontSelectorY = 181;
            fontSelector = new RadioBtnSet(2);
            fontSelector.radioBtn[0].Location = new Point(26, fontSelectorY);
            fontSelector.radioBtn[1].Location = new Point(26, fontSelectorY + 28);
            fontSelector.AddControl(panels[1]);
            fontInspector          = new Button();
            fontInspector.Location = new Point(127, fontSelectorY + 26);
            panels[1].Controls.Add(fontInspector);

            //폰트크기
            const int fontSizeY = 277;
            fontSizeSelector = new RadioBtnSet(3);
            fontSizeSelector.radioBtn[0].Location = new Point(28, fontSizeY);
            fontSizeSelector.radioBtn[1].Location = new Point(188, fontSizeY);
            fontSizeSelector.radioBtn[2].Location = new Point(352, fontSizeY);
            fontSizeSelector.AddControl(panels[1]);

            //최소길이
            const int widthOffset = 372;
            widthOffsetSelector = new RadioBtnSet(3);
            widthOffsetSelector.radioBtn[0].Location = new Point(28, widthOffset);
            widthOffsetSelector.radioBtn[1].Location = new Point(188, widthOffset);
            widthOffsetSelector.radioBtn[2].Location = new Point(352, widthOffset);
            widthOffsetSelector.AddControl(panels[1]);

            //날자타입
            const int dateTypeY = 505;
            dateTypeSelector = new RadioBtnSet(3);
            dateTypeSelector.radioBtn[0].Location = new Point(28, dateTypeY);
            dateTypeSelector.radioBtn[1].Location = new Point(188, dateTypeY);
            dateTypeSelector.radioBtn[2].Location = new Point(352, dateTypeY);
            dateTypeSelector.AddControl(panels[1]);

            //애니스피드
            const int animSpeedY = 665;
            animSpeedSelector = new RadioBtnSet(3);
            animSpeedSelector.radioBtn[0].Location = new Point(28, animSpeedY);
            animSpeedSelector.radioBtn[1].Location = new Point(188, animSpeedY);
            animSpeedSelector.radioBtn[2].Location = new Point(352, animSpeedY);
            animSpeedSelector.AddControl(panels[1]);


            //이벤트
            bool isScrollbarPressed = false;
            int  scrollbarPressedPos = 0, scrollbarOriginPos = 0;
            scrollBar.MouseDown += (object sender, MouseEventArgs e) => {
                if (e.Button == MouseButtons.Left)
                {
                    isScrollbarPressed  = true;
                    scrollbarPressedPos = Cursor.Position.Y;
                    scrollbarOriginPos  = scrollBar.Location.Y;
                }
            };
            scrollBar.MouseMove += (object sender, MouseEventArgs e) => {
                if (isScrollbarPressed)
                {
                    ScrollAreaPos(scrollbarOriginPos + Cursor.Position.Y - scrollbarPressedPos);
                }
            };
            scrollBar.MouseUp += (object sender, MouseEventArgs e) => {
                if (e.Button == MouseButtons.Left)
                {
                    isScrollbarPressed = false;
                }
            };

            //화면
            opacityBar.OnDrag += (int percent) => {
                Option.Display.opacity = percent;
                Option.OnOptionChanged();
            };
            RadioBtnSet.IndexHandler fontSelectEvent = (int index) => {
                switch (index)
                {
                case 0:
                    Option.Display.fontValue = index;
                    break;

                case 1:
                    Option.Display.fontValue = index;
                    Option.Display.font      = fontInspector.textArea.Font = this.fontDialog.Font;
                    break;
                }
                Option.OnOptionChanged();
            };
            fontSelector.OnSelected += fontSelectEvent;
            fontInspector.Click     += (object sender, EventArgs e) => {
                DialogResult result = this.fontDialog.ShowDialog();
                if (result == DialogResult.OK)
                {
                    Option.Display.fontValue    = 1;
                    Option.Display.font         = fontInspector.textArea.Font = this.fontDialog.Font;
                    fontInspector.textArea.Text = this.fontDialog.Font.FontFamily.Name;
                    Option.OnOptionChanged();

                    fontSelector.SelectWithoutEvent(1);
                }
            };
            fontSizeSelector.OnSelected += (int index) => {
                Option.Display.fontSize = index;
                Option.OnOptionChanged();
            };
            widthOffsetSelector.OnSelected += (int index) => {
                Option.Display.widthOffset = index;
                Option.OnOptionChanged();
            };
            dateTypeSelector.OnSelected += (int index) => {
                Option.Display.dateType = index;
                Option.OnOptionChanged();
            };
            animSpeedSelector.OnSelected += (int index) => {
                Option.Display.animSpeed = index;
                Option.OnOptionChanged();
            };

            //데이터
            saveBtn          = new Button("일정 저장");
            saveBtn.Location = new Point(29, 101);
            loadBtn          = new Button("일정 불러오기");
            loadBtn.Location = new Point(29, 137);
            panels[2].Controls.Add(saveBtn);
            panels[2].Controls.Add(loadBtn);

            saveBtn.OnClick += () => {
                DialogResult result = dataSaveDialog.ShowDialog();
                if (result == DialogResult.OK)
                {
                    SaveManager.Data.Save(new FileInfo(dataSaveDialog.FileName));
                }
            };
            loadBtn.OnClick += () => {
                DialogResult result = dataLoadDialog.ShowDialog();
                if (result == DialogResult.OK)
                {
                    LayerManager.ClearLayer();
                    SaveManager.Data.Load(new FileInfo(dataLoadDialog.FileName));
                }
            };


            Controls.Add(closeBtn);
            Controls.Add(separator);
            Controls.Add(contentArea);
            contentArea.Controls.Add(scrollArea);
            contentArea.Controls.Add(scrollBar);

            contentArea.BringToFront();
            separator.BringToFront();
            closeBtn.BringToFront();
            scrollBar.BringToFront();



            mainPanel.SetDragable(this);
            contentArea.SetDragable(this);
            scrollArea.SetDragable(this);
            for (int i = 0; i < panels.Length; i++)
            {
                panels[i].SetDragable(this);
            }

            ResumeLayout();

            LoadOption();
        }
        public TimelineHitObjectBlueprint(HitObject hitObject)
            : base(hitObject)
        {
            Anchor = Anchor.CentreLeft;
            Origin = Anchor.CentreLeft;

            startTime = hitObject.StartTimeBindable.GetBoundCopy();
            startTime.BindValueChanged(time => X = (float)time.NewValue, true);

            RelativePositionAxes = Axes.X;

            RelativeSizeAxes = Axes.X;
            AutoSizeAxes     = Axes.Y;

            AddRangeInternal(new Drawable[]
            {
                mainComponents = new Container
                {
                    Anchor           = Anchor.CentreLeft,
                    Origin           = Anchor.CentreLeft,
                    RelativeSizeAxes = Axes.X,
                    AutoSizeAxes     = Axes.Y,
                },
                comboIndexText = new OsuSpriteText
                {
                    Anchor = Anchor.CentreLeft,
                    Origin = Anchor.Centre,
                    Font   = OsuFont.Numeric.With(size: circle_size / 2, weight: FontWeight.Black),
                },
            });

            circle = new Circle
            {
                Size       = new Vector2(circle_size),
                Anchor     = Anchor.CentreLeft,
                Origin     = Anchor.Centre,
                EdgeEffect = new EdgeEffectParameters
                {
                    Type   = EdgeEffectType.Shadow,
                    Radius = shadow_radius,
                    Colour = Color4.Black
                },
            };

            shadowComponents.Add(circle);

            if (hitObject is IHasDuration)
            {
                DragBar   dragBarUnderlay;
                Container extensionBar;

                mainComponents.AddRange(new Drawable[]
                {
                    extensionBar = new Container
                    {
                        Masking = true,
                        Size    = new Vector2(1, thickness),
                        Anchor  = Anchor.CentreLeft,
                        Origin  = Anchor.CentreLeft,
                        RelativePositionAxes = Axes.X,
                        RelativeSizeAxes     = Axes.X,
                        EdgeEffect           = new EdgeEffectParameters
                        {
                            Type   = EdgeEffectType.Shadow,
                            Radius = shadow_radius,
                            Colour = Color4.Black
                        },
                        Child = new Box
                        {
                            RelativeSizeAxes = Axes.Both,
                        }
                    },
                    circle,
                    // only used for drawing the shadow
                    dragBarUnderlay = new DragBar(null),
                    // cover up the shadow on the join
                    new Box
                    {
                        Height           = thickness,
                        Anchor           = Anchor.CentreLeft,
                        Origin           = Anchor.CentreLeft,
                        RelativeSizeAxes = Axes.X,
                    },
                    dragBar = new DragBar(hitObject)
                    {
                        OnDragHandled = e => OnDragHandled?.Invoke(e)
                    },
                });

                shadowComponents.Add(dragBarUnderlay);
                shadowComponents.Add(extensionBar);
            }
            else
            {
                mainComponents.Add(circle);
            }

            updateShadows();
        }
        private void OnGuiHandleBarDragging(float screenWidth, float screenHeight)
        {
            if (Event.current.type == EventType.MouseUp)
            {
                mDragging = DragBar.NONE;
            }
            if (Event.current.type == EventType.MouseDown)
            {
                mDragging = DragBar.NONE;
                for (DragBar i = DragBar.Center; i < DragBar.NONE && mDragging == DragBar.NONE; ++i)
                {
                    Vector2 slop = new Vector2(5f, 5f);
                    if (i == DragBar.Center)
                    {
                        if (mDragBars[(int)i].width > 3f * slop.x)
                        {
                            slop.x = -slop.x;
                        }
                        if (mDragBars[(int)i].height > 3f * slop.y)
                        {
                            slop.y = -slop.y;
                        }
                    }
                    Rect r = mDragBars[(int)i].Inflated(slop);
                    if (r.Contains(Event.current.mousePosition))
                    {
                        mDragging = i;
                    }
                }
            }

            if (mDragging != DragBar.NONE && Event.current.type == EventType.MouseDrag)
            {
                Vector2 d = new Vector2(
                    Event.current.delta.x / screenWidth,
                    Event.current.delta.y / screenHeight);

                // First snapshot some settings
                Rect    newHard = GetHardGuide();
                Rect    newSoft = GetSoftGuide();
                Vector2 changed = Vector2.zero;
                switch (mDragging)
                {
                case DragBar.Center: newSoft.position += d; break;

                case DragBar.SoftBarLineLeft: newSoft = newSoft.Inflated(new Vector2(-d.x, 0)); break;

                case DragBar.SoftBarLineRight: newSoft = newSoft.Inflated(new Vector2(d.x, 0)); break;

                case DragBar.SoftBarLineTop: newSoft = newSoft.Inflated(new Vector2(0, -d.y)); break;

                case DragBar.SoftBarLineBottom: newSoft = newSoft.Inflated(new Vector2(0, d.y)); break;

                case DragBar.HardBarLineLeft: newHard = newHard.Inflated(new Vector2(-d.x, 0)); break;

                case DragBar.HardBarLineRight: newHard = newHard.Inflated(new Vector2(d.x, 0)); break;

                case DragBar.HardBarLineBottom: newHard = newHard.Inflated(new Vector2(0, d.y)); break;

                case DragBar.HardBarLineTop: newHard = newHard.Inflated(new Vector2(0, -d.y)); break;
                }

                // Apply the changes, enforcing the bounds
                SetNewBounds(GetHardGuide(), GetSoftGuide(), newHard, newSoft);
                UnityEditorInternal.InternalEditorUtility.RepaintAllViews();
            }
        }