init commit
This commit is contained in:
101
DayPilot.csproj
Normal file
101
DayPilot.csproj
Normal file
@@ -0,0 +1,101 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003" ToolsVersion="4.0">
|
||||||
|
<PropertyGroup>
|
||||||
|
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
|
||||||
|
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
|
||||||
|
<ProductVersion>10.0.20506</ProductVersion>
|
||||||
|
<SchemaVersion>2.0</SchemaVersion>
|
||||||
|
<ProjectGuid>{5D7983A4-CCFF-46F6-920F-F184A031D7E1}</ProjectGuid>
|
||||||
|
<OutputType>Library</OutputType>
|
||||||
|
<AppDesignerFolder>Properties</AppDesignerFolder>
|
||||||
|
<RootNamespace>DayPilot</RootNamespace>
|
||||||
|
<AssemblyName>DayPilot</AssemblyName>
|
||||||
|
<FileUpgradeFlags>
|
||||||
|
</FileUpgradeFlags>
|
||||||
|
<OldToolsVersion>3.5</OldToolsVersion>
|
||||||
|
<UpgradeBackupLocation>
|
||||||
|
</UpgradeBackupLocation>
|
||||||
|
<TargetFrameworkVersion>v2.0</TargetFrameworkVersion>
|
||||||
|
</PropertyGroup>
|
||||||
|
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
|
||||||
|
<DebugSymbols>true</DebugSymbols>
|
||||||
|
<DebugType>full</DebugType>
|
||||||
|
<Optimize>false</Optimize>
|
||||||
|
<OutputPath>bin\Debug\</OutputPath>
|
||||||
|
<DefineConstants>DEBUG;TRACE</DefineConstants>
|
||||||
|
<ErrorReport>prompt</ErrorReport>
|
||||||
|
<WarningLevel>4</WarningLevel>
|
||||||
|
<CodeAnalysisRuleSet>AllRules.ruleset</CodeAnalysisRuleSet>
|
||||||
|
</PropertyGroup>
|
||||||
|
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
|
||||||
|
<DebugType>pdbonly</DebugType>
|
||||||
|
<Optimize>true</Optimize>
|
||||||
|
<OutputPath>bin\Release\</OutputPath>
|
||||||
|
<DefineConstants>TRACE</DefineConstants>
|
||||||
|
<ErrorReport>prompt</ErrorReport>
|
||||||
|
<WarningLevel>4</WarningLevel>
|
||||||
|
<CodeAnalysisRuleSet>AllRules.ruleset</CodeAnalysisRuleSet>
|
||||||
|
</PropertyGroup>
|
||||||
|
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Corp|AnyCPU'">
|
||||||
|
<DebugSymbols>true</DebugSymbols>
|
||||||
|
<OutputPath>bin\Corp\</OutputPath>
|
||||||
|
<DefineConstants>DEBUG;TRACE</DefineConstants>
|
||||||
|
<DebugType>full</DebugType>
|
||||||
|
<PlatformTarget>AnyCPU</PlatformTarget>
|
||||||
|
<ErrorReport>prompt</ErrorReport>
|
||||||
|
<CodeAnalysisRuleSet>AllRules.ruleset</CodeAnalysisRuleSet>
|
||||||
|
<CodeAnalysisIgnoreBuiltInRuleSets>true</CodeAnalysisIgnoreBuiltInRuleSets>
|
||||||
|
<CodeAnalysisIgnoreBuiltInRules>true</CodeAnalysisIgnoreBuiltInRules>
|
||||||
|
</PropertyGroup>
|
||||||
|
<ItemGroup>
|
||||||
|
<Reference Include="System" />
|
||||||
|
<Reference Include="System.Data" />
|
||||||
|
<Reference Include="System.Design" />
|
||||||
|
<Reference Include="System.Drawing" />
|
||||||
|
<Reference Include="System.Web" />
|
||||||
|
<Reference Include="System.Xml" />
|
||||||
|
</ItemGroup>
|
||||||
|
<ItemGroup>
|
||||||
|
<Compile Include="Properties\AssemblyInfo.cs" />
|
||||||
|
<Compile Include="Properties\Settings.Designer.cs">
|
||||||
|
<AutoGen>True</AutoGen>
|
||||||
|
<DesignTimeSharedInput>True</DesignTimeSharedInput>
|
||||||
|
<DependentUpon>Settings.settings</DependentUpon>
|
||||||
|
</Compile>
|
||||||
|
<Compile Include="Utils\Encoder.cs" />
|
||||||
|
<Compile Include="Utils\TimeFormatter.cs" />
|
||||||
|
<Compile Include="Utils\Week.cs" />
|
||||||
|
<Compile Include="Web\Ui\Block.cs" />
|
||||||
|
<Compile Include="Web\Ui\Column.cs" />
|
||||||
|
<Compile Include="Web\Ui\Day.cs" />
|
||||||
|
<Compile Include="Web\Ui\DayPilotCalendar.cs" />
|
||||||
|
<Compile Include="Web\Ui\DayPilotCalendarProperties.cs" />
|
||||||
|
<Compile Include="Web\Ui\DayPilotScheduler.cs" />
|
||||||
|
<Compile Include="Web\Ui\Design\DayPilotCalendarDesigner.cs" />
|
||||||
|
<Compile Include="Web\Ui\Enums\GroupByEnum.cs" />
|
||||||
|
<Compile Include="Web\Ui\Event.cs" />
|
||||||
|
<Compile Include="Web\Ui\EventComparer.cs" />
|
||||||
|
<Compile Include="Web\Ui\EventDelegates.cs" />
|
||||||
|
<Compile Include="Web\Ui\NonBusinessHoursBehavior.cs" />
|
||||||
|
<Compile Include="Web\Ui\Resource.cs" />
|
||||||
|
<Compile Include="Web\Ui\ResourceCollection.cs" />
|
||||||
|
<Compile Include="Web\Ui\Serialization\ResourceCollectionConverter.cs" />
|
||||||
|
<Compile Include="Web\Ui\TimeFormat.cs" />
|
||||||
|
<Compile Include="Web\Ui\UserActionHandling.cs" />
|
||||||
|
</ItemGroup>
|
||||||
|
<ItemGroup>
|
||||||
|
<None Include="app.config" />
|
||||||
|
<None Include="Properties\Settings.settings">
|
||||||
|
<Generator>SettingsSingleFileGenerator</Generator>
|
||||||
|
<LastGenOutput>Settings.Designer.cs</LastGenOutput>
|
||||||
|
</None>
|
||||||
|
</ItemGroup>
|
||||||
|
<Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" />
|
||||||
|
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
|
||||||
|
Other similar extension points exist, see Microsoft.Common.targets.
|
||||||
|
<Target Name="BeforeBuild">
|
||||||
|
</Target>
|
||||||
|
<Target Name="AfterBuild">
|
||||||
|
</Target>
|
||||||
|
-->
|
||||||
|
</Project>
|
||||||
26
DayPilot.sln
Normal file
26
DayPilot.sln
Normal file
@@ -0,0 +1,26 @@
|
|||||||
|
|
||||||
|
Microsoft Visual Studio Solution File, Format Version 10.00
|
||||||
|
# Visual Studio 2008
|
||||||
|
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "DayPilot", "DayPilot.csproj", "{5D7983A4-CCFF-46F6-920F-F184A031D7E1}"
|
||||||
|
EndProject
|
||||||
|
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "dpMvc2", "..\..\..\Projects\dpMvc2\dpMvc2.csproj", "{2A46CBBE-6F72-433B-96ED-6B5CEA12F696}"
|
||||||
|
EndProject
|
||||||
|
Global
|
||||||
|
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||||
|
Debug|Any CPU = Debug|Any CPU
|
||||||
|
Release|Any CPU = Release|Any CPU
|
||||||
|
EndGlobalSection
|
||||||
|
GlobalSection(ProjectConfigurationPlatforms) = postSolution
|
||||||
|
{5D7983A4-CCFF-46F6-920F-F184A031D7E1}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||||
|
{5D7983A4-CCFF-46F6-920F-F184A031D7E1}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||||
|
{5D7983A4-CCFF-46F6-920F-F184A031D7E1}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||||
|
{5D7983A4-CCFF-46F6-920F-F184A031D7E1}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||||
|
{2A46CBBE-6F72-433B-96ED-6B5CEA12F696}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||||
|
{2A46CBBE-6F72-433B-96ED-6B5CEA12F696}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||||
|
{2A46CBBE-6F72-433B-96ED-6B5CEA12F696}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||||
|
{2A46CBBE-6F72-433B-96ED-6B5CEA12F696}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||||
|
EndGlobalSection
|
||||||
|
GlobalSection(SolutionProperties) = preSolution
|
||||||
|
HideSolutionNode = FALSE
|
||||||
|
EndGlobalSection
|
||||||
|
EndGlobal
|
||||||
58
Properties/AssemblyInfo.cs
Normal file
58
Properties/AssemblyInfo.cs
Normal file
@@ -0,0 +1,58 @@
|
|||||||
|
/*
|
||||||
|
Copyright © 2005 - 2008 Annpoint, s.r.o.
|
||||||
|
|
||||||
|
Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
you may not use this file except in compliance with the License.
|
||||||
|
You may obtain a copy of the License at
|
||||||
|
|
||||||
|
http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
|
||||||
|
Unless required by applicable law or agreed to in writing, software
|
||||||
|
distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
See the License for the specific language governing permissions and
|
||||||
|
limitations under the License.
|
||||||
|
|
||||||
|
-------------------------------------------------------------------------
|
||||||
|
|
||||||
|
NOTE: Reuse requires the following acknowledgement (see also NOTICE):
|
||||||
|
This product includes DayPilot (http://www.daypilot.org) developed by Annpoint, s.r.o.
|
||||||
|
*/
|
||||||
|
|
||||||
|
using System.Reflection;
|
||||||
|
using System.Runtime.InteropServices;
|
||||||
|
using System.Web.UI;
|
||||||
|
|
||||||
|
// General Information about an assembly is controlled through the following
|
||||||
|
// set of attributes. Change these attribute values to modify the information
|
||||||
|
// associated with an assembly.
|
||||||
|
[assembly: AssemblyTitle("DayPilot")]
|
||||||
|
[assembly: AssemblyDescription("")]
|
||||||
|
[assembly: AssemblyConfiguration("")]
|
||||||
|
[assembly: AssemblyCompany("")]
|
||||||
|
[assembly: AssemblyProduct("DayPilot")]
|
||||||
|
[assembly: AssemblyCopyright("Copyright © 2005 - 2008 Annpoint, s.r.o.")]
|
||||||
|
[assembly: AssemblyTrademark("")]
|
||||||
|
[assembly: AssemblyCulture("")]
|
||||||
|
|
||||||
|
// Setting ComVisible to false makes the types in this assembly not visible
|
||||||
|
// to COM components. If you need to access a type in this assembly from
|
||||||
|
// COM, set the ComVisible attribute to true on that type.
|
||||||
|
[assembly: ComVisible(false)]
|
||||||
|
|
||||||
|
// The following GUID is for the ID of the typelib if this project is exposed to COM
|
||||||
|
[assembly: Guid("e5d0e09d-0160-4c7c-a16e-374ba8867712")]
|
||||||
|
|
||||||
|
[assembly: TagPrefix("DayPilot.Web.Ui", "DayPilot")]
|
||||||
|
|
||||||
|
// Version information for an assembly consists of the following four values:
|
||||||
|
//
|
||||||
|
// Major Version
|
||||||
|
// Minor Version
|
||||||
|
// Build Number
|
||||||
|
// Revision
|
||||||
|
//
|
||||||
|
// You can specify all the values or you can default the Revision and Build Numbers
|
||||||
|
// by using the '*' as shown below:
|
||||||
|
[assembly: AssemblyVersion("3.0.210.0")]
|
||||||
|
[assembly: AssemblyFileVersion("3.0.210.0")]
|
||||||
37
Properties/Settings.Designer.cs
generated
Normal file
37
Properties/Settings.Designer.cs
generated
Normal file
@@ -0,0 +1,37 @@
|
|||||||
|
//------------------------------------------------------------------------------
|
||||||
|
// <auto-generated>
|
||||||
|
// This code was generated by a tool.
|
||||||
|
// Runtime Version:4.0.20506.1
|
||||||
|
//
|
||||||
|
// Changes to this file may cause incorrect behavior and will be lost if
|
||||||
|
// the code is regenerated.
|
||||||
|
// </auto-generated>
|
||||||
|
//------------------------------------------------------------------------------
|
||||||
|
|
||||||
|
namespace DayPilot.Properties {
|
||||||
|
|
||||||
|
|
||||||
|
[global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
|
||||||
|
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "10.0.0.0")]
|
||||||
|
internal sealed partial class Settings : global::System.Configuration.ApplicationSettingsBase {
|
||||||
|
|
||||||
|
private static Settings defaultInstance = ((Settings)(global::System.Configuration.ApplicationSettingsBase.Synchronized(new Settings())));
|
||||||
|
|
||||||
|
public static Settings Default {
|
||||||
|
get {
|
||||||
|
return defaultInstance;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
[global::System.Configuration.ApplicationScopedSettingAttribute()]
|
||||||
|
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
|
||||||
|
[global::System.Configuration.SpecialSettingAttribute(global::System.Configuration.SpecialSetting.ConnectionString)]
|
||||||
|
[global::System.Configuration.DefaultSettingValueAttribute("Data Source=.\\SQLEXPRESS;AttachDbFilename=|DataDirectory|\\bookings.mdf;Integrated" +
|
||||||
|
" Security=True;User Instance=True")]
|
||||||
|
public string bookingsConnectionString {
|
||||||
|
get {
|
||||||
|
return ((string)(this["bookingsConnectionString"]));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
14
Properties/Settings.settings
Normal file
14
Properties/Settings.settings
Normal file
@@ -0,0 +1,14 @@
|
|||||||
|
<?xml version='1.0' encoding='utf-8'?>
|
||||||
|
<SettingsFile xmlns="http://schemas.microsoft.com/VisualStudio/2004/01/settings" CurrentProfile="(Default)" GeneratedClassNamespace="DayPilot.Properties" GeneratedClassName="Settings">
|
||||||
|
<Profiles />
|
||||||
|
<Settings>
|
||||||
|
<Setting Name="bookingsConnectionString" Type="(Connection string)" Scope="Application">
|
||||||
|
<DesignTimeValue Profile="(Default)"><?xml version="1.0" encoding="utf-16"?>
|
||||||
|
<SerializableConnectionString xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
|
||||||
|
<ConnectionString>Data Source=.\SQLEXPRESS;AttachDbFilename=|DataDirectory|\bookings.mdf;Integrated Security=True;User Instance=True</ConnectionString>
|
||||||
|
<ProviderName>System.Data.SqlClient</ProviderName>
|
||||||
|
</SerializableConnectionString></DesignTimeValue>
|
||||||
|
<Value Profile="(Default)">Data Source=.\SQLEXPRESS;AttachDbFilename=|DataDirectory|\bookings.mdf;Integrated Security=True;User Instance=True</Value>
|
||||||
|
</Setting>
|
||||||
|
</Settings>
|
||||||
|
</SettingsFile>
|
||||||
123
Utils/Encoder.cs
Normal file
123
Utils/Encoder.cs
Normal file
@@ -0,0 +1,123 @@
|
|||||||
|
/*
|
||||||
|
Copyright <20> 2005 - 2008 Annpoint, s.r.o.
|
||||||
|
|
||||||
|
Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
you may not use this file except in compliance with the License.
|
||||||
|
You may obtain a copy of the License at
|
||||||
|
|
||||||
|
http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
|
||||||
|
Unless required by applicable law or agreed to in writing, software
|
||||||
|
distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
See the License for the specific language governing permissions and
|
||||||
|
limitations under the License.
|
||||||
|
|
||||||
|
-------------------------------------------------------------------------
|
||||||
|
|
||||||
|
NOTE: Reuse requires the following acknowledgement (see also NOTICE):
|
||||||
|
This product includes DayPilot (http://www.daypilot.org) developed by Annpoint, s.r.o.
|
||||||
|
*/
|
||||||
|
|
||||||
|
using System;
|
||||||
|
using System.Collections;
|
||||||
|
using System.Globalization;
|
||||||
|
using System.Text;
|
||||||
|
using System.Web;
|
||||||
|
|
||||||
|
namespace DayPilot.Utils
|
||||||
|
{
|
||||||
|
internal class Encoder
|
||||||
|
{
|
||||||
|
private static HttpApplication _app = null;
|
||||||
|
private static HttpServerUtility Server
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
if (HttpContext.Current != null)
|
||||||
|
return HttpContext.Current.Server;
|
||||||
|
|
||||||
|
if (_app == null)
|
||||||
|
_app = new HttpApplication();
|
||||||
|
return _app.Server;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
internal static string HtmlEncode(string input)
|
||||||
|
{
|
||||||
|
if (input == null)
|
||||||
|
{
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
return Server.HtmlEncode(input);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
internal static string UrlEncode(string input)
|
||||||
|
{
|
||||||
|
// return Server.UrlPathEncode(input);
|
||||||
|
if (input == null)
|
||||||
|
{
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
return input.Replace("&", "%26");
|
||||||
|
// return Server.UrlEncode(input);
|
||||||
|
}
|
||||||
|
|
||||||
|
internal static string UrlDecode(string input)
|
||||||
|
{
|
||||||
|
return Server.UrlDecode(input);
|
||||||
|
}
|
||||||
|
|
||||||
|
internal static DateTime UrlDecodeDateTime(string input)
|
||||||
|
{
|
||||||
|
CultureInfo culture = new CultureInfo("en-US");
|
||||||
|
string decoded = Server.UrlDecode(input);
|
||||||
|
|
||||||
|
try
|
||||||
|
{
|
||||||
|
return DateTime.ParseExact(decoded, culture.DateTimeFormat.SortableDateTimePattern, culture.DateTimeFormat);
|
||||||
|
}
|
||||||
|
catch (FormatException e)
|
||||||
|
{
|
||||||
|
throw new ApplicationException("Unable to parse DateTime: '" + decoded + "'.", e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
internal static string UrlEncode(IList list)
|
||||||
|
{
|
||||||
|
StringBuilder sb = new StringBuilder();
|
||||||
|
|
||||||
|
bool isFirst = true;
|
||||||
|
foreach (object o in list)
|
||||||
|
{
|
||||||
|
string item;
|
||||||
|
if (o is DateTime)
|
||||||
|
{
|
||||||
|
DateTime dt = (DateTime) o;
|
||||||
|
item = dt.ToString("s");
|
||||||
|
}
|
||||||
|
else if (o == null)
|
||||||
|
{
|
||||||
|
item = String.Empty;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
item = o.ToString();
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!isFirst)
|
||||||
|
{
|
||||||
|
sb.Append("&");
|
||||||
|
}
|
||||||
|
|
||||||
|
sb.Append(UrlEncode(item));
|
||||||
|
|
||||||
|
isFirst = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
return sb.ToString();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
83
Utils/TimeFormatter.cs
Normal file
83
Utils/TimeFormatter.cs
Normal file
@@ -0,0 +1,83 @@
|
|||||||
|
/*
|
||||||
|
Copyright <20> 2005 - 2008 Annpoint, s.r.o.
|
||||||
|
|
||||||
|
Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
you may not use this file except in compliance with the License.
|
||||||
|
You may obtain a copy of the License at
|
||||||
|
|
||||||
|
http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
|
||||||
|
Unless required by applicable law or agreed to in writing, software
|
||||||
|
distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
See the License for the specific language governing permissions and
|
||||||
|
limitations under the License.
|
||||||
|
|
||||||
|
-------------------------------------------------------------------------
|
||||||
|
|
||||||
|
NOTE: Reuse requires the following acknowledgement (see also NOTICE):
|
||||||
|
This product includes DayPilot (http://www.daypilot.org) developed by Annpoint, s.r.o.
|
||||||
|
*/
|
||||||
|
|
||||||
|
using System;
|
||||||
|
using DayPilot.Web.Ui;
|
||||||
|
|
||||||
|
namespace DayPilot.Utils
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Helper class for hour formatting.
|
||||||
|
/// </summary>
|
||||||
|
public class TimeFormatter
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Extracts hour from DateTime class and formats it for 12/24 hours clock.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="time"></param>
|
||||||
|
/// <param name="clock"></param>
|
||||||
|
/// <param name="format"></param>
|
||||||
|
/// <returns></returns>
|
||||||
|
public static string GetHour(DateTime time, TimeFormat clock, string format)
|
||||||
|
{
|
||||||
|
return GetHour(time.Hour, clock, format);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Formats an hour number for 12/24 hours clock.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="hour"></param>
|
||||||
|
/// <param name="clock"></param>
|
||||||
|
/// <param name="format"></param>
|
||||||
|
/// <returns></returns>
|
||||||
|
public static string GetHour(int hour, TimeFormat clock, string format)
|
||||||
|
{
|
||||||
|
bool am = (hour / 12) == 0;
|
||||||
|
if (clock == TimeFormat.Clock12Hours)
|
||||||
|
{
|
||||||
|
hour = hour % 12;
|
||||||
|
if (hour == 0)
|
||||||
|
hour = 12;
|
||||||
|
}
|
||||||
|
|
||||||
|
string suffix = String.Empty;
|
||||||
|
if (clock == TimeFormat.Clock12Hours)
|
||||||
|
{
|
||||||
|
if (am)
|
||||||
|
{
|
||||||
|
suffix = "AM";
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
suffix = "PM";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (String.IsNullOrEmpty(format))
|
||||||
|
{
|
||||||
|
format = "{0} {1}";
|
||||||
|
}
|
||||||
|
|
||||||
|
return String.Format(format, hour, suffix);
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
158
Utils/Week.cs
Normal file
158
Utils/Week.cs
Normal file
@@ -0,0 +1,158 @@
|
|||||||
|
/*
|
||||||
|
Copyright <20> 2005 - 2008 Annpoint, s.r.o.
|
||||||
|
|
||||||
|
Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
you may not use this file except in compliance with the License.
|
||||||
|
You may obtain a copy of the License at
|
||||||
|
|
||||||
|
http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
|
||||||
|
Unless required by applicable law or agreed to in writing, software
|
||||||
|
distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
See the License for the specific language governing permissions and
|
||||||
|
limitations under the License.
|
||||||
|
|
||||||
|
-------------------------------------------------------------------------
|
||||||
|
|
||||||
|
NOTE: Reuse requires the following acknowledgement (see also NOTICE):
|
||||||
|
This product includes DayPilot (http://www.daypilot.org) developed by Annpoint, s.r.o.
|
||||||
|
*/
|
||||||
|
using System;
|
||||||
|
using System.Collections;
|
||||||
|
using System.Threading;
|
||||||
|
|
||||||
|
namespace DayPilot.Utils
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Helper class for week manipulation and formatting.
|
||||||
|
/// </summary>
|
||||||
|
public class Week
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Gets the first day of this week. Based on current culture.
|
||||||
|
/// </summary>
|
||||||
|
/// <returns></returns>
|
||||||
|
public static DateTime FirstDayOfWeek()
|
||||||
|
{
|
||||||
|
return FirstDayOfWeek(DateTime.Today);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Gets the first day of a week where day (parameter) belongs. Based on current culture.
|
||||||
|
/// </summary>
|
||||||
|
/// <returns></returns>
|
||||||
|
public static DateTime FirstDayOfWeek(DateTime day)
|
||||||
|
{
|
||||||
|
return FirstDayOfWeek(day, Thread.CurrentThread.CurrentCulture.DateTimeFormat.FirstDayOfWeek);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Gets the first day of a week where day (parameter) belongs. weekStart (parameter) specifies the starting day of week.
|
||||||
|
/// </summary>
|
||||||
|
/// <returns></returns>
|
||||||
|
public static DateTime FirstDayOfWeek(DateTime day, DayOfWeek weekStarts)
|
||||||
|
{
|
||||||
|
DateTime d = day;
|
||||||
|
while (d.DayOfWeek != weekStarts)
|
||||||
|
{
|
||||||
|
d = d.AddDays(-1);
|
||||||
|
}
|
||||||
|
|
||||||
|
return d;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Returns Monday of the week where day (parameter) belongs.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="day"></param>
|
||||||
|
/// <returns></returns>
|
||||||
|
public static DateTime FirstWorkingDayOfWeek(DateTime day)
|
||||||
|
{
|
||||||
|
return FirstDayOfWeek(day, DayOfWeek.Monday);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// http://konsulent.sandelien.no/VB_help/Week/
|
||||||
|
// just for Monday being the first day of week
|
||||||
|
/// <summary>
|
||||||
|
/// Calculates week number for the specified date according to ISO 8601.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="date"></param>
|
||||||
|
/// <returns></returns>
|
||||||
|
public static int WeekNrISO8601(DateTime date)
|
||||||
|
{
|
||||||
|
bool ThursdayFlag = false;
|
||||||
|
int DayOfYear = date.DayOfYear;
|
||||||
|
|
||||||
|
int StartWeekDayOfYear =
|
||||||
|
(int)(new DateTime(date.Year, 1, 1)).DayOfWeek;
|
||||||
|
int EndWeekDayOfYear =
|
||||||
|
(int)(new DateTime(date.Year, 12, 31)).DayOfWeek;
|
||||||
|
|
||||||
|
if (StartWeekDayOfYear == 0)
|
||||||
|
StartWeekDayOfYear = 7;
|
||||||
|
if (EndWeekDayOfYear == 0)
|
||||||
|
EndWeekDayOfYear = 7;
|
||||||
|
|
||||||
|
int DaysInFirstWeek = 8 - (StartWeekDayOfYear);
|
||||||
|
|
||||||
|
if (StartWeekDayOfYear == 4 || EndWeekDayOfYear == 4)
|
||||||
|
ThursdayFlag = true;
|
||||||
|
|
||||||
|
int FullWeeks = (int)Math.Ceiling((DayOfYear - (DaysInFirstWeek)) / 7.0);
|
||||||
|
|
||||||
|
int WeekNumber = FullWeeks;
|
||||||
|
|
||||||
|
if (DaysInFirstWeek >= 4)
|
||||||
|
WeekNumber = WeekNumber + 1;
|
||||||
|
|
||||||
|
if (WeekNumber > 52 && !ThursdayFlag)
|
||||||
|
WeekNumber = 1;
|
||||||
|
|
||||||
|
if (WeekNumber == 0)
|
||||||
|
WeekNumber = WeekNrISO8601(new DateTime(date.Year - 1, 12, 31));
|
||||||
|
return WeekNumber;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Returns day names (using current culture).
|
||||||
|
/// </summary>
|
||||||
|
/// <returns></returns>
|
||||||
|
public static ArrayList GetDayNames()
|
||||||
|
{
|
||||||
|
return GetDayNames("dddd");
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Returns day names (using current culture).
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="format">Corresponds to DateTime.ToString() formats. "DD" is also available (first two characters of short day name).</param>
|
||||||
|
/// <returns></returns>
|
||||||
|
public static ArrayList GetDayNames(string format)
|
||||||
|
{
|
||||||
|
ArrayList result = new ArrayList();
|
||||||
|
DateTime start = new DateTime(2006, 12, 31); // Sunday
|
||||||
|
for (int i = 0; i < 7; i++)
|
||||||
|
{
|
||||||
|
// this uses the current culture
|
||||||
|
string name;
|
||||||
|
if (format == "DD")
|
||||||
|
{
|
||||||
|
name = start.AddDays(i).ToString("ddd").Substring(0, 2);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
name = start.AddDays(i).ToString(format);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
result.Add(name);
|
||||||
|
}
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
127
Web/Ui/Block.cs
Normal file
127
Web/Ui/Block.cs
Normal file
@@ -0,0 +1,127 @@
|
|||||||
|
/*
|
||||||
|
Copyright <20> 2005 - 2008 Annpoint, s.r.o.
|
||||||
|
|
||||||
|
Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
you may not use this file except in compliance with the License.
|
||||||
|
You may obtain a copy of the License at
|
||||||
|
|
||||||
|
http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
|
||||||
|
Unless required by applicable law or agreed to in writing, software
|
||||||
|
distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
See the License for the specific language governing permissions and
|
||||||
|
limitations under the License.
|
||||||
|
|
||||||
|
-------------------------------------------------------------------------
|
||||||
|
|
||||||
|
NOTE: Reuse requires the following acknowledgement (see also NOTICE):
|
||||||
|
This product includes DayPilot (http://www.daypilot.org) developed by Annpoint, s.r.o.
|
||||||
|
*/
|
||||||
|
|
||||||
|
using System;
|
||||||
|
using System.Collections;
|
||||||
|
|
||||||
|
namespace DayPilot.Web.Ui
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Block is a set of concurrent events.
|
||||||
|
/// </summary>
|
||||||
|
internal class Block
|
||||||
|
{
|
||||||
|
internal ArrayList Columns;
|
||||||
|
private ArrayList events = new ArrayList();
|
||||||
|
|
||||||
|
|
||||||
|
internal Block()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
internal void Add(Event ev)
|
||||||
|
{
|
||||||
|
events.Add(ev);
|
||||||
|
arrangeColumns();
|
||||||
|
}
|
||||||
|
|
||||||
|
private Column createColumn()
|
||||||
|
{
|
||||||
|
Column col = new Column();
|
||||||
|
this.Columns.Add(col);
|
||||||
|
col.Block = this;
|
||||||
|
|
||||||
|
return col;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
private void arrangeColumns()
|
||||||
|
{
|
||||||
|
// cleanup
|
||||||
|
this.Columns = new ArrayList();
|
||||||
|
|
||||||
|
foreach(Event e in events)
|
||||||
|
e.Column = null;
|
||||||
|
|
||||||
|
// there always will be at least one column because arrangeColumns is called only from Add()
|
||||||
|
createColumn();
|
||||||
|
|
||||||
|
foreach (Event e in events)
|
||||||
|
{
|
||||||
|
foreach (Column col in Columns)
|
||||||
|
{
|
||||||
|
if (col.CanAdd(e))
|
||||||
|
{
|
||||||
|
col.Add(e);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// it wasn't placed
|
||||||
|
if (e.Column == null)
|
||||||
|
{
|
||||||
|
Column col = createColumn();
|
||||||
|
col.Add(e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
internal bool OverlapsWith(Event e)
|
||||||
|
{
|
||||||
|
if (events.Count == 0)
|
||||||
|
return false;
|
||||||
|
|
||||||
|
return (this.BoxStart < e.BoxEnd && this.BoxEnd > e.BoxStart);
|
||||||
|
}
|
||||||
|
|
||||||
|
internal DateTime BoxStart
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
DateTime min = DateTime.MaxValue;
|
||||||
|
|
||||||
|
foreach(Event ev in events)
|
||||||
|
{
|
||||||
|
if (ev.BoxStart < min)
|
||||||
|
min = ev.BoxStart;
|
||||||
|
}
|
||||||
|
|
||||||
|
return min;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
internal DateTime BoxEnd
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
DateTime max = DateTime.MinValue;
|
||||||
|
|
||||||
|
foreach(Event ev in events)
|
||||||
|
{
|
||||||
|
if (ev.BoxEnd > max)
|
||||||
|
max = ev.BoxEnd;
|
||||||
|
}
|
||||||
|
|
||||||
|
return max;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
119
Web/Ui/Column.cs
Normal file
119
Web/Ui/Column.cs
Normal file
@@ -0,0 +1,119 @@
|
|||||||
|
/*
|
||||||
|
Copyright <20> 2005 - 2008 Annpoint, s.r.o.
|
||||||
|
|
||||||
|
Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
you may not use this file except in compliance with the License.
|
||||||
|
You may obtain a copy of the License at
|
||||||
|
|
||||||
|
http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
|
||||||
|
Unless required by applicable law or agreed to in writing, software
|
||||||
|
distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
See the License for the specific language governing permissions and
|
||||||
|
limitations under the License.
|
||||||
|
|
||||||
|
-------------------------------------------------------------------------
|
||||||
|
|
||||||
|
NOTE: Reuse requires the following acknowledgement (see also NOTICE):
|
||||||
|
This product includes DayPilot (http://www.daypilot.org) developed by Annpoint, s.r.o.
|
||||||
|
*/
|
||||||
|
|
||||||
|
using System;
|
||||||
|
using System.Collections;
|
||||||
|
using DayPilot.Web.Ui;
|
||||||
|
|
||||||
|
namespace DayPilot.Web.Ui
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Column is a column of events in a Block.
|
||||||
|
/// </summary>
|
||||||
|
public class Column
|
||||||
|
{
|
||||||
|
private ArrayList events = new ArrayList();
|
||||||
|
internal Block Block;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Gets the width of the column in percent.
|
||||||
|
/// </summary>
|
||||||
|
public int WidthPct
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
if (Block == null)
|
||||||
|
throw new ApplicationException("This Column does not belong to any Block.");
|
||||||
|
|
||||||
|
if (Block.Columns.Count == 0)
|
||||||
|
throw new ApplicationException("Internal error: Problem with Block.Column.Counts (it is zero).");
|
||||||
|
|
||||||
|
// the last block will be a bit longer to make sure the total width is 100%
|
||||||
|
if (isLastInBlock)
|
||||||
|
return 100 / Block.Columns.Count + 100 % Block.Columns.Count;
|
||||||
|
else
|
||||||
|
return 100 / Block.Columns.Count;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Gets the starting percent of the column.
|
||||||
|
/// </summary>
|
||||||
|
public int StartsAtPct
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
if (Block == null)
|
||||||
|
throw new ApplicationException("This Column does not belong to any Block.");
|
||||||
|
|
||||||
|
if (Block.Columns.Count == 0)
|
||||||
|
throw new ApplicationException("Internal error: Problem with Block.Column.Counts (it is zero).");
|
||||||
|
|
||||||
|
return 100 / Block.Columns.Count * Number;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private bool isLastInBlock
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
return Block.Columns[Block.Columns.Count - 1] == this;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
internal Column()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
internal bool CanAdd(Event e)
|
||||||
|
{
|
||||||
|
foreach (Event ev in events)
|
||||||
|
{
|
||||||
|
if (ev.OverlapsWith(e))
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
internal void Add(Event e)
|
||||||
|
{
|
||||||
|
if (e.Column != null)
|
||||||
|
throw new ApplicationException("This Event was already placed into a Column.");
|
||||||
|
|
||||||
|
events.Add(e);
|
||||||
|
e.Column = this;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Gets the order number of the column.
|
||||||
|
/// </summary>
|
||||||
|
public int Number
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
if (Block == null)
|
||||||
|
throw new ApplicationException("This Column doesn't belong to any Block.");
|
||||||
|
|
||||||
|
return Block.Columns.IndexOf(this);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
236
Web/Ui/Day.cs
Normal file
236
Web/Ui/Day.cs
Normal file
@@ -0,0 +1,236 @@
|
|||||||
|
/*
|
||||||
|
Copyright <20> 2005 - 2008 Annpoint, s.r.o.
|
||||||
|
|
||||||
|
Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
you may not use this file except in compliance with the License.
|
||||||
|
You may obtain a copy of the License at
|
||||||
|
|
||||||
|
http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
|
||||||
|
Unless required by applicable law or agreed to in writing, software
|
||||||
|
distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
See the License for the specific language governing permissions and
|
||||||
|
limitations under the License.
|
||||||
|
|
||||||
|
-------------------------------------------------------------------------
|
||||||
|
|
||||||
|
NOTE: Reuse requires the following acknowledgement (see also NOTICE):
|
||||||
|
This product includes DayPilot (http://www.daypilot.org) developed by Annpoint, s.r.o.
|
||||||
|
*/
|
||||||
|
|
||||||
|
using System;
|
||||||
|
using System.Collections;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Runtime.Serialization;
|
||||||
|
|
||||||
|
namespace DayPilot.Web.Ui
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Day handles events of a single day.
|
||||||
|
/// </summary>
|
||||||
|
internal class Day : ISerializable
|
||||||
|
{
|
||||||
|
internal List<Event> events = new List<Event>();
|
||||||
|
private List<Block> blocks = new List<Block>();
|
||||||
|
|
||||||
|
internal int cellDuration; // in minutes
|
||||||
|
|
||||||
|
private DateTime start;
|
||||||
|
internal DateTime end;
|
||||||
|
|
||||||
|
internal string Name;
|
||||||
|
internal string Value;
|
||||||
|
|
||||||
|
internal DateTime Start
|
||||||
|
{
|
||||||
|
get { return start; }
|
||||||
|
}
|
||||||
|
|
||||||
|
internal DateTime End
|
||||||
|
{
|
||||||
|
get { return end; }
|
||||||
|
}
|
||||||
|
|
||||||
|
public Day(DateTime date)
|
||||||
|
{
|
||||||
|
this.start = date.Date;
|
||||||
|
this.end = date.Date.AddDays(1);
|
||||||
|
}
|
||||||
|
|
||||||
|
internal Day(DateTime start, DateTime end, string header, string id, int cellDuration)
|
||||||
|
{
|
||||||
|
this.start = start.Date;
|
||||||
|
this.end = end.Date;
|
||||||
|
this.Name = header;
|
||||||
|
this.Value = id;
|
||||||
|
this.cellDuration = cellDuration;
|
||||||
|
}
|
||||||
|
|
||||||
|
private void stripAndAddEvent(Event e)
|
||||||
|
{
|
||||||
|
stripAndAddEvent(e.Start, e.End, e.PK, e.Name, e.Resource, e.Owner);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void stripAndAddEvent(DateTime start, DateTime end, string pk, string name, string resource, string owner)
|
||||||
|
{
|
||||||
|
if (!String.IsNullOrEmpty(Value)) // this applies to resources view only
|
||||||
|
{
|
||||||
|
if (Value != resource) // don't add events that don't belong to this column
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
// the event happens before this day
|
||||||
|
if (end <= Start)
|
||||||
|
return;
|
||||||
|
|
||||||
|
// the event happens after this day
|
||||||
|
if (start >= End)
|
||||||
|
return;
|
||||||
|
|
||||||
|
// this is invalid event that does have no duration
|
||||||
|
if (start >= end)
|
||||||
|
return;
|
||||||
|
|
||||||
|
// fix the starting time
|
||||||
|
if (start < Start)
|
||||||
|
start = Start;
|
||||||
|
|
||||||
|
|
||||||
|
// fix the ending time
|
||||||
|
if (end > End)
|
||||||
|
end = End;
|
||||||
|
|
||||||
|
events.Add(new Event(pk, start, end, name, resource, owner));
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
private void stripAndAddEvent(Event e)
|
||||||
|
{
|
||||||
|
if (!String.IsNullOrEmpty(Value)) // this applies to resources view only
|
||||||
|
{
|
||||||
|
if (Value != e.Resource) // don't add events that don't belong to this column
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
// the event happens before this day
|
||||||
|
if (e.End <= Start)
|
||||||
|
return;
|
||||||
|
|
||||||
|
// the event happens after this day
|
||||||
|
if (e.Start >= End.AddDays(1))
|
||||||
|
return;
|
||||||
|
|
||||||
|
// this is invalid event that has no duration
|
||||||
|
if (e.Start >= e.End)
|
||||||
|
return;
|
||||||
|
|
||||||
|
// Event part = new Event(this, e);
|
||||||
|
events.Add(e);
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
*/
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Loads events from ArrayList of Events.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="events">ArrayList that contains the Events.</param>
|
||||||
|
public void Load(ArrayList events)
|
||||||
|
{
|
||||||
|
if (events == null)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
foreach (Event e in events)
|
||||||
|
{
|
||||||
|
stripAndAddEvent(e);
|
||||||
|
}
|
||||||
|
putIntoBlocks();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void putIntoBlocks()
|
||||||
|
{
|
||||||
|
foreach (Event e in events)
|
||||||
|
{
|
||||||
|
// if there is no block, create the first one
|
||||||
|
if (lastBlock == null)
|
||||||
|
{
|
||||||
|
blocks.Add(new Block());
|
||||||
|
}
|
||||||
|
// or if the event doesn't overlap with the last block, create a new block
|
||||||
|
else if (!lastBlock.OverlapsWith(e))
|
||||||
|
{
|
||||||
|
blocks.Add(new Block());
|
||||||
|
}
|
||||||
|
|
||||||
|
// any case, add it to some block
|
||||||
|
lastBlock.Add(e);
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private Block lastBlock
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
if (blocks.Count == 0)
|
||||||
|
return null;
|
||||||
|
return blocks[blocks.Count - 1];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void GetObjectData(SerializationInfo info, StreamingContext context)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
internal int MaxColumns()
|
||||||
|
{
|
||||||
|
int i = 1;
|
||||||
|
foreach (Block b in blocks)
|
||||||
|
{
|
||||||
|
if (b.Columns.Count > i)
|
||||||
|
i = b.Columns.Count;
|
||||||
|
}
|
||||||
|
return i;
|
||||||
|
}
|
||||||
|
|
||||||
|
public DateTime BoxStart
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
DateTime min = DateTime.MaxValue;
|
||||||
|
|
||||||
|
foreach (Block block in blocks)
|
||||||
|
{
|
||||||
|
if (block.BoxStart < min)
|
||||||
|
min = block.BoxStart;
|
||||||
|
}
|
||||||
|
|
||||||
|
return min;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// The end of the box of the last event.
|
||||||
|
/// </summary>
|
||||||
|
public DateTime BoxEnd
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
DateTime max = DateTime.MinValue;
|
||||||
|
|
||||||
|
foreach (Block block in blocks)
|
||||||
|
{
|
||||||
|
if (block.BoxEnd > max)
|
||||||
|
max = block.BoxEnd;
|
||||||
|
}
|
||||||
|
|
||||||
|
return max;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
909
Web/Ui/DayPilotCalendar.cs
Normal file
909
Web/Ui/DayPilotCalendar.cs
Normal file
@@ -0,0 +1,909 @@
|
|||||||
|
/*
|
||||||
|
Copyright <20> 2005 - 2008 Annpoint, s.r.o.
|
||||||
|
|
||||||
|
Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
you may not use this file except in compliance with the License.
|
||||||
|
You may obtain a copy of the License at
|
||||||
|
|
||||||
|
http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
|
||||||
|
Unless required by applicable law or agreed to in writing, software
|
||||||
|
distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
See the License for the specific language governing permissions and
|
||||||
|
limitations under the License.
|
||||||
|
|
||||||
|
-------------------------------------------------------------------------
|
||||||
|
|
||||||
|
NOTE: Reuse requires the following acknowledgement (see also NOTICE):
|
||||||
|
This product includes DayPilot (http://www.daypilot.org) developed by Annpoint, s.r.o.
|
||||||
|
*/
|
||||||
|
|
||||||
|
using System;
|
||||||
|
using System.Collections;
|
||||||
|
using System.ComponentModel;
|
||||||
|
using System.Drawing;
|
||||||
|
using System.Security.Permissions;
|
||||||
|
using System.Web;
|
||||||
|
using System.Web.UI;
|
||||||
|
using System.Web.UI.WebControls;
|
||||||
|
using DayPilot.Web.Ui.Design;
|
||||||
|
|
||||||
|
namespace DayPilot.Web.Ui
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// DayPilot is a component for showing a day schedule.
|
||||||
|
/// </summary>
|
||||||
|
[ToolboxBitmap(typeof(Calendar))]
|
||||||
|
[Designer(typeof(DayPilotCalendarDesigner))]
|
||||||
|
[AspNetHostingPermission(SecurityAction.LinkDemand, Level = AspNetHostingPermissionLevel.Minimal), AspNetHostingPermission(SecurityAction.InheritanceDemand, Level = AspNetHostingPermissionLevel.Minimal)]
|
||||||
|
public partial class DayPilotCalendar : DataBoundControl, IPostBackEventHandler
|
||||||
|
{
|
||||||
|
internal Day[] days;
|
||||||
|
|
||||||
|
private string dataStartField;
|
||||||
|
private string dataEndField;
|
||||||
|
private string dataTextField;
|
||||||
|
private string dataValueField;
|
||||||
|
private string dataOwnerField;
|
||||||
|
|
||||||
|
// day header
|
||||||
|
private bool showHeader = true;
|
||||||
|
private int headerHeight = 21;
|
||||||
|
private string headerDateFormat = "d";
|
||||||
|
|
||||||
|
private ArrayList items;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Event called when the user clicks an event in the calendar. It's only called when EventClickHandling is set to PostBack.
|
||||||
|
/// </summary>
|
||||||
|
[Category("User actions")]
|
||||||
|
[Description("Event called when the user clicks an event in the calendar.")]
|
||||||
|
public event EventClickDelegate EventClick;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Event called when the user clicks a free space in the calendar. It's only called when FreeTimeClickHandling is set to PostBack.
|
||||||
|
/// </summary>
|
||||||
|
[Category("User actions")]
|
||||||
|
[Description("Event called when the user clicks a free space in the calendar.")]
|
||||||
|
public event FreeClickDelegate FreeTimeClick;
|
||||||
|
|
||||||
|
|
||||||
|
#region Viewstate
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Loads ViewState.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="savedState"></param>
|
||||||
|
protected override void LoadViewState(object savedState)
|
||||||
|
{
|
||||||
|
if (savedState == null)
|
||||||
|
return;
|
||||||
|
|
||||||
|
object[] vs = (object[])savedState;
|
||||||
|
|
||||||
|
if (vs.Length != 2)
|
||||||
|
throw new ArgumentException("Wrong savedState object.");
|
||||||
|
|
||||||
|
if (vs[0] != null)
|
||||||
|
base.LoadViewState(vs[0]);
|
||||||
|
|
||||||
|
if (vs[1] != null)
|
||||||
|
items = (ArrayList)vs[1];
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Saves ViewState.
|
||||||
|
/// </summary>
|
||||||
|
/// <returns></returns>
|
||||||
|
protected override object SaveViewState()
|
||||||
|
{
|
||||||
|
object[] vs = new object[2];
|
||||||
|
vs[0] = base.SaveViewState();
|
||||||
|
vs[1] = items;
|
||||||
|
|
||||||
|
return vs;
|
||||||
|
}
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
#region PostBack
|
||||||
|
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
///
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="eventArgument"></param>
|
||||||
|
public void RaisePostBackEvent(string eventArgument)
|
||||||
|
{
|
||||||
|
|
||||||
|
if (eventArgument.StartsWith("PK:"))
|
||||||
|
{
|
||||||
|
string pk = eventArgument.Substring(3, eventArgument.Length - 3);
|
||||||
|
if (EventClick != null)
|
||||||
|
EventClick(this, new EventClickEventArgs(pk));
|
||||||
|
}
|
||||||
|
else if (eventArgument.StartsWith("TIME:"))
|
||||||
|
{
|
||||||
|
DateTime time = Convert.ToDateTime(eventArgument.Substring(5, eventArgument.Length - 5));
|
||||||
|
if (FreeTimeClick != null)
|
||||||
|
FreeTimeClick(this, new FreeClickEventArgs(time));
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
throw new ArgumentException("Bad argument passed from postback event.");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
#region Rendering
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Renders the component HTML code.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="output"></param>
|
||||||
|
protected override void Render(HtmlTextWriter output)
|
||||||
|
{
|
||||||
|
loadEventsToDays();
|
||||||
|
|
||||||
|
// <table>
|
||||||
|
output.AddAttribute("id", ClientID);
|
||||||
|
output.AddAttribute("cellpadding", "0");
|
||||||
|
output.AddAttribute("cellspacing", "0");
|
||||||
|
output.AddAttribute("border", "0");
|
||||||
|
output.AddAttribute("width", Width.ToString());
|
||||||
|
output.AddStyleAttribute("border-bottom", "1px solid " + ColorTranslator.ToHtml(BorderColor));
|
||||||
|
output.AddStyleAttribute("text-align", "left");
|
||||||
|
output.RenderBeginTag("table");
|
||||||
|
|
||||||
|
// <tr>
|
||||||
|
output.RenderBeginTag("tr");
|
||||||
|
|
||||||
|
// <td>
|
||||||
|
output.AddAttribute("valign", "top");
|
||||||
|
output.RenderBeginTag("td");
|
||||||
|
|
||||||
|
if (ShowHours)
|
||||||
|
renderHourNamesTable(output);
|
||||||
|
|
||||||
|
// </td>
|
||||||
|
output.RenderEndTag();
|
||||||
|
|
||||||
|
// <td>
|
||||||
|
output.AddAttribute("width", "100%");
|
||||||
|
output.AddAttribute("valign", "top");
|
||||||
|
output.RenderBeginTag("td");
|
||||||
|
|
||||||
|
renderEventsAndCells(output);
|
||||||
|
|
||||||
|
// </td>
|
||||||
|
output.RenderEndTag();
|
||||||
|
// </tr>
|
||||||
|
output.RenderEndTag();
|
||||||
|
// </table>
|
||||||
|
output.RenderEndTag();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
private void renderHourNamesTable(HtmlTextWriter output)
|
||||||
|
{
|
||||||
|
// output.WriteLine("<!-- hours table -->");
|
||||||
|
output.AddAttribute("cellpadding", "0");
|
||||||
|
output.AddAttribute("cellspacing", "0");
|
||||||
|
output.AddAttribute("border", "0");
|
||||||
|
output.AddAttribute("width", this.HourWidth.ToString());
|
||||||
|
|
||||||
|
output.AddStyleAttribute("border-left", "1px solid " + ColorTranslator.ToHtml(BorderColor));
|
||||||
|
output.RenderBeginTag("table");
|
||||||
|
|
||||||
|
// <tr> first emtpy
|
||||||
|
output.AddStyleAttribute("height", "1px");
|
||||||
|
output.AddStyleAttribute("background-color", ColorTranslator.ToHtml(BorderColor));
|
||||||
|
output.RenderBeginTag("tr");
|
||||||
|
|
||||||
|
output.RenderBeginTag("td");
|
||||||
|
output.RenderEndTag();
|
||||||
|
|
||||||
|
// </tr> first empty
|
||||||
|
output.RenderEndTag();
|
||||||
|
|
||||||
|
if (this.ShowHeader)
|
||||||
|
renderHourHeader(output);
|
||||||
|
|
||||||
|
for (DateTime i = visibleStart; i < visibleEnd; i = i.AddHours(1))
|
||||||
|
{
|
||||||
|
renderHourTr(output, i);
|
||||||
|
}
|
||||||
|
|
||||||
|
// </table>
|
||||||
|
output.RenderEndTag();
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
private void renderHourTr(HtmlTextWriter output, DateTime i)
|
||||||
|
{
|
||||||
|
|
||||||
|
// <tr>
|
||||||
|
output.AddStyleAttribute("height", HourHeight + "px");
|
||||||
|
output.RenderBeginTag("tr");
|
||||||
|
|
||||||
|
// <td>
|
||||||
|
output.AddAttribute("valign", "bottom");
|
||||||
|
output.AddStyleAttribute("background-color", ColorTranslator.ToHtml(HourNameBackColor));
|
||||||
|
output.AddStyleAttribute("cursor", "default");
|
||||||
|
output.RenderBeginTag("td");
|
||||||
|
|
||||||
|
// <div> block
|
||||||
|
// DivWriter divBlock = new DivWriter();
|
||||||
|
output.AddStyleAttribute("display", "block");
|
||||||
|
output.AddStyleAttribute("border-bottom", "1px solid " + ColorTranslator.ToHtml(HourNameBorderColor));
|
||||||
|
output.AddStyleAttribute("height", (HourHeight - 1) + "px");
|
||||||
|
output.AddStyleAttribute("text-align", "right");
|
||||||
|
output.RenderBeginTag("div");
|
||||||
|
// output.Write(divBlock.BeginTag());
|
||||||
|
|
||||||
|
// <div> text
|
||||||
|
// DivWriter divText = new DivWriter();
|
||||||
|
output.AddStyleAttribute("padding", "2px");
|
||||||
|
output.AddStyleAttribute("font-family", HourFontFamily);
|
||||||
|
output.AddStyleAttribute("font-size", HourFontSize);
|
||||||
|
output.RenderBeginTag("div");
|
||||||
|
// output.Write(divText.BeginTag());
|
||||||
|
|
||||||
|
int hour = i.Hour;
|
||||||
|
bool am = (i.Hour / 12) == 0;
|
||||||
|
if (TimeFormat == TimeFormat.Clock12Hours)
|
||||||
|
{
|
||||||
|
hour = i.Hour % 12;
|
||||||
|
if (hour == 0)
|
||||||
|
hour = 12;
|
||||||
|
}
|
||||||
|
|
||||||
|
output.Write(hour);
|
||||||
|
output.Write("<span style='font-size:10px; vertical-align: super; '> ");
|
||||||
|
if (TimeFormat == TimeFormat.Clock24Hours)
|
||||||
|
{
|
||||||
|
output.Write("00");
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
if (am)
|
||||||
|
output.Write("AM");
|
||||||
|
else
|
||||||
|
output.Write("PM");
|
||||||
|
}
|
||||||
|
output.Write("</span>");
|
||||||
|
|
||||||
|
output.RenderEndTag();
|
||||||
|
output.RenderEndTag();
|
||||||
|
// output.Write(divText.EndTag());
|
||||||
|
// output.Write(divBlock.EndTag());
|
||||||
|
output.RenderEndTag(); // </td>
|
||||||
|
output.RenderEndTag(); // </tr>
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
private void renderHourHeader(HtmlTextWriter output)
|
||||||
|
{
|
||||||
|
|
||||||
|
// <tr>
|
||||||
|
output.AddStyleAttribute("height", (this.HeaderHeight) + "px");
|
||||||
|
output.RenderBeginTag("tr");
|
||||||
|
|
||||||
|
// <td>
|
||||||
|
output.AddAttribute("valign", "bottom");
|
||||||
|
output.AddStyleAttribute("background-color", ColorTranslator.ToHtml(HourNameBackColor));
|
||||||
|
output.AddStyleAttribute("cursor", "default");
|
||||||
|
output.RenderBeginTag("td");
|
||||||
|
|
||||||
|
// <div> block
|
||||||
|
// DivWriter divBlock = new DivWriter();
|
||||||
|
output.AddStyleAttribute("display", "block");
|
||||||
|
output.AddStyleAttribute("border-bottom", "1px solid " + ColorTranslator.ToHtml(BorderColor));
|
||||||
|
output.AddStyleAttribute("text-align", "right");
|
||||||
|
output.RenderBeginTag("div");
|
||||||
|
// output.Write(divBlock.BeginTag());
|
||||||
|
|
||||||
|
// <div> text
|
||||||
|
// DivWriter divText = new DivWriter();
|
||||||
|
output.AddStyleAttribute("padding", "2px");
|
||||||
|
output.AddStyleAttribute("font-size", "6pt");
|
||||||
|
output.RenderBeginTag("div");
|
||||||
|
// output.Write(divText.BeginTag());
|
||||||
|
|
||||||
|
output.Write(" ");
|
||||||
|
|
||||||
|
output.RenderEndTag();
|
||||||
|
output.RenderEndTag();
|
||||||
|
// output.Write(divText.EndTag());
|
||||||
|
// output.Write(divBlock.EndTag());
|
||||||
|
output.RenderEndTag(); // </td>
|
||||||
|
output.RenderEndTag(); // </tr>
|
||||||
|
}
|
||||||
|
|
||||||
|
private void renderEventsAndCells(HtmlTextWriter output)
|
||||||
|
{
|
||||||
|
// output.WriteLine("<!-- cells table -->");
|
||||||
|
|
||||||
|
if (days != null)
|
||||||
|
{
|
||||||
|
// <table>
|
||||||
|
output.AddAttribute("cellpadding", "0");
|
||||||
|
output.AddAttribute("cellspacing", "0");
|
||||||
|
output.AddAttribute("border", "0");
|
||||||
|
output.AddAttribute("width", "100%");
|
||||||
|
output.AddStyleAttribute("border-left", "1px solid " + ColorTranslator.ToHtml(BorderColor));
|
||||||
|
output.RenderBeginTag("table");
|
||||||
|
|
||||||
|
// <tr> first
|
||||||
|
output.AddStyleAttribute("height", "1px");
|
||||||
|
output.AddStyleAttribute("background-color", ColorTranslator.ToHtml(BorderColor));
|
||||||
|
output.RenderBeginTag("tr");
|
||||||
|
|
||||||
|
renderEventTds(output);
|
||||||
|
|
||||||
|
// </tr> first
|
||||||
|
output.RenderEndTag();
|
||||||
|
|
||||||
|
// header
|
||||||
|
if (this.ShowHeader)
|
||||||
|
{
|
||||||
|
renderDayHeaders(output);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
output.WriteLine("<!-- empty cells -->");
|
||||||
|
|
||||||
|
// render all cells
|
||||||
|
|
||||||
|
for (DateTime i = visibleStart; i < visibleEnd; i = i.AddHours(1))
|
||||||
|
{
|
||||||
|
|
||||||
|
// <tr> first half-hour
|
||||||
|
output.RenderBeginTag("tr");
|
||||||
|
|
||||||
|
addHalfHourCells(output, i, true, false);
|
||||||
|
|
||||||
|
// </tr>
|
||||||
|
output.RenderEndTag();
|
||||||
|
|
||||||
|
// <tr> second half-hour
|
||||||
|
output.AddStyleAttribute("height", (HourHeight / 2) + "px");
|
||||||
|
output.RenderBeginTag("tr");
|
||||||
|
|
||||||
|
bool isLastRow = (i == visibleEnd.AddHours(-1));
|
||||||
|
addHalfHourCells(output, i, false, isLastRow);
|
||||||
|
|
||||||
|
// </tr>
|
||||||
|
output.RenderEndTag();
|
||||||
|
}
|
||||||
|
|
||||||
|
// </table>
|
||||||
|
output.RenderEndTag();
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
private void renderDayHeaders(HtmlTextWriter output)
|
||||||
|
{
|
||||||
|
output.AddStyleAttribute("background-color", ColorTranslator.ToHtml(HourNameBackColor));
|
||||||
|
output.AddStyleAttribute("height", this.HeaderHeight + "px");
|
||||||
|
output.RenderBeginTag("tr");
|
||||||
|
|
||||||
|
foreach (Day d in days)
|
||||||
|
{
|
||||||
|
DateTime h = new DateTime(d.Start.Year, d.Start.Month, d.Start.Day, 0, 0, 0);
|
||||||
|
|
||||||
|
// <td>
|
||||||
|
output.AddAttribute("valign", "bottom");
|
||||||
|
output.AddStyleAttribute("background-color", ColorTranslator.ToHtml(HourNameBackColor));
|
||||||
|
output.AddStyleAttribute("cursor", "default");
|
||||||
|
output.AddStyleAttribute("border-right", "1px solid " + ColorTranslator.ToHtml(BorderColor));
|
||||||
|
output.RenderBeginTag("td");
|
||||||
|
|
||||||
|
// <div> block
|
||||||
|
// DivWriter divBlock = new DivWriter();
|
||||||
|
output.AddStyleAttribute("display", "block");
|
||||||
|
output.AddStyleAttribute("border-bottom", "1px solid " + ColorTranslator.ToHtml(BorderColor));
|
||||||
|
output.AddStyleAttribute("text-align", "center");
|
||||||
|
output.RenderBeginTag("div");
|
||||||
|
// output.Write(divBlock.BeginTag());
|
||||||
|
|
||||||
|
// <div> text
|
||||||
|
// DivWriter divText = new DivWriter();
|
||||||
|
output.AddStyleAttribute("padding", "2px");
|
||||||
|
output.AddStyleAttribute("font-family", DayFontFamily);
|
||||||
|
output.AddStyleAttribute("font-size", DayFontSize);
|
||||||
|
output.RenderBeginTag("div");
|
||||||
|
// output.Write(divText.BeginTag());
|
||||||
|
|
||||||
|
output.Write(h.ToString(this.headerDateFormat));
|
||||||
|
// output.Write(" ");
|
||||||
|
|
||||||
|
output.RenderEndTag();
|
||||||
|
output.RenderEndTag();
|
||||||
|
// output.Write(divText.EndTag());
|
||||||
|
// output.Write(divBlock.EndTag());
|
||||||
|
output.RenderEndTag(); // </td>
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
output.RenderEndTag();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
private void renderEventTds(HtmlTextWriter output)
|
||||||
|
{
|
||||||
|
|
||||||
|
int dayPctWidth = 100 / days.Length;
|
||||||
|
|
||||||
|
for (int i = 0; i < days.Length; i++)
|
||||||
|
{
|
||||||
|
Day d = days[i];
|
||||||
|
|
||||||
|
|
||||||
|
// <td>
|
||||||
|
output.AddStyleAttribute("height", "1px");
|
||||||
|
output.AddStyleAttribute("text-align", "left");
|
||||||
|
output.AddAttribute("width", dayPctWidth + "%");
|
||||||
|
output.RenderBeginTag("td");
|
||||||
|
|
||||||
|
// <div> position
|
||||||
|
// DivWriter divPosition = new DivWriter();
|
||||||
|
output.AddStyleAttribute("display", "block");
|
||||||
|
output.AddStyleAttribute("margin-right", ColumnMarginRight + "px");
|
||||||
|
output.AddStyleAttribute("position", "relative");
|
||||||
|
output.AddStyleAttribute("height", "1px");
|
||||||
|
output.AddStyleAttribute("font-size", "1px");
|
||||||
|
output.AddStyleAttribute("margin-top", "-1px");
|
||||||
|
output.RenderBeginTag("div");
|
||||||
|
// output.Write(divPosition.BeginTag());
|
||||||
|
|
||||||
|
foreach (Event e in d.events)
|
||||||
|
{
|
||||||
|
renderEvent(output, e, d);
|
||||||
|
}
|
||||||
|
|
||||||
|
// </div> position
|
||||||
|
// output.Write(divPosition.EndTag());
|
||||||
|
output.RenderEndTag();
|
||||||
|
|
||||||
|
// </td>
|
||||||
|
output.RenderEndTag();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void renderEvent(HtmlTextWriter output, Event e, Day d)
|
||||||
|
{
|
||||||
|
string displayTextPopup = e.Name + " (" + e.Start.ToShortTimeString() + " - " + e.End.ToShortTimeString() + ")"+":"+e.Owner;
|
||||||
|
string displayText = e.Name + ": " + e.Owner;
|
||||||
|
|
||||||
|
// real box dimensions and position
|
||||||
|
DateTime dayVisibleStart = new DateTime(d.Start.Year, d.Start.Month, d.Start.Day, visibleStart.Hour, 0, 0);
|
||||||
|
DateTime realBoxStart = e.BoxStart < dayVisibleStart ? dayVisibleStart : e.BoxStart;
|
||||||
|
|
||||||
|
DateTime dayVisibleEnd;
|
||||||
|
if (visibleEnd.Day == 1)
|
||||||
|
dayVisibleEnd = new DateTime(d.Start.Year, d.Start.Month, d.Start.Day, visibleEnd.Hour, 0, 0);
|
||||||
|
else if (visibleEnd.Day == 2)
|
||||||
|
dayVisibleEnd = new DateTime(d.Start.Year, d.Start.Month, d.Start.Day, visibleEnd.Hour, 0, 0).AddDays(1);
|
||||||
|
else
|
||||||
|
throw new ArgumentOutOfRangeException("Unexpected time for dayVisibleEnd.");
|
||||||
|
|
||||||
|
DateTime realBoxEnd = e.BoxEnd > dayVisibleEnd ? dayVisibleEnd : e.BoxEnd;
|
||||||
|
|
||||||
|
// top
|
||||||
|
double top = (realBoxStart - dayVisibleStart).TotalHours * HourHeight + 1;
|
||||||
|
if (ShowHeader)
|
||||||
|
top += this.HeaderHeight;
|
||||||
|
|
||||||
|
// height
|
||||||
|
double height = ((realBoxEnd - realBoxStart).TotalHours * HourHeight - 2);
|
||||||
|
|
||||||
|
// It's outside of visible area (for NonBusinessHours set to Hide).
|
||||||
|
// Don't draw it in that case.
|
||||||
|
if (height <= 0)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
// MAIN BOX
|
||||||
|
output.AddAttribute("onselectstart", "return false;"); // prevent text selection in IE
|
||||||
|
|
||||||
|
if (EventClickHandling == UserActionHandling.PostBack)
|
||||||
|
{
|
||||||
|
output.AddAttribute("onclick", "javascript:event.cancelBubble=true;" + Page.ClientScript.GetPostBackEventReference(this, "PK:" + e.PK));
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
output.AddAttribute("onclick", "javascript:event.cancelBubble=true;" + String.Format(EventClickJavaScript, e.PK));
|
||||||
|
}
|
||||||
|
|
||||||
|
output.AddStyleAttribute("-moz-user-select", "none"); // prevent text selection in FF
|
||||||
|
output.AddStyleAttribute("-khtml-user-select", "none"); // prevent text selection
|
||||||
|
output.AddStyleAttribute("user-select", "none"); // prevent text selection
|
||||||
|
output.AddStyleAttribute("cursor", "pointer");
|
||||||
|
//output.AddStyleAttribute("cursor", "hand");
|
||||||
|
output.AddStyleAttribute("position", "absolute");
|
||||||
|
output.AddStyleAttribute("font-family", EventFontFamily);
|
||||||
|
output.AddStyleAttribute("font-size", EventFontSize);
|
||||||
|
output.AddStyleAttribute("white-space", "no-wrap");
|
||||||
|
output.AddStyleAttribute("left", e.Column.StartsAtPct + "%");
|
||||||
|
output.AddStyleAttribute("top", top + "px");
|
||||||
|
output.AddStyleAttribute("width", e.Column.WidthPct + "%");
|
||||||
|
output.AddStyleAttribute("height", (realBoxEnd - realBoxStart).TotalHours * HourHeight + "px");
|
||||||
|
output.AddStyleAttribute("background-color", ColorTranslator.ToHtml(EventBorderColor));
|
||||||
|
output.RenderBeginTag("div");
|
||||||
|
//output.Write(divMain.BeginTag());
|
||||||
|
|
||||||
|
// FIX BOX - to fix the outer/inner box differences in Mozilla/IE (to create border)
|
||||||
|
// DivWriter divFix = new DivWriter();
|
||||||
|
output.AddAttribute("onmouseover", "this.style.backgroundColor='" + ColorTranslator.ToHtml(EventHoverColor) + "';event.cancelBubble=true;");
|
||||||
|
output.AddAttribute("onmouseout", "this.style.backgroundColor='" + ColorTranslator.ToHtml(EventBackColor) + "';event.cancelBubble=true;");
|
||||||
|
|
||||||
|
if (ShowToolTip)
|
||||||
|
{
|
||||||
|
output.AddAttribute("title", displayTextPopup);
|
||||||
|
}
|
||||||
|
|
||||||
|
output.AddStyleAttribute("margin-top", "1px");
|
||||||
|
output.AddStyleAttribute("display", "block");
|
||||||
|
output.AddStyleAttribute("height", height + "px");
|
||||||
|
output.AddStyleAttribute("background-color", ColorTranslator.ToHtml(EventBackColor));
|
||||||
|
output.AddStyleAttribute("border-left", "1px solid " + ColorTranslator.ToHtml(EventBorderColor));
|
||||||
|
output.AddStyleAttribute("border-right", "1px solid " + ColorTranslator.ToHtml(EventBorderColor));
|
||||||
|
output.AddStyleAttribute("overflow", "hidden");
|
||||||
|
output.RenderBeginTag("div");
|
||||||
|
// output.Write(divFix.BeginTag());
|
||||||
|
|
||||||
|
// blue column
|
||||||
|
if (e.Start > realBoxStart)
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
int startDelta = (int) Math.Floor((e.Start - realBoxStart).TotalHours * HourHeight);
|
||||||
|
int endDelta = (int) Math.Floor((realBoxEnd - e.End).TotalHours * HourHeight);
|
||||||
|
|
||||||
|
// DivWriter divBlue = new DivWriter();
|
||||||
|
output.AddStyleAttribute("float", "left");
|
||||||
|
output.AddStyleAttribute("width", "5px");
|
||||||
|
output.AddStyleAttribute("height", height - startDelta - endDelta + "px");
|
||||||
|
output.AddStyleAttribute("margin-top", startDelta + "px");
|
||||||
|
output.AddStyleAttribute("background-color", ColorTranslator.ToHtml(DurationBarColor));
|
||||||
|
output.AddStyleAttribute("font-size", "1px");
|
||||||
|
output.RenderBeginTag("div");
|
||||||
|
output.RenderEndTag();
|
||||||
|
// output.Write(divBlue.BeginTag());
|
||||||
|
// output.Write(divBlue.EndTag());
|
||||||
|
|
||||||
|
// right border of blue column
|
||||||
|
// DivWriter divBorder = new DivWriter();
|
||||||
|
output.AddStyleAttribute("float", "left");
|
||||||
|
output.AddStyleAttribute("width", "1px");
|
||||||
|
output.AddStyleAttribute("background-color", ColorTranslator.ToHtml(EventBorderColor));
|
||||||
|
output.AddStyleAttribute("height", "100%");
|
||||||
|
output.RenderBeginTag("div");
|
||||||
|
output.RenderEndTag();
|
||||||
|
// output.Write(divBorder.BeginTag());
|
||||||
|
// output.Write(divBorder.EndTag());
|
||||||
|
|
||||||
|
// space
|
||||||
|
// DivWriter divSpace = new DivWriter();
|
||||||
|
output.AddStyleAttribute("float", "left");
|
||||||
|
output.AddStyleAttribute("width", "2px");
|
||||||
|
output.AddStyleAttribute("height", "100%");
|
||||||
|
output.RenderBeginTag("div");
|
||||||
|
output.RenderEndTag();
|
||||||
|
// output.Write(divSpace.BeginTag());
|
||||||
|
// output.Write(divSpace.EndTag());
|
||||||
|
|
||||||
|
// PADDING BOX
|
||||||
|
// DivWriter divPadding = new DivWriter();
|
||||||
|
output.AddStyleAttribute("padding", "1px");
|
||||||
|
output.RenderBeginTag("div");
|
||||||
|
// output.Write(divPadding.BeginTag());
|
||||||
|
|
||||||
|
output.Write(displayText); // e.BoxStart - dayVisibleStart
|
||||||
|
|
||||||
|
// closing the PADDING BOX
|
||||||
|
output.RenderEndTag();
|
||||||
|
// output.Write(divPadding.EndTag());
|
||||||
|
|
||||||
|
// closing the FIX BOX
|
||||||
|
output.RenderEndTag();
|
||||||
|
// output.Write(divFix.EndTag());
|
||||||
|
|
||||||
|
// closing the MAIN BOX
|
||||||
|
// output.Write(divMain.EndTag());
|
||||||
|
output.RenderEndTag();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void addHalfHourCells(HtmlTextWriter output, DateTime hour, bool hourStartsHere, bool isLast)
|
||||||
|
{
|
||||||
|
foreach (Day d in days)
|
||||||
|
{
|
||||||
|
DateTime h = new DateTime(d.Start.Year, d.Start.Month, d.Start.Day, hour.Hour, 0, 0);
|
||||||
|
addHalfHourCell(output, h, hourStartsHere, isLast);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void addHalfHourCell(HtmlTextWriter output, DateTime hour, bool hourStartsHere, bool isLast)
|
||||||
|
{
|
||||||
|
string cellBgColor;
|
||||||
|
if (hour.Hour < BusinessBeginsHour || hour.Hour >= BusinessEndsHour || hour.DayOfWeek == DayOfWeek.Saturday || hour.DayOfWeek == DayOfWeek.Sunday)
|
||||||
|
cellBgColor = ColorTranslator.ToHtml(NonBusinessBackColor);
|
||||||
|
else
|
||||||
|
cellBgColor = ColorTranslator.ToHtml(BackColor);
|
||||||
|
|
||||||
|
string borderBottomColor;
|
||||||
|
if (hourStartsHere)
|
||||||
|
borderBottomColor = ColorTranslator.ToHtml(HourHalfBorderColor);
|
||||||
|
else
|
||||||
|
borderBottomColor = ColorTranslator.ToHtml(HourBorderColor);
|
||||||
|
|
||||||
|
DateTime startingTime = hour;
|
||||||
|
if (!hourStartsHere)
|
||||||
|
startingTime = hour.AddMinutes(30);
|
||||||
|
|
||||||
|
if (FreetimeClickHandling == UserActionHandling.PostBack)
|
||||||
|
{
|
||||||
|
output.AddAttribute("onclick", "javascript:" + Page.ClientScript.GetPostBackEventReference(this, "TIME:" + startingTime.ToString("s")));
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
output.AddAttribute("onclick", "javascript:" + String.Format(FreeTimeClickJavaScript, startingTime.ToString("s")));
|
||||||
|
}
|
||||||
|
output.AddAttribute("onmouseover", "this.style.backgroundColor='" + ColorTranslator.ToHtml(HoverColor) + "';");
|
||||||
|
output.AddAttribute("onmouseout", "this.style.backgroundColor='" + cellBgColor + "';");
|
||||||
|
output.AddAttribute("valign", "bottom");
|
||||||
|
output.AddStyleAttribute("background-color", cellBgColor);
|
||||||
|
output.AddStyleAttribute("cursor", "pointer");
|
||||||
|
output.AddStyleAttribute("cursor", "hand");
|
||||||
|
output.AddStyleAttribute("border-right", "1px solid " + ColorTranslator.ToHtml(BorderColor));
|
||||||
|
output.AddStyleAttribute("height", (HourHeight / 2) + "px");
|
||||||
|
output.RenderBeginTag("td");
|
||||||
|
|
||||||
|
// FIX BOX - to fix the outer/inner box differences in Mozilla/IE (to create border)
|
||||||
|
// DivWriter divFix = new DivWriter();
|
||||||
|
output.AddStyleAttribute("display", "block");
|
||||||
|
output.AddStyleAttribute("height", "14px");
|
||||||
|
if (!isLast)
|
||||||
|
output.AddStyleAttribute("border-bottom", "1px solid " + borderBottomColor);
|
||||||
|
output.RenderBeginTag("div");
|
||||||
|
// output.Write(divFix.BeginTag());
|
||||||
|
|
||||||
|
// required
|
||||||
|
output.Write("<span style='font-size:1px'> </span>");
|
||||||
|
|
||||||
|
// closing the FIX BOX
|
||||||
|
output.RenderEndTag();
|
||||||
|
// output.Write(divFix.EndTag());
|
||||||
|
|
||||||
|
// </td>
|
||||||
|
output.RenderEndTag();
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
#region Calculations
|
||||||
|
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// This is only a relative time. The date part should be ignored.
|
||||||
|
/// </summary>
|
||||||
|
private DateTime visibleStart
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
DateTime date = new DateTime(1900, 1, 1);
|
||||||
|
|
||||||
|
if (NonBusinessHours == NonBusinessHoursBehavior.Show)
|
||||||
|
return new DateTime(date.Year, date.Month, date.Day, 0, 0, 0);
|
||||||
|
|
||||||
|
DateTime start = new DateTime(date.Year, date.Month, date.Day, BusinessBeginsHour, 0, 0);
|
||||||
|
|
||||||
|
if (NonBusinessHours == NonBusinessHoursBehavior.Hide)
|
||||||
|
return start;
|
||||||
|
|
||||||
|
if (days == null)
|
||||||
|
return start;
|
||||||
|
|
||||||
|
if (totalEvents == 0)
|
||||||
|
return start;
|
||||||
|
|
||||||
|
foreach (Day d in days)
|
||||||
|
{
|
||||||
|
DateTime boxStart = new DateTime(date.Year, date.Month, date.Day, d.BoxStart.Hour, d.BoxStart.Minute, d.BoxStart.Second);
|
||||||
|
if (boxStart < start)
|
||||||
|
start = boxStart;
|
||||||
|
}
|
||||||
|
|
||||||
|
return new DateTime(start.Year, start.Month, start.Day, start.Hour, 0, 0);
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// This is only a relative time. The date part should be ignored.
|
||||||
|
/// </summary>
|
||||||
|
private DateTime visibleEnd
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
DateTime date = new DateTime(1900, 1, 1);
|
||||||
|
|
||||||
|
if (NonBusinessHours == NonBusinessHoursBehavior.Show)
|
||||||
|
return new DateTime(date.Year, date.Month, date.Day, 0, 0, 0).AddDays(1);
|
||||||
|
|
||||||
|
DateTime end;
|
||||||
|
if (BusinessEndsHour == 24)
|
||||||
|
end = new DateTime(date.Year, date.Month, date.Day, 0, 0, 0).AddDays(1);
|
||||||
|
else
|
||||||
|
end = new DateTime(date.Year, date.Month, date.Day, BusinessEndsHour, 0, 0);
|
||||||
|
|
||||||
|
if (NonBusinessHours == NonBusinessHoursBehavior.Hide)
|
||||||
|
return end;
|
||||||
|
|
||||||
|
if (days == null)
|
||||||
|
return end;
|
||||||
|
|
||||||
|
if (totalEvents == 0)
|
||||||
|
return end;
|
||||||
|
|
||||||
|
foreach (Day d in days)
|
||||||
|
{
|
||||||
|
|
||||||
|
bool addDay = false;
|
||||||
|
if (d.BoxEnd > DateTime.MinValue && d.BoxEnd.AddDays(-1) >= d.Start)
|
||||||
|
addDay = true;
|
||||||
|
|
||||||
|
DateTime boxEnd = new DateTime(date.Year, date.Month, date.Day, d.BoxEnd.Hour, d.BoxEnd.Minute, d.BoxEnd.Second);
|
||||||
|
|
||||||
|
if (addDay)
|
||||||
|
boxEnd = boxEnd.AddDays(1);
|
||||||
|
|
||||||
|
if (boxEnd > end)
|
||||||
|
end = boxEnd;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (end.Minute != 0)
|
||||||
|
end = end.AddHours(1);
|
||||||
|
|
||||||
|
return new DateTime(end.Year, end.Month, end.Day, end.Hour, 0, 0);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
private int totalEvents
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
int ti = 0;
|
||||||
|
foreach (Day d in days)
|
||||||
|
ti += d.events.Count;
|
||||||
|
|
||||||
|
return ti;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
#region Data binding
|
||||||
|
|
||||||
|
|
||||||
|
protected override void PerformSelect()
|
||||||
|
{
|
||||||
|
// Call OnDataBinding here if bound to a data source using the
|
||||||
|
// DataSource property (instead of a DataSourceID), because the
|
||||||
|
// databinding statement is evaluated before the call to GetData.
|
||||||
|
if (!IsBoundUsingDataSourceID)
|
||||||
|
{
|
||||||
|
this.OnDataBinding(EventArgs.Empty);
|
||||||
|
}
|
||||||
|
|
||||||
|
// The GetData method retrieves the DataSourceView object from
|
||||||
|
// the IDataSource associated with the data-bound control.
|
||||||
|
GetData().Select(CreateDataSourceSelectArguments(),
|
||||||
|
this.OnDataSourceViewSelectCallback);
|
||||||
|
|
||||||
|
// The PerformDataBinding method has completed.
|
||||||
|
RequiresDataBinding = false;
|
||||||
|
MarkAsDataBound();
|
||||||
|
|
||||||
|
// Raise the DataBound event.
|
||||||
|
OnDataBound(EventArgs.Empty);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void OnDataSourceViewSelectCallback(IEnumerable retrievedData)
|
||||||
|
{
|
||||||
|
// Call OnDataBinding only if it has not already been
|
||||||
|
// called in the PerformSelect method.
|
||||||
|
if (IsBoundUsingDataSourceID)
|
||||||
|
{
|
||||||
|
OnDataBinding(EventArgs.Empty);
|
||||||
|
}
|
||||||
|
// The PerformDataBinding method binds the data in the
|
||||||
|
// retrievedData collection to elements of the data-bound control.
|
||||||
|
PerformDataBinding(retrievedData);
|
||||||
|
}
|
||||||
|
|
||||||
|
protected override void PerformDataBinding(IEnumerable retrievedData)
|
||||||
|
{
|
||||||
|
// don't load events in design mode
|
||||||
|
if (DesignMode)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
base.PerformDataBinding(retrievedData);
|
||||||
|
|
||||||
|
if (DataStartField == null || DataStartField == String.Empty)
|
||||||
|
throw new NullReferenceException("DataStartField property must be specified.");
|
||||||
|
|
||||||
|
if (DataEndField == null || DataEndField == String.Empty)
|
||||||
|
throw new NullReferenceException("DataEndField property must be specified.");
|
||||||
|
|
||||||
|
if (DataTextField == null || DataTextField == String.Empty)
|
||||||
|
throw new NullReferenceException("DataTextField property must be specified.");
|
||||||
|
|
||||||
|
if (DataValueField == null || DataValueField == String.Empty)
|
||||||
|
throw new NullReferenceException("DataValueField property must be specified.");
|
||||||
|
if (DataOwnerField == null || DataOwnerField == String.Empty)
|
||||||
|
throw new NullReferenceException("DataOwnerField property must be specified.");
|
||||||
|
|
||||||
|
|
||||||
|
// Verify data exists.
|
||||||
|
if (retrievedData != null)
|
||||||
|
{
|
||||||
|
items = new ArrayList();
|
||||||
|
|
||||||
|
foreach (object dataItem in retrievedData)
|
||||||
|
{
|
||||||
|
|
||||||
|
DateTime start = Convert.ToDateTime(DataBinder.GetPropertyValue(dataItem, DataStartField, null));
|
||||||
|
DateTime end = Convert.ToDateTime(DataBinder.GetPropertyValue(dataItem, DataEndField, null));
|
||||||
|
string name = Convert.ToString(DataBinder.GetPropertyValue(dataItem, DataTextField, null));
|
||||||
|
string pk = Convert.ToString(DataBinder.GetPropertyValue(dataItem, DataValueField, null));
|
||||||
|
string own = Convert.ToString(DataBinder.GetPropertyValue(dataItem, DataOwnerField, null));
|
||||||
|
|
||||||
|
items.Add(new Event(pk, start, end, name, null, own));
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
items.Sort(new EventComparer());
|
||||||
|
|
||||||
|
// loadEventsToDays();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void loadEventsToDays()
|
||||||
|
{
|
||||||
|
|
||||||
|
if (EndDate < StartDate)
|
||||||
|
throw new ArgumentException("EndDate must be equal to or greater than StartDate.");
|
||||||
|
|
||||||
|
int dayCount = (int)(EndDate - StartDate).TotalDays + 1;
|
||||||
|
days = new Day[dayCount];
|
||||||
|
|
||||||
|
for (int i = 0; i < days.Length; i++)
|
||||||
|
{
|
||||||
|
days[i] = new Day(StartDate.AddDays(i));
|
||||||
|
|
||||||
|
if (items != null)
|
||||||
|
days[i].Load(items);
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
825
Web/Ui/DayPilotCalendarProperties.cs
Normal file
825
Web/Ui/DayPilotCalendarProperties.cs
Normal file
@@ -0,0 +1,825 @@
|
|||||||
|
/*
|
||||||
|
Copyright <20> 2005 - 2008 Annpoint, s.r.o.
|
||||||
|
|
||||||
|
Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
you may not use this file except in compliance with the License.
|
||||||
|
You may obtain a copy of the License at
|
||||||
|
|
||||||
|
http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
|
||||||
|
Unless required by applicable law or agreed to in writing, software
|
||||||
|
distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
See the License for the specific language governing permissions and
|
||||||
|
limitations under the License.
|
||||||
|
|
||||||
|
-------------------------------------------------------------------------
|
||||||
|
|
||||||
|
NOTE: Reuse requires the following acknowledgement (see also NOTICE):
|
||||||
|
This product includes DayPilot (http://www.daypilot.org) developed by Annpoint, s.r.o.
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
using System;
|
||||||
|
using System.ComponentModel;
|
||||||
|
using System.Drawing;
|
||||||
|
using System.Web.UI.WebControls;
|
||||||
|
|
||||||
|
namespace DayPilot.Web.Ui
|
||||||
|
{
|
||||||
|
public partial class DayPilotCalendar
|
||||||
|
{
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Gets or sets the start of the business day (in hours).
|
||||||
|
/// </summary>
|
||||||
|
[Description("Start of the business day (hour from 0 to 23).")]
|
||||||
|
[Category("Appearance")]
|
||||||
|
[DefaultValue(9)]
|
||||||
|
public int BusinessBeginsHour
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
if (ViewState["BusinessBeginsHour"] == null)
|
||||||
|
return 9;
|
||||||
|
return (int)ViewState["BusinessBeginsHour"];
|
||||||
|
}
|
||||||
|
set
|
||||||
|
{
|
||||||
|
if (value < 0)
|
||||||
|
ViewState["BusinessBeginsHour"] = 0;
|
||||||
|
else if (value > 23)
|
||||||
|
ViewState["BusinessBeginsHour"] = 23;
|
||||||
|
else
|
||||||
|
ViewState["BusinessBeginsHour"] = value;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Gets or sets the end of the business day (hours).
|
||||||
|
/// </summary>
|
||||||
|
[Description("End of the business day (hour from 1 to 24).")]
|
||||||
|
[Category("Appearance")]
|
||||||
|
[DefaultValue(18)]
|
||||||
|
public int BusinessEndsHour
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
if (ViewState["BusinessEndsHour"] == null)
|
||||||
|
return 18;
|
||||||
|
return (int)ViewState["BusinessEndsHour"];
|
||||||
|
}
|
||||||
|
set
|
||||||
|
{
|
||||||
|
if (value < BusinessBeginsHour)
|
||||||
|
ViewState["BusinessEndsHour"] = BusinessBeginsHour + 1;
|
||||||
|
else if (value > 24)
|
||||||
|
ViewState["BusinessEndsHour"] = 24;
|
||||||
|
else
|
||||||
|
ViewState["BusinessEndsHour"] = value;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Gets or sets the height of the hour cell in pixels. Must be even.
|
||||||
|
/// </summary>
|
||||||
|
[Description("Height of the hour cell in pixels. Must be even.")]
|
||||||
|
[Category("Layout")]
|
||||||
|
[DefaultValue(40)]
|
||||||
|
public int HourHeight
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
if (ViewState["HourHeight"] == null)
|
||||||
|
return 40;
|
||||||
|
return (int)ViewState["HourHeight"];
|
||||||
|
}
|
||||||
|
set
|
||||||
|
{
|
||||||
|
if (value % 2 == 0)
|
||||||
|
ViewState["HourHeight"] = value;
|
||||||
|
else
|
||||||
|
ViewState["HourHeight"] = value - 1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Gets or sets the width of the hour cell in pixels.
|
||||||
|
/// </summary>
|
||||||
|
[Description("Width of the hour cell in pixels.")]
|
||||||
|
[Category("Layout")]
|
||||||
|
[DefaultValue(40)]
|
||||||
|
public int HourWidth
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
if (ViewState["HourWidth"] == null)
|
||||||
|
return 40;
|
||||||
|
return (int)ViewState["HourWidth"];
|
||||||
|
}
|
||||||
|
set
|
||||||
|
{
|
||||||
|
ViewState["HourWidth"] = value;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Gets or sets the Javascript code that is executed when the users clicks on an event. '{0}' will be replaced by the primary key of the event.
|
||||||
|
/// </summary>
|
||||||
|
[Description("Javascript code that is executed when the users clicks on an event. '{0}' will be replaced by the primary key of the event.")]
|
||||||
|
[Category("User actions")]
|
||||||
|
[DefaultValue("alert('{0}');")]
|
||||||
|
public string EventClickJavaScript
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
if (ViewState["EventClickJavaScript"] == null)
|
||||||
|
return "alert('{0}');";
|
||||||
|
return (string)ViewState["EventClickJavaScript"];
|
||||||
|
}
|
||||||
|
set
|
||||||
|
{
|
||||||
|
ViewState["EventClickJavaScript"] = value;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Gets or sets the Javascript code that is executed when the users clicks on a free time slot. '{0}' will be replaced by the starting time of that slot (i.e. '9:00'.
|
||||||
|
/// </summary>
|
||||||
|
[Description("Javascript code that is executed when the users clicks on a free time slot. '{0}' will be replaced by the starting time of that slot (i.e. '9:00'.")]
|
||||||
|
[Category("User actions")]
|
||||||
|
[DefaultValue("alert('{0}');")]
|
||||||
|
public string FreeTimeClickJavaScript
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
if (ViewState["FreeTimeClickJavaScript"] == null)
|
||||||
|
return "alert('{0}');";
|
||||||
|
return (string)ViewState["FreeTimeClickJavaScript"];
|
||||||
|
}
|
||||||
|
set
|
||||||
|
{
|
||||||
|
ViewState["FreeTimeClickJavaScript"] = value;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Gets or sets the first day to be shown. Default is DateTime.Today.
|
||||||
|
/// </summary>
|
||||||
|
[Description("The first day to be shown. Default is DateTime.Today.")]
|
||||||
|
public DateTime StartDate
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
if (ViewState["StartDate"] == null)
|
||||||
|
{
|
||||||
|
return DateTime.Today;
|
||||||
|
}
|
||||||
|
|
||||||
|
return (DateTime)ViewState["StartDate"];
|
||||||
|
|
||||||
|
}
|
||||||
|
set
|
||||||
|
{
|
||||||
|
ViewState["StartDate"] = new DateTime(value.Year, value.Month, value.Day);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Gets or sets the number of days to be displayed. Default is 1.
|
||||||
|
/// </summary>
|
||||||
|
[Description("The number of days to be displayed on the calendar. Default value is 1.")]
|
||||||
|
[DefaultValue(1)]
|
||||||
|
public int Days
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
if (ViewState["Days"] == null)
|
||||||
|
return 1;
|
||||||
|
return (int)ViewState["Days"];
|
||||||
|
}
|
||||||
|
set
|
||||||
|
{
|
||||||
|
int daysCount = value;
|
||||||
|
|
||||||
|
if (daysCount < 1)
|
||||||
|
daysCount = 1;
|
||||||
|
|
||||||
|
ViewState["Days"] = daysCount;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Gets the last day to be shown.
|
||||||
|
/// </summary>
|
||||||
|
public DateTime EndDate
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
return StartDate.AddDays(Days - 1);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Gets or sets the name of the column that contains the event starting date and time (must be convertible to DateTime).
|
||||||
|
/// </summary>
|
||||||
|
[Description("The name of the column that contains the event starting date and time (must be convertible to DateTime).")]
|
||||||
|
[Category("Data")]
|
||||||
|
public string DataStartField
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
return dataStartField;
|
||||||
|
}
|
||||||
|
set
|
||||||
|
{
|
||||||
|
dataStartField = value;
|
||||||
|
|
||||||
|
if (Initialized)
|
||||||
|
{
|
||||||
|
OnDataPropertyChanged();
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Gets or sets the name of the column that contains the event ending date and time (must be convertible to DateTime).
|
||||||
|
/// </summary>
|
||||||
|
[Description("The name of the column that contains the event ending date and time (must be convertible to DateTime).")]
|
||||||
|
[Category("Data")]
|
||||||
|
public string DataEndField
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
return dataEndField;
|
||||||
|
}
|
||||||
|
set
|
||||||
|
{
|
||||||
|
dataEndField = value;
|
||||||
|
if (Initialized)
|
||||||
|
{
|
||||||
|
OnDataPropertyChanged();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Gets or sets the name of the column that contains the name of an event.
|
||||||
|
/// </summary>
|
||||||
|
[Category("Data")]
|
||||||
|
[Description("The name of the column that contains the name of an event.")]
|
||||||
|
public string DataTextField
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
return dataTextField;
|
||||||
|
}
|
||||||
|
set
|
||||||
|
{
|
||||||
|
dataTextField = value;
|
||||||
|
|
||||||
|
if (Initialized)
|
||||||
|
{
|
||||||
|
OnDataPropertyChanged();
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Gets or sets the name of the column that contains the primary key. The primary key will be used for rendering the custom JavaScript actions.
|
||||||
|
/// </summary>
|
||||||
|
[Category("Data")]
|
||||||
|
[Description("The name of the column that contains the primary key. The primary key will be used for rendering the custom JavaScript actions.")]
|
||||||
|
public string DataValueField
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
return dataValueField;
|
||||||
|
}
|
||||||
|
set
|
||||||
|
{
|
||||||
|
dataValueField = value;
|
||||||
|
|
||||||
|
if (Initialized)
|
||||||
|
{
|
||||||
|
OnDataPropertyChanged();
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
[Category("Data")]
|
||||||
|
[Description("The name of the owner field")]
|
||||||
|
public string DataOwnerField
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
return dataOwnerField;
|
||||||
|
}
|
||||||
|
set
|
||||||
|
{
|
||||||
|
dataOwnerField = value;
|
||||||
|
|
||||||
|
if (Initialized)
|
||||||
|
{
|
||||||
|
OnDataPropertyChanged();
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Gets or sets whether the hour numbers should be visible.
|
||||||
|
/// </summary>
|
||||||
|
[Category("Appearance")]
|
||||||
|
[Description("Should the hour numbers be visible?")]
|
||||||
|
[DefaultValue(true)]
|
||||||
|
public bool ShowHours
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
if (ViewState["ShowHours"] == null)
|
||||||
|
return true;
|
||||||
|
return (bool)ViewState["ShowHours"];
|
||||||
|
}
|
||||||
|
set
|
||||||
|
{
|
||||||
|
ViewState["ShowHours"] = value;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Gets or sets the time-format for hour numbers (on the left).
|
||||||
|
/// </summary>
|
||||||
|
[Category("Appearance")]
|
||||||
|
[Description("The time-format that will be used for the hour numbers.")]
|
||||||
|
[DefaultValue(TimeFormat.Clock12Hours)]
|
||||||
|
public TimeFormat TimeFormat
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
if (ViewState["TimeFormat"] == null)
|
||||||
|
return TimeFormat.Clock12Hours;
|
||||||
|
return (TimeFormat)ViewState["TimeFormat"];
|
||||||
|
}
|
||||||
|
set
|
||||||
|
{
|
||||||
|
ViewState["TimeFormat"] = value;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Gets or sets the drawing mode of non-business hours.
|
||||||
|
/// </summary>
|
||||||
|
[Category("Appearance")]
|
||||||
|
[Description("Determines whether the control shows the non-business hours.")]
|
||||||
|
[DefaultValue(NonBusinessHoursBehavior.HideIfPossible)]
|
||||||
|
public NonBusinessHoursBehavior NonBusinessHours
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
if (ViewState["NonBusinessHours"] == null)
|
||||||
|
return NonBusinessHoursBehavior.HideIfPossible;
|
||||||
|
return (NonBusinessHoursBehavior)ViewState["NonBusinessHours"];
|
||||||
|
}
|
||||||
|
set
|
||||||
|
{
|
||||||
|
ViewState["NonBusinessHours"] = value;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Handling of user action (clicking an event).
|
||||||
|
/// </summary>
|
||||||
|
[Category("User actions")]
|
||||||
|
[Description("Whether clicking an event should do a postback or run a javascript action. By default, it calls the javascript code specified in EventClickJavaScript property.")]
|
||||||
|
[DefaultValue(UserActionHandling.JavaScript)]
|
||||||
|
public UserActionHandling EventClickHandling
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
if (ViewState["EventClickHandling"] == null)
|
||||||
|
return UserActionHandling.JavaScript;
|
||||||
|
return (UserActionHandling)ViewState["EventClickHandling"];
|
||||||
|
}
|
||||||
|
set
|
||||||
|
{
|
||||||
|
ViewState["EventClickHandling"] = value;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Handling of user action (clicking a free-time slot).
|
||||||
|
/// </summary>
|
||||||
|
[Category("User actions")]
|
||||||
|
[Description("Whether clicking a free-time slot should do a postback or run a javascript action. By default, it calls the javascript code specified in FreeTimeClickJavaScript property.")]
|
||||||
|
[DefaultValue(UserActionHandling.JavaScript)]
|
||||||
|
public UserActionHandling FreetimeClickHandling
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
if (ViewState["FreeTimeClickHandling"] == null)
|
||||||
|
return UserActionHandling.JavaScript;
|
||||||
|
return (UserActionHandling)ViewState["FreeTimeClickHandling"];
|
||||||
|
}
|
||||||
|
set
|
||||||
|
{
|
||||||
|
ViewState["FreeTimeClickHandling"] = value;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
//headerDateFormat
|
||||||
|
/// <summary>
|
||||||
|
/// Gets or sets the format of the date display in the header columns.
|
||||||
|
/// </summary>
|
||||||
|
[Description("Format of the date display in the header columns.")]
|
||||||
|
[Category("Appearance")]
|
||||||
|
[DefaultValue("d")]
|
||||||
|
public string HeaderDateFormat
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
return headerDateFormat;
|
||||||
|
}
|
||||||
|
set
|
||||||
|
{
|
||||||
|
headerDateFormat = value;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Gets or sets whether the header should be visible.
|
||||||
|
/// </summary>
|
||||||
|
[Category("Appearance")]
|
||||||
|
[Description("Should the header be visible?")]
|
||||||
|
[DefaultValue(true)]
|
||||||
|
public bool ShowHeader
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
return showHeader;
|
||||||
|
}
|
||||||
|
set
|
||||||
|
{
|
||||||
|
showHeader = value;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Gets or sets whether the header should be visible.
|
||||||
|
/// </summary>
|
||||||
|
[Category("Layout")]
|
||||||
|
[Description("Header height in pixels.")]
|
||||||
|
[DefaultValue(21)]
|
||||||
|
public int HeaderHeight
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
return headerHeight;
|
||||||
|
}
|
||||||
|
set
|
||||||
|
{
|
||||||
|
headerHeight = value;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public override Color BackColor
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
if (ViewState["BackColor"] == null)
|
||||||
|
return ColorTranslator.FromHtml("#FFFFD5");
|
||||||
|
return (Color)ViewState["BackColor"];
|
||||||
|
}
|
||||||
|
set
|
||||||
|
{
|
||||||
|
ViewState["BackColor"] = value;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public override Color BorderColor
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
if (ViewState["BorderColor"] == null)
|
||||||
|
return ColorTranslator.FromHtml("#000000");
|
||||||
|
return (Color)ViewState["BorderColor"];
|
||||||
|
}
|
||||||
|
set
|
||||||
|
{
|
||||||
|
ViewState["BorderColor"] = value;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
[Category("Appearance")]
|
||||||
|
[TypeConverter(typeof(WebColorConverter))]
|
||||||
|
public Color HoverColor
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
if (ViewState["HoverColor"] == null)
|
||||||
|
return ColorTranslator.FromHtml("#FFED95");
|
||||||
|
return (Color)ViewState["HoverColor"];
|
||||||
|
|
||||||
|
}
|
||||||
|
set
|
||||||
|
{
|
||||||
|
ViewState["HoverColor"] = value;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
[Category("Appearance")]
|
||||||
|
[TypeConverter(typeof(WebColorConverter))]
|
||||||
|
public Color HourBorderColor
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
if (ViewState["HourBorderColor"] == null)
|
||||||
|
return ColorTranslator.FromHtml("#EAD098");
|
||||||
|
return (Color)ViewState["HourBorderColor"];
|
||||||
|
|
||||||
|
}
|
||||||
|
set
|
||||||
|
{
|
||||||
|
ViewState["HourBorderColor"] = value;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
[Category("Appearance")]
|
||||||
|
[TypeConverter(typeof(WebColorConverter))]
|
||||||
|
public Color HourHalfBorderColor
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
if (ViewState["HourHalfBorderColor"] == null)
|
||||||
|
return ColorTranslator.FromHtml("#F3E4B1");
|
||||||
|
return (Color)ViewState["HourHalfBorderColor"];
|
||||||
|
|
||||||
|
}
|
||||||
|
set
|
||||||
|
{
|
||||||
|
ViewState["HourHalfBorderColor"] = value;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
[Category("Appearance")]
|
||||||
|
[TypeConverter(typeof(WebColorConverter))]
|
||||||
|
public Color HourNameBorderColor
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
if (ViewState["HourNameBorderColor"] == null)
|
||||||
|
return ColorTranslator.FromHtml("#ACA899");
|
||||||
|
return (Color)ViewState["HourNameBorderColor"];
|
||||||
|
}
|
||||||
|
set
|
||||||
|
{
|
||||||
|
ViewState["HourNameBorderColor"] = value;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
[Category("Appearance")]
|
||||||
|
[TypeConverter(typeof(WebColorConverter))]
|
||||||
|
public Color HourNameBackColor
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
if (ViewState["HourNameBackColor"] == null)
|
||||||
|
return ColorTranslator.FromHtml("#ECE9D8");
|
||||||
|
return (Color)ViewState["HourNameBackColor"];
|
||||||
|
}
|
||||||
|
set
|
||||||
|
{
|
||||||
|
ViewState["HourNameBackColor"] = value;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
[Category("Appearance")]
|
||||||
|
[TypeConverter(typeof(WebColorConverter))]
|
||||||
|
public Color EventBackColor
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
if (ViewState["EventBackColor"] == null)
|
||||||
|
return ColorTranslator.FromHtml("#FFFFFF");
|
||||||
|
return (Color)ViewState["EventBackColor"];
|
||||||
|
}
|
||||||
|
set
|
||||||
|
{
|
||||||
|
ViewState["EventBackColor"] = value;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
[Category("Appearance")]
|
||||||
|
[TypeConverter(typeof(WebColorConverter))]
|
||||||
|
public Color EventHoverColor
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
if (ViewState["EventHoverColor"] == null)
|
||||||
|
return ColorTranslator.FromHtml("#DCDCDC");
|
||||||
|
return (Color)ViewState["EventHoverColor"];
|
||||||
|
}
|
||||||
|
set
|
||||||
|
{
|
||||||
|
ViewState["EventHoverColor"] = value;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
[Category("Appearance")]
|
||||||
|
[TypeConverter(typeof(WebColorConverter))]
|
||||||
|
public Color EventBorderColor
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
if (ViewState["EventBorderColor"] == null)
|
||||||
|
return ColorTranslator.FromHtml("#000000");
|
||||||
|
return (Color)ViewState["EventBorderColor"];
|
||||||
|
}
|
||||||
|
set
|
||||||
|
{
|
||||||
|
ViewState["EventBorderColor"] = value;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
[Category("Appearance")]
|
||||||
|
[TypeConverter(typeof(WebColorConverter))]
|
||||||
|
public Color DurationBarColor
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
if (ViewState["DurationBarColor"] == null)
|
||||||
|
return ColorTranslator.FromHtml("blue");
|
||||||
|
return (Color)ViewState["DurationBarColor"];
|
||||||
|
}
|
||||||
|
set
|
||||||
|
{
|
||||||
|
ViewState["DurationBarColor"] = value;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
[Category("Appearance")]
|
||||||
|
[TypeConverter(typeof(WebColorConverter))]
|
||||||
|
public Color NonBusinessBackColor
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
if (ViewState["NonBusinessBackColor"] == null)
|
||||||
|
return ColorTranslator.FromHtml("#FFF4BC");
|
||||||
|
|
||||||
|
return (Color)ViewState["NonBusinessBackColor"];
|
||||||
|
}
|
||||||
|
set
|
||||||
|
{
|
||||||
|
ViewState["NonBusinessBackColor"] = value;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
[Category("Appearance")]
|
||||||
|
public string EventFontFamily
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
if (ViewState["EventFontFamily"] == null)
|
||||||
|
return "Tahoma";
|
||||||
|
|
||||||
|
return (string)ViewState["EventFontFamily"];
|
||||||
|
}
|
||||||
|
set
|
||||||
|
{
|
||||||
|
ViewState["EventFontFamily"] = value;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
[Category("Appearance")]
|
||||||
|
public string HourFontFamily
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
if (ViewState["HourFontFamily"] == null)
|
||||||
|
return "Tahoma";
|
||||||
|
|
||||||
|
return (string)ViewState["HourFontFamily"];
|
||||||
|
}
|
||||||
|
set
|
||||||
|
{
|
||||||
|
ViewState["HourFontFamily"] = value;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
[Category("Appearance")]
|
||||||
|
public string DayFontFamily
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
if (ViewState["DayFontFamily"] == null)
|
||||||
|
return "Tahoma";
|
||||||
|
|
||||||
|
return (string)ViewState["DayFontFamily"];
|
||||||
|
}
|
||||||
|
set
|
||||||
|
{
|
||||||
|
ViewState["DayFontFamily"] = value;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
[Category("Appearance")]
|
||||||
|
public string EventFontSize
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
if (ViewState["EventFontSize"] == null)
|
||||||
|
return "8pt";
|
||||||
|
|
||||||
|
return (string)ViewState["EventFontSize"];
|
||||||
|
}
|
||||||
|
set
|
||||||
|
{
|
||||||
|
ViewState["EventFontSize"] = value;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
[Category("Appearance")]
|
||||||
|
public string HourFontSize
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
if (ViewState["HourFontSize"] == null)
|
||||||
|
return "16pt";
|
||||||
|
|
||||||
|
return (string)ViewState["HourFontSize"];
|
||||||
|
}
|
||||||
|
set
|
||||||
|
{
|
||||||
|
ViewState["HourFontSize"] = value;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
[Category("Appearance")]
|
||||||
|
public string DayFontSize
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
if (ViewState["DayFontSize"] == null)
|
||||||
|
return "10pt";
|
||||||
|
|
||||||
|
return (string)ViewState["DayFontSize"];
|
||||||
|
}
|
||||||
|
set
|
||||||
|
{
|
||||||
|
ViewState["DayFontSize"] = value;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Determines whether the event tooltip is active.
|
||||||
|
/// </summary>
|
||||||
|
[Description("Determines whether the event tooltip is active.")]
|
||||||
|
[Category("Appearance")]
|
||||||
|
[DefaultValue(true)]
|
||||||
|
public bool ShowToolTip
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
if (ViewState["ShowToolTip"] == null)
|
||||||
|
return true;
|
||||||
|
return (bool)ViewState["ShowToolTip"];
|
||||||
|
}
|
||||||
|
set
|
||||||
|
{
|
||||||
|
ViewState["ShowToolTip"] = value;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Width of the right margin inside a column (in pixels).
|
||||||
|
/// </summary>
|
||||||
|
[Description("Width of the right margin inside a column (in pixels).")]
|
||||||
|
[Category("Appearance")]
|
||||||
|
[DefaultValue(5)]
|
||||||
|
public int ColumnMarginRight
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
if (ViewState["ColumnMarginRight"] == null)
|
||||||
|
return 5;
|
||||||
|
return (int)ViewState["ColumnMarginRight"];
|
||||||
|
}
|
||||||
|
set
|
||||||
|
{
|
||||||
|
ViewState["ColumnMarginRight"] = value;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
1437
Web/Ui/DayPilotScheduler.cs
Normal file
1437
Web/Ui/DayPilotScheduler.cs
Normal file
File diff suppressed because it is too large
Load Diff
44
Web/Ui/Design/DayPilotCalendarDesigner.cs
Normal file
44
Web/Ui/Design/DayPilotCalendarDesigner.cs
Normal file
@@ -0,0 +1,44 @@
|
|||||||
|
/*
|
||||||
|
Copyright <20> 2005 - 2008 Annpoint, s.r.o.
|
||||||
|
|
||||||
|
Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
you may not use this file except in compliance with the License.
|
||||||
|
You may obtain a copy of the License at
|
||||||
|
|
||||||
|
http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
|
||||||
|
Unless required by applicable law or agreed to in writing, software
|
||||||
|
distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
See the License for the specific language governing permissions and
|
||||||
|
limitations under the License.
|
||||||
|
|
||||||
|
-------------------------------------------------------------------------
|
||||||
|
|
||||||
|
NOTE: Reuse requires the following acknowledgement (see also NOTICE):
|
||||||
|
This product includes DayPilot (http://www.daypilot.org) developed by Annpoint, s.r.o.
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
using System.Collections;
|
||||||
|
using System.Web.UI.Design.WebControls;
|
||||||
|
|
||||||
|
namespace DayPilot.Web.Ui.Design
|
||||||
|
{
|
||||||
|
public class DayPilotCalendarDesigner : DataBoundControlDesigner
|
||||||
|
{
|
||||||
|
protected override void PreFilterProperties(IDictionary properties)
|
||||||
|
{
|
||||||
|
base.PreFilterProperties(properties);
|
||||||
|
|
||||||
|
properties.Remove("Height");
|
||||||
|
properties.Remove("BorderStyle");
|
||||||
|
properties.Remove("BorderWidth");
|
||||||
|
properties.Remove("CssClass");
|
||||||
|
properties.Remove("Font");
|
||||||
|
properties.Remove("ForeColor");
|
||||||
|
properties.Remove("ToolTip");
|
||||||
|
properties.Remove("EndDate");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
55
Web/Ui/Enums/GroupByEnum.cs
Normal file
55
Web/Ui/Enums/GroupByEnum.cs
Normal file
@@ -0,0 +1,55 @@
|
|||||||
|
/*
|
||||||
|
Copyright <20> 2005 - 2008 Annpoint, s.r.o.
|
||||||
|
|
||||||
|
Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
you may not use this file except in compliance with the License.
|
||||||
|
You may obtain a copy of the License at
|
||||||
|
|
||||||
|
http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
|
||||||
|
Unless required by applicable law or agreed to in writing, software
|
||||||
|
distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
See the License for the specific language governing permissions and
|
||||||
|
limitations under the License.
|
||||||
|
|
||||||
|
-------------------------------------------------------------------------
|
||||||
|
|
||||||
|
NOTE: Reuse requires the following acknowledgement (see also NOTICE):
|
||||||
|
This product includes DayPilot (http://www.daypilot.org) developed by Annpoint, s.r.o.
|
||||||
|
*/
|
||||||
|
|
||||||
|
namespace DayPilot.Web.Ui.Enums
|
||||||
|
{
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Header grouping units.
|
||||||
|
/// </summary>
|
||||||
|
public enum GroupByEnum
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Grouped by hour.
|
||||||
|
/// </summary>
|
||||||
|
Hour,
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Grouped by day.
|
||||||
|
/// </summary>
|
||||||
|
Day,
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Grouped by week.
|
||||||
|
/// </summary>
|
||||||
|
Week,
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Grouped by month.
|
||||||
|
/// </summary>
|
||||||
|
Month,
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// No grouping.
|
||||||
|
/// </summary>
|
||||||
|
None
|
||||||
|
}
|
||||||
|
}
|
||||||
142
Web/Ui/Event.cs
Normal file
142
Web/Ui/Event.cs
Normal file
@@ -0,0 +1,142 @@
|
|||||||
|
/*
|
||||||
|
Copyright <20> 2005 - 2008 Annpoint, s.r.o.
|
||||||
|
|
||||||
|
Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
you may not use this file except in compliance with the License.
|
||||||
|
You may obtain a copy of the License at
|
||||||
|
|
||||||
|
http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
|
||||||
|
Unless required by applicable law or agreed to in writing, software
|
||||||
|
distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
See the License for the specific language governing permissions and
|
||||||
|
limitations under the License.
|
||||||
|
|
||||||
|
-------------------------------------------------------------------------
|
||||||
|
|
||||||
|
NOTE: Reuse requires the following acknowledgement (see also NOTICE):
|
||||||
|
This product includes DayPilot (http://www.daypilot.org) developed by Annpoint, s.r.o.
|
||||||
|
*/
|
||||||
|
|
||||||
|
using System;
|
||||||
|
|
||||||
|
namespace DayPilot.Web.Ui
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Summary description for Event.
|
||||||
|
/// </summary>
|
||||||
|
[Serializable]
|
||||||
|
public class Event
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Event start.
|
||||||
|
/// </summary>
|
||||||
|
public DateTime Start;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Event end;
|
||||||
|
/// </summary>
|
||||||
|
public DateTime End;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Event name;
|
||||||
|
/// </summary>
|
||||||
|
public string Name;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Event primary key.
|
||||||
|
/// </summary>
|
||||||
|
public string PK;
|
||||||
|
|
||||||
|
public string Resource;
|
||||||
|
public string Owner;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Column to which this event belongs.
|
||||||
|
/// </summary>
|
||||||
|
[NonSerialized]
|
||||||
|
public Column Column;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Constructor.
|
||||||
|
/// </summary>
|
||||||
|
public Event()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Constructor that prefills the fields.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="pk"></param>
|
||||||
|
/// <param name="start"></param>
|
||||||
|
/// <param name="end"></param>
|
||||||
|
/// <param name="name"></param>
|
||||||
|
public Event(string pk, DateTime start, DateTime end, string name) : this(pk, start, end, name, null)
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public Event(string pk, DateTime start, DateTime end, string name, string resource): this(pk, start, end, name, resource, null)
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
public Event(string pk, DateTime start, DateTime end, string name, string resource, string owner)
|
||||||
|
{
|
||||||
|
this.PK = pk;
|
||||||
|
this.Start = start;
|
||||||
|
this.End = end;
|
||||||
|
this.Name = name;
|
||||||
|
this.Resource = resource;
|
||||||
|
this.Owner = owner;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Gets the starting time of an event box.
|
||||||
|
/// </summary>
|
||||||
|
public DateTime BoxStart
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
if (Start.Minute >= 30)
|
||||||
|
return new DateTime(Start.Year, Start.Month, Start.Day, Start.Hour, 30, 0);
|
||||||
|
else
|
||||||
|
return new DateTime(Start.Year, Start.Month, Start.Day, Start.Hour, 0, 0);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Gets the ending time of an event box.
|
||||||
|
/// </summary>
|
||||||
|
public DateTime BoxEnd
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
if (End.Minute > 30)
|
||||||
|
{
|
||||||
|
DateTime hourPlus = End.AddHours(1);
|
||||||
|
return new DateTime(hourPlus.Year, hourPlus.Month, hourPlus.Day, hourPlus.Hour, 0, 0);
|
||||||
|
}
|
||||||
|
else if (End.Minute > 0)
|
||||||
|
{
|
||||||
|
return new DateTime(End.Year, End.Month, End.Day, End.Hour, 30, 0);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
return new DateTime(End.Year, End.Month, End.Day, End.Hour, 0, 0);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Returns true if this box overlaps with e's box.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="e"></param>
|
||||||
|
/// <returns></returns>
|
||||||
|
public bool OverlapsWith(Event e)
|
||||||
|
{
|
||||||
|
return (this.BoxStart < e.BoxEnd && this.BoxEnd > e.Start);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
52
Web/Ui/EventComparer.cs
Normal file
52
Web/Ui/EventComparer.cs
Normal file
@@ -0,0 +1,52 @@
|
|||||||
|
/*
|
||||||
|
Copyright <20> 2005 - 2008 Annpoint, s.r.o.
|
||||||
|
|
||||||
|
Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
you may not use this file except in compliance with the License.
|
||||||
|
You may obtain a copy of the License at
|
||||||
|
|
||||||
|
http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
|
||||||
|
Unless required by applicable law or agreed to in writing, software
|
||||||
|
distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
See the License for the specific language governing permissions and
|
||||||
|
limitations under the License.
|
||||||
|
|
||||||
|
-------------------------------------------------------------------------
|
||||||
|
|
||||||
|
NOTE: Reuse requires the following acknowledgement (see also NOTICE):
|
||||||
|
This product includes DayPilot (http://www.daypilot.org) developed by Annpoint, s.r.o.
|
||||||
|
*/
|
||||||
|
|
||||||
|
using System.Collections;
|
||||||
|
|
||||||
|
namespace DayPilot.Web.Ui
|
||||||
|
{
|
||||||
|
public class EventComparer : IComparer
|
||||||
|
{
|
||||||
|
|
||||||
|
// Calls CaseInsensitiveComparer.Compare with the parameters reversed.
|
||||||
|
public int Compare(object x, object y)
|
||||||
|
{
|
||||||
|
Event first = (Event) x;
|
||||||
|
Event second = (Event) y;
|
||||||
|
|
||||||
|
if (first.Start < second.Start)
|
||||||
|
{
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (first.Start > second.Start)
|
||||||
|
{
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (first.End > second.End)
|
||||||
|
return -1;
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
80
Web/Ui/EventDelegates.cs
Normal file
80
Web/Ui/EventDelegates.cs
Normal file
@@ -0,0 +1,80 @@
|
|||||||
|
/*
|
||||||
|
Copyright <20> 2005 - 2008 Annpoint, s.r.o.
|
||||||
|
|
||||||
|
Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
you may not use this file except in compliance with the License.
|
||||||
|
You may obtain a copy of the License at
|
||||||
|
|
||||||
|
http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
|
||||||
|
Unless required by applicable law or agreed to in writing, software
|
||||||
|
distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
See the License for the specific language governing permissions and
|
||||||
|
limitations under the License.
|
||||||
|
|
||||||
|
-------------------------------------------------------------------------
|
||||||
|
|
||||||
|
NOTE: Reuse requires the following acknowledgement (see also NOTICE):
|
||||||
|
This product includes DayPilot (http://www.daypilot.org) developed by Annpoint, s.r.o.
|
||||||
|
*/
|
||||||
|
|
||||||
|
using System;
|
||||||
|
|
||||||
|
namespace DayPilot.Web.Ui
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Delegate for passing an event primary key.
|
||||||
|
/// </summary>
|
||||||
|
public delegate void EventClickDelegate(object sender, EventClickEventArgs e);
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Delegate for passing a starting time.
|
||||||
|
/// </summary>
|
||||||
|
public delegate void FreeClickDelegate(object sender, FreeClickEventArgs e);
|
||||||
|
|
||||||
|
|
||||||
|
public class EventClickEventArgs : EventArgs
|
||||||
|
{
|
||||||
|
private string value;
|
||||||
|
|
||||||
|
public string Value
|
||||||
|
{
|
||||||
|
get { return value; }
|
||||||
|
}
|
||||||
|
|
||||||
|
public EventClickEventArgs(string value)
|
||||||
|
{
|
||||||
|
this.value = value;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public class FreeClickEventArgs : EventArgs
|
||||||
|
{
|
||||||
|
private DateTime start;
|
||||||
|
private string resource;
|
||||||
|
|
||||||
|
|
||||||
|
public DateTime Start
|
||||||
|
{
|
||||||
|
get { return start; }
|
||||||
|
}
|
||||||
|
|
||||||
|
public string Resource
|
||||||
|
{
|
||||||
|
get { return resource; }
|
||||||
|
}
|
||||||
|
|
||||||
|
public FreeClickEventArgs(DateTime start)
|
||||||
|
{
|
||||||
|
this.start = start;
|
||||||
|
}
|
||||||
|
|
||||||
|
public FreeClickEventArgs(DateTime start, string resource)
|
||||||
|
{
|
||||||
|
this.start = start;
|
||||||
|
this.resource = resource;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
45
Web/Ui/NonBusinessHoursBehavior.cs
Normal file
45
Web/Ui/NonBusinessHoursBehavior.cs
Normal file
@@ -0,0 +1,45 @@
|
|||||||
|
/*
|
||||||
|
Copyright <20> 2005 - 2008 Annpoint, s.r.o.
|
||||||
|
|
||||||
|
Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
you may not use this file except in compliance with the License.
|
||||||
|
You may obtain a copy of the License at
|
||||||
|
|
||||||
|
http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
|
||||||
|
Unless required by applicable law or agreed to in writing, software
|
||||||
|
distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
See the License for the specific language governing permissions and
|
||||||
|
limitations under the License.
|
||||||
|
|
||||||
|
-------------------------------------------------------------------------
|
||||||
|
|
||||||
|
NOTE: Reuse requires the following acknowledgement (see also NOTICE):
|
||||||
|
This product includes DayPilot (http://www.daypilot.org) developed by Annpoint, s.r.o.
|
||||||
|
*/
|
||||||
|
|
||||||
|
namespace DayPilot.Web.Ui
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Behavior of the non-business hours.
|
||||||
|
/// </summary>
|
||||||
|
public enum NonBusinessHoursBehavior
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Hides the non-business hours if there is no event in that time.
|
||||||
|
/// </summary>
|
||||||
|
HideIfPossible,
|
||||||
|
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Always hides the non-business hours.
|
||||||
|
/// </summary>
|
||||||
|
Hide,
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Always shows the non-business hours.
|
||||||
|
/// </summary>
|
||||||
|
Show
|
||||||
|
}
|
||||||
|
}
|
||||||
87
Web/Ui/Resource.cs
Normal file
87
Web/Ui/Resource.cs
Normal file
@@ -0,0 +1,87 @@
|
|||||||
|
/*
|
||||||
|
Copyright <20> 2005 - 2008 Annpoint, s.r.o.
|
||||||
|
|
||||||
|
Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
you may not use this file except in compliance with the License.
|
||||||
|
You may obtain a copy of the License at
|
||||||
|
|
||||||
|
http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
|
||||||
|
Unless required by applicable law or agreed to in writing, software
|
||||||
|
distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
See the License for the specific language governing permissions and
|
||||||
|
limitations under the License.
|
||||||
|
|
||||||
|
-------------------------------------------------------------------------
|
||||||
|
|
||||||
|
NOTE: Reuse requires the following acknowledgement (see also NOTICE):
|
||||||
|
This product includes DayPilot (http://www.daypilot.org) developed by Annpoint, s.r.o.
|
||||||
|
*/
|
||||||
|
|
||||||
|
using System;
|
||||||
|
|
||||||
|
namespace DayPilot.Web.Ui
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Class representing a resource <see cref="DayPilotScheduler">DayPilotScheduler</see>.
|
||||||
|
/// </summary>
|
||||||
|
[Serializable]
|
||||||
|
public class Resource
|
||||||
|
{
|
||||||
|
private string val;
|
||||||
|
private string name;
|
||||||
|
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Default constructor.
|
||||||
|
/// </summary>
|
||||||
|
public Resource()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Constructor that sets the default values.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="name">Row name (visible).</param>
|
||||||
|
/// <param name="val">Row value (id).</param>
|
||||||
|
public Resource(string name, string val)
|
||||||
|
{
|
||||||
|
this.name = name;
|
||||||
|
this.val = val;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Row value (id).
|
||||||
|
/// </summary>
|
||||||
|
public string Value
|
||||||
|
{
|
||||||
|
get { return val; }
|
||||||
|
set { val = value; }
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Get or set the row name (<see cref="Resource.Name">Row.Name</see>).
|
||||||
|
/// </summary>
|
||||||
|
public string Name
|
||||||
|
{
|
||||||
|
get { return name; }
|
||||||
|
set { name = value; }
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
///<summary>
|
||||||
|
///Returns a <see cref="T:System.String"></see> that represents the current <see cref="T:System.Object"></see>.
|
||||||
|
///</summary>
|
||||||
|
///
|
||||||
|
///<returns>
|
||||||
|
///A <see cref="T:System.String"></see> that represents the current <see cref="T:System.Object"></see>.
|
||||||
|
///</returns>
|
||||||
|
///<filterpriority>2</filterpriority>
|
||||||
|
public override string ToString()
|
||||||
|
{
|
||||||
|
return Name;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
155
Web/Ui/ResourceCollection.cs
Normal file
155
Web/Ui/ResourceCollection.cs
Normal file
@@ -0,0 +1,155 @@
|
|||||||
|
/*
|
||||||
|
Copyright <20> 2005 - 2008 Annpoint, s.r.o.
|
||||||
|
|
||||||
|
Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
you may not use this file except in compliance with the License.
|
||||||
|
You may obtain a copy of the License at
|
||||||
|
|
||||||
|
http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
|
||||||
|
Unless required by applicable law or agreed to in writing, software
|
||||||
|
distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
See the License for the specific language governing permissions and
|
||||||
|
limitations under the License.
|
||||||
|
|
||||||
|
-------------------------------------------------------------------------
|
||||||
|
|
||||||
|
NOTE: Reuse requires the following acknowledgement (see also NOTICE):
|
||||||
|
This product includes DayPilot (http://www.daypilot.org) developed by Annpoint, s.r.o.
|
||||||
|
*/
|
||||||
|
|
||||||
|
using System.Collections;
|
||||||
|
using System.ComponentModel;
|
||||||
|
using DayPilot.Web.Ui.Serialization;
|
||||||
|
|
||||||
|
namespace DayPilot.Web.Ui
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Collection of resources definitions.
|
||||||
|
/// </summary>
|
||||||
|
|
||||||
|
[TypeConverter(typeof(ResourceCollectionConverter))]
|
||||||
|
public class ResourceCollection : CollectionBase
|
||||||
|
{
|
||||||
|
internal bool designMode;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Gets the specified <see cref="Resource">Resource</see>.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="index">Item index</param>
|
||||||
|
/// <returns>Resource at the specified position.</returns>
|
||||||
|
public Resource this[int index]
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
return ((Resource)List[index]);
|
||||||
|
}
|
||||||
|
set
|
||||||
|
{
|
||||||
|
List[index] = value;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Converts ResourceCollection to ArrayList.
|
||||||
|
/// </summary>
|
||||||
|
/// <returns>ArrayList with ResourceCollection items.</returns>
|
||||||
|
public ArrayList ToArrayList()
|
||||||
|
{
|
||||||
|
ArrayList retArray = new ArrayList();
|
||||||
|
for (int i = 0; i < this.Count; i++)
|
||||||
|
{
|
||||||
|
retArray.Add(this[i]);
|
||||||
|
}
|
||||||
|
|
||||||
|
return retArray;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Adds a new <see cref="Resource">Resource</see> to the collection.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="value">Resource to be added.</param>
|
||||||
|
/// <returns></returns>
|
||||||
|
public int Add(Resource value)
|
||||||
|
{
|
||||||
|
return (List.Add(value));
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Adds a new <see cref="Resource">Resource</see> to the collection.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="name">Resource name</param>
|
||||||
|
/// <param name="id">Resource id</param>
|
||||||
|
/// <returns></returns>
|
||||||
|
public int Add(string name, string id)
|
||||||
|
{
|
||||||
|
return Add(new Resource(name, id));
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Determines the index of a specific item in the collection.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="value"></param>
|
||||||
|
/// <returns></returns>
|
||||||
|
public int IndexOf(Resource value)
|
||||||
|
{
|
||||||
|
return (List.IndexOf(value));
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Inserts a new resource at the specified position.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="index">New resource position.</param>
|
||||||
|
/// <param name="value">Resource to be added.</param>
|
||||||
|
public void Insert(int index, Resource value)
|
||||||
|
{
|
||||||
|
List.Insert(index, value);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Removes a Resource from the collection.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="value">Resource to be removed.</param>
|
||||||
|
public void Remove(Resource value)
|
||||||
|
{
|
||||||
|
List.Remove(value);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Determines whether the collection contains a specified resource.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="value">Resource to be found.</param>
|
||||||
|
/// <returns>True if the collection contains the resource</returns>
|
||||||
|
public bool Contains(Resource value)
|
||||||
|
{
|
||||||
|
return (List.Contains(value));
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Creates a new collection from an ArrayList.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="items">ArrayList that contains the new resources.</param>
|
||||||
|
public ResourceCollection(ArrayList items)
|
||||||
|
: base()
|
||||||
|
{
|
||||||
|
for (int i = 0; i < items.Count; i++)
|
||||||
|
{
|
||||||
|
if (items[i] is Resource)
|
||||||
|
{
|
||||||
|
this.Add((Resource)items[i]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Creates a new ResourceCollection.
|
||||||
|
/// </summary>
|
||||||
|
public ResourceCollection()
|
||||||
|
: base()
|
||||||
|
{ }
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
136
Web/Ui/Serialization/ResourceCollectionConverter.cs
Normal file
136
Web/Ui/Serialization/ResourceCollectionConverter.cs
Normal file
@@ -0,0 +1,136 @@
|
|||||||
|
/*
|
||||||
|
Copyright <20> 2005 - 2008 Annpoint, s.r.o.
|
||||||
|
|
||||||
|
Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
you may not use this file except in compliance with the License.
|
||||||
|
You may obtain a copy of the License at
|
||||||
|
|
||||||
|
http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
|
||||||
|
Unless required by applicable law or agreed to in writing, software
|
||||||
|
distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
See the License for the specific language governing permissions and
|
||||||
|
limitations under the License.
|
||||||
|
|
||||||
|
-------------------------------------------------------------------------
|
||||||
|
|
||||||
|
NOTE: Reuse requires the following acknowledgement (see also NOTICE):
|
||||||
|
This product includes DayPilot (http://www.daypilot.org) developed by Annpoint, s.r.o.
|
||||||
|
*/
|
||||||
|
|
||||||
|
using System;
|
||||||
|
using System.Collections;
|
||||||
|
using System.ComponentModel;
|
||||||
|
using Encoder=DayPilot.Utils.Encoder;
|
||||||
|
|
||||||
|
namespace DayPilot.Web.Ui.Serialization
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Internal class for serializing ResourceCollection (ViewState).
|
||||||
|
/// </summary>
|
||||||
|
public class ResourceCollectionConverter : TypeConverter
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
///
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="context"></param>
|
||||||
|
/// <param name="sourceType"></param>
|
||||||
|
/// <returns></returns>
|
||||||
|
public override bool CanConvertFrom(ITypeDescriptorContext context, Type sourceType)
|
||||||
|
{
|
||||||
|
if (sourceType == typeof(String))
|
||||||
|
return true;
|
||||||
|
return base.CanConvertFrom(context, sourceType);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
///
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="context"></param>
|
||||||
|
/// <param name="destinationType"></param>
|
||||||
|
/// <returns></returns>
|
||||||
|
public override bool CanConvertTo(ITypeDescriptorContext context, Type destinationType)
|
||||||
|
{
|
||||||
|
if (destinationType == typeof(String))
|
||||||
|
return true;
|
||||||
|
return base.CanConvertTo(context, destinationType);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
///
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="context"></param>
|
||||||
|
/// <param name="culture"></param>
|
||||||
|
/// <param name="value"></param>
|
||||||
|
/// <returns></returns>
|
||||||
|
public override object ConvertFrom(ITypeDescriptorContext context, System.Globalization.CultureInfo culture, object value)
|
||||||
|
{
|
||||||
|
String state = value as String;
|
||||||
|
if (state == null)
|
||||||
|
{
|
||||||
|
return base.ConvertFrom(context, culture, value);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (state == String.Empty)
|
||||||
|
{
|
||||||
|
return new ResourceCollection();
|
||||||
|
}
|
||||||
|
|
||||||
|
String[] parts = state.Split('&');
|
||||||
|
|
||||||
|
ResourceCollection collection = new ResourceCollection();
|
||||||
|
foreach (string encRes in parts)
|
||||||
|
{
|
||||||
|
string[] props = Encoder.UrlDecode(encRes).Split('&');
|
||||||
|
|
||||||
|
Resource r = new Resource();
|
||||||
|
r.Name = Encoder.UrlDecode(props[0]);
|
||||||
|
r.Value = Encoder.UrlDecode(props[1]);
|
||||||
|
|
||||||
|
collection.Add(r);
|
||||||
|
}
|
||||||
|
|
||||||
|
return collection;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
///
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="context"></param>
|
||||||
|
/// <param name="culture"></param>
|
||||||
|
/// <param name="value"></param>
|
||||||
|
/// <param name="destinationType"></param>
|
||||||
|
/// <returns></returns>
|
||||||
|
public override object ConvertTo(ITypeDescriptorContext context, System.Globalization.CultureInfo culture, object value, Type destinationType)
|
||||||
|
{
|
||||||
|
if (destinationType == null)
|
||||||
|
throw new ArgumentException("destinationType");
|
||||||
|
ResourceCollection collection = value as ResourceCollection;
|
||||||
|
|
||||||
|
if (collection == null)
|
||||||
|
{
|
||||||
|
return base.ConvertTo(context, culture, value, destinationType);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
if (collection.designMode)
|
||||||
|
{
|
||||||
|
return "(Collection)";
|
||||||
|
}
|
||||||
|
|
||||||
|
ArrayList al = new ArrayList();
|
||||||
|
|
||||||
|
foreach (Resource r in collection)
|
||||||
|
{
|
||||||
|
ArrayList properties = new ArrayList();
|
||||||
|
properties.Add(r.Name);
|
||||||
|
properties.Add(r.Value);
|
||||||
|
|
||||||
|
al.Add(Encoder.UrlEncode(properties));
|
||||||
|
}
|
||||||
|
|
||||||
|
return Encoder.UrlEncode(al);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
39
Web/Ui/TimeFormat.cs
Normal file
39
Web/Ui/TimeFormat.cs
Normal file
@@ -0,0 +1,39 @@
|
|||||||
|
/*
|
||||||
|
Copyright <20> 2005 - 2008 Annpoint, s.r.o.
|
||||||
|
|
||||||
|
Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
you may not use this file except in compliance with the License.
|
||||||
|
You may obtain a copy of the License at
|
||||||
|
|
||||||
|
http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
|
||||||
|
Unless required by applicable law or agreed to in writing, software
|
||||||
|
distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
See the License for the specific language governing permissions and
|
||||||
|
limitations under the License.
|
||||||
|
|
||||||
|
-------------------------------------------------------------------------
|
||||||
|
|
||||||
|
NOTE: Reuse requires the following acknowledgement (see also NOTICE):
|
||||||
|
This product includes DayPilot (http://www.daypilot.org) developed by Annpoint, s.r.o.
|
||||||
|
*/
|
||||||
|
|
||||||
|
namespace DayPilot.Web.Ui
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Options for the time format.
|
||||||
|
/// </summary>
|
||||||
|
public enum TimeFormat
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// 12-hours time format (e.g. 2 p.m.)
|
||||||
|
/// </summary>
|
||||||
|
Clock12Hours,
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 24-hours time format (e.g. 14:00)
|
||||||
|
/// </summary>
|
||||||
|
Clock24Hours
|
||||||
|
}
|
||||||
|
}
|
||||||
40
Web/Ui/UserActionHandling.cs
Normal file
40
Web/Ui/UserActionHandling.cs
Normal file
@@ -0,0 +1,40 @@
|
|||||||
|
/*
|
||||||
|
Copyright <20> 2005 - 2008 Annpoint, s.r.o.
|
||||||
|
|
||||||
|
Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
you may not use this file except in compliance with the License.
|
||||||
|
You may obtain a copy of the License at
|
||||||
|
|
||||||
|
http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
|
||||||
|
Unless required by applicable law or agreed to in writing, software
|
||||||
|
distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
See the License for the specific language governing permissions and
|
||||||
|
limitations under the License.
|
||||||
|
|
||||||
|
-------------------------------------------------------------------------
|
||||||
|
|
||||||
|
NOTE: Reuse requires the following acknowledgement (see also NOTICE):
|
||||||
|
This product includes DayPilot (http://www.daypilot.org) developed by Annpoint, s.r.o.
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
namespace DayPilot.Web.Ui
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Summary description for UserActionHandling.
|
||||||
|
/// </summary>
|
||||||
|
public enum UserActionHandling
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// It should run a JavaScript action.
|
||||||
|
/// </summary>
|
||||||
|
JavaScript,
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// It should call a PostBack.
|
||||||
|
/// </summary>
|
||||||
|
PostBack
|
||||||
|
}
|
||||||
|
}
|
||||||
10
app.config
Normal file
10
app.config
Normal file
@@ -0,0 +1,10 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8" ?>
|
||||||
|
<configuration>
|
||||||
|
<configSections>
|
||||||
|
</configSections>
|
||||||
|
<connectionStrings>
|
||||||
|
<add name="DayPilot.Properties.Settings.bookingsConnectionString"
|
||||||
|
connectionString="Data Source=.\SQLEXPRESS;AttachDbFilename=|DataDirectory|\bookings.mdf;Integrated Security=True;User Instance=True"
|
||||||
|
providerName="System.Data.SqlClient" />
|
||||||
|
</connectionStrings>
|
||||||
|
</configuration>
|
||||||
Reference in New Issue
Block a user