Commit f5edb7f9 authored by Viet Hoang's avatar Viet Hoang

Image coordinate picker2

parent 98fb82e6
......@@ -4,3 +4,5 @@ For more information, please visit the blogs:
* [Sync Media Folder Sitecore Processor](https://buoctrenmay.wordpress.com/2017/03/25/storing-sitecore-media-assets-on-the-file-system-and-how-to-get-synced-at-your-machine/)
* [Media Provider For Graysale](https://buoctrenmay.wordpress.com/2017/05/24/how-to-enable-grayscale-feature-on-sitecore-xp-8/)
* [Pre-population Item Version](https://buoctrenmay.wordpress.com/2017/05/27/pre-population-item-version-module-for-sitecore-development/)
* [How to inject the custom icons to Sitecore 8](https://buoctrenmay.wordpress.com/2017/06/17/how-to-inject-the-custom-icons-to-sitecore-8/)
* [How to get public URL of a media item inside Sitecore](https://buoctrenmay.wordpress.com/2017/07/08/how-to-get-public-url-of-a-media-item-inside-sitecore/)
\ No newline at end of file
This diff is collapsed.
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
// 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("Vhs.CustomIconsInjector")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("Vhs.CustomIconsInjector")]
[assembly: AssemblyCopyright("Copyright © viet.hoang.sitecore@gmail.com 2017")]
[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("e246265b-04e5-44a6-b542-ad92bb768aa0")]
// 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("1.0.0.0")]
[assembly: AssemblyFileVersion("1.0.0.0")]
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="12.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Import Project="..\packages\Microsoft.CodeDom.Providers.DotNetCompilerPlatform.1.0.0\build\Microsoft.CodeDom.Providers.DotNetCompilerPlatform.props" Condition="Exists('..\packages\Microsoft.CodeDom.Providers.DotNetCompilerPlatform.1.0.0\build\Microsoft.CodeDom.Providers.DotNetCompilerPlatform.props')" />
<Import Project="..\packages\Microsoft.Net.Compilers.1.0.0\build\Microsoft.Net.Compilers.props" Condition="Exists('..\packages\Microsoft.Net.Compilers.1.0.0\build\Microsoft.Net.Compilers.props')" />
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
<ProductVersion>
</ProductVersion>
<SchemaVersion>2.0</SchemaVersion>
<ProjectGuid>{6A952CC3-A869-4A2E-97B6-CBCEC9C23CF4}</ProjectGuid>
<ProjectTypeGuids>{349c5851-65df-11da-9384-00065b846f21};{fae04ec0-301f-11d3-bf4b-00c04f79efbc}</ProjectTypeGuids>
<OutputType>Library</OutputType>
<AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>Vhs.CustomIconsInjector</RootNamespace>
<AssemblyName>Vhs.CustomIconsInjector</AssemblyName>
<TargetFrameworkVersion>v4.6</TargetFrameworkVersion>
<UseIISExpress>true</UseIISExpress>
<IISExpressSSLPort />
<IISExpressAnonymousAuthentication />
<IISExpressWindowsAuthentication />
<IISExpressUseClassicPipelineMode />
<UseGlobalApplicationHostFile />
<NuGetPackageImportStamp>
</NuGetPackageImportStamp>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<DebugSymbols>true</DebugSymbols>
<DebugType>full</DebugType>
<Optimize>false</Optimize>
<OutputPath>bin\</OutputPath>
<DefineConstants>DEBUG;TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<DebugType>pdbonly</DebugType>
<Optimize>true</Optimize>
<OutputPath>bin\</OutputPath>
<DefineConstants>TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<ItemGroup>
<Reference Include="Microsoft.CodeDom.Providers.DotNetCompilerPlatform, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
<HintPath>..\packages\Microsoft.CodeDom.Providers.DotNetCompilerPlatform.1.0.0\lib\net45\Microsoft.CodeDom.Providers.DotNetCompilerPlatform.dll</HintPath>
<Private>True</Private>
</Reference>
<Reference Include="Microsoft.CSharp" />
<Reference Include="Microsoft.Synchronization, Version=2.1.0.0, Culture=neutral, PublicKeyToken=89845dcd8080cc91, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
<HintPath>..\lib\Microsoft Sync Framework\Microsoft.Synchronization.dll</HintPath>
</Reference>
<Reference Include="Microsoft.Synchronization.Files, Version=2.1.0.0, Culture=neutral, PublicKeyToken=89845dcd8080cc91, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
<HintPath>..\lib\Microsoft Sync Framework\Microsoft.Synchronization.Files.dll</HintPath>
</Reference>
<Reference Include="Sitecore.Kernel, Version=10.0.0.0, Culture=neutral, processorArchitecture=MSIL">
<HintPath>..\packages\Sitecore.Kernel.NoReferences.8.2.170407\lib\NET452\Sitecore.Kernel.dll</HintPath>
<Private>True</Private>
</Reference>
<Reference Include="System.Web.DynamicData" />
<Reference Include="System.Web.Entity" />
<Reference Include="System.Web.ApplicationServices" />
<Reference Include="System.ComponentModel.DataAnnotations" />
<Reference Include="System" />
<Reference Include="System.Data" />
<Reference Include="System.Core" />
<Reference Include="System.Data.DataSetExtensions" />
<Reference Include="System.Web.Extensions" />
<Reference Include="System.Xml.Linq" />
<Reference Include="System.Drawing" />
<Reference Include="System.Web" />
<Reference Include="System.Xml" />
<Reference Include="System.Configuration" />
<Reference Include="System.Web.Services" />
<Reference Include="System.EnterpriseServices" />
</ItemGroup>
<ItemGroup>
<Reference Include="System.Web.Razor">
<HintPath>..\packages\Microsoft.AspNet.Razor.3.2.3\lib\net45\System.Web.Razor.dll</HintPath>
</Reference>
<Reference Include="System.Web.Webpages">
<HintPath>..\packages\Microsoft.AspNet.Webpages.3.2.3\lib\net45\System.Web.Webpages.dll</HintPath>
</Reference>
<Reference Include="System.Web.Webpages.Deployment">
<HintPath>..\packages\Microsoft.AspNet.Webpages.3.2.3\lib\net45\System.Web.Webpages.Deployment.dll</HintPath>
</Reference>
<Reference Include="System.Web.Webpages.Razor">
<HintPath>..\packages\Microsoft.AspNet.Webpages.3.2.3\lib\net45\System.Web.Webpages.Razor.dll</HintPath>
</Reference>
<Reference Include="System.Web.Helpers">
<HintPath>..\packages\Microsoft.AspNet.Webpages.3.2.3\lib\net45\System.Web.Helpers.dll</HintPath>
</Reference>
<Reference Include="Microsoft.Web.Infrastructure">
<HintPath>..\packages\Microsoft.Web.Infrastructure.1.0.0.0\lib\net40\Microsoft.Web.Infrastructure.dll</HintPath>
</Reference>
<Reference Include="System.Web.Mvc">
<HintPath>..\packages\Microsoft.AspNet.Mvc.5.2.3\lib\net45\System.Web.Mvc.dll</HintPath>
</Reference>
</ItemGroup>
<ItemGroup>
<Content Include="sitecore\shell\Applications\Content Manager\Dialogs\Set Icon\Set Icon.xml">
<SubType>Designer</SubType>
</Content>
<None Include="Properties\PublishProfiles\Local.pubxml" />
<Content Include="sitecore\shell\Themes\Standard\Custom.zip" />
<None Include="Web.config" />
</ItemGroup>
<ItemGroup>
<Compile Include="Dialogs\SetIconForm.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
</ItemGroup>
<ItemGroup>
<None Include="packages.config" />
<None Include="Web.Debug.config">
<DependentUpon>Web.config</DependentUpon>
</None>
<None Include="Web.Release.config">
<DependentUpon>Web.config</DependentUpon>
</None>
</ItemGroup>
<ItemGroup />
<PropertyGroup>
<VisualStudioVersion Condition="'$(VisualStudioVersion)' == ''">10.0</VisualStudioVersion>
<VSToolsPath Condition="'$(VSToolsPath)' == ''">$(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion)</VSToolsPath>
</PropertyGroup>
<Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" />
<Import Project="$(VSToolsPath)\WebApplications\Microsoft.WebApplication.targets" Condition="'$(VSToolsPath)' != ''" />
<Import Project="$(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v10.0\WebApplications\Microsoft.WebApplication.targets" Condition="false" />
<ProjectExtensions>
<VisualStudio>
<FlavorProperties GUID="{349c5851-65df-11da-9384-00065b846f21}">
<WebProjectProperties>
<UseIIS>True</UseIIS>
<AutoAssignPort>True</AutoAssignPort>
<DevelopmentServerPort>9229</DevelopmentServerPort>
<DevelopmentServerVPath>/</DevelopmentServerVPath>
<IISUrl>http://localhost:9229/</IISUrl>
<NTLMAuthentication>False</NTLMAuthentication>
<UseCustomServer>False</UseCustomServer>
<CustomServerUrl>
</CustomServerUrl>
<SaveServerSettingsInUserFile>False</SaveServerSettingsInUserFile>
</WebProjectProperties>
</FlavorProperties>
</VisualStudio>
</ProjectExtensions>
<Target Name="EnsureNuGetPackageBuildImports" BeforeTargets="PrepareForBuild">
<PropertyGroup>
<ErrorText>This project references NuGet package(s) that are missing on this computer. Use NuGet Package Restore to download them. For more information, see http://go.microsoft.com/fwlink/?LinkID=322105. The missing file is {0}.</ErrorText>
</PropertyGroup>
<Error Condition="!Exists('..\packages\Microsoft.Net.Compilers.1.0.0\build\Microsoft.Net.Compilers.props')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\Microsoft.Net.Compilers.1.0.0\build\Microsoft.Net.Compilers.props'))" />
<Error Condition="!Exists('..\packages\Microsoft.CodeDom.Providers.DotNetCompilerPlatform.1.0.0\build\Microsoft.CodeDom.Providers.DotNetCompilerPlatform.props')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\Microsoft.CodeDom.Providers.DotNetCompilerPlatform.1.0.0\build\Microsoft.CodeDom.Providers.DotNetCompilerPlatform.props'))" />
</Target>
<!-- 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>
\ No newline at end of file
<?xml version="1.0" encoding="utf-8"?>
<!-- For more information on using web.config transformation visit http://go.microsoft.com/fwlink/?LinkId=125889 -->
<configuration xmlns:xdt="http://schemas.microsoft.com/XML-Document-Transform">
<!--
In the example below, the "SetAttributes" transform will change the value of
"connectionString" to use "ReleaseSQLServer" only when the "Match" locator
finds an attribute "name" that has a value of "MyDB".
<connectionStrings>
<add name="MyDB"
connectionString="Data Source=ReleaseSQLServer;Initial Catalog=MyReleaseDB;Integrated Security=True"
xdt:Transform="SetAttributes" xdt:Locator="Match(name)"/>
</connectionStrings>
-->
<system.web>
<!--
In the example below, the "Replace" transform will replace the entire
<customErrors> section of your web.config file.
Note that because there is only one customErrors section under the
<system.web> node, there is no need to use the "xdt:Locator" attribute.
<customErrors defaultRedirect="GenericError.htm"
mode="RemoteOnly" xdt:Transform="Replace">
<error statusCode="500" redirect="InternalError.htm"/>
</customErrors>
-->
</system.web>
</configuration>
\ No newline at end of file
<?xml version="1.0" encoding="utf-8"?>
<!-- For more information on using web.config transformation visit http://go.microsoft.com/fwlink/?LinkId=125889 -->
<configuration xmlns:xdt="http://schemas.microsoft.com/XML-Document-Transform">
<!--
In the example below, the "SetAttributes" transform will change the value of
"connectionString" to use "ReleaseSQLServer" only when the "Match" locator
finds an attribute "name" that has a value of "MyDB".
<connectionStrings>
<add name="MyDB"
connectionString="Data Source=ReleaseSQLServer;Initial Catalog=MyReleaseDB;Integrated Security=True"
xdt:Transform="SetAttributes" xdt:Locator="Match(name)"/>
</connectionStrings>
-->
<system.web>
<compilation xdt:Transform="RemoveAttributes(debug)" />
<!--
In the example below, the "Replace" transform will replace the entire
<customErrors> section of your web.config file.
Note that because there is only one customErrors section under the
<system.web> node, there is no need to use the "xdt:Locator" attribute.
<customErrors defaultRedirect="GenericError.htm"
mode="RemoteOnly" xdt:Transform="Replace">
<error statusCode="500" redirect="InternalError.htm"/>
</customErrors>
-->
</system.web>
</configuration>
\ No newline at end of file
<?xml version="1.0" encoding="utf-8"?>
<!--
For more information on how to configure your ASP.NET application, please visit
http://go.microsoft.com/fwlink/?LinkId=301880
-->
<configuration>
<appSettings>
<add key="webpages:Version" value="3.0.0.0"/>
<add key="webpages:Enabled" value="false"/>
<add key="ClientValidationEnabled" value="true"/>
<add key="UnobtrusiveJavaScriptEnabled" value="true"/>
</appSettings>
<system.web>
<compilation debug="true" targetFramework="4.6"/>
<httpRuntime targetFramework="4.6"/>
</system.web>
<runtime>
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
<dependentAssembly>
<assemblyIdentity name="System.Web.Helpers" publicKeyToken="31bf3856ad364e35"/>
<bindingRedirect oldVersion="1.0.0.0-3.0.0.0" newVersion="3.0.0.0"/>
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="System.Web.WebPages" publicKeyToken="31bf3856ad364e35"/>
<bindingRedirect oldVersion="1.0.0.0-3.0.0.0" newVersion="3.0.0.0"/>
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="System.Web.Mvc" publicKeyToken="31bf3856ad364e35"/>
<bindingRedirect oldVersion="1.0.0.0-5.2.3.0" newVersion="5.2.3.0"/>
</dependentAssembly>
</assemblyBinding>
</runtime>
<system.codedom>
<compilers>
<compiler language="c#;cs;csharp" extension=".cs"
type="Microsoft.CodeDom.Providers.DotNetCompilerPlatform.CSharpCodeProvider, Microsoft.CodeDom.Providers.DotNetCompilerPlatform, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"
warningLevel="4" compilerOptions="/langversion:6 /nowarn:1659;1699;1701"/>
<compiler language="vb;vbs;visualbasic;vbscript" extension=".vb"
type="Microsoft.CodeDom.Providers.DotNetCompilerPlatform.VBCodeProvider, Microsoft.CodeDom.Providers.DotNetCompilerPlatform, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"
warningLevel="4" compilerOptions="/langversion:14 /nowarn:41008 /define:_MYTYPE=\&quot;Web\&quot; /optionInfer+"/>
</compilers>
</system.codedom>
</configuration>
<?xml version="1.0" encoding="utf-8"?>
<packages>
<package id="Microsoft.AspNet.Mvc" version="5.2.3" targetFramework="net46" />
<package id="Microsoft.AspNet.Razor" version="3.2.3" targetFramework="net46" />
<package id="Microsoft.AspNet.WebPages" version="3.2.3" targetFramework="net46" />
<package id="Microsoft.CodeDom.Providers.DotNetCompilerPlatform" version="1.0.0" targetFramework="net46" />
<package id="Microsoft.Net.Compilers" version="1.0.0" targetFramework="net46" developmentDependency="true" />
<package id="Microsoft.Web.Infrastructure" version="1.0.0.0" targetFramework="net46" />
<package id="Sitecore.Kernel.NoReferences" version="8.2.170407" targetFramework="net46" developmentDependency="true" />
</packages>
\ No newline at end of file
<?xml version="1.0" encoding="utf-8" ?>
<control xmlns:def="Definition" xmlns="http://schemas.sitecore.net/Visual-Studio-Intellisense">
<SetIcon>
<FormDialog Header="Change Icon" Submittable="false" Text="Click the new icon that you want to assign to the selected item.">
<CodeBeside Type="Vhs.CustomIconsInjector.Dialogs.SetIconForm, Vhs.CustomIconsInjector"/>
<Script Src="/sitecore/shell/Applications/Content Manager/Dialogs/Set Icon/SetIcon.js" />
<Stylesheet>
#TabStrip {
padding-bottom: 50px;
}
.ie #RecentList {
width: 100% !important;
}
#tabcontent_Recent td {vertical-align:top;}
.scRecentIcon {
cursor: pointer;
margin: 5px 5px 5px 0;
}
#List {
position: absolute;
top: 65px;
bottom: 0;
left: 0;
right: 0;
overflow: auto;
padding: 10px 0 10px 5px;
}
#List > div {
border: 0 !important;
}
.iconFileName {
padding-top: 8px;
position: absolute;
bottom: 0;
left: 0;
right: 0;
}
</Stylesheet>
<div class="scStretch">
<VerticalTabstrip ID="TabStrip">
<Tab ID="Recent" Header="Recent">
<GridPanel Width="100%" Height="100%" Fixed="true">
<Scrollbox ID="RecentList" Class="scScrollbox scFixSize scFixSize8 scKeepFixSize" Height="100%" GridPanel.Height="100%" Border="none" Click="javascript:scClick(this,event)"/>
</GridPanel>
</Tab>
<Tab ID="Icons" Header="Icons">
<div class="scStretch">
<Border Padding="0 5px 15px 5px">
<Combobox ID="Selector" Change="javascript:scChange(this,event)">
<ListItem Header="Applications" Value="Applications"/>
<ListItem Header="ApplicationsV2" Value="ApplicationsV2"/>
<ListItem Header="Apps" Value="Apps"/>
<ListItem Header="CUSTOM" Value="Custom"/>
<ListItem Header="Business" Value="Business"/>
<ListItem Header="BusinessV2" Value="BusinessV2"/>
<ListItem Header="Controls" Value="Controls"/>
<ListItem Header="Core 1" Value="Core1" />
<ListItem Header="Core 2" Value="Core2"/>
<ListItem Header="Core 3" Value="Core3" />
<ListItem Header="Database" Value="Database"/>
<ListItem Header="Flags" Value="Flags"/>
<ListItem Header="FlagsV2" Value="FlagsV2"/>
<ListItem Header="Imaging" Value="Imaging"/>
<ListItem Header="Multimedia" Value="Multimedia"/>
<ListItem Header="Network" Value="Network" />"
<ListItem Header="NetworkV2" Value="NetworkV2" />
<ListItem Header="Office" Value="Office" />
<ListItem Header="Office White" Value="OfficeWhite" />
<ListItem Header="Other" Value="Other" />
<ListItem Header="People" Value="People" />
<ListItem Header="PeopleV2" Value="PeopleV2" />
<ListItem Header="Software" Value="Software" />
<ListItem Header="SoftwareV2" Value="SoftwareV2" />
<ListItem Header="Word Processing" Value="WordProcessing"/>
</Combobox>
</Border>
<Border Padding="0 5px" style="font-weight:600;">
<Literal Text="Icons:"/>
</Border>
<Border ID="List" Click="javascript:scClick(this,event)">
<Scrollbox ID="ApplicationsList" Border="none"/>
<Scrollbox ID="ApplicationsV2List" Visible="false"/>
<Scrollbox ID="AppsList" Visible="false"/>
<Scrollbox ID="CustomList" Visible="false"/>
<Scrollbox ID="BusinessList" Visible="false" />
<Scrollbox ID="BusinessV2List" Visible="false" />
<Scrollbox ID="ControlsList" Visible="false" />
<Scrollbox ID="Core1List" Visible="false" />
<Scrollbox ID="Core2List" Visible="false" />
<Scrollbox ID="Core3List" Visible="false" />
<Scrollbox ID="DatabaseList" Visible="false" />
<Scrollbox ID="FlagsList" Visible="false" />
<Scrollbox ID="FlagsV2List" Visible="false" />
<Scrollbox ID="ImagingList" Visible="false" />
<Scrollbox ID="MultimediaList" Visible="false" />
<Scrollbox ID="NetworkList" Visible="false" />
<Scrollbox ID="NetworkV2List" Visible="false" />
<Scrollbox ID="OfficeList" Visible="false" />
<Scrollbox ID="OfficeWhiteList" Visible="false" />
<Scrollbox ID="OtherList" Visible="false" />
<Scrollbox ID="PeopleList" Visible="false" />
<Scrollbox ID="PeopleV2List" Visible="false" />
<Scrollbox ID="SoftwareList" Visible="false" />
<Scrollbox ID="SoftwareV2List" Visible="false" />
<Scrollbox ID="WordProcessingList" Visible="false" />
</Border>
</div>
</Tab>
</VerticalTabstrip>
<GridPanel class="iconFileName scFormTable" Columns="2">
<Literal Text="Icon:"/>
<Edit ID="IconFile"/>
</GridPanel>
</div>
</FormDialog>
</SetIcon>
</control>
<configuration xmlns:patch="http://www.sitecore.net/xmlconfig/">
<sitecore>
<settings>
<setting name="Vhs.ImageCoordinatePickerField2.DialogWidth" value="800"/>
<setting name="Vhs.ImageCoordinatePickerField2.DialogHeight" value="600"/>
<setting name="Vhs.ImageCoordinatePickerField2.ImageFieldName" value="HeroImage|BannerImage"/>
<setting name="Vhs.ImageCoordinatePickerField2.ImageAlternateText"
value="There is NO image in the parent item."/>
</settings>
</sitecore>
</configuration>
\ No newline at end of file
namespace Vhs.ImageCoordinatePickerField2.Constants
{
public static class QueryStringKeys
{
public const string Value = "value";
public const string ContainerId = "containerId";
public const string Code = "code";
public const string View = "view";
}
}
\ No newline at end of file
using System;
using System.Web.UI.WebControls;
using SC = Sitecore;
using Sitecore.Configuration;
using Sitecore.Data;
using Sitecore.Resources.Media;
using Sitecore.Web;
using Sitecore.Web.UI.Pages;
using Sitecore.Web.UI.Sheer;
using Vhs.ImageCoordinatePickerField2.Constants;
using Vhs.ImageCoordinatePickerField2.Services;
using ImageField = Sitecore.Data.Fields.ImageField;
namespace Vhs.ImageCoordinatePickerField2.Dialogs
{
public class ImageCoordinatePickerDialog : DialogForm
{
private const string Separator = "|";
private readonly Database _masterDb = Factory.GetDatabase("master");
public SC.Web.UI.HtmlControls.Image ImageFrame;
public SC.Web.UI.HtmlControls.Edit TextBoxCoordinate;
protected override void OnLoad(EventArgs e)
{
base.OnLoad(e);
if (TextBoxCoordinate == null || ImageFrame == null) return;
TextBoxCoordinate.Value = WebUtil.GetQueryString(QueryStringKeys.Value);
var containerId = WebUtil.GetQueryString(QueryStringKeys.ContainerId);
var currentItem = _masterDb.Items.GetItem(containerId);
var parentItem = currentItem.Parent;
var imageFieldNames = ConfigurationService.ImageFieldName.Split(new[] { Separator },
StringSplitOptions.RemoveEmptyEntries);
ImageField imageField = null;
foreach (var imageFieldName in imageFieldNames)
{
imageField = parentItem.Fields[imageFieldName];
if (imageField != null) break;
}
if (imageField == null || string.IsNullOrWhiteSpace(imageField.Value))
{
ImageFrame.Alt = ConfigurationService.ImageAlternateText;
ImageFrame.Src = "#";
return;
}
ImageFrame.Width = new Unit(double.Parse(imageField.Width), UnitType.Pixel);
ImageFrame.Height = new Unit(double.Parse(imageField.Height), UnitType.Pixel);
var imageSrc = MediaManager.GetMediaUrl(
_masterDb.Items.GetItem(imageField.MediaID),
new MediaUrlOptions
{
Database = _masterDb,
DisableMediaCache = true,
DisableBrowserCache = true,
AllowStretch = false
});
if (!string.IsNullOrWhiteSpace(imageSrc))
{
imageSrc += "&usecustomfunctions=1&centercrop=1";
}
ImageFrame.Src = imageSrc;
}
protected override void OnOK(object sender, EventArgs args)
{
SheerResponse.SetDialogValue(this.TextBoxCoordinate.Value);
base.OnOK(sender, args);
}
}
}
\ No newline at end of file
using System.Collections.Specialized;
using Sitecore.Shell.Applications.ContentEditor;
using Sitecore.Web.UI.Sheer;
using Vhs.ImageCoordinatePickerField2.Constants;
using Vhs.ImageCoordinatePickerField2.Services;
using SC = Sitecore;
namespace Vhs.ImageCoordinatePickerField2.Fields
{
public class ImageCoordinatePickerField : Text, IContentField
{
public string GetValue()
{
return this.Value;
}
public void SetValue(string value)
{
this.Value = value;
}
public override void HandleMessage(Message message)
{
base.HandleMessage(message);
if (!message.Name.Equals("vhs:PickCoordinate2"))
return;
// manage to get the container id (Sitecore item id) of this field
// onFocus attribute's value will be like this
// javascript:return scContent.activate(this,event,'sitecore://master/{6DB97A83-480E-4F51-A9D5-B6C688C651B3}?lang=en&ver=1&fld={AA29FFC7-DEA0-4053-87A3-967C198AB652}&ctl=FIELD313682656')
// in this case, container id = 6DB97A83-480E-4F51-A9D5-B6C688C651B3
var onFocus = this.Attributes["onfocus"];
var containerId = onFocus.Split('?')[0].Split('{')[1].Replace("}", string.Empty);
SC.Context.ClientPage.Start(
this,
"PickCoordinate",
new NameValueCollection { { QueryStringKeys.ContainerId, containerId } });
}
protected void PickCoordinate(ClientPipelineArgs args)
{
if (args.IsPostBack)
{
if (args.HasResult && args.Result != this.Value)
{
this.SetModified();
this.SetValue(args.Result);
}
}
else
{
var uri = string.Format(
"{0}&{1}={2}&{3}={4}",
SC.UIUtil.GetUri("control:ImageCoordinatePickerDialog2"),
QueryStringKeys.Value,
this.GetValue(),
QueryStringKeys.ContainerId,
args.Parameters[QueryStringKeys.ContainerId]);
SheerResponse.ShowModalDialog(uri, ConfigurationService.DialogWidth, ConfigurationService.DialogHeight,
string.Empty, true);
args.WaitForPostBack();
}
}
}
}
\ No newline at end of file
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
// 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("Vhs.ImageCoordinatePicker")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("Vhs.ImageCoordinatePicker")]
[assembly: AssemblyCopyright("Copyright © viet.hoang.sitecore@gmail.com 2017")]
[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("f841033b-d175-434c-9c06-1e20278ed0b9")]
// 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("1.0.0.0")]
[assembly: AssemblyFileVersion("1.0.0.0")]
using SC = Sitecore;
namespace Vhs.ImageCoordinatePickerField2.Services
{