public void RemovePrinter() { if (this.PrinterToRemove == null) { return; } string strPrinterToRemove = this.PrinterToRemove.IPAddress; int index = this.PrinterList.IndexOf(this.PrinterToRemove); this.PrinterList.RemoveAt(index); string strIPs = ""; for (int i = 0; i < this.PrinterList.Count; i++) { PrinterProperties obj = this.PrinterList[i]; strIPs += obj.IPAddress + ","; } strIPs = strIPs.Substring(0, strIPs.Length - 1); Configuration config = ConfigurationManager.OpenExeConfiguration(ConfigurationUserLevel.None); config.AppSettings.Settings["Printers"].Value = strIPs; config.Save(ConfigurationSaveMode.Modified); ConfigurationManager.RefreshSection("appSettings"); }
public void AddPrinter() { for (int i = 0; i < PrinterList.Count; i++) { PrinterProperties printerProp = PrinterList[i]; if (printerProp.IPAddress == this.IPAddress) { Common.CommonMethods.ShowErrorMessage("Printer already exists", "Error"); return; } } PrinterProperties objProp = new PrinterProperties(); objProp.IPAddress = this.IPAddress; this.PrinterList.Add(objProp); string strIPs = ""; for (int i = 0; i < this.PrinterList.Count; i++) { PrinterProperties obj = this.PrinterList[i]; strIPs += obj.IPAddress + ","; } strIPs = strIPs.Substring(0, strIPs.Length - 1); Configuration config = ConfigurationManager.OpenExeConfiguration(ConfigurationUserLevel.None); config.AppSettings.Settings["Printers"].Value = strIPs; config.Save(ConfigurationSaveMode.Modified); ConfigurationManager.RefreshSection("appSettings"); Common.CommonMethods.ShowInfoMessage("Printer Added Successfully.\nIf you don't wish to add another printer then restart the application", "Information"); }
public MainWindowViewModel() { string strPrinters = Common.LocalConfigurationSettings.GetConfiguration("Printers"); string[] arr = strPrinters.Split(','); for (int i = 0; i < arr.Length; i++) { PrinterProperties printerProps = new PrinterProperties(); printerProps.IPAddress = arr[i].Trim(); this.ControlList.Add(new ucPrinter(printerProps, this)); } ConnectCommand = new UserCommands(ConnectToPrinter, CanConnectToPrinter); DownloadFileCommand = new UserCommands(DownloadFile, CanDownload); StartPrintCommand = new UserCommands(StartPrint, CanPrintStart); StopPrintCommand = new UserCommands(StopPrint, CanPrintStop); DisconnectCommand = new UserCommands(DisconnectToPrinter, CanConnectToPrinter); AddRemovePrinterCommand = new UserCommands(AddRemovePrinter, CanAddRemovePrinters); //Read the version info string ver = Assembly.GetExecutingAssembly().GetName().Version.ToString(); this.Version = "Version : " + ver; string strLicKey = Common.LocalConfigurationSettings.GetConfiguration("License_Key"); strLicKey = Cryptography.Decrypt(strLicKey); if (strLicKey.ToUpper().Trim() == "TRIAL") { this.Title = "Multidownloader"; if (IsLicenseExpired()) { Environment.Exit(0); } //CreateRegistryKeys(); ////Create a timer of 15 mins.. //aTimer = new Timer(1000); //aTimer.Start(); //aTimer.Elapsed += new ElapsedEventHandler(aTimer_Elapsed); } else if (strLicKey.ToUpper().Trim() == ver) { // CreateRegistryKeys(); this.Title = "Multidownloader | Licensed Version"; } else { CommonMethods.ShowErrorMessage("Invalid Key!!!", "Error"); Environment.Exit(0); } }
private void GetPrinterList() { string strPrinters = Common.LocalConfigurationSettings.GetConfiguration("Printers"); string[] arr = strPrinters.Split(','); for (int i = 0; i < arr.Length; i++) { PrinterProperties objProp = new PrinterProperties(); objProp.IPAddress = arr[i].Trim(); this.PrinterList.Add(objProp); } }
public PrinterViewModel(PrinterProperties printerProps, MainWindowViewModel _mainVM) { this.IPAddress = printerProps.IPAddress; g_objJPNano = new JPNANO(this.IPAddress); this.mainWindowViewModel = _mainVM; DownloadFileCommand = new UserCommands(DownloadFile, CanDownload); SettingsCommand = new UserCommands(ShowSettings, CanDownload); this.PingStatus = g_objJPNano.PingHost(this.IPAddress); this.mainWindowViewModel.ConnectPrinterEvent += new MainWindowViewModel.ConnectPrinter(mainWindowViewModel_ConnectPrinterEvent); this.mainWindowViewModel.DownloadFileEvent += new MainWindowViewModel.DownloadFileDelegate(mainWindowViewModel_DownloadFileEvent); this.mainWindowViewModel.StartPrintEvent += new MainWindowViewModel.StartPrintDelegate(mainWindowViewModel_StartPrintEvent); this.mainWindowViewModel.StopPrintEvent += new MainWindowViewModel.StopPrintDelegate(mainWindowViewModel_StopPrintEvent); this.mainWindowViewModel.DisconnectPrinterEvent += new MainWindowViewModel.DisconnectPrinter(mainWindowViewModel_DisconnectPrinterEvent); aTimer.Elapsed += new System.Timers.ElapsedEventHandler(aTimer_Elapsed); aTimer.Start(); }
public ucPrinter(PrinterProperties printerProps, MainWindowViewModel _mainVM) { InitializeComponent(); this.DataContext = new PrinterViewModel(printerProps, _mainVM); }
public bool HasProperties(PrinterProperties properties) { return((properties & PRINTER_PROPERTIES) == properties); }