Inheritance: System.Windows.Forms.Label, IColorable, IVisibleInfo
Example #1
0
        // List selected
        private void listbutton_Click(object sender, EventArgs e)
        {
            int           listindex;
            DisplayButton c = (DisplayButton)sender;

            if (int.TryParse(c.Tag.ToString(), out listindex))
            {
                SelectList(listindex);
            }
        }
        // Directory button clicked
        private void dirbutton_Click(object sender, EventArgs e)
        {
            DisplayButton thisbutton = (DisplayButton)sender;

            if (thisbutton.IsInfoFlashing)
            {
                thisbutton.StopInfoFlash();
            }
            else
            {
                thisbutton.StartInfoFlash();
            }

            UpdateSearchButton();
        }
Example #3
0
        // File clicked
        private void filebutton_Click(object sender, EventArgs e)
        {
            // Check if this is a directory
            DisplayButton button    = (sender as DisplayButton);
            int           itemindex = (int)(button.Tag);

            if ((itemindex >= 0) && (itemindex < allitems.TotalCount))
            {
                if (allitems[itemindex].isdirectory)
                {
                    currentpath   = allitems[itemindex].filepathname;
                    searchresults = false;
                    RefreshDirButtons();
                    RefreshFilesList(true);
                }
                else
                {
                    // Select the file
                    for (int i = 0; i < numbuttons; i++)
                    {
                        if (filebuttons[i] == button)
                        {
                            if (itemselected[itemindex])
                            {
                                // Deselect
                                filebuttons[i].StopInfoFlash();
                                itemselected[itemindex] = false;
                            }
                            else
                            {
                                // Select
                                filebuttons[i].StartInfoFlash();
                                itemselected[itemindex] = true;
                            }

                            break;
                        }
                    }

                    UpdateButtons();
                }
            }
        }
Example #4
0
        // Doubleclicking a file
        private void filebutton_DoubleClick(object sender, EventArgs e)
        {
            // Determine index
            DisplayButton button    = (sender as DisplayButton);
            int           realindex = (int)(button.Tag);

            // Make selected state the same for all items
            bool thisstate = itemselected[realindex];

            for (int i = allitems.DirectoryCount; i < allitems.TotalCount; i++)
            {
                itemselected[i] = thisstate;
            }

            // After doubleclick there is another click event which must select this one
            itemselected[realindex] = !itemselected[realindex];

            UpdateFileItems();
            UpdateButtons();
        }
Example #5
0
        // A quick item is clicked
        private void quickitem_Click(object sender, EventArgs e)
        {
            DisplayButton quickitembutton = (DisplayButton)sender;

            int index = GetIndexByName(quickitembutton.Text);

            if (index > -1)
            {
                items[index].count++;
                items[index].SqlUpdateOrInsert(false);
            }
            else
            {
                GroceriesItem newitem = new GroceriesItem();
                newitem.name  = quickitembutton.Text;
                newitem.count = 1;
                newitem.list  = selectedlist;
                newitem.SqlUpdateOrInsert(true);
                items = General.Groceries.GetAllItems(selectedlist).ToArray();
            }

            RefreshMainItems();
        }
Example #6
0
        // This sets up the directory buttons for the current path
        private void RefreshDirButtons()
        {
            bool          titlehidden   = false;
            DisplayButton lastdirbutton = rootbutton;

            if (searchresults)
            {
                // Hide all buttons
                for (int i = 0; i < dirbuttons.Length; i++)
                {
                    dirbuttons[i].Visible = false;
                }

                // Setup buttons for search results
                dirbuttons[0].Visible   = true;
                dirbuttons[0].Text      = "Search results for \"" + searchstring + "\"";
                dirsizelabel.Text       = dirbuttons[0].Text;
                dirbuttons[0].Width     = Math.Min(dirsizelabel.Width, titlelabel.Left - dirbuttons[0].Left - 20);
                dirbuttons[0].Clickable = false;
                lastdirbutton           = dirbuttons[0];
            }
            else
            {
                // Figure out path parts
                string proot = Path.GetFullPath(General.Settings.LibraryRoot);
                string pcur  = Path.GetFullPath(currentpath);

                if (!pcur.StartsWith(proot))
                {
                    throw new Exception("Current path does not contain root path. Fix me!");
                }

                string relpath = pcur.Substring(proot.Length);
                relpath.Trim(Path.DirectorySeparatorChar);

                string[] pathparts;
                if (relpath.Length > 0)
                {
                    pathparts = relpath.Split(Path.DirectorySeparatorChar);
                }
                else
                {
                    pathparts = new string[0];
                }

                if (pathparts.Length > dirbuttons.Length)
                {
                    throw new Exception("Paths longer than " + dirbuttons.Length + " directories deep are not supported. Fix me!");
                }

                // Setup buttons
                for (int i = 0; i < dirbuttons.Length; i++)
                {
                    if (i < pathparts.Length)
                    {
                        dirsizelabel.Text = pathparts[i];
                        int width = Math.Min(dirsizelabel.Width, 300);
                        dirbuttons[i].Text      = pathparts[i];
                        dirbuttons[i].Visible   = true;
                        dirbuttons[i].Width     = width;
                        dirbuttons[i].Clickable = true;
                        if (i > 0)
                        {
                            dirbuttons[i].Left = dirbuttons[i - 1].Right + dirbuttons[i].Margin.Left + dirbuttons[i - 1].Margin.Right;
                        }
                        if (dirbuttons[i].Right > 777)
                        {
                            if (dirbuttons[i].Left > 1150)
                            {
                                // No room to display this button
                                dirbuttons[i].Visible = false;
                            }
                            else
                            {
                                // We have to hide the title to make room or the directory buttons
                                titlehidden = true;
                                if (dirbuttons[i].Right > barend.Left)
                                {
                                    dirbuttons[i].Width = barend.Left - dirbuttons[i].Left - barend.Margin.Left - barend.Margin.Right;
                                }
                                lastdirbutton = dirbuttons[i];
                            }
                        }
                        else
                        {
                            lastdirbutton = dirbuttons[i];
                        }
                    }
                    else
                    {
                        dirbuttons[i].Visible = false;
                    }
                }
            }

            // Adjust title label and directory filler
            titlelabel.Visible = !titlehidden;
            int fillerrightalign = titlehidden ? barend.Left : fillerright.Left;

            directoryfiller.Left  = lastdirbutton.Right + directoryfiller.Margin.Left + lastdirbutton.Margin.Right;
            directoryfiller.Width = fillerrightalign - directoryfiller.Left;
        }