public AppViewModel(IEventAggregator eventAggregator, IWindowManager windowManager) { DisplayName = "Redis Explorer"; //SetTheme(); this.eventAggregator = eventAggregator; eventAggregator.Subscribe(this); this.windowManager = windowManager; Servers = new BindableCollection <RedisServer>(); KeyViewModel = new KeyViewModel(eventAggregator); KeyViewModel.ConductWith(this); DefaultViewModel = new DefaultViewModel(); DefaultViewModel.ConductWith(this); ServerViewModel = new ServerViewModel(eventAggregator); ServerViewModel.ConductWith(this); DatabaseViewModel = new DatabaseViewModel(eventAggregator); DatabaseViewModel.ConductWith(this); ActivateItem(DefaultViewModel); LoadServers(); }
public ActionResult ShareToUser(UsernameViewModel model) { KeyViewModel key = null; var responseTask = client.GetAsync($"GetKey/{model.keyId}"); responseTask.Wait(); var result = responseTask.Result; if (result.IsSuccessStatusCode) { var readTask = result.Content.ReadAsAsync <KeyViewModel>(); readTask.Wait(); key = readTask.Result; } else { ModelState.AddModelError(string.Empty, "Server error. Please contact administrator."); } //duplicate the key for new user key.UserId = model.SelectedUser; var postTask2 = client.PostAsJsonAsync <KeyViewModel>("CreateAsync", key); postTask2.Wait(); var result2 = postTask2.Result; if (result2.IsSuccessStatusCode) { return(RedirectToAction("Keys", "Key")); } return(RedirectToAction("ShareKey", key.Id)); }
private void button1_Click(object sender, EventArgs e) { Form2 f2 = new Form2(); if (update) { key.Username = username.Text; key.Password = password.Text; key.ExpirationDate = expDate.Value; if (callWebApi.UpdateKey(key)) { key = null; update = false; f2.LoadRows(); f2.CheckExpirationDate(); this.Close(); } } else { key.Username = username.Text; key.Password = password.Text; key.ExpirationDate = expDate.Value; if (callWebApi.CreateKey(key)) { key = null; update = false; f2.LoadRows(); f2.CheckExpirationDate(); this.Close(); } } }
public KeyViewModel GetKey(string id) { try { KeyViewModel key = new KeyViewModel(); var responseTask = client.GetAsync($"Key/GetKey/{id}"); responseTask.Wait(); var result = responseTask.Result; if (result.IsSuccessStatusCode) { var readTask = result.Content.ReadAsAsync <KeyViewModel>(); readTask.Wait(); key = readTask.Result; } else { key = null; } return(key); } catch (Exception ex) { throw ex; } }
public bool EnterKey(string storage, string key) { string url = HttpService.Url; try { var model = new KeyViewModel() { StorageName = storage, Key = key }; string json = JsonConvert.SerializeObject(model); HttpContent content = new StringContent(json, Encoding.UTF8, "application/json"); var result = HttpService.Instance.PostAsync(url + "Storage/EnterKey", content).Result; if (result.IsSuccessStatusCode) { return(true); } Exceptions.Add(new Exception(result.Content.ReadAsStringAsync().Result)); return(false); } catch (Exception ex) { Exceptions.Add(ex); return(false); } }
public ActionResult DeleteKey(string id) { KeyViewModel key = null; if (id == null) { ModelState.AddModelError(string.Empty, "Record could not found"); } var responseTask = client.GetAsync($"GetKey/{id}"); responseTask.Wait(); var result = responseTask.Result; if (result.IsSuccessStatusCode) { var readTask = result.Content.ReadAsAsync <KeyViewModel>(); readTask.Wait(); key = readTask.Result; } else { ModelState.AddModelError(string.Empty, "Server error. Please contact administrator."); } return(View(key)); }
public ActionResult AddKey(KeyViewModel key) { var mapper = new MapperConfiguration(cfg => cfg.CreateMap <KeyViewModel, KeyDTO>()).CreateMapper(); var k = mapper.Map <KeyViewModel, KeyDTO>(key); service.GameEditor.AddKey(k); return(RedirectToAction("KeysList", "Admin", new { id = key.GameId })); }
protected void AddKeyDocumentation(PageViewModel doc, ItemViewModel obj, IElement keyElement, bool primaryKey) { KeyViewModel keyModel = new KeyViewModel(); keyModel.PrimaryKey = primaryKey; keyModel.Fields = keyElement.GetStringProperty(PropertyType.Key); obj.Keys.Add(keyModel); }
private void dataGridView1_CellContentClick(object sender, DataGridViewCellEventArgs e) { string id = null; var senderGrid = (DataGridView)sender; if (senderGrid.Columns["Edit"].Index == e.ColumnIndex) { DataGridViewRow row = dataGridView1.Rows[e.RowIndex]; id = row.Cells[0].Value.ToString(); Form3 f3 = new Form3(id); f3.TopMost = true; f3.Show(); } else if (senderGrid.Columns["Share"].Index == e.ColumnIndex) { KeyViewModel key = new KeyViewModel(); DataGridViewRow row = dataGridView1.Rows[e.RowIndex]; key.Id = row.Cells[0].Value.ToString(); key.UserId = row.Cells[1].Value.ToString(); key.Username = row.Cells[2].Value.ToString(); key.Password = row.Cells[3].Value.ToString(); key.ExpirationDate = DateTime.Parse(row.Cells[4].Value.ToString(), CultureInfo.InvariantCulture, DateTimeStyles.None); ShareForm sh = new ShareForm(key); sh.TopMost = true; sh.Show(); } else if (senderGrid.Columns["Delete"].Index == e.ColumnIndex) { DataGridViewRow row = dataGridView1.Rows[e.RowIndex]; id = row.Cells[0].Value.ToString(); MessageBoxButtons buttons = MessageBoxButtons.YesNo; DialogResult result; // Displays the MessageBox. result = MessageBox.Show("Are u sure, would you like to delete this data?", "Delete Warning", buttons); if (result == System.Windows.Forms.DialogResult.Yes) { if (callWebApi.DeleteRow(id)) { MessageBox.Show("Data succesfully deleted."); dataGridView1.Update(); } } } else if (senderGrid.Columns["Username"].Index == e.ColumnIndex) { DataGridViewRow row = dataGridView1.Rows[e.RowIndex]; Clipboard.SetText(row.Cells[2].Value.ToString()); MessageBox.Show("Username coppied!"); } else if (senderGrid.Columns["Password"].Index == e.ColumnIndex) { DataGridViewRow row = dataGridView1.Rows[e.RowIndex]; Clipboard.SetText(row.Cells[3].Value.ToString()); MessageBox.Show("Password coppied!"); } }
public MainWindow() { InitializeComponent(); monitorControl.Focus(); _viewmodel = new MainWindowViewModel(this, keyControl, monitorControl); _keyViewModel = (KeyViewModel)keyControl.DataContext; _monitorViewModel = (MonitorViewModel)monitorControl.DataContext; _monitorViewModel.OnTimerTicked += MonitorViewModelOnOnTimerTicked; }
public ShareForm(KeyViewModel key) { InitializeComponent(); model.Id = key.Id; model.Username = key.Username; model.UserId = key.UserId; model.Password = key.Password; model.ExpirationDate = key.ExpirationDate; model.CreateDate = key.CreateDate; }
public IRunHotKeyService UnBind() { if (runKey != null) { hotKeys.Remove(runKey.Key, runKey.Modifier); } runKey = null; return(this); }
//GET-Create public async Task <IActionResult> Create() { KeyViewModel model = new KeyViewModel() { StockList = await _db.Stock.ToListAsync(), GameList = await _db.Game.ToListAsync(), Key = new Models.Key() }; return(View(model)); }
private void Form3_Load(object sender, EventArgs e) { if (keyID != null) { update = true; key = callWebApi.GetKey(keyID); username.Text = key.Username; password.Text = key.Password; key.ExpirationDate = DateTime.ParseExact(key.ExpirationDate.ToString("dd/mm/yyyy"), "dd/mm/yyyy", System.Globalization.CultureInfo.InvariantCulture, System.Globalization.DateTimeStyles.None); expDate.Value = key.ExpirationDate; } }
public IRunHotKeyService Bind(Key key, ModifierKeys modifier) { if (runKey == null || runKey.Key != key || runKey.Modifier != modifier) { hotKeys.Add(key, modifier, OnRunHotKeyPressed); UnBind(); runKey = new KeyViewModel(key, modifier); } return(this); }
private async void OnListViewItemSelected(object sender, SelectedItemChangedEventArgs args) { (sender as ListView).SelectedItem = null; if (args.SelectedItem != null) { TheList.ItemsSource = null; KeyViewModel.SelectAttribute(args.SelectedItem as Models.Attribute); KeyViewModel.DoneSelecting = true; await Navigation.PopAsync(); } }
public ActionResult UpdateKey(KeyViewModel model) { var postTask = client.PostAsJsonAsync <KeyViewModel>("UpdateKey", model); postTask.Wait(); var result = postTask.Result; if (result.IsSuccessStatusCode) { return(RedirectToAction("Keys", "Key")); } return(RedirectToAction($"GetKey/{model.Id}")); }
private static void OnKeyChanged(DependencyObject d, DependencyPropertyChangedEventArgs e) { TextBox textBox = (TextBox)d; textBox.IsReadOnly = true; textBox.IsReadOnlyCaretVisible = true; textBox.PreviewKeyDown += OnPreviewKeyDown; textBox.LostFocus += OnLostFocus; KeyViewModel viewModel = GetKey(textBox); if (viewModel != null) { BindKeyValue(textBox, viewModel.Key, viewModel.Modifier); } }
public bool CreateKey(KeyViewModel key) { try { var postTask = client.PostAsJsonAsync <KeyViewModel>("Key/CreateAsync", key); postTask.Wait(); var result = postTask.Result; if (result.IsSuccessStatusCode) { return(true); } return(false); } catch (Exception) { throw; } }
public void AssignKeys(KeyAssignmentSet keyAssignmentSet) { //Console.Write("AssignKeys(" + keyAssignmentSet.Language + "), "); int n = TheKeyViewModels.Count; Debug.Assert(n == keyAssignmentSet.KeyAssignments.Length, "These collections should be the same length."); for (int i = 0; i < n; i++) { KeyViewModel vm = TheKeyViewModels[i]; KeyAssignment ka = keyAssignmentSet.KeyAssignments[i]; vm.IsLetter = ka.IsLetter; vm.UnshiftedCodePoint = (char)ka.UnshiftedCodePoint; vm.ShiftedCodePoint = (char)ka.ShiftedCodePoint; if (ka.IsToShowBothGlyphs) { // If it's an underscore, if (ka.ShiftedCodePoint == 0x005F) { // double it up because the first one gets eaten string sText = (char)ka.ShiftedCodePoint + Environment.NewLine + (char)ka.UnshiftedCodePoint; string sTextWithUnderscoresDoubled = sText.Replace("_", @"__"); vm.Text = sTextWithUnderscoresDoubled; } else { vm.Text = (char)ka.ShiftedCodePoint + Environment.NewLine + (char)ka.UnshiftedCodePoint; } } else { vm.Text = null; } // Assign the font family, if one is specified.. if (!String.IsNullOrEmpty(ka.FontFamilyName)) { // Those assigned to this specific key-assignment, override those assigned to the key-assignment-set. vm.FontFamily = new FontFamily(ka.FontFamilyName); } else { vm.FontFamily = null; } } }
public ActionResult Create(KeyViewModel model) { userid = HttpContext.Session.GetString(key: sessionUserid); model.UserId = userid; //HTTP POST var postTask = client.PostAsJsonAsync <KeyViewModel>("CreateAsync", model); postTask.Wait(); var result = postTask.Result; if (result.IsSuccessStatusCode) { return(RedirectToAction("Keys", "Key")); } ModelState.AddModelError(string.Empty, "An error occured. Please try again."); return(View(model)); }
public ActionResult Index(KeyViewModel model, string returnUrl) { if (ModelState.IsValid) { if (authProvider.Authenticate(model.Number, model.AccessKey)) { return(Redirect(returnUrl ?? Url.Action("Index", "Home"))); } else { ModelState.AddModelError("", "Incorrect admin number or admin key."); return(View()); } } else { return(View()); } }
public IActionResult EnterKey([FromBody] KeyViewModel model) { var storage = storageContext.Storages .Where(s => s.Name == model.StorageName && s.User == User.Identity.Name) .FirstOrDefault(); var word = storageContext.Words .Where(w => w.Storage == model.StorageName && w.User == User.Identity.Name) .FirstOrDefault(); if (storage == null) { return(new BadRequestObjectResult("Хранилище не найдено")); } if (word == null) { return(new BadRequestObjectResult("Контрольное слово не найдено")); } if (!encryptor.CheckSizeKey(model.Key)) { return(new BadRequestObjectResult("Размер ключа [16, 24, 32]")); } //HttpContext.Session.SetString("StorageKey", ); // Возсожно нужно хранить в STRING //HttpContext.Session.SetString("StorageIV", ); if (encryptor.Decrypt(encryptor.ToByte(model.Key), storage.IV, word.ControlWord) == null) { return(new BadRequestObjectResult("Ключ неверный")); } //dataLite.Close(); dataLite.Initializing(model.StorageName); dataLite.Close(); HttpContext.Session.SetString("StorageName", model.StorageName); HttpContext.Session.SetString("StorageKey", model.Key); // Возсожно нужно хранить в STRING HttpContext.Session.SetString("StorageIV", encryptor.ToString(storage.IV)); return(new OkObjectResult("Ключ верный")); }
public async Task <IActionResult> Create(KeyViewModel model) { if (ModelState.IsValid) { _db.Key.Add(model.Key); await _db.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } //en caso de que no sea valido tendremos que retroceder y crear el view model KeyViewModel modelVM = new KeyViewModel() { StockList = await _db.Stock.ToListAsync(), GameList = await _db.Game.ToListAsync(), Key = model.Key }; return(View(modelVM)); }
private void KeyPress(KeyViewModel mykey) { Mediator.SendMessage(MsgTag.SetFocus, MsgTag.SetFocus); var text = mykey.CodePoint.ToString(); var target = System.Windows.Input.Keyboard.FocusedElement; var routedEvent = TextCompositionManager.TextInputEvent; if (target != null) { target.RaiseEvent( new TextCompositionEventArgs( InputManager.Current.PrimaryKeyboardDevice, new TextComposition(InputManager.Current, target, text)) { RoutedEvent = routedEvent } ); } IsShiftLock = false; }
//GET-Edit public async Task <IActionResult> Edit(int?id) { if (id == null) { return(NotFound()); } var key = await _db.Key.SingleOrDefaultAsync(m => m.Id == id); if (key == null) { return(NotFound()); } KeyViewModel model = new KeyViewModel() { StockList = await _db.Stock.ToListAsync(), GameList = await _db.Game.ToListAsync(), Key = key }; return(View(model)); }
public async Task <IActionResult> Edit(int id, KeyViewModel model) { if (ModelState.IsValid) { //actualizar solo a la categoria elegida var keyFromDb = await _db.Key.FindAsync(id); keyFromDb.Id = model.Key.Id; await _db.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } //en caso de que no sea valido tendremos que retroceder y crear el view model KeyViewModel modelVM = new KeyViewModel() { StockList = await _db.Stock.ToListAsync(), GameList = await _db.Game.ToListAsync(), Key = model.Key }; return(View(modelVM)); }
public KeyControl() { InitializeComponent(); DataContext = new KeyViewModel(this); }
public MainViewModel(UIElement element, Action relogin, Action refreshRoomList) { this._element = element; this._reLogin = relogin; this._refreshRoomList = refreshRoomList; Notification.Instance.NotificationLanguage += (obj, value, args) => { _element.Dispatcher.BeginInvoke(new Action(() => { SetCurrentName(); })); }; // 添加处理事件 this._element.AddHandler(PublicEvents.PopupEvent, new RoutedEventHandler(HandlePopop), true); _msg = new MsgViewModel(SetMsgCommand); _key = new KeyViewModel(SetKeyCommand); _animation = new AnimationViewModel(); // 设置语言 SetCurrentName(); // 定时检测 LoadingCheck(); // 更新检测 SetUpdate(); // 更新检测 SetUpdate(); // 注册睡眠唤醒(免得session失效) SystemEvents.PowerModeChanged -= this.SystemEvents_PowerModeChanged; SystemEvents.PowerModeChanged += this.SystemEvents_PowerModeChanged; (_element as Window).Loaded += (z, y) => { if (!_isLoaded) { _isLoaded = true; // 扫码,刷卡 // 扫条码处理 hookBarcode = new KeyboardHook(); var availbleScanners = hookBarcode.GetKeyboardDevices(); string first = availbleScanners.Where(x => String.Format("{0:X}", x.GetHashCode()) == Resources.GetRes().BarcodeReader).FirstOrDefault(); if (!string.IsNullOrWhiteSpace(first)) { hookBarcode.SetDeviceFilter(first); hookBarcode.KeyPressed += OnBarcodeKey; hookBarcode.AddHook(_element as Window); } hookCard = new KeyboardHook(); first = availbleScanners.Where(x => String.Format("{0:X}", x.GetHashCode()) == Resources.GetRes().CardReader).FirstOrDefault(); if (!string.IsNullOrWhiteSpace(first)) { hookCard.SetDeviceFilter(first); hookCard.KeyPressed += OnCardKey; hookCard.AddHook(_element as Window); } } }; }
public static void SetKey(DependencyObject obj, KeyViewModel value) { obj.SetValue(KeyProperty, value); }