예제 #1
0
        private void InitTimezones()
        {
            List <string> timezones = new List <string> {
                UTC.getID()
            };

            string[] allTimezones = TimeZone.getAvailableIDs();
            Array.Sort(allTimezones);

            foreach (string timezone in allTimezones)
            {
                if (Regex.IsMatch(timezone, TimezoneIdPrefixes))
                {
                    timezones.Add(TimeZone.getTimeZone(timezone).getID());
                }
            }
            View.PopulateTimezones(timezones);
        }
예제 #2
0
        private void View_ChangedTimezoneEvent()
        {
            string selected = View.SelectedTimezone;

            if (selected.Equals(Auto))
            {
                _host.setTimezone(null);
            }
            else
            {
                string[] ids = TimeZone.getAvailableIDs();
                foreach (string id in ids)
                {
                    TimeZone tz;
                    if ((tz = TimeZone.getTimeZone(id)).getID().Equals(selected))
                    {
                        _host.setTimezone(tz);
                        break;
                    }
                }
            }
            ItemChanged();
        }
예제 #3
0
        public static DateTime ConvertJavaMillisecondsToDateTime(long javaMS, string tz)
        {
            int offset = TimeZone.getTimeZone(tz).getOffset(javaMS);

            return(ConvertJavaMillisecondsToDateTime(javaMS + offset));
        }
예제 #4
0
        private void Update()
        {
            View.WindowTitle      = _host.getNickname();
            View.Hostname         = _host.getHostname();
            View.HostFieldEnabled = _host.getProtocol().isHostnameConfigurable();
            View.Nickname         = _host.getNickname();
            View.DownloadFolder   = _host.getDownloadFolder().getAbsolute();
            string url;

            if (Utils.IsNotBlank(_host.getDefaultPath()))
            {
                url = _host.toURL() + Path.normalize(_host.getDefaultPath());
            }
            else
            {
                url = _host.toURL();
            }
            View.URL              = url;
            View.Port             = _host.getPort().ToString();
            View.PortFieldEnabled = _host.getProtocol().isHostnameConfigurable();
            View.Path             = _host.getDefaultPath();
            View.Username         = _host.getCredentials().getUsername();
            View.UsernameEnabled  = !_host.getCredentials().isAnonymousLogin();
            View.UsernameLabel    = _host.getProtocol().getUsernamePlaceholder() + ":";
            View.AnonymousEnabled = _host.getProtocol().isAnonymousConfigurable();
            View.AnonymousChecked = _host.getCredentials().isAnonymousLogin();
            View.SelectedProtocol = _host.getProtocol();

            if (null == _host.getMaxConnections())
            {
                View.SelectedTransferMode = Default;
            }
            else
            {
                View.SelectedTransferMode = _host.getMaxConnections().intValue() == 1
                                                ? TransferBrowserconnection
                                                : TransferNewconnection;
            }

            View.EncodingFieldEnabled    = _host.getProtocol().isEncodingConfigurable();
            View.ConnectModeFieldEnabled = _host.getProtocol().isConnectModeConfigurable();
            if (_host.getProtocol().isConnectModeConfigurable())
            {
                if (null == _host.getFTPConnectMode())
                {
                    View.SelectedConnectMode = Default;
                }
                else if (_host.getFTPConnectMode().equals(FTPConnectMode.PASV))
                {
                    View.SelectedConnectMode = ConnectmodePassive;
                }
                else if (_host.getFTPConnectMode().equals(FTPConnectMode.PORT))
                {
                    View.SelectedConnectMode = ConnectmodeActive;
                }
            }
            View.PkCheckboxEnabled = _host.getProtocol().equals(Protocol.SFTP);
            if (_host.getCredentials().isPublicKeyAuthentication())
            {
                View.PkCheckboxState = true;
                View.PkLabel         = _host.getCredentials().getIdentity().getAbbreviatedPath();
            }
            else
            {
                View.PkCheckboxState = false;
                View.PkLabel         = Locale.localizedString("No Private Key selected");
            }
            View.WebUrlFieldEnabled  = _host.getProtocol().isWebUrlConfigurable();
            View.WebUrlButtonToolTip = _host.getWebURL();
            View.WebURL = _host.getWebURL();
            View.Notes  = _host.getComment();
            View.TimezoneFieldEnabled = !_host.getProtocol().isUTCTimezone();
            if (null == _host.getTimezone())
            {
                if (_host.getProtocol().isUTCTimezone())
                {
                    View.SelectedTimezone = UTC.getID();
                }
                else
                {
                    if (Preferences.instance().getBoolean("ftp.timezone.auto"))
                    {
                        View.SelectedTimezone = Auto;
                    }
                    else
                    {
                        View.SelectedTimezone =
                            TimeZone.getTimeZone(
                                Preferences.instance().getProperty("ftp.timezone.default")).getID();
                    }
                }
            }
            else
            {
                View.SelectedTimezone = _host.getTimezone().getID();
            }
        }