コード例 #1
0
ファイル: UserEditor.cs プロジェクト: kostejnv/TCGSync
        /// <summary>
        /// Get user google token and replace it with temporally
        /// </summary>
        private void ChangeGoogleToken()
        {
            if (!WasGLogin)
            {
                return;
            }
            string tokenDir = GUtil.TokenDirectory;

            GUtil.RemoveGoogleToken(OldUser);
            try
            {
                string[] files      = Directory.GetFiles(tempDir);
                var      tokenNames = files.Where(f => f.Contains(ChangingUser.Username));
                if (tokenNames.ToList().Count != 0)
                {
                    string tokenNameFullPath = files.Where(f => f.Contains(ChangingUser.Username)).First();
                    string tokenName         = tokenNameFullPath.Substring(tempDir.Length + 1);
                    File.Copy(tokenNameFullPath, Path.Combine(tokenDir, tokenName));
                }
            }
            catch (IOException e)
            {
                MessageBox.Show(string.Format("Token does not add, because '{0}', please try login to Google again", e.Message), "Error", MessageBoxButtons.OK);
                Form.GoogleButton.BackColor = System.Drawing.Color.OrangeRed;
                throw new InvalidOperationException();
            }
        }
コード例 #2
0
        private void InitUI()
        {
            for (int i = 1; i <= GApp.Options.SerialCount; i++)
            {
                _portBox.Items.Add(String.Format("COM{0}", i));
            }

            StringCollection c = GApp.ConnectionHistory.LogPaths;

            foreach (string p in c)
            {
                _logFileBox.Items.Add(p);
            }

            if (GApp.Options.DefaultLogType != LogType.None)
            {
                _logTypeBox.SelectedIndex = (int)GApp.Options.DefaultLogType;
                string t = GUtil.CreateLogFileName(null);
                _logFileBox.Items.Add(t);
                _logFileBox.Text = t;
            }
            else
            {
                _logTypeBox.SelectedIndex = 0;
            }

            AdjustUI();
        }
コード例 #3
0
ファイル: UserEditor.cs プロジェクト: kostejnv/TCGSync
        /// <summary>
        /// multithreading method to login google account
        /// </summary>
        /// <returns>true if successful</returns>
        public bool GoogleLogin()
        {
            RemoveTemp();
            if (ChangingUser.Username == null)
            {
                throw new InvalidOperationException("This operation is without UserName not supported");
            }

            //login
            GUtil.GLogin(ChangingUser, "temp");
            WasGLogin = true;

            //multithreading change of CalendarsBox
            var calendars = GUtil.GetCalendars(ChangingUser, tempDir);

            Form.CalendarsBox.Invoke(new Action(() => Form.CalendarsBox.Items.Clear()));
            foreach (var calendar in calendars)
            {
                Form.CalendarsBox.Invoke(new Action(() => Form.CalendarsBox.Items.Add(calendar)));
            }
            Form.CalendarsBox.Invoke(new Action(() => Form.CalendarsBox.SelectedIndex = -1));
            Form.CalendarsBox.Invoke(new Action(() => Form.CalendarsBox.Text          = "(select)"));
            Form.EmailLabel.Invoke(new Action(() => Form.EmailLabel.Text = GetGoogleEmail()));

            return(true);
        }
コード例 #4
0
        /// <summary>
        /// check if all data are correct and get user
        /// </summary>
        /// <returns></returns>
        public User GetUser()
        {
            if (!WasTCVerify)
            {
                throw new InvalidOperationException("Time Cockpit verifying was not successful");
            }
            if (!WasGLogin)
            {
                throw new InvalidOperationException("Google Login was not successful");
            }
            if (!WaSSetSetting)
            {
                throw new InvalidOperationException("Setting was not filled");
            }

            //Check if new user with same Timecockpit credentials was added meanwhile set setting
            if (DataDatabase.ExistsUser(NewUser.Username))
            {
                throw new InvalidOperationException("There is the same username in database! Time Cockpit username is unique parameter and therefore it cannot be use more than once.");
            }

            NewUser.GoogleEmail = GUtil.GetEmail(NewUser);
            Synchronization.SyncNow();

            return(NewUser);
        }
コード例 #5
0
        public static Connector AsyncPrepareSocket(ISocketWithTimeoutClient client, LocalShellTerminalParam param)
        {
            Connector c = new Connector(param, client);

            GUtil.CreateThread(new ThreadStart(c.AsyncConnect)).Start();
            return(c);
        }
コード例 #6
0
ファイル: Command.cs プロジェクト: weltmeyer/terminalcontrol
        public void Load(ConfigNode parent)
        {
            InitCommands();
            InitFixedCommands();

            ConfigNode node = parent.FindChildConfigNode("key-definition");

            if (node != null)
            {
                IDictionaryEnumerator ie = node.GetPairEnumerator();
                while (ie.MoveNext())
                {
                    CID id = (CID)GUtil.ParseEnum(typeof(CID), (string)ie.Key, CID.NOP);
                    if (id == CID.NOP)
                    {
                        continue;
                    }
                    string value = (string)ie.Value;
                    Entry  e     = FindEntry(id);
                    Keys   t     = GUtil.ParseKey(value.Split(','));
                    e.Modifiers = t & Keys.Modifiers;
                    e.Key       = t & Keys.KeyCode;
                }
            }
        }
コード例 #7
0
        public static ConnectionTag CreateNewSerialConnection(IWin32Window parent, SerialTerminalParam param)
        {
            bool       successful = false;
            FileStream strm       = null;

            try {
                string portstr = String.Format("\\\\.\\COM{0}", param.Port);
                IntPtr ptr     = Win32.CreateFile(portstr, Win32.GENERIC_READ | Win32.GENERIC_WRITE, 0, IntPtr.Zero, Win32.OPEN_EXISTING, Win32.FILE_ATTRIBUTE_NORMAL | Win32.FILE_FLAG_OVERLAPPED, IntPtr.Zero);
                if (ptr == Win32.INVALID_HANDLE_VALUE)
                {
                    string msg = GEnv.Strings.GetString("Message.CommunicationUtil.FailedToOpenSerial");
                    int    err = Win32.GetLastError();
                    if (err == 2)
                    {
                        msg += GEnv.Strings.GetString("Message.CommunicationUtil.NoSuchDevice");
                    }
                    else if (err == 5)
                    {
                        msg += GEnv.Strings.GetString("Message.CommunicationUtil.DeviceIsBusy");
                    }
                    else
                    {
                        msg += "\nGetLastError=" + Win32.GetLastError();
                    }
                    throw new Exception(msg);
                }
                //strm = new FileStream(ptr, FileAccess.Write, true, 8, true);
                Win32.DCB dcb = new Win32.DCB();
                FillDCB(ptr, ref dcb);
                UpdateDCB(ref dcb, param);

                if (!Win32.SetCommState(ptr, ref dcb))
                {
                    throw new Exception(GEnv.Strings.GetString("Message.CommunicationUtil.FailedToConfigSerial"));
                }
                Win32.COMMTIMEOUTS timeouts = new Win32.COMMTIMEOUTS();
                Win32.GetCommTimeouts(ptr, ref timeouts);
                timeouts.ReadIntervalTimeout         = 0xFFFFFFFF;
                timeouts.ReadTotalTimeoutConstant    = 0;
                timeouts.ReadTotalTimeoutMultiplier  = 0;
                timeouts.WriteTotalTimeoutConstant   = 100;
                timeouts.WriteTotalTimeoutMultiplier = 100;
                Win32.SetCommTimeouts(ptr, ref timeouts);
                successful = true;
                System.Drawing.Size      sz = GEnv.Frame.TerminalSizeForNextConnection;
                SerialTerminalConnection r  = new SerialTerminalConnection(param, ptr, sz.Width, sz.Height);
                r.SetServerInfo("COM" + param.Port, null);
                return(new ConnectionTag(r));
            }
            catch (Exception ex) {
                GUtil.Warning(parent, ex.Message);
                return(null);
            }
            finally {
                if (!successful && strm != null)
                {
                    strm.Close();
                }
            }
        }
コード例 #8
0
        private void OnAllocateKey(object sender, EventArgs args)
        {
            StringResource sr = OptionDialogPlugin.Instance.Strings;

            if (_keyConfigList.SelectedItems.Count == 0)
            {
                return;
            }

            IGeneralCommand cmd = _keyConfigList.SelectedItems[0].Tag as IGeneralCommand;

            Debug.Assert(cmd != null);
            Keys key = _hotKey.Key;

            IGeneralCommand existing = _keybinds.FindCommand(key);

            if (existing != null && existing != cmd)   //別コマンドへの割当があったら
            {
                if (GUtil.AskUserYesNo(this, String.Format(sr.GetString("Message.OptionDialog.AskOverwriteCommand"), existing.Description)) == DialogResult.No)
                {
                    return;
                }

                _keybinds.SetKey(existing, Keys.None); //既存のやつに割当をクリア
                FindItemFromTag(existing).SubItems[2].Text = "";
            }

            //設定を書き換え
            _keybinds.SetKey(cmd, key);
            _keyConfigList.SelectedItems[0].SubItems[2].Text = FormatKey(key);
        }
コード例 #9
0
ファイル: SSHOptionPanel.cs プロジェクト: sunxking/poderosa
        public bool Commit(IProtocolOptions options, IKeyAgentOptions agent)
        {
            StringResource sr = OptionDialogPlugin.Instance.Strings;

            //暗号アルゴリズム順序はoptionsを直接いじっているのでここでは何もしなくてよい
            try {
                options.HostKeyAlgorithmOrder = GetHostKeyAlgorithmOrder();

                try {
                    options.SSHWindowSize = Int32.Parse(_windowSizeBox.Text);
                }
                catch (FormatException) {
                    GUtil.Warning(this, sr.GetString("Message.OptionDialog.InvalidWindowSize"));
                    return(false);
                }

                options.SSHCheckMAC          = _sshCheckMAC.Checked;
                options.CipherAlgorithmOrder = GetCipherAlgorithmOrder();
                options.LogSSHEvents         = _sshEventLog.Checked;

                return(true);
            }
            catch (Exception ex) {
                GUtil.Warning(this, ex.Message);
                return(false);
            }
        }
コード例 #10
0
        /// <summary>
        /// store user setting
        /// </summary>
        /// <param name="pastSyncInterval"></param>
        /// <param name="isFutureSpecified"></param>
        /// <param name="futureSyncInterval"></param>
        public void SetSetting(int pastSyncInterval, bool isFutureSpecified, int futureSyncInterval)
        {
            NewUser.PastSyncInterval   = pastSyncInterval;
            NewUser.IsFutureSpecified  = isFutureSpecified;
            NewUser.FutureSyncInterval = futureSyncInterval;

            // if user want to create new calendar
            if (Form.NewCalendarBox.Text != "")
            {
                NewUser.googleCalendarId = GUtil.CreateNewCalendar(NewUser, Form.NewCalendarBox.Text);
                WaSSetSetting            = true;
            }
            else
            {
                // if user select his calendar
                if (Form.CalendarsBox.SelectedItem != null)
                {
                    NewUser.googleCalendarId = ((GoogleCalendarInfo)(Form.CalendarsBox.SelectedItem)).ID;
                    WaSSetSetting            = true;
                }
                else
                {
                    WaSSetSetting = false;
                }
            }
        }
コード例 #11
0
        internal MacroExecutor RunMacroModule(MacroModule module, ISession sessionToBind, IMacroEventListener listener)
        {
            try {
                Assembly      asm       = MacroUtil.LoadMacroAssembly(module);
                MacroExecutor macroExec = new MacroExecutor(module, asm);

                if (sessionToBind != null)
                {
                    bool bound = _sessionBinder.Bind(macroExec, sessionToBind);
                    if (!bound)
                    {
                        GUtil.Warning(null, Strings.GetString("Message.MacroPlugin.AnotherMacroIsRunningInThisSession"));
                        return(null);
                    }
                }

                if (listener != null)
                {
                    listener.IndicateMacroStarted();
                }
                macroExec.AsyncExec(listener);
                return(macroExec);
            }
            catch (Exception ex) {
                RuntimeUtil.ReportException(ex);
                return(null);
            }
        }
コード例 #12
0
ファイル: ShellSchemeEditor.cs プロジェクト: yueker/poderosa
        private void OnValidatePrompt(object sender, CancelEventArgs e)
        {
            if (_blockUIEvent)
            {
                return;
            }
            StringResource sr = TerminalUIPlugin.Instance.Strings;
            bool           ok = false;

            try {
                Regex re = new Regex(_promptBox.Text);
                Match m  = re.Match("");
                ok = !m.Success;
            }
            catch (Exception) {
            }

            if (ok)
            {
                _current.ShellScheme.PromptExpression = _promptBox.Text;
            }
            else
            {
                GUtil.Warning(this, sr.GetString("Message.ShellSchemeEditor.PromptError"));
                e.Cancel = true;
            }
        }
コード例 #13
0
        private void panelDrop_DragDrop(object sender, DragEventArgs e)
        {
            if (e.Effect == DragDropEffects.Copy)
            {
                if (e.Data.GetDataPresent(DataFormats.FileDrop))
                {
                    string[] files = e.Data.GetData(DataFormats.FileDrop) as string[];
                    if (files != null)
                    {
                        if (!checkRecursive.Checked && ContainsDirectory(files))
                        {
                            string       message = SFTPPlugin.Instance.StringResource.GetString("SCPForm.RecursiveOptionIsRequired");
                            DialogResult result  = GUtil.AskUserYesNo(this, message, MessageBoxIcon.Information);
                            if (result != DialogResult.Yes)
                            {
                                return;
                            }
                            this.checkRecursive.Checked = true;
                        }

                        StartUpload(files);
                    }
                }
            }
        }
コード例 #14
0
ファイル: RenderProfile.cs プロジェクト: nwtajcky/RDManager
 public void Load(string value)
 {
     if (value == null)
     {
         SetDefault();
     }
     else
     {
         string[] cols = value.Split(',');
         if (cols.Length < _colors.Length)
         {
             SetDefault();
         }
         else
         {
             for (int i = 0; i < cols.Length; i++)
             {
                 _colors[i] = GUtil.ParseColor(cols[i], Color.Empty);
                 if (_colors[i].IsEmpty)
                 {
                     _colors[i] = GetDefaultColor(i);
                 }
             }
             _isDefault = false;
         }
     }
 }
コード例 #15
0
ファイル: ShellSchemeEditor.cs プロジェクト: yueker/poderosa
        private void OnValidateSchemeName(object sender, CancelEventArgs e)
        {
            if (_blockUIEvent)
            {
                return;
            }
            StringResource sr = TerminalUIPlugin.Instance.Strings;

            if (_nameBox.Text.Length == 0)
            {
                GUtil.Warning(this, sr.GetString("Message.ShellSchemeEditor.EmptyName"));
                e.Cancel = true;
            }

            ItemTag t = FindTag(_nameBox.Text);

            if (t != null && t != _current)
            {
                GUtil.Warning(this, sr.GetString("Message.ShellSchemeEditor.DuplicatedName"));
                e.Cancel = true;
            }
            else
            {
                _current.ShellScheme.Name = _nameBox.Text;
                _currentSchemeGroup.Text  = String.Format(sr.GetString("Form.ShellSchemeEditor._currentSchemeGroup"), _nameBox.Text);
                _schemeComboBox.Items[_schemeComboBox.SelectedIndex] = _nameBox.Text;
            }
        }
コード例 #16
0
ファイル: RenderProfile.cs プロジェクト: nwtajcky/RDManager
        public void Import(ConfigNode data)
        {
            CommonOptions opt = GEnv.Options;

            _fontName = data["font-name"];
            if (_fontName == null)
            {
                _fontName = opt.FontName;
            }
            _japaneseFontName = data["japanese-font-name"];
            if (_japaneseFontName == null)
            {
                _japaneseFontName = opt.JapaneseFontName;
            }
            _fontSize     = (float)GUtil.ParseInt(data["font-size"], 10);
            _useClearType = GUtil.ParseBool(data["clear-type"], false);
            ClearFont();

            unchecked {
                _forecolor = Color.FromArgb(GUtil.ParseHexInt(data["fore-color"], (int)0xFF000000));
                _bgcolor   = Color.FromArgb(GUtil.ParseHexInt(data["back-color"], (int)0xFFFFFFFF));
            }
            if (_esColorSet == null)
            {
                _esColorSet = (EscapesequenceColorSet)opt.ESColorSet.Clone();
            }
            _esColorSet.Load(data["color-sequence"]);
            ClearBrush();

            _backgroundImageFileName = data["image-file"];
            _imageLoadIsAttempted    = false;
            _imageStyle = (ImageStyle)EnumDescAttribute.For(typeof(ImageStyle)).FromName(data["bg-style"], ImageStyle.Center);
        }
コード例 #17
0
        private bool ValidateParams()
        {
            StringResource res = PipePlugin.Instance.Strings;

            _name = _textBoxName.Text;

            if (_name.Length == 0)
            {
                GUtil.Warning(this, res.GetString("Form.EditVariableDialog.Error.EnterName"));
                return(false);
            }

            if (_name.IndexOf('=') != -1)
            {
                GUtil.Warning(this, res.GetString("Form.EditVariableDialog.Error.NameHasIllegalCharacter"));
                return(false);
            }

            _value = _textBoxValue.Text;

            if (_value.Length == 0)
            {
                GUtil.Warning(this, res.GetString("Form.EditVariableDialog.Error.EnterValue"));
                return(false);
            }

            return(true);
        }
コード例 #18
0
        private void OnOK(object sender, EventArgs args)
        {
            this.DialogResult = DialogResult.None;
            if (!File.Exists(_path.Text))
            {
                GUtil.Warning(this, String.Format(GApp.Strings.GetString("Message.ModuleProperty.FileNotExist"), _path.Text));
            }
            else if (_title.Text.Length > 30)
            {
                GUtil.Warning(this, GApp.Strings.GetString("Message.ModuleProperty.TooLongTitle"));
            }
            else
            {
                if (_shortcut.Key != _prevShortCut)
                {
                    string n = _parent.FindCommandDescription(_shortcut.Key);
                    if (n != null)
                    {
                        GUtil.Warning(this, String.Format(GApp.Strings.GetString("Message.ModuleProperty.DuplicatedKey"), n));
                        return;
                    }
                }

                _module.Title                = _title.Text;
                _module.Path                 = _path.Text;
                _module.DebugMode            = _debugOption.Checked;
                _module.AdditionalAssemblies = ParseAdditionalAssemblies(_additionalAssembly.Text);
                this.DialogResult            = DialogResult.OK;
            }
        }
コード例 #19
0
        private void OnOK(object sender, EventArgs args)
        {
            SerialTerminalParam p = (SerialTerminalParam)_con.Param.Clone();

            p.BaudRate    = Int32.Parse(_baudRateBox.Text);
            p.ByteSize    = (byte)(_dataBitsBox.SelectedIndex == 0? 7 : 8);
            p.StopBits    = (StopBits)_stopBitsBox.SelectedIndex;
            p.Parity      = (Parity)_parityBox.SelectedIndex;
            p.FlowControl = (FlowControl)_flowControlBox.SelectedIndex;
            try {
                p.TransmitDelayPerChar = Int32.Parse(_transmitDelayPerCharBox.Text);
                p.TransmitDelayPerLine = Int32.Parse(_transmitDelayPerLineBox.Text);
            }
            catch (Exception ex) {
                GUtil.Warning(this, ex.Message);
                this.DialogResult = DialogResult.None;
                return;
            }

            try {
                ((SerialTerminalConnection)_con).ApplySerialParam(p);
                this.DialogResult = DialogResult.OK;
            }
            catch (Exception ex) {
                GUtil.Warning(this, ex.Message);
                this.DialogResult = DialogResult.None;
            }
        }
コード例 #20
0
ファイル: GenericOptionPanel.cs プロジェクト: yueker/poderosa
        public bool Commit(ITerminalSessionOptions terminalsession, IMRUOptions mru, ICoreServicePreference window, IStartupActionOptions startup)
        {
            StringResource sr         = OptionDialogPlugin.Instance.Strings;
            string         itemname   = null;
            bool           successful = false;

            try {
                itemname       = sr.GetString("Caption.OptionDialog.MRUCount");
                mru.LimitCount = Int32.Parse(_MRUSize.Text);
                terminalsession.AskCloseOnExit = _askCloseOnExit.Checked;
                window.ShowsToolBar            = _showToolBar.Checked;

                window.Language       = ((EnumListItem <Language>)_languageBox.SelectedItem).Value;
                startup.StartupAction = ((EnumListItem <StartupAction>)_startupOptionBox.SelectedItem).Value;
                successful            = true;
            }
            catch (FormatException) {
                GUtil.Warning(this, String.Format(sr.GetString("Message.OptionDialog.InvalidItem"), itemname));
            }
            catch (Exception ex) {
                GUtil.Warning(this, ex.Message);
            }

            return(successful);
        }
コード例 #21
0
        private void OnOK(object sender, EventArgs args)
        {
            this.DialogResult = DialogResult.None;

            try {
                SSH2UserAuthKey key = SSH2UserAuthKey.FromSECSHStyleFile(_tKeyFile.Text, _tCurrentPassphrase.Text);
                if (_tNewPassphrase.Text != _tNewPassphraseAgain.Text)
                {
                    GUtil.Warning(this, GApp.Strings.GetString("Message.ChangePassphrase.PassphraseMismatch"));
                }
                else
                {
                    if (_tNewPassphrase.Text.Length > 0 || GUtil.AskUserYesNo(this, GApp.Strings.GetString("Message.ChangePassphrase.AskEmptyPassphrase")) == DialogResult.Yes)
                    {
                        FileStream s = new FileStream(_tKeyFile.Text, FileMode.Create);
                        key.WritePrivatePartInSECSHStyleFile(s, "", _tNewPassphrase.Text);
                        s.Close();
                        GUtil.Warning(this, GApp.Strings.GetString("Message.ChangePassphrase.NotifyChanged"), MessageBoxIcon.Information);
                        this.DialogResult = DialogResult.OK;
                        this.Close();
                    }
                }
            }
            catch (Exception ex) {
                GUtil.Warning(this, ex.Message);
            }
        }
コード例 #22
0
ファイル: AboutBox.cs プロジェクト: xydoublez/EasyConnect
 protected override bool ProcessDialogChar(char charCode)
 {
     if ('A' <= charCode && charCode <= 'Z')
     {
         charCode = (char)('a' + charCode - 'A');
     }
     if (charCode == _guevaraString[_guevaraIndex])
     {
         if (++_guevaraIndex == _guevaraString.Length)
         {
             if (!GApp.Options.GuevaraMode)
             {
                 GUtil.Warning(this, GApp.Strings.GetString("Message.AboutBox.EnterGuevara"));
             }
             else
             {
                 GUtil.Warning(this, GApp.Strings.GetString("Message.AboutBox.ExitGuevara"));
             }
             GApp.Options.GuevaraMode = !GApp.Options.GuevaraMode;
             GApp.Frame.ReloadIcon();
             this.Close();
         }
     }
     else
     {
         _guevaraIndex = 0;
     }
     return(base.ProcessDialogChar(charCode));
 }
コード例 #23
0
ファイル: SFTPToolbar.cs プロジェクト: stone89son/poderosa
        protected bool ConfirmToUse(Form ownerForm, string feature)
        {
            string       messageFormat = SFTPPlugin.Instance.StringResource.GetString("Common.WarnExperimentalFormat");
            string       message       = String.Format(messageFormat, feature);
            DialogResult result        = GUtil.AskUserYesNo(ownerForm, message, MessageBoxIcon.Warning);

            return(result == DialogResult.Yes);
        }
コード例 #24
0
        private bool ValidateParam()
        {
            SerialTerminalSettings settings = _terminalSettings;
            SerialTerminalParam    param    = _terminalParam;

            try {
                LogType            logtype     = (LogType)EnumDescAttribute.For(typeof(LogType)).FromDescription(_logTypeBox.Text, LogType.None);
                ISimpleLogSettings logsettings = null;
                if (logtype != LogType.None)
                {
                    logsettings = CreateSimpleLogSettings(logtype, _logFileBox.Text);
                    if (logsettings == null)
                    {
                        return(false);                  //動作キャンセル
                    }
                }

                param.Port = _portBox.SelectedIndex + 1;

                string autoExecMacroPath = null;
                if (_autoExecMacroPathBox.Text.Length != 0)
                {
                    autoExecMacroPath = _autoExecMacroPathBox.Text;
                }

                IAutoExecMacroParameter autoExecParams = param.GetAdapter(typeof(IAutoExecMacroParameter)) as IAutoExecMacroParameter;
                if (autoExecParams != null)
                {
                    autoExecParams.AutoExecMacroPath = autoExecMacroPath;
                }

                settings.BeginUpdate();
                if (logsettings != null)
                {
                    settings.LogSettings.Reset(logsettings);
                }
                settings.Caption     = String.Format("COM{0}", param.Port);
                settings.BaudRate    = Int32.Parse(_baudRateBox.Text);
                settings.ByteSize    = (byte)(_dataBitsBox.SelectedIndex == 0? 7 : 8);
                settings.StopBits    = (StopBits)_stopBitsBox.SelectedIndex;
                settings.Parity      = (Parity)_parityBox.SelectedIndex;
                settings.FlowControl = (FlowControl)_flowControlBox.SelectedIndex;

                settings.Encoding = (EncodingType)_encodingBox.SelectedIndex;

                settings.LocalEcho  = _localEchoBox.SelectedIndex == 1;
                settings.TransmitNL = (NewLine)EnumDescAttribute.For(typeof(NewLine)).FromDescription(_newLineBox.Text, LogType.None);

                settings.TransmitDelayPerChar = Int32.Parse(_transmitDelayPerCharBox.Text);
                settings.TransmitDelayPerLine = Int32.Parse(_transmitDelayPerLineBox.Text);
                settings.EndUpdate();
                return(true);
            }
            catch (Exception ex) {
                GUtil.Warning(this, ex.Message);
                return(false);
            }
        }
コード例 #25
0
ファイル: LoginDialog.cs プロジェクト: xydoublez/EasyConnect
        private void InitializeLoginParams()
        {
            StringCollection c = _history.Hosts;

            foreach (string h in c)
            {
                _hostBox.Items.Add(h);
            }
            if (_hostBox.Items.Count > 0)
            {
                _hostBox.SelectedIndex = 0;
            }

            c = _history.Accounts;
            foreach (string a in c)
            {
                _userNameBox.Items.Add(a);
            }
            if (_userNameBox.Items.Count > 0)
            {
                _userNameBox.SelectedIndex = 0;
            }

            int[] ic = _history.Ports;
            foreach (int p in ic)
            {
                _portBox.Items.Add(PortDescription(p));
            }

            if (_hostBox.Items.Count > 0)
            {
                TCPTerminalParam last = _history.SearchByHost((string)_hostBox.Items[0]);
                if (last != null)
                {
                    ApplyParam(last);
                }
            }

            c = _history.LogPaths;
            foreach (string p in c)
            {
                _logFileBox.Items.Add(p);
            }

            if (GApp.Options.DefaultLogType != LogType.None)
            {
                _logTypeBox.SelectedIndex = (int)GApp.Options.DefaultLogType;
                string t = GUtil.CreateLogFileName(null);
                _logFileBox.Items.Add(t);
                _logFileBox.Text = t;
            }
            else
            {
                _logTypeBox.SelectedIndex = 0;
            }
        }
コード例 #26
0
        private void OnSelectBackgroundImage(object sender, EventArgs args)
        {
            string t = GCUtil.SelectPictureFileByDialog(FindForm());

            if (t != null)
            {
                _backgroundImageBox.Text = t;
                _defaultFileDir          = GUtil.FileToDir(t);
            }
        }
コード例 #27
0
ファイル: GFontDialog.cs プロジェクト: nwtajcky/RDManager
        private void OnJapaneseFontChange(object sender, EventArgs args)
        {
            if (_ignoreEvent || _japaneseFontList.SelectedIndex == -1)
            {
                return;
            }
            string fontname = (string)_japaneseFontList.Items[_japaneseFontList.SelectedIndex];

            _japaneseFont         = GUtil.CreateFont(fontname, GetFontSize());
            _lJapaneseSample.Font = _japaneseFont;
        }
コード例 #28
0
ファイル: Logger.cs プロジェクト: hanamiche/poderosa
        //既存のファイルであったり、書き込み不可能だったら警告する
        public static LogFileCheckResult CheckLogFileName(string path, Form parent)
        {
            try {
                StringResource sr = GEnv.Strings;
                if (path.Length == 0)
                {
                    GUtil.Warning(parent, sr.GetString("Message.CheckLogFileName.EmptyPath"));
                    return(LogFileCheckResult.Cancel);
                }

                string dir = Path.GetDirectoryName(path);
                if (!Directory.Exists(dir))
                {
                    GUtil.Warning(parent, String.Format(sr.GetString("Message.CheckLogFileName.BadPathName"), path));
                    return(LogFileCheckResult.Cancel);
                }

                if (File.Exists(path))
                {
                    if ((FileAttributes.ReadOnly & File.GetAttributes(path)) != (FileAttributes)0)
                    {
                        GUtil.Warning(parent, String.Format(sr.GetString("Message.CheckLogFileName.NotWritable"), path));
                        return(LogFileCheckResult.Cancel);
                    }

                    Poderosa.Forms.ThreeButtonMessageBox mb = new Poderosa.Forms.ThreeButtonMessageBox();
                    mb.Message          = String.Format(sr.GetString("Message.CheckLogFileName.AlreadyExist"), path);
                    mb.Text             = sr.GetString("Util.CheckLogFileName.Caption");
                    mb.YesButtonText    = sr.GetString("Util.CheckLogFileName.OverWrite");
                    mb.NoButtonText     = sr.GetString("Util.CheckLogFileName.Append");
                    mb.CancelButtonText = sr.GetString("Util.CheckLogFileName.Cancel");
                    switch (mb.ShowDialog(parent))
                    {
                    case DialogResult.Cancel:
                        return(LogFileCheckResult.Cancel);

                    case DialogResult.Yes:     //上書き
                        return(LogFileCheckResult.Create);

                    case DialogResult.No:      //追記
                        return(LogFileCheckResult.Append);

                    default:
                        break;
                    }
                }

                return(LogFileCheckResult.Create); //!!書き込み可能なディレクトリにあることを確認すればなおよし
            }
            catch (Exception ex) {
                GUtil.Warning(parent, ex.Message);
                return(LogFileCheckResult.Error);
            }
        }
コード例 #29
0
 private void Warning(IPoderosaForm pf, Form wf, string msg)
 {
     if (pf != null)
     {
         pf.Warning(msg);
     }
     else
     {
         GUtil.Warning(wf, msg);
     }
 }
コード例 #30
0
ファイル: GFontDialog.cs プロジェクト: nwtajcky/RDManager
        private void OnASCIIFontChange(object sender, EventArgs args)
        {
            if (_ignoreEvent || _asciiFontList.SelectedIndex == -1)
            {
                return;
            }
            string fontname = (string)_asciiFontList.Items[_asciiFontList.SelectedIndex];

            _asciiFont         = GUtil.CreateFont(fontname, GetFontSize());
            _lASCIISample.Font = _asciiFont;
        }