private void openReportWithAllDimensionsToolStripMenuItem_Click(object sender, EventArgs e)
        {
            try
            {
                List <VisualizeAttributeLatticeImageForReport> images = new List <VisualizeAttributeLatticeImageForReport>();
                foreach (Microsoft.AnalysisServices.Dimension d in dimension.Parent.Dimensions)
                {
                    Bitmap img = VisualizeAttributeLattice.Render(d, VisualizeAttributeLattice.LatticeLayoutMethod.DeepestPathsFirst, showOnlyMultilevelRelationshipsToolStripMenuItem.Checked);
                    images.Add(new VisualizeAttributeLatticeImageForReport(d.Name, img));
                    img.Dispose();
                }

                ReportViewerForm frm = new ReportViewerForm();
                frm.ReportBindingSource.DataSource = images;
                frm.Report = "SSAS.VisualizeAttributeLattice.rdlc";
                Microsoft.Reporting.WinForms.ReportDataSource reportDataSource1 = new Microsoft.Reporting.WinForms.ReportDataSource();
                reportDataSource1.Name  = "VisualizeAttributeLatticeImageForReport";
                reportDataSource1.Value = frm.ReportBindingSource;
                frm.ReportViewerControl.LocalReport.DataSources.Add(reportDataSource1);
                frm.ReportViewerControl.LocalReport.ReportEmbeddedResource = "SSAS.VisualizeAttributeLattice.rdlc";

                frm.Caption = "Visualize All Attribute Lattices";
                frm.Show();
            }
            catch (System.Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
        }
 private void saveAllDimensionsToFolderToolStripMenuItem_Click(object sender, EventArgs e)
 {
     try
     {
         FolderBrowserDialog dlg = new FolderBrowserDialog();
         dlg.Description         = "Save images of all dimension to directory...";
         dlg.ShowNewFolderButton = true;
         //dlg.RootFolder = System.Environment.SpecialFolder.;
         if (dlg.ShowDialog(this) == DialogResult.OK)
         {
             System.Drawing.Imaging.EncoderParameters parameters1 = new System.Drawing.Imaging.EncoderParameters(3);
             parameters1.Param[0] = new System.Drawing.Imaging.EncoderParameter(System.Drawing.Imaging.Encoder.Compression, 2L);
             parameters1.Param[1] = new System.Drawing.Imaging.EncoderParameter(System.Drawing.Imaging.Encoder.Quality, 95L);
             parameters1.Param[2] = new System.Drawing.Imaging.EncoderParameter(System.Drawing.Imaging.Encoder.ColorDepth, 24L);
             foreach (Microsoft.AnalysisServices.Dimension d in dimension.Parent.Dimensions)
             {
                 Bitmap img = VisualizeAttributeLattice.Render(d, VisualizeAttributeLattice.LatticeLayoutMethod.DeepestPathsFirst, showOnlyMultilevelRelationshipsToolStripMenuItem.Checked);
                 img.Save(dlg.SelectedPath + "\\" + d.Name + ".jpg", VisualizeAttributeLattice.GetJpegCodec(), parameters1);
                 img.Dispose();
             }
         }
     }
     catch (Exception ex)
     {
         MessageBox.Show("Error: " + ex.Message);
     }
 }
        private void LayoutImage()
        {
            if (pictureBox1.Image != null)
            {
                pictureBox1.Image.Dispose();
            }
            if (currentLayoutType == layoutAToolStripMenuItem)
            {
                layoutAToolStripMenuItem.Checked = true;
                layoutBToolStripMenuItem.Checked = false;
                layoutCToolStripMenuItem.Checked = false;
                pictureBox1.Image = VisualizeAttributeLattice.Render(dimension, VisualizeAttributeLattice.LatticeLayoutMethod.DeepestPathsFirst, showOnlyMultilevelRelationshipsToolStripMenuItem.Checked);
            }
            else if (currentLayoutType == layoutBToolStripMenuItem)
            {
                layoutAToolStripMenuItem.Checked = false;
                layoutBToolStripMenuItem.Checked = true;
                layoutCToolStripMenuItem.Checked = false;
                pictureBox1.Image = VisualizeAttributeLattice.Render(dimension, VisualizeAttributeLattice.LatticeLayoutMethod.ShortSingleLevelRelationshipsFirst, showOnlyMultilevelRelationshipsToolStripMenuItem.Checked);
            }
            else
            {
                layoutAToolStripMenuItem.Checked = false;
                layoutBToolStripMenuItem.Checked = false;
                layoutCToolStripMenuItem.Checked = true;
                pictureBox1.Image = VisualizeAttributeLattice.Render(dimension, VisualizeAttributeLattice.LatticeLayoutMethod.ShortRelationshipsFirst, showOnlyMultilevelRelationshipsToolStripMenuItem.Checked);
            }

            pictureBox1.Width  = pictureBox1.Image.Width;
            pictureBox1.Height = pictureBox1.Image.Height;
            this.Text          = dimension.Name + " - Attribute Lattice";
            if (pictureBox1.Width > 600)
            {
                if (this.WindowState != FormWindowState.Maximized)
                {
                    this.Width = 600;
                }
                panel1.AutoScrollPosition = new Point(0, panel1.AutoScrollPosition.Y);
                pictureBox1.Left          = 0;
                panel1.AutoScrollPosition = new Point((pictureBox1.Width - this.Width) / 2, panel1.AutoScrollPosition.Y);
            }
            else if (pictureBox1.Width < 300)
            {
                if (this.WindowState != FormWindowState.Maximized)
                {
                    this.Width = 300;
                }
                panel1.AutoScrollPosition = new Point(0, panel1.AutoScrollPosition.Y);
                pictureBox1.Left          = (this.Width - pictureBox1.Width) / 2;
                panel1.AutoScrollPosition = new Point(0, 0);
            }
            else
            {
                if (this.WindowState != FormWindowState.Maximized)
                {
                    this.Width = pictureBox1.Width + 30;
                }
                panel1.AutoScrollPosition = new Point(0, 0);
                pictureBox1.Left          = 0;
            }

            if (this.WindowState != FormWindowState.Maximized)
            {
                if (pictureBox1.Height + 100 > 600)
                {
                    this.Height = 600;
                }
                else if (pictureBox1.Height + 100 < 300)
                {
                    this.Height = 300;
                }
                else
                {
                    this.Height = pictureBox1.Height + 100;
                }
            }
        }