Beispiel #1
0
        /// <summary>
        /// Called when the user clicks the browse button.
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void buttonBrowse_Click(object sender, EventArgs e)
        {
            string folder = null;

            if (!String.IsNullOrEmpty(FileName))
            {
                folder = Path.GetDirectoryName(FileName);
            }
            if (!Directory.Exists(folder))
            {
                folder = Environment.GetFolderPath(Environment.SpecialFolder.ProgramFiles);
            }

            using (var dialog = new OpenFileDialog()
            {
                AddExtension = BrowserAddExtension,
                AutoUpgradeEnabled = true,
                CheckFileExists = BrowserCheckFileExists,
                DefaultExt = BrowserDefaultExt,
                FileName = FileName,
                Filter = BrowserFilter,
                InitialDirectory = folder,
                Multiselect = false,
                Title = Localise.GetLocalisedText(BrowserTitle),
            }) {
                if (dialog.ShowDialog() == DialogResult.OK)
                {
                    FileName = dialog.FileName;
                }
            }
        }
Beispiel #2
0
        /// <summary>
        /// Called when the user clicks the browse button.
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void buttonBrowse_Click(object sender, EventArgs e)
        {
            string folder = Folder;

            if (String.IsNullOrEmpty(folder) || !Directory.Exists(folder))
            {
                folder = Environment.GetFolderPath(Environment.SpecialFolder.ProgramFiles);
            }

            using (var dialog = new FolderBrowserDialog()
            {
                Description = Localise.GetLocalisedText(BrowserDescription),
                SelectedPath = folder,
                ShowNewFolderButton = BrowserShowNewFolderButton,
            }) {
                if (dialog.ShowDialog() == DialogResult.OK)
                {
                    Folder = dialog.SelectedPath;
                }
            }
        }
        /// <summary>
        /// See base class docs.
        /// </summary>
        /// <param name="context"></param>
        /// <param name="provider"></param>
        /// <param name="value"></param>
        /// <returns></returns>
        public override object EditValue(ITypeDescriptorContext context, IServiceProvider provider, object value)
        {
            var result = value as string ?? "";

            string folder = null;

            if (!String.IsNullOrEmpty(result))
            {
                folder = Path.GetDirectoryName(result);
            }
            if (!Directory.Exists(folder))
            {
                folder = Environment.GetFolderPath(Environment.SpecialFolder.ProgramFiles);
            }

            var fileNameBrowserAttribute = context.PropertyDescriptor.Attributes.OfType <FileNameBrowserAttribute>().FirstOrDefault();

            if (fileNameBrowserAttribute == null)
            {
                fileNameBrowserAttribute = new FileNameBrowserAttribute();
            }

            using (var dialog = new OpenFileDialog()
            {
                AddExtension = fileNameBrowserAttribute.AddExtension,
                AutoUpgradeEnabled = true,
                CheckFileExists = fileNameBrowserAttribute.CheckFileExists,
                DefaultExt = fileNameBrowserAttribute.DefaultExtension,
                FileName = result,
                Filter = fileNameBrowserAttribute.Filter,
                InitialDirectory = folder,
                Multiselect = false,
                Title = String.IsNullOrEmpty(fileNameBrowserAttribute.BrowserTitle) ? "" : Localise.GetLocalisedText(fileNameBrowserAttribute.BrowserTitle),
            }) {
                if (dialog.ShowDialog() == DialogResult.OK)
                {
                    result = dialog.FileName;
                }
            }

            return(result);
        }
Beispiel #4
0
        /// <summary>
        /// See base class docs.
        /// </summary>
        /// <param name="context"></param>
        /// <param name="provider"></param>
        /// <param name="value"></param>
        /// <returns></returns>
        public override object EditValue(ITypeDescriptorContext context, IServiceProvider provider, object value)
        {
            var result = value as string;

            string folder = result;

            if (String.IsNullOrEmpty(folder) || !Directory.Exists(folder))
            {
                folder = Environment.GetFolderPath(Environment.SpecialFolder.ProgramFiles);
            }

            var folderBrowserAttribute = context.PropertyDescriptor.Attributes.OfType <FolderBrowserAttribute>().FirstOrDefault();

            if (folderBrowserAttribute == null)
            {
                folderBrowserAttribute = new FolderBrowserAttribute();
            }

            using (var dialog = new FolderBrowserDialog()
            {
                Description = String.IsNullOrEmpty(folderBrowserAttribute.Description) ? "" : Localise.GetLocalisedText(folderBrowserAttribute.Description),
                SelectedPath = folder,
                ShowNewFolderButton = folderBrowserAttribute.ShowNewFolderButton,
            }) {
                if (dialog.ShowDialog() == DialogResult.OK)
                {
                    result = dialog.SelectedPath;
                }
            }

            return(result);
        }
        private ISheet AddValidationMessage(ISheet selectSheet, StringBuilder messages, ValidationResult result)
        {
            if (messages.Length != 0)
            {
                messages.Append("\r\n");
            }
            messages.AppendFormat("{0}{1}", result.IsWarning ? Localise.GetLocalisedText("::Warning:::") : "", result.Message);

            if (selectSheet == null)
            {
                switch (result.Field)
                {
                case ValidationField.BaseStationAddress:
                case ValidationField.BaseStationPort:
                case ValidationField.ComPort:
                case ValidationField.BaudRate:
                case ValidationField.DataBits:
                case ValidationField.BaseStationDatabase:
                case ValidationField.FlagsFolder:
                case ValidationField.PicturesFolder:
                case ValidationField.SilhouettesFolder:
                    selectSheet = _DataSourcesSheet;
                    break;

                case ValidationField.Location:
                case ValidationField.ReceiverRange:
                case ValidationField.AcceptableAirborneLocalPositionSpeed:
                case ValidationField.AcceptableSurfaceLocalPositionSpeed:
                case ValidationField.AcceptableTransitionLocalPositionSpeed:
                case ValidationField.AirborneGlobalPositionLimit:
                case ValidationField.FastSurfaceGlobalPositionLimit:
                case ValidationField.SlowSurfaceGlobalPositionLimit:
                case ValidationField.AcceptIcaoInNonPICount:
                case ValidationField.AcceptIcaoInNonPISeconds:
                case ValidationField.AcceptIcaoInPI0Count:
                case ValidationField.AcceptIcaoInPI0Seconds:
                    selectSheet = _RawFeedSheet;
                    break;

                case ValidationField.WebUserName:
                case ValidationField.UPnpPortNumber:
                case ValidationField.InternetUserIdleTimeout:
                    selectSheet = _WebServerSheet;
                    break;

                case ValidationField.InitialGoogleMapRefreshSeconds:
                case ValidationField.MinimumGoogleMapRefreshSeconds:
                case ValidationField.Latitude:
                case ValidationField.Longitude:
                case ValidationField.GoogleMapZoomLevel:
                    selectSheet = _WebSiteSheet;
                    break;

                case ValidationField.CheckForNewVersions:
                case ValidationField.DisplayTimeout:
                case ValidationField.ShortTrailLength:
                case ValidationField.TextToSpeechSpeed:
                case ValidationField.TrackingTimeout:
                    selectSheet = _GeneralOptions;
                    break;

                default:
                    throw new NotImplementedException();
                }
            }

            return(selectSheet);
        }