Beispiel #1
0
        /// <summary>
        /// Edit an endpoint
        /// </summary>
        public override object EditValue(ITypeDescriptorContext context, IServiceProvider provider, object value)
        {
            if ((context != null) && (context.Instance != null) && (provider != null))
            {
                var entity = context.GetFirstEntitySettings <IEntitySettings>();
                if (entity == null)
                {
                    return(value);
                }
                var module = entity.Module;

                var editorService = (IWindowsFormsEditorService)provider.GetService(typeof(IWindowsFormsEditorService));
                if (editorService != null)
                {
                    // Create a listbox
                    var lb = new ListBox();
                    LoadBlocks(module.Blocks, lb);
                    lb.SelectedIndexChanged += (s, _) => editorService.CloseDropDown();

                    editorService.DropDownControl(lb);
                    var selection = (Entry)lb.SelectedItem;
                    return((selection != null) ? selection.Block : null);
                }
            }

            return(value);
        }
Beispiel #2
0
        /// <summary>
        /// Edit an endpoint
        /// </summary>
        public override object EditValue(ITypeDescriptorContext context, IServiceProvider provider, object value)
        {
            if ((context != null) && (context.Instance != null) && (provider != null))
            {
                var entity = context.GetFirstEntitySettings <IGatherProperties>();
                if (entity == null)
                {
                    return(value);
                }
                var railway = entity.Railway;

                var editorService = (IWindowsFormsEditorService)provider.GetService(typeof(IWindowsFormsEditorService));
                if (editorService != null)
                {
                    // Create a listbox
                    var lb = new ListBox();
                    lb.Items.AddRange(railway.Locs.Select(x =>
                    {
                        ILoc loc;
                        return(x.TryResolve(out loc) ? loc : null);
                    }).Where(x => x != null).OrderBy(x => x.Description, NameWithNumbersComparer.Instance).ToArray());
                    lb.SelectedIndexChanged += (s, _) => editorService.CloseDropDown();

                    editorService.DropDownControl(lb);
                    return(lb.SelectedItem);
                }
            }

            return(value);
        }
        /// <summary>
        /// Edit an endpoint
        /// </summary>
        public override object EditValue(ITypeDescriptorContext context, IServiceProvider provider, object value)
        {
            if ((context != null) && (context.Instance != null) && (provider != null))
            {
                var entity = context.GetFirstEntitySettings <IEntitySettings>();
                if (entity == null)
                {
                    return(value);
                }
                var module = entity.Module;

                var editorService = (IWindowsFormsEditorService)provider.GetService(typeof(IWindowsFormsEditorService));
                if (editorService != null)
                {
                    // Create a listbox
                    var lb = new ListBox();
                    lb.Items.AddRange(module.Blocks.OrderBy(x => x.Description, NameWithNumbersComparer.Instance).ToArray());
                    lb.Items.AddRange(module.Edges.OrderBy(x => x.Description, NameWithNumbersComparer.Instance).ToArray());
                    lb.SelectedIndexChanged += (s, _) => editorService.CloseDropDown();

                    editorService.DropDownControl(lb);
                    return(lb.SelectedItem);
                }
            }

            return(value);
        }
Beispiel #4
0
        /// <summary>
        /// Edit an address
        /// </summary>
        public override object EditValue(ITypeDescriptorContext context, IServiceProvider provider, object value)
        {
            var entity = context.GetFirstEntitySettings <IGatherProperties>();

            if (entity == null)
            {
                return(value);
            }
            var predicate = (ILocPredicate)value;

            using (var dialog = new PredicateEditorForm(predicate, entity.Railway))
            {
                dialog.Text = "Edit permissions";
                if (dialog.ShowDialog() == DialogResult.OK)
                {
                    if (provider != null)
                    {
                        var listener = (IPredicateChangedListener)provider.GetService(typeof(IPredicateChangedListener));
                        if (listener != null)
                        {
                            listener.PredicateChanged(predicate);
                        }
                    }
                }
                return(predicate);
            }
        }
        /// <summary>
        /// Edit an edge
        /// </summary>
        public override object EditValue(ITypeDescriptorContext context, IServiceProvider provider, object value)
        {
            if ((context != null) && (context.Instance != null) && (provider != null))
            {
                var entity = context.GetFirstEntitySettings <IGatherProperties>();
                if (entity == null)
                {
                    return(value);
                }
                var railway = entity.Railway;

                var editorService = (IWindowsFormsEditorService)provider.GetService(typeof(IWindowsFormsEditorService));
                if (editorService != null)
                {
                    // Create a listbox
                    var lb       = new ListBox();
                    var allEdges = railway.GetModules().SelectMany(x => x.Edges);
                    lb.Items.AddRange(allEdges.Select(x => new EdgeItem(x)).OrderBy(x => x.ToString(), NameWithNumbersComparer.Instance).ToArray());
                    lb.SelectedIndexChanged += (s, _) => editorService.CloseDropDown();

                    editorService.DropDownControl(lb);
                    var item = lb.SelectedItem as EdgeItem;
                    return((item != null) ? item.Edge : null);
                }
            }

            return(value);
        }
Beispiel #6
0
        /// <summary>
        /// Edit an address
        /// </summary>
        public override object EditValue(ITypeDescriptorContext context, IServiceProvider provider, object value)
        {
            var events   = value as IRouteEventSet;
            var settings = context.GetFirstEntitySettings <IEntitySettings>();

            if ((settings == null) || (events == null))
            {
                return(value);
            }
            using (var dialog = new RouteEventSetEditorForm(settings.Railway, settings.Module, events))
            {
                dialog.ShowDialog();
            }
            return(events);
        }
        /// <summary>
        /// Edit an address
        /// </summary>
        public override object EditValue(ITypeDescriptorContext context, IServiceProvider provider, object value)
        {
            var junctions = value as IJunctionWithStateSet;
            var settings  = context.GetFirstEntitySettings <IEntitySettings>();

            if ((settings == null) || (junctions == null))
            {
                return(value);
            }
            using (var dialog = new JunctionWithStateSetEditorForm(settings.Module, junctions))
            {
                dialog.ShowDialog();
            }
            return(junctions);
        }
        /// <summary>
        /// Edit an address
        /// </summary>
        public override object EditValue(ITypeDescriptorContext context, IServiceProvider provider, object value)
        {
            var source   = value as IActionTriggerSource;
            var settings = context.GetFirstEntitySettings <IEntitySettings>();

            if ((settings == null) || (source == null))
            {
                return(value);
            }
            using (var dialog = new ActionsEditorForm(source, settings.Railway, settings.Context))
            {
                dialog.ShowDialog();
            }
            return(source);
        }
        /// <summary>
        /// Edit an address
        /// </summary>
        public override object EditValue(ITypeDescriptorContext context, IServiceProvider provider, object value)
        {
            var locs     = value as IEntitySet3 <ILoc>;
            var settings = context.GetFirstEntitySettings <IGatherProperties>();

            if ((settings == null) || (locs == null))
            {
                return(value);
            }
            using (var dialog = new LocSetEditorForm(settings.Railway, locs))
            {
                dialog.ShowDialog();
            }
            return(locs);
        }