Beispiel #1
0
        /// <summary>
        /// Initializes a new instance of SettingsControl, which is used to dynamically build all configuration options.
        /// </summary>
        public SettingsControl()
        {
            InitializeComponent();

            // localise buttons
            IResourceString save = LocalizationHelper.CreateLabelProperty("[configuration.settings.button.save]");

            _btnSave.Tag     = save;
            _btnSave.Text    = save.Evaluate();
            _btnSave.Enabled = false;

            IResourceString apply = LocalizationHelper.CreateLabelProperty("[configuration.settings.button.apply]");

            _btnApply.Tag     = apply;
            _btnApply.Text    = apply.Evaluate();
            _btnApply.Enabled = false;

            _treeSections.ImageList                  = new ImageList();
            _treeSections.ImageList.ColorDepth       = ColorDepth.Depth32Bit;
            _treeSections.ImageList.TransparentColor = Color.Transparent;
            _treeSections.ImageList.ImageSize        = new Size(22, 22);

            LoadSections();

            ServiceScope.Get <ILocalisation>().LanguageChange += LanguageChange;
            CheckRightToLeft();
        }
        /// <summary>
        /// Gets a name for a player context.
        /// </summary>
        /// <param name="playerContext">Player context to return the name for.</param>
        /// <param name="slotNo">Number of the player slot of the given <paramref name="playerContext"/>.</param>
        /// <returns>Human readable name for the given <paramref name="playerContext"/>.</returns>
        protected static string GetNameForPlayerContext(IPlayerContext playerContext, int slotNo)
        {
            IPlayer player = playerContext.CurrentPlayer;

            if (player == null)
            {
                IResourceString playerOfType = LocalizationHelper.CreateResourceString(Consts.RES_PLAYER_OF_TYPE);                         // "{0} player"
                IResourceString slotNoRes    = LocalizationHelper.CreateResourceString(Consts.RES_SLOT_NO);                                // "Slot #{0}"
                return(playerOfType.Evaluate(playerContext.AVType.ToString()) + " (" + slotNoRes.Evaluate((slotNo + 1).ToString()) + ")"); // "Video player (Slot #1)"
            }
            return(player.Name + ": " + player.MediaItemTitle);
        }
Beispiel #3
0
        public void UpdateMenuActions(NavigationContext context, IDictionary <Guid, WorkflowAction> actions)
        {
            IConfigurationManager configurationManager = ServiceRegistration.Get <IConfigurationManager>();
            string        configLocation = GetConfigLocation(context);
            WorkflowState mainState;

            ServiceRegistration.Get <IWorkflowManager>().States.TryGetValue(new Guid(CONFIGURATION_MAIN_STATE_ID_STR),
                                                                            out mainState);
            IConfigurationNode currentNode = configurationManager.GetNode(configLocation);

            foreach (IConfigurationNode childNode in currentNode.ChildNodes)
            {
                if (childNode.ConfigObj is ConfigSection)
                {
                    bool supportedSettings = NumSettingsSupported(childNode) > 0;
                    // Hint (Albert): Instead of skipping, we could disable the transition in case there are no supported
                    // settings contained in it
                    if (!supportedSettings)
                    {
                        continue;
                    }
                    ConfigSection section = (ConfigSection)childNode.ConfigObj;
                    // Create transient state for new config section
                    WorkflowState newState = WorkflowState.CreateTransientState(
                        string.Format("Config: '{0}'", childNode.Location), section.SectionMetadata.Text, false, CONFIGURATION_SECTION_SCREEN,
                        false, WorkflowType.Workflow, context.WorkflowState.HideGroups);
                    // Add action for menu
                    IResourceString res = LocalizationHelper.CreateResourceString(section.Metadata.Text);
                    WorkflowAction  wa  = new PushTransientStateNavigationTransition(
                        Guid.NewGuid(), context.WorkflowState.Name + "->" + childNode.Location, null,
                        new Guid[] { context.WorkflowState.StateId }, newState, res)
                    {
                        DisplayCategory = ACTIONS_WORKFLOW_CATEGORY,
                        SortOrder       = childNode.Sort ?? res.Evaluate(),
                        WorkflowNavigationContextVariables = new Dictionary <string, object>
                        {
                            { CONFIG_LOCATION_KEY, childNode.Location }
                        }
                    };
                    actions.Add(wa.ActionId, wa);
                }
            }
        }
Beispiel #4
0
        /// <summary>
        /// Helper for MainWindow_FormClosing event.
        /// </summary>
        /// <returns></returns>
        public bool Closing()
        {
            if (_btnSave.Enabled)
            {
                IResourceString message = LocalizationHelper.CreateLabelProperty("[configuration.save_on_exit]");
                IResourceString title   = LocalizationHelper.CreateLabelProperty("[configuration.unsaved_warning]");
                DialogResult    result  = MessageBox.Show(message.Evaluate(), title.Evaluate(), MessageBoxButtons.YesNoCancel, MessageBoxIcon.Exclamation);

                switch (result)
                {
                case DialogResult.Yes:
                    ServiceScope.Get <IConfigurationManager>().Save();
                    break;

                case DialogResult.Cancel:
                    return(false);
                }
            }
            return(true);
        }
Beispiel #5
0
 public int CompareTo(IResourceString other)
 {
     return(_stringValue.CompareTo(other.Evaluate()));
 }
 public int CompareTo(IResourceString other)
 {
   return _stringValue.CompareTo(other.Evaluate());
 }