📄 selecttooltaskwebconfigurator.cs
字号:
}
gSelTask.RenderSelectedSet = ckbRenderSelectionSet.Checked;
gSelTask.SelectedSetColor = cpSelectionSetColor.ChosenColor;
gSelTask.FeatureSelectionColor = cpHighlightColor.ChosenColor;
OnWebConfigurationComplete(new WebConfigurationCompleteEventArgs(
gSelTask, getDesignTimeTag()));
}
protected override HtmlTextWriterTag TagKey
{
get
{
return HtmlTextWriterTag.Div;
}
}
protected override void OnPreRender(EventArgs e)
{
base.OnPreRender(e);
if (!Page.IsCallback)
{
// load current properties of control to edit
loadProperties();
}
}
private void loadProperties()
{
if (gSelTask == null)
return;
dialogTitle.Text = gSelTask.Title;
txtSelectionTolerance.Text = gSelTask.PointSelectionTolerance.ToString();
ckbHidePreviousSelections.Checked = gSelTask.HidePreviousSelections;
// set selectable layers, if set in the task
if (String.IsNullOrEmpty(gSelTask.SelectionLayerNames))
{
rbnAllowAllLayers.Checked = true;
//lstAvailableLayers.Enabled = false;
lstAvailableLayers.Attributes["disabled"] = "disabled";
foreach (ListItem item in lstAvailableLayers.Items)
item.Selected = false;
}
else
{
rbnSpecifyAvailableLayers.Checked = true;
string[] layerNameArray =
gSelTask.SelectionLayerNames.Split(new string[] { "::" }, StringSplitOptions.None);
foreach (string lyr in layerNameArray)
foreach (ListItem item in lstAvailableLayers.Items)
if (item.Text == lyr)
{
item.Selected = true;
break;
}
}
ckbRenderSelectionSet.Checked = gSelTask.RenderSelectedSet;
cpSelectionSetColor.ChosenColor = gSelTask.SelectedSetColor;
cpHighlightColor.ChosenColor = gSelTask.FeatureSelectionColor;
// add click handler to enable/disable layer list if specify-layer radio button is clicked
rbnSpecifyAvailableLayers.Attributes.Add("onClick",
String.Format("var selList=document.getElementById(\"{0}\");selList.disabled=false;",
lstAvailableLayers.ClientID));
rbnAllowAllLayers.Attributes.Add("onClick",
String.Format("var selList=document.getElementById(\"{0}\");selList.disabled=true;",
lstAvailableLayers.ClientID));
}
public override void Refresh()
{
loadProperties();
base.Refresh();
}
#endregion
#region getDesignTimeTag - enables Manager to write out settings to the web application page
private string getDesignTimeTag()
{
StringBuilder sbTag = new StringBuilder();
sbTag.Append("<selectToolTask:SelectToolTask runat=\"server\"");
AddTagProperty(sbTag, "ID", gSelTask.ID);
sbTag.Append(" bordercolor=\"LightSteelBlue\" borderstyle=\"Outset\"");
sbTag.Append(" borderwidth=\"1px\" font-names=\"Verdana\"");
sbTag.Append(" font-size=\"8pt\" forecolor=\"Black\" titlebarcolor=\"WhiteSmoke\"");
sbTag.Append(" Style=\"z-index: 10000; left: 500px; position: absolute; top: 500px\" ");
sbTag.Append(" Width=\"200px\" Visible=\"False\" BackColor=\"White\"");
AddTagProperty(sbTag, "Title", gSelTask.Title);
AddTagProperty(sbTag, "PointSelectionTolerance", gSelTask.PointSelectionTolerance.ToString());
AddTagProperty(sbTag, "HidePreviousSelections", gSelTask.HidePreviousSelections.ToString());
AddTagProperty(sbTag, "SelectionLayerNames", gSelTask.SelectionLayerNames);
AddTagProperty(sbTag, "RenderSelectedSet", gSelTask.RenderSelectedSet.ToString());
AddTagProperty(sbTag, "SelectedSetColor", ToHtmlColor(gSelTask.SelectedSetColor));
AddTagProperty(sbTag, "FeatureSelectionColor", ToHtmlColor(gSelTask.FeatureSelectionColor));
sbTag.Append(">");
// task containers tag
sbTag.Append("<TaskResultsContainers>");
sbTag.Append("<esri:BuddyControl Name=\"TaskResults1\" />");
sbTag.Append("</TaskResultsContainers>");
// closing tag
sbTag.Append("</selectToolTask:SelectToolTask>");
return sbTag.ToString();
}
private void AddTagProperty(StringBuilder sb, string name, object value)
{
sb.Append(String.Format(" {0}=\"{1}\"", name, value));
}
private string ToHtmlColor(System.Drawing.Color color)
{
if (color.IsNamedColor)
return color.Name;
else
return System.Drawing.ColorTranslator.ToHtml(color);
}
#endregion
#region IWebConfigurator Members
private SelectToolTask gSelTask = null;
private ControlCollection controls;
public ControlCollection AdditionalControls
{
get { return controls; }
set { controls = value; }
}
public Control ControlToConfigure
{
get
{
return gSelTask;
}
set
{
if (!(value is SelectToolTask))
throw new ArgumentException(
String.Concat("Control must be a ",
typeof(SelectToolTask).Name));
else
gSelTask = value as SelectToolTask;
}
}
public bool ValidateResources(out string message)
{
message = string.Empty;
return true;
}
private WebConfigurationCompleteEventHandler onWebConfigurationComplete;
public event WebConfigurationCompleteEventHandler WebConfigurationCompleted
{
add { onWebConfigurationComplete += value; }
remove { onWebConfigurationComplete -= value; }
}
protected virtual void OnWebConfigurationComplete(WebConfigurationCompleteEventArgs args)
{
if (onWebConfigurationComplete != null) onWebConfigurationComplete(this, args);
}
private WebConfigurationCanceledEventHandler onWebConfigurationCancel;
public event WebConfigurationCanceledEventHandler WebConfigurationCanceled
{
add { onWebConfigurationCancel += value; }
remove { onWebConfigurationCancel -= value; }
}
protected virtual void OnWebConfigurationCancel(EventArgs args)
{
if (onWebConfigurationCancel != null) onWebConfigurationCancel(this, args);
}
#endregion
#region IBuddyControlSupport Members
public Type[] GetSupportedBuddyControlTypes()
{
Type[] arrTypes = new Type[1];
arrTypes[0] = typeof(SelectToolTask);
return arrTypes;
}
#endregion
#region Private methods
private ListItem[] GetQueryableLayers(out string[] failedResources)
{
List<ListItem> itemList = new List<ListItem>();
List<string> invalidResources = new List<string>();
MapResourceManager mrm;
// check Page.Controls for resource items
List<Control> pgCtls = Utilities.FindControls(typeof(MapResourceManager),
Page.Controls);
foreach (Control ctl in pgCtls)
{
mrm = (MapResourceManager)ctl;
for (int i = 0; i < mrm.ResourceItems.Count; i++)
{
GISResourceItem resource = mrm.ResourceItems[i];
if (resource.FailedToInitialize ||
resource.Resource == null)
invalidResources.Add(resource.Name);
else
itemList.AddRange(
Utilities.GetQueryableLayersInResource(
resource.Resource, idStringDelim));
}
}
// check AdditionalControls too
if (AdditionalControls != null && AdditionalControls.Count > 0)
{
List<Control> addCtls = Utilities.FindControls(typeof(MapResourceManager),
AdditionalControls);
foreach (Control ctl in addCtls)
{
mrm = (MapResourceManager)ctl;
for (int i = 0; i < mrm.ResourceItems.Count; i++)
{
GISResourceItem resource = mrm.ResourceItems[i];
if (resource.FailedToInitialize ||
resource.Resource == null)
invalidResources.Add(resource.Name);
else
itemList.AddRange(
Utilities.GetQueryableLayersInResource(
mrm.ResourceItems[i].Resource, idStringDelim));
}
}
}
// set array of failed resources
failedResources = invalidResources.ToArray();
return itemList.ToArray();
}
#endregion
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -