public MainWindow_ViewModel() { _InitializeDocumentTemplate(); m_CurrentDocument = CreateNewDocument(); AppCloseTimer.SetBeforeShutdownDelegate(OnBeforeAppShutdown); }
//============================================================================= private void Application_Startup(object sender, StartupEventArgs e) { // Apply application theme from TXT file var assembly = Assembly.GetExecutingAssembly(); var resourceName = "RackDrawingApp.Resources.ApplicationTheme.txt"; // using (Stream stream = assembly.GetManifestResourceStream(resourceName)) { ColorTheme appTheme = ColorTheme.ReadFromStream(stream); // apply theme if (appTheme != null) { CurrentTheme.CurrentColorTheme = appTheme; } } // Application should be closed after 24 hours run. AppCloseTimer.Initialize(AppShutdown); bool bShowLoginWindows = true; // If some arguments are passed, then try to get login, password and license path. if (e.Args.Count() > 0) { string strLogin = string.Empty; string strPassword = string.Empty; string strLicensePath = string.Empty; string strCutomerName = string.Empty; string strEnqNo = string.Empty; string strContactNo = string.Empty; string strEmailID = string.Empty; string strBillingAddress = string.Empty; string strSiteAddress = string.Empty; string strDrawingPath = string.Empty; // foreach (string strArg in e.Args) { if (string.IsNullOrEmpty(strArg)) { continue; } if (strArg.StartsWith(ARG_LOGIN)) { strLogin = strArg.Replace(ARG_LOGIN, string.Empty); } else if (strArg.StartsWith(ARG_PASSWORD)) { strPassword = strArg.Replace(ARG_PASSWORD, string.Empty); } else if (strArg.StartsWith(ARG_LICENSE)) { strLicensePath = strArg.Replace(ARG_LICENSE, string.Empty); } else if (strArg.StartsWith(ARG_CUSTOMER_NAME)) { strCutomerName = strArg.Replace(ARG_CUSTOMER_NAME, string.Empty); } else if (strArg.StartsWith(ARG_ENQ_NO)) { strEnqNo = strArg.Replace(ARG_ENQ_NO, string.Empty); } else if (strArg.StartsWith(ARG_CONTACT_NO)) { strContactNo = strArg.Replace(ARG_CONTACT_NO, string.Empty); } else if (strArg.StartsWith(ARG_EMAIL_ID)) { strEmailID = strArg.Replace(ARG_EMAIL_ID, string.Empty); } else if (strArg.StartsWith(ARG_BILLING_ADDRESS)) { strBillingAddress = strArg.Replace(ARG_BILLING_ADDRESS, string.Empty); } else if (strArg.StartsWith(ARG_SITE_ADDRESS)) { strSiteAddress = strArg.Replace(ARG_SITE_ADDRESS, string.Empty); } else if (strArg.StartsWith(ARG_DRAWING_PATH)) { strDrawingPath = strArg.Replace(ARG_DRAWING_PATH, string.Empty); } } UserInfo.Login = strLogin; UserInfo.CustomerName = strCutomerName; UserInfo.EnqNo = strEnqNo; UserInfo.CustomerContactNo = strContactNo; UserInfo.CustomerEmailID = strEmailID; UserInfo.CustomerBillingAddress = strBillingAddress; UserInfo.CustomerSiteAddress = strSiteAddress; UserInfo.DrawingPath = strDrawingPath; if (!string.IsNullOrEmpty(strLicensePath)) { string strError; int iRes = LicenseUtilities.IsValidLicense(strLicensePath, strLogin, strPassword, out strError); if (iRes >= 0) { bShowLoginWindows = false; } } } if (bShowLoginWindows) { LoginWindow loginWnd = new LoginWindow(); loginWnd.Show(); } else { StartupWindow startupWnd = new StartupWindow(); if (!string.IsNullOrEmpty(UserInfo.DrawingPath)) { startupWnd.StartOldApp(); } else { startupWnd.Show(); } } }