本文整理汇总了C#中ICommandTarget.GetAdapter方法的典型用法代码示例。如果您正苦于以下问题:C# ICommandTarget.GetAdapter方法的具体用法?C# ICommandTarget.GetAdapter怎么用?C# ICommandTarget.GetAdapter使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ICommandTarget
的用法示例。
在下文中一共展示了ICommandTarget.GetAdapter方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: AsViewOrLastActivatedView
//ちょっと恣意的だが、ビュー直接またはLastActivatedViewで
public static IPoderosaView AsViewOrLastActivatedView(ICommandTarget target) {
IPoderosaView view = (IPoderosaView)target.GetAdapter(typeof(IPoderosaView));
if (view != null)
return view; //成功
else
return AsLastActivatedView(target);
}
示例2: GetForm
/// <summary>
/// Gets System.Windows.Forms.Form of the target.
/// </summary>
/// <param name="target">Target object which has been passed to the IPoderosaCommand's method.</param>
/// <returns>Form object if it is available. Otherwise null.</returns>
protected Form GetForm(ICommandTarget target)
{
IPoderosaMainWindow window = (IPoderosaMainWindow)target.GetAdapter(typeof(IPoderosaMainWindow));
if (window != null)
return window.AsForm();
else
return null;
}
示例3: AsLastActivatedView
public static IPoderosaView AsLastActivatedView(ICommandTarget target) {
IPoderosaMainWindow window = AsWindow(target);
if (window != null)
return window.LastActivatedView;
else {
IPoderosaPopupWindow popup = (IPoderosaPopupWindow)target.GetAdapter(typeof(IPoderosaPopupWindow));
if (popup != null)
return popup.InternalView;
else
return null;
}
}
示例4: InternalExecute
/// <summary>
/// Command execution
/// </summary>
public override CommandResult InternalExecute(ICommandTarget target, params IAdaptable[] args)
{
PipeTerminalParameter paramInit = null;
PipeTerminalSettings settingsInit = null;
IExtensionPoint ext = PipePlugin.Instance.PoderosaWorld.PluginManager.FindExtensionPoint("org.poderosa.terminalsessions.loginDialogUISupport");
if (ext != null && ext.ExtensionInterface == typeof(ILoginDialogUISupport)) {
foreach (ILoginDialogUISupport sup in ext.GetExtensions()) {
ITerminalParameter terminalParam;
ITerminalSettings terminalSettings;
sup.FillTopDestination(typeof(PipeTerminalParameter), out terminalParam, out terminalSettings);
PipeTerminalParameter paramTemp = terminalParam as PipeTerminalParameter;
PipeTerminalSettings settingsTemp = terminalSettings as PipeTerminalSettings;
if (paramInit == null)
paramInit = paramTemp;
if (settingsInit == null)
settingsInit = settingsTemp;
}
}
if (paramInit == null)
paramInit = new PipeTerminalParameter();
if (settingsInit == null)
settingsInit = new PipeTerminalSettings();
IPoderosaMainWindow window = (IPoderosaMainWindow)target.GetAdapter(typeof(IPoderosaMainWindow));
CommandResult commandResult = CommandResult.Failed;
using (OpenPipeDialog dialog = new OpenPipeDialog()) {
dialog.OpenPipe =
delegate(PipeTerminalParameter param, PipeTerminalSettings settings) {
PipeTerminalConnection connection = PipeCreator.CreateNewPipeTerminalConnection(param, settings);
commandResult = PipePlugin.Instance.CommandManager.Execute(
PipePlugin.Instance.TerminalSessionsService.TerminalSessionStartCommand,
window, connection, settings);
return (commandResult == CommandResult.Succeeded);
};
dialog.ApplyParams(paramInit, settingsInit);
DialogResult dialogResult = dialog.ShowDialog(window != null ? window.AsForm() : null);
if (dialogResult == DialogResult.Cancel)
commandResult = CommandResult.Cancelled;
}
return commandResult;
}
示例5: OpenShortcutFile
public static CommandResult OpenShortcutFile(ICommandTarget target, string filename)
{
IPoderosaMainWindow window = CommandTargetUtil.AsWindow(target);
if (window == null)
window = (IPoderosaMainWindow)CommandTargetUtil.AsViewOrLastActivatedView(target).ParentForm.GetAdapter(typeof(IPoderosaMainWindow));
if (window == null)
return CommandResult.Ignored;
if (!File.Exists(filename)) {
window.Warning(String.Format("{0} is not a file", filename));
return CommandResult.Failed;
}
ShortcutFileContent f = null;
try {
f = ShortcutFileContent.LoadFromXML(filename);
}
catch (Exception ex) {
//変なファイルをドロップしたなどで例外は簡単に起こりうる
window.Warning(String.Format("Failed to read {0}\n{1}", filename, ex.Message));
return CommandResult.Failed;
}
try {
//独立ウィンドウにポップアップさせるようなことは考えていない
IContentReplaceableView rv = (IContentReplaceableView)target.GetAdapter(typeof(IContentReplaceableView));
if (rv == null) {
rv = (IContentReplaceableView)window.ViewManager.GetCandidateViewForNewDocument().GetAdapter(typeof(IContentReplaceableView));
}
TerminalControl tc = (TerminalControl)rv.GetCurrentContent().GetAdapter(typeof(TerminalControl));
if (tc != null) { //ターミナルコントロールがないときは無理に設定しにいかない
RenderProfile rp = f.TerminalSettings.UsingDefaultRenderProfile ? TerminalSessionsPlugin.Instance.TerminalEmulatorService.TerminalEmulatorOptions.CreateRenderProfile() : f.TerminalSettings.RenderProfile;
Size sz = tc.CalcTerminalSize(rp);
f.TerminalParameter.SetTerminalSize(sz.Width, sz.Height);
}
ITerminalSession s = TerminalSessionsPlugin.Instance.TerminalSessionStartCommand.StartTerminalSession(target, f.TerminalParameter, f.TerminalSettings);
return s != null ? CommandResult.Succeeded : CommandResult.Failed;
}
catch (Exception ex) {
RuntimeUtil.ReportException(ex);
return CommandResult.Failed;
}
}
示例6: OpenShortcutFile
public static CommandResult OpenShortcutFile(ICommandTarget target, string filename)
{
IPoderosaMainWindow window = CommandTargetUtil.AsWindow(target);
if (window == null)
window = (IPoderosaMainWindow)CommandTargetUtil.AsViewOrLastActivatedView(target).ParentForm.GetAdapter(typeof(IPoderosaMainWindow));
if (window == null)
return CommandResult.Ignored;
if (!File.Exists(filename)) {
window.Warning(String.Format("{0} is not a file", filename));
return CommandResult.Failed;
}
ShortcutFileContent f = null;
try {
f = ShortcutFileContent.LoadFromXML(filename);
}
catch (Exception ex) {
//�ςȃt�@�C����h���b�v�����Ȃǂŗ�O�͊ȒP�ɋN���肤��
window.Warning(String.Format("Failed to read {0}\n{1}", filename, ex.Message));
return CommandResult.Failed;
}
try {
//�Ɨ��E�B���h�E�Ƀ|�b�v�A�b�v������悤�Ȃ��Ƃ͍l���Ă��Ȃ�
IContentReplaceableView rv = (IContentReplaceableView)target.GetAdapter(typeof(IContentReplaceableView));
if (rv == null) {
rv = (IContentReplaceableView)window.ViewManager.GetCandidateViewForNewDocument().GetAdapter(typeof(IContentReplaceableView));
}
TerminalControl tc = (TerminalControl)rv.GetCurrentContent().GetAdapter(typeof(TerminalControl));
if (tc != null) { //�^�[�~�i���R���g���[�����Ȃ��Ƃ��͖����ɐݒ肵�ɂ����Ȃ�
RenderProfile rp = f.TerminalSettings.UsingDefaultRenderProfile ? TerminalSessionsPlugin.Instance.TerminalEmulatorService.TerminalEmulatorOptions.CreateRenderProfile() : f.TerminalSettings.RenderProfile;
Size sz = tc.CalcTerminalSize(rp);
f.TerminalParameter.SetTerminalSize(sz.Width, sz.Height);
}
ITerminalSession s = TerminalSessionsPlugin.Instance.TerminalSessionStartCommand.StartTerminalSession(target, f.TerminalParameter, f.TerminalSettings);
return s != null ? CommandResult.Succeeded : CommandResult.Failed;
}
catch (Exception ex) {
RuntimeUtil.ReportException(ex);
return CommandResult.Failed;
}
}
示例7: AsWindow
public static IPoderosaMainWindow AsWindow(ICommandTarget target) {
IPoderosaMainWindow window = (IPoderosaMainWindow)target.GetAdapter(typeof(IPoderosaMainWindow));
return window;
}
示例8: AsContentReplaceableViewOrLastActivatedView
/// <exclude/>
public static IContentReplaceableView AsContentReplaceableViewOrLastActivatedView(ICommandTarget target)
{
if (target == null)
return null;
IContentReplaceableViewSite view = (IContentReplaceableViewSite)target.GetAdapter(typeof(IContentReplaceableViewSite));
if (view != null)
return view.CurrentContentReplaceableView; //成功
else {
IContentReplaceableView view2 = (IContentReplaceableView)target.GetAdapter(typeof(IContentReplaceableView));
if (view2 != null)
return view2;
else {
IPoderosaMainWindow window = AsWindow(target);
if (window != null)
return window.LastActivatedView;
else
return null;
}
}
}
示例9: InternalExecute
public CommandResult InternalExecute(ICommandTarget target, params IAdaptable[] args)
{
CharacterDocumentViewer control = (CharacterDocumentViewer)target.GetAdapter(typeof(CharacterDocumentViewer));
ITextSelection s = control.ITextSelection;
if (s.IsEmpty || !control.EnabledEx)
return CommandResult.Ignored;
string t = s.GetSelectedText(TextFormatOption.Default);
if (t.Length > 0)
CopyToClipboard(t);
return CommandResult.Succeeded;
}
示例10: AsDocumentOrViewOrLastActivatedDocument
//ドキュメント直接指定か、Viewか、ウィンドウの最後にアクティブになったドキュメント
/// <summary>
/// <ja>
/// ドキュメントまたは最後にアクティブであったドキュメントに変換します。
/// </ja>
/// <en>
/// It converts it at the document or the end into an active document.
/// </en>
/// </summary>
/// <param name="target">
/// <ja>対象となるターゲット。</ja>
/// <en>It is a target that becomes an object. </en>
/// </param>
/// <returns>
/// <ja>変換したインターフェイスです。変換できないときにはnullが戻ります。</ja>
/// <en>It is a converted interface. Null returns when it is not possible to convert it. </en>
/// </returns>
/// <remarks>
/// <ja>
/// このメソッドは、まず、<paramref name="target"/>をIPoderosaDocumentに変換しようとし、変換できたならそのインターフェイスを返します。
/// 変換できない場合には、<see cref="AsViewOrLastActivatedView">AsViewOrLastActivatedViewメソッド</see>を呼び出して得たビューの<see cref="IPoderosaView.Document">Documentプロパティ</see>
/// からドキュメントを得ます。
/// </ja>
/// <en>
/// If it tries to convert <paramref name="target"/> into IPoderosaDocument first of all, and it was possible to convert it, this method returns the interface.
/// The document is obtained from the <see cref="IPoderosaView.Document">Document property</see> of the view that calls the <see cref="AsViewOrLastActivatedView">AsViewOrLastActivatedView method</see> when it is not possible to convert it and obtains it.
/// </en>
/// </remarks>
public static IPoderosaDocument AsDocumentOrViewOrLastActivatedDocument(ICommandTarget target)
{
IPoderosaDocument doc = null;
if (target != null)
doc = (IPoderosaDocument)target.GetAdapter(typeof(IPoderosaDocument));
if (doc != null)
return doc;
else {
IPoderosaView view = AsViewOrLastActivatedView(target);
if (view != null)
return view.Document;
else
return null;
}
}
示例11: InternalExecute
public CommandResult InternalExecute(ICommandTarget target, params IAdaptable[] args) {
IPoderosaMainWindow window = (IPoderosaMainWindow)target.GetAdapter(typeof(IPoderosaMainWindow));
if (window == null)
return CommandResult.Ignored;
LocalShellLoginDialog dlg = new LocalShellLoginDialog(window);
using (dlg) {
dlg.ApplyParam();
if (dlg.ShowDialog(window.AsForm()) == DialogResult.OK) {
ITerminalConnection con = dlg.Result;
if (con != null) {
ISessionManager sm = (ISessionManager)CygwinPlugin.Instance.PoderosaWorld.PluginManager.FindPlugin("org.poderosa.core.sessions", typeof(ISessionManager));
TerminalSession ts = new TerminalSession(con, dlg.TerminalSettings);
sm.StartNewSession(ts, dlg.TargetView);
sm.ActivateDocument(ts.Terminal.IDocument, ActivateReason.InternalAction);
IAutoExecMacroParameter autoExecParam = con.Destination.GetAdapter(typeof(IAutoExecMacroParameter)) as IAutoExecMacroParameter;
if (autoExecParam != null && autoExecParam.AutoExecMacroPath != null && CygwinPlugin.Instance.MacroEngine != null) {
CygwinPlugin.Instance.MacroEngine.RunMacro(autoExecParam.AutoExecMacroPath, ts);
}
return CommandResult.Succeeded;
}
}
}
return CommandResult.Cancelled;
}
示例12: ToPoderosaView
private static IPoderosaView ToPoderosaView(ICommandTarget target) {
IPoderosaMainWindow window = (IPoderosaMainWindow)target.GetAdapter(typeof(IPoderosaMainWindow));
IPoderosaView view;
if (window != null)
view = window.ViewManager.GetCandidateViewForNewDocument();
else {
view = (IPoderosaView)target.GetAdapter(typeof(IPoderosaView));
Debug.Assert(view != null);
}
IContentReplaceableView rv = (IContentReplaceableView)view.GetAdapter(typeof(IContentReplaceableView));
if (rv != null)
view = rv.AssureViewClass(typeof(TerminalView));
return view;
}
示例13: StartTerminalSession
//Parameterからスタートするタイプ 今はtargetはwindow強制だがViewでも可能にしたい
public ITerminalSession StartTerminalSession(ICommandTarget target, ITerminalParameter destination, ITerminalSettings settings) {
IPoderosaMainWindow window = (IPoderosaMainWindow)target.GetAdapter(typeof(IPoderosaMainWindow));
if (window == null) {
IPoderosaView view = (IPoderosaView)target.GetAdapter(typeof(IPoderosaView));
window = (IPoderosaMainWindow)view.ParentForm.GetAdapter(typeof(IPoderosaMainWindow));
}
Debug.Assert(window != null);
ITerminalConnection connection = OpenConnection(window, destination, settings);
if (connection == null)
return null;
return StartTerminalSession(target, connection, settings);
}
示例14: InternalExecute
public CommandResult InternalExecute(ICommandTarget target, params IAdaptable[] args)
{
IPoderosaMainWindow window = (IPoderosaMainWindow)target.GetAdapter(typeof(IPoderosaMainWindow));
if (window == null)
return CommandResult.Ignored;
TelnetSSHLoginDialog dlg = new TelnetSSHLoginDialog(window);
dlg.ApplyParam();
CommandResult res = CommandResult.Cancelled;
//Task.Run(() =>
{
if (dlg.ShowDialog() == DialogResult.OK)
{
ITerminalConnection con = dlg.Result;
if (con != null)
{
ISessionManager sm = (ISessionManager)TelnetSSHPlugin.Instance.PoderosaWorld.PluginManager.FindPlugin("org.poderosa.core.sessions", typeof(ISessionManager));
TerminalSession ts = new TerminalSession(con, dlg.TerminalSettings);
sm.StartNewSession(ts, (IPoderosaView)dlg.TargetView.GetAdapter(typeof(IPoderosaView)));
sm.ActivateDocument(ts.Terminal.IDocument, ActivateReason.InternalAction);
IAutoExecMacroParameter autoExecParam = con.Destination.GetAdapter(typeof(IAutoExecMacroParameter)) as IAutoExecMacroParameter;
if (autoExecParam != null && autoExecParam.AutoExecMacroPath != null && TelnetSSHPlugin.Instance.MacroEngine != null)
{
TelnetSSHPlugin.Instance.MacroEngine.RunMacro(autoExecParam.AutoExecMacroPath, ts);
}
return CommandResult.Succeeded;
}
}
dlg.Dispose();
}
//);
return res;
}
示例15: GetViewAndSession
/// <summary>
/// <ja>GetViewAndSession</ja>
/// </summary>
private bool GetViewAndSession(ICommandTarget target, out IPoderosaView view, out ITerminalSession session)
{
view = (IPoderosaView)target.GetAdapter(typeof(IPoderosaView));
if ((view != null) && (view.Document != null)) {
session = (ITerminalSession)view.Document.OwnerSession.GetAdapter(typeof(ITerminalSession));
if (!session.TerminalConnection.IsClosed) return true;
} else {
session = null;
}
return false;
}