Пример #1
0
        private void UpdateContent()
        {
            ReleaseVM();
            if (CurrentUid.Equals(Guid.Empty))
            {
                m_body.Content       = null;
                m_namedViewModel     = new BlankVM();
                m_seeAlso.Visibility = Visibility.Collapsed;
                UiManager.CastDocumentCommand(EDocumentCommand.SELECTED, EAlphaKind.NONE, EAlphaDocumentKind.BLANK, Guid.Empty);
            }
            else
            {
                var descriptor = m_history[m_current].Item2;
                m_body.Content = descriptor.Generate(CurrentUid, out m_namedViewModel);
                UiManager.CastUiMessage(EUiEvent.SELECTED, m_namedViewModel.Kind, CurrentUid);
                foreach (var dscr in UiManager.GetDocumentDescriptors(m_namedViewModel.Kind))
                {
                    if (dscr.DocKind != descriptor.DocKind)
                    {
                        SeeAlso.Add(new AlphaSpecificDocumentVM(dscr, CurrentUid));
                    }
                }
                m_seeAlso.Visibility = Visibility.Visible;
                UiManager.CastDocumentCommand(EDocumentCommand.SELECTED, m_namedViewModel.Kind, descriptor.DocKind, CurrentUid);
                m_namedViewModel.PropertyChanged += NamedViewModelOnPropertyChanged;
            }

            UpdateTitle();
        }
Пример #2
0
 public override void VisitSeeAlso(SeeAlso seeAlso)
 {
     //if (seeAlso.Cref != null)
     //{
     //    var cref = NormalizeLink(seeAlso.Cref);
     //    Console.WriteLine("[{0}]({1})", cref.Substring(2), cref);
     //}
 }
Пример #3
0
        /// <summary>
        /// Insert all of the resources added in the control to the database.
        /// </summary>
        /// <param name="moduleID">The module identifer to which the
        /// resources should be added.</param>
        public void insertAll(int moduleID, bool removePrevious)
        {
            if (removePrevious)
            {
                SeeAlso.removeAll(moduleID);
            }

            SeeAlso.addAll(moduleID, SeeAlsoEditor.DataList);
        }
Пример #4
0
 private void ReleaseVM()
 {
     if (m_namedViewModel != null)
     {
         if (!(m_namedViewModel is BlankVM))
         {
             AlphaClient.Instance.Release(m_namedViewModel);
             m_namedViewModel.PropertyChanged -= NamedViewModelOnPropertyChanged;
         }
     }
     SeeAlso.Clear();
 }
Пример #5
0
 /// <summary>
 /// Initialize the list of resources.
 /// </summary>
 /// <param name="moduleID">The module identifier for the
 /// initial list of resources or 0 if it should be initially empty.</param>
 public void initList(int moduleID)
 {
     if (moduleID == 0)
     {
         SeeAlsoEditor.DataList = new ArrayList();
         SeeAlsoEditor.DataBind();
     }
     else if (moduleID > 0)
     {
         SeeAlsoEditor.DataList = SeeAlso.getAll(moduleID);
         SeeAlsoEditor.DataBind();
     }
     else
     {
         throw new ArgumentException("Invalid module identifier.", "moduleID");
     }
 }
        /// <summary>
        ///   Visits the <c>seealso</c> documentation element.
        /// </summary>
        ///
        public override void VisitSeeAlso(SeeAlso seeAlso)
        {
            string url  = DistributionManager.GetDocumentationUrl(seeAlso.Cref);
            string text = parse(seeAlso.Cref, false);

            var hyperlink = new HyperlinkViewModel()
            {
                Url = url, Text = text
            };

            if (!String.IsNullOrEmpty(seeAlso.Content))
            {
                hyperlink.Text = seeAlso.Content;
            }

            current.SeeAlso.Add(hyperlink);
        }
 public override void VisitSeeAlso(SeeAlso seeAlso)
 {
     var cref = _normalizeLink(seeAlso.Cref);
     _builder.AppendFormat("[{0}]({1})", cref.Substring(2), cref);
 }
        private void Page_Load(object sender, System.EventArgs e)
        {
            if (!IsPostBack)
            {
                try {
                    string strModuleID = Request.Params["moduleID"];

                    if (strModuleID != null)
                    {
                        int moduleID = int.Parse(Request.Params["moduleID"]);
                        Modules.ModuleInfo modInfo = Modules.getModuleInfo(moduleID);
                        ModInfo     = modInfo;
                        isSubmitter = ModulesControl.isModuleSubmitter(User.Identity.Name, modInfo.Id);
                        isAuthor    = ModulesControl.isModuleAuthor(User.Identity.Name, modInfo.Id);
                        bool isEditor = User.IsInRole(UserRole.Editor.ToString());

                        // If the user is not an editor...
                        if (!isEditor)
                        {
                            if (modInfo.Status == ModuleStatus.PreviousVersion)
                            {
                                // If the module being viewed is a previous version, display the newest
                                // version of the module, and tell the user.
                                Modules.ModuleInfo curVer = Modules.getModuleCurrentVersion(modInfo.BaseId);
                                string             newUrl = "viewModule.aspx?moduleID=" + curVer.Id;
                                lblMessage.Text = "There is a <a href=\"" + newUrl + "\">newer version</a> of the module you are trying to access.  "
                                                  + "You will be directed to it momentarily.";
                                Response.AppendHeader("Refresh", REFRESH_DELAY + "; URL=" + newUrl);
                                disableModule();
                                return;
                            }
                            else if (modInfo.Status != ModuleStatus.Approved && !isSubmitter)
                            {
                                // If it is the newest version, but has not been approved
                                // and this user is not the submitter, do not let them view
                                // the module.
                                disableModule();
                                lblMessage.Text = "Module not available.";
                                return;
                            }
                        }

                        // Modules.Size

                        string[] labels = { "Lecture",
                                            "Lab",
                                            "Exercise",
                                            "Homework",
                                            "Other" };
                        string[] sizeText = { modInfo.LectureSize,
                                              modInfo.LabSize,
                                              modInfo.ExerciseSize,
                                              modInfo.HomeworkSize,
                                              modInfo.OtherSize };

                        ArrayList sizes = new ArrayList(NUM_SIZES);

                        for (int i = 0; i < NUM_SIZES; i++)
                        {
                            if (!sizeText[i].Equals(""))
                            {
                                sizes.Add("<strong>" + labels[i] + "</strong>: " + sizeText[i]);
                            }
                        }

                        SizeRepeater.DataSource = sizes;
                        SizeRepeater.DataBind();

                        // Authors

                        AuthorsRepeater.DataSource = Authors.getAll(modInfo.Id);
                        AuthorsRepeater.DataBind();

                        // Materials
                        // Since Materials aren't displayed as simply as other
                        // areas, some modification needs to be done
                        // Retrieve the materials that the user has the access level right to acquire
                        tempMats1 = getAccessLevelFilesList(moduleID);                         //Materials.getAll( moduleID );
                        ArrayList tempMats2   = new ArrayList();
                        ArrayList knownTitles = new ArrayList();
                        int       pos         = 0;

                        foreach (Materials.MaterialInfo mi in tempMats1)
                        {
                            int    position = mi.Link.LastIndexOf('.'); // temp value for extracting the title and extension
                            string title;                               // the title part of the filename
                            string extension;                           // the extension of the filename

                            if (position == -1)
                            {
                                title     = "(No Title)";
                                extension = mi.Link;
                            }
                            else
                            {
                                title     = mi.Link.Substring(0, position);
                                extension = getFormat(mi.Link.Substring(position + 1));
                            }

                            // this is the reference to the current material that will
                            // be added to the materials repeater in the html
                            string reference = "(<a href='Materials/" + mi.ModuleID + "/" + mi.Link +
                                               "' target='_blank'>" + extension + "</a>)";

                            // see if we've already come across this title
                            int index = knownTitles.IndexOf(title.ToLower());

                            if (index == -1)
                            {
                                // Means that the title hasn't already been found,
                                // so we need to add it as a new Material group
                                tempMats2.Add(new Materials.MaterialInfo(mi.Id, mi.IdentInfo, reference,
                                                                         mi.ModuleID, mi.RatingImage, mi.Rating,
                                                                         mi.AccessFlag));
                                knownTitles.Add(title.ToLower());
                            }
                            else
                            {
                                // Means that the title has already been found, so we
                                // need to add a link for this extra Material to the
                                // appropriate existing Material group
                                ((Materials.MaterialInfo)(tempMats2[index])).Link += " " + reference;
                            }
                        }

                        MaterialsRepeater.DataSource = tempMats2;
                        MaterialsRepeater.DataBind();

                        // Categories

                        CategoriesRepeater.DataSource = Categories.getAll(modInfo.Id);
                        CategoriesRepeater.DataBind();

                        // Prerequisites

                        PrereqRepeater.DataSource = Prerequisites.getAll(modInfo.Id);
                        PrereqRepeater.DataBind();

                        // Objectives

                        ObjectivesRepeater.DataSource = Objectives.getAll(modInfo.Id);
                        ObjectivesRepeater.DataBind();

                        // Topics

                        TopicsRepeater.DataSource = Topics.getAll(modInfo.Id);
                        TopicsRepeater.DataBind();

                        // Resources

                        IList resourcesList = Resources.getAll(modInfo.Id);

                        // If there are no resources, display text that says so.
                        if (resourcesList.Count == 0)
                        {
                            ResourcesRepeater.Controls.Add(new LiteralControl("<p>No resources.</p>"));
                        }
                        else
                        {
                            ResourcesRepeater.DataSource = resourcesList;
                            ResourcesRepeater.DataBind();
                        }

                        // See Also

                        IList seeAlsoList = SeeAlso.getAll(modInfo.Id);

                        // If there are no alternate modules, display text that says so.
                        if (seeAlsoList.Count == 0)
                        {
                            SeeAlsoRepeater.Controls.Add(new LiteralControl("<p>No alternate modules.</p>"));
                        }
                        else
                        {
                            SeeAlsoRepeater.DataSource = seeAlsoList;
                            SeeAlsoRepeater.DataBind();
                        }

                        // Ratings

                        if (modInfo.Status == ModuleStatus.Approved)
                        {
                            ModuleRatingInfo mci = ModuleRatings.getRating(modInfo.Id);
                            RateModuleControl1.RatingInfo = mci;

                            // Submitters and authors can't rate their own modules.
                            if (isSubmitter || isAuthor)
                            {
                                RateModuleControl1.AddRatingEnabled = false;
                                RatingsMessage.Text = "<p>You may not rate a module that " +
                                                      "you have submitted or are listed as an author of.</p>";
                            }
                            else
                            {
                                Rating rating = ModuleRatingsControl.getRatingForUser(User.Identity.Name, mci);
                                RateModuleControl1.UserRating = rating;
                            }
                        }
                        else
                        {
                            disableRatings();
                        }

                        // Related Modules
                        IList related = ModuleGroups.getRelatedModules(modInfo.BaseId);

                        if (related.Count == 0)
                        {
                            H21.Visible = false;
                        }
                        else
                        {
                            RelatedRepeater.DataSource = related;
                            RelatedRepeater.DataBind();
                        }
                    }
                    else
                    {
                        lblMessage.Text =
                            "An error occurred while attempting to get the requested module." +
                            "  No module was specified.  <a href=\"browseModules.aspx\">Browse</a>" +
                            " or <a href=\"search.aspx\">search</a> to select a module to view.";
                    }
                } catch (Exception ex) {
                    lblMessage.Text =
                        "An error occurred while attempting to get the requested module." +
                        "  " + ex.Message + " " + ex.StackTrace;
                }
            }
        }
Пример #9
0
 public virtual void VisitSeeAlso(SeeAlso seeAlso)
 {
 }
Пример #10
0
        /// <summary>
        /// See <see cref="Visitor.VisitSeeAlso"/>.
        /// </summary>
        public override void VisitSeeAlso(SeeAlso seeAlso)
        {
            if (delegates.VisitSeeAlso != null)
                delegates.VisitSeeAlso(seeAlso);

            base.VisitSeeAlso(seeAlso);
        }
Пример #11
0
        /// <summary>
        /// Reads all supported documentation elements.
        /// </summary>
        private static IEnumerable<Element> ReadContent(XElement xml)
        {
            foreach (var node in xml.Nodes())
            {
                var element = default(Element);
                switch (node.NodeType)
                {
                    case System.Xml.XmlNodeType.Element:
                        var elementNode = (XElement)node;
                        switch (elementNode.Name.LocalName)
                        {
                            case "summary":
                                element = new Summary(ReadContent(elementNode));
                                break;
                            case "remarks":
                                element = new Remarks(ReadContent(elementNode));
                                break;
                            case "example":
                                element = new Example(ReadContent(elementNode));
                                break;
                            case "para":
                                element = new Para(ReadContent(elementNode));
                                break;
                            case "param":
                                element = new Param(FindAttribute(elementNode, "name"), ReadContent(elementNode));
                                break;
                            case "paramref":
                                element = new ParamRef(FindAttribute(elementNode, "name"));
                                break;
                            case "typeparam":
                                element = new TypeParam(FindAttribute(elementNode, "name"), ReadContent(elementNode));
                                break;
                            case "typeparamref":
                                element = new TypeParamRef(FindAttribute(elementNode, "name"));
                                break;
                            case "code":
                                element = new Code(TrimCode(elementNode.Value));
                                break;
                            case "c":
                                element = new C(elementNode.Value);
                                break;
                            case "see":
                                element = new See(FindAttribute(elementNode, "cref"), FindAttribute(elementNode, "langword"), elementNode.Value, ReadContent(elementNode));
                                break;
                            case "seealso":
                                element = new SeeAlso(FindAttribute(elementNode, "cref"), elementNode.Value, ReadContent(elementNode));
                                break;
                            case "list":
                                element = new List(FindAttribute(elementNode, "type"), ReadContent(elementNode));
                                break;
                            case "listheader":
                                element = new ListHeader(ReadContent(elementNode));
                                break;
                            case "term":
                                element = new Term(ReadContent(elementNode));
                                break;
                            case "description":
                                element = new Description(ReadContent(elementNode));
                                break;
                            case "item":
                                element = new Item(ReadContent(elementNode));
                                break;
                            case "exception":
                                element = new Exception(FindAttribute(elementNode, "cref"), ReadContent(elementNode));
                                break;
                            case "value":
                                element = new Value(ReadContent(elementNode));
                                break;
                            case "returns":
                                element = new Returns(ReadContent(elementNode));
                                break;
                            default:
                                element = new UnknownElement(elementNode, ReadContent(elementNode));
                                break;
                        }
                        break;
                    case System.Xml.XmlNodeType.Text:
                        element = new Text(TrimText(((XText)node).Value));
                        break;
                    default:
                        break;
                }

                if (element != null)
                {
                    element.SetLineInfo(xml as IXmlLineInfo);
                    yield return element;
                }
            }
        }
Пример #12
0
 /// <summary>
 /// Visits the <c>seealso</c> documentation element.
 /// </summary>
 public virtual void VisitSeeAlso(SeeAlso seeAlso)
 {
     VisitElement(seeAlso);
 }
Пример #13
0
        public override void VisitSeeAlso(SeeAlso seeAlso)
        {
            var cref = _normalizeLink(seeAlso.Cref);

            _builder.AppendFormat("[{0}]({1})", cref.Substring(2), cref);
        }
Пример #14
0
 public virtual void VisitSeeAlso(SeeAlso seeAlso)
 {
 }
        /// <summary>
        ///   Visits the <c>seealso</c> documentation element.
        /// </summary>
        /// 
        public override void VisitSeeAlso(SeeAlso seeAlso)
        {
            string url = DistributionManager.GetDocumentationUrl(seeAlso.Cref);
            string text = parse(seeAlso.Cref, false);

            var hyperlink = new HyperlinkViewModel() { Url = url, Text = text };

            if (!String.IsNullOrEmpty(seeAlso.Content))
                hyperlink.Text = seeAlso.Content;

            current.SeeAlso.Add(hyperlink);
        }
Пример #16
0
            public override void VisitSeeAlso(SeeAlso seeAlso)
            {
                var cref = NormalizeLink(seeAlso.Cref);

                Console.WriteLine("[{0}]({1})", cref.Substring(2), cref);
            }