public MainFormController(ICCTrayMultiConfiguration configuration, ISynchronizeInvoke owner, MainForm mainForm)
		{
            this.mainForm = mainForm;
			this.configuration = configuration;

			serverMonitors = configuration.GetServerMonitors();
			for (int i = 0; i < serverMonitors.Length; i++)
			{
				serverMonitors[i] = new SynchronizedServerMonitor(serverMonitors[i], owner);
			}
			aggregatedServerMonitor = new AggregatingServerMonitor(serverMonitors);
			queueIconProvider = new ResourceIntegrationQueueIconProvider();

			projectMonitors = configuration.GetProjectStatusMonitors(serverMonitors);
			execRunners = new BuildTransitionExecRunner[projectMonitors.Length];
			for (int i = 0; i < projectMonitors.Length; i++)
			{
				execRunners[i] = new BuildTransitionExecRunner(projectMonitors[i], configuration.Execs);
				projectMonitors[i] = new SynchronizedProjectMonitor(projectMonitors[i], owner);
			}
			aggregatedProjectMonitor = new AggregatingProjectMonitor(projectMonitors);
			projectStateIconProvider = new ConfigurableProjectStateIconProvider(configuration.Icons);
			projectStateIconAdaptor = new ProjectStateIconAdaptor(aggregatedProjectMonitor, projectStateIconProvider);
			soundPlayer = new BuildTransitionSoundPlayer(aggregatedProjectMonitor, new AudioPlayer(), configuration.Audio);
			LampController lampController = new LampController(configuration.X10,null);
			x10Controller = new X10Controller(aggregatedProjectMonitor,new DateTimeProvider(),configuration.X10,lampController);
			
			growlController = new GrowlController(aggregatedProjectMonitor, configuration.Growl);

#if !DISABLE_COM
			IBalloonMessageProvider balloonMessageProvider = new ConfigurableBalloonMessageProvider(configuration.BalloonMessages);
			speakerForTheDead = new SpeakingProjectMonitor(aggregatedProjectMonitor, balloonMessageProvider, configuration.Speech);
#endif
		}
示例#2
0
        static void Main()
        {
            Application.EnableVisualStyles();
            Application.DoEvents();

            try
            {
                ICruiseManagerFactory remoteCruiseManagerFactory = new RemoteCruiseManagerFactory();
                ICruiseProjectManagerFactory cruiseProjectManagerFactory = new CruiseProjectManagerFactory( remoteCruiseManagerFactory );
                CCTrayMultiConfiguration configuration = new CCTrayMultiConfiguration( cruiseProjectManagerFactory, GetSettingsFilename() );

                MainForm mainForm = new MainForm(configuration);

                Application.Run(mainForm);
            }
            catch (Exception ex)
            {
                MessageBox.Show("Failed to start: " + ex, AppDomain.CurrentDomain.FriendlyName);
            }
        }
        public CCProjectsViewMgr(MainForm form, ImageList large, ImageList small)
            : base()
        {
            mainForm = form;
            this.SuspendLayout();
            largeImageList = large;
            smallImageList = small;


            CCProjectsViewMgrPanel = new System.Windows.Forms.Panel();
            CCProjectsViewMgrPanel.Tag = this;
            Controls.Add(CCProjectsViewMgrPanel);
            CCProjectsViewMgrPanel.Location = new System.Drawing.Point(0, 0);
            CCProjectsViewMgrPanel.Name = "CCProjectsViewMgrPanel";
            CCProjectsViewMgrPanel.BackColor = Color.AliceBlue;

            CCProjectsViewMgrPanel.MouseDoubleClick += new MouseEventHandler(CCProjectsViewMgrPanel_MouseDoubleClick);

            CCProjectsViewMgrPanel.Dock = DockStyle.Fill;

            // project views are added to the tabcontrol so it needs to be created first

            m_tabControl = new TabControl();
            m_tabControl.SuspendLayout();
            m_tabControl.Name = "tabControl";
            m_tabControl.SelectedIndex = 0;
            m_tabControl.TabIndex = 0;
            m_tabControl.MouseUp += new MouseEventHandler(TabControl_MouseUp);
            m_tabControl.MouseClick += new MouseEventHandler(CCProjectsViewMgr_MouseClick);
            m_tabControl.AllowDrop = true;
            m_tabControl.DragEnter += new DragEventHandler(TabControl_DragEnter);
            m_tabControl.DragDrop += new DragEventHandler(TabControl_DragDrop);
            m_tabControl.DragOver += new DragEventHandler(TabControl_DragOver);
            m_tabControl.DragLeave += new EventHandler(m_tabControl_DragLeave);
            m_tabControl.Dock = DockStyle.Fill;
            m_tabControl.ImageList = smallImageList;
            CCProjectsViewMgrPanel.Controls.Add(m_tabControl);

            form.DragEnter += new DragEventHandler(form_DragEnter);

            // create the container of views
            m_projectViews = new List<CCProjectsView>();

            // the 'all' view always has all the projects the user has subscribed to
            m_all = new CCProjectsView(this, "All");
            m_all.IsUserView = false;

            AddView(m_all);


            // the 'broken' view is dynamically updated with any broken projects
            m_broken = new CCProjectsView(this, "Broken");
            m_broken.IsUserView = false;
            m_broken.IsReadOnly = false;
            m_broken.TabPage.ImageIndex = ProjectState.Broken.ImageIndex;
            m_broken.TabPage.TabIndex = 1;

            // we don't add it to make  iterating over 'real' views more easy
            AddView(m_broken);

            this.ResumeLayout(false);
            m_tabControl.ResumeLayout(false);

            form.dummyDockingPanel.Controls.Add(CCProjectsViewMgrPanel);

            #region // menus

            projectContextMenu = new System.Windows.Forms.ContextMenuStrip();

            mnuForce = new System.Windows.Forms.ToolStripMenuItem();
            mnuAbort = new System.Windows.Forms.ToolStripMenuItem();
            mnuStart = new System.Windows.Forms.ToolStripMenuItem();
            mnuStop = new System.Windows.Forms.ToolStripMenuItem();
            mnuWebPage = new System.Windows.Forms.ToolStripMenuItem();
            mnuCancelPending = new System.Windows.Forms.ToolStripMenuItem();
            mnuFixBuild = new System.Windows.Forms.ToolStripMenuItem();
            mnuCopyBuildLabel = new System.Windows.Forms.ToolStripMenuItem();
            mnuSendToNewTab = new System.Windows.Forms.ToolStripMenuItem();
            mnuCreateTabFromPattern = new System.Windows.Forms.ToolStripMenuItem();
            mnuCreateTabFromCategory = new System.Windows.Forms.ToolStripMenuItem();

            projectContextMenu.Items.AddRange(new System.Windows.Forms.ToolStripMenuItem[] 
         {
            mnuForce,
            mnuAbort,
            mnuStart,
            mnuStop,
            mnuWebPage,
            mnuCancelPending,
            mnuFixBuild,
            mnuCopyBuildLabel,
            mnuSendToNewTab,
            mnuCreateTabFromPattern,
            mnuCreateTabFromCategory
         });

            mnuForce.Text = "&Force Build";
            mnuForce.Click += new System.EventHandler(mnuForce_Click);
            mnuAbort.Text = "&Abort Build";
            mnuAbort.Click += new System.EventHandler(mnuAbort_Click);
            mnuStart.Text = "&Start Project";
            mnuStart.Click += new System.EventHandler(mnuStart_Click);
            mnuStop.Text = "&Stop Project";
            mnuStop.Click += new System.EventHandler(mnuStop_Click);
            mnuWebPage.Text = "Display &Web Page";
            mnuWebPage.Click += new System.EventHandler(mnuWebPage_Click);
            mnuCancelPending.Text = "&Cancel Pending";
            mnuCancelPending.Click += new System.EventHandler(mnuCancelPending_Click);
            mnuFixBuild.Text = "&Volunteer to Fix Build";
            mnuFixBuild.Click += new System.EventHandler(mnuFixBuild_Click);
            mnuCopyBuildLabel.Text = "Copy Build &Label";
            mnuCopyBuildLabel.Click += new System.EventHandler(mnuCopyBuildLabel_Click);

            mnuSendToNewTab.Text = "Send to New &Tab";
            mnuSendToNewTab.Click += new EventHandler(mnuSendToNewTab_Click);

            mnuCreateTabFromPattern.Text = "New Tab from &Pattern";
            mnuCreateTabFromPattern.Click += new EventHandler(mnuCreateTabFromPattern_Click);

            mnuCreateTabFromCategory.Text = "Create tabs from category";
            mnuCreateTabFromCategory.Click += new EventHandler(mnuCreateTabFromCategory_Click);

            tabContextMenu = new System.Windows.Forms.ContextMenuStrip();
            mnuEditName = new System.Windows.Forms.ToolStripMenuItem();
            mnuDeleteTab = new System.Windows.Forms.ToolStripMenuItem();
            tabContextMenu.Items.AddRange(new System.Windows.Forms.ToolStripMenuItem[] {
                mnuEditName,
                mnuDeleteTab, 
            });

            mnuEditName.Text = "&Rename Tab";
            mnuEditName.Click += new System.EventHandler(mnuEditName_Click);
            mnuDeleteTab.Text = "&Delete Tab";
            mnuDeleteTab.Click += new System.EventHandler(mnuDeleteTab_Click);

            #endregion

            mainForm.MainFormController.BindToViewMgr(this);

            // restore users tabs
            LoadViewConfiguration();

            // colour in the icons on each tab
            UpdateAllTabPageIcons(null);


            // set up the general edit box
            // this needs a tidy up
            m_tb = new TextBox();
            m_tb.PreviewKeyDown += new PreviewKeyDownEventHandler(tb_PreviewKeyDown);
            m_tb.LostFocus += new EventHandler(tb_LostFocus);

            int timerPeriod = mainForm.Configuration.PollPeriodSeconds * 1000;
            m_bTimerRunning = false;
            m_viewUpdate = new System.Threading.Timer(new System.Threading.TimerCallback(UpdateAllTabPageIcons), this, 0, timerPeriod);

            this.Show();
        }