public CommandResult NewSFUConnectionWithDialog(SFUTerminalParam param)
        {
            if (!CheckPaneCount())
            {
                return(CommandResult.Denied);
            }

            if (SFUUtil.GuessRootDirectory().Length == 0)
            {
                return(CommandResult.Failed);
            }

            LocalShellLoginDialog dlg = new LocalShellLoginDialog();

            if (param != null)
            {
                dlg.ApplyParam(param);
            }
            else
            {
                dlg.ApplyParam(GApp.ConnectionHistory.TopSFUParam);
            }

            if (GCUtil.ShowModalDialog(_frame, dlg) == DialogResult.OK)
            {
                ConnectionTag con = dlg.Result;
                if (con != null)
                {
                    AddNewTerminal(con);
                    return(CommandResult.Success);
                }
            }

            return(CommandResult.Cancelled);
        }
示例#2
0
        private void InitTerminalPane(ConnectionTag ct)
        {
            this._terminalPane.Dock        = DockStyle.Fill;
            this._terminalPane.ForeColor   = this.ForeColor;
            this._terminalPane.BackColor   = this.BackColor;
            this._terminalPane.FakeVisible = true;
            this._terminalPane.Attach(ct);
            ct.Receiver.Listen();

            if (this._terminalPane.Connection != null)
            {
                statusText.Visible = false;

                this.Controls.Add(this._terminalPane);

                if (this._terminalPane.Connection != null)
                {
                    this._terminalPane.Connection.ClosedEvent += Connection_ClosedEvent;
                }

                OnConnected?.Invoke(this, new EventArgs());
            }
            else
            {
                statusText.Visible = true;
                statusText.Text    = "连接已断开";

                OnDisconnected?.Invoke(this, new EventArgs());
            }
        }
示例#3
0
        public CommandResult ClearScreen()
        {
            ConnectionTag    tag = GEnv.Connections.FindTag(_connection);
            TerminalDocument doc = tag.Document;

            lock (doc) {
                GLine l      = doc.TopLine;
                int   top_id = l.ID;
                int   limit  = l.ID + _connection.TerminalHeight;
                while (l != null && l.ID < limit)
                {
                    l.Clear();
                    l = l.NextLine;
                }
                doc.CurrentLineNumber = top_id;
                doc.CaretColumn       = 0;
                doc.InvalidateAll();
                if (tag.Pane != null)
                {
                    GEnv.TextSelection.Clear();
                    tag.Pane.Invalidate();
                }
            }
            return(CommandResult.Success);
        }
示例#4
0
        public void SetActiveTab(ConnectionTag active)
        {
            TabBarButton b;

            foreach (ConnectionTag ct in GEnv.Connections)
            {
                b = ct.Button as TabBarButton;
                if (active == ct)
                {
                    b.BackColor = _activeTabColor;
                    b.Font      = _activeTabFont;
                    b.Selected  = true;
                    if (GApp.Options.TabBarStyle == TabBarStyle.ScrollButton)
                    {
                        if (!b.Visible)
                        {
                            int index = GEnv.Connections.IndexOf(ct);
                            if (index != -1)
                            {
                                EnsureButtonVisible(index);
                            }
                        }
                    }
                }
                else
                {
                    b.BackColor = SystemColors.Control;
                    b.Font      = _basicFont;
                    b.Selected  = false;
                }
                b.Invalidate();
            }
        }
示例#5
0
        private void SetButtonText(TabBarButton btn, int index, ConnectionTag tag)
        {
            btn.HeadText = (index + 1).ToString();
            string t = tag.FormatTabText();

            btn.Text = (t == null || t.Length == 0)? " " : t;         //テキストなしだとHeadTextもなくなってしまうのでやむなく回避
        }
示例#6
0
        public void AddTab(ConnectionTag ct)
        {
            Control b = CreateNewButton(ct);

            Controls.Add(b);
            if (GApp.Options.TabBarStyle == TabBarStyle.ScrollButton)
            {
                int width = GetTabAreaWidth();
                int index = GEnv.Connections.Count;
                while (width > 0 && index > 0)
                {
                    index--;
                    width -= GetNecessaryButtonWidth(GEnv.Connections.TagAt(index));
                }
                index++;
                if (index >= GEnv.Connections.Count)
                {
                    index = GEnv.Connections.Count - 1;
                }
                if (index < 0)
                {
                    index = 0;
                }
                _scrollButtonOffset = index;
            }
            ArrangeButtons();
        }
 public void CloseConnection(ConnectionTag tag)
 {
     _connection = tag.Connection;
     lock (this) {
         SendMessageCore(CService.CloseConnection);
     }
 }
 public void ActivateConnection(ConnectionTag tag)
 {
     lock (this) {
         _connection = tag.Connection;
         SendMessageCore(CService.ActivateConnection);
     }
 }
示例#9
0
            public void AsyncConnect()
            {
                bool success = false;

                _asyncThread = Thread.CurrentThread;
                try {
                    ConnectionTag result = Connect();
                    result.ChildProcess = _process;
                    success             = true;
                    if (!_interrupted)
                    {
                        _client.SuccessfullyExit(result);
                    }
                }
                catch (Exception ex) {
                    if (!_interrupted)
                    {
                        _client.ConnectionFailed(ex.Message);
                    }
                }
                finally {
                    if (!success && _process != null)
                    {
                        _process.Kill();
                    }
                }
            }
        public override CommandResult Paste()
        {
            string value = (string)Clipboard.GetDataObject().GetData("Text");

            if (value == null || value.Length == 0)
            {
                return(CommandResult.Ignored);
            }

            ConnectionTag ct = GEnv.Connections.FindTag(_connection);

            if (ct.ModalTerminalTask != null)
            {
                return(CommandResult.Denied);
            }

            if (value.Length > 0x1000)
            {
                SendingLargeText dlg = new SendingLargeText(new PasteProcessor(ct, value));
                if (GCUtil.ShowModalDialog(GApp.Frame, dlg) == DialogResult.OK)
                {
                    return(CommandResult.Success);
                }
                else
                {
                    return(CommandResult.Cancelled);
                }
            }
            else
            {
                return(PasteMain(value));
            }
        }
示例#11
0
 private Bitmap GetTabIcon(ConnectionTag tag)
 {
     if (_tabIconDefault == null)
     {
         _tabIconDefault = (Bitmap)IconList.LoadIcon(IconList.ICON_NEWCONNECTION);
         _tabIconSerial  = (Bitmap)IconList.LoadIcon(IconList.ICON_SERIAL);
         _tabIconCygwin  = (Bitmap)IconList.LoadIcon(IconList.ICON_CYGWIN);
         _tabIconSFU     = (Bitmap)IconList.LoadIcon(IconList.ICON_SFU);
     }
     if (tag.Connection.Param is SFUTerminalParam)
     {
         return(_tabIconSFU);
     }
     else if (tag.Connection.Param is CygwinTerminalParam)
     {
         return(_tabIconCygwin);
     }
     else if (tag.Connection.Param is SerialTerminalParam)
     {
         return(_tabIconSerial);
     }
     else
     {
         return(_tabIconDefault);
     }
 }
示例#12
0
 public void ClearTimerToConnectionTag(ConnectionTag ct)
 {
     if (ct.Timer != null)
     {
         ct.Timer.Dispose();
         ct.Timer = null;
     }
 }
示例#13
0
        public PasteProcessor(ConnectionTag tag, string text)
        {
            _tag = tag;
            StringReader r = new StringReader(text);

            Fill(r);
            r.Close();
        }
示例#14
0
        public XModemSender(ConnectionTag tag, string filename) : base(tag, filename)
        {
            _body = new byte[new FileInfo(filename).Length];
            FileStream strm = new FileStream(filename, FileMode.Open, FileAccess.Read);

            strm.Read(_body, 0, _body.Length);
            strm.Close();
        }
示例#15
0
        public VT100Terminal(ConnectionTag tag, ICharDecoder decoder) : base(tag, decoder)
        {
            _insertMode           = false;
            _scrollRegionRelative = false;
            bool sfu = tag.Connection.Param is SFUTerminalParam;

            _homePositionOnCSIJ2 = sfu;
        }
 public void SetPanePosition(ConnectionTag tag, PanePosition pos)
 {
     lock (this) {
         _connection = tag.Connection;
         _destinationPanePosition = pos;
         SendMessageCore(CService.SetPanePosition);
     }
 }
示例#17
0
        private static StringBuilder Flush(ConnectionTag tag, StringBuilder buf)
        {
            char[] data = buf.ToString().ToCharArray();
            tag.Terminal.Input(data, 0, data.Length);
            tag.Pane.DataArrived();

            return(new StringBuilder());
        }
示例#18
0
        public CommandResult SelectAll()
        {
            ConnectionTag tag = GEnv.Connections.FindTag(_connection);

            GEnv.TextSelection.SelectAll(tag.Pane);
            tag.Pane.AsControl().Invalidate();
            return(CommandResult.Success);
        }
        public CommandResult SetEncoding(EncodingProfile enc)
        {
            ConnectionTag ct = GEnv.Connections.FindTag(_connection);

            _connection.Param.EncodingProfile = enc;
            ct.Terminal.Reset();
            GApp.Frame.AdjustTerminalUI(true, ct);
            return(CommandResult.Success);
        }
示例#20
0
        protected override void Negotiate()
        {
            TelnetNegotiator         neg = new TelnetNegotiator(_param, _size.Width, _size.Height);
            TelnetTerminalConnection r   = new TelnetTerminalConnection(_param, neg, new PlainGuevaraSocket(_socket), _size.Width, _size.Height);

            r.UsingSocks = _socks != null;
            r.SetServerInfo(_param.Host, this.IPAddress);
            _result = new ConnectionTag(r);
        }
 public override CommandResult SetConnectionLocation(ConnectionTag ct, TerminalPane pane)
 {
     if (ct.AttachedPane == pane)
     {
         return(CommandResult.Ignored);
     }
     _frame.PaneContainer.SetConnectionLocation(ct, pane);
     return(CommandResult.Success);
 }
        //TerminalConnection
        protected override void AddNewTerminalInternal(ConnectionTag con)
        {
            GApp.ConnectionHistory.Update(con.Connection.Param);
            _frame.AddConnection(con);
            _frame.AdjustMRUMenu();

            ActivateConnection(con.Connection);
            _frame.RefreshConnection(con);
        }
示例#23
0
 /// <summary>
 /// 操作の対象になるドキュメントと文字のエンコーディングを指定して構築
 /// </summary>
 public AbstractTerminal(ConnectionTag tag, ICharDecoder decoder)
 {
     _tag               = tag;
     _decoder           = decoder;
     _terminalMode      = TerminalMode.Normal;
     _currentdecoration = TextDecoration.Default;
     _manipulator       = new GLineManipulator(80);
     _bufferForMacro    = new StringBuilder();
     _signalForMacro    = new AutoResetEvent(false);
 }
示例#24
0
        /// <summary>
        /// The method to get all connection tags
        /// </summary>
        /// <returns>a list with all connection tags</returns>
        public static async Task <List <string> > GetAllTags()
        {
            HttpClient client = new HttpClient();

            var    url          = string.Format(_baseUrl + "/get_all_tags");
            string jsonResponse = await client.GetStringAsync(url);

            ConnectionTag tags = JsonConvert.DeserializeObject <ConnectionTag>(jsonResponse);

            return(tags.tags);
        }
示例#25
0
        private static void OnTimer(object state)
        {
            ConnectionTag ct = (ConnectionTag)state;

            if (!ct.Connection.IsClosed)
            {
                //Debug.WriteLine("Send KA " + ct.Button.Text + ";"+DateTime.Now.ToString());
                ct.Connection.SendKeepAliveData();
                ct.Timer.Change(GEnv.Options.KeepAliveInterval, Timeout.Infinite);
            }
        }
示例#26
0
        public void RefreshConnection(ConnectionTag tag)
        {
            TerminalDocument doc = tag.Document;

            Monitor.Exit(doc);
            lock (this) {
                _connection = tag.Connection;
                SendMessageCore(Service.RefreshConnection);
            }
            Monitor.Enter(doc);
        }
示例#27
0
        public CommandResult Close()
        {
            try {
                _connection.Disconnect();
                _connection.Close();
            }
            catch (Exception ex) {
                //ここでエラーが発生しても処理は続行してアプリ自体は実行を継続
                GUtil.Warning(GEnv.Frame, GEnv.Strings.GetString("Message.ConnectionCommandTarget.CloseError") + ex.Message);
            }
            bool          active = _connection == GEnv.Connections.ActiveConnection;
            ConnectionTag ct     = GEnv.Connections.FindTag(_connection);

            //Debug.WriteLine("ct==null? " + (ct==null));
            if (ct == null)
            {
                return(CommandResult.Ignored);
            }

            TerminalPane pane = ct.AttachedPane;

            ct.IsTerminated = true;
            GEnv.Frame.RemoveConnection(ct);
            ConnectionTag next = GEnv.Connections.GetCandidateOfActivation(ct.PositionIndex, ct);

            GEnv.Connections.Remove(_connection);
            if (next != null)
            {
                if (pane != null)
                {
                    pane.Attach(next);
                }
                if (active)
                {
                    GEnv.Frame.ActivateConnection(next);                     //もともとアクティブでない接続が切れたときは変更しない
                }
            }
            else
            {
                if (pane != null)
                {
                    pane.FakeVisible = false;
                    pane.Detach();
                }
                GEnv.Frame.RefreshConnection(null);
            }

            if (GEnv.Options.QuitAppWithLastPane && GEnv.Connections.Count == 0)
            {
                GEnv.Frame.AsForm().Close();
            }

            return(CommandResult.Success);
        }
示例#28
0
        public static void EmulateWithLog(string filename, ConnectionTag tag)
        {
            _filename = filename;
            _tag      = tag;
            //XmlTextReader r = new XmlTextReader(filename);
            //EmulateWithLog(r, tag);
            //r.Close();
            Thread th = new Thread(new ThreadStart(Run));

            th.Start();
        }
示例#29
0
        public void RefreshConnection(ConnectionTag tag)
        {
            if (tag.Button == null)
            {
                return;
            }

            SetButtonText(tag.Button as TabBarButton, GEnv.Connections.IndexOf(tag), tag);
            ((TabBarButton)tag.Button).Image = GetTabIcon(tag);

            _tabToolTip.SetToolTip(tag.Button, tag.FormatFrameText());
        }
        public CommandResult SetFocusToActiveConnection()
        {
            ConnectionTag tag = GEnv.Connections.ActiveTag;

            if (tag == null || tag.AttachedPane == null)
            {
                return(CommandResult.Ignored);
            }
            //アクティブにしたときにクラッシュするのはこのFocus呼び出しが濃厚。ここはGFrame.OnActivatedから呼ばれている
            //tag.AttachedPane.AsControl().Focus(); //タイトルバーをクリックするなどするとペインにフォーカスがない
            return(CommandResult.Success);
        }
示例#31
0
 internal static ConnectionCommandTarget GetConnectionCommandTarget(ConnectionTag tag) {
     return new ConnectionCommandTarget(tag.Connection);
 }