Example #1
0
        /// <summary>
        /// Добавление нового редактора
        /// </summary>
        /// <param name="editor">Редактор</param>
        public static void AddEditor(BaseForm editor)
        {
            if (Editors != null)
            {
                if (Editors.Contains(editor))
                {
                    return;
                }
            }

            TabPage p = new TabPage(editor.Name);

            p.Tag = (object)editor;

            editor.FormBorderStyle = FormBorderStyle.None;
            editor.Dock            = DockStyle.Fill;
            editor.TopLevel        = false;
            editor.TextChanged    += delegate(object sender, EventArgs e) {
                p.Text = ((BaseForm)sender).Text;
            };
            p.Controls.Add(editor);
            editor.Show();
            W.projectTabs.AddTab(p, true);

            List <BaseForm> edlist = Editors != null?Editors.ToList() : new List <BaseForm>();

            edlist.Add(editor);
            Editors = edlist.ToArray();
        }
Example #2
0
 public IEnumerable ArticlesByEditors()
 {
     for (int i = 0; i < ArticlesList.Count; i++)
     {
         if (Editors.Contains((ArticlesList[i]).Author))
         {
             yield return(ArticlesList[i]);
         }
     }
 }
Example #3
0
        /// <summary>
        /// Закрытие редактора
        /// </summary>
        /// <param name="editor">Редактор</param>
        public static void RemoveEditor(BaseForm editor)
        {
            if (Editors != null)
            {
                if (!Editors.Contains(editor))
                {
                    return;
                }
            }

            TabPage p = GetPageForEditor(editor);

            if (p == null)
            {
                return;
            }
        }
Example #4
0
        /// <summary>
        /// Фокус на указанный редактор
        /// </summary>
        /// <param name="e">Редактор</param>
        /// <returns>True если фокус успешен</returns>
        public static bool FocusEditor(Editor e)
        {
            if (W == null)
            {
                return(false);
            }
            if (Editors != null)
            {
                if (!Editors.Contains(e.Form))
                {
                    return(false);
                }
            }

            W.projectTabs.SelectedTab = e.Form.Tag as TabPage;
            return(true);
        }
Example #5
0
        /// <summary>
        /// Закрытие редактора
        /// </summary>
        /// <param name="e">Редактор который необходимо закрыть</param>
        public static bool CloseEditor(Editor e, bool force = false)
        {
            if (Editors != null)
            {
                if (!Editors.Contains(e.Form))
                {
                    return(true);
                }
            }
            bool close = true;

            if (!force)
            {
                close = e.AllowClose();
            }

            if (close)
            {
                TabPage tp = null;
                foreach (TabPage t in W.projectTabs.TabPages)
                {
                    if (tp.Tag == (object)e.Form)
                    {
                        tp = t;
                        break;
                    }
                }
                if (tp != null)
                {
                    W.projectTabs.RemoveTab(tp);
                    List <BaseForm> edlist = Editors == null ? new List <BaseForm>() : Editors.ToList();
                    if (edlist.Contains(e.Form))
                    {
                        edlist.Remove(e.Form);
                    }
                    Editors = edlist.ToArray();
                }
            }
            return(close);
        }
 /// <summary>Find out if a principal has a certain permission by default.</summary>
 /// <param name="user">The principal to check for allowance.</param>
 /// <param name="permission">The type of permission to map against.</param>
 /// <returns>True if the system is configured to allow the user to the given permission.</returns>
 public virtual bool IsAuthorized(IPrincipal user, Permission permission)
 {
     return((Administrators.MapsTo(permission) && Administrators.Contains(user)) ||
            (Editors.MapsTo(permission) && Editors.Contains(user)) ||
            (Writers.MapsTo(permission) && Writers.Contains(user)));
 }
 /// <summary>Find out if a princpial has edit access.</summary>
 /// <param name="user">The princpial to check.</param>
 /// <returns>A boolean indicating whether the principal has edit access.</returns>
 public virtual bool IsEditor(IPrincipal user)
 {
     return(IsAdmin(user) || Editors.Contains(user) || Writers.Contains(user));
 }