Library.Application

This property returns the associated application.

This property is read only.

Syntax Parameters Return Value
- - Application

C# Example

Creating and Editing a Box & Whisker Plot in C#:

using System;
using System.Drawing;
using System.Collections;
using System.ComponentModel;
using System.Windows.Forms;
using System.Data;

//Create a Windows Form C# project and paste this code into the main form's CS file.
//Then, in the main program CS file, change this line:
//    Application.Run(new Form1());

//to this:
//    Application.Run(new CSharpExample.MainForm());
//Finally, add these COM references to the project:
// - Statistica Graphics Type Library
// - Statistica Object Library
namespace CSharpExample
{
    /// <summary>
    /// Summary description for CSharpForm.
    /// </summary>
    public class MainForm : System.Windows.Forms.Form
    {
        private System.Windows.Forms.Button IDD_OPEN_DATASET;

        /// <summary>
        /// Required designer variable.
        /// </summary>
        private System.ComponentModel.Container components = null;

        public MainForm()
        {
            // Required for Windows Form Designer support
            InitializeComponent();
        }

        /// <summary>
        /// Clean up any resources being used.
        /// </summary>
        protected override void Dispose(bool disposing)
        {
            if (disposing)
            {

                if (components != null)
                {
                    components.Dispose();
                }

            }
            base.Dispose(disposing);
        }

        #region Windows Form Designer generated code

        /// <summary>
        /// Required method for Designer support - do not modify
        /// the contents of this method with the code editor.
        /// </summary>
        private void InitializeComponent()
        {
            this.IDD_OPEN_DATASET = new System.Windows.Forms.Button();
            this.SuspendLayout();

            // IDD_OPEN_DATASET

            this.IDD_OPEN_DATASET.Location = new System.Drawing.Point(8, 8);
            this.IDD_OPEN_DATASET.Name = "IDD_OPEN_DATASET";
            this.IDD_OPEN_DATASET.RightToLeft = System.Windows.Forms.RightToLeft.No;
            this.IDD_OPEN_DATASET.Size = new System.Drawing.Size(184, 40);
            this.IDD_OPEN_DATASET.TabIndex = 0;
            this.IDD_OPEN_DATASET.Text = "&Open Spreadsheet";
            this.IDD_OPEN_DATASET.Click += new System.EventHandler(this.IDD_OPEN_DATASET_Click);

            // MainForm

            this.AutoScaleBaseSize = new System.Drawing.Size(5, 13);
            this.ClientSize = new System.Drawing.Size(200, 53);
            this.Controls.AddRange(new System.Windows.Forms.Control[] { this.IDD_OPEN_DATASET });
            this.Name = "MainForm";
            this.Text = "Box and Whisker Plot";
            this.ResumeLayout(false);
        }

        #endregion

        /// <summary>
        /// The main entry point for the application.
        /// </summary>
        [STAThread]

        private void IDD_OPEN_DATASET_Click(object sender, System.EventArgs e)
        {
            //see which spreadsheet the user wishes to use
            OpenFileDialog FileDlg = new OpenFileDialog();
            FileDlg.InitialDirectory = "c:\\";
            FileDlg.Filter = "Spreadsheet file (*.sta)|*.sta";
            FileDlg.FilterIndex = 2;

            //quit if user presses the cancel button
            if (FileDlg.ShowDialog() == DialogResult.Cancel)
            {
                return;
            }

            //get the file pathway
            string FilePath = FileDlg.FileName;

            //launch an instance of STATISTICA
            STATISTICA.Application StatApp = new STATISTICA.Application();
            //If Enterprise is installed, then pass in the username and password to login.
            //This will need to be customized for your system.
            StatApp.SWSInfo("Isabelle", "password123");
            StatApp.Visible = true;

            //open the spreadsheet--note that a cast is necessary because
            //Spreadsheets.open() returns as an Object
            STATISTICA.Spreadsheet spr =
                (STATISTICA.Spreadsheet)StatApp.Spreadsheets.Open(FilePath, true);

            //create a box and whisker plot
            CreateBoxAndWhisker(StatApp, spr);
        }

        /// <summary>
        /// creates a box and whisker plot with outliers calculated from standard
        /// error plus means
        /// </summary>
        public void CreateBoxAndWhisker(STATISTICA.Application StatApp,
        STATISTICA.Spreadsheet DataSet)
        {
            STATISTICA.Analysis newanalysis =
            StatApp.Analysis((STATISTICA.AnalysisIdentifier)11010, DataSet);
            STATISTICA.BoxPlot2D BoxPlotDlg = (STATISTICA.BoxPlot2D)newanalysis.Dialog;

            //set the box plot's options
            BoxPlotDlg.set_DependentVariable("2");
            BoxPlotDlg.BoxMode = 0; //regular mode
            BoxPlotDlg.MiddlePointValue = 0; //midpoint is mean
            BoxPlotDlg.MiddlePointStyle = 0;
            BoxPlotDlg.MiddlePointPooledVariance = false;
            BoxPlotDlg.MultipleBoxLayout = 0; //multiple plot shift
            BoxPlotDlg.TrimDistribExtremes = 0;
            BoxPlotDlg.ConnectMiddlePoint = false;
            BoxPlotDlg.MeanBoxValue = 0; //means + std. err.
            BoxPlotDlg.MeanWhiskerValue = (STATISTICA.MeanWhiskerValueType)4; //Min-Max values
            BoxPlotDlg.Outliers = (STATISTICA.Outlier)3; //outliers and extremes
            BoxPlotDlg.OutliersCoefficient = 1.500000;
            BoxPlotDlg.DisplayFTestAndP = false;
            BoxPlotDlg.DisplayKruskalWallisTest = false;
            BoxPlotDlg.set_BoxCoefficient(0, 1);
            BoxPlotDlg.set_WhiskerCoefficient(0, 1.000000);

            //get access to the box and whisker plot within the analysis
            STATISTICA.StaDocuments docs = (STATISTICA.StaDocuments)BoxPlotDlg.Graphs;
            STATISTICAGraphics.Graph grph = (STATISTICAGraphics.Graph)docs[1];

            //customize the graph
            CustomizeBoxPlot(grph);
        }

        /// <summary>
        /// customizes the box plot
        /// </summary>
        public void CustomizeBoxPlot(STATISTICAGraphics.Graph BoxPlot)
        {
            STATISTICAGraphics.Layout2D GraphLayout =
                (STATISTICAGraphics.Layout2D)BoxPlot.Content;

            //add your company name to the title
            BoxPlot.Titles[1].Text = "Acme corporation";

            //set the background to be transparent
            GraphLayout.Attribute.Background.Color.Transparent = true;

            //present the box plot
            BoxPlot.Visible = true;
        }
    }
}