Beispiel #1
0
        public static void ShowObject(object value, string caption, bool errorObjects = false)
        {
            if (DormantForm != null && DormantForm.Visible)
            {
                DormantForm.Close();
            }
            DormantForm = new ScriptOutputForm();

            DormantForm.Text       = caption;
            DormantForm.ShowErrors = errorObjects;
            if (DormantForm.ShowErrors)
            {
                DormantForm.chkDontShow.Visible           = false;
                DormantForm.DataListView.Width            = (DormantForm.Width * 3) / 5;
                DormantForm.DataListView.Columns[1].Name  = "Error";
                DormantForm.DataListView.Columns[1].Width = 500;
            }
            else
            {
                DormantForm.chkDontShow.Visible           = true;
                DormantForm.DataListView.Width            = DormantForm.Width / 2;
                DormantForm.DataListView.Columns[1].Name  = "Type";
                DormantForm.DataListView.Columns[1].Width = DormantForm.DataListView.Width - DormantForm.DataListView.Columns[0].Width - 5;
            }

            var testTabularObject = value as TabularObject;

            IEnumerable <ITabularNamedObject> testTabularCollection;

            if (value is IEnumerable <IDaxDependantObject> )
            {
                // Most IDaxDependantObjects are ITabularNamedObjects, with the exception of RLSFilterExpression.
                // So if we encounter an enumeration of IDaxDependantObjects lets convert it to an enumeration of
                // ITabularNamedObjects. If there are any RLSFilterExpressions in the enumeration, output their
                // corresponding roles instead.
                var v = (value as IEnumerable <IDaxDependantObject>);
                testTabularCollection = v.OfType <ITabularNamedObject>()
                                        .Concat(v.OfType <RLSFilterExpression>().Select(rls => rls.Role));
            }
            else
            {
                testTabularCollection = value as IEnumerable <ITabularNamedObject>;
            }
            var testDictionary = value as IDictionary;
            var testList       = value as IEnumerable <object>;

            if (value == null)
            {
                ShowString("(Null)");
            }
            else if (testTabularObject != null)
            {
                ShowTabularObject(testTabularObject);
            }
            else if (testTabularCollection != null)
            {
                ShowTabularObjectCollection(testTabularCollection);
            }
            else if (testDictionary != null)
            {
                ShowObjectDictionary(testDictionary);
            }
            else if (testList != null)
            {
                ShowObjectCollection(testList);
            }
            else
            {
                ShowString(value.ToString());
            }

            if (errorObjects)
            {
                DormantForm.Show();
                DormantForm.BringToFront();
                DormantForm.Activate();
            }
            else
            {
                if (DormantForm.Visible)
                {
                    DormantForm.Visible = false;
                }
                DormantForm.ShowDialog();
            }

            DontShow = DormantForm.chkDontShow.Checked;
        }
        public static void ShowObject(object value, string caption, bool errorObjects = false)
        {
            if (DormantForm != null && DormantForm.Visible)
            {
                DormantForm.Close();
            }
            DormantForm = new ScriptOutputForm();

            DormantForm.Text       = caption;
            DormantForm.ShowErrors = errorObjects;
            if (DormantForm.ShowErrors)
            {
                DormantForm.chkDontShow.Visible           = false;
                DormantForm.DataListView.Width            = (DormantForm.Width * 3) / 5;
                DormantForm.DataListView.Columns[1].Name  = "Error";
                DormantForm.DataListView.Columns[1].Width = 500;
            }
            else
            {
                DormantForm.chkDontShow.Visible           = true;
                DormantForm.DataListView.Width            = DormantForm.Width / 2;
                DormantForm.DataListView.Columns[1].Name  = "Type";
                DormantForm.DataListView.Columns[1].Width = DormantForm.DataListView.Width - DormantForm.DataListView.Columns[0].Width - 5;
            }

            var testTabularObject     = value as TabularObject;
            var testTabularCollection = value as IEnumerable <ITabularNamedObject>;
            var testDictionary        = value as IDictionary;
            var testList = value as IEnumerable <object>;

            if (value == null)
            {
                ShowString("(Null)");
            }
            else if (testTabularObject != null)
            {
                ShowTabularObject(testTabularObject);
            }
            else if (testTabularCollection != null)
            {
                ShowTabularObjectCollection(testTabularCollection);
            }
            else if (testDictionary != null)
            {
                ShowObjectDictionary(testDictionary);
            }
            else if (testList != null)
            {
                ShowObjectCollection(testList);
            }
            else
            {
                ShowString(value.ToString());
            }

            if (errorObjects)
            {
                DormantForm.Show();
                DormantForm.BringToFront();
                DormantForm.Activate();
            }
            else
            {
                if (DormantForm.Visible)
                {
                    DormantForm.Visible = false;
                }
                DormantForm.ShowDialog();
            }

            DontShow = DormantForm.chkDontShow.Checked;
        }