Exemple #1
0
        void CaseViewShowAll(NSObject sender)
        {
            float  fontSize = 13.0f;
            nfloat height   = HeightWrappedToWidth(CaseTextField, fontSize);

            if (!isCaseViewExpand)
            {
                nfloat orgHeight = CaseTextField.Frame.Size.Height;
                nfloat offset    = height - orgHeight;
                var    oldSize   = DescriptionView.Frame.Size;
                var    newSize   = new CGSize(oldSize.Width, caseViewHeight + offset);
                CaseView.SetFrameSize(newSize);

                var button = (NSButton)CaseView.Subviews [3];
                NSAttributedString title = Utility.AttributeTitle("...less", Utility.ColorWithRGB(44, 117, 252, 1.0f), 12);
                button.Cell.AttributedTitle = title;

                isCaseViewExpand = true;
            }
            else
            {
                var oldSize = CaseView.Frame.Size;
                var newSize = new CGSize(oldSize.Width, caseViewHeight);
                CaseView.SetFrameSize(newSize);

                var button = (NSButton)CaseView.Subviews [3];
                NSAttributedString title = Utility.AttributeTitle("...more", Utility.ColorWithRGB(44, 117, 252, 1.0f), 12);
                button.Cell.AttributedTitle = title;

                isCaseViewExpand = false;
            }

            LayoutSubViews();
        }
Exemple #2
0
        public MainWindow()
        {
            InitializeComponent();

            //Create the board
            for (int i = 0; i < 8; i++)
            {
                ColumnDefinition columnDefinition = new ColumnDefinition();
                RowDefinition    rowDefinition    = new RowDefinition();
                board.ColumnDefinitions.Add(columnDefinition);
                board.RowDefinitions.Add(rowDefinition);
            }


            //Fill each case of the board
            for (int i = 0; i < 8; i++)
            {
                for (int j = 0; j < 8; j++)
                {
                    CaseView caseBoard = new CaseView(j, i);
                    Grid.SetRow(caseBoard, i);
                    Grid.SetColumn(caseBoard, j);
                    board.Children.Add(caseBoard);
                }
            }
            //Init the game
            OthelloManager.Instance.InitGame();

            this.DataContext = new ViewModel();
        }
Exemple #3
0
        //cases
        void InitializeCasesView()
        {
            if (isFTC)
            {
                CaseView.Hidden = false;
            }
            else
            {
                CaseView.Hidden = true;
            }

            if (BookInfo == null)
            {
                return;
            }

            float fontSize = 13.0f;

            string description = "What can you expect from your subscription to the new + Cases titles: \n" +
                                 "- The same great content you know and trust, automatically updated. \n" +
                                 "- Inclusion of new additional content from our unreported judgment \n" +
                                 "  database: \n" +
                                 "   - High value text cases chosen based on their high degree of \n" +
                                 "     relevance to this title; \n" +
                                 "   - Offline accessibility to this content within your Red title; \n" +
                                 "   - Ability to link between the analytical and case content within \n" +
                                 "     this title, and between your other Red titles; \n" +
                                 "   - Use of Red’s award winning annotation, highlighting and legal \n" +
                                 "     define features on the text cases within this title. \n" +
                                 "\n" +
                                 "Please don’t hesitate to contact your Relationship Manager should you have any questions or feedback regarding your subscription. ";

            CaseTextField.StringValue = description;

            caseViewHeight = CaseView.Frame.Size.Height;

            var height = HeightWrappedToWidth(CaseTextField, fontSize);

            if (height > TEXTVIEW_SIXLINE_HEIGHT)
            {
                NSButton moreButton = CreateMoreButton();
                DescriptionView.WantsLayer = true;
                moreButton.Action          = new Selector("CaseViewShowAll:");
                moreButton.Target          = this;
                CaseView.AddSubview(moreButton);

                isCaseViewExpand = false;
            }
            else
            {
                nfloat orgHeight = CaseTextField.Frame.Size.Height;
                nfloat offset    = height - orgHeight;
                var    oldSize   = CaseView.Frame.Size;
                var    newSize   = new CGSize(oldSize.Width, caseViewHeight + offset);
                CaseView.SetFrameSize(newSize);
            }
        }
 protected bool Contains(CaseView obj, string search)
 {
     if (obj == null)
     {
         return(false);
     }
     return(Contains(obj.Title, search) ||
            Contains(obj.Description, search) ||
            Contains(obj.GetPunishment(_translator), search) ||
            Contains(obj.Username, search) ||
            Contains(obj.Discriminator, search) ||
            Contains(obj.Nickname, search) ||
            Contains(obj.UserId, search) ||
            Contains(obj.ModId, search) ||
            Contains(obj.LastEditedByModId, search) ||
            Contains(obj.CreatedAt, search) ||
            Contains(obj.OccuredAt, search) ||
            Contains(obj.LastEditedAt, search) ||
            Contains(obj.Labels, search) ||
            Contains(obj.CaseId.ToString(), search) ||
            Contains($"#{obj.CaseId}", search));
 }
 private void btn_InvertCase_Click(object sender, RibbonControlEventArgs e)
 {
     CaseView caseview = new CaseView();
 }
Exemple #6
0
        void ReleaseDesignerOutlets()
        {
            if (AContentView != null)
            {
                AContentView.Dispose();
                AContentView = null;
            }

            if (AreaLabel != null)
            {
                AreaLabel.Dispose();
                AreaLabel = null;
            }

            if (AuthorLabel != null)
            {
                AuthorLabel.Dispose();
                AuthorLabel = null;
            }

            if (BookSize != null)
            {
                BookSize.Dispose();
                BookSize = null;
            }

            if (BookSizeLabel != null)
            {
                BookSizeLabel.Dispose();
                BookSizeLabel = null;
            }

            if (BookTitleLabel != null)
            {
                BookTitleLabel.Dispose();
                BookTitleLabel = null;
            }

            if (CaseLabel != null)
            {
                CaseLabel.Dispose();
                CaseLabel = null;
            }

            if (CasesButton != null)
            {
                CasesButton.Dispose();
                CasesButton = null;
            }

            if (CaseTextField != null)
            {
                CaseTextField.Dispose();
                CaseTextField = null;
            }

            if (CaseView != null)
            {
                CaseView.Dispose();
                CaseView = null;
            }

            if (ContactEmailLabel != null)
            {
                ContactEmailLabel.Dispose();
                ContactEmailLabel = null;
            }

            if (ContactPhoneLabel != null)
            {
                ContactPhoneLabel.Dispose();
                ContactPhoneLabel = null;
            }

            if (CoverImageView != null)
            {
                CoverImageView.Dispose();
                CoverImageView = null;
            }

            if (CurrencyDate != null)
            {
                CurrencyDate.Dispose();
                CurrencyDate = null;
            }

            if (CurrencyDateLabel != null)
            {
                CurrencyDateLabel.Dispose();
                CurrencyDateLabel = null;
            }

            if (CurrentDayLabel != null)
            {
                CurrentDayLabel.Dispose();
                CurrentDayLabel = null;
            }

            if (DescriptionLabel != null)
            {
                DescriptionLabel.Dispose();
                DescriptionLabel = null;
            }

            if (DescriptionView != null)
            {
                DescriptionView.Dispose();
                DescriptionView = null;
            }

            if (DespTextField != null)
            {
                DespTextField.Dispose();
                DespTextField = null;
            }

            if (ExpiredInfoTF != null)
            {
                ExpiredInfoTF.Dispose();
                ExpiredInfoTF = null;
            }

            if (ExpiredLabel != null)
            {
                ExpiredLabel.Dispose();
                ExpiredLabel = null;
            }

            if (ExpiredView != null)
            {
                ExpiredView.Dispose();
                ExpiredView = null;
            }

            if (InfoLabel != null)
            {
                InfoLabel.Dispose();
                InfoLabel = null;
            }

            if (InformationView != null)
            {
                InformationView.Dispose();
                InformationView = null;
            }

            if (InstalledDate != null)
            {
                InstalledDate.Dispose();
                InstalledDate = null;
            }

            if (InstalledLabel != null)
            {
                InstalledLabel.Dispose();
                InstalledLabel = null;
            }

            if (LoanButton != null)
            {
                LoanButton.Dispose();
                LoanButton = null;
            }

            if (PracticeArea != null)
            {
                PracticeArea.Dispose();
                PracticeArea = null;
            }

            if (ProgressBar != null)
            {
                ProgressBar.Dispose();
                ProgressBar = null;
            }

            if (ProgressStatusLabel != null)
            {
                ProgressStatusLabel.Dispose();
                ProgressStatusLabel = null;
            }

            if (ProgressView != null)
            {
                ProgressView.Dispose();
                ProgressView = null;
            }

            if (ScrollView != null)
            {
                ScrollView.Dispose();
                ScrollView = null;
            }

            if (Subcategory != null)
            {
                Subcategory.Dispose();
                Subcategory = null;
            }

            if (SubcategoryLabel != null)
            {
                SubcategoryLabel.Dispose();
                SubcategoryLabel = null;
            }

            if (TagsView != null)
            {
                TagsView.Dispose();
                TagsView = null;
            }

            if (TitleView != null)
            {
                TitleView.Dispose();
                TitleView = null;
            }

            if (UpdateButton != null)
            {
                UpdateButton.Dispose();
                UpdateButton = null;
            }

            if (UpdateInfoLabel != null)
            {
                UpdateInfoLabel.Dispose();
                UpdateInfoLabel = null;
            }

            if (Version != null)
            {
                Version.Dispose();
                Version = null;
            }

            if (VersionLabel != null)
            {
                VersionLabel.Dispose();
                VersionLabel = null;
            }

            if (WhatNewInfoLabel != null)
            {
                WhatNewInfoLabel.Dispose();
                WhatNewInfoLabel = null;
            }

            if (WhatNewInfoView != null)
            {
                WhatNewInfoView.Dispose();
                WhatNewInfoView = null;
            }

            if (WhatNewLabel != null)
            {
                WhatNewLabel.Dispose();
                WhatNewLabel = null;
            }

            if (WhatNewView != null)
            {
                WhatNewView.Dispose();
                WhatNewView = null;
            }

            if (DotButton != null)
            {
                DotButton.Dispose();
                DotButton = null;
            }
        }
Exemple #7
0
        void LayoutSubViews()
        {
            if (BookInfo == null)
            {
                return;
            }

            //calculate the subview size
            CGSize infoViewSize     = InformationView.Frame.Size;
            CGSize whatsNewViewSize = WhatNewView.Frame.Size;

            CGSize casesViewSize;

            if (CaseView.Hidden)
            {
                casesViewSize = new CGSize(0, 0);
            }
            else
            {
                casesViewSize = CaseView.Frame.Size;
            }

            CGSize despViewSize = DescriptionView.Frame.Size;

            CGSize expiredViewSize;

            if (BookInfo.DaysRemaining < 0)
            {
                expiredViewSize = ExpiredView.Frame.Size;
            }
            else
            {
                expiredViewSize = new CGSize(0, 0);
            }

            CGSize titleViewSize = TitleView.Frame.Size;

            //set scrollview contentview size
            nfloat caseSpace   = casesViewSize.Height == 0 ? 0 : VERTICAL_SPACING;
            nfloat expirdSpace = expiredViewSize.Height == 0 ? 0 : VERTICAL_SPACING;
            nfloat height      = VERTICAL_SPACING +
                                 infoViewSize.Height + VERTICAL_SPACING +
                                 whatsNewViewSize.Height + VERTICAL_SPACING +
                                 casesViewSize.Height + caseSpace +
                                 despViewSize.Height + VERTICAL_SPACING +
                                 expiredViewSize.Height + expirdSpace +
                                 titleViewSize.Height;

            CGRect scrollFrame = ScrollView.Frame;

            nfloat contentHeight = scrollFrame.Bottom > height ? scrollFrame.Bottom : height;

            var contentSize = new CGSize(AContentView.Frame.Size.Width, contentHeight);

            AContentView.SetFrameSize(contentSize);

            //add subview to document view
            var docView = (NSView)ScrollView.DocumentView;

            docView.SetFrameSize(contentSize);

            foreach (NSView view in docView.Subviews)
            {
                view.RemoveFromSuperview();
            }

            docView.AddSubview(AContentView);
            AContentView.SetFrameOrigin(new CGPoint(0, 0));

            //recalulate subviews origin point
            nfloat startOffset = scrollFrame.Bottom >= height ? (scrollFrame.Bottom - height + VERTICAL_SPACING) : VERTICAL_SPACING;
            nfloat yOffset;

            var InfoViewPoint = InformationView.Frame.Location;

            InfoViewPoint.Y = startOffset;
            InformationView.SetFrameOrigin(InfoViewPoint);

            var WhatsViewPoint = new CGPoint(InfoViewPoint.X, InfoViewPoint.Y + infoViewSize.Height + VERTICAL_SPACING);

            WhatNewView.SetFrameOrigin(WhatsViewPoint);

            var CaseViewPoint = new CGPoint(InfoViewPoint.X, WhatsViewPoint.Y + whatsNewViewSize.Height + VERTICAL_SPACING);

            CaseView.SetFrameOrigin(CaseViewPoint);

            if (casesViewSize.Height > 0)
            {
                yOffset = VERTICAL_SPACING;
            }
            else
            {
                yOffset = 0;
            }

            var DesViewPoint = new CGPoint(InfoViewPoint.X, CaseViewPoint.Y + casesViewSize.Height + yOffset);

            DescriptionView.SetFrameOrigin(DesViewPoint);

            var ExpireViewPoint = new CGPoint(InfoViewPoint.X, DesViewPoint.Y + despViewSize.Height + VERTICAL_SPACING);

            ExpiredView.SetFrameOrigin(ExpireViewPoint);

            if (expiredViewSize.Height > 0)
            {
                yOffset = VERTICAL_SPACING;
            }
            else
            {
                yOffset = 0;
            }

            var TitleViewPoint = new CGPoint(InfoViewPoint.X, ExpireViewPoint.Y + expiredViewSize.Height + yOffset);

            TitleView.SetFrameOrigin(TitleViewPoint);

            ScrollToTop();
        }
        public async Task <IActionResult> GetModCaseView([FromRoute] string guildid, [FromRoute] string caseid)
        {
            logger.LogInformation($"{HttpContext.Request.Method} {HttpContext.Request.Path} | Incoming request.");
            Identity currentIdentity = await identityManager.GetIdentity(HttpContext);

            User currentUser = await currentIdentity.GetCurrentDiscordUser();

            if (currentUser == null)
            {
                logger.LogInformation($"{HttpContext.Request.Method} {HttpContext.Request.Path} | 401 Unauthorized.");
                return(Unauthorized());
            }
            ModCase modCase = await database.SelectSpecificModCase(guildid, caseid);

            if (!await currentIdentity.HasModRoleOrHigherOnGuild(guildid, this.database) && !config.Value.SiteAdminDiscordUserIds.Contains(currentUser.Id))
            {
                if (modCase == null)
                {
                    logger.LogInformation($"{HttpContext.Request.Method} {HttpContext.Request.Path} | 401 Unauthorized.");
                    return(Unauthorized());
                }
                else
                {
                    if (modCase.UserId != currentUser.Id)
                    {
                        logger.LogInformation($"{HttpContext.Request.Method} {HttpContext.Request.Path} | 401 Unauthorized.");
                        return(Unauthorized());
                    }
                }
            }
            // ========================================================

            if (await database.SelectSpecificGuildConfig(guildid) == null)
            {
                logger.LogInformation($"{HttpContext.Request.Method} {HttpContext.Request.Path} | 400 Guild not registered.");
                return(BadRequest("Guild not registered."));
            }

            if (modCase == null)
            {
                logger.LogInformation($"{HttpContext.Request.Method} {HttpContext.Request.Path} | 404 ModCase not found.");
                return(NotFound());
            }

            List <CommentsView> comments = new List <CommentsView>();

            foreach (ModCaseComment comment in modCase.Comments)
            {
                comments.Add(new CommentsView()
                {
                    Id        = comment.Id,
                    Message   = comment.Message,
                    CreatedAt = comment.CreatedAt,
                    UserId    = comment.UserId,
                    User      = await discord.FetchUserInfoAsync(comment.UserId),
                });
            }

            CaseView caseView = new CaseView(
                modCase,
                await discord.FetchUserInfoAsync(modCase.ModId),
                await discord.FetchUserInfoAsync(modCase.LastEditedByModId),
                await discord.FetchUserInfoAsync(modCase.UserId),
                comments
                );

            logger.LogInformation($"{HttpContext.Request.Method} {HttpContext.Request.Path} | 200 Returning ModCase.");
            return(Ok(caseView));
        }