ReportNames is used to control the names of objects in the report
Beispiel #1
0
        private void bOK_Click(object sender, System.EventArgs e)
        {
            // Verify there are no duplicate names in the data sources
            Hashtable ht = new Hashtable(this.lbDataSources.Items.Count + 1);

            foreach (DataSourceValues dsv in lbDataSources.Items)
            {
                if (dsv.Name == null || dsv.Name.Length == 0)
                {
                    MessageBox.Show(this, "Name must be specified for all DataSources.", "Data Sources");
                    return;
                }

                if (!ReportNames.IsNameValid(dsv.Name))
                {
                    MessageBox.Show(this,
                                    string.Format("Name '{0}' contains invalid characters.", dsv.Name), "Data Sources");
                    return;
                }

                string name = (string)ht[dsv.Name];
                if (name != null)
                {
                    MessageBox.Show(this,
                                    string.Format("Each DataSource must have a unique name. '{0}' is repeated.", dsv.Name), "Data Sources");
                    return;
                }
                ht.Add(dsv.Name, dsv.Name);
            }

            // apply the result
            Apply();
            DialogResult = DialogResult.OK;
        }
        private void bOK_Click(object sender, System.EventArgs e)
        {
            // Verify there are no duplicate names in the embedded list
            Hashtable ht = new Hashtable(lbImages.Items.Count + 1);

            foreach (EmbeddedImageValues eiv in lbImages.Items)
            {
                if (eiv.Name == null || eiv.Name.Length == 0)
                {
                    MessageBox.Show(this, Strings.DialogEmbeddedImages_ShowE_NameMustSpecified, Strings.DialogEmbeddedImages_ShowE_Image);
                    return;
                }

                if (!ReportNames.IsNameValid(eiv.Name))
                {
                    MessageBox.Show(this,
                                    string.Format(Strings.DialogEmbeddedImages_ShowE_NameInvalid, eiv.Name), Strings.DialogEmbeddedImages_ShowE_Image);
                    return;
                }

                string name = (string)ht[eiv.Name];
                if (name != null)
                {
                    MessageBox.Show(this,
                                    string.Format(Strings.DialogEmbeddedImages_ShowE_ImageMustUniqueName, eiv.Name), Strings.DialogEmbeddedImages_ShowE_Image);
                    return;
                }
                ht.Add(eiv.Name, eiv.Name);
            }

            Apply();
            DialogResult = DialogResult.OK;
        }
Beispiel #3
0
        private void bOK_Click(object sender, System.EventArgs e)
        {
            // Verify there are no duplicate names in the embedded list
            Hashtable ht = new Hashtable(lbImages.Items.Count + 1);

            foreach (EmbeddedImageValues eiv in lbImages.Items)
            {
                if (eiv.Name == null || eiv.Name.Length == 0)
                {
                    MessageBox.Show(this, "Name must be specified for all embedded images.", "Image");
                    return;
                }

                if (!ReportNames.IsNameValid(eiv.Name))
                {
                    MessageBox.Show(this,
                                    string.Format("Name '{0}' contains invalid characters.", eiv.Name), "Image");
                    return;
                }

                string name = (string)ht[eiv.Name];
                if (name != null)
                {
                    MessageBox.Show(this,
                                    string.Format("Each embedded image must have a unique name. '{0}' is repeated.", eiv.Name), "Image");
                    return;
                }
                ht.Add(eiv.Name, eiv.Name);
            }

            Apply();
            DialogResult = DialogResult.OK;
        }
Beispiel #4
0
        private void bOK_Click(object sender, System.EventArgs e)
        {
            // Verify there are no duplicate names in the data sources
            Hashtable ht = new Hashtable(this.lbDataSources.Items.Count + 1);

            foreach (DataSourceValues dsv in lbDataSources.Items)
            {
                if (dsv.Name == null || dsv.Name.Length == 0)
                {
                    MessageBox.Show(this, Strings.DialogDataSources_ShowE_NameMustSpecified, Strings.DialogDataSources_ShowE_DataSources);
                    return;
                }

                if (!ReportNames.IsNameValid(dsv.Name))
                {
                    MessageBox.Show(this,
                                    string.Format(Strings.DialogDataSources_ShowE_NameInvalid, dsv.Name), Strings.DialogDataSources_ShowE_DataSources);
                    return;
                }

                string name = (string)ht[dsv.Name];
                if (name != null)
                {
                    MessageBox.Show(this,
                                    string.Format(Strings.DialogDataSources_ShowE_DataSourceMustUniqueN, dsv.Name), Strings.DialogDataSources_ShowE_DataSources);
                    return;
                }
                ht.Add(dsv.Name, dsv.Name);
            }

            // apply the result
            Apply();
            DialogResult = DialogResult.OK;
        }
 private void tbEIName_Validating(object sender, System.ComponentModel.CancelEventArgs e)
 {
     if (!ReportNames.IsNameValid(tbEIName.Text))
     {
         e.Cancel = true;
         MessageBox.Show(this,
                         string.Format(Strings.DialogEmbeddedImages_ShowE_NameInvalid, tbEIName.Text), Strings.DialogEmbeddedImages_ShowE_Image);
     }
 }
Beispiel #6
0
 private void tbEIName_Validating(object sender, System.ComponentModel.CancelEventArgs e)
 {
     if (!ReportNames.IsNameValid(tbEIName.Text))
     {
         e.Cancel = true;
         MessageBox.Show(this,
                         string.Format("Name '{0}' contains invalid characters.", tbEIName.Text), "Image");
     }
 }
Beispiel #7
0
        private void tbDSName_Validating(object sender, System.ComponentModel.CancelEventArgs e)
        {
            int cur = lbDataSources.SelectedIndex;

            if (cur < 0)
            {
                return;
            }

            if (!ReportNames.IsNameValid(tbDSName.Text))
            {
                e.Cancel = true;
                MessageBox.Show(this,
                                string.Format("Name '{0}' contains invalid characters.", tbDSName.Text), "Data Sources");
            }
        }
Beispiel #8
0
        private void tbName_Validating(object sender, System.ComponentModel.CancelEventArgs e)
        {
            bool bRows = HasRows();

            // If no rows and no data in name it's ok
            if (!bRows && this.tbName.Text.Trim().Length == 0)
            {
                return;
            }

            if (!ReportNames.IsNameValid(tbName.Text))
            {
                e.Cancel = true;
                MessageBox.Show(string.Format("{0} is an invalid name.", tbName.Text), "Name");
            }
        }
Beispiel #9
0
        private void tbDSName_Validating(object sender, System.ComponentModel.CancelEventArgs e)
        {
            int cur = lbDataSources.SelectedIndex;

            if (cur < 0)
            {
                return;
            }

            if (!ReportNames.IsNameValid(tbDSName.Text))
            {
                e.Cancel = true;
                MessageBox.Show(this,
                                string.Format(Strings.DialogDataSources_ShowE_NameInvalid, tbDSName.Text), Strings.DialogDataSources_ShowE_DataSources);
            }
        }
        private void bImport_Click(object sender, System.EventArgs e)
        {
            OpenFileDialog ofd = new OpenFileDialog();

            ofd.Filter          = Strings.DialogEmbeddedImages_bImport_Click_ImageFilesFilter;
            ofd.FilterIndex     = 6;
            ofd.CheckFileExists = true;
            ofd.Multiselect     = true;
            try
            {
                if (ofd.ShowDialog(this) != DialogResult.OK)
                {
                    return;
                }

                // need to create a new embedded image(s)
                int cur = 0;
                foreach (string filename in ofd.FileNames)
                {
                    Stream strm             = null;
                    System.Drawing.Image im = null;
                    string imagedata        = null;
                    try
                    {
                        strm      = new FileStream(filename, FileMode.Open, FileAccess.Read, FileShare.Read);
                        im        = System.Drawing.Image.FromStream(strm);
                        imagedata = this.GetBase64Image(im);
                    }
                    catch (Exception ex)
                    {
                        MessageBox.Show(this, ex.Message, Strings.DialogEmbeddedImages_ShowE_Image);
                    }
                    finally
                    {
                        if (strm != null)
                        {
                            strm.Close();
                        }
                        if (im != null)
                        {
                            im.Dispose();
                        }
                    }

                    if (imagedata != null)
                    {
                        FileInfo fi = new FileInfo(filename);

                        string fname;
                        int    offset = fi.Name.IndexOf('.');
                        if (offset >= 0)
                        {
                            fname = fi.Name.Substring(0, offset);
                        }
                        else
                        {
                            fname = fi.Name;
                        }

                        if (!ReportNames.IsNameValid(fname))
                        {
                            fname = "embeddedimage";
                        }
                        // Now check to see if we already have one with that name
                        int  index = 1;
                        bool bDup  = true;
                        while (bDup)
                        {
                            bDup = false;
                            foreach (EmbeddedImageValues ev in lbImages.Items)
                            {
                                if (fname == ev.Name)
                                {
                                    bDup = true;
                                    break;
                                }
                            }
                            if (bDup)
                            {                                                // we have a duplicate name; try adding an index number
                                fname  = Regex.Replace(fname, "[0-9]*", ""); // remove old numbers (side effect removes all numbers)
                                fname += index.ToString();
                                index++;
                            }
                        }

                        EmbeddedImageValues eiv = new EmbeddedImageValues(fname);
                        eiv.MIMEType  = "image/png";
                        eiv.ImageData = imagedata;
                        cur           = this.lbImages.Items.Add(eiv);
                    }
                }
                lbImages.SelectedIndex = cur;
            }
            finally
            {
                ofd.Dispose();
            }
            this.tbEIName.Focus();
        }