예제 #1
0
 static DeveloperFactory()
 {
     c_Factory = new MonitorBasedDeveloperFactory();
 }
예제 #2
0
파일: MainForm.cs 프로젝트: ForNeVeR/pnet
        /// <summary>
        /// Create the developers.
        /// </summary>
        private bool CreateDevelopers()
        {
            int x;

            FileInfo[]       files;
            DeveloperView    view;
            DeveloperFactory factory;
            Random           random = new Random();
            Developer        first, prev, developer;
            DirectoryInfo    dirInfo = new DirectoryInfo(Environment.CurrentDirectory);

            factory = DeveloperFactory.GetFactory();

            prev = first = developer = null;

            files = dirInfo.GetFiles();

            for (int i = 0; i < files.Length; i++)
            {
                FileInfo fileinfo;

                x = random.Next(i, files.Length - 1);

                fileinfo = files[i];
                files[i] = files[x];
                files[x] = fileinfo;
            }

            for (int i = 0; i < files.Length; i++)
            {
                Match  match;
                string filename, name;

                name = files[i].Name;

                match = fileNameRegex.Match(name);

                if (match.Length == 0)
                {
                    continue;
                }

                filename = match.Groups["filename"].Value;
                name     = match.Groups["name"].Value;


                m_NumberOfDevelopers++;

                Console.WriteLine("Found " + files[i].Name);

                developer               = factory.NewDeveloper(name, prev, null, this);
                developer.CodingDelay   = m_CodingDelay;
                developer.ThinkingDelay = m_ThinkingDelay;

                if (prev != null)
                {
                    prev.Right = developer;
                }

                if (m_NumberOfDevelopers == 1)
                {
                    first = developer;
                }

                view = new DeveloperView(developer, files[i].FullName);

                mainPanel.Controls.Add(view);

                m_DefaultDeveloperWidth  = view.Width;
                m_DefaultDeveloperHeight = view.Height;

                prev = developer;
            }

            if (m_NumberOfDevelopers < 1)
            {
                string message = "No developer pictures found.";

#if CONFIG_SMALL_CONSOLE
                Console.WriteLine(message);
#else
                Console.Error.WriteLine(message);
#endif
                MessageBox.Show(message);

                Application.Exit();

                return(false);
            }

            first.Left      = developer;
            developer.Right = first;

            return(true);
        }
		static DeveloperFactory()
		{
			c_Factory = new MonitorBasedDeveloperFactory();
		}