예제 #1
0
            public static string ShowDialog(string text, string caption)
            {
                Form prompt = new DarkForm
                {
                    Width           = 400,
                    Height          = 150,
                    FormBorderStyle = FormBorderStyle.FixedToolWindow,
                    Text            = caption,
                    StartPosition   = FormStartPosition.CenterScreen
                };
                DarkLabel textLabel = new DarkLabel()
                {
                    Left = 50, Top = 15, Height = 50, Width = 300, Text = text
                };
                DarkTextBox textBox = new DarkTextBox()
                {
                    Left = 50, Top = 50, Width = 300
                };
                DarkButton confirmation = new DarkButton()
                {
                    Text = "Ok", Left = 250, Width = 100, Top = 80, DialogResult = DialogResult.OK
                };

                confirmation.Click += (sender, e) => { prompt.Close(); };
                prompt.Controls.Add(textBox);
                prompt.Controls.Add(confirmation);
                prompt.Controls.Add(textLabel);
                prompt.AcceptButton = confirmation;

                return(prompt.ShowDialog() == DialogResult.OK ? textBox.Text : "");
            }
예제 #2
0
        // We move from ProgramButton_MouseMove to this method if panel_Programs.Capture is true
        private void panel_Programs_MouseMove(object sender, MouseEventArgs e)
        {
            if ((e.Button != MouseButtons.Left) || (_draggedButton == null))
            {
                return;
            }

            // Check if we can swap the button

            DarkButton hoveredButton = GetHoveredButton();

            if (hoveredButton == null)
            {
                return;
            }

            if (hoveredButton == _draggedButton)
            {
                return;
            }

            SwapButtons(_draggedButton, hoveredButton);

            SavePinnedPrograms();
        }
예제 #3
0
        /// <summary>
        /// Initializes the main page
        /// </summary>
        public MainPage()
        {
            InitializeComponent();
            GuiController.GetController().assignMainPage(this);

            panelState = PanelState.Normal;

            addAlarmButton.Click   += AddEditButton_Click;
            AlarmList_Button.Click += AlarmList_Button_Click;
            Options_Button.Click   += OptionsButton_Click;

            this.AMPM_Analog.Visibility = System.Windows.Visibility.Collapsed;
            this.Analog_setHidden();
            this.date_analog.Visibility = System.Windows.Visibility.Collapsed;

            SnoozeButton  = new DarkButton(Snooze);
            DismissButton = new DarkButton(Dismiss);

            SnoozeButton.SetActiveColors(Colors.Gray, Colors.Black);
            SnoozeButton.SetIdleColors(Colors.Gray, Colors.White);

            DismissButton.SetActiveColors(Colors.Gray, Colors.Black);
            DismissButton.SetIdleColors(Colors.Gray, Colors.White);

            Snooze.Click  += Snooze_Click;
            Dismiss.Click += Dismiss_Click;

            GuiController.GetController().SetDismissAvailable(false);
            GuiController.GetController().SetSnoozeAvailable(false);
        }
예제 #4
0
        private void UpdateColorButtonStyleText(DarkButton colorButton)
        {
            HighlightingObject highlighting = (HighlightingObject)colorButton.Tag;

            if (highlighting.IsBold && highlighting.IsItalic)
            {
                colorButton.Text = "Style: Bold & Italic";
            }
            else if (highlighting.IsBold)
            {
                colorButton.Text = "Style: Bold";
            }
            else if (highlighting.IsItalic)
            {
                colorButton.Text = "Style: Italic";
            }
            else
            {
                colorButton.Text = "Style: Normal";
            }

            if (colorButton.BackColor.R + (colorButton.BackColor.G * 1.25) + colorButton.BackColor.B > 384)             // Green is a much lighter color
            {
                colorButton.ForeColor = Color.Black;
            }
            else
            {
                colorButton.ForeColor = Color.White;
            }
        }
예제 #5
0
        private void panel_Programs_MouseUp(object sender, MouseEventArgs e)
        {
            _draggedButton = null;

            panel_Programs.Capture = false;
            Cursor.Current         = Cursors.Default;
        }
예제 #6
0
 private void ProgramButton_MouseDown(object sender, MouseEventArgs e)
 {
     if (_draggedButton == null)
     {
         _clickPosition = e.Location;                 // Get the cursor position for the dragging threshold
     }
     _draggedButton = (DarkButton)sender;
 }
예제 #7
0
        private void buttonContextMenu_Opening(object sender, CancelEventArgs e)
        {
            DarkButton         sourceButton = (DarkButton)((DarkContextMenu)sender).SourceControl;
            HighlightingObject highlighting = (HighlightingObject)sourceButton.Tag;

            menuItem_Bold.Checked   = highlighting.IsBold;
            menuItem_Italic.Checked = highlighting.IsItalic;
        }
예제 #8
0
        private void ShowButton(DarkButton button, bool isLast = false)
        {
            button.SendToBack();

            if (!isLast)
            {
                button.Margin = new Padding(0, 0, 10, 0);
            }

            button.Visible = true;
        }
예제 #9
0
        private void UpdateButton(object sender)
        {
            DarkButton         sourceButton = (DarkButton)((DarkContextMenu)((ToolStripMenuItem)sender).GetCurrentParent()).SourceControl;
            HighlightingObject highlighting = (HighlightingObject)sourceButton.Tag;

            highlighting.IsBold   = menuItem_Bold.Checked;
            highlighting.IsItalic = menuItem_Italic.Checked;

            UpdateColorButtonStyleText(sourceButton);

            UpdatePreview();
        }
예제 #10
0
        private void AddProgramButton(string filePath, bool saveList)
        {
            // Check if the program is valid
            if (!File.Exists(filePath))
            {
                return;
            }

            int   buttonIndex = panel_Programs.Controls.OfType <DarkButton>().Count();
            Image image       = Icon.ExtractAssociatedIcon(filePath).ToBitmap();

            // Create the button
            DarkButton button = new DarkButton
            {
                Name     = buttonIndex.ToString(),
                Tag      = filePath,
                Image    = image,
                Size     = new Size(40, 40),
                Location = button_AddProgram.Location
            };

            // Bind event methods to the button
            button.Click     += ProgramButton_Click;
            button.MouseDown += ProgramButton_MouseDown;
            button.MouseMove += ProgramButton_MouseMove;

            button.ContextMenuStrip = contextMenu_ProgramButton;

            string programName = FileVersionInfo.GetVersionInfo(filePath).ProductName;

            // Handle batch files and programs without ProductNames
            if (Path.GetExtension(filePath).ToLower() == ".bat")
            {
                programName = Path.GetFileNameWithoutExtension(filePath) + " (Batch File)";
            }
            else if (string.IsNullOrWhiteSpace(programName))
            {
                programName = Path.GetFileNameWithoutExtension(filePath);
            }

            toolTip.SetToolTip(button, programName);

            // Add the button exactly where button_AddProgram is and move button_AddProgram lower
            panel_Programs.Controls.Add(button);
            button_AddProgram.Location = new Point(button_AddProgram.Location.X, button_AddProgram.Location.Y + 46);             // 40 + 6 (Margins)

            if (saveList)
            {
                SavePinnedPrograms();
            }
        }
예제 #11
0
        private void SavePinnedPrograms()
        {
            _ide.IDEConfiguration.PinnedProgramPaths.Clear();

            // Use for() instead of foreach() to also save the positions of the buttons based on their name numbers
            for (int i = 0; i < panel_Programs.Controls.OfType <DarkButton>().Count(); i++)
            {
                DarkButton button = (DarkButton)panel_Programs.Controls.Find(i.ToString(), false).First();
                _ide.IDEConfiguration.PinnedProgramPaths.Add(button.Tag.ToString());
            }

            _ide.IDEConfiguration.Save();
            _ide.ProgramButtonsModified();
        }
예제 #12
0
        private void SwapButtons(DarkButton src, DarkButton dst)
        {
            string srcName = src.Name;
            Point  srcLoc  = src.Location;

            string dstName = dst.Name;
            Point  dstLoc  = dst.Location;

            src.Name     = dstName;
            src.Location = dstLoc;

            dst.Name     = srcName;
            dst.Location = srcLoc;
        }
        private void Form1_Load(object sender, EventArgs e)
        {
            this.Controls.Add(_lblCalculatorHistory);
            this.Controls.Add(_lblCalculatorResult);
            DarkButton[,] buttons = new DarkButton[6, 4];
            int top    = 160;
            int left   = 0;
            int number = 9;

            string[] signs = new string[14] {
                "%", "CE", "C", "←", "1/x", "x²", "√x", "÷", "×", "−", "+", "+/-", ",", "="
            };
            int lastSignIndex = 0;
            int lastNumber    = 7;

            for (int i = 0; i <= buttons.GetUpperBound(0); i++)
            {
                if (i > 2 && i < 5)
                {
                    lastNumber -= 6;
                }
                else if (i == 5)
                {
                    lastNumber = 0;
                }
                for (int j = 0; j <= buttons.GetUpperBound(1); j++)
                {
                    string buttonText;
                    if ((i == 0 || i == 1) || (i != 5 && j != 0 && j % 3 == 0) || (i == 5 && j != 1))
                    {
                        buttonText = signs[lastSignIndex++];
                    }
                    else
                    {
                        buttonText = lastNumber.ToString();
                        lastNumber++;
                    }
                    buttons[i, j] = new DarkButton($"btn{buttonText}", buttonText, left, top, handleClickEvent);
                    left         += _controlWidth;
                    this.Controls.Add(buttons[i, j]);
                }
                top += _controlWidth;
                left = 0;
            }
        }
예제 #14
0
        private void ChangeColor(DarkButton targetButton)
        {
            colorDialog.Color = targetButton.BackColor;

            if (colorDialog.ShowDialog(this) == DialogResult.OK)
            {
                targetButton.BackColor = colorDialog.Color;

                if (targetButton.Tag != null)
                {
                    ((HighlightingObject)targetButton.Tag).HtmlColor = ColorTranslator.ToHtml(colorDialog.Color);
                }

                UpdatePreview();

                UpdateColorButtonStyleText(targetButton);
            }
        }
예제 #15
0
        private void menuItem_DeleteButton_Click(object sender, EventArgs e)
        {
            ToolStripMenuItem source         = (ToolStripMenuItem)sender;
            DarkContextMenu   owner          = (DarkContextMenu)source.GetCurrentParent();
            DarkButton        disposedButton = (DarkButton)owner.SourceControl;

            disposedButton.Dispose();

            // Rename every button beneath the disposedButton to reset the numbers in their names
            for (int i = int.Parse(disposedButton.Name) + 1; i <= panel_Programs.Controls.OfType <DarkButton>().Count(); i++)
            {
                DarkButton button = (DarkButton)panel_Programs.Controls.Find(i.ToString(), false).First();
                button.Location = new Point(button.Location.X, button.Location.Y - 46);
                button.Name     = (int.Parse(button.Name) - 1).ToString();
            }

            button_AddProgram.Location = new Point(button_AddProgram.Location.X, button_AddProgram.Location.Y - 46);             // 40 + 6 (Margins)

            SavePinnedPrograms();
        }
예제 #16
0
 public Layer(string folderName, DarkComboBox itemList, DarkButton colorButton, ColorDialog colorD, TrackBar intBar, TrackBar aBar, PictureBox lockPic, frmGenerator form)
 {
     if (!Directory.Exists("assets"))
     {
         Directory.CreateDirectory("assets");
     }
     frmGenerator = form;
     colorDialog  = colorD;
     intensityBar = intBar;
     lockBox      = lockPic;
     alphaBar     = aBar;
     directory    = folderName;
     cmbItems     = itemList;
     colorBtn     = colorButton;
     LoadItems();
     PopulateList(true);
     cmbItems.SelectedIndexChanged += cmbItems_SelectedIndexChanged;
     colorBtn.Click        += btnColor_Click;
     intBar.ValueChanged   += intBar_ValueChanged;
     alphaBar.ValueChanged += alphaBar_ValueChanged;
     lockBox.Click         += LockBox_Click;
 }
예제 #17
0
        public MainForm()
        {
            this.InitializeComponent();

            this.FormClosing += this.MainForm_FormClosing;

            // 实现停靠容器拖拽和拉伸
            Application.AddMessageFilter(this.DemoDockPanel.DockContentDragFilter);
            Application.AddMessageFilter(this.DemoDockPanel.DockResizeFilter);

            this.DemoDockPanel.AddContent(this.dock1);
            // DockPanel.AddContent(, DockGroup) 合并子容器
            this.DemoDockPanel.AddContent(this.dock2, this.dock1.DockGroup);
            this.DemoDockPanel.AddContent(this.dock3);
            this.DemoDockPanel.AddContent(this.dock4);
            this.DemoDockPanel.AddContent(this.dock5);
            this.DemoDockPanel.AddContent(this.dock6);
            this.DemoDockPanel.AddContent(this.dock7);
            this.DemoDockPanel.AddContent(this.dock8);
            this.DemoDockPanel.AddContent(this.dock9);
            this.DemoDockPanel.AddContent(this.dock10);
            this.DemoDockPanel.AddContent(this.dock11);
            this.DemoDockPanel.AddContent(this.dock12);
            this.DemoDockPanel.AddContent(this.dock13);

            DarkDocument document = new DarkDocument()
            {
                DockText = "测试"
            };
            DarkButton button = new DarkButton()
            {
                Dock = DockStyle.Fill, Text = "Button"
            };

            document.Padding = new Padding(30);
            document.Controls.Add(button);
            button.MouseClick += this.Button_MouseClick;
            this.DemoDockPanel.AddContent(document);
        }