Exemplo n.º 1
0
        private void ResizeImageDrawingArea()
        {
            HScrollProperties hScroll = m_imagePanel.HorizontalScroll;
            VScrollProperties vScroll = m_imagePanel.VerticalScroll;
            int  prevHMax             = hScroll.Maximum;
            int  prevVMax             = vScroll.Maximum;
            bool isHScrollVisible     = hScroll.Visible;
            bool isVScrollVisible     = vScroll.Visible;

            m_drawingArea.Width  = (int)((float)m_imageWidth * m_imageZoom);
            m_drawingArea.Height = (int)((float)m_imageHeight * m_imageZoom);

            if (isHScrollVisible)
            {
                int hNewValue = hScroll.Value + ((hScroll.Maximum - prevHMax) / 2);
                if (hNewValue < hScroll.Minimum)
                {
                    hScroll.Value = hScroll.Minimum;
                }
                else if (hNewValue > hScroll.Maximum)
                {
                    hScroll.Value = hScroll.Maximum;
                }
                else
                {
                    hScroll.Value = hNewValue;
                }
            }
            else
            {
                hScroll.Value = (hScroll.Maximum - hScroll.LargeChange) / 2;
            }

            if (isVScrollVisible)
            {
                int vNewValue = vScroll.Value + ((vScroll.Maximum - prevVMax) / 2);
                if (vNewValue < vScroll.Minimum)
                {
                    vScroll.Value = vScroll.Minimum;
                }
                else if (vNewValue > vScroll.Maximum)
                {
                    vScroll.Value = vScroll.Maximum;
                }
                else
                {
                    vScroll.Value = vNewValue;
                }
            }
            else
            {
                vScroll.Value = (vScroll.Maximum - vScroll.LargeChange) / 2;
            }

            m_drawingArea.Refresh();
        }
Exemplo n.º 2
0
        private void panelMovies_Scroll(object sender, ScrollEventArgs e)
        {
            panelMovies.Update();

            VScrollProperties vs = panelMovies.VerticalScroll;

            if (e.NewValue == vs.Maximum - vs.LargeChange + 1)
            {
                loadMovies(52);
            }
        }
Exemplo n.º 3
0
        /// <summary>
        /// Add song to panel
        /// </summary>
        /// <param name="song">
        /// Song object witch will be added to panel
        /// </param>
        /// <param name="player">
        /// Is Song added by user or loaded by programm
        /// </param>
        public void addSong(Song song, bool player)
        {
            if (player)
            {
                VScrollProperties vScroll = this.mainPanel.VerticalScroll;
                vScroll.Value = 0;
            }

            this.mainPanel.Controls.Add(new MusicPanel(song, new Point(this.mainPanel.Controls.Count % 3 * 150, (this.mainPanel.Controls.Count / 3) * 50)));
            this.mainPanel.BackgroundImage = null;
        }
        private bool ScrollReachedBottom(FlowLayoutPanel flowLayoutPnl)
        {
            VScrollProperties vs = flowLayoutPnl.VerticalScroll;

            if (vs.Value == vs.Maximum - vs.LargeChange + 1)
            {
                return(true);
            }

            return(false);
        }
Exemplo n.º 5
0
        private void Dg_Scroll(object sender, ScrollEventArgs e)
        {
            VScrollProperties vs = dg.VerticalScroll;

            if (e.NewValue == vs.Maximum - vs.LargeChange + 1)
            {
                if (tasks == task.browse)
                {
                    LoadNextPackages();
                }
                else if (tasks == task.search)
                {
                    LoadNextPackages(searchText.GetText());
                }
            }
        }
Exemplo n.º 6
0
        void OnResultsScroll(object sender, ScrollEventArgs e)
        {
            var autoLoad = AppSettings.Instance.LoadMoreResultsOnScrollToEnd;

            if (searchState == null || appendingResult || !autoLoad)
            {
                return;
            }
            VScrollProperties properties = uiResults.VerticalScroll;

            if (e.NewValue != properties.Maximum - properties.LargeChange + 1)
            {
                return;
            }
            LoadMoreResults();
        }
Exemplo n.º 7
0
        public Size CalculateAutoScrollSize(Size autoScrollMinSize, Size size, VScrollProperties verticalScroll)
        {
            Size autoScrollSize = this.autoScrollMinSize;

            //Dynamically adjust width
            if (verticalScroll.Visible)
            {
                autoScrollSize.Width = size.Width - SystemInformation.VerticalScrollBarWidth;
            }
            else
            {
                autoScrollSize.Width = size.Width;
            }

            int timeDivisions     = (EndHourInDay - StartHourInDay) * (EndDate - StartDate).Days;
            int pixelsPerDivision = autoScrollSize.Width / timeDivisions;

            if (pixelsPerDivision < MinTimeIntervalWidth)
            {
                if (verticalScroll.Visible)
                {
                    autoScrollSize.Width = timeDivisions * MinTimeIntervalWidth - SystemInformation.VerticalScrollBarWidth;
                }
                else
                {
                    autoScrollSize.Width = timeDivisions * MinTimeIntervalWidth;
                }
            }

            //Dynamically adjust height
            if (Rows.Count > 0 && Rows.All(p => p.Rect != null))
            {
                int highestYValue = Rows.Select(p => { return(p.Rect.Bottom); }).Max();
                autoScrollSize.Height = highestYValue + 1;
            }
            else
            {
                autoScrollSize.Height = size.Height;
            }

            if (autoScrollMinSize != autoScrollSize)
            {
                autoScrollMinSize = autoScrollSize;
            }

            return(autoScrollMinSize);
        }
Exemplo n.º 8
0
 private void scrollMainForm(int nLines, bool horz)
 {
     if (horz)
     {
         // scroll the ChartImage left/right
         HScrollProperties hscroll = mChartImagePanel.HorizontalScroll;
         int scrollRange           = hscroll.Maximum - hscroll.Minimum;
         int scrollX = hscroll.Value + (int)(scrollRange * nLines / 100);
         scrollChartImagePanel(scrollX, null);
     }
     else
     {
         // scroll the ChartImage up/down
         VScrollProperties vscroll = mChartImagePanel.VerticalScroll;
         int scrollRange           = vscroll.Maximum - vscroll.Minimum;
         int scrollY = vscroll.Value + (int)(scrollRange * nLines / 100);
         scrollChartImagePanel(null, scrollY);
     }
 }
Exemplo n.º 9
0
        // ScrollableControl.get_VerticalScroll

        public __ScrollableControl()
        {
            this.HorizontalScroll = (HScrollProperties)(object)new __HScrollProperties();
            this.VerticalScroll   = (VScrollProperties)(object)new __VScrollProperties();
        }
Exemplo n.º 10
0
 /// <summary>
 /// ctor
 /// </summary>
 public ScrollableView()
 {
     _hscroll = new HScrollProperties(this);
     _vscroll = new VScrollProperties(this);
 }
Exemplo n.º 11
0
 public VScrollPropertiesWrapper(VScrollProperties vScrollProperties)
 {
     _vScrollProperties = vScrollProperties;
 }
Exemplo n.º 12
0
    private void doMainFormResize(Point?clientMousePos)
    {
        // check if we are showing a ChartImage
        Image img = mChartImagePictureBox.Image;

        if (img == null)
        {
            mChartImagePanel.Visible = false;
            return;
        }
        mChartImagePanel.Visible = true;

        // resize the ChartImage panel to fill the available space
        mChartImagePanel.Size = new Size(
            mSplitter.Panel2.Width - (Program.isMono?8:17),
            mSplitter.Panel2.Height - (Program.isMono?28:40)
            );

        // figure out how large to show the ChartImage
        int    width, height;
        int    margin         = 5;
        int    availableWidth = mChartImagePanel.Width - 2 * margin;
        double zoom           = Math.Max(Math.Min(mCurrZoom, mMaxZoom), mMinZoom);

        width  = (int)(img.Width * zoom + 0.5);
        height = (int)(img.Height * zoom + 0.5);

        // check if the v-scrollbar is showing
        if (height >= mChartImagePanel.Height)
        {
            // yup - adjust the width
            int sbWidth = SystemInformation.VerticalScrollBarWidth;
            availableWidth -= sbWidth;
            width          -= sbWidth;
        }

        // remember the current scroll positions
        HScrollProperties hscroll           = mChartImagePanel.HorizontalScroll;
        int               prevScrollPosX    = hscroll.Value;
        int               prevMaxScrollX    = ChartImagePanel_MaxScrollX();
        double            prevRelScrollPosX = (double)prevScrollPosX / (double)prevMaxScrollX;
        VScrollProperties vscroll           = mChartImagePanel.VerticalScroll;
        int               prevScrollPosY    = vscroll.Value;
        int               prevMaxScrollY    = ChartImagePanel_MaxScrollY();
        double            prevRelScrollPosY = (double)prevScrollPosY / (double)prevMaxScrollY;

        // resize and position the ChartImage
        setChartImagePanelScrollPos(0, 0);
        Size prevChartImagePictureBoxSize = new Size(mChartImagePictureBox.Size.Width, mChartImagePictureBox.Size.Height);

        mChartImagePictureBox.Size = new Size(width, height);
        if (width < availableWidth)
        {
            mChartImagePictureBox.Location = new Point(margin + (availableWidth - width) / 2, margin);
        }
        else
        {
            mChartImagePictureBox.Location = new Point(margin, margin);
        }

        // restore the scroll positions
        int newScrollPosX, newScrollPosY;
        int newMaxScrollX = ChartImagePanel_MaxScrollX();
        int newMaxScrollY = ChartImagePanel_MaxScrollY();

        if (clientMousePos == null)
        {
            // maintain the relative scroll positions
            newScrollPosX = (int)(prevRelScrollPosX * newMaxScrollX + 0.5);
            newScrollPosY = (int)(prevRelScrollPosY * newMaxScrollY + 0.5);
        }
        else
        {
            // keep whatever's under the mouse in the same place
            int    absX    = prevScrollPosX + clientMousePos.Value.X;
            double scaling = (double)mChartImagePictureBox.Size.Width / (double)prevChartImagePictureBoxSize.Width;
            newScrollPosX = (int)(absX * scaling + 0.5) - clientMousePos.Value.X;
            int absY = prevScrollPosY + clientMousePos.Value.Y;
            scaling       = (double)mChartImagePictureBox.Size.Height / (double)prevChartImagePictureBoxSize.Height;
            newScrollPosY = (int)(absY * scaling + 0.5) - clientMousePos.Value.Y;
        }
        scrollChartImagePanel(newScrollPosX, newScrollPosY);
    }
Exemplo n.º 13
0
    protected override bool ProcessCmdKey(ref Message msg, Keys keyData)
    {
        // prevent recursive calls
        if (mDisableProcessCmdKey)
        {
            return(false);
        }

        // initialize
        Keys modifierKeys = Control.ModifierKeys & (Keys.Control | Keys.Shift | Keys.Alt);
        Keys keyCode      = keyData & ~(Keys.Control | Keys.Shift | Keys.Alt);

        // handle search result selection
        if ((keyData & Keys.Control) == 0 && (keyCode == Keys.Left || keyCode == Keys.Right))
        {
            // send the keypress to the search results
            // NOTE: We could also respond to Up/Down and scroll the ChartImage vertically,
            // but that would be confusing, given that Left/Right selects a search result.
            if (mSearchResults.Items.Count > 1 && mSearchResults.SelectedItems.Count > 0)
            {
                // check for wrap-around
                ImageListViewItem selItem = mSearchResults.SelectedItems[0];
                if (keyCode == Keys.Left && Object.ReferenceEquals(selItem, mSearchResults.Items[0]))
                {
                    mSearchResults.setSelection(mSearchResults.Items.Count - 1);
                    return(true);
                }
                if (keyCode == Keys.Right && Object.ReferenceEquals(selItem, mSearchResults.Items[mSearchResults.Items.Count - 1]))
                {
                    mSearchResults.setSelection(0);
                    return(true);
                }
            }
            mSearchResults.Focus();
            mDisableProcessCmdKey = true;
            SendKeys.SendWait("{" + keyCode.ToString() + "}");
            mDisableProcessCmdKey = false;
            return(true);
        }

        // handle ChartImage zoom and panning
        if ((keyData & Keys.Control) == 0 && (keyCode == Keys.Up || keyCode == Keys.Down))
        {
            // FUDGE! Windows seems to be mapping Ctrl-Up/Down to PageUp/Down before even preFilterMessage()
            //  sees the message. It would nice to be able to scroll the ChartImage using Ctrl-Left/Right/Up/Down,
            //  but since Ctrl-Left/Right will be rarely used, we can live with doing things like this :-/
            if (keyCode == Keys.Up)
            {
                scrollMainForm(-3, false);
                return(true);
            }
            if (keyCode == Keys.Down)
            {
                scrollMainForm(+3, false);
                return(true);
            }
        }
        if ((keyData & Keys.Control) != 0)
        {
            if (keyCode == Keys.Add || keyCode == Keys.Oemplus)
            {
                adjustZoom(+0.05, null);
                return(true);
            }
            if (keyCode == Keys.Subtract || keyCode == Keys.OemMinus)
            {
                adjustZoom(-0.05, null);
                return(true);
            }
            if (keyCode == Keys.D0)
            {
                adjustZoom(null, null);
                return(true);
            }
            if (keyCode == Keys.Left)
            {
                scrollMainForm(-3, true);
                return(true);
            }
            if (keyCode == Keys.Right)
            {
                scrollMainForm(+3, true);
                return(true);
            }
        }
        if (keyCode == Keys.PageUp || keyCode == Keys.PageDown)
        {
            if (mChartImagePictureBox.Image == null)
            {
                return(false);
            }
            double            ratio   = (double)mChartImagePanel.Height / (double)mChartImagePictureBox.Height;
            VScrollProperties vscroll = mChartImagePanel.VerticalScroll;
            int scrollRange           = vscroll.Maximum - vscroll.Minimum;
            int pageSize = (int)(ratio * scrollRange * 0.8);
            if (keyCode == Keys.PageUp)
            {
                pageSize = -pageSize;
            }
            int scrollY = vscroll.Value + pageSize;
            scrollChartImagePanel(null, scrollY);
            return(true);
        }
        if (keyCode == Keys.Home)
        {
            int?scrollX = null, scrollY = null;
            if ((modifierKeys & Keys.Control) != 0)
            {
                scrollX = scrollY = 0;
            }
            if ((modifierKeys & Keys.Shift) != 0)
            {
                scrollX = 0;
            }
            else
            {
                scrollY = 0;
            }
            setChartImagePanelScrollPos(scrollX, scrollY);
            return(true);
        }
        if (keyCode == Keys.End)
        {
            int?scrollX = null, scrollY = null;
            if ((modifierKeys & Keys.Control) != 0)
            {
                scrollX = 0;
                scrollY = ChartImagePanel_MaxScrollY();
            }
            if ((modifierKeys & Keys.Shift) != 0)
            {
                scrollX = ChartImagePanel_MaxScrollX();
            }
            else
            {
                scrollY = ChartImagePanel_MaxScrollY();
            }
            setChartImagePanelScrollPos(scrollX, scrollY);
            return(true);
        }

        // check if the user wants to clear the search query
        if (keyCode == Keys.Escape)
        {
            loadSearchResults(null, "", true);
            return(true);
        }

        // FUDGE! Stop Windows from beeping :-/
        if (keyCode == Keys.Return)
        {
            return(true);
        }

        // NOTE: The remaining keypress handling is only done after we've finished initialization.
        if (!mIsReady)
        {
            return(false);
        }

        // handle shortcuts
        if (Shortcut.handleShortcut(keyData))
        {
            return(true);
        }

        // check if we should update the search query
        // FUDGE! This is incredibly annoying :-/ We get a *key code*, which is not the same as an ASCII character,
        // so we only recognize a very limited set of characters here. Other characters will still be recognized
        // and added to the search query *if* the textbox has focus (since the code here won't fire, we end up
        // flagging the message as "not processed", and the textbox will receive the message normally), so it's
        // only an issue when the user is typing a search query and something else has focus. We could perhaps
        // translate things like Keys.OemXXX key codes here, but it's not worth the effort, since search queries
        // will almost always consist of only letters and/or numbers.
        int    ch      = (int)keyCode;
        string sendKey = "";

        if ((ch >= 65 && ch <= 90) || ch == 32)
        {
            sendKey = ((char)ch).ToString().ToLower();
        }
        else if (ch >= 48 && ch <= 57)
        {
            sendKey = keyCode.ToString().Substring(1);    // nb: this will also detect Shift 0-9 :-/
        }
        else if (keyCode == Keys.Back)
        {
            sendKey = "{BKSP}";
        }
        if (sendKey != "")
        {
            // send the keypress to the search query textbox
            mSearchQuery.Focus();
            mDisableProcessCmdKey = true;
            SendKeys.SendWait(sendKey);
            mDisableProcessCmdKey = false;
            return(true);
        }

        return(false);
    }
Exemplo n.º 14
0
        void flowLayoutPanel_DragDrop(object sender, DragEventArgs e)
        {
            TaskItem          data               = (TaskItem)e.Data.GetData(typeof(TaskItem));
            Panel             _destination       = (Panel)sender;
            VScrollProperties lastScrollPosition = _destination.VerticalScroll;
            Control           _source            = (Panel)data.Parent;

            SortedDictionary <int, Control> list = new SortedDictionary <int, Control>();
            int currentIndex = -1;

            foreach (Control control in _destination.Controls)
            {
                int i = _destination.Controls.GetChildIndex(control, false);
                if (control != data)
                {
                    list.Add(i * 10, control);
                }
                else
                {
                    currentIndex = i * 10;
                }
            }

            if (_source != _destination)
            {
                // Add control to panel
                _destination.Controls.Add(data);
                data.Width = _destination.Width - 14;

                // Reorder
                Point p     = _destination.PointToClient(new Point(e.X, e.Y));
                var   item  = _destination.GetChildAtPoint(p);
                int   index = _destination.Controls.GetChildIndex(item, false);

                list.Add(((index * 10)) - 5, data);

                _destination.Invalidate();
                _source.Invalidate();
            }
            else
            {
                Point p     = _destination.PointToClient(new Point(e.X, e.Y));
                var   item  = _destination.GetChildAtPoint(p);
                int   index = _destination.Controls.GetChildIndex(item, false);
                if (index * 10 < currentIndex)
                {
                    list.Add(((index * 10)) - 5, data);
                }
                else
                {
                    list.Add(((index * 10)) + 5, data);
                }

                _destination.Invalidate();
            }

            int newIndex = list.Count;

            _destination.Controls.Clear();
            foreach (KeyValuePair <int, Control> co in list)
            {
                _destination.Controls.Add(co.Value);
                ((KanbanPosition)co.Value.Tag).Position = newIndex;
                newIndex--;
            }

            foreach (Control control in _destination.Controls)
            {
                int i = _destination.Controls.GetChildIndex(control, false);
                ((KanbanPosition)control.Tag).Position = i;
            }

            if (data.Tag != null && data.Tag.GetType() == typeof(KanbanPosition))
            {
                //((KanbanPosition)data.Tag).Position = _destination.Controls.GetChildIndex(data, false);
                ((KanbanPosition)data.Tag).Status = (Status)_destination.Tag;


                SortableBindingList <Todo> todos = (SortableBindingList <Todo>)todoBindingSource.DataSource;
                var task = from todo in todos
                           where todo.pId == ((KanbanPosition)data.Tag).TaskPid
                           select todo;



                if (task.Count() > 0)
                {
                    Todo todo = (Todo)task.First();
                    todo.Status = (Status)_destination.Tag;
                    //dataGridViewKanbanTasks.DataSource = new object();
                    //dataGridViewKanbanTasks.DataSource = todoBindingSource;
                }
            }
            HasChanges = true;
            _destination.ScrollControlIntoView(data);
        }