Example #1
0
 public SPListItem AddItem(String text, Uri uri, Image icon)
 {
     SPListItem c = new SPListItem(this);
     c.Text = text;
     c.Uri = uri;
     c.Icon = icon;
     this.Items.Add(c);
     return c;
 }
Example #2
0
        public SPListItem AddItem(String text, Uri uri)
        {
            SPListItem c = new SPListItem(this);
            c.Text = text;
            c.Uri = uri;

            this.Items.Add(c);
            return c;
        }
Example #3
0
        private void ListDirectory(String project, DirectoryInfo Dir, SPListItem item,ref String path)
        {
            SPListItem add_file = item.AddItem("Add File", new Uri("spotdev:project:" + project + ":" + path + "#AddFile"), Resources.ic_add);
            SPListItem add_folder = item.AddItem("Add Folder", new Uri("spotdev:project:" + project + ":" + path + "#AddFile"), Resources.ic_add);

            // Show all directories
            foreach (DirectoryInfo directory in Dir.GetDirectories())
            {
                String sub_path = path + ":" + directory.Name;
                SPListItem dir = item.AddItem(directory.Name, new Uri("spotdev:project:" + project + ":" + sub_path + ":"), Resources.folder);
                ListDirectory(project, directory, dir, ref sub_path);
            }
            // Show all directories
            foreach (FileInfo file in Dir.GetFiles())
            {
                String sub_path = path + ":" + file.Name;
                SPListItem dir = item.AddItem(file.Name, new Uri("spotdev:project:" + project + ":" + sub_path + ":"), Resources.folder);
                switch (file.Extension)
                {
                    case ".js":

                        dir.Icon = Resources.script;
                        break;
                     case ".json":

                        dir.Icon = Resources.ic_settings;
                        break;
                    default:
                        dir.Icon = Resources.ic_doc_spotify;
                        break;
                }

            }
        }
Example #4
0
        private void checkItem(SPListItem Item, MouseEventArgs e, ref int level, ref int pos)
        {
            if (e.Y > pos && e.Y < pos + ItemHeight)
            {

                Item.Selected = true;
                SPListItemEventArgs args = new SPListItemEventArgs();
                args.Item = Item;
                this.ItemSelected(this, args);
            }
            pos += ItemHeight;
            // If has subitems draw them
            if (Item.Expanded)
                foreach (SPListItem subItem in Item.Children)
                {
                    level += 16;
                    checkItem(subItem, e, ref level, ref pos);
                    level -= 16;
                }
        }
Example #5
0
        private void touchItem(SPListItem Item, MouseEventArgs e, ref int level, ref int pos)
        {
            if (e.Y > pos && e.Y < pos + ItemHeight)
            {

                // If clicked on expander
                if (e.X < level + 17 && Item.Children.Count > 0)
                {
                    Item.Expanded = !Item.Expanded;
                    pos += ItemHeight;
                    expanding = true;
                    return;
                }

                Item.Touched = true;
            }
            pos += ItemHeight;
            // If has subitems draw them
            if (Item.Expanded)
                foreach (SPListItem subItem in Item.Children)
                {
                    level += 16;
                    touchItem(subItem, e, ref level, ref pos);
                    level -= 16;
                }
        }
Example #6
0
        /// <summary>
        /// Draw item and sub-Items
        /// </summary>
        /// <param name="Item"></param>
        /// <param name="pos"></param>
        /// <param name="level"></param>
        private void drawItem(Graphics g, SPListItem Item, ref int pos, ref int level)
        {
            Color foreColor = Item.CustomColor ? Item.Color : Program.Skin.ForegroundColor;
            if (Item.Text.StartsWith("#"))
            {
                foreColor = Color.FromArgb(150,150,150);
                g.DrawString(Item.Text.ToUpper().Replace("#", ""), new Font("MS Sans Serif", 8), new SolidBrush(Color.FromArgb(50,50,50)), new Point(4, pos + 0));
                g.DrawString(Item.Text.ToUpper().Replace("#", ""), new Font("MS Sans Serif", 8), new SolidBrush(foreColor), new Point(4, pos + 1));
            }
            else
            {

                if (Item.Selected)
                {

                    g.DrawImage(Resources.menu_selection, 0, pos, this.Width * 500, Resources.menu_selection.Height);

                    foreColor = Program.Skin.SelectedForeColor;
                }
                else if (Item.Touched)
                {
                    g.FillRectangle(new SolidBrush(Color.Gray), 0, pos, this.Width, ItemHeight);
                }
                else
                {
                    g.DrawString(Item.Text, new Font("MS Sans Serif", 8), new SolidBrush(Color.FromArgb(10, 10, 10)), new Point(level + 32, pos + 3));
                }
                g.DrawString(Item.Text, new Font("MS Sans Serif", 8), new SolidBrush(foreColor), new Point(level+32, pos + 2));
                if (Item.Icon != null)
                {
                    g.DrawImage(Item.Icon, level+16, pos +1, 16, 16);
                }
                // If has subItems create expander
                if (Item.Children.Count > 0)
                {
                    Image expander = Item.Expanded ? Resources.ic_expander_open : Resources.ic_expander_closed;
                    g.DrawImage(expander, level, pos, 16, 16);
                }
            }
            pos += ItemHeight;
            // If has subitems draw them
            if(Item.Expanded)
                foreach (SPListItem subItem in Item.Children)
                {
                    level += 16;
                    drawItem(g, subItem, ref pos, ref level);
                    level -= 16;
                }
        }
Example #7
0
 private void deselectTouchItem(SPListItem item)
 {
     item.Touched = false;
     foreach (SPListItem subItem in item.Children)
     {
         deselectTouchItem(subItem);
     }
 }
Example #8
0
 public SPListItem AddItem(String text, Uri uri)
 {
     SPListItem c = new SPListItem(this.Parent);
     c.Text = text;
     c.Uri = uri;
     this.Children.Add(c);
     return c;
 }