温馨提示:代码在线浏览功能只能做为源码浏览参考,如果想更进一步了解该代码请下载:IFNuke(修改自DNN)网站源码
当前文件:
IFNuke/MySpace/UI/MySpaceModuleBase.cs,打开代码结构图
IFNuke/MySpace/UI/MySpaceModuleBase.cs,打开代码结构图1using System; 2
using System.Collections.Generic; 3
using System.Text; 4
using System.Web; 5
using System.Drawing; 6
7
using IFNuke.Data; 8
using IFNuke.Web.Security; 9
using IFNuke.Web; 10
using IFNuke.Web.UI.Modules; 11
using IFNuke.MySpaces.BO; 12
13
namespace IFNuke.MySpaces.UI 14
{ 15
public class MySpaceModuleBase : PortalModuleBase 16
{ 17
protected Dictionary<string, string> MySpaceSettings 18
{ 19
get 20
{ 21
if (HttpContext.Current.Items["MySpaceSettings"] == null) 22
{ 23
24
HttpContext.Current.Items["MySpaceSettings"] = (new MySpaceSetting(PortalSetting.Id)).Settings; 25
26
} 27
return (Dictionary<string, string> )HttpContext.Current.Items["MySpaceSettings"]; 28
} 29
} 30
31
protected int MySpaceId 32
{ 33
get 34
{ 35
object o = ViewState["MySpaceId"]; 36
return (o == null) ? MagicValue.IdNull : (int)o; 37
} 38
set 39
{ 40
ViewState["MySpaceId"] = value; 41
} 42
} 43
44
protected int CategoryId 45
{ 46
get 47
{ 48
object o = ViewState["CategoryId"]; 49
return (o == null) ? MagicValue.IdNull : (int)o; 50
} 51
set 52
{ 53
ViewState["CategoryId"] = value; 54
} 55
} 56
57
protected int PostId 58
{ 59
get 60
{ 61
object o = ViewState["PostId"]; 62
return (o == null) ? MagicValue.IdNull : (int)o; 63
} 64
set 65
{ 66
ViewState["PostId"] = value; 67
} 68
} 69
70
protected int AlbumId 71
{ 72
get 73
{ 74
object o = ViewState["AlbumId"]; 75
return (o == null) ? MagicValue.IdNull : (int)o; 76
} 77
set 78
{ 79
ViewState["AlbumId"] = value; 80
} 81
} 82
83
protected int PhotoId 84
{ 85
get 86
{ 87
object o = ViewState["PhotoId"]; 88
return (o == null) ? MagicValue.IdNull : (int)o; 89
} 90
set 91
{ 92
ViewState["PhotoId"] = value; 93
} 94
} 95
96
protected bool CanOperation 97
{ 98
get 99
{ 100
object o = ViewState["CanOperation"]; 101
return o == null ? false : (bool)o; 102
} 103
set 104
{ 105
ViewState["CanOperation"] = value; 106
} 107
108
} 109
110
protected virtual void InitProperties() 111
{ 112
if (Request.QueryString["MySpaceId"] != null) 113
MySpaceId = Int32.Parse(Request.QueryString["MySpaceId"]); 114
else 115
{ 116
MySpaceId = IFNuke.MySpaces.BO.MySpace.GetSingleSpaceId(PortalSetting.Id); 117
} 118
if (Request.QueryString["CategoryId"] != null) 119
CategoryId = Int32.Parse(Request.QueryString["CategoryId"]); 120
if (Request.QueryString["PostId"] != null) 121
PostId = Int32.Parse(Request.QueryString["PostId"]); 122
if (Request.QueryString["AlbumId"] != null) 123
AlbumId = Int32.Parse(Request.QueryString["AlbumId"]); 124
if (Request.QueryString["PhotoId"] != null) 125
PhotoId = Int32.Parse(Request.QueryString["PhotoId"]); 126
CanOperation = GetCanOperation(); 127
} 128
129
protected virtual bool GetCanOperation() 130
{ 131
if (CurrentUser.IsAuthenticated && PortalSecurity.IsEditMode()) 132
{ 133
return PortalSecurity.IsPortalAdmin(); 134
} 135
else 136
return false; 137
} 138
139
public static Size ResizePhoto(int width, int height, int maxWidth, int maxHeight) 140
{ 141
decimal Max_Width = (decimal)maxWidth; 142
decimal Max_Height = (decimal)maxHeight; 143
144
decimal Aspect_Ratio = Max_Width / maxHeight; 145
146
int newWidth, newHeight; 147
148
decimal originalWidth = (decimal)width; 149
decimal originalHeight = (decimal)height; 150
151
if (originalWidth > Max_Width || originalHeight > Max_Height) 152
{ 153
decimal factor; 154
if (originalWidth / originalHeight > Aspect_Ratio) 155
{ 156
factor = originalWidth / Max_Width; 157
//newWidth = Convert.ToInt32(originalWidth / factor); 158
//newHeight = Convert.ToInt32(originalHeight / factor); 159
} 160
else 161
{ 162
factor = originalHeight / maxHeight; 163
//newWidth = Convert.ToInt32(originalWidth / factor); 164
//newHeight = Convert.ToInt32(originalHeight / factor); 165
} 166
newWidth = Convert.ToInt32(originalWidth / factor); 167
newHeight = Convert.ToInt32(originalHeight / factor); 168
} 169
else 170
{ 171
newWidth = width; 172
newHeight = height; 173
} 174
return new Size(newWidth, newHeight); 175
} 176
} 177
} 178





}
}