Пример #1
0
        private void setMetrics()
        {
            int bandPixWidth = Math.Max(QScrollBar.MIN_WIDTH, this.ClientRectangle.Width / 2 / numBands);

            float spacing = (this.ClientRectangle.Width - HORIZ_MARGIN - HORIZ_MARGIN - LEFT_MARGIN - bandPixWidth) / (numBands - 1);

            int freqRectTop = this.ClientRectangle.Height - BOTTOM_MARGIN + 10;

            for (int i = 0; i < numBands; i++)
            {
                QScrollBar s = scrollBars[i];
                s.Bounds = new Rectangle((int)((float)i * spacing) + HORIZ_MARGIN + LEFT_MARGIN,
                                         TOP_MARGIN,
                                         bandPixWidth,
                                         this.ClientRectangle.Height - TOP_MARGIN - BOTTOM_MARGIN);

                int w = TextRenderer.MeasureText(freqMarkers[i], Styles.FontSmall).Width;
                freqRects[i]          = new Rectangle(s.Left + s.Width / 2 - w / 2, freqRectTop, w, 30);
                scrollBars[i].Visible = true;
            }
            for (int i = numBands; i < MAX_NUM_BANDS; i++)
            {
                scrollBars[i].Visible = false;
            }

            zeroLine = TOP_MARGIN + (this.ClientRectangle.Height - TOP_MARGIN - BOTTOM_MARGIN) / 2;
            this.Invalidate();
        }
Пример #2
0
        public QTextArea()
        {
            this.DoubleBuffered = true;

            this.text = String.Empty;

            scrollbar         = new QScrollBar(false);
            scrollbar.Visible = false;
            this.Controls.Add(scrollbar);

            this.Font = Styles.Font;

            scrollbar.UserScroll += (s, v) => { this.Invalidate(); };
        }
Пример #3
0
        private void scroll(QScrollBar Sender, int Value)
        {
            int band = (int)(Sender.Tag);

            if (btnFineControl.Value)
            {
                CurrentEqualizer.Values[band] = Value;
            }
            else if (btnAllTogether.Value)
            {
                float oldVal = CurrentEqualizer.Values[band];
                float newVal = Sender.Value;
                float diff   = newVal - oldVal;

                for (int i = 0; i < numBands; i++)
                {
                    CurrentEqualizer.Values[i] = Math.Max(-SCALE_FLOAT, Math.Min(SCALE_FLOAT, CurrentEqualizer.Values[i] + diff));
                    scrollBars[i].Value        = (int)CurrentEqualizer.Values[i];
                }
            }
            else
            {
                float oldVal = CurrentEqualizer.Values[band];

                CurrentEqualizer.Values[band] = Value;

                float newVal = Value;
                float factor = Math.Min(scrollFactor, Math.Abs(4.0f * (newVal - oldVal) / SCALE_FLOAT));

                for (int i = 1; i < numBands; i++)
                {
                    if (band + i < numBands)
                    {
                        CurrentEqualizer.Values[band + i] += ((((CurrentEqualizer.Values[band + i - 1] + newVal) / 2) - CurrentEqualizer.Values[band + i]) * factor);
                    }
                    if (band - i >= 0)
                    {
                        CurrentEqualizer.Values[band - i] += ((((CurrentEqualizer.Values[band - i + 1] + newVal) / 2) - CurrentEqualizer.Values[band - i]) * factor);
                    }
                    factor *= scrollFactor;
                }

                for (int i = 0; i < numBands; i++)
                {
                    scrollBars[i].Value = (int)CurrentEqualizer.Values[i];
                }
            }
            Clock.Update(ref eqChangeTimer, eqChanged, 360, false);
        }
Пример #4
0
        public QSelectPanel()
        {
            this.DoubleBuffered = true;

            qScrollBar             = new QScrollBar(true);
            qScrollBar.Top         = 0;
            qScrollBar.Width       = SCROLL_BAR_WIDTH;
            qScrollBar.UserScroll += new QScrollBar.ScrollDelegate(scroll);
            qScrollBar.ScrollSkip += new QScrollBar.ScrollSkipDelegate(qScrollBar_ScrollSkip);
            this.Controls.Add(qScrollBar);

            textHeight = Styles.TextHeight;
            viewMode   = HTPCMode.Normal;
            updateForViewMode();
        }
Пример #5
0
        public QListView(List <string> Headings, List <ClickDelegate> EventCallbacks, string[] FixedColumnsText, ListViewSortDelegate SortDelegate)
        {
            this.DoubleBuffered = true;

            numColumns = Headings.Count;
            numFields  = numColumns - EventCallbacks.Count;
            numActions = EventCallbacks.Count;

            this.sortDelegate = SortDelegate;

            headings = new string[numColumns];
            for (int i = 0; i < numColumns; i++)
            {
                headings[i] = Headings[i];
            }

            fixedColumnWidths = new int[numColumns];
            setFixedColumnWidths(FixedColumnsText);

            tff = new TextFormatFlags[numColumns];
            for (int i = 0; i < numColumns; i++)
            {
                if (fixedColumnWidths[i] == -1)
                {
                    tff[i] = tffLeft;
                }
                else
                {
                    tff[i] = tffCenter;
                }
            }

            scrollBar             = new QScrollBar(false);
            scrollBar.UserScroll += new QScrollBar.ScrollDelegate(scrollBar_UserScroll);
            scrollBar.Max         = 0;

            int callbackIndex = numFields;

            foreach (ClickDelegate cd in EventCallbacks)
            {
                eventCallbacks.Add(new QListView <T> .ItemEventCallback(Headings[callbackIndex], cd, callbackIndex));
                callbackIndex++;
            }

            this.Controls.Add(scrollBar);
        }
Пример #6
0
        public QListBox(bool Unique)
        {
            qScrollBar             = new QScrollBar(false);
            qScrollBar.Max         = 0;
            qScrollBar.Width       = SCROLLBAR_WIDTH;
            qScrollBar.UserScroll += new QScrollBar.ScrollDelegate(scroll);

            this.Controls.Add(qScrollBar);

            items         = new List <string>();
            itemHeight    = Styles.TextHeight;
            topItem       = 0;
            hoverIndex    = -1;
            selectedIndex = -1;

            unique = Unique;

            this.DoubleBuffered = true;
        }
Пример #7
0
 private void scrollBar_UserScroll(QScrollBar Sender, int Value)
 {
     FirstVisibleRow = scrollBar.Value;
     safeInvalidate();
 }
Пример #8
0
 private void scroll(QScrollBar Sender, int Value)
 {
     topItem = qScrollBar.Value;
     this.Invalidate();
 }
Пример #9
0
 protected void scroll(QScrollBar Sender, int Value)
 {
     FirstVisibleItem = qScrollBar.Value;
     this.Invalidate();
 }
Пример #10
0
 private void scroll(QScrollBar Sender, int Value)
 {
     FirstVisibleStation = scrollBar.Value;
 }
Пример #11
0
        public Radio()
        {
            this.Visible        = false;
            this.DoubleBuffered = true;

            stationPanel = new StationPanel();
            this.Panel2.Controls.Add(stationPanel);
            stationPanel.AllowDrop = true;

            instance              = this;
            scrollBar             = new QScrollBar(false);
            scrollBar.Width       = SCROLL_BAR_WIDTH;
            scrollBar.UserScroll += new QScrollBar.ScrollDelegate(scroll);
            stationPanel.Controls.Add(scrollBar);

            txtURL = new QTextBoxFocusOnClick();
            stationPanel.Controls.Add(txtURL);
            txtURL.EnableWatermark(stationPanel, Localization.Get(UI_Key.Radio_URL_Watermark), String.Empty);
            txtURL.MaxLength = 2048;
            txtURL.Enter    += (s, e) => { keyPreviewChange(); };
            txtURL.Leave    += (s, e) => { keyPreviewChange(); };
            txtURL.KeyPress += (s, e) =>
            {
                switch (e.KeyChar)
                {
                case '\r':
                    if (txtURL.Text.Length > 0)
                    {
                        go(btnGo);
                    }
                    e.Handled = true;
                    break;
                }
            };

            txtFilter = new QTextBox();
            stationPanel.Controls.Add(txtFilter);
            txtFilter.EnableWatermark(stationPanel, Localization.Get(UI_Key.Radio_Filter_Watermark), String.Empty);
            txtFilter.Enter       += (s, e) => { keyPreviewChange(); };
            txtFilter.Leave       += (s, e) => { keyPreviewChange(); };
            txtFilter.TextChanged += (s, e) => { populateStations(); };

            btnClear = new QButton("X", false, true);
            btnClear.ButtonPressed += new QButton.ButtonDelegate(clear);
            btnClear.BackColor      = stationPanel.BackColor;
            stationPanel.Controls.Add(btnClear);

            btnGo = new QButton(Localization.Get(UI_Key.Radio_Add_And_Play), false, true);
            btnGo.ButtonPressed += new QButton.ButtonDelegate(go);
            btnGo.BackColor      = stationPanel.BackColor;
            stationPanel.Controls.Add(btnGo);

            genrePanel            = new RadioGenreSelectPanel();
            genrePanel.Location   = Point.Empty;
            genrePanel.HeaderText = Localization.Get(UI_Key.Radio_Genres);
            this.Panel1.Controls.Add(genrePanel);

            cells = new List <Cell>();
            setupCells();

            this.Panel1.Resize += (s, e) => { arrangeSelectPanel(); };
            this.Panel2.Resize += (s, e) => { arrangeStationPanel(); };

            stationPanel.MouseMove        += new MouseEventHandler(stationPanelMouseMove);
            stationPanel.MouseDown        += new MouseEventHandler(stationPanelMouseDown);
            stationPanel.MouseUp          += new MouseEventHandler(stationPanelMouseUp);
            stationPanel.Paint            += new PaintEventHandler(stationPanelPaint);
            stationPanel.MouseDoubleClick += new MouseEventHandler(stationPanelDoubleClick);
            stationPanel.MouseWheel       += new MouseEventHandler(stationPanelMouseWheel);
            stationPanel.MouseEnter       += (s, e) => { if (!txtURL.Focused && !txtFilter.Focused)
                                                         {
                                                             stationPanel.Focus();
                                                         }
            };
            stationPanel.MouseLeave += (s, e) => { hoverCell = null; };
            stationPanel.Resize     += (s, e) => { setupCells(); };
            stationPanel.GotFocus   += (s, e) => { stationPanel.Active = true; keyPreviewChange(); };
            stationPanel.LostFocus  += (s, e) => { stationPanel.Active = false; };
            stationPanel.DragEnter  += (s, e) => { onDragEnter(e); };
            stationPanel.DragDrop   += (s, e) => { onDragDrop(e, true); };

            txtURL.DragEnter += (s, e) => { onDragEnter(e); };
            txtURL.DragDrop  += (s, e) => { onDragDrop(e, false); };
            txtURL.AllowDrop  = true;

            txtURL.Watermark.DragEnter += (s, e) => { onDragEnter(e); };
            txtURL.Watermark.DragDrop  += (s, e) => { onDragDrop(e, false); };
            txtURL.Watermark.AllowDrop  = true;

            genrePanel.AllowDrop             = true;
            genrePanel.SelectedIndexChanged += () => { populateStations(); };
            genrePanel.ValueChanged         += new QSelectPanel.ValueEditDelegate(selectPanel_ValueChanged);
            genrePanel.DragEnter            += (s, e) =>
            {
                onDragEnter(e);
            };
            genrePanel.DragDrop         += (s, e) => { onDragDropGenre(e); };
            this.genrePanel.MouseEnter  += (s, e) => { genrePanel.Focus(); };
            this.genrePanel.GotFocus    += (s, e) => { genrePanel.Active = true; };
            this.genrePanel.LostFocus   += (s, e) => { genrePanel.Active = false; };
            this.genrePanel.DoubleClick += (s, e) => { genreDoubleClick(); };

            int tabIndex = 0;

            txtFilter.TabIndex = tabIndex++;
            btnClear.TabIndex  = tabIndex++;
            txtURL.TabIndex    = tabIndex++;
            btnGo.TabIndex     = tabIndex++;
        }
Пример #12
0
        public Equalizer()
        {
            instance = this;

            this.DoubleBuffered = true;

            _currentEqualizer = EqualizerSetting.Off;

            scrollBars = new QScrollBar[MAX_NUM_BANDS];

            for (int i = 0; i < MAX_NUM_BANDS; i++)
            {
                QScrollBar qsb = new QScrollBar(false);
                qsb.Max         = SCALE;
                qsb.Min         = -SCALE;
                qsb.LargeChange = LARGE_CHANGE;
                qsb.Value       = 0;
                qsb.Brightness  = QScrollBar.SBBrightness.Dim;
                qsb.UserScroll += new QScrollBar.ScrollDelegate(scroll);
                this.Controls.Add(qsb);
                qsb.Tag       = i;
                scrollBars[i] = qsb;
            }

            btnOn           = new QButton(Localization.Get(UI_Key.Equalizer_Eq_Off), true, false);
            btnOn.BackColor = Color.Black;

            cboName                       = new QComboBox(true);
            cboName.Location              = new Point(HORIZ_MARGIN, BUTTON_TOPS + btnOn.Height / 2 - cboName.Height / 2);
            cboName.DropDownStyle         = ComboBoxStyle.DropDownList;
            cboName.SelectedValueChanged += new EventHandler(cboName_SelectedValueChanged);
            this.Controls.Add(cboName);

            btnOn.ButtonPressed += new QButton.ButtonDelegate(turnOn);
            this.Controls.Add(btnOn);

            btnLockPreset                = new QButton(Localization.Get(UI_Key.Equalizer_Lock), true, false);
            btnLockPreset.BackColor      = Color.Black;
            btnLockPreset.ButtonPressed += new QButton.ButtonDelegate(btnLockPreset_ButtonPressed);
            this.Controls.Add(btnLockPreset);

            btnFineControl                = new QButton(Localization.Get(UI_Key.Equalizer_Fine_Control), true, false);
            btnFineControl.BackColor      = Color.Black;
            btnFineControl.Value          = false;
            btnFineControl.ButtonPressed += (s) => { if (btnFineControl.Value)
                                                     {
                                                         btnAllTogether.Value = false;
                                                     }
            };
            this.Controls.Add(btnFineControl);

            btnAllTogether                = new QButton(Localization.Get(UI_Key.Equalizer_All_Together), true, false);
            btnAllTogether.BackColor      = Color.Black;
            btnAllTogether.Value          = false;
            btnAllTogether.ButtonPressed += (s) => { if (btnAllTogether.Value)
                                                     {
                                                         btnFineControl.Value = false;
                                                     }
            };
            this.Controls.Add(btnAllTogether);

            btnExpand                = new QButton(Localization.Get(UI_Key.Equalizer_Expand), false, false);
            btnExpand.BackColor      = Color.Black;
            btnExpand.ButtonPressed += new QButton.ButtonDelegate(expand);
            this.Controls.Add(btnExpand);

            btnCompress                = new QButton(Localization.Get(UI_Key.Equalizer_Compress), false, false);
            btnCompress.BackColor      = Color.Black;
            btnCompress.ButtonPressed += new QButton.ButtonDelegate(compress);
            this.Controls.Add(btnCompress);

            btnReset                = new QButton(Localization.Get(UI_Key.Equalizer_Reset), false, false);
            btnReset.BackColor      = Color.Black;
            btnReset.ButtonPressed += new QButton.ButtonDelegate(reset);
            this.Controls.Add(btnReset);

            btnRemovePreset                = new QButton(Localization.Get(UI_Key.Equalizer_Remove), false, false);
            btnRemovePreset.BackColor      = Color.Black;
            btnRemovePreset.ButtonPressed += new QButton.ButtonDelegate(btnRemovePreset_ButtonPressed);
            this.Controls.Add(btnRemovePreset);

            btnNewPreset                = new QButton(Localization.Get(UI_Key.Equalizer_New), false, false);
            btnNewPreset.BackColor      = Color.Black;
            btnNewPreset.ButtonPressed += new QButton.ButtonDelegate(btnNewPreset_ButtonPressed);
            this.Controls.Add(btnNewPreset);

            btnNumBands                = new QButton(Localization.Get(UI_Key.Equalizer_Bands, "10"), false, false);
            btnNumBands.BackColor      = Color.Black;
            btnNumBands.ButtonPressed += new QButton.ButtonDelegate(btnNumBands_ButtonPressed);
            this.Controls.Add(btnNumBands);

            fullButtonsWidth = getButtonsWidth();
        }