Beispiel #1
0
        protected override async void OnStartup(StartupEventArgs e)
        {
            string procName = Process.GetCurrentProcess().ProcessName;

            Process[] processes = Process.GetProcessesByName(procName);

            if (processes.Length > 1)
            {
                MessageBox.Show($"{procName} already running", "Error");
                Current.Shutdown();
                return;
            }

            if (!Directory.Exists(AppDomain.CurrentDomain.BaseDirectory + "\\receipts"))
            {
                try
                {
                    System.IO.Directory.CreateDirectory(AppDomain.CurrentDomain.BaseDirectory + "\\receipts");
                }
                catch (Exception)
                {
                    MessageBox.Show("Error creating receipts directory.");
                    Environment.Exit(1);
                }
            }


            Thread.CurrentThread.CurrentCulture   = new CultureInfo("el-GR");
            Thread.CurrentThread.CurrentUICulture = new CultureInfo("el-GR");
            FrameworkElement.LanguageProperty.OverrideMetadata(
                typeof(FrameworkElement),
                new FrameworkPropertyMetadata(
                    XmlLanguage.GetLanguage(CultureInfo.CurrentCulture.IetfLanguageTag)));


            await SMGAppDbContextFactory.MigrateIfNeeded();

            IServiceProvider serviceProvider = CreateServiceProvider();

            Window window = serviceProvider.GetRequiredService <MainWindow>();

            window.WindowStartupLocation = WindowStartupLocation.CenterScreen;
            window.Height      = SystemParameters.PrimaryScreenHeight * 0.95;
            window.Width       = SystemParameters.PrimaryScreenWidth * 0.95;
            window.DataContext = serviceProvider.GetRequiredService <MainViewModel>();
            window.Show();

            base.OnStartup(e);
        }
 public GuaranteeDataService(SMGAppDbContextFactory contextFactory) : base(contextFactory)
 {
 }
 public ServiceItemsDataService(SMGAppDbContextFactory contextFactory) : base(contextFactory)
 {
 }
 public GenericDataServices(SMGAppDbContextFactory contextFactory)
 {
     ContextFactory = contextFactory;
 }
 public CustomersDataService(SMGAppDbContextFactory contextFactory) : base(contextFactory)
 {
 }