Exemplo n.º 1
0
        private void AddRule(PossibleMergedEpisode selected, ShowConfiguration si, ListViewItem lastClicked)
        {
            ShowRule sr = selected.GenerateRule();

            si.AddSeasonRule(selected.SeasonNumber, sr);

            lvMergedEpisodes.Items.Remove(lastClicked);
            dupEps.Remove(selected);
        }
Exemplo n.º 2
0
        private void duplicateRightClickMenu_ItemClicked(object sender,
                                                         ToolStripItemClickedEventArgs e)
        {
            duplicateRightClickMenu.Close();

            if (e.ClickedItem.Tag != null)
            {
                RightClickCommands n = (RightClickCommands)e.ClickedItem.Tag;

                ShowItem si = mlastSelected?.ShowItem;

                switch (n)
                {
                case RightClickCommands.kEpisodeGuideForShow:     // epguide
                    if (mlastSelected != null)
                    {
                        mainUi.GotoEpguideFor(mlastSelected.Episode, true);
                    }
                    else
                    {
                        if (si != null)
                        {
                            mainUi.GotoEpguideFor(si, true);
                        }
                    }
                    Close();
                    break;

                case RightClickCommands.kForceRefreshSeries:
                    if (si != null)
                    {
                        mainUi.ForceRefresh(new List <ShowItem> {
                            si
                        });
                    }
                    Close();
                    break;

                case RightClickCommands.kEditShow:
                    if (si != null)
                    {
                        mainUi.EditShow(si);
                    }
                    break;

                case RightClickCommands.kEditSeason:
                    if (si != null)
                    {
                        mainUi.EditSeason(si, mlastSelected.SeasonNumber);
                    }
                    break;

                case RightClickCommands.kAddRule:
                    if (mlastSelected != null)
                    {
                        ShowRule sr = mlastSelected.GenerateRule();

                        si?.AddSeasonRule(mlastSelected.SeasonNumber, sr);

                        lvDuplicates.Items.Remove(mlastClicked);
                        dupEps.Remove(mlastSelected);
                    }
                    break;

                default:
                {
                    System.Diagnostics.Debug.Fail("Unknown right-click action " + n);
                    break;
                }
                }
            }
            mlastSelected = null;
        }
Exemplo n.º 3
0
        /// <inheritdoc />
        public ContentApp GetContentAppFor(object o, IEnumerable <IReadOnlyUserGroup> userGroups)
        {
            string partA, partB;

            switch (o)
            {
            case IContent content:
                partA = "content";
                partB = content.ContentType.Alias;
                break;

            case IMedia media:
                partA = "media";
                partB = media.ContentType.Alias;
                break;

            default:
                return(null);
            }

            var rules          = _showRules ?? (_showRules = ShowRule.Parse(_definition.Show).ToArray());
            var userGroupsList = userGroups.ToList();

            var okRole  = false;
            var hasRole = false;
            var okType  = false;
            var hasType = false;

            foreach (var rule in rules)
            {
                if (rule.PartA.InvariantEquals("role"))
                {
                    // if roles have been ok-ed already, skip the rule
                    if (okRole)
                    {
                        continue;
                    }

                    // remember we have role rules
                    hasRole = true;

                    foreach (var group in userGroupsList)
                    {
                        // if the entry does not apply, skip
                        if (!rule.Matches("role", group.Alias))
                        {
                            continue;
                        }

                        // if the entry applies,
                        // if it's an exclude entry, exit, do not display the content app
                        if (!rule.Show)
                        {
                            return(null);
                        }

                        // else ok to display, remember roles are ok, break from userGroupsList
                        okRole = rule.Show;
                        break;
                    }
                }
                else // it is a type rule
                {
                    // if type has been ok-ed already, skip the rule
                    if (okType)
                    {
                        continue;
                    }

                    // remember we have type rules
                    hasType = true;

                    // if the entry does not apply, skip it
                    if (!rule.Matches(partA, partB))
                    {
                        continue;
                    }

                    // if the entry applies,
                    // if it's an exclude entry, exit, do not display the content app
                    if (!rule.Show)
                    {
                        return(null);
                    }

                    // else ok to display, remember type rules are ok
                    okType = true;
                }
            }

            // if roles rules are specified but not ok,
            // or if type roles are specified but not ok,
            // cannot display the content app
            if ((hasRole && !okRole) || (hasType && !okType))
            {
                return(null);
            }

            // else
            // content app can be displayed
            return(_app ?? (_app = new ContentApp
            {
                Alias = _definition.Alias,
                Name = _definition.Name,
                Icon = _definition.Icon,
                View = _definition.View,
                Weight = _definition.Weight
            }));
        }
Exemplo n.º 4
0
        public void duplicateRightClickMenu_ItemClicked(object sender,
                                                        ToolStripItemClickedEventArgs e)
        {
            this.duplicateRightClickMenu.Close();

            if (e.ClickedItem.Tag != null)
            {
                RightClickCommands n = (RightClickCommands)e.ClickedItem.Tag;

                ShowItem si = this.mlastSelected?.ShowItem;

                switch (n)
                {
                case RightClickCommands.kEpisodeGuideForShow:     // epguide
                    if (this.mlastSelected != null)
                    {
                        this.mainUI.GotoEpguideFor(this.mlastSelected.Episode, true);
                    }
                    else
                    {
                        if (si != null)
                        {
                            this.mainUI.GotoEpguideFor(si, true);
                        }
                    }
                    Close();
                    break;


                case RightClickCommands.kForceRefreshSeries:
                    if (si != null)
                    {
                        this.mainUI.ForceRefresh(new List <ShowItem> {
                            this.mlastSelected.ShowItem
                        });
                    }
                    Close();
                    break;

                case RightClickCommands.kEditShow:
                    if (si != null)
                    {
                        this.mainUI.EditShow(si);
                    }
                    break;

                case RightClickCommands.kEditSeason:
                    if (si != null)
                    {
                        this.mainUI.EditSeason(si, this.mlastSelected.SeasonNumber);
                    }
                    break;

                case RightClickCommands.kAddRule:
                    ShowRule sr = new ShowRule();
                    sr.DoWhatNow = RuleAction.kMerge;
                    sr.First     = this.mlastSelected.episodeOne.AppropriateEpNum;
                    sr.Second    = this.mlastSelected.episodeTwo.AppropriateEpNum;

                    si?.AddSeasonRule(this.mlastSelected.SeasonNumber, sr);

                    this.lvDuplicates.Items.Remove(this.mlastClicked);
                    this.dupEps.Remove(this.mlastSelected);
                    break;

                default:
                {
/*                        if ((n >= RightClickCommands.kWatchBase) && (n < RightClickCommands.kOpenFolderBase))
 *                      {
 *                          int wn = n - RightClickCommands.kWatchBase;
 *                          if ((this.mLastFL != null) && (wn >= 0) && (wn < this.mLastFL.Count))
 *                              Helpers.SysOpen(this.mLastFL[wn].FullName);
 *                      }
 *                      else if (n >= RightClickCommands.kOpenFolderBase)
 *                      {
 *                          int fnum = n - RightClickCommands.kOpenFolderBase;
 *
 *                          if (fnum < this.mFoldersToOpen.Count)
 *                          {
 *                              string folder = this.mFoldersToOpen[fnum];
 *
 *                              if (Directory.Exists(folder))
 *                                  Helpers.SysOpen(folder);
 *                          }
 *
 *                          return;
 *                      }
 *                      else*/
                    System.Diagnostics.Debug.Fail("Unknown right-click action " + n);

                    break;
                }
                }
            }

            this.mlastSelected = null;
        }
Exemplo n.º 5
0
 private void 显示标尺(object sender, EventArgs e)
 {
     ShowRule = !ShowRule;
     _currentSetting.SetConfigValue(Settings.ConfigItem.显示标尺, ShowRule.ToString());
 }
Exemplo n.º 6
0
    /// <inheritdoc />
    public ContentApp?GetContentAppFor(object o, IEnumerable <IReadOnlyUserGroup> userGroups)
    {
        string?partA, partB;

        switch (o)
        {
        case IContent content:
            partA = "content";
            partB = content.ContentType.Alias;
            break;

        case IMedia media:
            partA = "media";
            partB = media.ContentType.Alias;
            break;

        case IMember member:
            partA = "member";
            partB = member.ContentType.Alias;
            break;

        case IContentType contentType:
            partA = "contentType";
            partB = contentType?.Alias;
            break;

        case IDictionaryItem _:
            partA = "dictionary";
            partB = "*";     // Not really a different type for dictionary items
            break;

        default:
            return(null);
        }

        ShowRule[] rules          = _showRules ??= ShowRule.Parse(_definition.Show).ToArray();
        var        userGroupsList = userGroups.ToList();

        var okRole  = false;
        var hasRole = false;
        var okType  = false;
        var hasType = false;

        foreach (ShowRule rule in rules)
        {
            if (rule.PartA?.InvariantEquals("role") ?? false)
            {
                // if roles have been ok-ed already, skip the rule
                if (okRole)
                {
                    continue;
                }

                // remember we have role rules
                hasRole = true;

                foreach (IReadOnlyUserGroup group in userGroupsList)
                {
                    // if the entry does not apply, skip
                    if (!rule.Matches("role", group.Alias))
                    {
                        continue;
                    }

                    // if the entry applies,
                    // if it's an exclude entry, exit, do not display the content app
                    if (!rule.Show)
                    {
                        return(null);
                    }

                    // else ok to display, remember roles are ok, break from userGroupsList
                    okRole = rule.Show;
                    break;
                }
            }

            // it is a type rule
            else
            {
                // if type has been ok-ed already, skip the rule
                if (okType)
                {
                    continue;
                }

                // remember we have type rules
                hasType = true;

                // if the entry does not apply, skip it
                if (!rule.Matches(partA, partB))
                {
                    continue;
                }

                // if the entry applies,
                // if it's an exclude entry, exit, do not display the content app
                if (!rule.Show)
                {
                    return(null);
                }

                // else ok to display, remember type rules are ok
                okType = true;
            }
        }

        // if roles rules are specified but not ok,
        // or if type roles are specified but not ok,
        // cannot display the content app
        if ((hasRole && !okRole) || (hasType && !okType))
        {
            return(null);
        }

        // else
        // content app can be displayed
        return(_app ??= new ContentApp
        {
            Alias = _definition.Alias,
            Name = _definition.Name,
            Icon = _definition.Icon,
            View = _ioHelper.ResolveRelativeOrVirtualUrl(_definition.View),
            Weight = _definition.Weight,
        });
    }