public async Task <List <Question> > GetRandomQuestions(int num)
        {
            DbCommand <Question> selectAllCommand = new SelectAllCommand <Question>();
            List <Question>      questions        = await ServiceHelper <Question> .ExecuteSelectCommand(selectAllCommand);

            return(questions.OrderBy(a => Guid.NewGuid()).Take(num).ToList());
        }
        public PersonViewModel()
        {
            Person = new PersonModel()
            {
                ForName = "",
                SurName = "",
                Gender  = "",
                Age     = 0,
                ID      = 0
            };

            Persons = new ObservableCollection <PersonModel>();

            InsertCommand    = new InsertCommand(this);
            DeleteAllCommand = new DeleteAllCommand(this);
            DeleteCommand    = new DeleteCommand(this);
            UpdateCommand    = new UpdateCommand(this);
            SelectAllCommand = new SelectAllCommand(this);
            SelectCommand    = new SelectCommand(this);

            connection = new SqlConnection("Server = .; DataBase = PersonDatabase; Trusted_Connection = true;");
            connection.Open();

            Select("SELECT * FROM Person;");
        }
Example #3
0
        private async void OnOpenDrive()
        {
            try
            {
                Reading = true;
                CdItems.Clear();
                CdItemViewModel[] cdTracks = await _cdReaderService.GetTracks(DriveLetter);

                CdItems.AddRange(cdTracks);
                await RaisePropertyChanged(nameof(CdItems));

                Reading = false;
            }
            catch (Exception)
            {
                _dialogService.ShowError(Resources.Error_CdRead);
                Reading = false;
                CdItems.Clear();
            }
            finally
            {
                SelectAllCommand.RaiseCanExecuteChanged();
                DeSelectAllCommand.RaiseCanExecuteChanged();
                ReadCommand.RaiseCanExecuteChanged();
            }
        }
Example #4
0
        /// <summary>
        /// 子供の検索(無駄にasync)
        /// </summary>
        private async void Search()
        {
            await _model.SearchChildDirectoryTaskAsync();


            SelectAllCommand.RaiseCanExecuteChanged();
            DeselectAllCommand.RaiseCanExecuteChanged();
        }
Example #5
0
 public IEnumerable <T> GetAll()
 {
     ConnectionCheck();
     SelectAllCommand.Connection = connection;
     using (SqlDataReader reader = SelectAllCommand.ExecuteReader())
     {
         List <T> objects = new List <T>();
         while (reader.Read())
         {
             objects.Add(GetObject(reader));
         }
         return(objects);
     }
 }
Example #6
0
 public EditCommand(UndoCommand undoCommand, RedoCommand redoCommand, CutCommand cutCommand,
                    CopyCommand copyCommand, PasteCommand pasteCommand, SelectAllCommand selectAllCommand,
                    ExponentCommand exponentCommand)
     : base(MenuStrings.editToolStripMenuItem1_Text)
 {
     ChildrenCommands = new List <IToolbarCommand>
     {
         undoCommand,
         redoCommand,
         null,
         cutCommand,
         copyCommand,
         pasteCommand,
         null,
         selectAllCommand,
         null,
         exponentCommand
     };
 }
Example #7
0
        public async Task <IList <City> > GetAll()
        {
            DbCommand <City> selectAllCommand = new SelectAllCommand <City>();

            return(await ServiceHelper <City> .ExecuteSelectCommand(selectAllCommand));
        }
        //Test if any objects were clicked
        private void checkSelect()
        {
            //Stores the command that needs to be executed
            EditCommand selectionCommand = null;

            //If escape is pressed, deselect all
            if (Input.GetKeyDown(KeyCode.Escape))
            {
                selectionCommand = new DeselectAllCommand();
            }
            //If escape was not pressed, check for shortcut commands
            else
            {
                if (selectAllShortcut.Pressed())
                {
                    if (selectedObjects.Count > 0)
                    {
                        selectionCommand = new DeselectAllCommand();
                    }
                    else
                    {
                        selectionCommand = new SelectAllCommand();
                    }
                }

                if (invertSelectionShortcut.Pressed())
                {
                    selectionCommand = new InvertSelectionCommand();
                }
            }

            //If the mouse was clicked and the cursor is not over the UI, check if any objects were selected
            if (Input.GetMouseButtonUp(0) && !EventSystem.current.IsPointerOverGameObject(-1))
            {
                RaycastHit hit;
                Ray        ray    = mainCamera.ScreenPointToRay(Input.mousePosition);
                bool       rayHit = Physics.Raycast(ray, out hit, Mathf.Infinity);

                //Check if nothing was hit or the hit object isn't selectable
                if (!rayHit || hit.transform.gameObject.tag != "Selectable")
                {
                    //If not in additive mode and there is a selection, deselect all
                    if (!Input.GetKey(KeyCode.LeftControl) && Instance.selectedObjects.Count > 0)
                    {
                        selectionCommand = new DeselectAllCommand();
                    }
                }
                //If an object was clicked, select it
                else
                {
                    //Select the parent of the object
                    GameObject parentObject = GetParent(hit.transform.gameObject);

                    //If left control is not held, deselect all objects and select the clicked object
                    if (!Input.GetKey(KeyCode.LeftControl))
                    {
                        //If the clicked object is already the only selected object, skip it
                        if (Instance.selectedObjects.Count == 1 &&
                            Instance.selectedObjects.Contains(parentObject))
                        {
                            return;
                        }

                        selectionCommand = new SelectReplaceCommand(parentObject);
                    }
                    //If left control is held, select or deselect the object based on if its currently selected
                    else
                    {
                        if (!selectedObjects.Contains(parentObject))
                        {
                            selectionCommand = new SelectAdditiveCommand(parentObject);
                        }
                        else
                        {
                            selectionCommand = new DeselectObjectCommand(parentObject);
                        }
                    }
                }
            }

            //If a selection was made, execute its associated command and add it to the history
            if (selectionCommand != null)
            {
                selectionCommand.ExecuteEdit();
                EditHistory.Instance.AddCommand(selectionCommand);
            }
        }
        public void LoadCommands()
        {
            LoadEquippedItemsCommand = new RelayCommand(parameter =>
            {
                try
                {
                    if (ZetaDia.Me == null || !ZetaDia.IsInGame)
                    {
                        if (!ChangeEvents.IsInGame.Value)
                        {
                            Core.Logger.Log("Must be in a game to use this feature");
                        }
                        else
                        {
                            using (ZetaDia.Memory.AcquireFrame())
                            {
                                ZetaDia.Actors.Update();
                                Core.Logger.Log("Scanning Character for Equipped Items");
                                SelectItems(InventoryManager.Equipped);
                            }
                        }
                    }
                    else
                    {
                        if (!BotMain.IsRunning)
                        {
                            ZetaDia.Actors.Update();
                        }

                        Core.Logger.Log("Scanning Character for Equipped Items");
                        SelectItems(InventoryManager.Equipped);
                    }
                }
                catch (Exception ex)
                {
                    Core.Logger.Error("Exception in SelectAllCommand {0}", ex);
                }
            });

            LoadStashedItemsCommand = new RelayCommand(parameter =>
            {
                try
                {
                    if (ZetaDia.Me == null || !ZetaDia.IsInGame)
                    {
                        if (BotMain.IsRunning)
                        {
                            Core.Logger.Log("Must be in a game to use this feature");
                        }
                        else
                        {
                            using (ZetaDia.Memory.AcquireFrame())
                            {
                                ZetaDia.Actors.Update();
                                Core.Logger.Log("Scanning Character for Stashed Items");
                                SelectItems(InventoryManager.StashItems);
                            }
                        }
                    }
                    else
                    {
                        ZetaDia.Actors.Update();
                        Core.Logger.Log("Scanning Character for Stashed Items");
                        SelectItems(InventoryManager.StashItems);
                    }
                }
                catch (Exception ex)
                {
                    Core.Logger.Error("Exception in SelectAllCommand {0}", ex);
                }
            });

            AdvancedOptionCommand = new RelayCommand(parameter =>
            {
                try
                {
                    if (parameter == null)
                    {
                        return;
                    }

                    Core.Logger.Verbose("AdvancedOptionCommand Fired {0}", parameter.ToString());

                    var item = parameter as ComboBoxItem;
                    var selectedPropertyName = item != null ? item.Tag.ToString() : parameter.ToString();

                    switch (selectedPropertyName)
                    {
                    case "SelectAllCommand":
                        SelectAllCommand.Execute(null);
                        break;

                    case "SelectNoneCommand":
                        SelectNoneCommand.Execute(null);
                        break;

                    case "ClearRulesCommand":
                        ClearRulesCommand.Execute(null);
                        break;

                    case "AddAllSetsCommand":
                        AddAllSetsCommand.Execute(null);
                        break;

                    case "AddAllLegendaryAffixCommand":
                        AddAllLegendaryAffixCommand.Execute(null);
                        break;

                    case "Add24ItemsCommand":
                        Add24ItemsCommand.Execute(null);
                        break;
                    }
                }
                catch (Exception ex)
                {
                    Core.Logger.Error("Exception in AdvancedOptionCommand: {0} {1}", ex.Message, ex.InnerException);
                }
            });

            SelectAllCommand = new RelayCommand(parameter =>
            {
                try
                {
                    if (SelectedTab == Tab.Legendary)
                    {
                        Core.Logger.Log("Selecting all items");
                        using (Collection.DeferRefresh())
                        {
                            SelectedItems = new List <LItem>(DisplayItems);
                            UpdateSelectedItems();
                        }
                        return;
                    }

                    if (SelectedTab == Tab.ItemType)
                    {
                        Core.Logger.Log("Selecting all item types.");
                        ItemTypes.ForEach(i => i.IsSelected = true);
                    }
                }
                catch (Exception ex)
                {
                    Core.Logger.Error("Exception in SelectAllCommand {0}", ex);
                }
            });

            Add24ItemsCommand = new RelayCommand(parameter =>
            {
                try
                {
                    Core.Logger.Log("Add24ItemsCommand Not Implemented");
                    AddToSelection(item => ItemListPresets.Patch24Items.Contains(item.Id));
                }
                catch (Exception ex)
                {
                    Core.Logger.Error("Exception in SelectAllCommand {0}", ex);
                }
            });

            AddAllSetsCommand = new RelayCommand(parameter =>
            {
                try
                {
                    Core.Logger.Log("AddAllSetsCommand Not Implemented");
                    AddToSelection(item => item.IsSetItem);
                }
                catch (Exception ex)
                {
                    Core.Logger.Error("Exception in SelectAllCommand {0}", ex);
                }
            });

            AddAllLegendaryAffixCommand = new RelayCommand(parameter =>
            {
                try
                {
                    Core.Logger.Log("Selecting all items with a legendary affix");
                    AddToSelection(item => !string.IsNullOrEmpty(item.LegendaryAffix));
                }
                catch (Exception ex)
                {
                    Core.Logger.Error("Exception in SelectAllLegendaryAffixCommand {0}", ex);
                }
            });

            SelectNoneCommand = new RelayCommand(parameter =>
            {
                try
                {
                    if (SelectedTab == Tab.Legendary)
                    {
                        Core.Logger.Log("Deselecting all legendary items");
                        using (Collection.DeferRefresh())
                        {
                            SelectedItems = new List <LItem>();
                            CreateView();
                            UpdateSelectedItems();
                        }
                        return;
                    }

                    if (SelectedTab == Tab.ItemType)
                    {
                        using (ItemTypes.ViewSource.DeferRefresh())
                        {
                            foreach (var itemType in ItemTypes)
                            {
                                itemType.IsSelected = false;
                            }
                        }
                    }
                }
                catch (Exception ex)
                {
                    Core.Logger.Error("Exception in SelectNoneCommand {0}", ex);
                }
            });

            ClearRulesCommand = new RelayCommand(parameter =>
            {
                try
                {
                    if (SelectedTab == Tab.Legendary)
                    {
                        Core.Logger.Log("Removing rules from all legendary items.");
                        using (Collection.DeferRefresh())
                        {
                            SelectedItems.ForEach(i => i.Rules = new ObservableCollection <LRule>());
                            UpdateSelectedItems();
                        }
                        return;
                    }

                    if (SelectedTab == Tab.ItemType)
                    {
                        Core.Logger.Log("Removing rules from all item types.");
                        ItemTypes.ForEach(i => i.Rules = new FullyObservableCollection <LRule>());
                    }
                }
                catch (Exception ex)
                {
                    Core.Logger.Error("Exception in ClearAllRulesCommand {0}", ex);
                }
            });

            ResetFilterCommand = new RelayCommand(parameter => { FilterText = string.Empty; });

            EnableItemListCommand = new RelayCommand(parameter =>
            {
                Core.Logger.Log("Setting ItemFilterMode to ItemList");
                UILoader.DataContext.Items.LegendaryMode = LegendaryMode.ItemList;
            });

            LoadModalCommand = new RelayCommand(parameter =>
            {
                if (parameter == null)
                {
                    return;
                }

                ModalPage page;
                if (Enum.TryParse(parameter.ToString(), out page))
                {
                    if (page != ModalPage.None)
                    {
                        SelectedModalPage = page;
                        IsModalVisible    = true;
                    }

                    ExportCode = string.Empty;

                    if (page == ModalPage.Export)
                    {
                        ExportCommand.Execute(parameter);
                    }
                }

                Core.Logger.Log("Selecting modal content... {0}", parameter.ToString());
            });

            CloseModalCommand = new RelayCommand(parameter => { IsModalVisible = false; });

            ImportCommand = new RelayCommand(parameter =>
            {
                Core.Logger.Log("Importing ItemList...");

                var oldSlected = _selectedItems.Count;

                ImportFromCode(ExportCode);

                Core.Logger.Log("Selected Before = {0} After = {1}", oldSlected, _selectedItems.Count);

                IsModalVisible = false;
            });

            ExportCommand = new RelayCommand(parameter =>
            {
                Core.Logger.Log("Exporting ItemList... {0}", parameter);
                ExportCode = CreateExportCode();
            });
        }
Example #10
0
 private void OnCdItemsChanged(object sender, ListChangedEventArgs e)
 {
     SelectAllCommand.RaiseCanExecuteChanged();
     DeSelectAllCommand.RaiseCanExecuteChanged();
     ReadCommand.RaiseCanExecuteChanged();
 }
Example #11
0
 private void RaiseCanExecuteChanged()
 {
     UpdateSelectedFilesCommand.RaiseCanExecuteChanged();
     SelectAllCommand.RaiseCanExecuteChanged();
     SelectNoneCommand.RaiseCanExecuteChanged();
 }