private void EnsureUiBasedOnCultureInfo(String culture)
 {
     var resources = new UIResources(culture);
     grpCustomers.Text = resources.Customers;
     btnAdd.Text = resources.Add;
     btnSelect.Text = resources.Select;
     btnClose.Text = resources.Close;
     btnDelete.Text = resources.Delete;
     btnEdit.Text = resources.Edit;
 }
 public override String GenerateHeader(ProjectFile file)
 {
     UIResources resources = new UIResources(Settings.GetSavedCulture());
     StringBuilder sb = new StringBuilder();
     sb.AppendLine("<TABLE><tbody>");
     sb.AppendLine(
         String.Format(
             "<TR><TD><b>{0}</b></TD> <TD><b>{1}</b></TD> <TD><b>{2}</b></TD> <TD><b>{3}</b></TD> <TD><b>{4}</b></TD></TR>",
             resources.Type, resources.Rates,
             resources.Words, resources.Characters, resources.Value));
     return sb.ToString();
 }
 private String GenerateJustLines(ProjectFile file)
 {
     UIResources resources = new UIResources(Settings.GetSavedCulture());
     StringBuilder sb = new StringBuilder();
     sb.AppendLine("<TABLE><tbody>");
     sb.AppendLine(String.Format("<TR><TD><b>{0}</b></TD> <TD><b>{1}</b></TD></TR>", resources.Type.PadRight(30, ' '), resources.Rates));
     foreach (var rate in AdditionalRates)
     {
         sb.AppendLine(String.Format("<TR><TD>{0}</TD> <TD>{1}</TD></TR>", rate.Type.PadRight(30, ' '), rate.Rate.ToString()));
     }
     sb.AppendLine("</tbody></TABLE>");
     sb.AppendLine("<br>"); 
     sb.AppendLine(resources.JustLines);
     sb.AppendLine("<br>");
     sb.AppendLine("<TABLE><tbody>");
     sb.AppendLine(String.Format("<TR><TD><b>{0}:</b></TD> <TD>{1} {2}</TD> <TD>{3} {4}</TD></TR>", resources.PaymentByCharacters, file.LinesByCharacters.ToString(), 
         resources.StandardLines, file.ValueByLbC.ToString(), resources.Euros));
     sb.AppendLine(String.Format("<TR><TD><b>{0}:</b></TD> <TD>{1} {2}</TD> <TD>{3} {4}</TD></TR>", resources.PaymentByKeystrokes, file.LinesByKeyStrokes.ToString(),
         resources.StandardLines, file.ValueByLbK.ToString(), resources.Euros));
     sb.AppendLine("</tbody></TABLE>");
     sb.AppendLine("<br>");
     return sb.ToString();
 }
        private string GenerateCustomerData(Customer customer)
        {
            if (customer == null)
                return String.Empty;
            UIResources resources = new UIResources(Settings.GetSavedCulture());
            var sb = new StringBuilder();
            sb.AppendLine(resources.GeneratedFor);
            sb.AppendLine("<br>");
            if (!String.IsNullOrEmpty(customer.Name))
            {
                sb.AppendLine(String.Format("   {1}: {0}", customer.Name, resources.CustomerName));
                sb.AppendLine("<br>");
            }
            if (!String.IsNullOrEmpty(customer.Street))
            {
                sb.AppendLine(String.Format("   {1}: {0}", customer.Street, resources.Street));
                sb.AppendLine("<br>");
            }
            if (!String.IsNullOrEmpty(customer.City))
            {
                sb.AppendLine(String.Format("   {1}: {0}", customer.City, resources.City));
                sb.AppendLine("<br>");
            }
            if (!String.IsNullOrEmpty(customer.State))
            {
                sb.AppendLine(String.Format("   {1}: {0}", customer.State, resources.State));
                sb.AppendLine("<br>");
            }
            if (!String.IsNullOrEmpty(customer.Zip))
            {
                sb.AppendLine(String.Format("   {1}: {0}", customer.Zip, resources.Zip));
                sb.AppendLine("<br>");
            }
            if (!String.IsNullOrEmpty(customer.Country))
            {
                sb.AppendLine(String.Format("   {1}: {0}", customer.Country, resources.Country));
                sb.AppendLine("<br>");
            }

            return sb.ToString();
        }
        private string GenerateUserData(User user)
        {
            if (user == null)
                return String.Empty;
            UIResources resources = new UIResources(Settings.GetSavedCulture());
            var sb = new StringBuilder();
            sb.AppendLine("<br>");
            sb.AppendLine(resources.GeneratedBy);
            if (!String.IsNullOrEmpty(user.Name))
            {
                sb.AppendLine(String.Format("   {1}: {0}", user.Name, resources.UserName));
                sb.AppendLine("<br>");
            }
            if (!String.IsNullOrEmpty(user.Street))
            {
                sb.AppendLine(String.Format("   {1}: {0}", user.Street, resources.Street));
                sb.AppendLine("<br>");
            }
            if (!String.IsNullOrEmpty(user.City))
            {
                sb.AppendLine(String.Format("   {1}: {0}", user.City, resources.City));
                sb.AppendLine("<br>");
            }
            if (!String.IsNullOrEmpty(user.State))
            {
                sb.AppendLine(String.Format("   {1}: {0}", user.State, resources.State));
                sb.AppendLine("<br>");
            }
            if (!String.IsNullOrEmpty(user.Zip))
            {
                sb.AppendLine(String.Format("   {1}: {0}", user.Zip, resources.Zip));
                sb.AppendLine("<br>");
            }
            if (!String.IsNullOrEmpty(user.Country))
            {
                sb.AppendLine(String.Format("   {1}: {0}", user.Country, resources.Country));
                sb.AppendLine("<br>");
            }
            if (!String.IsNullOrEmpty(user.Phone))
            {
                sb.AppendLine(String.Format("   {1}: {0}", user.Phone, resources.Phone));
                sb.AppendLine("<br>");
            }
            if (!String.IsNullOrEmpty(user.Mobile))
            {
                sb.AppendLine(String.Format("   {1}: {0}", user.Mobile, resources.Mobile));
                sb.AppendLine("<br>");
            }
            if (!String.IsNullOrEmpty(user.Email))
            {
                sb.AppendLine(String.Format("   {1}: {0}", user.Email, resources.Email));
                sb.AppendLine("<br>");
            }
            if (!String.IsNullOrEmpty(user.Skype))
            {
                sb.AppendLine(String.Format("   {1}: {0}", user.Skype, resources.Skype));
                sb.AppendLine("<br>");
            }
            if (!String.IsNullOrEmpty(user.WebAddress))
            {
                sb.AppendLine(String.Format("   {1}: {0}", user.WebAddress, resources.WebAddress));
                sb.AppendLine("<br>");
            }
            if (!String.IsNullOrEmpty(user.Twitter))
            {
                sb.AppendLine(String.Format("   {1}: {0}", user.Twitter, resources.Twitter));
                sb.AppendLine("<br>");
            }

            return sb.ToString();
        }
        private void btnGenerate_Click(object sender, EventArgs e)
        {
            if (!ckWord.Checked && !ckExcel.Checked && !ckClipboard.Checked)
                return;

            Settings.SaveRatesState(_rates.State);

            ITemplateRates currentSelectedTemplate = _rates.CurrentRatesTemplate;
            if (currentSelectedTemplate == null)
            {
                if (_rates == null || _rates.State == null)
                    currentSelectedTemplate = new SimpleWordTemplate();
                else
                {
                    currentSelectedTemplate = _rates.GetSimpleWordTemplateFromState();
                }
            }
            Project project = new Project(cmbLanguagePair.SelectedValue.ToString(),
                currentSelectedTemplate, 
                cmbReportType.SelectedIndex == 0 ? ReportType.Detailed : ReportType.Summary);

            Customer customer = new Customer(
                txtCustomerName.SDLText,
                txtCustomerStreet.SDLText,
                txtCustomerCity.SDLText,
                txtCustomerState.SDLText,
                txtCustomerZip.SDLText,
                txtCustomerCountry.SDLText);

            //Settings.SaveCurrentCustomer(customer);
            bool emptyUser = String.IsNullOrEmpty(txtUserName.SDLText);
            User user = new User()
                {
                    Name = emptyUser ? String.Empty : txtUserName.SDLText,
                    Street = emptyUser ? String.Empty : txtUserStreet.SDLText,
                    City = emptyUser ? String.Empty : txtUserCity.SDLText,
                    State = emptyUser ? String.Empty : txtUserState.SDLText,
                    Zip = emptyUser ? String.Empty : txtUserZip.SDLText,
                    Country = emptyUser ? String.Empty : txtUserCountry.SDLText,
                    Phone = emptyUser ? String.Empty : txtUserPhone.SDLText,
                    Mobile = emptyUser ? String.Empty : txtUserMobile.SDLText,
                    Email = emptyUser ? String.Empty : txtUserEmail.SDLText,
                    Skype = emptyUser ? String.Empty : txtUserSkype.SDLText,
                    WebAddress = emptyUser ? String.Empty : txtUserWebAdress.SDLText,
                    Twitter = emptyUser ? String.Empty : txtUserTwitter.SDLText
                };
            Settings.SaveCurrentUser(user);
            UIResources resources = new UIResources(ddlLanguages.SelectedValue.ToString());
            if (ckClipboard.Checked)
            {
                project.GenerateClipboardData(customer, user);
                MessageBox.Show(resources.QuoteGeneratedClipboard, resources.Information, MessageBoxButtons.OK,
                                MessageBoxIcon.Information);
            }
            if (ckExcel.Checked)
            {
                saveFileDialog.FileName = String.Empty;
                saveFileDialog.DefaultExt = "xlsx";
                saveFileDialog.AddExtension = true;
                saveFileDialog.Filter = @"Excel Document|*.xlsx";

                if (saveFileDialog.ShowDialog() == DialogResult.OK)
                {
                    String fileToSave = saveFileDialog.FileName;
                    String template = ddlExcel.SelectedValue.ToString();

                    project.GenerateExcelData(customer, user, fileToSave, template);
                    MessageBox.Show(resources.QuoteGeneratedExcel, resources.Information, MessageBoxButtons.OK,
                                    MessageBoxIcon.Information);
                }
            }
            if (ckWord.Checked)
            {
                saveFileDialog.FileName = String.Empty;
                saveFileDialog.DefaultExt = "docx";
                saveFileDialog.AddExtension = true;
                saveFileDialog.Filter = @"Word Document|*.docx";
                saveFileDialog.SupportMultiDottedExtensions = false;

                if (saveFileDialog.ShowDialog() == DialogResult.OK)
                {
                    String fileToSave = saveFileDialog.FileName;
                    String template = ddlWord.SelectedValue.ToString();

                    project.GenerateWordData(customer, user, fileToSave, template);
                    MessageBox.Show(resources.QuoteGeneratedWord, resources.Information, MessageBoxButtons.OK,
                                    MessageBoxIcon.Information);
                }
            }
        }
        private void EnsureUIBasedOnCultureInfo(String culture)
        {
            var resources = new UIResources(culture);

            pageCreateQuote.Text = resources.CreateQuote;
            pageTemplates.Text = resources.Rates;
            pageUserDetails.Text = resources.UserDetails;
            groupCustomer.Text = resources.SelectCustomer;
            groupProjects.Text = resources.SelectProject;
            btnGenerate.Text = resources.GenerateQuote;
            groupReportType.Text = resources.ReportType;
            ckExcel.Text = resources.MSExcel;
            ckClipboard.Text = resources.Clipboard;
            ckWord.Text = resources.MSWord;
            txtCustomerName.LabelText = resources.CustomerName;
            txtCustomerStreet.LabelText = resources.Street;
            txtCustomerCountry.LabelText = resources.Country;
            txtCustomerZip.LabelText = resources.Zip;
            txtCustomerState.LabelText = resources.State;
            txtCustomerCity.LabelText = resources.City;
            groupStudioAnalysisBands.Text = resources.StudioAnalysisBands;
            rbGroupedAnalysis.Text = resources.GroupedAnalysis;
            rbStandardLines.Text = resources.StandardLines;
            rbSimpleWordAnalysis.Text = resources.SimpleWordAnalysis;
            rbTemplateGroupedAnalysis.Text = resources.GroupedAnalysis;
            rbTemplateStandardLines.Text = resources.StandardLines;
            rbTemplateSimpleWordAnalysis.Text = resources.SimpleWordAnalysis;
            groupUserDetails.Text = resources.UserDetails;
            txtUserTwitter.LabelText = resources.Twitter;
            txtUserWebAdress.LabelText = resources.WebAddress;
            txtUserSkype.LabelText = resources.Skype;
            txtUserEmail.LabelText = resources.Email;
            txtUserMobile.LabelText = resources.Mobile;
            txtUserPhone.LabelText = resources.Phone;
            txtUserCountry.LabelText = resources.Country;
            txtUserZip.LabelText = resources.Zip;
            txtUserState.LabelText = resources.State;
            txtUserCity.LabelText = resources.City;
            txtUserStreet.LabelText = resources.Street;
            txtUserName.LabelText = resources.UserName;
            btnCustomer.Text = resources.Customers;
            lblLanguagePair.Text = resources.LanguagePair;
            lblSummaryReportType.Text = resources.SummaryReportType;
            groupTemplateTemplates.Text = grpTemplateType.Text = resources.Templates;
            lblProjectsXML.Text = resources.ProjectsXMLPath;
        }
 private void FillReportTypeDDL()
 {
     UIResources resources = new UIResources(Settings.GetSavedCulture());
     cmbReportType.Items.Clear();
     cmbReportType.Items.Add(resources.BreakdownAndSummary);
     cmbReportType.Items.Add(resources.Summary);
     cmbReportType.SelectedIndex = 0;
 }
        private void EnsureUiBasedOnCultureInfo(String culture, Customer customer)
        {
            var resources = new UIResources(culture);

            groupCustomer.Text = resources.Customer;
            _txtCustomerName.LabelText = resources.CustomerName;
            _txtCustomerStreet.LabelText = resources.Street;
            _txtCustomerCountry.LabelText = resources.Country;
            _txtCustomerZip.LabelText = resources.Zip;
            _txtCustomerState.LabelText = resources.State;
            _txtCustomerCity.LabelText = resources.City;

            _txtCustomerName.SDLText = customer != null ? customer.Name : String.Empty;
            _txtCustomerStreet.SDLText = customer != null ? customer.Street : String.Empty;
            _txtCustomerCountry.SDLText = customer != null ? customer.Country : String.Empty;
            _txtCustomerZip.SDLText = customer != null ? customer.Zip : String.Empty;
            _txtCustomerState.SDLText = customer != null ? customer.State : String.Empty;
            _txtCustomerCity.SDLText = customer != null ? customer.City : String.Empty;

            groupStudioAnalysisBands.Text = resources.StudioAnalysisBands;
            groupTemplateTemplates.Text = resources.Templates;

            rbTemplateGroupedAnalysis.Text = resources.GroupedAnalysis;
            rbTemplateSimpleWordAnalysis.Text = resources.SimpleWordAnalysis;
            rbTemplateStandardLines.Text = resources.StandardLines;
        }
Exemple #10
0
 public void UpdateStateBasedOnUICulture()
 {
     if (_state == null)
         return;
     UIResources resources = new UIResources(Settings.GetSavedCulture());
     foreach (var templateRates in _state)
     {
         foreach (var rateValue in templateRates.Rates)
         {
             rateValue.Type = resources.GetString(rateValue.ResourceToken);
         }
         foreach (var rateValue in templateRates.AdditionalRates)
         {
             rateValue.Type = resources.GetString(rateValue.ResourceToken);
         }
     }
 }
Exemple #11
0
        private void SaveCurrentState()
        {
            if (_currentRatesTemplate == null)
                return;
            if (_state == null)
                _state = new List<TemplateRatesBase>();
            ITemplateRates currentTemplate =
                _state.FirstOrDefault(
                    template => template != null && template.Name == _currentRatesTemplate.Name);
            if (currentTemplate != null)
                _state.Remove((TemplateRatesBase)currentTemplate);

            var resources = new UIResources(Settings.GetSavedCulture());
             _currentRatesTemplate.Rates.Clear();
            foreach (DataGridViewRow row  in gridRates.Rows)
            {
                _currentRatesTemplate.Rates.Add(new RateValue() { ResourceToken = row.Cells[0].Value.ToString(), Type = resources.GetString(row.Cells[0].Value.ToString()), Rate = Convert.ToDecimal(row.Cells[2].Value) });
            }
            _currentRatesTemplate.AdditionalRates.Clear();
            foreach (DataGridViewRow row in gridAdditionalRates.Rows)
            {
                _currentRatesTemplate.AdditionalRates.Add(new RateValue() { ResourceToken = row.Cells[0].Value.ToString(), Type = resources.GetString(row.Cells[0].Value.ToString()), Rate = Convert.ToDecimal(row.Cells[2].Value) });
            }
            _state.Add((TemplateRatesBase)_currentRatesTemplate);
            //add rates
        }