Example #1
0
        private void MainWindowLoader()
        {
            ThumbPanel.Children.Clear();
            projects = PM.LoadProjects();
            foreach (var item in projects)
            {
                ProjectThumbViewModel viewModel = new ProjectThumbViewModel
                {
                    Image   = item.GetPreviewPath(),
                    project = item,
                    Title   = item.title
                };
                ProjectThumb thumb = new ProjectThumb(viewModel);

                System.Windows.Controls.ContextMenu cm = this.FindResource("ThumbContextMenu") as System.Windows.Controls.ContextMenu;
                foreach (System.Windows.Controls.MenuItem cmItem in cm.Items)
                {
                    cmItem.Click += HandleMenuitem;
                }
                thumb.ContextMenu = cm;
                //(thumb.ContextMenu.Items[0] as System.Windows.Controls.MenuItem).Click += HandleMenuitem;
                thumb.MouseDown += ThumbClick;
                ThumbPanel.Children.Add(thumb);
            }
            if (!projects.Contains(currProject) && projects.Count() > 0)
            {
                SelectProject(projects.Last());
            }
            if (projects.Count() < 1)
            {
                Reset();
            }
        }
Example #2
0
        private void HandleMenuitem(object sender, RoutedEventArgs e)
        {
            System.Windows.Controls.MenuItem    menuItem = e.Source as System.Windows.Controls.MenuItem;
            System.Windows.Controls.ContextMenu parent;
            if (menuItem.Parent is System.Windows.Controls.ContextMenu)
            {
                parent = menuItem.Parent as System.Windows.Controls.ContextMenu;
            }
            else
            {
                parent = (menuItem.Parent as  System.Windows.Controls.MenuItem).Parent as System.Windows.Controls.ContextMenu;
            }
            ProjectThumb thumb    = parent.PlacementTarget as ProjectThumb;
            var          project  = thumb.project;
            var          ItemName = menuItem.Name;

            switch (ItemName)
            {
            case "Play":
                Play(project);
                break;

            case "ShareAsZip":
                ShareZip(project);
                break;

            case "UploadFileIo":
                UploadFileio(project);
                break;

            case "Delete":
                DeleteProject(project);
                break;
            }
        }