示例#1
0
        public void populateRootElements(Projects projects)
        {
            List <String> names = new List <String>();

            foreach (NugetProject project in projects.projects)
            {
                List <String> projectDependencies = new List <string>();
                Component     comp = new Component()
                {
                    Key    = project.name,
                    Group  = project.name,
                    Issues = new List <Issue>()
                };
                Severity topSeverity = Severity.Unknown;
                if (project.dependencies != null && project.dependencies.Length > 0)
                {
                    foreach (Dependency dep in project.dependencies)
                    {
                        Component depComponent = getComponent(dep);
                        if (Severities.Contains(depComponent.TopSeverity))
                        {
                            projectDependencies.Add(depComponent.Key);
                        }
                        topSeverity = getTopComponentSeverity(topSeverity, depComponent);
                        foreach (Issue issue in depComponent.Issues)
                        {
                            if (!comp.Issues.Contains(issue))
                            {
                                comp.Issues.Add(issue);
                            }
                        }
                    }
                }

                comp.TopSeverity  = topSeverity;
                comp.Dependencies = projectDependencies;
                names.Add(project.name);
                // Adding to the data service components the project itself
                if (!getComponents().ContainsKey(comp.Key))
                {
                    getComponents().Add(comp.Key, comp);
                }
                else
                {
                    if (!getComponents().ContainsValue(comp))
                    {
                        //New value for the same key
                        getComponents().Remove(comp.Key);
                        getComponents().Add(comp.Key, comp);
                    }
                }
            }

            RootElements.Clear();
            foreach (String name in names)
            {
                RootElements.Add(name);
            }
        }
 public virtual void InitElements()
 {
     RootElements.Clear();
     AllElements.Clear();
     foreach (var cell in Current.ForEach())
     {
         Init(cell);
     }
     if (MouseMoveElement != null)
     {
         AddAndInitElement(MouseMoveElement);
     }
     if (Text != null)
     {
         AddAndInitElement(Text);
     }
 }
示例#3
0
 protected internal virtual void EnsureAllElementsContained()
 {
     foreach (var element in this.Descendants())
     {
         foreach (var referenced in element.ReferencedElements)
         {
             var ancestor = referenced;
             while (ancestor.Parent != null)
             {
                 ancestor = ancestor.Parent;
             }
             if (ancestor.Model == null)
             {
                 RootElements.Add(ancestor);
             }
         }
     }
 }
示例#4
0
 protected override string GetRelativePathForNonIdentifiedChild(IModelElement child)
 {
     if (RootElements.Count == 1 && PromoteSingleRootElement)
     {
         return(null);
     }
     else
     {
         var index = RootElements.IndexOf(child);
         if (index != -1)
         {
             return("/" + index.ToString());
         }
         else
         {
             return(null);
         }
     }
 }
示例#5
0
        public UmmApp(string[] cmdLineArgs) : base(cmdLineArgs)
        {
            Instance   = this;
            AppVersion = UmmVersion.String;
            AboutIcon  = MmeMuxer.Properties.Resources.UMMIcon;

            var manageJobsTab = new TabItem();

            manageJobsTab.Header  = "Manage Jobs";
            manageJobsTab.Content = CreateJobsTab();

            var settingsTab = new TabItem();

            settingsTab.Header  = "Settings";
            settingsTab.Content = CreateSettingsTab();

            var progressTab = new TabItem();

            ProgressTab         = progressTab;
            progressTab.Header  = "Progress";
            progressTab.Content = CreateProgressTab();

            var tabControl = new TabControl();

            TabControl = tabControl;
            tabControl.HorizontalAlignment = HorizontalAlignment.Stretch;
            tabControl.VerticalAlignment   = VerticalAlignment.Stretch;
            tabControl.Margin = new Thickness(5);
            tabControl.Items.Add(manageJobsTab);
            tabControl.Items.Add(settingsTab);

            var exitMenuItem = new MenuItem();

            exitMenuItem.Header  = "E_xit";
            exitMenuItem.Click  += (obj, arg) => OnQuit();
            exitMenuItem.ToolTip = new ToolTip {
                Content = "Close the program"
            };

            /*
             * var openFolderMenuItem = new MenuItem();
             * openFolderMenuItem.Header = "Open MME Mux Folder...";
             * openFolderMenuItem.Click += (obj, arg) => OnOpenMuxFolder();
             * openFolderMenuItem.ToolTip = new ToolTip { Content = "Open a demo folder for processing/analysis" };
             */
            var fileMenuItem = new MenuItem();

            fileMenuItem.Header = "_File";
            //fileMenuItem.Items.Add(openFolderMenuItem);
            //fileMenuItem.Items.Add(new Separator());
            fileMenuItem.Items.Add(exitMenuItem);

            var log = new Log(150);

            Log = log;

            var viewHelpMenuItem = new MenuItem();

            viewHelpMenuItem.Header  = "View Online Help";
            viewHelpMenuItem.Click  += (obj, arg) => ViewHelp();
            viewHelpMenuItem.ToolTip = new ToolTip {
                Content = "Opens a new tab with the help in your default web browser"
            };

            var aboutMenuItem = new MenuItem();

            aboutMenuItem.Header  = "_About Uber MME Muxer";
            aboutMenuItem.Click  += (obj, arg) => ShowAboutWindow();
            aboutMenuItem.ToolTip = new ToolTip {
                Content = "Learn more about this awesome application"
            };

            var helpMenuItem = new MenuItem();

            helpMenuItem.Header = "_Help";
            helpMenuItem.Items.Add(viewHelpMenuItem);
            helpMenuItem.Items.Add(new Separator());
            helpMenuItem.Items.Add(aboutMenuItem);

            var mainMenu = new Menu();

            mainMenu.IsMainMenu = true;
            mainMenu.Items.Add(fileMenuItem);
            mainMenu.Items.Add(log.LogMenuItem);
            mainMenu.Items.Add(helpMenuItem);

            var logGroupBox = new GroupBox();

            logGroupBox.HorizontalAlignment = HorizontalAlignment.Stretch;
            logGroupBox.VerticalAlignment   = VerticalAlignment.Stretch;
            logGroupBox.Margin  = new Thickness(5);
            logGroupBox.Header  = "Log";
            logGroupBox.Content = log.LogListBox;

            var progressBar = new ProgressBar();

            ProgressBar = progressBar;
            progressBar.HorizontalAlignment = HorizontalAlignment.Stretch;
            progressBar.VerticalAlignment   = VerticalAlignment.Bottom;
            progressBar.Margin  = new Thickness(5);
            progressBar.Height  = 20;
            progressBar.Minimum = 0;
            progressBar.Maximum = 100;
            progressBar.Value   = 0;

            var cancelJobButton = new Button();

            CancelJobButton = cancelJobButton;
            cancelJobButton.HorizontalAlignment = HorizontalAlignment.Right;
            cancelJobButton.VerticalAlignment   = VerticalAlignment.Center;
            cancelJobButton.Width   = 70;
            cancelJobButton.Height  = 25;
            cancelJobButton.Content = "Cancel";
            cancelJobButton.Click  += (obj, args) => OnCancelJobClicked();

            var progressPanel = new DockPanel();

            progressPanel.HorizontalAlignment = HorizontalAlignment.Stretch;
            progressPanel.VerticalAlignment   = VerticalAlignment.Bottom;
            progressPanel.LastChildFill       = true;
            progressPanel.Children.Add(cancelJobButton);
            progressPanel.Children.Add(progressBar);
            DockPanel.SetDock(cancelJobButton, Dock.Right);

            var progressGroupBox = new GroupBox();

            ProgressGroupBox = progressGroupBox;
            progressGroupBox.HorizontalAlignment = HorizontalAlignment.Stretch;
            progressGroupBox.VerticalAlignment   = VerticalAlignment.Center;
            progressGroupBox.Margin     = new Thickness(5, 0, 5, 0);
            progressGroupBox.Header     = "Progress";
            progressGroupBox.Content    = progressPanel;
            progressGroupBox.Visibility = Visibility.Collapsed;

            var jobsGridView = new GridView();

            jobsGridView.AllowsColumnReorder = false;
            jobsGridView.Columns.Add(new GridViewColumn {
                Header = "Status", Width = 60, DisplayMemberBinding = new Binding("Status")
            });
            jobsGridView.Columns.Add(new GridViewColumn {
                Header = "File or Folder Name", Width = 330, DisplayMemberBinding = new Binding("Name")
            });
            jobsGridView.Columns.Add(new GridViewColumn {
                Header = "Frames", Width = 60, DisplayMemberBinding = new Binding("FrameCount")
            });
            jobsGridView.Columns.Add(new GridViewColumn {
                Header = "Audio?", Width = 50, DisplayMemberBinding = new Binding("HasAudio")
            });
            jobsGridView.Columns.Add(new GridViewColumn {
                Header = "Videos", Width = 60, DisplayMemberBinding = new Binding("VideoCount")
            });

            var jobsListView = new ListView();

            _jobsListView                    = jobsListView;
            _jobsListViewBackground          = jobsListView.Background;
            jobsListView.HorizontalAlignment = HorizontalAlignment.Stretch;
            jobsListView.VerticalAlignment   = VerticalAlignment.Stretch;
            jobsListView.Margin              = new Thickness(5);
            jobsListView.Width               = 570;
            jobsListView.AllowDrop           = true;
            jobsListView.View                = jobsGridView;
            jobsListView.SelectionMode       = SelectionMode.Extended;
            jobsListView.DragEnter          += OnMuxFolderListBoxDragEnter;
            jobsListView.Drop               += OnMuxFolderListBoxDragDrop;
            jobsListView.Initialized        += (obj, arg) => { _jobsListViewBackground = _jobsListView.Background; };
            jobsListView.Foreground          = new SolidColorBrush(Colors.Black);

            var jobsListGroupBox = new GroupBox();

            jobsListGroupBox.Header = "Jobs List";
            jobsListGroupBox.HorizontalAlignment = HorizontalAlignment.Stretch;
            jobsListGroupBox.VerticalAlignment   = VerticalAlignment.Stretch;
            jobsListGroupBox.Margin  = new Thickness(5);
            jobsListGroupBox.Content = jobsListView;

            var centerPartPanel = new DockPanel();

            centerPartPanel.HorizontalAlignment = HorizontalAlignment.Stretch;
            centerPartPanel.VerticalAlignment   = VerticalAlignment.Stretch;
            centerPartPanel.Margin = new Thickness(5);
            centerPartPanel.Children.Add(jobsListGroupBox);
            centerPartPanel.Children.Add(tabControl);
            centerPartPanel.LastChildFill = true;
            DockPanel.SetDock(jobsListGroupBox, Dock.Left);

            var statusBarTextBox = new TextBox();

            statusBarTextBox.HorizontalAlignment = HorizontalAlignment.Stretch;
            statusBarTextBox.VerticalAlignment   = VerticalAlignment.Bottom;
            statusBarTextBox.IsEnabled           = true;
            statusBarTextBox.IsReadOnly          = true;
            statusBarTextBox.Background          = new SolidColorBrush(System.Windows.SystemColors.ControlColor);
            statusBarTextBox.Text = Quotes.GetRandomQuote();

            var rootPanel = new DockPanel();

            RootPanel = rootPanel;
            rootPanel.HorizontalAlignment = HorizontalAlignment.Stretch;
            rootPanel.VerticalAlignment   = VerticalAlignment.Stretch;
            rootPanel.LastChildFill       = true;
            AddRootElement(statusBarTextBox);
            AddRootElement(logGroupBox);
            AddRootElement(progressGroupBox);
            AddRootElement(mainMenu);
            AddRootElement(centerPartPanel);
            DockPanel.SetDock(mainMenu, Dock.Top);
            DockPanel.SetDock(centerPartPanel, Dock.Top);
            DockPanel.SetDock(statusBarTextBox, Dock.Bottom);
            DockPanel.SetDock(logGroupBox, Dock.Bottom);
            DockPanel.SetDock(progressGroupBox, Dock.Bottom);
            RootElements.Remove(progressGroupBox); // Only the cancel button can remain active at all times.

            AltListBoxBg.ApplyTo(_jobsListView);
            AltListBoxBg.ApplyTo(log.LogListBox);

            var label = new Label {
                Content = "You can drag'n'drop files and folders here.", HorizontalAlignment = HorizontalAlignment.Center, VerticalAlignment = VerticalAlignment.Center
            };
            var brush = new VisualBrush(label)
            {
                Stretch = Stretch.None, Opacity = 0.5
            };

            _jobsListView.Background = brush;

            CreateWindow();

            LogInfo("UMM version " + UmmVersion.String + " is now operational!");

            ProcessCommandLine(cmdLineArgs);

            RunApplication();
        }