Пример #1
0
        public void WriteIndexing(int index, object _value)
        {
            switch (index)
            {
            case 0:
                ProductId = int.Parse(_value.ToString());
                break;

            case 1:
                ASIN = _value.ToString();
                break;

            case 2:
                DateList.Add(new DateTime());
                DateList[DateList.Count - 1] = (DateTime)_value;
                break;

            case 3:
                Status.Add("");
                Status[Status.Count - 1] = _value.ToString();
                break;

            case 4:
                Notes.Add("");
                Notes[Notes.Count - 1] = _value.ToString();
                break;
            }
        }
Пример #2
0
        public EditInboxPage(MessageNode node, InboxNameRecordInfo inboxItem) : base("EditInboxPage")
        {
            Subscribe <InboxRenameEvent>(InboxRenamed);

            _node      = node;
            _inboxItem = inboxItem;
            _title     = inboxItem.Title;

            AddTitleRow("Title");

            AddHeaderRow("RenameHeader");

            _titleRow = AddEntryRow(_title, "RenameEntry");

            Status.Add(_titleRow.Edit, T("RenameStatus"), (sv, edit, newText, oldText) =>
            {
                if (!string.IsNullOrEmpty(newText) && newText.Length <= MessageServiceInfo.MaxInboxNameLength && newText != _title)
                {
                    return(true);
                }

                return(false);
            });

            AddSubmitRow("RenameButton", Rename);

            AddFooterRow();
        }
Пример #3
0
    void AddRoundStatus <T>(Unit target, int num) where T : StatusEffect
    {
        Status s = target.GetComponent <Status>();
        DurationStatusCondition d = s.Add <T, DurationStatusCondition>();

        d.duration = num;
    }
Пример #4
0
        public TransferPage(long receiverId = 0, long amount = 0, string reason = null) : base("TransferPage")
        {
            _receiverId = receiverId;

            Subscribe <CoreAccountTransferEvent>(TransferEvent);

            AddTitleRow("Title");

            AddHeaderRow("TransferDetail");

            _receiver = AddEntryRow(null, "Receiver");
            _receiver.SetDetailViewIcon(Icons.Coins);

            if (receiverId > 0)
            {
                _receiver.Edit.Text      = receiverId.ToString();
                _receiver.Edit.IsEnabled = false;
            }

            var showreceiver = AddButtonRow("ReceiverButton", ShowReceiver);

            showreceiver.IsEnabled = false;

            _amount = AddEntryRow(null, "Amount");
            _amount.SetDetailViewIcon(Icons.CreditCardFront);
            if (amount > 0)
            {
                _amount.Edit.Text = Currency.ToString(amount, false);
            }

            _reason = AddEntryRow(null, "Reason");
            _reason.SetDetailViewIcon(Icons.Pencil);
            _reason.Edit.Text = reason;

            _reason.Edit.TextChanged += (sender, e) =>
            {
                var txt = e.NewTextValue;
                if (!string.IsNullOrEmpty(txt) && txt.Length > AccountUpdateOperation.MaxReasonLength)
                {
                    _reason.Edit.Text = txt.Substring(0, AccountUpdateOperation.MaxReasonLength);
                }
            };

            AddFooterRow();

            Status.Add(_receiver.Edit, T("ReceiverStatus"), (sv, edit, newText, oldText) =>
            {
                return(showreceiver.IsEnabled = StatusValidators.PositiveNumberValidator(sv, edit, newText, oldText));
            }).
            Add(_amount.Edit, T("AmountStatus"), StatusValidators.HeleusCoinValidator).
            AddBusyView(showreceiver).
            AddBusyView(_reason.Edit);

            AddIndex       = AddSubmitRow("Submit", Submit);
            AddIndexBefore = true;

            _password = AddPasswordRow(null, "Password");

            Status.Add(_password.Edit, T("PasswordStatus"), StatusValidators.HeleusPasswordValidator);
        }
Пример #5
0
 private void UpdateLoop()
 {
     while (true)
     {
         if (Dirty)
         {
             lock (InternalStatus)
             {
                 var data = InternalStatus.ToArray();
                 dispatcher.Invoke(() =>
                 {
                     for (int idx = 0; idx < data.Length; idx += 1)
                     {
                         if (idx >= Status.Count)
                         {
                             Status.Add(data[idx]);
                         }
                         else if (Status[idx] != data[idx])
                         {
                             Status[idx] = data[idx];
                         }
                     }
                 });
                 Dirty = false;
             }
         }
         Thread.Sleep(1000);
     }
 }
Пример #6
0
    void AddTurnStatus <T>(Unit target, int turnNum) where T : StatusEffect
    {
        Status s = target.GetComponent <Status>();
        TurnStatusCondition cond = s.Add <T, TurnStatusCondition>();

        cond.durationTurns = turnNum;
    }
Пример #7
0
 /// <summary>
 /// ツイート取得に関する奴
 /// </summary>
 /// <param name="maxID"></param>
 private async void GetHomeTimeLineAsync(long?maxID = null)
 {
     try
     {
         var flug        = maxID.HasValue;
         var selectIndex = listBox.SelectedIndex;
         foreach (var tweet in await Tokens.Statuses.HomeTimelineAsync(null, null, maxID))
         {
             if (Status.Contains(tweet) || flug)
             {
                 flug = false;
                 continue;
             }
             Status.Add(TweetProcessing(tweet));
         }
         View.Refresh();
         LoadLock = false;
         if (maxID == null)
         {
             return;
         }
         listBox.SelectedIndex = selectIndex++;
         listBox.ScrollIntoView(listBox.SelectedItem);
         //カーソルでの位置固定
         var lbi = listBox.ItemContainerGenerator.ContainerFromIndex(selectIndex) as ListBoxItem;
         lbi?.Focus();
     }
     catch (Exception exception)
     {
         MessageBox.Show(exception.Message, "Error!");
     }
 }
        public ProfileItemPage(EditProfilePage editProfilePage, ProfileItemJson profileItem) : base("ProfileItemPage")
        {
            _editProfilePage = editProfilePage;
            _profileItem     = profileItem;

            AddTitleRow("Title");

            AddHeaderRow();

            _key = AddEntryRow(profileItem.k, "Key");
            _key.SetDetailViewIcon(Icons.Pencil);
            _value = AddEntryRow(profileItem.v ?? (profileItem.IsWebSite() ? "https://" : ""), profileItem.IsWebSite() ? "WebsiteValue" : "MailValue");
            _value.SetDetailViewIcon(profileItem.IsWebSite() ? Icons.RowLink : Icons.At);

            Status.Add(_key.Edit, T("KeyStatus"), (sv, edit, newText, oldText) =>
            {
                return(!string.IsNullOrWhiteSpace(newText));
            }).Add(_value.Edit, profileItem.IsWebSite() ? T("WebsiteStatus") : T("MailStatus"), (sv, edit, newText, oldText) =>
            {
                if (profileItem.IsWebSite())
                {
                    return(newText.IsValdiUrl(false));
                }
                if (profileItem.IsMail())
                {
                    return(newText.IsValidMail(false));
                }

                return(false);
            });

            AddFooterRow();

            AddSubmitRow("Common.Submit", Submit);
        }
Пример #9
0
        async Task ExecuteLoadItemsCommand()
        {
            try
            {
                Stores.Clear();
                var palletMaster = await DataStore.GetPalletMaterDataAsync();

                foreach (var item in palletMaster.Stores)
                {
                    Stores.Add(item);
                }

                Status.Clear();
                foreach (var item in palletMaster.Status)
                {
                    Status.Add(item);
                }

                Categories.Clear();
                foreach (var item in palletMaster.Categories)
                {
                    Categories.Add(item);
                }

                Wrappers.Clear();
                foreach (var item in palletMaster.Wrappers)
                {
                    Wrappers.Add(item);
                }

                Shippers.Clear();
                foreach (var item in palletMaster.Shippers)
                {
                    Shippers.Add(item);
                }

                Suppliers.Clear();
                foreach (var item in palletMaster.Suppliers)
                {
                    Suppliers.Add(item);
                }

                Builders.Clear();
                foreach (var item in palletMaster.Builders)
                {
                    Builders.Add(item);
                }

                PalletTypes.Clear();
                foreach (var item in palletMaster.PalletTypes)
                {
                    PalletTypes.Add(item);
                }
            }
            catch (Exception ex)
            {
                Debug.WriteLine(ex);
            }
        }
Пример #10
0
 public HqStatusViewModel()
 {
     Status = Enum.GetNames(typeof(ReadStatus)).ToList();
     Status.Add("Add to...");
     SelectedStatus = Status.Last();
     Scores         = new List <double> {
         0, 1, 1.5, 2, 2.5, 3, 3.5, 4, 4.5, 5, 5.5, 6, 6.5, 7, 7.5, 8, 8.5, 9, 9.5, 10
     };
 }
Пример #11
0
 public string[] ReadFile(string fuulPath)
 {
     if (!File.Exists(fuulPath))
     {
         Status.Add(MainWindowVM.GetLocalization["prepRead1"] + " " + fuulPath + " " + MainWindowVM.GetLocalization["prepRead2"]);
         return(text = new string[] { });
     }
     return(text = File.ReadAllLines(fuulPath));
 }
Пример #12
0
        public RestorePage() : base("RestorePage")
        {
            EnableStatus();

            AddTitleRow("Title");

            AddHeaderRow("Account");

            _accountId = AddEntryRow(null, "AccountId");
            _accountId.SetDetailViewIcon(Icons.Coins);

            AddSeparatorRow();

            _name = AddEntryRow("", "RegisterPage.Name");
            _name.SetDetailViewIcon(Icons.Pencil);
            _password1 = AddPasswordRow("", "RegisterPage.Password1");
            var password2 = AddPasswordRow("", "RegisterPage.Password2");

            Status.AddBusyView(_accountId);
            Status.Add(_accountId.Edit, T("AccountStatus"), StatusValidators.PositiveNumberValidator);

            Status.Add(_password1.Edit, T("RegisterPage.PasswordStatus", WalletApp.MinPasswordLength), (sv, entry, newText, oldText) =>
            {
                var pw1 = _password1.Edit.Text;
                var pw2 = password2.Edit.Text;

                return(WalletApp.IsValidPassword(pw1) && WalletApp.IsValidPassword(pw2) && pw1 == pw2);
            }).
            AddBusyView(password2);

            AddFooterRow();


            AddHeaderRow("AuthorizeAccountPage.SignatureKey");

            _passphrase = AddEntryRow(null, "AuthorizeAccountPage.Passphrase", ServiceNodeManager.MinimumServiceAccountPassphraseLength);
            var button = AddButtonRow("AuthorizeAccountPage.NewPassphrase", Generate);

            Status.AddBusyView(button);

            _key = AddEditorRow(null, "AuthorizeAccountPage.SignatureKey");
            _key.SetDetailViewIcon(Icons.Key);
            Status.Add(_key.Edit, T("RestoreAccountPage.KeyStatus"), (sv, edit, newText, oldText) =>
            {
                return(StatusValidators.HexValidator(64, sv, edit, newText, oldText));
            });

            AddFooterRow();


            password2.Edit.TextChanged += (sender, e) =>
            {
                Status.ReValidate();
            };

            AddSubmitRow("Restore", Restore);
        }
Пример #13
0
        public AddTodoTaskPage(TodoList todoList) : base("AddTodoTaskPage")
        {
            Subscribe <NewTodoTaskEvent>(TodoTask);

            AddTitleRow("Title");

            AddHeaderRow("TodoList");

            var selectionList = new SelectionItemList <TodoList>();

            foreach (var serviceNode in ServiceNodeManager.Current.ServiceNodes)
            {
                var todo = TodoApp.Current.GetTodo(serviceNode);
                if (todo != null)
                {
                    foreach (var list in todo.TodoLists)
                    {
                        selectionList.Add(new SelectionItem <TodoList>(list, TodoApp.GetTodoListName(list)));
                    }
                }
            }

            _listSelection = AddSelectionRows(selectionList, todoList);
            _listSelection.SelectionChanged = SelectionChanged;

            Status.Add(T("ListStatus"), (sv) =>
            {
                return(_listSelection.Selection != null);
            });

            AddFooterRow();

            _editor = AddEditorRow("", "Text");
            _editor.SetDetailViewIcon(Icons.Pencil);

            FocusElement = _editor.Edit;

            Status.Add(_editor.Edit, T("TextStatus"), (sv, edit, newText, oldText) =>
            {
                return(!string.IsNullOrWhiteSpace(newText) && newText.Length >= 2);
            });


            AddSubmitRow("Submit", Submit);

            AddHeaderRow("Common.SubmitAccount");
            _submitAccount = AddRow(new SubmitAccountButtonRow <TodoListSubmitAccount>(null, this, SelectSubmitAccount));
            AddInfoRow("Common.SubmitAccountInfo");
            AddFooterRow();
            SelectionChanged(todoList);

            Status.Add(T("SubmitAccountStatus"), (sv) =>
            {
                return(_submitAccount.SubmitAccount != null);
            });
        }
Пример #14
0
        async Task ExecuteLoadItemsCommand()
        {
            if (IsBusy)
            {
                return;
            }

            IsBusy = true;

            try
            {
                var palletMaster = await DataStore.GetPalletMaterDataAsync();

                Stores.Clear();

                if (!Convert.ToBoolean(Application.Current.Properties["IsAdmin"]))
                {
                    var userId = Convert.ToString(Application.Current.Properties["UserId"]);
                    Stores.Add(palletMaster.Stores.Find(s => string.Equals(s.Name, userId.Trim(), StringComparison.OrdinalIgnoreCase)));
                }
                else
                {
                    foreach (var item in palletMaster.Stores)
                    {
                        Stores.Add(item);
                    }
                }

                Status.Clear();
                foreach (var item in palletMaster.Status)
                {
                    Status.Add(item);
                }

                Categories.Clear();
                foreach (var item in palletMaster.Categories)
                {
                    Categories.Add(item);
                }

                Wrappers.Clear();
                foreach (var item in palletMaster.Wrappers)
                {
                    Wrappers.Add(item);
                }
            }
            catch (Exception ex)
            {
                Debug.WriteLine(ex);
            }
            finally
            {
                IsBusy = false;
            }
        }
Пример #15
0
    void OnHPDidChangeNotification(object sender, object args)
    {
        Stats stats = sender as Stats;

        if (stats[StatTypes.HP] == 0)
        {
            Status status             = stats.GetComponentInChildren <Status>();
            StatComparisonCondition c = status.Add <KnockOutStatusEffect, StatComparisonCondition>();
            c.Init(StatTypes.HP, 0, c.EqualTo);
        }
    }
Пример #16
0
 public string[] ReadFile(string path, string name, out bool errore)
 {
     errore = false;
     if (!File.Exists(path + name))
     {
         Status.Add(MainWindowVM.GetLocalization["prepRead1"] + " " + path + name + " " + MainWindowVM.GetLocalization["prepRead2"]);
         errore = true;
         return(text = new string[] { });
     }
     return(text = File.ReadAllLines(path + name));
 }
Пример #17
0
        public void SetStatus(string key, string data)
        {
            var value = ParseStatus(data);

            if (Status.Keys.Contains(key))
            {
                Status[key] = value;
            }
            else
            {
                Status.Add(key, value);
            }
        }
Пример #18
0
        internal void StatusMessage_PreviewMouseDoubleClick(object sender, MouseButtonEventArgs e)
        {
            if (MainWindowVM.Project.Count == 0)
            {
                return;
            }
            ListBox lb      = (ListBox)sender;
            string  message = (string)lb.SelectedItem;

            if (message == null)
            {
                return;
            }
            if (message.IndexOf("file:") != -1 && message.IndexOf("line:") != -1 && message.IndexOf("| code:") != -1)
            {
                int startName = message.IndexOf("file:") + 5;
                int endName   = message.IndexOf("line:") - 1;
                int startLine = message.IndexOf("line:") + 5;
                int endLine   = message.IndexOf("| code:") - 1;

                string name     = message.Substring(startName, endName - startName).Trim();
                string line     = message.Substring(startLine, endLine - startLine).Trim();
                string fileName = GetName(name);
                if (MainWindowVM.Project.GetDictionary().ContainsKey(fileName))
                {
                    var item = MainWindowVM.Project.GetDictionary()[fileName];
                    item.Item.IsSelected = true;
                    item.Editor.SelectLine(Convert.ToInt32(line) - 1);
                }
                else
                {
                    if (name != "")
                    {
                        if (File.Exists(name.Replace("/", "\\")))
                        {
                            MainWindowVM.FileNew(name.Replace("/", "\\"), false);
                        }
                        if (MainWindowVM.Project.GetDictionary().ContainsKey(fileName))
                        {
                            var item = MainWindowVM.Project.GetDictionary()[fileName];
                            item.Item.IsSelected = true;
                            item.Editor.SelectLine(Convert.ToInt32(line) - 1);
                        }
                        else
                        {
                            Status.Add(MainWindowVM.GetLocalization["prepRead1"] + " " + name.Replace("/", "\\") + " (" + fileName + ") " + MainWindowVM.GetLocalization["prepRead2"]);
                        }
                    }
                }
            }
        }
Пример #19
0
 internal void Play(string name)
 {
     try
     {
         string uri = "pack://application:,,,/Resources/Media/wav/" + name + ".wav";
         player.Stream = Application.GetResourceStream(new Uri(uri)).Stream;
         player.Play();
     }
     catch (Exception ex)
     {
         Status.Clear();
         Status.Add(ex.Message);
     }
 }
Пример #20
0
        VerificationFilePage(AddVerificationPage verificationPage, VerifyFileJson verifyItem, OpenFile file = null) : base("VerificationFilePage")
        {
            _verificationPage = verificationPage;
            _item             = verifyItem ?? new VerifyFileJson();

            AddTitleRow("Title");
            AddHeaderRow("File");
            Status.AddBusyView(AddButtonRow("Select", Select));

            _link = AddEntryRow(null, "Link");
            _link.SetDetailViewIcon(Icons.RowLink);

            _verifyView = new VerifyFileView(false);
            AddViewRow(_verifyView);

            if (verifyItem != null)
            {
                _link.Edit.Text = verifyItem.link;
                _fileName       = verifyItem.name;
                _fileHash       = verifyItem.GetHash();
                _length         = verifyItem.length;
                _verifyView.Update(verifyItem);
            }

            Status.Add(_link.Edit, T("LinkStatus"), (view, entry, newText, oldText) =>
            {
                if (string.IsNullOrEmpty(newText))
                {
                    return(true);
                }

                return(newText.IsValdiUrl(true));
            });

            Status.Add(T("FileStatus"), (sv) =>
            {
                return(!string.IsNullOrEmpty(_fileName) && _fileHash != null && _length > 0);
            });

            AddFooterRow();

            AddSubmitRow("Submit", Submit);

            if (file != null)
            {
                UIApp.Run(() => HashFile(file));
            }
        }
Пример #21
0
        protected void AddSubmitSection()
        {
            AddIndex       = AddSubmitRow("Submit", Submit);
            AddIndexBefore = true;

            if (!WalletApp.IsCoreAccountUnlocked)
            {
                _password = AddPasswordRow(null, "ChainInfoBasePage.Password");
                Status.Add(_password.Edit, T("ChainInfoBasePage.PasswordStatus"), StatusValidators.HeleusPasswordValidator);
            }

            if (_chainId > 0)
            {
                _ = QueryChainInfo(_chainId);
            }

            AddIndex = null;
        }
Пример #22
0
 protected void EBtnSubmit_Click(object sender, EventArgs e)
 {
     if (this.Page.IsValid)
     {
         StatusInfo statusInfo = new StatusInfo();
         int        statusId   = DataConverter.CLng(this.DropStatusCode.SelectedValue);
         bool       flag       = false;
         if (this.HdnAction.Value == "Modify")
         {
             statusInfo.StatusId = BasePage.RequestInt32("StatusID");
         }
         statusInfo.StatusCode = statusId;
         statusInfo.StatusName = this.TxtStatusName.Text;
         statusInfo.StatusType = 1;
         bool flag2 = false;
         if ((this.HdnAction.Value == "Modify") && (statusId == DataConverter.CLng(this.HdnStatusCode.Value)))
         {
             flag = false;
         }
         else if (Status.Exists(statusId))
         {
             AdminPage.WriteErrMsg("<li>已经添加过此状态码了,请返回重新选择状态码!</li>");
         }
         if (!flag)
         {
             if (this.HdnAction.Value == "Modify")
             {
                 flag2 = Status.Update(statusInfo);
             }
             else
             {
                 flag2 = Status.Add(statusInfo);
             }
             if (flag2)
             {
                 AdminPage.WriteSuccessMsg("<li>保存稿件状态码成功!</li>", "StatusManage.aspx");
             }
             else
             {
                 AdminPage.WriteErrMsg("<li>保存稿件状态码失败!</li>");
             }
         }
     }
 }
Пример #23
0
 public bool Remove(string name)
 {
     if (data.ContainsKey(name))
     {
         try
         {
             return(data.Remove(name));
         }
         catch (Exception ex)
         {
             Status.Clear();
             Status.Add(MainWindowVM.GetErrors["ePrjDataRemove"] + ex.ToString());
             return(false);
         }
     }
     else
     {
         return(false);
     }
 }
Пример #24
0
        public BuyPurchasePage(int chainId = 0, int purchaseId = 0) : base(chainId, "BuyPurchasePage")
		{
            if (chainId > 0 && purchaseId > 0)
                _purchaseId = purchaseId;

            Subscribe<PurchaseEvent>(Purchased);

            SetupPage();

            AddHeaderRow("PurchaseInfo");

            _selectPurchase = AddButtonRow("SelectPurchase", SelectPurchase);
            _selectPurchase.IsEnabled = false;

            _purchaseIdText = AddEntryRow(null, "PurchaseId");
            _purchaseView = new PurchaseInfoView();
            AddViewRow(_purchaseView);

            AddFooterRow();

            Status.Add(_purchaseIdText.Edit, T("PurchaseStatus"), (sv, edit, newText, oldText) =>
            {
                if(_chainInfo != null && StatusValidators.PositiveNumberValidator(sv, edit, newText, oldText))
                {
                    if(int.TryParse(newText, out var id))
                    {
                        var purchase = _chainInfo.GetPurchase(id);
                        if(purchase != null)
                        {
                            _purchaseView.Update(purchase);
                            return true;
                        }
                    }
                }
                _purchaseView.Reset();
                return false;
            });

            AddSubmitSection();
		}
Пример #25
0
 public bool Add(string key, ProgramData value)
 {
     if (!data.ContainsKey(key))
     {
         try
         {
             data.Add(key, value);
             return(true);
         }
         catch (Exception ex)
         {
             Status.Clear();
             //MainWindowVM.Status.Add(MainWindowVM.GetLocalization["brkFindErr"] + " " + errors.Count);
             Status.Add(MainWindowVM.GetErrors["ePrjDataAdd"] + ex.ToString());
             return(false);
         }
     }
     else
     {
         return(false);
     }
 }
Пример #26
0
 private void WriteEv3File()
 {
     try
     {
         if (ev3filePath == "")
         {
             SaveFileDialog sfd = new SaveFileDialog();
             sfd.FileName = ev3fileName;
             if (sfd.ShowDialog() == true)
             {
                 ev3filePath = sfd.FileName;
             }
         }
         FileStream fs = new FileStream(ev3filePath, FileMode.Create, FileAccess.Write);
         fs.Write(ev3fileB, 0, ev3fileB.Length);
         fs.Close();
     }
     catch (Exception ex)
     {
         Status.Clear();
         Status.Add("Exception: " + ex.Message);
     }
 }
Пример #27
0
 public void SetRetToStatus()
 {
     Status.Add(Const.StatusResultCode, Ret.ToString());
     Status.Add(Const.StatusResultDesc, ResultDesc ?? "");
 }
Пример #28
0
    protected override void OnApply()
    {
        Status status = GetComponentInParent <Status>();

        statusCondition = status.Add <T, StatusCondition>();
    }
Пример #29
0
        public ChainKeyPage(ChainPage chainPage, List <ChainKeyItem> chainKeys) : base("ChainKeyPage")
        {
            _chainPage = chainPage;

            AddTitleRow("Title");

            AddHeaderRow("Key");

            _name = AddEntryRow(null, "Name");
            _name.SetDetailViewIcon(Icons.Pencil);

            _key = AddEditorRow(null, "Key");
            _key.SetDetailViewIcon(Icons.Key);

            AddButtonRow("KeyButton", NewKey);

            _keyIndex = AddEntryRow(string.Empty, "KeyIndex");
            _keyIndex.SetDetailViewIcon(Icons.Highlighter);

            AddFooterRow();

            AddHeaderRow("KeyOptions");

            _admin       = AddSwitchRow("Admin");
            _serviceKey  = AddSwitchRow("ServiceKey");
            _serviceVote = AddSwitchRow("ServiceVote");
            _dataKey     = AddSwitchRow("DataKey");
            _dataVote    = AddSwitchRow("DataVote");
            _chainIndex  = AddEntryRow(string.Empty, "ChainIndex");

            _admin.Switch.Toggled = (swt) =>
            {
                if (swt.IsToggled)
                {
                    _serviceKey.Switch.IsToggled  = false;
                    _serviceVote.Switch.IsToggled = false;
                    _dataKey.Switch.IsToggled     = false;
                    _dataVote.Switch.IsToggled    = false;
                    _chainIndex.Edit.Text         = null;
                }
                Status.ReValidate();
            };

            _serviceKey.Switch.Toggled = (swt) =>
            {
                if (swt.IsToggled)
                {
                    _admin.Switch.IsToggled    = false;
                    _dataKey.Switch.IsToggled  = false;
                    _dataVote.Switch.IsToggled = false;
                    _chainIndex.Edit.Text      = null;
                }
                else
                {
                    _serviceVote.Switch.IsToggled = false;
                }
                Status.ReValidate();
            };

            _serviceVote.Switch.Toggled = (swt) =>
            {
                if (swt.IsToggled)
                {
                    _serviceKey.Switch.IsToggled = true;
                }
            };

            _dataKey.Switch.Toggled = (swt) =>
            {
                if (swt.IsToggled)
                {
                    _admin.Switch.IsToggled       = false;
                    _serviceKey.Switch.IsToggled  = false;
                    _serviceVote.Switch.IsToggled = false;
                }
                else
                {
                    _dataVote.Switch.IsToggled = false;
                }
                Status.ReValidate();
            };

            _dataVote.Switch.Toggled = (swt) =>
            {
                if (swt.IsToggled)
                {
                    _dataKey.Switch.IsToggled = true;
                }
            };

            AddFooterRow();

            AddHeaderRow("Password");

            _pw1 = AddEntryRow(string.Empty, "Password");
            _pw1.SetDetailViewIcon(Icons.Unlock);
            _pw2 = AddEntryRow(string.Empty, "Password2");
            _pw2.SetDetailViewIcon(Icons.Unlock);
            _pw1.Edit.IsPassword = _pw2.Edit.IsPassword = true;

            AddFooterRow();

            Status.Add(_key.Edit, T("KeyStatus"), (view, entry, newText, oldtext) =>
            {
                try
                {
                    var key = Key.Restore(entry.Text);
                    return(key.KeyType == Protocol.TransactionKeyType);
                }
                catch { }
                return(false);
            }).
            Add(_keyIndex.Edit, T("KeyIndexStatus", short.MinValue, short.MaxValue), (view, entry, newText, oldText) =>
            {
                if (short.TryParse(newText, out var idx))
                {
                    foreach (var key in chainKeys)
                    {
                        if (key.Item.KeyIndex == idx)
                        {
                            return(false);
                        }
                    }
                    return(true);
                }
                if (!newText.IsNullOrEmpty())
                {
                    entry.Text = oldText;
                }
                return(false);
            }).
            Add(_chainIndex.Edit, T("ChainIndexStatus"), (view, entry, newText, oldText) =>
            {
                if (_dataKey.Switch.IsToggled)
                {
                    return(StatusValidators.PositiveNumberValidatorWithZero(view, entry, newText, oldText));
                }

                if (!string.IsNullOrEmpty(newText))
                {
                    entry.Text = null;
                }

                return(true);
            }).
            Add(_name.Edit, T("NameStatus"), (view, entry, newText, oldtext) =>
            {
                return(!newText.IsNullOrWhiteSpace());
            }).
            Add(_pw1.Edit, T("PasswordStatus", WalletApp.MinPasswordLength), (view, entry, newText, oldtext) =>
            {
                var pw1 = _pw1.Edit.Text;
                var pw2 = _pw2.Edit.Text;

                return(WalletApp.IsValidPassword(pw1) && WalletApp.IsValidPassword(pw2) && pw1 == pw2);
            });

            _pw2.Edit.TextChanged += (sender, e) =>
            {
                Status.ReValidate();
            };

            AddSubmitRow("Submit", Submit);
        }
Пример #30
0
        protected void SetupPage()
        {
            AddTitleRow("Title");

            AddHeaderRow("Service");

#pragma warning disable RECS0021 // Warns about calls to virtual member functions occuring in the constructor
            PreAddRows();
#pragma warning restore RECS0021 // Warns about calls to virtual member functions occuring in the constructor

            _chainIdText = AddEntryRow(null, "ChainInfoBasePage.ChainId");
            _chainIdText.SetDetailViewIcon(Icons.Link);

            if (_chainId > 0)
            {
                _chainIdText.Edit.Text      = _chainId.ToString();
                _chainIdText.Edit.IsEnabled = false;
            }

            _chainView = new ChainInfoView();
            AddViewRow(_chainView);
            _link           = AddLinkRow("ChainInfoBasePage.ChainLink", "");
            _link.IsEnabled = false;

            _account = AddButtonRow("ChainInfoBasePage.AccountProfile", Account);
            _account.SetDetailViewIcon(Icons.Coins);
            _account.IsEnabled = false;

#pragma warning disable RECS0021 // Warns about calls to virtual member functions occuring in the constructor
            PostAddRows();
#pragma warning restore RECS0021 // Warns about calls to virtual member functions occuring in the constructor

            AddFooterRow();

            Status.Add(_chainIdText.Edit, T("ChainInfoBasePage.ChainIdStatus"), (sv, edit, newText, oldText) =>
            {
                var success = false;
                if (StatusValidators.PositiveNumberValidator(sv, edit, newText, oldText))
                {
                    if (int.TryParse(newText, out var id))
                    {
                        if (_chainInfo != null && _chainInfo.ChainId == id)
                        {
                            success = true;
                        }
                        else
                        {
                            _ = QueryChainInfo(id);
                        }
                    }
                }
                else
                {
                    _queryChainId = -1;
                    _chainInfo    = null;
                    QueryDone(-1, null);
                    UIApp.Run(() => QueryDoneAsync(-1, null));
                }

                _chainView.Update(_chainInfo);
                if (_chainInfo != null)
                {
                    if (!string.IsNullOrEmpty(_chainInfo.Website))
                    {
                        _link.IsEnabled = true;
                        _link.Tag       = _chainInfo.Website;
                    }
                    _account.IsEnabled = true;
                }
                else
                {
                    _link.IsEnabled    = false;
                    _account.IsEnabled = false;
                }

                ChainInfoChanged();

                return(success);
            });
        }