示例#1
0
        /// <summary>
        /// Updates the ID3 tags for the song file, then moves it into iTunes if the setting is enabled.
        /// </summary>
        public override bool Finish(bool close = true)
        {
            View.Report("Finalizing");
            try
            {
                UpdateId3Tags();
                AddToiTunes();
            }
            catch (Exception e)
            {
                // Should have been handled already
                View.Report("Invalid file!", true);
                CrashHandler.Throw("Invalid file was downloaded!", e);
                return(false);
            }

            // Log the song genre to see how SDownload is used
            if (Genre != null && !Genre.Equals(String.Empty))
            {
                BugSenseHandler.Instance.SendEventAsync(Genre);
            }

            base.Finish(close);
            return(true);
        }
示例#2
0
        public override bool FinishedLaunching(UIApplication app, NSDictionary options)
        {
            global::Xamarin.Forms.Forms.Init();

            // Code for starting up the Xamarin Test Cloud Agent
                        #if ENABLE_TEST_CLOUD
            Xamarin.Calabash.Start();
                        #endif

            Insights.Initialize("4cdef01b1dc979920d5d485896d5fe50e9c752a6");
            Insights.Track("iOS/Start");

            Ubertesters.Shared.InitializeWithOptions(UbertestersOptions.ActivationModeWidget | UbertestersOptions.LockingModeDisableUbertesters);
            AppDomain.CurrentDomain.UnhandledException += (object sender, UnhandledExceptionEventArgs e) => {
                CrashHandler.PostCrash(e);
            };

            App.Version          = GetBuildNumber();
            App.ClipboardService = new ClipboardService();

            LoadApplication(new App());

            UIApplication.SharedApplication.IdleTimerDisabled = true;

            return(base.FinishedLaunching(app, options));
        }
示例#3
0
        protected override void Run()
        {
            try
            {
                //Sys.Thread TBAR = new Sys.Thread(TaskBar);
                while (running)
                {
                    if (Logged) //If logged
                    {
                        //TBAR.Start();
                        BeforeCommand();

                        AConsole.writecommand = true;

                        var cmd = Console.ReadLine();
                        //TBAR.Stop();
                        CommandManager._CommandManger(cmd);
                        //Console.WriteLine();
                    }
                    else
                    {
                        Login.LoginForm();
                    }
                }
            }
            catch (Exception ex)
            {
                CrashHandler CH = new CrashHandler();
                CH.Whoops(ex);
            }
        }
示例#4
0
        /// <summary>
        /// Parse the given link and send it to the appropriate stream downloader
        /// </summary>
        /// <param name="url">The link provided to the application from the view</param>
        /// <param name="view">The view to report progress back to</param>
        /// <param name="exit">Exit after download?</param>
        public static async void DownloadTrack(String url, InfoReportProxy view, bool exit = false)
        {
            CrashHandler.AddExtra("stream_url", url);
            try
            {
                BaseStream sound;
                if (url.Contains(@"/sets/"))
                    sound = new SCSetStream(url, view);
                else
                    sound = new SCTrackStream(url, view);

                var download = sound.Download();

                if (download != null && await download)
                    sound.Finish();
            }
            catch (Exception e)
            {
                CrashHandler.Throw("There was an issue downloading the stream!", e);
            }
            finally
            {
                CrashHandler.ClearExtras();
                if (exit)
                {
                    Application.Exit();
                }
            }
        }
示例#5
0
        private static string CheckCrash()
        {
            string res = null;

            if (CrashHandler.LastSessionCrashed)
            {
                TaskDialog dialog = new TaskDialog();
                dialog.WindowTitle     = "Warning";
                dialog.MainIcon        = TaskDialogIcon.Warning;
                dialog.MainInstruction = "It seems like a file can be recovered from last session.";
                dialog.Content         = "Would you like to attempt to recover the file?";
                TaskDialogButton saveButton = new TaskDialogButton(ButtonType.Yes);
                saveButton.Text = "Yes";
                dialog.Buttons.Add(saveButton);
                TaskDialogButton noSaveButton = new TaskDialogButton(ButtonType.No);
                noSaveButton.Text = "No";
                dialog.Buttons.Add(noSaveButton);
                TaskDialogButton button = dialog.ShowDialog();
                string           temp   = CrashHandler.RecoverLastSessionFile();
                if (button.ButtonType == ButtonType.Yes)
                {
                    res = temp;
                }
            }
            return(res);
        }
示例#6
0
        public static void ApplySettings(IDebugSettings settings)
        {
            Debug.RemoveAllOutputStreams();
            Debug.RemoveAllPrefixes();

            Debug.PrefixLookupMode = (PrefixLookupSettings)settings.PrefixLookupFlags;

            SeverityFilter = settings.SeverityFilter;

            Debug.AdlEnabled      = settings.Enabled;
            Debug.AdlWarningMask  = 0;
            Debug.CheckForUpdates = settings.SearchForUpdates;
            Debug.AdlWarningMask  = -1;
            Debug.SendWarnings    = settings.SendInternalWarnings;
            Debug.UpdateMask      = -1;

            Debug.SetAllPrefixes(settings.StageNames);

            Debug.AddPrefixForMask(0, "[Silent]");

            foreach (ILogStreamSettings logStreamSettings in settings.Streams)
            {
                Debug.AddOutputStream(OpenStream(logStreamSettings));
            }


            CrashConfig cconf = new CrashConfig();

            cconf.CrashMask       = -1;
            cconf.CheckForUpdates = settings.SearchForUpdates;
            CrashHandler.Initialize(cconf);
        }
 private static void GameTicker_Tick(object sender, EventArgs e)
 {
     try
     {
         gameWnd.Tick++;
         if (gameWnd.Tick == 10)
         {
             gameWnd.OnCreated();
         }
         else if (gameWnd.Tick > 10)
         {
             gameWnd.OnUpdate();
             if (gameWnd.CurrentScene != null)
             {
                 gameWnd.CurrentScene.OnUpdate();
                 CallGameObjectsUpdates();
                 GameWindowBridge.CurrentTick = gameWnd.Tick;
                 OnGameTickEvent?.Invoke(null, null);
             }
         }
     }
     catch (Exception ex)
     {
         gameTicker.Stop();
         CrashHandler?.Crash(ex);
     }
 }
示例#8
0
        /// <summary>
        /// Downloads the necessary files and handles any exceptions
        /// </summary>
        /// <param name="ignoreExtras">If the extra files associated with the main resource should be skipped</param>
        /// <returns>A task representation for keeping track of the method's progress</returns>
        public override async Task <bool> Download(bool ignoreExtras = false)
        {
            var result = await base.Download(ignoreExtras);

            if (!result)
            {
                // If the last attempt was manual, it's impossible
                if (_forceManual)
                {
                    // Can ignore this being called for every reattempt, view will close and ignore
                    View.Report("Impossible! :/", true);

                    // Ignore songs that have streaming blocked and can't be downloaded, throw everything else
                    if (LastException.Message.Contains("401"))
                    {
                        View.Report("Impossible! :/", true);
                    }
                    else
                    {
                        View.Report("Error!", true);
                        CrashHandler.Throw("There was an issue downloading the necessary file(s)!",
                                           LastException);
                    }
                }
                else
                {
                    result = await RetryDownload();
                }
            }
            return(result && await Validate());
        }
示例#9
0
        private void ProcessQueue()
        {
            var token = _tokenSource.Token;

            while (!token.IsCancellationRequested)
            {
                LogMessage logMessage;
                try
                {
                    logMessage = _logQueue.Take(_tokenSource.Token);
                }
                catch (OperationCanceledException)
                {
                    break;
                }

                logMessage.Format();
                try
                {
                    ForwardToLogTarget(logMessage);
                    ForwardToListeners(logMessage);
                }
                catch (Exception ex)
                {
                    // Well, how do we log if the logger throws exceptions. :D
                    CrashHandler.WriteErrorToFile("Caught exception while logging! Exception: " + ex.Message);
                }
            }
        }
示例#10
0
        /// <summary>
        /// Downloads and installs the newest version
        /// </summary>
        /// <param name="size">The size of the new version to download</param>
        private void DownloadAndInstall(int size)
        {
            var downloader   = new DownloadProgressDialog(_fileUrl, size);
            var fileLocation = String.Format("{0}\\sdownload_update.exe", Path.GetTempPath());

            try
            {
                LogUpdate();
            }
            catch (Exception) { }

            if (downloader.Download(fileLocation))
            {
                // Launch the installer and close the running instance
                try
                {
                    Process.Start(fileLocation);
                }
                catch (Exception)
                {
                    CrashHandler.Throw("There was an issue launching the update! You'll need to manually start the file: " + fileLocation, false);
                }
                Close();
                Application.Exit();
            }
            else
            {
                // There was an issue downloading the file
                CrashHandler.Throw("There was an issue downloading the update!", downloader.LastException);
                Close();
            }
        }
示例#11
0
        /// <summary>
        /// Initializes the singleton application object.  This is the first line of authored code
        /// executed, and as such is the logical equivalent of main() or WinMain().
        /// </summary>
        public App()
        {
            this.crashHandler = new CrashHandler(this);

            this.mutex = new Mutex(true, Constants.SyncPrimitiveAppRunningForeground);

            var logHandler = new WinLogHandler();

            LogService.Initialize(logHandler);
            WinSettings winSettings = WinSettings.Instance;

            // check log file rotation once every 5 launches
            if (winSettings.GetValue <int>(CoreSettings.LaunchCount) % 5 == 0)
            {
                logHandler.CheckLogRotationAsync().Wait(TimeSpan.FromMilliseconds(500));
            }

            LogService.Level = winSettings.GetValue <LogLevel>(CoreSettings.LogLevel);

            this.RequestedTheme = winSettings.GetValue <bool>(CoreSettings.UseDarkTheme) ? ApplicationTheme.Dark : ApplicationTheme.Light;

            this.InitializeLanguage(winSettings);

            this.InitializeComponent();

            this.Suspending += this.OnSuspending;
        }
        private static SaveFile DeserializeSaveFile(FileInfo file)
        {
            SaveFile saveFile = null;

            file.Refresh();

            if (!file.Exists)
            {
                CrashHandler.ShowException(new FileNotFoundException("The file " + file.Name + " was not found.", file.Name));

                return(saveFile);
            }

            //Open the save file.
            FileStream fs = new FileStream(file.FullName, FileMode.Open);

            try
            {
                BinaryFormatter formatter = new BinaryFormatter();

                saveFile = (SaveFile)formatter.Deserialize(fs);
            }
            catch (Exception e)
            {
                CrashHandler.ShowException("Failed to deserialize save file. Reason: " + e.Message);
            }
            finally
            {
                fs.Close();
            }

            return(saveFile);
        }
示例#13
0
        public static void Crash(Exception ex, bool recoverable)
        {
            CrashHandler.Log(ex, 0);

            if (!recoverable || ThrowOnAllExceptions)
            {
                throw ex;
            }
        }
示例#14
0
        public override bool FinishedLaunching(UIApplication app, NSDictionary options)
        {
            Ubertesters.Shared.Initialize();
            AppDomain.CurrentDomain.UnhandledException += (object sender, UnhandledExceptionEventArgs e) => {
                CrashHandler.PostCrash(e);
            };

            return(true);
        }
示例#15
0
 private void Awake()
 {
     playerControls    = new PlayerControls();
     rb                = GetComponent <Rigidbody>();
     fuel              = GetComponent <Fuel>();
     crashHandler      = GetComponent <CrashHandler>();
     camController     = FindObjectOfType <CameraController>();
     gameStatus        = FindObjectOfType <GameStatus>();
     shipSFXController = GetComponent <ShipSFXController>();
 }
 public override void OnCreate()
 {
     base.OnCreate();
     sInstance = this;
     AppUtils.init(this);
     CrashHandler.getInstance().init(this);
     initPrefs();
     initNightMode();
     //TO DO: initHciCloud();
 }
示例#17
0
        private static void Main(string[] args)
        {
            //ADL Setup
            Debug.DefaultInitialization();
            CrashHandler.Initialize();

            Core.CLI._Main(args);
#if DEBUG
            Console.ReadLine();
#endif
        }
示例#18
0
        public GameBase(OsuMode mode = OsuMode.Unknown)
        {
            startupMode = mode;
            Instance    = this;

            CrashHandler.Initialize();

            //initialise config before everything, because it may be used in Initialize() override.
            Config = new pConfigManager(Instance.PathConfig + "osum.cfg");

            Clock.USER_OFFSET = Config.GetValue("offset", 0);
        }
 /// <summary>
 /// Method to wrap all execution exceptions
 /// </summary>
 /// <param name="environment">Environment to execute</param>
 private static RuntimeErrorCode RunEnvironment(IRunMode environment)
 {
     try
     {
         return(environment.Run());
     }
     catch (Exception ex)
     {
         CrashHandler.HandleCrash(null, new UnhandledExceptionEventArgs(ex, true));
         return(RuntimeErrorCode.Error);
     }
 }
示例#20
0
        /// <summary>
        /// Confirms the file tags can actually be read, proving the file is valid.
        /// TODO: Possibly find a better way to validate more file types quicker
        /// TODO: perhaps by reading the resolved url ending rather than assuming mp3 immediately
        /// </summary>
        /// <returns>True if the file was downloaded correctly and can be modified</returns>
        public override async Task <bool> Validate()
        {
            var   valid = false;
            var   retry = false;
            SFile file  = null;

            try
            {
                // Test if the file is a valid mp3
                file = SFile.Create(MainResource.AbsolutePath);
            }
            catch (CorruptFileException) // File isn't mp3
            {
                try
                {
                    // Check if the file is wma
                    var old = MainResource.AbsolutePath;
                    MainResource.AbsolutePath = MainResource.AbsolutePath.Substring(0,
                                                                                    MainResource.AbsolutePath.Length - 3) + "wma";
                    File.Move(old, MainResource.AbsolutePath);
                    file = SFile.Create(MainResource.AbsolutePath);
                }
                catch (CorruptFileException e) // File isn't any supported type
                {
                    File.Delete(MainResource.AbsolutePath);

                    // If manual has already been attempted, this isn't possible
                    retry = !_forceManual;

                    if (!retry)
                    {
                        View.Report("Error!", true);
                        CrashHandler.Throw("Unable to download a valid song format for editing!", e);
                    }
                }
            }
            finally
            {
                if (file != null)
                {
                    valid = true;
                    file.Dispose();
                }
            }

            // Retry the download if necessary
            if (retry)
            {
                valid = await RetryDownload();
            }

            return(valid);
        }
示例#21
0
        public static void Main(string[] args)
        {
            Application app = new Application(Eto.Platforms.Wpf);

            ChapterManager    chapterManager    = null;
            string            startChapter      = null;
            KanjiInputManager kanjiInputManager = null;
            TranslatorThread  translatorThread  = null;
            MiharuMainWindow  mainWindow        = null;

            try {
                Directory.SetCurrentDirectory(AppDomain.CurrentDomain.BaseDirectory.ToString());

                if (Init.CheckForTesseract())
                {
                    if (Init.CheckForGecko())
                    {
                        translatorThread = TranslatorThread.StartThread();
                    }

                    startChapter = Init.CheckCrash();
                    if (startChapter == null && args.Length > 0 && File.Exists(args [0]))
                    {
                        startChapter = args[0];
                    }

                    kanjiInputManager = new KanjiInputManager();

                    chapterManager = new ChapterManager(kanjiInputManager, translatorThread);

                    mainWindow = new MiharuMainWindow(chapterManager, startChapter);

                    app.Run(mainWindow);
                }
            }
            catch (Exception e) {
                CrashHandler.HandleCrash(chapterManager, e);
                FileInfo crashFileInfo = new FileInfo(Logger.CurrentCrashLog);

                MessageBox.Show("There was a fatal error. Details can be found in the generated crash log:" + Environment.NewLine +
                                crashFileInfo.FullName,
                                "Fatal Error",
                                MessageBoxButtons.OK,
                                MessageBoxType.Error,
                                MessageBoxDefaultButton.OK);
            }
            finally {
                mainWindow?.Close();
                translatorThread?.FinalizeThread();
            }
        }
示例#22
0
        /// <summary>
        /// Used to initialize service dependencies. This method is called before OnInitialize(),
        /// and should include common behavior for a family of services.
        /// When overridden on the family services base, it is recommended to mark it as sealed,
        /// to prevent concrete services from overriding the common behavior.
        /// </summary>
        /// <param name="kernel"></param>
        protected virtual void PreInitialize(IKernel kernel)
        {
            Kernel.Get <SystemInitializer.SystemInitializer>().Init();
            CrashHandler = kernel.Get <ICrashHandler>();
            CrashHandler.Init(OnCrash);

            IWorkloadMetrics workloadMetrics = kernel.Get <IWorkloadMetrics>();

            workloadMetrics.Init();

            var metricsInitializer = kernel.Get <IMetricsInitializer>();

            metricsInitializer.Init();
        }
示例#23
0
        static void Main()
        {
            CrashHandler.Bind();

            try
            {
                using (var game = new Desktop())
                    game.Run();
            }
            catch (Exception e)
            {
                CrashHandler.Report(e);
            }
        }
示例#24
0
        protected override void OnStart()
        {
            Kernel = new StandardKernel(new NinjectSettings {
                ActivationCacheDisabled = true
            });

            var env = HostEnvironment.CreateDefaultEnvironment(ServiceName, InfraVersion, Arguments);

            Kernel.Bind <IEnvironment>().ToConstant(env).InSingletonScope();
            Kernel.Bind <CurrentApplicationInfo>().ToConstant(env.ApplicationInfo).InSingletonScope();

            this.PreConfigure(Kernel, Arguments);
            this.Configure(Kernel);

            Kernel.Get <SystemInitializer>().Init();

            CrashHandler = Kernel.Get <ICrashHandler>();
            CrashHandler.Init(OnCrash);

            IWorkloadMetrics workloadMetrics = Kernel.Get <IWorkloadMetrics>();

            workloadMetrics.Init();

            var metricsInitializer = Kernel.Get <IMetricsInitializer>();

            metricsInitializer.Init();

            if (PerSiloGrainType != null)
            {
                Kernel.Get <OrleansConfigurationBuilder>().GetBuilder()
                .ConfigureServices(service => service.AddGrainService(PerSiloGrainType).AddSingleton(typeof(IPerSiloGrain), PerSiloGrainType));
            }

            this.PreInitialize(Kernel);

            this.OnInitilize(Kernel);

            VerifyConfigurationsIfNeeded(Kernel.Get <MicrodotHostingConfig>(), Kernel.Get <ConfigurationVerificator>());

            this.Warmup(Kernel);

            //don't move up the get should be after all the binding are done
            var log = Kernel.Get <ILog>();

            this.requestListener = Kernel.Get <IRequestListener>();
            this.requestListener.Listen();

            log.Info(_ => _("start getting traffic", unencryptedTags: new { siloName = CurrentApplicationInfo.HostName }));
        }
示例#25
0
        public static SpriteFont GetFont(string path)
        {
            SpriteFont loaded = null;

            try
            {
                loaded = MainGame.Singleton.Content.Load <SpriteFont>(path);
            }
            catch (ContentLoadException e)
            {
                CrashHandler.ShowException(e);
            }

            return(loaded);
        }
示例#26
0
        public static Texture2D GetSprite(string path)
        {
            Texture2D loaded = Missing_Sprite;

            try
            {
                loaded = MainGame.Singleton.Content.Load <Texture2D>(path);
            }
            catch (ContentLoadException e)
            {
                CrashHandler.ShowException(e);
            }

            return(loaded);
        }
示例#27
0
        private void CreateSaveFile()
        {
            //Check if the file name is valid BEFORE trying to create a new save file:
            if (SaveFileController.IsValidFileName(saveFileNameInputField.Text))
            {
                SaveFile saveFile = new SaveFile(saveFileNameInputField.Text, playerNameInputField.Text);

                GameController.NewGame();
                SaveFileController.SaveGame(saveFile);
            }
            else
            {
                CrashHandler.ShowException("Save file name \"" + saveFileNameInputField.Text + "\" is not a valid name.");
            }
        }
示例#28
0
        public BotProgram()
        {
            crashHandler = new CrashHandler();

            //Below normal priority
            //NOTE: Have a setting to set the priority
            Process thisProcess = Process.GetCurrentProcess();
            thisProcess.PriorityBoostEnabled = false;
            thisProcess.PriorityClass = ProcessPriorityClass.BelowNormal;

            ThreadSleepFindFunc = FindThreadSleepTime;

            //Call this to set the application start time
            DateTime start = Application.ApplicationStartTimeUTC;
        }
示例#29
0
        public static SoundEffect GetSoundEffect(string path)
        {
            SoundEffect loaded = null;

            try
            {
                loaded = MainGame.Singleton.Content.Load <SoundEffect>(path);
            }
            catch (ContentLoadException e)
            {
                CrashHandler.ShowException(e);
            }

            return(loaded);
        }
示例#30
0
        /// <summary>
        /// Function that sets up ADL to operate with the DebugLevel enum and more.
        /// </summary>
        private static void InitAdl()
        {
            CrashHandler.Initialize((int)DebugLevel.INTERNAL_ERROR, false);
            Debug.LoadConfig((AdlConfig) new AdlConfig().GetStandard());
            Debug.SetAllPrefixes("[ERRORS]", "[WARNINGS]", "[LOGS]", "[INTERNAL_ERROR]", "[PROGRESS]");
            Debug.AddPrefixForMask(-1, "[ALL]");
            Debug.CheckForUpdates = false;
            Debug.AdlWarningMask  = (int)DebugLevel.WARNINGS;
            lts = new LogTextStream(
                Console.OpenStandardOutput(),
                -1,
                MatchType.MatchAll,
                false);

            Debug.AddOutputStream(lts);
        }
示例#31
0
文件: Event.cs 项目: wach78/Turbofest
        public Event(DateTime ClockStart, DateTime ClockEnd, int ClockRunTime, System.Xml.Linq.XDocument XMLEvents, ref CrashHandler Crash)
        {
            ch = Crash;
            events = new Dictionary<string, List<EventItem>>();
            clock = new PartyClock(ClockStart, ClockEnd, ClockRunTime);
            Util.ShowClock = true;
            sound = new Sound(true);
            text = new Text2D();
            chess = new Chess();
            sf = new Starfield(150);

            intro = new Intro(ref sound, ref text);
            outro = new Outro(ref sound);

            advent = new Advent(ref sound);
            birthday = new Birthday(ref sound, ref text, ref chess);
            xmas = new Christmas(ref sound);
            smurf = new Datasmurf(ref sound, ref text); // random
            dif = new Dif(ref chess, ref sound); // random
            fbk = new Fbk(ref sound); // random
            hw = new Halloween(ref chess, ref sound, 25);
            lucia = new Lucia(ref chess, ref sound);
            newyear = new NewYear();
            richard = new RMS(ref sound, ref text); // random
            scroller = new Scroller(ref chess, ref sf, ref text); // random
            semla = new Semla();
            sune = new SuneAnimation(ref sound, ref text);
            tl = new TurboLogo(ref sound, ref chess, (OpenGL.Util.SpringOrFall.Equals("Spring")? true:false)/*((ClockStart.Month >= 1 && ClockStart.Month <= 8)? false:true)*/ ); // vilken termin är det? jan till början av augusti VT, resten HT... random
            valentine = new Valentine(ref sound);
            wl = new WinLinux(ref chess); //random
            creators = new Self(ref sound); // random
            bb = new BB(ref sound); // random
            GM = new GummiBears(ref sound);
            NDay = new National(ref chess, ref sound);
            easter = new Easter(ref sound);
            hajk = new Hajk(ref sound);
            mid = new Midsummer(ref sound);
            vaf = new Vaffla();
            wp = new Walpurgis();
            crayfish = new CrayFish();

            ts = new TeknatStyle(ref chess, ref sound, ref text);
            m = new Matrix(ref text);
            q = new Quiz(ref text, false, ref sound);
            talepsin = new Talespin(ref sound);
            cd = new ChipAndDale(ref sound, ref chess);
            nerd = new Nerdy(ref chess, ref sound);
            trex = new Trex(ref sound);
            sailormoon = new Sailormoon(ref sound,ref chess);
            gb = new GhostBusters(ref sound);
            zelda = new Zelda(ref sound, ref chess);
            tardis = new Tardis(ref sound);
            f**k = new F**k(ref sound, ref chess);

            silverFang = new SilverFang(ref sound);
            mt = new MoraT(ref sound);

            swine = new Swine(ref chess, ref text);
            tjall = new Tjall(ref chess, ref text);

            ronja = new Ronja(ref sound);
            emil = new Emil(ref sound);
            djungelboken = new Djungelboken(ref sound);
            fabbe = new Fabbe(ref sound);
            drink = new Drink(ref sound);
            frozen = new Frozen(ref sound);

            eventCurrent = null; // event item for events to be triggerd in clock_NewDate
            //randomEvent = new List<string>(new string[] { "starfield", "SuneAnimation", "TurboLogo", "Datasmurf", "WinLinux", "Scroller", "BB", "GummiBears", "TeknatStyle", "Matrix"});
            randomEvent = new List<string>(new string[] { "starfield", "Nerdy", "Talespin", "Sailormoon", "GhostBusters", "Zelda", "Tardis", "F**k", "SilverFang", "MoraT" });
            //new stuff
             List<UtilXML.EventData> ed = UtilXML.Loadeffectdata();

            // TODO: Make a clean list with all events allowed to be used implement so that it is actaully usable instead of a switch at the bottom of this file.
            Dictionary<string, Effect> effects = new Dictionary<string, Effect>()
            {
                {"SuneAnimation", new Effect(sune, ed.Find(e => e.Name == "SuneAnimation"))},
                {"Dif",new Effect(dif, ed.Find(e => e.Name == "Dif"))},
                {"Fbk",new Effect(fbk, ed.Find(e => e.Name == "Fbk"))},
                {"TurboLogo",new Effect(tl, ed.Find(e => e.Name == "TurboLogo"))},
                {"Datasmurf", new Effect(smurf, ed.Find(e => e.Name == "Datasmurf"))},
                {"RMS",new Effect(richard, ed.Find(e => e.Name == "RMS"))},
                {"WinLinux",new Effect(wl, ed.Find(e => e.Name == "WinLinux"))},
                {"Scroller",new Effect(scroller, ed.Find(e => e.Name == "Scroller"))},
                {"Self",new Effect(creators, ed.Find(e => e.Name == "Self"))},
                {"BB",new Effect(bb, ed.Find(e => e.Name == "BB"))},
                {"GummiBears",new Effect(GM, ed.Find(e => e.Name == "GummiBears"))},
                {"Hajk",new Effect(hajk, ed.Find(e => e.Name == "Hajk"))},
                {"TeknatStyle",new Effect(ts, ed.Find(e => e.Name == "TeknatStyle"))},
                {"Matrix",new Effect(m, ed.Find(e => e.Name == "Matrix"))},
                {"Quiz",new Effect(q, ed.Find(e => e.Name == "Quiz"))},
                {"Talespin",new Effect(talepsin, ed.Find(e => e.Name == "Talespin"))},
                {"ChipDale",new Effect(cd, ed.Find(e => e.Name == "ChipDale"))},
                {"Nerdy",new Effect(nerd, ed.Find(e => e.Name == "Nerdy"))},
              /*  {"Trex",new Effect(trex, ed.Find(e => e.Name == "Trex"))},*/
                {"Sailormoon",new Effect(sailormoon, ed.Find(e => e.Name == "Sailormoon"))},
                {"GhostBusters",new Effect(gb, ed.Find(e => e.Name == "GhostBusters"))},
                {"Zelda",new Effect(zelda, ed.Find(e => e.Name == "Zelda"))},
                {"Tardis",new Effect(tardis, ed.Find(e => e.Name == "Tardis"))},
                {"F**k",new Effect(f**k, ed.Find(e => e.Name == "F**k"))},
                {"SilverFang",new Effect(silverFang, ed.Find(e => e.Name == "SilverFang"))},
                {"MoraT",new Effect(mt, ed.Find(e => e.Name == "MoraT"))},
                {"Ronja",new Effect(ronja, ed.Find(e => e.Name == "Ronja"))},
                {"Emil",new Effect(emil, ed.Find(e => e.Name == "Emil"))},
                {"Djungelboken",new Effect(djungelboken, ed.Find(e => e.Name == "Djungelboken"))},
                {"Fabbe",new Effect(fabbe, ed.Find(e => e.Name == "Fabbe"))},
                {"Drink",new Effect(drink, ed.Find(e => e.Name == "Drink"))},
                {"Frozen",new Effect(drink, ed.Find(e => e.Name == "Frozen"))}
            };

            runEffectInMonth = new Dictionary<string, List<objdata>>();

            string[] months = Util.monthlist();
            int counter;
            foreach (KeyValuePair<string, Effect> pair in effects)
            {
                counter = 0;
                foreach (bool b in pair.Value.RunAllowedlist)
                {
                    if (b == true)
                    {
                        if (!runEffectInMonth.ContainsKey(months[counter]))
                        {
                            runEffectInMonth.Add(months[counter], new List<objdata>());
                        }

                        runEffectInMonth[months[counter]].Add(new objdata(pair.Key, pair.Value.Vetolist[counter], pair.Value.Priolist[counter], pair.Value.Runslist[counter]));
                    }
                    counter++;
                }
            }

            clock.NewDate += clock_NewDate; // Event listener

            if (ch.CrashDialogResult == System.Windows.Forms.DialogResult.Yes)
            {
                clock.clock = ch.CrashClock;
            }

            string name, date, type;
            // Event dates setup
            foreach (var item in XMLEvents.Descendants("event"))
            {
                name = item.Element("name").Value;
                date = item.Element("date").Value;
                type = item.Element("type").Value.ToLower();
                EventItem ei = new EventItem(name, type, date);
                if (!events.ContainsKey(date))
                {
                    List<EventItem> list = new List<EventItem>(); // seems most bad in my eyes...
                    events.Add(date, list);
                }

                for (int i = 0; i < events[date].Count; i++)
                {
                    EventItem e = events[date][i];
                    if ("birthday".Equals(e.Type) && "birthday".Equals(ei.Type))
                    {
                        e.Name += "\n\n" + ei.Name;
                        events[date][i] = e;
                    }
                }
                events[date].Add(ei);
                name = date = type = string.Empty;
            }

            // this needs to be fixed nicer...
            if (events.ContainsKey(ClockEnd.ToShortDateString()))
            {
                events[ClockEnd.ToShortDateString()].Clear(); // force this to be top..
                events[ClockEnd.ToShortDateString()].Add( new EventItem("outro", "outro", ClockEnd.ToShortDateString()) );
            }
            else
            {
                events.Add(ClockEnd.ToShortDateString(), new List<EventItem>() { new EventItem("outro", "outro", ClockEnd.ToShortDateString()) });
            }

            // Random effects on dates with no effects and check against new list of allowed things for them...
            DateTime dt = ClockStart;
            bool star = (Util.Rnd.Next(0, 1000) < 500 ? true:false); // make this random at the start too?
            int num = 0;

            while (dt <= ClockEnd)
            {
                date = dt.ToShortDateString();
                if (!events.ContainsKey(date))
                {
                    EventItem ei;

                    if (num == 0 || num == 1)
                    {
                        ei = new EventItem("starfield", "random", date);
                    }
                    else
                    {
                        //ei = new EventItem(randomEvent[Util.Rnd.Next(1, randomEvent.Count)], "random", date);

                        string month = "";
                        if (dt != null)
                            month = dt.Month.ToString();

                        switch (month)
                        {
                            case "1": month = "jan"; break;
                            case "2": month = "feb"; break;
                            case "3": month = "mar"; break;
                            case "4": month = "apr"; break;
                            case "5": month = "maj"; break;
                            case "6": month = "jun"; break;
                            case "7": month = "jul"; break;
                            case "8": month = "aug"; break;
                            case "9": month = "sep"; break;
                            case "10": month = "okt"; break;
                            case "11": month = "nov"; break;
                            case "12": month = "dec"; break;
                        }//switch

                        if (runEffectInMonth.ContainsKey(month))
                        {
                            List<objdata> mobj = runEffectInMonth[month];

                            List<objdata> vetolist = new List<objdata>();
                            List<objdata> novetolist = new List<objdata>();

                            foreach (objdata n in mobj)
                            {

                                if ("Quiz".Equals(n.Name) && eventnum == 4)
                                {
                                    n.vetoAgain();
                                    eventnum = 0;
                                }

                                if (n.Veto == true)
                                {
                                    if (n.Runs > 0)
                                        vetolist.Add(n);
                                }
                                else
                                {
                                    if (n.Runs > 0)
                                        novetolist.Add(n);
                                }
                            }

                            vetolist.Sort();
                            novetolist.Sort();

                            if (vetolist.Count > 0)
                            {
                                ei = new EventItem(vetolist[0].Name, "random", date);
                                vetolist[0].noMoreVeto();
                            }
                            else if (novetolist.Count > 0)
                            {
                                ei = new EventItem(novetolist[0].Name, "random", date);
                                novetolist[0].decRuns();
                                if (eventnum < 4)
                                    eventnum++;
                            }
                            else
                            {
                                ei = new EventItem(randomEvent[Util.Rnd.Next(1, randomEvent.Count)], "random", date);
                            }
                        }
                        else
                        {
                            ei = new EventItem(randomEvent[Util.Rnd.Next(1, randomEvent.Count)], "random", date);
                        }
                    }

                    num++;
                    if (num == 3)
                    {
                        num = 0;
                    }
                    ei = new EventItem("Self", "random", date); // this is for debuging new events
                    events.Add(date, new List<EventItem>());
                    events[date].Add(ei);
                }

                dt = dt.AddDays(1);
                date = string.Empty;
            }
        }