示例#1
0
        private PropertyPageListView CreateCheckedListBox(string[] values, bool[] selected, string tooltip = null, int height = 200)
        {
            var columns = new[]
            {
                new ColumnDesc("A", 0.0f, ColumnType.CheckBox),
                new ColumnDesc("B", 1.0f, ColumnType.Label)
            };

            var list = new PropertyPageListView(columns);
            var data = new object[values.Length, 2];

            for (int i = 0; i < values.Length; i++)
            {
                data[i, 0] = selected != null ? selected[i] : true;
                data[i, 1] = values[i];
            }

            list.UpdateData(data);

            list.Font          = font;
            list.Height        = DpiScaling.ScaleForDialog(height);
            list.HeaderStyle   = ColumnHeaderStyle.None;
            list.ValueChanged += CheckedListBox_ValueChanged;
            toolTip.SetToolTip(list, SplitLongTooltip(tooltip));

            return(list);
        }
        private Button AddButton(string text, Bitmap image)
        {
            var btn   = new NoFocusButton();
            var sizeY = DpiScaling.ScaleForDialog(32);

            btn.BackColor  = BackColor;
            btn.ForeColor  = Theme.LightGreyFillColor2;
            btn.ImageAlign = ContentAlignment.MiddleLeft;
            btn.TextAlign  = ContentAlignment.MiddleLeft;
            btn.FlatStyle  = FlatStyle.Flat;
            btn.FlatAppearance.BorderSize         = 0;
            btn.FlatAppearance.MouseOverBackColor = Theme.DarkGreyFillColor2;
            btn.FlatAppearance.MouseDownBackColor = Theme.DarkGreyFillColor2;
            btn.Image             = image;
            btn.Top               = tabs.Count * sizeY;
            btn.Left              = 0;
            btn.Width             = panelTabs.Width;
            btn.Height            = sizeY;
            btn.Font              = tabs.Count == 0 ? fontBold : font;
            btn.Text              = text;
            btn.TextImageRelation = TextImageRelation.ImageBeforeText;
            btn.Click            += Btn_Click;

            panelTabs.Controls.Add(btn);

            return(btn);
        }
示例#3
0
 public PropertyDialog(string title, int width, bool canAccept = true, bool canCancel = true, Form parent = null)
 {
     StartPosition = FormStartPosition.CenterParent;
     Init();
     Width             = DpiScaling.ScaleForDialog(width);
     buttonYes.Visible = canAccept;
     buttonNo.Visible  = canCancel;
     FormClosed       += PropertyDialog_FormClosed;
 }
示例#4
0
        private PictureBox CreatePictureBox(Bitmap bmp)
        {
            var pictureBox = new PictureBox();

            pictureBox.Image       = bmp;
            pictureBox.Width       = DpiScaling.ScaleForDialog(bmp.Width);
            pictureBox.Height      = DpiScaling.ScaleForDialog(bmp.Height);
            pictureBox.SizeMode    = PictureBoxSizeMode.Zoom;
            pictureBox.BorderStyle = BorderStyle.None;

            return(pictureBox);
        }
示例#5
0
        private int GetRadioButtonHeight(string text, int width)
        {
            var testLabel = CreateLabel(text, null, true);

            testLabel.MaximumSize = new Size(width - DpiScaling.ScaleForDialog(16), 0);
            Controls.Add(testLabel);
            var height = testLabel.Height + DpiScaling.ScaleForDialog(8);

            Controls.Remove(testLabel);

            return(height);
        }
示例#6
0
        private RadioButton CreateRadioButton(string text, bool check)
        {
            var radio = new RadioButton();

            radio.Font      = font;
            radio.ForeColor = Theme.LightGreyFillColor2;
            radio.Text      = text;
            radio.AutoSize  = false;
            radio.Checked   = check;
            radio.Padding   = new Padding(DpiScaling.ScaleForDialog(16), 0, 0, 0);

            return(radio);
        }
示例#7
0
        private Button CreateButton(string text, string tooltip)
        {
            var button = new Button();

            button.Text      = text;
            button.Click    += Button_Click;
            button.FlatStyle = FlatStyle.Flat;
            button.Font      = font;
            button.ForeColor = Theme.LightGreyFillColor2;
            button.Height    = DpiScaling.ScaleForDialog(32);
            toolTip.SetToolTip(button, SplitLongTooltip(tooltip));
            return(button);
        }
示例#8
0
        private string[] BuildDpiScalingList()
        {
            var scalings = DpiScaling.GetAvailableScalings();
            var list     = new string[scalings.Length + 1];

            list[0] = "System";
            for (int i = 0; i < scalings.Length; i++)
            {
                list[i + 1] = $"{scalings[i]}%";
            }

            return(list);
        }
示例#9
0
        public void Resize(int w, int h)
        {
            width  = Math.Max(1, w);
            height = Math.Max(1, h);

            int toolBarHeight        = DpiScaling.ScaleForMainWindow(40);
            int projectExplorerWidth = DpiScaling.ScaleForMainWindow(300);
            int sequencerHeight      = pianoRoll.IsMaximized ? 1 : DpiScaling.ScaleForMainWindow(sequencer.ComputeDesiredSizeY());

            toolbar.Move(0, 0, width, toolBarHeight);
            projectExplorer.Move(width - projectExplorerWidth, toolBarHeight, projectExplorerWidth, height - toolBarHeight);
            sequencer.Move(0, toolBarHeight, width - projectExplorerWidth, sequencerHeight);
            pianoRoll.Move(0, toolBarHeight + sequencerHeight, width - projectExplorerWidth, height - toolBarHeight - sequencerHeight);
        }
示例#10
0
        public static void Save()
        {
            var ini = new Dictionary <string, Dictionary <string, string> >();

            ini["UI"]    = new Dictionary <string, string>();
            ini["Audio"] = new Dictionary <string, string>();
            ini["MIDI"]  = new Dictionary <string, string>();

            ini["UI"]["DpiScaling"]            = DpiScaling.ToString();
            ini["UI"]["CheckUpdates"]          = CheckUpdates.ToString();
            ini["Audio"]["InstrumentStopTime"] = InstrumentStopTime.ToString();
            ini["MIDI"]["Device"] = MidiDevice;

            Directory.CreateDirectory(GetConfigFilePath());

            IniFile.WriteINI(GetConfigFileName(), ini);
        }
示例#11
0
        public MultiPropertyDialog(string title, int width, int height, int tabsWidth = 150)
        {
            InitializeComponent();

            string suffix = DpiScaling.Dialog >= 2.0f ? "@2x" : "";

            buttonYes.Image = Image.FromStream(Assembly.GetExecutingAssembly().GetManifestResourceStream($"FamiStudio.Resources.Yes{suffix}.png"));
            buttonNo.Image  = Image.FromStream(Assembly.GetExecutingAssembly().GetManifestResourceStream($"FamiStudio.Resources.No{suffix}.png"));
            Width           = DpiScaling.ScaleForDialog(width);
            font            = new Font(PlatformUtils.PrivateFontCollection.Families[0], 10.0f, FontStyle.Regular);
            fontBold        = new Font(PlatformUtils.PrivateFontCollection.Families[0], 10.0f, FontStyle.Bold);

            toolTip.SetToolTip(buttonYes, "Accept");
            toolTip.SetToolTip(buttonNo, "Cancel");

            tableLayout.ColumnStyles[0].Width = tabsWidth * DpiScaling.Dialog;
        }
示例#12
0
        public PropertyDialog(string title, Point pt, int width, bool leftAlign = false, bool topAlign = false)
        {
            top   = topAlign;
            width = DpiScaling.ScaleForDialog(width);

            if (leftAlign)
            {
                pt.X -= width;
            }

            StartPosition = FormStartPosition.Manual;
            Location      = pt;
            FormClosed   += PropertyDialog_FormClosed;

            Init();

            Width = width;
        }
示例#13
0
        public void SetPropertyWarning(int idx, CommentType type, string comment)
        {
            var prop = properties[idx];

            if (prop.warningIcon == null)
            {
                prop.warningIcon = CreatePictureBox(warningIcons[(int)type]);
            }
            else
            {
                prop.warningIcon.Image = warningIcons[(int)type];
            }

            prop.warningIcon.Width   = DpiScaling.ScaleForDialog(16);
            prop.warningIcon.Height  = DpiScaling.ScaleForDialog(16);
            prop.warningIcon.Visible = !string.IsNullOrEmpty(comment);
            toolTip.SetToolTip(prop.warningIcon, SplitLongTooltip(comment));
        }
示例#14
0
        private PropertyPageListView CreateListView(ColumnDesc[] columnDescs, object[,] data, int height = 300)
        {
            var list = new PropertyPageListView(columnDescs);

            if (data != null)
            {
                list.UpdateData(data);
            }

            list.Font              = font;
            list.Height            = DpiScaling.ScaleForDialog(height);
            list.MouseDoubleClick += ListView_MouseDoubleClick;
            list.MouseDown        += ListView_MouseDown;
            list.ButtonPressed    += ListView_ButtonPressed;
            list.ValueChanged     += ListView_ValueChanged;

            return(list);
        }
示例#15
0
        private TextBox CreateMultilineTextBox(string txt)
        {
            var textBox = new TextBox();

            textBox.Font        = new Font(PlatformUtils.PrivateFontCollection.Families[0], 8.0f, FontStyle.Regular);
            textBox.Text        = txt;
            textBox.BackColor   = Theme.DarkGreyFillColor1;
            textBox.BorderStyle = BorderStyle.FixedSingle;
            textBox.ForeColor   = Theme.LightGreyFillColor2;
            textBox.Location    = new Point(5, 5);
            textBox.Multiline   = true;
            textBox.ReadOnly    = true;
            textBox.Height      = DpiScaling.ScaleForDialog(300);
            textBox.ScrollBars  = ScrollBars.Vertical;
            textBox.Select(0, 0);
            textBox.GotFocus += TextBox_GotFocus;

            return(textBox);
        }
示例#16
0
        private void Init()
        {
            InitializeComponent();

            string suffix = DpiScaling.Dialog >= 2.0f ? "@2x" : "";

            buttonLeft.Image = Image.FromStream(Assembly.GetExecutingAssembly().GetManifestResourceStream($"FamiStudio.Resources.ArrowLeft{suffix}.png"));

            Width         = DpiScaling.ScaleForDialog(Width);
            Height        = DpiScaling.ScaleForDialog(Height);
            label1.Height = DpiScaling.ScaleForDialog(label1.Height);

            pictureBox1.Top    = (label1.Top + label1.Height) + 8;
            pictureBox1.Height = (int)(pictureBox1.Width / 1.7777777f); // 16:9
            pictureBox1.Width  = DpiScaling.ScaleForDialog(pictureBox1.Width);
            pictureBox1.Height = DpiScaling.ScaleForDialog(pictureBox1.Height);

            label1.ForeColor           = Theme.LightGreyFillColor2;
            checkBoxDontShow.ForeColor = Theme.LightGreyFillColor2;

            buttonLeft.Width   = DpiScaling.ScaleForDialog(buttonLeft.Width);
            buttonLeft.Height  = DpiScaling.ScaleForDialog(buttonLeft.Height);
            buttonRight.Width  = DpiScaling.ScaleForDialog(buttonRight.Width);
            buttonRight.Height = DpiScaling.ScaleForDialog(buttonRight.Height);

            buttonRight.Left = ClientSize.Width - buttonRight.Width - 10;
            buttonRight.Top  = ClientSize.Height - buttonRight.Height - 10;
            buttonLeft.Left  = buttonRight.Left - buttonLeft.Width - 10;
            buttonLeft.Top   = buttonRight.Top;

            toolTip.SetToolTip(buttonRight, "Next");
            toolTip.SetToolTip(buttonLeft, "Previous");

            try
            {
                label1.Font           = new Font(PlatformUtils.PrivateFontCollection.Families[0], 10.0f, FontStyle.Regular);
                checkBoxDontShow.Font = label1.Font;
            }
            catch {}

            SetPage(0);
        }
示例#17
0
        protected override void OnLoad(EventArgs e)
        {
            SuspendLayout();

            var y         = 0;
            var maxHeight = 0;

            for (int i = 0; i < tabs.Count; i++)
            {
                var tab = tabs[i];
                tab.button.Visible = tab.visible;
                if (tab.visible)
                {
                    tab.button.Top = y;
                    y        += tab.button.Height;
                    maxHeight = Math.Max(maxHeight, tabs[i].properties.LayoutHeight);
                }
            }

            maxHeight = Math.Max(maxHeight, Width / 2);

            tableLayout.Height = maxHeight;

            buttonYes.Width  = DpiScaling.ScaleForDialog(buttonYes.Width);
            buttonYes.Height = DpiScaling.ScaleForDialog(buttonYes.Height);
            buttonNo.Width   = DpiScaling.ScaleForDialog(buttonNo.Width);
            buttonNo.Height  = DpiScaling.ScaleForDialog(buttonNo.Height);

            Height = maxHeight + buttonNo.Height + 20;

            buttonYes.Left = Width - buttonYes.Width * 2 - 17;
            buttonYes.Top  = Height - buttonNo.Height - 12;
            buttonNo.Left  = Width - buttonNo.Width - 12;
            buttonNo.Top   = Height - buttonNo.Height - 12;

            ResumeLayout();
            CenterToParent();

            base.OnLoad(e);
        }
示例#18
0
        private void UpdateLayout(bool init)
        {
            if (init)
            {
                buttonYes.Width  = DpiScaling.ScaleForDialog(buttonYes.Width);
                buttonYes.Height = DpiScaling.ScaleForDialog(buttonYes.Height);
                buttonNo.Width   = DpiScaling.ScaleForDialog(buttonNo.Width);
                buttonNo.Height  = DpiScaling.ScaleForDialog(buttonNo.Height);
            }

            Height = propertyPage.Height + buttonNo.Height + 7;

            buttonYes.Top = propertyPage.Bottom;
            buttonNo.Top  = propertyPage.Bottom;

            if (buttonNo.Visible)
            {
                buttonYes.Left = propertyPage.Right - buttonYes.Width * 2 - 10;
                buttonNo.Left  = propertyPage.Right - buttonNo.Width - 5;
            }
            else
            {
                buttonYes.Left = propertyPage.Right - buttonNo.Width - 5;
            }

            if (propertyPage.HasAdvancedProperties)
            {
                if (init)
                {
                    buttonAdvanced.Width  = DpiScaling.ScaleForMainWindow(buttonAdvanced.Width);
                    buttonAdvanced.Height = DpiScaling.ScaleForMainWindow(buttonAdvanced.Height);
                }

                buttonAdvanced.Left    = 5;
                buttonAdvanced.Top     = propertyPage.Bottom + 0;
                buttonAdvanced.Visible = true;
            }
        }
示例#19
0
        public void Build(bool advanced = false)
        {
            SuspendLayout();

            int margin             = DpiScaling.ScaleForDialog(5);
            int maxLabelWidth      = 0;
            int defaultLabelHeight = 24;

            // Workaround scaling issue with checkboxes.
            // Measure a label and well use this for checkbox.
            if (DpiScaling.Dialog > 1.0f)
            {
                Label testLabel = CreateLabel("888");
                Controls.Add(testLabel);
                defaultLabelHeight = Math.Max(defaultLabelHeight, testLabel.Height) + 2;
                Controls.Remove(testLabel);
            }

            var propertyCount = advanced || advancedPropertyStart < 0 ? properties.Count : advancedPropertyStart;

            for (int i = 0; i < propertyCount; i++)
            {
                var prop = properties[i];

                if (prop.visible && prop.label != null)
                {
                    // This is really ugly. We cant measure the labels unless they are added.
                    Controls.Add(prop.label);
                    maxLabelWidth = Math.Max(maxLabelWidth, prop.label.Width);
                    Controls.Remove(prop.label);
                }
            }

            int widthNoMargin = Width - (margin * 2);
            int totalHeight   = margin;
            int warningWidth  = showWarnings ? DpiScaling.ScaleForDialog(16) + margin : 0;

            for (int i = 0; i < propertyCount; i++)
            {
                var prop        = properties[i];
                var height      = 0;
                var marginScale = 1;

                if (!prop.visible)
                {
                    continue;
                }

                // Hack for checkbox that dont scale with Hi-DPI.
                if (DpiScaling.Dialog > 1.0f && prop.control is CheckBox)
                {
                    prop.control.Height = defaultLabelHeight;
                    if (prop.label != null)
                    {
                        prop.label.Height = defaultLabelHeight;
                    }
                }

                if (prop.label != null)
                {
                    prop.label.Left = margin;
                    prop.label.Top  = totalHeight;

                    prop.control.Left  = maxLabelWidth + margin;
                    prop.control.Top   = totalHeight;
                    prop.control.Width = widthNoMargin - maxLabelWidth - warningWidth;

                    Controls.Add(prop.label);
                    Controls.Add(prop.control);

                    height = prop.label.Height;
                }
                else
                {
                    prop.control.Left  = margin + prop.leftMarging;
                    prop.control.Top   = totalHeight;
                    prop.control.Width = widthNoMargin;

                    Controls.Add(prop.control);
                }

                // HACK : For some multiline controls.
                if (prop.control is Label && prop.control.MaximumSize.Width != 0)
                {
                    prop.control.MaximumSize = new Size(widthNoMargin, 0);
                }
                else if (prop.control is RadioButton)
                {
                    prop.control.Height = GetRadioButtonHeight(prop.control.Text, prop.control.Width);
                    marginScale         = 0;
                }

                if (prop.type == PropertyType.ColoredTextBox)
                {
                    (prop.control as TextBox).SelectAll();
                    prop.control.Focus();
                }

                height = Math.Max(prop.control.Height, height);

                if (prop.warningIcon != null)
                {
                    prop.warningIcon.Top  = totalHeight + (height - prop.warningIcon.Height) / 2;
                    prop.warningIcon.Left = widthNoMargin + margin + margin - warningWidth;
                    Controls.Add(prop.warningIcon);
                }

                totalHeight += height + margin * marginScale;
            }

            Height       = totalHeight;
            layoutHeight = totalHeight;
            ResumeLayout();
        }