default.aspxページでは、ツールバーにいくつかのESRIツール(およびいくつかのコマンド)があるので、次のようになります。
<ToolbarItems>
<esri:Tool ClientAction="MapPoint('Map1','%toolbarItem%',false,'crosshair') DefaultImage="~/images/default_tool.gif"
EnablePostBack="True" JavaScriptFile="" Name="TestTool" SelectedImage="~/images/selected_tool.gif" DisabledImage="~/images/disabled_tool.gif"
ServerActionAssembly="Test.Web.Mapping" ServerActionClass="Test.Web.Mapping.TestTool"
Text="It's a tool!" ToolTip="Use it." />
</ToolbarItems>
これで、ツールを無効にして、そのイメージを効果的に変更するために使用されるコードがいくつかあります。コードは基本的にツールバーをループして、無効にする必要のあるツールを見つけ、それを実行します。
コードが実行された後、すべてが美しく機能します。適切なツールが無効になり、それに応じて画像が変更されました。
問題は、たとえば拡大ツールを選択すると、無効にしたツールの画像がすぐにデフォルトの画像に戻ることです。
Default.aspxページで定義されているように、すべてのツールの状態をデフォルトにリセットするJavascriptのブロックがどこかで実行されている必要があるようです。私はそれを見つけるのに苦労しています。何か案は?
編集:ボタンを無効にするためのコードは、次のようなC#コードです...
foreach (InteractiveImageToolbarItem toolbarTool in toolbar.ToolbarItems)
{
// First check to see if the dictionary even contains the tool, if not we assume the tool is enabled for all themes, so enable it and
// move to the next iteration.
if (!enabledTools.Keys.Contains(toolbarTool.Name))
{
toolbarTool.Disabled = false;
continue;
}
// So the tool is in the list, this loop checks to see if the tool is enabled for the current theme, meaning the theme is in the list
// associated with the tool.
foreach (string themeFromConfig in enabledTools[toolbarTool.Name])
{
if (currentTheme != themeFromConfig)
{
toolbarTool.Disabled = true;
}
else
{
toolbarTool.Disabled = false;
break;
}
}
}
構成値を確認することで、何を有効にする必要があるかを確認できます。もう一度言いますが、この部分は正常に機能します。
2009年9月3日更新:わかりました。問題が何であるかはわかっていると思います。Web ADFでは、呼び出されるメソッドToolbarMouseDownの最後に呼び出しがあります...
Toolbars[toolbarName].refreshGroup();
ツールバーと同じグループの一部であるツールバーでツールをクリックすると、画像がリセットされます。その背後にあるロジックを理解できるかどうかはわかりません。ツールを無効にしたり、画像を変更して永続化することはできません。なんでもいい...
とにかく、これはすべてJavascript側にありますが、refreshGroup呼び出しがいつ行われたかなどを知る方法はありますか?画像が有効にリセットされたら、すぐに無効に戻す必要があると思います。