DesignerHelpers.cs source code in C# .NET

Source code for the .NET framework in C#

                        

Code:

/ 4.0 / 4.0 / DEVDIV_TFS / Dev10 / Releases / RTMRel / ndp / cdf / src / WF / Activities / Rules / Design / DesignerHelpers.cs / 1305376 / DesignerHelpers.cs

                            using System; 
using System.CodeDom;
using System.Collections;
using System.Collections.Generic;
using System.Drawing; 
using System.IO;
using System.Windows.Forms; 
using System.Windows.Forms.Design; 
using System.Workflow.ComponentModel;
using System.Workflow.ComponentModel.Serialization; 
using System.Text;

namespace System.Workflow.Activities.Rules.Design
{ 
 	/// 
	/// Summary description for DesignerHelpers. 
	///  
	internal static class DesignerHelpers
 	{ 
		internal static void DisplayError(string message, string messageBoxTitle, IServiceProvider serviceProvider)
 		{
 			IUIService uis = null;
			if (serviceProvider != null) 
 				uis = (IUIService)serviceProvider.GetService(typeof(IUIService));
 
			if (uis != null) 
				uis.ShowError(message);
			else 
 				MessageBox.Show(message, messageBoxTitle, MessageBoxButtons.OK, MessageBoxIcon.Exclamation, MessageBoxDefaultButton.Button1, 0);
		}

        static internal string GetRulePreview(Rule rule) 
        {
            StringBuilder rulePreview = new StringBuilder(); 
 
            if (rule != null)
            { 
                rulePreview.Append("IF ");
                if (rule.Condition != null)
                    rulePreview.Append(rule.Condition.ToString() + " ");
                rulePreview.Append("THEN "); 

                foreach (RuleAction action in rule.ThenActions) 
                { 
                    rulePreview.Append(action.ToString());
                    rulePreview.Append(' '); 
                }

                if (rule.ElseActions.Count > 0)
                { 
                    rulePreview.Append("ELSE ");
                    foreach (RuleAction action in rule.ElseActions) 
                    { 
                        rulePreview.Append(action.ToString());
                        rulePreview.Append(' '); 
                    }
                }
            }
 
            return rulePreview.ToString();
        } 
 
        static internal string GetRuleSetPreview(RuleSet ruleSet)
        { 
            StringBuilder preview = new StringBuilder();
            bool first = true;
            if (ruleSet != null)
            { 
                foreach (Rule rule in ruleSet.Rules)
                { 
                    if (first) 
                        first = false;
                    else 
                        preview.Append("\n");

                    preview.Append(rule.Name);
                    preview.Append(": "); 
                    preview.Append(DesignerHelpers.GetRulePreview(rule));
                } 
            } 

            return preview.ToString(); 
        }
 	}
}

// File provided for Reference Use Only by Microsoft Corporation (c) 2007.
// Copyright (c) Microsoft Corporation. All rights reserved.
using System; 
using System.CodeDom;
using System.Collections;
using System.Collections.Generic;
using System.Drawing; 
using System.IO;
using System.Windows.Forms; 
using System.Windows.Forms.Design; 
using System.Workflow.ComponentModel;
using System.Workflow.ComponentModel.Serialization; 
using System.Text;

namespace System.Workflow.Activities.Rules.Design
{ 
 	/// 
	/// Summary description for DesignerHelpers. 
	///  
	internal static class DesignerHelpers
 	{ 
		internal static void DisplayError(string message, string messageBoxTitle, IServiceProvider serviceProvider)
 		{
 			IUIService uis = null;
			if (serviceProvider != null) 
 				uis = (IUIService)serviceProvider.GetService(typeof(IUIService));
 
			if (uis != null) 
				uis.ShowError(message);
			else 
 				MessageBox.Show(message, messageBoxTitle, MessageBoxButtons.OK, MessageBoxIcon.Exclamation, MessageBoxDefaultButton.Button1, 0);
		}

        static internal string GetRulePreview(Rule rule) 
        {
            StringBuilder rulePreview = new StringBuilder(); 
 
            if (rule != null)
            { 
                rulePreview.Append("IF ");
                if (rule.Condition != null)
                    rulePreview.Append(rule.Condition.ToString() + " ");
                rulePreview.Append("THEN "); 

                foreach (RuleAction action in rule.ThenActions) 
                { 
                    rulePreview.Append(action.ToString());
                    rulePreview.Append(' '); 
                }

                if (rule.ElseActions.Count > 0)
                { 
                    rulePreview.Append("ELSE ");
                    foreach (RuleAction action in rule.ElseActions) 
                    { 
                        rulePreview.Append(action.ToString());
                        rulePreview.Append(' '); 
                    }
                }
            }
 
            return rulePreview.ToString();
        } 
 
        static internal string GetRuleSetPreview(RuleSet ruleSet)
        { 
            StringBuilder preview = new StringBuilder();
            bool first = true;
            if (ruleSet != null)
            { 
                foreach (Rule rule in ruleSet.Rules)
                { 
                    if (first) 
                        first = false;
                    else 
                        preview.Append("\n");

                    preview.Append(rule.Name);
                    preview.Append(": "); 
                    preview.Append(DesignerHelpers.GetRulePreview(rule));
                } 
            } 

            return preview.ToString(); 
        }
 	}
}

// File provided for Reference Use Only by Microsoft Corporation (c) 2007.
// Copyright (c) Microsoft Corporation. All rights reserved.
                        

Link Menu

Network programming in C#, Network Programming in VB.NET, Network Programming in .NET
This book is available now!
Buy at Amazon US or
Buy at Amazon UK