Wednesday, December 1, 2010

test something

  1: using System;
  2: using System.Data;
  3: using System.Configuration;
  4: using System.Web.UI;
  5: using System.Web.UI.WebControls;
  6: using umbraco.cms.businesslogic;
  7: 
  8: namespace OrbitOne.Umbraco
  9: {
 10:     public abstract class BaseUserControl : UserControl
 11:     {
 12:         protected BaseUserControl()
 13:         {
 14:             this.Init += Page_Init;
 15:         }
 16: 
 17:         protected void Page_Init(object sender, EventArgs e)
 18:         {
 19:             DictionaryId = this.ToString();
 20: 
 21:             if (string.IsNullOrEmpty(DictionaryId))
 22:                 throw new Exception("DictionaryId cannot be null or empty when creating translation labels");
 23: 
 24:             if (Request["addtodictionary"] != null)
 25:             {
 26:                 CreateDictionaryItems();
 27:             }
 28: 
 29:             SetTranslation();
 30:         }
 31: 
 32:         protected void DisableButtonWhileSubmitting(Button button, string validationGroup)
 33:         {
 34:             var sbValid = new System.Text.StringBuilder();
 35:             sbValid.Append("if (typeof(Page_ClientValidate) == 'function') { ");
 36:             sbValid.Append("if (Page_ClientValidate('" + validationGroup + "') == false) { return false; }} ");
 37:             sbValid.Append("this.disabled = true;");
 38: 
 39:             //GetPostBackEventReference obtains a reference to a client-side script function that causes the server to post back to the page.
 40:             sbValid.Append(Page.GetPostBackEventReference(button));
 41:             sbValid.Append(";");
 42:             button.Attributes.Add("onclick", sbValid.ToString());
 43:         }
 44: 
 45:         #region UmbracoDictionaryFunctions
 46: 
 47:         private void SetTranslation()
 48:         {
 49:             if (!IsPostBack)
 50:             {
 51:                 setCopy(this.Controls);
 52:             }
 53:         }
 54: 
 55:         private void CreateDictionaryItems()
 56:         {
 57:             createDictionaryItems(this.Controls);
 58:             Response.Write("Dictionary Items Created");
 59:         }
 60: 
 61:         //loop all controls and set text
 62:         public void setCopy(ControlCollection controls)
 63:         {
 64: 
 65:             foreach (Control ctrl in controls)
 66:             {
 67: 
 68:                 if (ctrl is Panel)
 69:                 {
 70:                     setCopy(ctrl.Controls);
 71:                 }
 72: 
 73:                 if (ctrl is Literal)
 74:                 {
 75:                     if (umbraco.library.GetDictionaryItem(DictionaryId + "." + ctrl.ID) != string.Empty)
 76:                     {
 77:                         ((Literal)ctrl).Text = umbraco.library.GetDictionaryItem(DictionaryId + "." + ctrl.ID);
 78:                     }
 79:                 }
 80: 
 81:                 if (ctrl is HyperLink)
 82:                 {
 83:                     if (umbraco.library.GetDictionaryItem(DictionaryId + "." + ctrl.ID) != string.Empty)
 84:                     {
 85:                         ((HyperLink)ctrl).Text = umbraco.library.GetDictionaryItem(DictionaryId + "." + ctrl.ID);
 86:                     }
 87:                 }
 88: 
 89:                 if (ctrl is Button)
 90:                 {
 91:                     if (umbraco.library.GetDictionaryItem(DictionaryId + "." + ctrl.ID) != string.Empty)
 92:                     {
 93:                         ((Button)ctrl).Text = umbraco.library.GetDictionaryItem(DictionaryId + "." + ctrl.ID);
 94:                     }
 95: 
 96:                 }
 97: 
 98:                 if (ctrl is CheckBox)
 99:                 {
100:                     if (umbraco.library.GetDictionaryItem(DictionaryId + "." + ctrl.ID) != string.Empty)
101:                     {
102:                         ((CheckBox)ctrl).Text = umbraco.library.GetDictionaryItem(DictionaryId + "." + ctrl.ID);
103:                     }
104:                 }
105: 
106:                 if (ctrl is Label)
107:                 {
108:                     if (umbraco.library.GetDictionaryItem(DictionaryId + "." + ctrl.ID) != string.Empty)
109:                     {
110:                         ((Label)ctrl).Text = umbraco.library.GetDictionaryItem(DictionaryId + "." + ctrl.ID);
111:                     }
112:                 }
113: 
114:                 if (ctrl is BaseValidator)
115:                 {
116:                     if (umbraco.library.GetDictionaryItem(DictionaryId + "." + ctrl.ID) != string.Empty)
117:                     {
118:                         ((BaseValidator)ctrl).Text = umbraco.library.GetDictionaryItem(DictionaryId + "." + ctrl.ID);
119:                     }
120:                 }
121:             }
122:         }
123: 
124:         //loop all controls and create dictionary Item
125:         public void createDictionaryItems(ControlCollection Controls)
126:         {
127:             foreach (Control ctrl in Controls)
128:             {
129: 
130:                 if (ctrl is Panel)
131:                 {
132:                     createDictionaryItems(ctrl.Controls);
133:                 }
134: 
135:                 if (ctrl is Literal)
136:                 {
137:                     createDictionaryItem(DictionaryId + "." + ctrl.ID, ((Literal)ctrl).Text);
138:                 }
139: 
140:                 if (ctrl is HyperLink)
141:                 {
142:                     createDictionaryItem(DictionaryId + "." + ctrl.ID, ((HyperLink)ctrl).Text);
143:                 }
144: 
145:                 if (ctrl is Button)
146:                 {
147:                     createDictionaryItem(DictionaryId + "." + ctrl.ID, ((Button)ctrl).Text);
148:                 }
149: 
150:                 if (ctrl is CheckBox)
151:                 {
152:                     createDictionaryItem(DictionaryId + "." + ctrl.ID, ((CheckBox)ctrl).Text);
153:                 }
154: 
155:                 if (ctrl is Label)
156:                 {
157:                     createDictionaryItem(DictionaryId + "." + ctrl.ID, ((Label)ctrl).Text);
158:                 }
159: 
160:                 if (ctrl is BaseValidator)
161:                 {
162:                     createDictionaryItem(DictionaryId + "." + ctrl.ID, ((BaseValidator)ctrl).Text);
163:                 }
164:             }
165:         }
166: 
167: 
168:         //create dictionaryItem
169:         private void createDictionaryItem(string name, string defaulttext)
170:         {
171:             try
172:             {
173: 
174:                 Dictionary.DictionaryItem.addKey(name, defaulttext);
175: 
176:                 Response.Write("added " + name + "<br/>");
177:             }
178:             catch
179:             {
180:                 //allready exists
181:             }
182:         }
183: 
184:         //identifier for umbraco dictionary
185:         //string dictionaryId = "frmLoginLogout";
186:         public string DictionaryId { get; set; }
187: 
188:         #endregion
189:     }
190: }
191: 

test something

  1: using System;
  2: using System.Data;
  3: using System.Configuration;
  4: using System.Web.UI;
  5: using System.Web.UI.WebControls;
  6: using umbraco.cms.businesslogic;
  7: 
  8: namespace OrbitOne.Umbraco
  9: {
 10:     public abstract class BaseUserControl : UserControl
 11:     {
 12:         protected BaseUserControl()
 13:         {
 14:             this.Init += Page_Init;
 15:         }
 16: 
 17:         protected void Page_Init(object sender, EventArgs e)
 18:         {
 19:             DictionaryId = this.ToString();
 20: 
 21:             if (string.IsNullOrEmpty(DictionaryId))
 22:                 throw new Exception("DictionaryId cannot be null or empty when creating translation labels");
 23: 
 24:             if (Request["addtodictionary"] != null)
 25:             {
 26:                 CreateDictionaryItems();
 27:             }
 28: 
 29:             SetTranslation();
 30:         }
 31: 
 32:         protected void DisableButtonWhileSubmitting(Button button, string validationGroup)
 33:         {
 34:             var sbValid = new System.Text.StringBuilder();
 35:             sbValid.Append("if (typeof(Page_ClientValidate) == 'function') { ");
 36:             sbValid.Append("if (Page_ClientValidate('" + validationGroup + "') == false) { return false; }} ");
 37:             sbValid.Append("this.disabled = true;");
 38: 
 39:             //GetPostBackEventReference obtains a reference to a client-side script function that causes the server to post back to the page.
 40:             sbValid.Append(Page.GetPostBackEventReference(button));
 41:             sbValid.Append(";");
 42:             button.Attributes.Add("onclick", sbValid.ToString());
 43:         }
 44: 
 45:         #region UmbracoDictionaryFunctions
 46: 
 47:         private void SetTranslation()
 48:         {
 49:             if (!IsPostBack)
 50:             {
 51:                 setCopy(this.Controls);
 52:             }
 53:         }
 54: 
 55:         private void CreateDictionaryItems()
 56:         {
 57:             createDictionaryItems(this.Controls);
 58:             Response.Write("Dictionary Items Created");
 59:         }
 60: 
 61:         //loop all controls and set text
 62:         public void setCopy(ControlCollection controls)
 63:         {
 64: 
 65:             foreach (Control ctrl in controls)
 66:             {
 67: 
 68:                 if (ctrl is Panel)
 69:                 {
 70:                     setCopy(ctrl.Controls);
 71:                 }
 72: 
 73:                 if (ctrl is Literal)
 74:                 {
 75:                     if (umbraco.library.GetDictionaryItem(DictionaryId + "." + ctrl.ID) != string.Empty)
 76:                     {
 77:                         ((Literal)ctrl).Text = umbraco.library.GetDictionaryItem(DictionaryId + "." + ctrl.ID);
 78:                     }
 79:                 }
 80: 
 81:                 if (ctrl is HyperLink)
 82:                 {
 83:                     if (umbraco.library.GetDictionaryItem(DictionaryId + "." + ctrl.ID) != string.Empty)
 84:                     {
 85:                         ((HyperLink)ctrl).Text = umbraco.library.GetDictionaryItem(DictionaryId + "." + ctrl.ID);
 86:                     }
 87:                 }
 88: 
 89:                 if (ctrl is Button)
 90:                 {
 91:                     if (umbraco.library.GetDictionaryItem(DictionaryId + "." + ctrl.ID) != string.Empty)
 92:                     {
 93:                         ((Button)ctrl).Text = umbraco.library.GetDictionaryItem(DictionaryId + "." + ctrl.ID);
 94:                     }
 95: 
 96:                 }
 97: 
 98:                 if (ctrl is CheckBox)
 99:                 {
100:                     if (umbraco.library.GetDictionaryItem(DictionaryId + "." + ctrl.ID) != string.Empty)
101:                     {
102:                         ((CheckBox)ctrl).Text = umbraco.library.GetDictionaryItem(DictionaryId + "." + ctrl.ID);
103:                     }
104:                 }
105: 
106:                 if (ctrl is Label)
107:                 {
108:                     if (umbraco.library.GetDictionaryItem(DictionaryId + "." + ctrl.ID) != string.Empty)
109:                     {
110:                         ((Label)ctrl).Text = umbraco.library.GetDictionaryItem(DictionaryId + "." + ctrl.ID);
111:                     }
112:                 }
113: 
114:                 if (ctrl is BaseValidator)
115:                 {
116:                     if (umbraco.library.GetDictionaryItem(DictionaryId + "." + ctrl.ID) != string.Empty)
117:                     {
118:                         ((BaseValidator)ctrl).Text = umbraco.library.GetDictionaryItem(DictionaryId + "." + ctrl.ID);
119:                     }
120:                 }
121:             }
122:         }
123: 
124:         //loop all controls and create dictionary Item
125:         public void createDictionaryItems(ControlCollection Controls)
126:         {
127:             foreach (Control ctrl in Controls)
128:             {
129: 
130:                 if (ctrl is Panel)
131:                 {
132:                     createDictionaryItems(ctrl.Controls);
133:                 }
134: 
135:                 if (ctrl is Literal)
136:                 {
137:                     createDictionaryItem(DictionaryId + "." + ctrl.ID, ((Literal)ctrl).Text);
138:                 }
139: 
140:                 if (ctrl is HyperLink)
141:                 {
142:                     createDictionaryItem(DictionaryId + "." + ctrl.ID, ((HyperLink)ctrl).Text);
143:                 }
144: 
145:                 if (ctrl is Button)
146:                 {
147:                     createDictionaryItem(DictionaryId + "." + ctrl.ID, ((Button)ctrl).Text);
148:                 }
149: 
150:                 if (ctrl is CheckBox)
151:                 {
152:                     createDictionaryItem(DictionaryId + "." + ctrl.ID, ((CheckBox)ctrl).Text);
153:                 }
154: 
155:                 if (ctrl is Label)
156:                 {
157:                     createDictionaryItem(DictionaryId + "." + ctrl.ID, ((Label)ctrl).Text);
158:                 }
159: 
160:                 if (ctrl is BaseValidator)
161:                 {
162:                     createDictionaryItem(DictionaryId + "." + ctrl.ID, ((BaseValidator)ctrl).Text);
163:                 }
164:             }
165:         }
166: 
167: 
168:         //create dictionaryItem
169:         private void createDictionaryItem(string name, string defaulttext)
170:         {
171:             try
172:             {
173: 
174:                 Dictionary.DictionaryItem.addKey(name, defaulttext);
175: 
176:                 Response.Write("added " + name + "<br/>");
177:             }
178:             catch
179:             {
180:                 //allready exists
181:             }
182:         }
183: 
184:         //identifier for umbraco dictionary
185:         //string dictionaryId = "frmLoginLogout";
186:         public string DictionaryId { get; set; }
187: 
188:         #endregion
189:     }
190: }
191: 

Wednesday, May 5, 2010

Anthony Franco: The Laws of User Experience

I've watched this great presentation by Anthony Franco about User Experience and designing good interfaces.

Whether you want to sell more software, improve employee efficiency, enhance brand strength or increase ad revenue, great user experiences (UX) better play a large role in your business strategy. In this session, EffectiveUI President Anthony Franco discusses why and how engaging software drives value to strategic business goals by increasing site stickiness, differentiating from competitors and making users hungry for your product or services. Armed with insider stats and research from industry analysts across verticals, Anthony defines the criteria behind custom usable software and demonstrate real-world examples of socially enabled experiences that are good for business. You will leave this session with proof of how UX impacts your bottom line, as well as a roadmap to help you cost-effectively put the theory into practice.


Watch the MIX2010 session

Anthony's blog

Monday, May 3, 2010

Colorful Expression


Colorful Expression is an add-in for Expression Blend and Expression Design that brings you the Adobe Kuler community directly into your toolbox. It adds a new palette to your design environment, making it easy to leverage the community to find the perfect color theme for your application or design.

The add-in also available as a standalone application, making it useful for web developers working in Visual Studio or Expression Web to select colors for your CSS style sheets.


Check it out at: http://colorful.codeplex.com/

Saturday, February 28, 2009

How to post source code on blogspot / blogger

An easy way to post source code on blogspot / blogger is descriped in this blog post.

It involves using Microsoft’s Windows Live Writer with a third party plugin.

Check out skotl's blog for a complete walk-trough of how to share brilliant code on your blog using this technique.