private void ScrollTo(int index) { MenuBtnUpdate(index); scroller.SetDestY(index); scroller.scrollMode = ScrollMode.Auto; Renderer.AddRenderQueue(scroller); }
public static Layer AddLayer() { if (Count < MaxCount) { Layer layer = new Layer(); layer.IndexY = LayerManager.Count; layer.mainText.Text = defaultText; layerList.Add(layer); if (LayerResize()) { RenderAllLayers(); } else { Renderer.AddRenderQueue(layer); } Renderer.AddRenderQueue(MainForm.instance.mainUI); if (Count == MaxCount) { MainForm.instance.addBtn.Image = Resources.Root_PlusBtn_disabled; } return(layer); } else { //토스트메세지 띄우기 return(null); } }
//전체 렌더 public static void RenderAllLayers() { for (int i = 0; i < layerList.Count; i++) { Renderer.AddRenderQueue(layerList[i]); } }
public static void FocusLayer(Layer layer) { LayerManager.focusedLayer = layer; Renderer.AddRenderQueue(layer); layer.Render(); layer.mainText.UpdateWidth(); }
private void ScrollAreaPos(int scrollbarPosY) { scroller.scrollMode = ScrollMode.Manual; int posY = (int)((float)-scrollbarPosY / (contentArea.Height - scrollBar.Height) * (scrollArea.Height - contentArea.Height)); scroller.posY = scroller.destY = Math.Min(0, Math.Max(posY, -scrollArea.Height + contentArea.Height)); ScrollbarPos(); Renderer.AddRenderQueue(scroller); }
public static void UnFocusLayer() { if (LayerManager.focusedLayer != null) { Layer layer = LayerManager.focusedLayer; LayerManager.focusedLayer = null; Renderer.AddRenderQueue(layer); layer.Render(); layer.UpdateFont(); } }
public static void ClearLayer() { for (int i = 0; i < layerList.Count; i++) { layerList[i].group.Parent.Controls.Remove(layerList[i].group); layerList[i].group.Dispose(); } layerList.Clear(); LayerResize(); Renderer.AddRenderQueue(MainForm.instance.mainUI); }
private void Initialize() { instance = this; FontManager.Initialize(); SaveManager.Initialize(); SaveManager.Option.Load(); UpdateCheck.StartCheck(); mainUI = new MainUI(); trashArea = new TrashArea(); TrashArea.instance = trashArea; layerNamer = new LayerNamer(); Controls.Add(layerNamer); layerNamer.BringToFront(); dragEffector = new DragEffector(); dragEffector.Visible = false; Controls.Add(dragEffector); dragEffector.BringToFront(); detailPanel = new DetailPanel(); detailPanel.Show(this); detailPanel.Hide(); bool loadSuccess = true; if (!SaveManager.Data.Load(SaveManager.saveDataInfo)) { if (!SaveManager.Data.Load(SaveManager.saveDataBackupInfo)) { loadSuccess = false; } } if (!loadSuccess | LayerManager.Count == 0) { //초기화 LayerManager.ClearLayer(); LayerManager.AddLayer(); LayerManager.AddLayer(); } layerNamer.UpdateFont(); Renderer.AddRenderQueue(mainUI); tickUpdater.Start(); mouseUpdater.Start(); if (!SaveManager.optionInfo.Exists) { ShowTutorial(); } }
private void OnMouseClick(object sender, MouseEventArgs e) { if (e.Button == MouseButtons.Right) { memoText.Select(memoText.Text.Length, 0); showMemo = !showMemo; if (showMemo) { memoText.Visible = true; } Renderer.AddRenderQueue(this); } }
public static void RemoveLayer(Layer layer) { if (layerList.Contains(layer)) { if (Count == MaxCount) { MainForm.instance.addBtn.Image = Resources.Root_PlusBtn; } layerList.Remove(layer); layer.group.Parent.Controls.Remove(layer.group); LayerResize(); Sort(); RenderAllLayersDirect(); Renderer.AddRenderQueue(MainForm.instance.mainUI); } }
private void OnMouseUp(object sender, MouseEventArgs e) { if (e == null || e.Button == MouseButtons.Left) { mainPanel.BackColor = bgColor; TrashArea.instance.Hide(); TrashArea.instance.Close(); if (isPanelDragging) { if (MainForm.instance.trashPanel.OnMouse()) { OnDestroy(); LayerManager.RemoveLayer(this); } Renderer.AddRenderQueue(MainForm.instance.trashArea); } isPanelPressed = isPanelDragging = false; } }
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(); }