示例#1
0
        public MainForm()
        {
            InitializeComponent();

            SongUpdateMutex = new Mutex();
            TaskMutex       = new Mutex();

            Platforms        = new List <PlatformData>();
            ProgressList     = new List <TaskScheduler>();
            ProgressControls = new Dictionary <TaskScheduler, ProgressItem>();

            RootPath = Environment.CurrentDirectory;
            Configuration.Load(this);

            try {             // It may be in use by another instance... So you get no logs, too bad.
                LogStream           = new StreamWriter(new FileStream(Path.Combine(RootPath, "rawksd.log"), FileMode.Create, FileAccess.Write, FileShare.Read));
                LogStream.AutoFlush = true;
                LogStream.WriteLine("RawkSD started at " + DateTime.Now.ToString());
                Console.SetOut(LogStream);
            } catch (Exception exception) {
                Exceptions.Warning(exception, "Unable to use the log file; another RawkSD instance is probably still running.");
            }

            ImportMap.RootPath = Path.Combine(RootPath, "importdata");

            if (!Path.IsPathRooted(Configuration.LocalPath))
            {
                StoragePath = Path.Combine(RootPath, Configuration.LocalPath);
            }
            else
            {
                StoragePath = Configuration.LocalPath;
            }
            if (!Path.IsPathRooted(Configuration.TemporaryPath))
            {
                TemporaryPath = Path.Combine(RootPath, Configuration.TemporaryPath);
            }
            else
            {
                TemporaryPath = Configuration.TemporaryPath;
            }

            Directory.CreateDirectory(TemporaryPath);
            TemporaryStream.BasePath = TemporaryPath;

            for (int i = 0; i < Configuration.MaxConcurrentTasks; i++)
            {
                AddTaskScheduler();
            }

            Tiers    = new Image[7];
            Tiers[0] = Properties.Resources.TierZero;
            Tiers[1] = Properties.Resources.TierOne;
            Tiers[2] = Properties.Resources.TierTwo;
            Tiers[3] = Properties.Resources.TierThree;
            Tiers[4] = Properties.Resources.TierFour;
            Tiers[5] = Properties.Resources.TierFive;
            Tiers[6] = Properties.Resources.TierSix;

            AlbumImage = WiiImage.Create(new EndianReader(new MemoryStream(RawkSD.Properties.Resources.rawksd_albumart), Endianness.LittleEndian)).Bitmap;

            SongList.DoubleBuffer();

            SongList_SelectedIndexChanged(this, EventArgs.Empty);
        }