public static void ShowDialog(string message, string stacktrace)
 {
     Application.Current.Dispatcher.Invoke(() =>
     {
         var d   = new ExceptionDialog(message, stacktrace);
         d.Owner = Application.Current.MainWindow;
         d.WindowStartupLocation = WindowStartupLocation.CenterOwner;
         d.Topmost = true;
         d.ShowDialog();
     });
 }
Exemplo n.º 2
0
 private void CheckPreviousRunException()
 {
     Task.Delay(100).ContinueWith(_ =>
     {
         var exFile = Logging.AppDomainErrorLog;
         if (File.Exists(exFile))
         {
             var msg = File.ReadAllText(exFile);
             ExceptionDialog.ShowDialog("This program reported a crash earlier.", msg);
             File.Delete(exFile);
         }
     });
 }
Exemplo n.º 3
0
        public MainViewModel()
        {
            Logging.SetupLogging();
            PortAudio.Pa_Initialize();

            var realtimeProcesingExePath = Path.Combine(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location), "IrWorkshop.RealtimeProcessing.exe");

            realtimeProcess = new RealtimeProcessManager(realtimeProcesingExePath);
            realtimeProcess.PrematureTerminationCallback = logOutput => ExceptionDialog.ShowDialog("Audio engine has died", string.Join("\r\n", logOutput));

            //ensure copy dependency
            // ReSharper disable once UnusedVariable
            var ttt = typeof(RealtimeProcessing.Program);

            var mSec = new MemoryMappedFileSecurity();

            mSec.AddAccessRule(new AccessRule <MemoryMappedFileRights>(new SecurityIdentifier(WellKnownSidType.WorldSid, null), MemoryMappedFileRights.FullControl, AccessControlType.Allow));
            try
            {
                memoryMap  = MemoryMappedFile.CreateNew("Global\\IRWorkshopMap", 65536, MemoryMappedFileAccess.ReadWrite, MemoryMappedFileOptions.None, mSec, HandleInheritability.Inheritable);
                mmAccessor = memoryMap.CreateViewAccessor();
            }
            catch (IOException ex)
            {
                if (ex.Message.Contains("already exists"))
                {
                    Logging.ShowMessage("IR Workshop Studio is already running", LogType.Information, true);
                    Environment.Exit(0);
                }

                throw;
            }
            catch (Exception)
            {
                Logging.ShowMessage("This software needs to run in Administrator mode", LogType.Error, true);
                throw;
            }

            volumeSlider  = 0.7;
            preset        = new ImpulsePreset();
            ImpulseConfig = new ObservableCollection <ImpulseConfigViewModel>();
            MixingConfig  = new MixingViewModel(preset.MixingConfig, preset.SamplerateTransformed)
            {
                OnUpdateCallback = () => updateRateLimiter.Pulse()
            };

            Title        = "IR Workshop - v" + Assembly.GetExecutingAssembly().GetName().Version;
            settingsFile = Path.Combine(Path.GetDirectoryName(Assembly.GetEntryAssembly().Location), "settings.json");

            NewPresetCommand  = new DelegateCommand(_ => NewPreset());
            OpenPresetCommand = new DelegateCommand(_ => OpenPreset());
            SavePresetCommand = new DelegateCommand(_ => SavePreset());

            AudioSetupCommand         = new DelegateCommand(_ => AudioSetup());
            RestartAudioEngineCommand = new DelegateCommand(_ => RestartAudioEngine());
            ExportWavCommand          = new DelegateCommand(_ => ExportWav());
            ShowAboutCommand          = new DelegateCommand(_ => ShowAbout());
            CheckForUpdatesCommand    = new DelegateCommand(_ => Process.Start("https://github.com/ValdemarOrn/IRWorkshop"));

            AddImpulseCommand       = new DelegateCommand(_ => AddImpulse());
            RemoveImpulseCommand    = new DelegateCommand(_ => RemoveImpulse());
            MoveImpulseLeftCommand  = new DelegateCommand(_ => MoveImpulseLeft());
            MoveImpulseRightCommand = new DelegateCommand(_ => MoveImpulseRight());
            CloneImpulseCommand     = new DelegateCommand(_ => CloneImpulse());
            SwitchGraphsCommand     = new DelegateCommand(_ => SwitchGraphs());
            selectedInputL          = -1;
            selectedInputR          = -1;
            selectedOutputL         = -1;
            selectedOutputR         = -1;

            updateRateLimiter = new LastRetainRateLimiter(100, Update);

            LoadSettings();

            var t = new Thread(SaveSettingsLoop)
            {
                IsBackground = true
            };

            t.Priority = ThreadPriority.Lowest;
            t.Start();

            var t3 = new Thread(UpdateClipIndicators)
            {
                IsBackground = true
            };

            t3.Priority = ThreadPriority.Lowest;
            t3.Start();

            AddImpulse();
            Update();
            UpdateMemoryMap();
            StartAudioEngine();

            CheckPreviousRunException();
        }
Exemplo n.º 4
0
 public static void Exception(string message, string traceMessage)
 {
     ExceptionDialog.ShowDialog(message, traceMessage);
 }