Exemplo n.º 1
0
        private void InitParams(ObservableCollection <SubscriberParams> collection, ElgamalSubscriber sub)
        {
            AllSubscribers = collection;
            AllSubscribers.CollectionChanged += AllSubscribers_CollectionChanged;
            Subscriber = sub;

            groupBoxParams.Text = groupBoxParams.Text.Replace(SubNameConst, sub.Name);
            this.Text           = this.Text.Replace(SubNameConst, sub.Name);

            tbParamP.Text    = sub.P.ToString();
            tbParamG.Text    = sub.G.ToString();
            tbOpenedKey.Text = sub.OpenedKey.ToString();
            tbClosedKey.Text = sub.ClosedKey.ToString();

            var subs = AllSubscribers.Select(x => x.ElgamalSubscriber.Name).Where(x => x != sub.Name);

            subComboBox.Items.AddRange(subs.ToArray());
            ChatController = new ChatController <ElgamalSubscriber>(sub);
            ChatController.OnNewMessage += ChatController_OnNewMessage;
            ChatController.OnNewInfo    += ChatController_OnNewInfo;
        }
Exemplo n.º 2
0
        private void BtAddSubscriber_Click(object sender, EventArgs e)
        {
            CatchException(() =>
            {
                var name = string.IsNullOrWhiteSpace(tbSubscriberName.Text)
                    ? throw new ArgumentException("Имя подписчика не должно быть пустым")
                    : tbSubscriberName.Text;
                var openedKey = BigInteger.Parse(tbOpenedKey.Text);
                var closedKey = BigInteger.Parse(tbClosedKey.Text);
                var g         = int.Parse(tbParamG.Text);
                var p         = int.Parse(tbParamP.Text);

                var newSub        = new ElgamalSubscriber(openedKey, closedKey, name, p, g);
                var form          = new SubscriberForm(SubscribersParams, newSub);
                form.FormClosing += SubscriberParams_FormClosing;
                SubscribersParams.Add(new SubscriberParams(form, newSub));
                form.Show();

                BtSetRandomSubscriberParams(this, e);
            });
        }
Exemplo n.º 3
0
 public ElgamalEDSController(ElgamalSubscriber sub)
 {
     Subscriber = sub;
 }
Exemplo n.º 4
0
 public SubscriberForm(ObservableCollection <SubscriberParams> collection, ElgamalSubscriber sub)
 {
     InitializeComponent();
     InitParams(collection, sub);
 }
Exemplo n.º 5
0
 public SubscriberParams(SubscriberForm subscriberForm, ElgamalSubscriber elgamalSubscriber)
 {
     this.SubscriberForm    = subscriberForm;
     this.ElgamalSubscriber = elgamalSubscriber;
 }