/IZWebFileManager/FileType.cs
C# | 115 lines | 81 code | 19 blank | 15 comment | 9 complexity | 4fedf99b13c69b362e3427dd0ddd09f9 MD5 | raw file
1// Copyright (C) 2006 Igor Zelmanovich <izwebfilemanager@gmail.com> 2// 3// This program is free software; you can redistribute it and/or modify 4// it under the terms of the GNU General Public License as published by 5// the Free Software Foundation; either version 2 of the License, or 6// (at your option) any later version. 7// 8// This program is distributed in the hope that it will be useful, 9// but WITHOUT ANY WARRANTY; without even the implied warranty of 10// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 11// GNU General Public License for more details. 12// 13// You should have received a copy of the GNU General Public License 14// along with this program; if not, write to the Free Software 15// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 16 17using System; 18using System.Collections.Generic; 19using System.Text; 20using System.Web.UI; 21using System.Collections.ObjectModel; 22using System.ComponentModel; 23using System.Web.UI.WebControls; 24using System.Drawing.Design; 25using System.Diagnostics.CodeAnalysis; 26 27namespace IZ.WebFileManager 28{ 29 [PersistChildren (false)] 30 [ParseChildren (true)] 31 public sealed class FileType : IStateManager 32 { 33 readonly StateBag bag = new StateBag (); 34 readonly FileManagerCommandCollection fileManagerCommandCollection = new FileManagerCommandCollection (); 35 36 [MergableProperty (true)] 37 [PersistenceMode (PersistenceMode.InnerProperty)] 38 public FileManagerCommandCollection Commands { 39 get { return fileManagerCommandCollection; } 40 } 41 42 [SuppressMessage ("Microsoft.Design", "CA1056:UriPropertiesShouldNotBeStrings")] 43 [Editor ("System.Web.UI.Design.ImageUrlEditor, System.Design, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a", typeof (UITypeEditor))] 44 [DefaultValue ("")] 45 [UrlProperty] 46 [Bindable (true)] 47 public string SmallImageUrl { 48 get { return bag ["SmallIconUrl"] == null ? String.Empty : (string) bag ["SmallIconUrl"]; } 49 set { bag ["SmallIconUrl"] = value; } 50 } 51 52 [SuppressMessage ("Microsoft.Design", "CA1056:UriPropertiesShouldNotBeStrings")] 53 [Editor ("System.Web.UI.Design.ImageUrlEditor, System.Design, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a", typeof (UITypeEditor))] 54 [DefaultValue ("")] 55 [UrlProperty] 56 [Bindable (true)] 57 public string LargeImageUrl { 58 get { return bag ["LargeIconUrl"] == null ? String.Empty : (string) bag ["LargeIconUrl"]; } 59 set { bag ["LargeIconUrl"] = value; } 60 } 61 62 [DefaultValue ("")] 63 public string Extensions { 64 get { return bag ["Extensions"] == null ? String.Empty : (string) bag ["Extensions"]; } 65 set { bag ["Extensions"] = value; } 66 } 67 68 [DefaultValue ("")] 69 public string Name { 70 get { return bag ["Name"] == null ? String.Empty : (string) bag ["Name"]; } 71 set { bag ["Name"] = value; } 72 } 73 74 75 #region IStateManager Members 76 77 bool IStateManager.IsTrackingViewState { 78 get { return ((IStateManager) bag).IsTrackingViewState; } 79 } 80 81 void IStateManager.LoadViewState (object state) { 82 if (state == null) 83 return; 84 85 object [] states = (object []) state; 86 87 ((IStateManager) bag).LoadViewState (states [0]); 88 ((IStateManager) Commands).LoadViewState (states [1]); 89 } 90 91 object IStateManager.SaveViewState () { 92 object [] states = new object [2]; 93 94 states [0] = ((IStateManager) bag).SaveViewState (); 95 states [1] = ((IStateManager) Commands).SaveViewState (); 96 97 for (int i = 0; i < states.Length; i++) { 98 if (states [i] != null) 99 return states; 100 } 101 return null; 102 } 103 104 void IStateManager.TrackViewState () { 105 ((IStateManager) bag).TrackViewState (); 106 ((IStateManager) Commands).TrackViewState (); 107 } 108 109 #endregion 110 111 internal void SetDirty () { 112 bag.SetDirty (true); 113 } 114 } 115}