示例#1
0
        /// <summary>
        /// Loads the property add-ons
        /// </summary>
        protected override void  Load()
        {
            // Initialize each of property addons. Careful not to break the loop
            // on eventual exceptions. It's important to try loading as much as
            // possible registered addons.
            if (AddonsConfig.PropertyAddons != null)
            {
                foreach (string addonName in AddonsConfig.PropertyAddons)
                {
                    try
                    {
                        Logger.LogTrace("Loading property addon: {0} ...", addonName);

                        PropertyAddon navAddon = new PropertyAddon(addonName);
                        Addons.Add(addonName, navAddon);
                    }
                    catch (Exception ex)
                    {
                        ErrorDispatcher.DispatchError(string.Format("Could not load addon: {0}.\nError: {1}",
                            addonName, ex.Message), Application.ProductName);
                    }
                }
            }
        }
示例#2
0
        /// <summary>
        /// Selects the proper addon that can handle the action request.
        /// </summary>
        public static ActionResponse DispatchAction(ActionRequest request)
        {
            ActionResponse response = null;

            switch (request.ActionType)
            {
                case ActionType.ActionSaveProperties:
                    if (propertyAddon != null)
                    {
                        PropBaseCtl propCtl = (propertyAddon.AddonPanel as PropBaseCtl);
                        if (propCtl != null)
                        {
                            propCtl.SaveProperties();
                        }
                    }
                    break;

                case ActionType.ActionBeginEdit:
                    {
                        // Stop editing properties if it's the case.
                        if (propertyAddon != null)
                        {
                            PropBaseCtl propCtl = (propertyAddon.AddonPanel as PropBaseCtl);
                            if (propCtl != null)
                            {
                                propCtl.EndEdit();
                                propertyAddon = null;
                            }
                        }

                        propertyAddon = SelectPropertyAddon(request.Items);
                        response = new ActionResponse(request, propertyAddon);
                    }
                    break;

                case ActionType.ActionBeginPreview:
                    {
                        // Stop previewing if it's the case.
                        if (request.ActionType == ActionType.ActionBeginPreview &&
                            previewAddon != null)
                        {
                            PreviewBaseCtl previewCtl = (previewAddon.AddonPanel as PreviewBaseCtl);
                            if (previewCtl != null)
                            {
                                previewCtl.EndPreview();
                                AddonsCore.Instance.FirePreviewEnded();
                                previewAddon = null;
                            }
                        }

                        previewAddon = SelectPreviewAddon(request.Items);
                        response = new ActionResponse(request, previewAddon);
                    }
                    break;

                default:
                    response = null;
                    break;
            }

            return response;
        }