PageRenderTime 82ms CodeModel.GetById 40ms app.highlight 7ms RepoModel.GetById 33ms app.codeStats 0ms

/IZWebFileManager/ToolbarOptions.cs

http://izwebfilemanager.googlecode.com/
C# | 141 lines | 113 code | 13 blank | 15 comment | 9 complexity | 4c48742253434432d32dbb10a83bf882 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.ComponentModel;
 22
 23namespace IZ.WebFileManager
 24{
 25	[TypeConverter (typeof (ExpandableObjectConverter))]
 26	public sealed class ToolbarOptions
 27	{
 28		[Flags]
 29		enum OptionsEnum
 30		{
 31			ShowAll = 0xFF,
 32			ShowCopyButton = 0x01,
 33			ShowMoveButton = 0x02,
 34			ShowDeleteButton = 0x04,
 35			ShowRenameButton = 0x08,
 36			ShowFolderUpButton = 0x10,
 37			ShowViewButton = 0x20,
 38			ShowNewFolderButton = 0x40,
 39			ShowRefreshButton = 0x80,
 40		}
 41
 42		internal ToolbarOptions (StateBag viewState) {
 43			_viewState = viewState;
 44		}
 45
 46		StateBag _viewState;
 47
 48		OptionsEnum Options {
 49			get { return _viewState ["ToolbarOptions"] == null ? OptionsEnum.ShowAll : (OptionsEnum) _viewState ["ToolbarOptions"]; }
 50			set { _viewState ["ToolbarOptions"] = value; }
 51		}
 52
 53		[DefaultValue (true)]
 54		public bool ShowCopyButton {
 55			get { return (Options & OptionsEnum.ShowCopyButton) > 0; }
 56			set {
 57				if (value)
 58					Options |= OptionsEnum.ShowCopyButton;
 59				else
 60					Options &= OptionsEnum.ShowAll ^ OptionsEnum.ShowCopyButton;
 61			}
 62		}
 63
 64		[DefaultValue (true)]
 65		public bool ShowMoveButton {
 66			get { return (Options & OptionsEnum.ShowMoveButton) > 0; }
 67			set {
 68				if (value)
 69					Options |= OptionsEnum.ShowMoveButton;
 70				else
 71					Options &= OptionsEnum.ShowAll ^ OptionsEnum.ShowMoveButton;
 72			}
 73		}
 74
 75		[DefaultValue (true)]
 76		public bool ShowDeleteButton {
 77			get { return (Options & OptionsEnum.ShowDeleteButton) > 0; }
 78			set {
 79				if (value)
 80					Options |= OptionsEnum.ShowDeleteButton;
 81				else
 82					Options &= OptionsEnum.ShowAll ^ OptionsEnum.ShowDeleteButton;
 83			}
 84		}
 85
 86		[DefaultValue (true)]
 87		public bool ShowFolderUpButton {
 88			get { return (Options & OptionsEnum.ShowFolderUpButton) > 0; }
 89			set {
 90				if (value)
 91					Options |= OptionsEnum.ShowFolderUpButton;
 92				else
 93					Options &= OptionsEnum.ShowAll ^ OptionsEnum.ShowFolderUpButton;
 94			}
 95		}
 96
 97		[DefaultValue (true)]
 98		public bool ShowRenameButton {
 99			get { return (Options & OptionsEnum.ShowRenameButton) > 0; }
100			set {
101				if (value)
102					Options |= OptionsEnum.ShowRenameButton;
103				else
104					Options &= OptionsEnum.ShowAll ^ OptionsEnum.ShowRenameButton;
105			}
106		}
107
108		[DefaultValue (true)]
109		public bool ShowViewButton {
110			get { return (Options & OptionsEnum.ShowViewButton) > 0; }
111			set {
112				if (value)
113					Options |= OptionsEnum.ShowViewButton;
114				else
115					Options &= OptionsEnum.ShowAll ^ OptionsEnum.ShowViewButton;
116			}
117		}
118
119		[DefaultValue (true)]
120		public bool ShowNewFolderButton {
121			get { return (Options & OptionsEnum.ShowNewFolderButton) > 0; }
122			set {
123				if (value)
124					Options |= OptionsEnum.ShowNewFolderButton;
125				else
126					Options &= OptionsEnum.ShowAll ^ OptionsEnum.ShowNewFolderButton;
127			}
128		}
129
130		[DefaultValue (true)]
131		public bool ShowRefreshButton {
132			get { return (Options & OptionsEnum.ShowRefreshButton) > 0; }
133			set {
134				if (value)
135					Options |= OptionsEnum.ShowRefreshButton;
136				else
137					Options &= OptionsEnum.ShowAll ^ OptionsEnum.ShowRefreshButton;
138			}
139		}
140	}
141}