Ejemplo n.º 1
0
        public EditRenderProfile(RenderProfile prof)
        {
            //
            // Windows フォーム デザイナ サポートに必要です。
            //
            InitializeComponent();
            _imageStyleBox.Items.AddRange(EnumDescAttributeT.For(typeof(ImageStyle)).DescriptionCollection());
            this._bgColorLabel.Text            = GApp.Strings.GetString("Form.EditRenderProfile._bgColorLabel");
            this._textColorLabel.Text          = GApp.Strings.GetString("Form.EditRenderProfile._textColorLabel");
            this._fontSelectButton.Text        = GApp.Strings.GetString("Form.EditRenderProfile._fontSelectButton");
            this._fontLabel.Text               = GApp.Strings.GetString("Form.EditRenderProfile._fontLabel");
            this._backgroundImageLabel.Text    = GApp.Strings.GetString("Form.EditRenderProfile._backgroungImageLabel");
            this._imageStyleLabel.Text         = GApp.Strings.GetString("Form.EditRenderProfile._imageStyleLabel");
            this._cancelButton.Text            = GApp.Strings.GetString("Common.Cancel");
            this._okButton.Text                = GApp.Strings.GetString("Common.OK");
            this._fontSample.Text              = GApp.Strings.GetString("Common.FontSample");
            this._editColorEscapeSequence.Text = GApp.Strings.GetString("Form.EditRenderProfile._editEscapeSequenceColorBox");
            this.Text = GApp.Strings.GetString("Form.EditRenderProfile.Text");

            //
            // TODO: InitializeComponent 呼び出しの後に、コンストラクタ コードを追加してください。
            //
            _profile = new RenderProfile(prof == null? GEnv.DefaultRenderProfile : prof);
            InitUI();
        }
Ejemplo n.º 2
0
        public ConnectionTag(TerminalConnection c)
        {
            _connection      = c;
            _pane            = null;
            _invalidateParam = new InvalidateParam();
            _tabButton       = null;
            _document        = new TerminalDocument(_connection);
            _receiver        = new TerminalDataReceiver(this);
            _terminated      = false;
            _timer           = null;
            _windowTitle     = "";

            //nullのときはデフォルトプロファイルを使う
            _renderProfile = c.Param.RenderProfile;

            //VT100指定でもxtermシーケンスを送ってくるアプリケーションが後をたたないので
            //_terminal = new XTerm(this, new JapaneseCharDecoder(_connection));

            if (c.Param.TerminalType == TerminalType.XTerm || c.Param.TerminalType == TerminalType.KTerm)
            {
                _terminal = new XTerm(this, new JapaneseCharDecoder(_connection));
            }
            else
            {
                _terminal = new VT100Terminal(this, new JapaneseCharDecoder(_connection));
            }

            GEnv.Connections.KeepAlive.SetTimerToConnectionTag(this);
        }
Ejemplo n.º 3
0
        public void SuccessfullyExit(ITerminalConnection connection)
        {
            ITerminalSettings terminalSettings = PoderosaTerminalEmulatorService.CreateDefaultTerminalSettings(Connection.DisplayName, null);

            TerminalSession session       = new TerminalSession(connection, terminalSettings);
            SessionHost     sessionHost   = new SessionHost(PoderosaSessionManagerPlugin, session);
            TerminalView    terminalView  = new TerminalView(null, _terminal);
            RenderProfile   renderProfile = new RenderProfile(_terminal.GetRenderProfile());

            renderProfile.BackColor = Connection.BackgroundColor;
            renderProfile.ForeColor = Connection.TextColor;

            session.TerminalSettings.BeginUpdate();
            session.TerminalSettings.RenderProfile = renderProfile;
            session.TerminalSettings.EndUpdate();

            _sshConnection = (SSHTerminalConnection)connection;

            Invoke(
                new Action(
                    () =>
            {
                _terminal.Attach(session);

                session.InternalStart(sessionHost);
                session.InternalAttachView(sessionHost.DocumentAt(0), terminalView);

                _sshConnection.ConnectionEventReceiver.NormalTermination   += ConnectionEventReceiver_NormalTermination;
                _sshConnection.ConnectionEventReceiver.AbnormalTermination += ConnectionEventReceiver_AbnormalTermination;

                ParentForm.Closing += ParentForm_OnClosing;

                OnConnected(_terminal, null);
            }));
        }
Ejemplo n.º 4
0
        public EditRenderProfile(RenderProfile prof)
        {
            //
            // Windows フォーム デザイナ サポートに必要です。
            //
            InitializeComponent();
            StringResource sr = TerminalUIPlugin.Instance.Strings;

            _imageStyleBox.Items.AddRange(EnumListItem <ImageStyle> .GetListItems());
            this._bgColorLabel.Text            = sr.GetString("Form.EditRenderProfile._bgColorLabel");
            this._textColorLabel.Text          = sr.GetString("Form.EditRenderProfile._textColorLabel");
            this._fontSelectButton.Text        = sr.GetString("Form.EditRenderProfile._fontSelectButton");
            this._fontLabel.Text               = sr.GetString("Form.EditRenderProfile._fontLabel");
            this._backgroundImageLabel.Text    = sr.GetString("Form.EditRenderProfile._backgroungImageLabel");
            this._imageStyleLabel.Text         = sr.GetString("Form.EditRenderProfile._imageStyleLabel");
            this._cancelButton.Text            = sr.GetString("Common.Cancel");
            this._okButton.Text                = sr.GetString("Common.OK");
            this._setToDefaultButton.Text      = sr.GetString("Form.EditRenderProfile._setToDefaultButton");
            this._fontSample.Text              = sr.GetString("Common.FontSample");
            this._editColorEscapeSequence.Text = sr.GetString("Form.EditRenderProfile._editEscapeSequenceColorBox");
            this.Text = sr.GetString("Form.EditRenderProfile.Text");

            _profile = prof == null?TerminalUIPlugin.Instance.TerminalEmulatorPlugin.TerminalEmulatorOptions.CreateRenderProfile() : (RenderProfile)prof.Clone();

            InitUI();
        }
Ejemplo n.º 5
0
        public static void UpdateOptions(ContainerOptions opt)
        {
            GEnv.Options = opt;
            _frame.ApplyOptions(_options, opt);
            _history.LimitCount(opt.MRUSize);
            _frame.AdjustMRUMenu();

            if (_options.Language != opt.Language)            //言語のリロードが必要なとき
            {
                System.Threading.Thread.CurrentThread.CurrentUICulture = opt.Language == Language.Japanese? new CultureInfo("ja") : CultureInfo.InvariantCulture;
                GApp.ReloadStringResource();
                Granados.SSHC.Strings.Reload();
                GApp.MacroManager.ReloadLanguage();
                _frame.ReloadLanguage(opt.Language);
            }

            //デフォルトのままであった場合には更新をかける
            RenderProfile newprof = new RenderProfile(opt);

            foreach (ConnectionTag ct in GEnv.Connections)
            {
                if (ct.RenderProfile == null && ct.AttachedPane != null)
                {
                    ct.AttachedPane.ApplyRenderProfile(newprof);
                }
            }
            GEnv.DefaultRenderProfile = newprof;
            _options = opt;
        }
Ejemplo n.º 6
0
        public static ITerminalSession InvokeOpenSessionOrNull(ICommandTarget target, TerminalParam param)
        {
            ITerminalParameter tp = param.ConvertToTerminalParameter();
            ITerminalSettings  ts = CreateTerminalSettings(param);

            IViewManager pm = CommandTargetUtil.AsWindow(target).ViewManager;
            //独立ウィンドウにポップアップさせるようなことは考えていない
            IContentReplaceableView rv = (IContentReplaceableView)pm.GetCandidateViewForNewDocument().GetAdapter(typeof(IContentReplaceableView));
            TerminalControl         tc = (TerminalControl)rv.GetCurrentContent().GetAdapter(typeof(TerminalControl));

            if (tc != null) //ターミナルコントロールがないときは無理に設定しにいかない
            {
                Size sz;
                if (ts.UsingDefaultRenderProfile)
                {
                    using (RenderProfile profile = MacroPlugin.Instance.TerminalEmulatorService.TerminalEmulatorOptions.CreateRenderProfile())
                        sz = tc.CalcTerminalSize(profile);
                }
                else
                {
                    sz = tc.CalcTerminalSize(ts.RenderProfile);
                }
                //RenderProfile rp = ts.UsingDefaultRenderProfile? MacroPlugin.Instance.TerminalEmulatorService.TerminalEmulatorOptions.CreateRenderProfile() : ts.RenderProfile;
                //Size sz = tc.CalcTerminalSize(rp);
                tp.SetTerminalSize(sz.Width, sz.Height);
            }


            return((ITerminalSession)MacroPlugin.Instance.WindowManager.ActiveWindow.AsForm().Invoke(new OpenSessionDelegate(OpenSessionOrNull), tp, ts));
        }
        protected void OnOK(object sender, EventArgs args)
        {
            this.DialogResult = DialogResult.None;
            _targetView       = GetTargetView();
            ITerminalParameter term = PrepareTerminalParameter();

            if (term == null)
            {
                return;            //設定に誤りがある場合
            }
            TerminalControl tc = (TerminalControl)_targetView.GetAdapter(typeof(TerminalControl));
            //Size sz = tc.CalcTerminalSize((_terminalSettings.RenderProfile == null) ?
            //            this.GetInitialRenderProfile() : _terminalSettings.RenderProfile);
            Size sz;

            if (_terminalSettings.RenderProfile == null)
            {
                using (RenderProfile profile = this.GetInitialRenderProfile())
                    sz = tc.CalcTerminalSize(profile);
            }
            else
            {
                sz = tc.CalcTerminalSize(_terminalSettings.RenderProfile);
            }
            term.SetTerminalSize(sz.Width, sz.Height);

            _loginButton.Enabled  = false;
            _cancelButton.Enabled = false;
            this.Cursor           = Cursors.WaitCursor;
            _originalText         = this.Text;
            this.Text             = String.Format("{0} - {1}", _originalText, TEnv.Strings.GetString("Caption.HowToCancel"));

            StartConnection();
        }
Ejemplo n.º 8
0
 private static RenderProfile CreateLogRenderProfile() {
     RenderProfile rp = new RenderProfile();
     rp.FontName = "Courier New";
     rp.FontSize = 9;
     rp.BackColor = SystemColors.Window;
     rp.ForeColor = SystemColors.WindowText;
     return rp;
 }
Ejemplo n.º 9
0
        /// <summary>
        /// 表示オプションボタンクリックイベント
        /// </summary>
        private void _editRenderButton_Click(object sender, EventArgs e)
        {
            EditRenderProfile dlg = new EditRenderProfile(_renderProfile);

            if (dlg.ShowDialog() == DialogResult.OK)
            {
                _renderProfile = dlg.Result;
            }
        }
Ejemplo n.º 10
0
        public void SetPaneColors(Color TextColor, Color BackColor)
        {
            RenderProfile prof = this._terminalPane.ConnectionTag.RenderProfile;

            prof.BackColor = BackColor;
            prof.ForeColor = TextColor;

            this._terminalPane.ApplyRenderProfile(prof);
        }
Ejemplo n.º 11
0
        /// <summary>
        /// Create and add a render profile based on its type
        /// </summary>

        public void AddRenderProfile(Type renderProfileType)
        {
            /// Instantiate a render profile with the resource content manager
            RenderProfile profile =
                (RenderProfile)Activator.CreateInstance(renderProfileType, graphicsDevice, content);

            renderProfiles.Add(profile);
            currentRenderProfile = profile;
            currentRenderProfile.MapInputs();
        }
Ejemplo n.º 12
0
 internal TerminalParam()
 {
     _encoding      = EncodingType.EUC_JP;
     _logtype       = LogType.None;
     _terminalType  = TerminalType.XTerm;
     _localecho     = false;
     _lineFeedRule  = LineFeedRule.Normal;
     _transmitnl    = NewLine.CR;
     _renderProfile = null;
 }
Ejemplo n.º 13
0
        private static void Init()
        {
            RenderProfile rp = GEnv.Options.CreateRenderProfile();

            rp.FontName               = "MS ゴシック";
            rp.JapaneseFontName       = "MS ゴシック";
            rp.BackColor              = Color.White;
            rp.ForeColor              = Color.Black;
            GEnv.DefaultRenderProfile = rp;
        }
Ejemplo n.º 14
0
        /// <summary>
        /// Create and add a render profile based on its type
        /// </summary>

        public void AddRenderProfile(Type renderProfileType)
        {
            /// Instantiate a render profile with the resource content manager
            RenderProfile profile =
                (RenderProfile)Activator.CreateInstance(renderProfileType, ServiceContainer, resxContent);

            renderProfiles.Add(profile);
            currentRenderProfile = renderProfiles[renderProfiles.Count - 1];
            currentRenderProfile.MapInputs(currentScene, currentCamera);
        }
Ejemplo n.º 15
0
        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);
            }
        }
        /// <summary>
        /// コンストラクタ
        /// </summary>
        /// <param name="prof">プロファイル</param>
        public ProfileEditForm(ConnectProfileStruct prof)
        {
            InitializeComponent();
            InitializeComponentValue();

            // オブジェクト初期値設定
            if (prof == null) {
                // 新規作成時はデフォルト値を設定
                _protocolBox.SelectedItem = ConnectionMethod.SSH2;
                _portBox.Value = ConnectProfileStruct.DEFAULT_SSH_PORT;
                _authTypeBox.SelectedItem = AuthType.Password;
                _charCodeBox.SelectedItem = EncodingType.UTF8;
                _newLineTypeBox.SelectedItem = NewLine.CR;
                _telnetNewLineCheck.Checked = true;
                _terminalTypeBox.SelectedItem = TerminalType.XTerm;
                _commandSendIntBox.Value = ConnectProfileStruct.DEFAULT_CMD_SEND_INTERVAL;
                _promptRecvTimeoutBox.Value = ConnectProfileStruct.DEFAULT_PROMPT_RECV_TIMEOUT;

                // コンソール表示オブジェクトはターミナルオプション値を反映
                _renderProfile = ConnectProfilePlugin.Instance.TerminalEmulatorService.TerminalEmulatorOptions.CreateRenderProfile();
            } else {
                // 編集時は対象プロファイル値を設定
                _hostNameBox.Text = prof.HostName;
                _protocolBox.SelectedItem = prof.Protocol;
                _portBox.Value = prof.Port;
                _authTypeBox.SelectedItem = prof.AuthType;
                _keyFileBox.Text = prof.KeyFile;
                _userNameBox.Text = prof.UserName;
                _passwordBox.Text = prof.Password;
                _autoLoginCheck.Checked = prof.AutoLogin;
                _loginPromptBox.Text = prof.LoginPrompt;
                _passwordPromptBox.Text = prof.PasswordPrompt;
                _execCommandBox.Text = prof.ExecCommand;
                _suUserNameBox.Text = prof.SUUserName;
                _suPasswordBox.Text = prof.SUPassword;
                if (prof.SUType == _suTypeRadio1.Text) _suTypeRadio1.Checked = true;
                else if (prof.SUType == _suTypeRadio2.Text) _suTypeRadio2.Checked = true;
                else if (prof.SUType == _suTypeRadio3.Text) _suTypeRadio3.Checked = true;
                else if (prof.SUType == _suTypeRadio4.Text) _suTypeRadio4.Checked = true;
                _charCodeBox.SelectedItem = prof.CharCode;
                _newLineTypeBox.SelectedItem = prof.NewLine;
                _telnetNewLineCheck.Checked = prof.TelnetNewLine;
                _terminalTypeBox.SelectedItem = prof.TerminalType;
                _commandSendIntBox.Value = prof.CommandSendInterval;
                _promptRecvTimeoutBox.Value = prof.PromptRecvTimeout;
                _profileItemColorButton.SelectedColor = prof.ProfileItemColor;
                _descriptionBox.Text = prof.Description;
                _renderProfile = ConnectProfilePlugin.Instance.TerminalEmulatorService.TerminalEmulatorOptions.CreateRenderProfile();
                _renderProfile = prof.RenderProfile;
            }

            _Initialized = true;
            EnableValidControls(this, EventArgs.Empty);
        }
Ejemplo n.º 17
0
 internal void Import(TerminalParam r)
 {
     _encoding      = r._encoding;
     _logtype       = r._logtype;
     _logpath       = r._logpath;
     _localecho     = r._localecho;
     _transmitnl    = r._transmitnl;
     _lineFeedRule  = r._lineFeedRule;
     _terminalType  = r._terminalType;
     _renderProfile = r._renderProfile == null ? null : new RenderProfile(r._renderProfile);
     _caption       = r._caption;
 }
Ejemplo n.º 18
0
        public void ImportProperties(ConnectionTag src)
        {
            _renderProfile          = src.RenderProfile;
            _positionIndex          = src.PositionIndex;
            _preservedPositionIndex = src.PreservedPositionIndex;

            if (src.Button != null)
            {
                src.Button.Tag = this;
            }
            _tabButton = src.Button;
        }
 public CommandResult ResetAllRenderProfiles(RenderProfile prof)
 {
     GEnv.DefaultRenderProfile = prof;
     foreach (ConnectionTag ct in GEnv.Connections)
     {
         ct.RenderProfile = null;
         if (ct.AttachedPane != null)
         {
             ct.AttachedPane.ApplyRenderProfile(prof);
         }
     }
     return(CommandResult.Success);
 }
Ejemplo n.º 20
0
 public virtual void Import(ConfigNode data)
 {
     _encoding     = ParseEncoding(data["encoding"]);
     _terminalType = (TerminalType)EnumDescAttribute.For(typeof(TerminalType)).FromName(data["terminal-type"], TerminalType.VT100);
     _transmitnl   = (NewLine)EnumDescAttribute.For(typeof(NewLine)).FromName(data["transmit-nl"], NewLine.CR);
     _localecho    = GUtil.ParseBool(data["localecho"], false);
     //_lineFeedByCR = GUtil.ParseBool((string)data["linefeed-by-cr"], false);
     _lineFeedRule = (LineFeedRule)EnumDescAttribute.For(typeof(LineFeedRule)).FromName(data["linefeed"], LineFeedRule.Normal);
     _caption      = data["caption"];
     if (data.Contains("font-name")) //項目がなければ空のまま
     {
         _renderProfile = new RenderProfile(data);
     }
 }
Ejemplo n.º 21
0
        //フォーカスのあるペインを拡大または縮小する
        public void ResizeSplitterByFocusedPane(bool expand)
        {
            ConnectionTag ct   = GEnv.Connections.ActiveTag;
            RenderProfile prof = ct == null? GEnv.DefaultRenderProfile : ct.RenderProfile;

            if (prof == null)
            {
                prof = GEnv.DefaultRenderProfile;
            }
            double diff = IsVerticalFrameStyle(GApp.Options.FrameStyle)? prof.Pitch.Width / this.Width : prof.Pitch.Height / this.Height;


            int active_index = 0;             //アクティブなのがなくてもnull

            if (ct != null)
            {
                for (int i = 0; i < _panes.Length; i++)
                {
                    if (ct.AttachedPane == _panes[i])
                    {
                        active_index = i;
                        break;
                    }
                }
            }

            int pane_count = StyleToPaneCount(GApp.Options.FrameStyle);

            double[] ratio = _splitterRatio[pane_count - 2];
            if (active_index < pane_count - 1)
            {
                double n0 = ratio[active_index] + (expand? diff : -diff);
                if (n0 < diff * 2 || n0 > (active_index + 1 >= ratio.Length? 1 : ratio[active_index + 1]) - diff * 2)
                {
                    return;                                                                                                      //小さすぎてしまうときは拒否
                }
                ratio[active_index] = n0;
            }
            else
            {
                double n0 = ratio[active_index - 1] + (expand? -diff : diff);
                if (n0 < diff * 2 || n0 > 1 - diff * 2)
                {
                    return;
                }
                ratio[active_index - 1] = n0;
            }
            AdjustSplitters();
        }
Ejemplo n.º 22
0
        /// <summary>
        /// Constructor without a default scene
        /// </summary>

        public Core(IServiceProvider services)
            : base(services)
        {
            content     = new ContentManager(services, "MeteorEngine.Content");
            resxContent = new ResourceContentManager(services, MeteorContentResource.ResourceManager);
            renderStats = new RenderStats();

            currentRenderProfile = null;
            renderProfiles       = new List <RenderProfile>();
            debugString          = new StringBuilder(64, 64);

            // Setup rendering components
            cameras = new List <Camera>();
            scenes  = new List <Scene>();
        }
Ejemplo n.º 23
0
        public ConnectionTag(TerminalConnection c)
        {
            _connection      = c;
            _pane            = null;
            _invalidateParam = new InvalidateParam();
            _tabButton       = null;
            _document        = new TerminalDocument(_connection);
            _receiver        = new TerminalDataReceiver(this);
            _terminated      = false;
            _timer           = null;
            _windowTitle     = "";
            _renderProfile   = c.Param.RenderProfile;
            _terminal        = new XTerm(this, new JapaneseCharDecoder(_connection));

            GEnv.Connections.KeepAlive.SetTimerToConnectionTag(this);
        }
Ejemplo n.º 24
0
        /// <summary>
        /// 使用されているリソースに後処理を実行します。
        /// </summary>
        protected override void Dispose(bool disposing)
        {
            if (_profile != null)
            {
                _profile.Dispose();
                _profile = null;
            }

            if (disposing)
            {
                if (components != null)
                {
                    components.Dispose();
                }
            }
            base.Dispose(disposing);
        }
Ejemplo n.º 25
0
        /// <summary>
        /// Constructor without a default scene
        /// </summary>
        public Core(GameServiceContainer services)
            : base(services)
        {
#if XNA
            content = new ResourceContentManager(services, MeteorContentResource.ResourceManager);
#elif MONOGAME
            content = new ContentManager(services, "MeteorEngine.Content");
#endif
            renderStats = new RenderStats();

            currentRenderProfile = null;
            renderProfiles       = new List <RenderProfile>();
            debugString          = new StringBuilder(64, 64);

            // Setup rendering components
            cameras = new List <Camera>();
            scenes  = new Dictionary <String, Scene>();
        }
Ejemplo n.º 26
0
        public TerminalSettings() {
            IPoderosaCulture culture = TerminalEmulatorPlugin.Instance.PoderosaWorld.Culture;
            if (culture.IsJapaneseOS || culture.IsSimplifiedChineseOS || culture.IsTraditionalChineseOS || culture.IsKoreanOS)
                _encoding = EncodingType.UTF8;
            else
                _encoding = EncodingType.ISO8859_1;

            _terminalType = TerminalType.XTerm;
            _localecho = false;
            _lineFeedRule = LineFeedRule.Normal;
            _transmitnl = NewLine.CR;
            _renderProfile = null;
            _shellSchemeName = ShellSchemeCollection.DEFAULT_SCHEME_NAME;
            _enabledCharTriggerIntelliSense = false;
            _multiLogSettings = new MultiLogSettings();

            _listeners = new ListenerList<ITerminalSettingsChangeListener>();
        }
Ejemplo n.º 27
0
        private void DrawStringByOneChar2(IntPtr hdc, GWord word, int display_length, IntPtr bkbrush, float fx, int y, RenderProfile prof)
        {
            float pitch      = prof.Pitch.Width;
            int   nextoffset = WordNextOffset(word);

            if (bkbrush != IntPtr.Zero)            //これがないと日本語文字ピッチが小さいとき選択時のすきまができる場合がある
            {
                Win32.RECT rect = new Win32.RECT();
                rect.left   = (int)fx;
                rect.top    = y;
                rect.right  = (int)(fx + pitch * display_length);
                rect.bottom = y + (int)prof.Pitch.Height;
                Win32.FillRect(hdc, ref rect, bkbrush);
            }
            for (int i = word.Offset; i < nextoffset; i++)
            {
                char ch = _text[i];
                if (ch == '\0')
                {
                    break;
                }
                if (ch == GLine.WIDECHAR_PAD)
                {
                    continue;
                }
                unsafe {
                    Win32.TextOut(hdc, (int)fx, y, &ch, 1);
                }
                fx += pitch * CalcDisplayLength(ch);
            }
        }
Ejemplo n.º 28
0
        internal void Render(IntPtr hdc, RenderParameter param, RenderProfile prof, int y)
        {
            if (_text[0] == '\0')
            {
                return;                            //何も描かなくてよい
            }
            float fx = (float)param.TargetRect.Left;

            RectangleF rect = new RectangleF();

            rect.Y      = param.TargetRect.Top + y;
            rect.Height = prof.Pitch.Height;

            GWord word = _firstWord;

            while (word != null)
            {
                rect.X     = fx /*- prof.CharGap*/;             //Nativeな描画では不要?
                rect.Width = param.TargetRect.Right - rect.X;
                int ix = (int)rect.X;
                int iy = (int)rect.Y;

                TextDecoration dec = word.Decoration;

                //Brush brush = prof.CalcTextBrush(dec);
                uint   forecolorref = DrawUtil.ToCOLORREF(prof.CalcTextColor(dec));
                Color  bkcolor      = prof.CalcBackColor(dec);
                uint   bkcolorref   = DrawUtil.ToCOLORREF(bkcolor);
                IntPtr hfont        = prof.CalcHFONT_NoUnderline(dec, word.CharGroup);
                Win32.SelectObject(hdc, hfont);
                Win32.SetTextColor(hdc, forecolorref);
                Win32.SetBkColor(hdc, bkcolorref);
                Win32.SetBkMode(hdc, bkcolor == prof.BackColor? 1 : 2);               //基本背景色と一緒ならTRANSPARENT, 異なればOPAQUE
                IntPtr bkbrush = bkcolor == prof.BackColor? IntPtr.Zero : Win32.CreateSolidBrush(bkcolorref);

                int display_length = WordDisplayLength(word);
                if (word.Decoration == null)                //装飾なし
                //g.DrawString(WordText(word), font, brush, rect);
                {
                    DrawWord(hdc, ix, iy, word);
                }
                else
                {
                    //if(dec.Bold || (!prof.UsingIdenticalFont && word.CharGroup==CharGroup.TwoBytes))
                    if (dec.Bold || word.CharGroup == CharGroup.TwoBytes)                  //同じフォント指定でも日本語が半角の2倍でない場合あり。パフォーマンス問題はクリアされつつあるので確実に1文字ずつ描画
                    {
                        DrawStringByOneChar2(hdc, word, display_length, bkbrush, rect.X, iy, prof);
                    }
                    else
                    {
                        DrawWord(hdc, ix, iy, word);                         //いまやアホな描画エンジンの問題からは解放された!
                    }
                }
                //Debug.WriteLine("PW="+p.Pitch.Width+",TL="+(pb.Text.Length*p.Pitch.Width)+", real="+g.MeasureString(pb.Text, p.Font).Width);
                if (dec.Underline)
                {
                    DrawUnderline(hdc, forecolorref, ix, iy + (int)prof.Pitch.Height - 1, (int)(prof.Pitch.Width * display_length));
                }

                fx  += prof.Pitch.Width * display_length;
                word = word.Next;
                if (bkbrush != IntPtr.Zero)
                {
                    Win32.DeleteObject(bkbrush);
                }
            }
        }
Ejemplo n.º 29
0
        /// <summary>
        /// コンストラクタ
        /// </summary>
        /// <param name="prof">プロファイル</param>
        public ProfileEditForm(ConnectProfileStruct prof)
        {
            InitializeComponent();
            InitializeComponentValue();

            // オブジェクト初期値設定
            if (prof == null)
            {
                // 新規作成時はデフォルト値を設定
                _protocolBox.SelectedItem     = ConnectionMethod.SSH2;
                _portBox.Value                = ConnectProfileStruct.DEFAULT_SSH_PORT;
                _authTypeBox.SelectedItem     = AuthType.Password;
                _charCodeBox.SelectedItem     = EncodingType.UTF8;
                _newLineTypeBox.SelectedItem  = NewLine.CR;
                _telnetNewLineCheck.Checked   = true;
                _terminalTypeBox.SelectedItem = TerminalType.XTerm;
                _commandSendIntBox.Value      = ConnectProfileStruct.DEFAULT_CMD_SEND_INTERVAL;
                _promptRecvTimeoutBox.Value   = ConnectProfileStruct.DEFAULT_PROMPT_RECV_TIMEOUT;

                // コンソール表示オブジェクトはターミナルオプション値を反映
                _renderProfile = ConnectProfilePlugin.Instance.TerminalEmulatorService.TerminalEmulatorOptions.CreateRenderProfile();
            }
            else
            {
                // 編集時は対象プロファイル値を設定
                _hostNameBox.Text         = prof.HostName;
                _protocolBox.SelectedItem = prof.Protocol;
                _portBox.Value            = prof.Port;
                _authTypeBox.SelectedItem = prof.AuthType;
                _keyFileBox.Text          = prof.KeyFile;
                _userNameBox.Text         = prof.UserName;
                _passwordBox.Text         = prof.Password;
                _autoLoginCheck.Checked   = prof.AutoLogin;
                _loginPromptBox.Text      = prof.LoginPrompt;
                _passwordPromptBox.Text   = prof.PasswordPrompt;
                _execCommandBox.Text      = prof.ExecCommand;
                _suUserNameBox.Text       = prof.SUUserName;
                _suPasswordBox.Text       = prof.SUPassword;
                if (prof.SUType == _suTypeRadio1.Text)
                {
                    _suTypeRadio1.Checked = true;
                }
                else if (prof.SUType == _suTypeRadio2.Text)
                {
                    _suTypeRadio2.Checked = true;
                }
                else if (prof.SUType == _suTypeRadio3.Text)
                {
                    _suTypeRadio3.Checked = true;
                }
                else if (prof.SUType == _suTypeRadio4.Text)
                {
                    _suTypeRadio4.Checked = true;
                }
                _charCodeBox.SelectedItem             = prof.CharCode;
                _newLineTypeBox.SelectedItem          = prof.NewLine;
                _telnetNewLineCheck.Checked           = prof.TelnetNewLine;
                _terminalTypeBox.SelectedItem         = prof.TerminalType;
                _commandSendIntBox.Value              = prof.CommandSendInterval;
                _promptRecvTimeoutBox.Value           = prof.PromptRecvTimeout;
                _profileItemColorButton.SelectedColor = prof.ProfileItemColor;
                _descriptionBox.Text = prof.Description;
                _renderProfile       = ConnectProfilePlugin.Instance.TerminalEmulatorService.TerminalEmulatorOptions.CreateRenderProfile();
                _renderProfile       = prof.RenderProfile;
            }

            _Initialized = true;
            EnableValidControls(this, EventArgs.Empty);
        }
 private void OnSetToDefault(object sender, EventArgs args)
 {
     _profile = ConnectProfilePlugin.Instance.TerminalEmulatorService.TerminalEmulatorOptions.CreateRenderProfile();
     InitUI();
 }
Ejemplo n.º 31
0
 //Listener以外を持ってくる
 public virtual void Import(ITerminalSettings src)
 {
     _encoding = src.Encoding;
     _terminalType = src.TerminalType;
     _localecho = src.LocalEcho;
     _lineFeedRule = src.LineFeedRule;
     _transmitnl = src.TransmitNL;
     _caption = src.Caption;
     _icon = src.Icon;
     TerminalSettings src_r = (TerminalSettings)src;
     _shellSchemeName = src_r._shellSchemeName; //ちょっとインチキ
     if (src_r._shellScheme != null) {
         _shellScheme = src_r._shellScheme;
         TerminalEmulatorPlugin.Instance.ShellSchemeCollection.AddDynamicChangeListener(this);
     }
     _enabledCharTriggerIntelliSense = src.EnabledCharTriggerIntelliSense;
     _renderProfile = src.RenderProfile == null ? null : (RenderProfile)src.RenderProfile.Clone();
     _multiLogSettings = src.LogSettings == null ? null : (IMultiLogSettings)_multiLogSettings.Clone();
 }
Ejemplo n.º 32
0
        internal void Render(IntPtr hdc, RenderProfile prof, Color baseBackColor, int x, int y)
        {
            if (_text.Length == 0 || _text[0] == '\0')
            {
                return; //何も描かなくてよい。これはよくあるケース
            }
            float fx0 = (float)x;
            float fx1 = fx0;
            int   y1  = y;
            int   y2  = y1 + (int)prof.Pitch.Height;

            float pitch = prof.Pitch.Width;
            int   defaultBackColorArgb = baseBackColor.ToArgb();

            Win32.SetBkMode(hdc, Win32.TRANSPARENT);

            GWord word = _firstWord;

            while (word != null)
            {
                TextDecoration dec = word.Decoration;

                IntPtr hFont = prof.CalcHFONT_NoUnderline(dec, word.CharGroup);
                Win32.SelectObject(hdc, hFont);

                uint foreColorRef = DrawUtil.ToCOLORREF(prof.CalcTextColor(dec));
                Win32.SetTextColor(hdc, foreColorRef);

                Color bkColor  = prof.CalcBackColor(dec);
                bool  isOpaque = (bkColor.ToArgb() != defaultBackColorArgb);
                if (isOpaque)
                {
                    uint bkColorRef = DrawUtil.ToCOLORREF(bkColor);
                    Win32.SetBkColor(hdc, bkColorRef);
                }

                int nextOffset = GetNextOffset(word);

                float fx2 = fx0 + pitch * nextOffset;

                if (prof.CalcBold(dec) || CharGroupUtil.IsCJK(word.CharGroup))
                {
                    // It is not always true that width of a character in the CJK font is twice of a character in the ASCII font.
                    // Characters are drawn one by one to adjust pitch.

                    int   step      = CharGroupUtil.GetColumnsPerCharacter(word.CharGroup);
                    float charPitch = pitch * step;
                    int   offset    = word.Offset;
                    float fx        = fx1;
                    if (isOpaque)
                    {
                        // If background fill is required, we call ExtTextOut() with ETO_OPAQUE to draw the first character.
                        if (offset < nextOffset)
                        {
                            Win32.RECT rect = new Win32.RECT((int)fx1, y1, (int)fx2, y2);
                            char       ch   = _text[offset];
                            Debug.Assert(ch != GLine.WIDECHAR_PAD);
                            unsafe {
                                Win32.ExtTextOut(hdc, rect.left, rect.top, Win32.ETO_OPAQUE, &rect, &ch, 1, null);
                            }
                        }
                        offset += step;
                        fx     += charPitch;
                    }

                    for (; offset < nextOffset; offset += step)
                    {
                        char ch = _text[offset];
                        Debug.Assert(ch != GLine.WIDECHAR_PAD);
                        unsafe {
                            Win32.ExtTextOut(hdc, (int)fx, y1, 0, null, &ch, 1, null);
                        }
                        fx += charPitch;
                    }
                }
                else
                {
                    int offset        = word.Offset;
                    int displayLength = nextOffset - offset;
                    if (isOpaque)
                    {
                        Win32.RECT rect = new Win32.RECT((int)fx1, y1, (int)fx2, y2);
                        unsafe
                        {
                            fixed(char *p = &_text[offset])
                            {
                                Win32.ExtTextOut(hdc, rect.left, rect.top, Win32.ETO_OPAQUE, &rect, p, displayLength, null);
                            }
                        }
                    }
                    else
                    {
                        unsafe
                        {
                            fixed(char *p = &_text[offset])
                            {
                                Win32.ExtTextOut(hdc, (int)fx1, y1, 0, null, p, displayLength, null);
                            }
                        }
                    }
                }

                if (dec.Underline)
                {
                    DrawUnderline(hdc, foreColorRef, (int)fx1, y2 - 1, (int)fx2 - (int)fx1);
                }

                fx1  = fx2;
                word = word.Next;
            }
        }
 public Size CalcTerminalSize(RenderProfile prof)
 {
     SizeF charPitch = prof.Pitch;
     Win32.SystemMetrics sm = GEnv.SystemMetrics;
     int width = (int)Math.Floor((float)(this.ClientSize.Width - sm.ScrollBarWidth - CharacterDocumentViewer.BORDER * 2) / charPitch.Width);
     int height = (int)Math.Floor((float)(this.ClientSize.Height - CharacterDocumentViewer.BORDER * 2 + prof.LineSpacing) / (charPitch.Height + prof.LineSpacing));
     if (width <= 0)
         width = 1; //�ɒ[�ȃ��T�C�Y�����ƕ��̒l�ɂȂ邱�Ƃ�����
     if (height <= 0)
         height = 1;
     return new Size(width, height);
 }
 public void ApplyRenderProfile(RenderProfile prof)
 {
     if (this.EnabledEx) {
         this.BackColor = prof.BackColor;
         Size ts = CalcTerminalSize(prof);
         if (!IsConnectionClosed() && (ts.Width != GetDocument().TerminalWidth || ts.Height != GetDocument().TerminalHeight)) {
             ResizeTerminal(ts.Width, ts.Height);
         }
         Invalidate();
     }
 }
 /// <summary>
 /// 表示オプションボタンクリックイベント
 /// </summary>
 private void _editRenderButton_Click(object sender, EventArgs e)
 {
     EditRenderProfile dlg = new EditRenderProfile(_renderProfile);
     if (dlg.ShowDialog() == DialogResult.OK) {
         _renderProfile = dlg.Result;
     }
 }
Ejemplo n.º 36
0
        /// <summary>
        /// Wires up a PowerShell runspace created via <see cref="RunspaceFactory.CreateRunspace()"/> to the terminal to display the PowerShell to the user.
        /// </summary>
        public override void Connect()
        {
            _progressBar.Value  = 0;
            _progressLabel.Text = "";

            // This is not strictly a network connection:  we're relaying information that we receive from the runspace to the terminal over a local stream
            // (a StreamConnection in this case)
            ITerminalParameter terminalParam = new EmptyTerminalParameter();
            StreamConnection   connection    = new StreamConnection(terminalParam)
            {
                Capture = false
            };

            // Attach the new "connection" to the terminal control
            try
            {
                ITerminalSettings terminalSettings = PoderosaTerminalEmulatorService.CreateDefaultTerminalSettings(Connection.DisplayName, null);
                TerminalSession   session          = new TerminalSession(connection, terminalSettings);
                SessionHost       sessionHost      = new SessionHost(PoderosaSessionManagerPlugin, session);
                TerminalView      terminalView     = new TerminalView(null, _terminal);
                RenderProfile     renderProfile    = new RenderProfile(_terminal.GetRenderProfile());

                renderProfile.BackColor = Connection.BackgroundColor;
                renderProfile.ForeColor = Connection.TextColor;
                renderProfile.FontName  = Connection.FontFamily;
                renderProfile.FontSize  = Connection.FontSize;

                session.TerminalSettings.BeginUpdate();
                session.TerminalSettings.RenderProfile = renderProfile;
                session.TerminalSettings.EndUpdate();

                _terminal.Attach(session);

                session.InternalStart(sessionHost);
                session.InternalAttachView(sessionHost.DocumentAt(0), terminalView);

                _powerShellHost = new PowerShellHost(this, _terminal, connection, ExecuteQuiet, _progressBar, _progressLabel);

                // Create the host and runspace instances for this interpreter.  If we're connecting to the local host, don't bother with the connection info.
                // ReSharper disable StringCompareIsCultureSpecific.3
                if (String.Compare(Connection.Host, "localhost", true) != 0 && Connection.Host != "127.0.0.1" &&
                    String.Compare(Connection.Host, Environment.MachineName, true) != 0)
                // ReSharper restore StringCompareIsCultureSpecific.3
                {
                    WSManConnectionInfo connectionInfo = new WSManConnectionInfo
                    {
                        ComputerName = Connection.Host
                    };

                    if (!String.IsNullOrEmpty(Connection.InheritedUsername))
                    {
                        connectionInfo.Credential = new PSCredential(Connection.InheritedUsername, Connection.InheritedPassword);
                    }

                    Runspace = RunspaceFactory.CreateRunspace(_powerShellHost, connectionInfo);
                }

                else
                {
                    Runspace = RunspaceFactory.CreateRunspace(_powerShellHost);
                }

                Runspace.Open();
            }

            catch (Exception e)
            {
                OnConnectionLost(this, new ErrorEventArgs(e));
                return;
            }

            // Start capturing input from the prompt via the input loop
            _inputThread = new Thread(InputLoop)
            {
                Name = "PowerShellConnectionForm Input Thread"
            };
            _inputThread.Start();

            ParentForm.Closing += ParentForm_Closing;

            OnConnected(this, null);
        }
 public CommandResultSession(CommandResultDocument doc, RenderProfile prof) {
     _document = doc;
     _renderProfile = prof;
 }
Ejemplo n.º 38
0
        public RenderProfile CreateRenderProfile() {
            //起動の高速化のため、フォントの作成は遅延評価
            RenderProfile p = new RenderProfile();
            p.FontName = _fontName.Value;
            p.CJKFontName = _cjkFontName.Value;
            p.FontSize = GetFontSizeAsFloat();
            p.UseClearType = _useClearType.Value;
            p.EnableBoldStyle = _enableBoldStyle.Value;
            p.ForceBoldStyle = _forceBoldStyle.Value;
            p.LineSpacing = _lineSpacing.Value;
            p.ESColorSet = (EscapesequenceColorSet)this.EscapeSequenceColorSet.Clone();
            p.DarkenEsColorForBackground = this.DarkenEsColorForBackground;

            p.ForeColor = _textColor.Value;
            p.BackColor = _bgColor.Value;
            p.BackgroundImageFileName = _backgroundImageFileName.Value;
            p.ImageStyle = _imageStyle.Value;

            return p;
        }
 // --------------------------------------------------------------------
 // 表示プロファイルの更新
 // --------------------------------------------------------------------
 /// <summary>
 /// ターミナルセッションの表示プロファイルを更新します。
 /// </summary>
 /// <param name="renderProfile"></param>
 public void UpdateRenderProfile(RenderProfile renderProfile)
 {
     #if DEBUG
     WriteLog("ターミナルセッションの表示プロファイルを更新します。");
     #endif
     if (_session != null)
     {
         _session.TerminalSettings.BeginUpdate();
         _session.TerminalSettings.RenderProfile = renderProfile;
         _session.TerminalSettings.EndUpdate();
     }
 }