private void _bluetoothFolderBox_Validating(object sender, CancelEventArgs e) { if (string.IsNullOrEmpty(_bluetoothFolderBox.Text) || !Directory.Exists(_bluetoothFolderBox.Text)) { ShowToolTip(RM.GetString("BluetoothFolderError"), _bluetoothFolderBox); } }
private void _templateBox_Validating(object sender, CancelEventArgs e) { if (string.IsNullOrEmpty(_templateBox.Text) || !File.Exists(_templateBox.Text)) { ShowToolTip(RM.GetString("ReceiptTemplateError"), _templateBox); } }
private void _photoTemplateBox_Validating(object sender, CancelEventArgs e) { if (!_photoTemplateBox.Text.EndsWith(OrderManager.FilenameTag)) { ShowToolTip(string.Format(RM.GetString("PhotoTemplateError"), OrderManager.FilenameTag), _photoTemplateBox); } }
private void _bluetoothHostBox_Validating(object sender, CancelEventArgs e) { if (string.IsNullOrEmpty(_bluetoothHostBox.Text)) { ShowToolTip(RM.GetString("BluetoothHostError"), _bluetoothHostBox); } }
private void _themeBox_Validating(object sender, CancelEventArgs e) { if (!string.IsNullOrEmpty(_themeBox.Text) && !File.Exists(_themeBox.Text)) { ShowToolTip(RM.GetString("ThemeFileError"), _themeBox); } }
internal static string ElevatedExecute(NameValueCollection parameters) { string tempFile = Path.GetTempFileName(); File.WriteAllText(tempFile, ConstructQueryString(parameters)); try { var startInfo = new ProcessStartInfo(); startInfo.UseShellExecute = true; startInfo.WorkingDirectory = Environment.CurrentDirectory; var uri = new Uri(Assembly.GetExecutingAssembly().GetName().CodeBase); startInfo.FileName = uri.LocalPath; startInfo.Arguments = "\"" + tempFile + "\""; startInfo.Verb = "runas"; Process p = Process.Start(startInfo); p.WaitForExit(); return(File.ReadAllText(tempFile)); } catch (Win32Exception) { return(RM.GetString("UserCancelsOperation")); } finally { File.Delete(tempFile); } }
private void _localizationBox_Validating(object sender, CancelEventArgs e) { if (string.IsNullOrEmpty(_localizationBox.Text) || !File.Exists(_localizationBox.Text)) { ShowToolTip(RM.GetString("LocalizationFileError"), _localizationBox); } }
private void BehaviourPanel_Load(object sender, EventArgs e) { if (Config != null) { _units.Add(Constants.MmUnits, RM.GetString("UnitsComboBoxMm")); _units.Add(Constants.InchUnits, RM.GetString("UnitsComboBoxInch")); foreach (string value in _units.Values) { _unitsBox.Items.Add(value); } // Settings GroupBox _photoKioskIdBox.Text = Config.PhotoKioskId.Value; _cacheSizeBox.IntValue = Config.MemoryCacheSize.Value; _searchTimeoutBox.IntValue = Config.SearchProcessDuration.Value; _timeoutBox.IntValue = Config.InactivityTimeout.Value; _eventLoggingCheckbox.Checked = Config.EnableEventLogging.Value; _unitsBox.SelectedItem = _units[Config.PaperSizeUnits.Value]; // Paths GroupBox _sourcePathsBox.Text = Config.SourcePaths.Value; _folderSelectionCheckbox.Checked = Config.EnableFolderSelection.Value; } }
private void _pathBox_Validating(object sender, System.ComponentModel.CancelEventArgs e) { if (string.IsNullOrEmpty(_pathBox.Text) || !Directory.Exists(_pathBox.Text)) { ShowToolTip(RM.GetString("DestinationPathError"), _pathBox); } }
private void _channelsView_CellValueChanged(object sender, DataGridViewCellEventArgs e) { if (!_isUpdating) { var key = (KeyValuePair <PaperFormat, PaperType>)_channelsView.Rows[e.RowIndex].Tag; string newChannel = _channelsView["ChannelColumn", e.RowIndex].Value != null ? _channelsView["ChannelColumn", e.RowIndex].Value.ToString() : string.Empty; _channelsView.Rows[e.RowIndex].ErrorText = ""; if (!string.IsNullOrEmpty(newChannel)) { foreach (DataGridViewRow row in _channelsView.Rows) { if (row.Index != e.RowIndex) { string name = _channelsView["ChannelColumn", row.Index].Value != null ? _channelsView["ChannelColumn", row.Index].Value.ToString() : string.Empty; if (name.Equals(newChannel)) { _channelsView.Rows[e.RowIndex].ErrorText = RM.GetString("ChannelError"); break; } } } } if (PriceManager.ContainsProduct(GetProductKey(key))) { PriceManager.GetProduct(GetProductKey(key)).Channel = newChannel; } } }
private void _testButton_Click(object sender, EventArgs e) { try { var receiptData = new ReceiptData(); receiptData.Id = string.Format(RM.GetString("RecieptTestOrderId")); receiptData.UserName = string.Format(RM.GetString("RecieptTestCustomerName")); receiptData.UserPhone = "1234567890"; receiptData.BurnCd = false; receiptData.OrderPhotos = true; receiptData.CropMode = string.Format(RM.GetString("RecieptTestCropMode")); receiptData.PaperType = string.Format(RM.GetString("RecieptTestPaperType")); receiptData.OrderDate = DateTime.Now.ToString(CultureInfo.CurrentCulture); receiptData.PhotosCount = 10; receiptData.PrintsCount = 20; receiptData.OrderCost = (receiptData.PrintsCount * 10).ToString("c", NumberFormatInfo.CurrentInfo); receiptData.Formats.Add(new FormatInfo("10x15", 10)); receiptData.Formats.Add(new FormatInfo("20x30", 10)); for (int i = 0; i < receiptData.PhotosCount; i++) { receiptData.Photos.Add(new PhotoInfo("P000000" + i.ToString() + ".JPG", 1, "10x15")); receiptData.Photos.Add(new PhotoInfo("P000000" + i.ToString() + ".JPG", 1, "20x30")); } receiptData.MorePhotos = false; var receipt = new Receipt(receiptData, Config.ReceiptTemplateFile.Value); receipt.Print(Config.ReceiptPrinterName.Value); } catch (Exception ex) { MainForm.ShowWarningMessage(string.Format(RM.GetString("PrintingError"), ex.Message)); } }
private void PaperFormatsPanel_VisibleChanged(object sender, EventArgs e) { if (Config != null && Visible) { _formatsView.Columns["WidthColumn"].HeaderText = string.Format(RM.GetString("WidthColumnHeader"), RM.GetString(Config.PaperSizeUnits.Value)); _formatsView.Columns["HeightColumn"].HeaderText = string.Format(RM.GetString("HeightColumnHeader"), RM.GetString(Config.PaperSizeUnits.Value)); } }
private void _discLabelBox_Validating(object sender, CancelEventArgs e) { if (string.IsNullOrEmpty(_discLabelBox.Text)) { ShowToolTip(RM.GetString("DiscLabelError"), _discLabelBox); e.Cancel = true; } }
private void _timeoutBox_Validating(object sender, CancelEventArgs e) { if (_timeoutBox.IntValue == 0) { ShowToolTip(RM.GetString("InactivityTimeoutError"), _timeoutBox); e.Cancel = true; } }
private void _priceBox_Validating(object sender, CancelEventArgs e) { if (_priceBox.FloatValue <= 0) { ShowToolTip(RM.GetString("PriceError"), _priceBox); e.Cancel = true; } }
private void _cacheSizeBox_Validating(object sender, CancelEventArgs e) { if (_cacheSizeBox.IntValue == 0) { ShowToolTip(RM.GetString("MemoryCacheSizeError"), _cacheSizeBox); e.Cancel = true; } }
private void _searchTimeoutBox_Validating(object sender, CancelEventArgs e) { if (_searchTimeoutBox.IntValue == 0) { ShowToolTip(RM.GetString("SearchProcessDurationError"), _searchTimeoutBox); e.Cancel = true; } }
private void _box_Validating(object sender, CancelEventArgs e) { TextBox box = sender as TextBox; if (!string.IsNullOrEmpty(box.Text) && !File.Exists(box.Text)) { ShowToolTip(RM.GetString("ScreenImageError"), box); } }
public PaperFormatsPanel() { InitializeComponent(); _contextMenuItem.Text = RM.GetString("CopyToCrops"); _contextMenuItem.Click += new EventHandler(_contextMenuItem_Click); _formatsView.ContextMenuStrip = new ContextMenuStrip(); _formatsView.ContextMenuStrip.Opening += new CancelEventHandler(_contextMenu_DropDownOpened); _formatsView.ContextMenuStrip.Items.Add(_contextMenuItem); }
private void MainForm_Load(object sender, EventArgs e) { if (_config != null && _priceManager != null && _orderManager != null) { UpdatePriceNodes(); UpdateServiceNodes(); foreach (ScreenSetting screen in _config.Screens) { _optionsTree.Nodes["AppearanceNode"].Nodes.Add(screen.Key, RM.GetString(screen.Key)); } _applyButton.Enabled = false; _helpButton.Enabled = File.Exists(Config.HelpFile); } else { Close(); } }
private void ValidateCells(CancelEventArgs e) { for (int i = _servicesView.Rows.Count - 1; i >= 0; i--) { DataGridViewRow curRow = _servicesView.Rows[i]; if (!curRow.IsNewRow) { curRow.ErrorText = string.Empty; string curName = curRow.Cells["ServiceNameColumn"].Value != null ? curRow.Cells["ServiceNameColumn"].Value.ToString() : string.Empty; if (!string.IsNullOrEmpty(curName)) { foreach (DataGridViewRow row in _servicesView.Rows) { if (row != curRow && string.IsNullOrEmpty(row.ErrorText) && curName.Equals(row.Cells["ServiceNameColumn"].Value)) { curRow.ErrorText = RM.GetString("ServiceNameDuplicateError"); } } } else { curRow.ErrorText = RM.GetString("ServiceNameEmptyError"); } } } if (!BasePanel.HasErrors(_servicesView, false)) { if (Parent is MainForm) { (Parent as MainForm).UpdateServiceNodes(); } } else if (e != null) { e.Cancel = true; } }
public static void ShowErrorMessage(string message) { MessageBox.Show(message, RM.GetString("Error"), MessageBoxButtons.OK, MessageBoxIcon.Error); }
public PricePanel() { InitializeComponent(); _minPriceLabel.Text = string.Format(RM.GetString("MinimumPriceLabel"), CultureInfo.CurrentCulture.NumberFormat.CurrencySymbol); }
public static void ShowInfoMessage(string message) { MessageBox.Show(message, RM.GetString("Info"), MessageBoxButtons.OK, MessageBoxIcon.Information); }
private void _discountsView_CellValueChanged(object sender, DataGridViewCellEventArgs e) { if (_isLoaded) { var cell = _discountsView[e.ColumnIndex, e.RowIndex]; if (cell.ColumnIndex == _discountsView.Columns["ToColumn"].Index) { int toValue = int.MaxValue; if (cell.Value == null || (!cell.Value.ToString().Equals("-") && !int.TryParse(cell.Value.ToString(), out toValue)) || toValue <= 0) { SetError(cell, RM.GetString("DiscountValueToLessError")); return; } if (toValue == int.MaxValue) { cell.Value = "-"; } int fromValue = int.Parse(_discountsView["FromColumn", e.RowIndex].Value.ToString(), CultureInfo.CurrentCulture); if (e.RowIndex < _discountsView.Rows.Count - 1) { int nextToValue = int.MaxValue; if (_discountsView["ToColumn", e.RowIndex + 1].Value != null && !_discountsView["ToColumn", e.RowIndex + 1].Value.ToString().Equals("-")) { int.TryParse(_discountsView["ToColumn", e.RowIndex + 1].Value.ToString(), out nextToValue); } if (toValue < fromValue || toValue > nextToValue - 2) { SetError(cell, string.Format(RM.GetString("DiscountValueOutOfRangeError"), fromValue, nextToValue - 2)); return; } } else { if (toValue < fromValue) { SetError(cell, string.Format(RM.GetString("DiscountValueToBigError"), fromValue)); return; } _discountsView.Rows.Add(toValue + 1, "-", _product.Price); } SetError(cell, ""); _discountsView["FromColumn", e.RowIndex + 1].Value = toValue + 1; } else if (cell.ColumnIndex == _discountsView.Columns["PriceColumn"].Index) { float testValue; if (cell.Value == null || !float.TryParse(cell.Value.ToString(), out testValue) || testValue <= 0) { SetError(cell, RM.GetString("PriceError")); } else { SetError(cell, ""); if (e.RowIndex == 0) { _product.Price = testValue; } } } _discountsView_Validating(null, null); } }
private void ValidateCells(CancelEventArgs e) { for (int i = _formatsView.Rows.Count - 1; i >= 0; i--) { DataGridViewRow curRow = _formatsView.Rows[i]; if (!curRow.IsNewRow) { curRow.ErrorText = string.Empty; curRow.Cells["WidthColumn"].ErrorText = string.Empty; curRow.Cells["HeightColumn"].ErrorText = string.Empty; curRow.Cells["DpiColumn"].ErrorText = string.Empty; string curName = curRow.Cells["NameColumn"].Value != null ? curRow.Cells["NameColumn"].Value.ToString() : string.Empty; if (!string.IsNullOrEmpty(curName)) { foreach (DataGridViewRow row in _formatsView.Rows) { if (row != curRow && string.IsNullOrEmpty(row.ErrorText) && curName.Equals(row.Cells["NameColumn"].Value)) { curRow.ErrorText = RM.GetString("PaperFormatDuplicateError"); } } } else { curRow.ErrorText = RM.GetString("PaperFormatEmptyError"); } float width = 0.0f; if (curRow.Cells["WidthColumn"].Value == null || !float.TryParse(curRow.Cells["WidthColumn"].Value.ToString(), out width) || width < 0) { curRow.Cells["WidthColumn"].ErrorText = RM.GetString("PaperWidthError"); } float height = 0.0f; if (curRow.Cells["HeightColumn"].Value == null || !float.TryParse(curRow.Cells["HeightColumn"].Value.ToString(), out height) || height < 0) { curRow.Cells["HeightColumn"].ErrorText = RM.GetString("PaperHeightError"); } int dpi = 0; if (curRow.Cells["DpiColumn"].Value == null || !int.TryParse(curRow.Cells["DpiColumn"].Value.ToString(), out dpi) || dpi < 0) { curRow.Cells["DpiColumn"].ErrorText = RM.GetString("PaperDpiError"); } if ((width == 0 || height == 0 || dpi == 0) && (width > 0 || height > 0 || dpi > 0)) { curRow.ErrorText = RM.GetString("FreeFormatError"); } } } if (!BasePanel.HasErrors(_formatsView, false)) { if (Parent is MainForm) { (Parent as MainForm).UpdatePriceNodes(); } } else if (e != null) { e.Cancel = true; } }
public MainForm() { InitializeComponent(); _panelCollection.Add("BehaviourNode", _behaviourPanel); _panelCollection.Add("BehaviourGeneralNode", _behaviourPanel); _panelCollection.Add("BehaviourContactInfoNode", _contactInfoPanel); _panelCollection.Add("BehaviourCallbackNode", _callbackPanel); _panelCollection.Add("BluetoothNode", _bluetoothPanel); _panelCollection.Add("ImageEditorNode", _imageEditorPanel); _panelCollection.Add("ImageEditorGeneralNode", _imageEditorPanel); _panelCollection.Add("CropsNode", _cropsPanel); _panelCollection.Add("AppearanceNode", _appearancePanel); _panelCollection.Add("AppearanceGeneralNode", _appearancePanel); _panelCollection.Add("PaperFormatsNode", _paperFormatsPanel); _panelCollection.Add("PaperTypesNode", _paperTypesPanel); _panelCollection.Add("PricesNode", _pricePanel); _panelCollection.Add("PricesGeneralNode", _pricePanel); _panelCollection.Add("ServicesNode", _servicesPanel); _panelCollection.Add("OrderManagerNode", _orderManagerPanel); _panelCollection.Add("OrderManagerGeneralNode", _orderManagerPanel); _panelCollection.Add("ArbitraryFormatNode", _arbitraryFormatPanel); _panelCollection.Add("DpofNode", _dpofPanel); _panelCollection.Add("PhotoPrinterNode", _photoPrinterPanel); _panelCollection.Add("CdBurnerNode", _cdBurnerPanel); _panelCollection.Add("ReceiptPrinterNode", _receiptPrinterPanel); _pricesGeneralNode = _optionsTree.Nodes["PricesNode"].Nodes["PricesGeneralNode"]; try { _config = new Config(false); } catch (Exception e) { ShowErrorMessage(string.Format(RM.GetString("PhotoKioskConfigError"), e.Message)); return; } try { _priceManager = new PriceManager(false, _config.PriceFile.Value, new PriceManager.ModifiedHandler(_settings_Modified)); } catch (Exception e) { ShowErrorMessage(string.Format(RM.GetString("PriceReadingError"), e.Message)); return; } try { _orderManager = new OrderManager(); } catch (Exception e) { ShowErrorMessage(string.Format(RM.GetString("OrderManagerConfigError"), e.Message)); return; } try { _cropManager = new CropManager(false, _config.CropFile.Value, new CropManager.ModifiedHandler(_settings_Modified)); } catch (Exception e) { ShowErrorMessage((string.Format(RM.GetString("CropReadingError"), e.Message))); return; } _config.Modified += new Config.ModifiedHandler(_settings_Modified); _orderManager.Modified += new OrderManager.ModifiedHandler(_settings_Modified); foreach (BasePanel panel in _panelCollection.Values) { panel.Config = _config; panel.PriceManager = _priceManager; panel.OrderManager = _orderManager; panel.CropManager = _cropManager; } _screenPanel.Config = _config; }
public static void ShowWarningMessage(string message) { MessageBox.Show(message, RM.GetString("Warning"), MessageBoxButtons.OK, MessageBoxIcon.Warning); }
public void UpdatePriceNodes() { _optionsTree.Nodes["PricesNode"].Nodes.Clear(); _optionsTree.Nodes["PricesNode"].Nodes.Add(_pricesGeneralNode); foreach (PaperFormat format in _priceManager.PaperFormats) { foreach (PaperType type in _priceManager.PaperTypes) { Product product; if (_config.EnablePhotoOrdering.Value) { product = _priceManager.GetProduct(format.Name + type.Name); if (product == null) { product = _priceManager.AddProduct(format, type, ""); } _optionsTree.Nodes["PricesNode"].Nodes.Add(product.ToString(), format.Name + " " + type.Name); } if (_priceManager.ContainsProduct(format.Name + type.Name + Constants.InstantKey) && _config.EnablePhotoPrinting.Value) { product = _priceManager.GetProduct(format.Name + type.Name + Constants.InstantKey); _optionsTree.Nodes["PricesNode"].Nodes.Add(product.ToString(), format.Name + " " + type.Name + RM.GetString("InstantPostfix")); } } } }
public BasePanel() { InitializeComponent(); _toolTip.ToolTipTitle = RM.GetString("Warning"); }