BlueSky.CommandExecutionHelper.ExecuteSplit C# (CSharp) Method

ExecuteSplit() public method

public ExecuteSplit ( string command = null, FrameworkElement fe = null ) : void
command string
fe System.Windows.FrameworkElement
return void
        public void ExecuteSplit(string command = null, FrameworkElement fe = null)
        {
            CommandRequest cr = new CommandRequest();
            cr.CommandSyntax = command;
            string stmt = command; //cmd.CommandSyntax;
            if (stmt.Contains("BSkySetDataFrameSplit("))///executes when SPLIT is fired from menu
            {
                bool setsplit = false;
                int startind = 0; int endind = 0;
                if (stmt.Contains("col.names"))
                {
                    startind = stmt.IndexOf("c(", stmt.IndexOf("col.names"));// index of c(
                }
                else
                {
                    startind = stmt.IndexOf("c(");// index of c(
                }
                if (startind > 0)
                    endind = stmt.IndexOf(")", startind);
                if (startind > 0 && endind > startind)
                {
                    int len = endind - startind + 1; // finding the length of  c(......)
                    string str = stmt.Substring(startind, len); // this will contain c('tg0','tg1') or just c()
                    string ch = null;
                    if (str.Contains("'")) ch = "'";
                    if (str.Contains('"')) ch = "\"";
                    if (ch != null && ch.Length > 0)
                    {
                        int i = str.IndexOf(ch);
                        int j = -1;
                        if (i >= 0) j = str.IndexOf(ch, i + 1);
                        if (j < 0) j = i + 1;
                        string sub = str.Substring(i + 1, (j - i - 1)).Trim();
                        if (i < 0)
                            i = str.IndexOf("'");
                        if (i >= 0)
                        {
                            if (sub.Length > 0)
                                setsplit = true;
                        }
                    }
                }
                //Executing the command in R///
                analytics.ExecuteR(cr,false,false);

                ////Creating a command output////11Jul2014

                CommandOutput splitCo = new CommandOutput();
                splitCo.NameOfAnalysis = "Split:#" + setsplit;
                splitCo.IsFromSyntaxEditor = false;

                AUParagraph aup = new AUParagraph();
                aup.FontSize = BSkyStyler.BSkyConstants.TEXT_FONTSIZE;//App.HEADER_FONTSIZE;
                aup.Text = stmt;
                aup.ControlType = "Header";// treenodename.Length < treenodecharlen ? treenodename : treenodename.Substring(0, treenodecharlen);
                splitCo.Add(aup);

                //////////  Setting/Unsetting Macro  for SPLIT //////////
                if (setsplit)
                {
                    OutputHelper.AddGlobalObject(string.Format("GLOBAL.{0}.SPLIT", UIController.GetActiveDocument().Name), fe);
                    //window.Template = null; //11Mar2013 release the XAML object. ie obj is no more child of window.
                    AddToSyntaxSession(splitCo);//11Jul2014 SendToOutputWindow(dialogTitle, stmt);
                    Refresh_Statusbar();// RefreshGrids();
                    return;// no need to do any thing further
                }
                else // unset split
                {
                    OutputHelper.DeleteGlobalObject(string.Format("GLOBAL.{0}.SPLIT", UIController.GetActiveDocument().Name));
                    //if (window != null && window.Template != null)
                    //    window.Template = null; //11Mar2013 release the XAML object. ie obj is no more child of window.
                    AddToSyntaxSession(splitCo);//11Jul2014 SendToOutputWindow(dialogTitle, stmt);
                    Refresh_Statusbar();// RefreshGrids();
                    return;// no need to do any thing further
                }
            }

        }

Usage Example

        private void ExecuteSplit(string stmt)
        {
            //object o = null;
            CommandRequest cmd = new CommandRequest();

            CommandExecutionHelper ceh = new CommandExecutionHelper();
            UAMenuCommand uamc = new UAMenuCommand();
            uamc.bskycommand = stmt;
            uamc.commandtype = stmt;
            cmd.CommandSyntax = stmt;
            ceh.ExecuteSplit(stmt, FElement);
            ceh = null;
        }