Beispiel #1
0
        public void Set(CircleController controller, IEnumerable<VotingDescriptor2> votings)
        {
            this.currentVotingListControl.Height = this.currentTabPage.ClientRectangle.Height - this.currentVotingListControl.Top;
              this.pastVotingListControl.Height = this.pastTabPage.ClientRectangle.Height - this.pastVotingListControl.Top;

              this.currentVotingListControl.Set(controller,
            votings.Where(voting =>
              voting.Status == VotingStatus.New ||
              voting.Status == VotingStatus.Sharing ||
              voting.Status == VotingStatus.Ready ||
              voting.Status == VotingStatus.Voting ||
              voting.Status == VotingStatus.Deciphering ||
              (voting.Status == VotingStatus.Finished &&
              DateTime.Now.Subtract(voting.VoteUntil).Days <= 14d))
              .OrderByDescending(voting => voting.VoteFrom));

              this.pastVotingListControl.Set(controller,
            votings.Where(voting =>
              voting.Status == VotingStatus.Aborted ||
              voting.Status == VotingStatus.Offline ||
              (voting.Status == VotingStatus.Finished &&
              DateTime.Now.Subtract(voting.VoteUntil).Days > 14d))
              .OrderByDescending(voting => voting.VoteFrom));

              this.certificateStatus.Controller = controller;
              this.certificateStatus.UpdateDisplay();
        }
Beispiel #2
0
        public void Set(CircleController controller, IEnumerable<VotingDescriptor2> newVotings)
        {
            SuspendLayout();

              var oldQueue = new Queue<VotingDescriptor2>(this.votings);
              var newQueue = new Queue<VotingDescriptor2>(newVotings);
              var oldControlQueue = new Queue<VotingControl>(this.controls);
              var newControlQueue = new Queue<VotingControl>();
              this.votings = new List<VotingDescriptor2>();
              int top = 0;
              this.VerticalScroll.Value = 0;
              Invalidate();

              this.emptyLabel.Visible = newVotings.Count() == 0;

              while (oldQueue.Count > 0 ||
             newQueue.Count > 0)
              {
            if (oldQueue.Count > 0 &&
            newQueue.Count > 0 &&
            oldQueue.Peek().Id.Equals(newQueue.Peek().Id))
            {
              oldQueue.Dequeue();
              var newVoting = newQueue.Dequeue();
              this.votings.Add(newVoting);

              VotingControl control = oldControlQueue.Dequeue();
              control.Voting = newVoting;
              control.Left = 0;
              control.Top = top;
              control.UpdateDisplay();
              newControlQueue.Enqueue(control);

              top += control.Height + VerticalSpace;
             }
            else if (oldQueue.Count > 0 &&
                 newQueue.Count > 0)
            {
              oldQueue.Dequeue();
              Controls.Remove(oldControlQueue.Dequeue());
            }
            else if (oldQueue.Count > 0)
            {
              oldQueue.Dequeue();
              Controls.Remove(oldControlQueue.Dequeue());
            }
            else if (newQueue.Count > 0)
            {
              var newVoting = newQueue.Dequeue();
              this.votings.Add(newVoting);

              VotingControl control = new VotingControl();
              control.Controller = controller;
              control.Voting = newVoting;
              control.Left = 0;
              control.Top = top;
              control.Width = Width - (VerticalScroll.Visible ? 16 : 0) - HorizontalSpace;
              control.Anchor = AnchorStyles.Left | AnchorStyles.Right | AnchorStyles.Top;
              control.VotingAction += new VotingActionHandler(Control_VotingAction);
              newControlQueue.Enqueue(control);
              Controls.Add(control);

              top += control.Height + VerticalSpace;
            }
              }

              this.controls = new List<VotingControl>(newControlQueue);

              foreach (var control in this.controls)
              {
            control.Width = Width - (VerticalScroll.Visible ? 16 : 0) - HorizontalSpace;
              }

              ResumeLayout();
        }
Beispiel #3
0
        private void Master_Load(object sender, EventArgs e)
        {
            var screenBounds = Screen.PrimaryScreen.Bounds;

              if (screenBounds.Width < Width)
              {
            Width = screenBounds.Width;
              }

              if (screenBounds.Height < Height)
              {
            Height = screenBounds.Height;
              }

              CenterToScreen();
              SetDefaultLanguage();
              Controller = new CircleController();

              Status.InitScreen.ShowInfo(Controller, this);

              try
              {
            Controller.Prepare();
              }
              catch (InvalidOperationException)
              {
            MessageForm.Show(Resources.CannotConnectMessage, Resources.MessageBoxTitle, MessageBoxButtons.OK, MessageBoxIcon.Information);
            Close();
            return;
              }
              catch (SocketException)
              {
            MessageForm.Show(Resources.CannotConnectMessage, Resources.MessageBoxTitle, MessageBoxButtons.OK, MessageBoxIcon.Information);
            Close();
            return;
              }
              catch (Exception exception)
              {
            Error.ErrorDialog.ShowError(exception);
            Close();
            return;
              }

              try
              {
            Controller.CheckUpdate();
            Controller.LoadCertificates();
            RefreshInternal();
              }
              catch (Exception exception)
              {
            Error.ErrorDialog.ShowError(exception);
            Close();
            return;
              }

              Status.InitScreen.HideInfo();

              Show();
        }