예제 #1
0
        public override Client CreateEntry(Client newValue)
        {
            if (newValue.Id != -1)
            {
                throw new ArgumentException("Invalid client entry creation, Id is already set.");
            }

            using (var command = new SqliteCommand())
            {
                string insertQuery = $"INSERT INTO {TableName} ({string.Join(", ", Enum.GetNames(typeof(Columns)).Skip(1))})"
                                     + "VALUES (@FirstName, @LastName, @Company, @Phone, @Email, @Address, @Note, @CreationDate);";

                command.CommandText = insertQuery;

                SetParameters(command, newValue);
                command.Parameters.Add(new SqliteParameter("@CreationDate", DbType.DateTime)
                {
                    Value = newValue.CreationDate
                });

                newValue.Id = DBService.InsertValue(command);
            }

            AllItems.Add(newValue);

            return(newValue);
        }
예제 #2
0
        async Task ExecuteLoadItemsCommand(IDataStore <Item> DataStore)
        {
            if (IsBusy)
            {
                return;
            }
            IsBusy = true;
            try
            {
                AllItems.Clear();
                List <Item> items = await DataStore.GetItemsAsync();

                foreach (var item in items)
                {
                    AllItems.Add(item);
                }
            }
            catch (Exception ex)
            {
                Debug.WriteLine(ex);
            }
            finally
            {
                IsBusy = false;
            }
        }
예제 #3
0
        public void SpawnItem(int id, Vector2 pos, Vector2?vel = null)
        {
            switch (id)
            {
            case 0:
                DeluminatorWorld deluminator = new DeluminatorWorld(pos);
                AllItems.Add(deluminator);
                break;

            case 1:
                MaraudersMapWorld map = new MaraudersMapWorld(pos);
                AllItems.Add(map);
                break;

            case 2:
                PortKeyWorld key = new PortKeyWorld(pos);
                AllItems.Add(key);
                break;

            case 3:
                TheGoldenSnitchWorld snitch = new TheGoldenSnitchWorld(pos, vel.Value);
                AllItems.Add(snitch);
                break;
            }
        }
예제 #4
0
        public async void GetWeather(string text)
        {
            Windows.Data.Json.JsonObject total_json = await service.GetWeatherItem(text);

            if (total_json == null)
            {
                MessageDialog dialog = new MessageDialog("搜索不到相关城市信息\n请检查输入是否无误");
                await dialog.ShowAsync();

                return;
            }
            StringBuilder message = new StringBuilder("");

            if (total_json.GetNamedNumber("showapi_res_code") != 0)
            {
                message.AppendLine(total_json.GetNamedString("showapi_res_error"));
                MessageDialog dialog = new MessageDialog(message.ToString());
                await dialog.ShowAsync();
            }
            else
            {
                json = total_json.GetNamedObject("showapi_res_body");
                current_item.Area = json.GetNamedObject("cityInfo").GetNamedString("c9") +
                                    json.GetNamedObject("cityInfo").GetNamedString("c7") + "省" +
                                    json.GetNamedObject("cityInfo").GetNamedString("c3") + "市";
                current_item.Json = json.GetNamedObject("now");
                AllItems.Clear();
                for (int i = 1; i <= 7; i++)
                {
                    AllItems.Add(new WeatherItem(json.GetNamedObject("f" + i)));
                }
            }
        }
예제 #5
0
        void Load()
        {
            cbNode.Items.Clear();
            AllItems.Clear();

            lvChilds.ItemsSource   = SelectedChildLinks;
            lvVariants.ItemsSource = Variants;

            cbNode.Items.Add("Add new...");
            foreach (var node in knowlegeBaseManager.Base.Nodes)
            {
                AllItems.Add(new ContentControl()
                {
                    Content = node.Id.ToString(), Tag = node.Id
                });
            }
            foreach (var node in knowlegeBaseManager.Base.Nodes)
            {
                cbNode.Items.Add(new ContentControl()
                {
                    Content = node.Id.ToString(), Tag = node.Id
                });
            }
            cbNode.SelectedIndex = 0;
            tbVariantTitle.Clear();
            tbVariantlinkname.Clear();
        }
        protected override void UpdateContent()
        {
            AllItems.Clear();
            IList <Item> all_items = FindAllItems(mSearchField, mSearchValue);

            foreach (Item item in all_items)
            {
                AllItems.Add(item);
            }

            SoldItems.Clear();
            IList <Item> sold_items = FindSoldItems(mSearchField, mSearchValue);

            foreach (Item item in sold_items)
            {
                SoldItems.Add(item);
            }

            BoughtItems.Clear();
            IList <Item> bought_items = FindBoughtItems(mSearchField, mSearchValue);

            foreach (Item item in bought_items)
            {
                BoughtItems.Add(item);
            }

            InventoriedItems.Clear();
            IList <Item> inventoried_items = FindInventoriedItems(mSearchField, mSearchValue);

            foreach (Item item in inventoried_items)
            {
                InventoriedItems.Add(item);
            }
        }
예제 #7
0
        //向歌单里增加歌曲,返回歌曲ID
        public int AddSong(string _name, string _singer, string _path)
        {
            Song tempSong = new Song(_name, _singer, _path);

            AllItems.Add(tempSong);
            return(tempSong.id);
        }
예제 #8
0
 /// <summary>
 /// Adds an object to the collection. Also makes modifications to the object.
 /// </summary>
 /// <param name="currObject">The object to be added to the collection.</param>
 /// <returns>The object added to the collection.</returns>
 public T Add(T currObject)
 {
     MakeDocumentDirty();
     currObject.Owner = this.Owner;
     AllItems.Add(currObject);
     return(currObject);
 }
예제 #9
0
        public override Expense CreateEntry(Expense newValue)
        {
            if (newValue.Id != -1)
            {
                throw new ArgumentException("Invalid expense entry creation, Id is already set.");
            }

            using (var command = new SqliteCommand())
            {
                string insertQuery = $"INSERT INTO {TableName} ({string.Join(", ", Enum.GetNames(typeof(Columns)).Skip(1))})"
                                     + "VALUES (@Date, @Description, @ImageReference, @InvoiceID, @ExpenseCategory, @TaxAmount, @TotalAmount, @CreationDate, @Note);";

                command.CommandText = insertQuery;

                SetParameters(command, newValue);
                command.Parameters.Add(new SqliteParameter("@CreationDate", DbType.DateTime)
                {
                    Value = newValue.CreationDate
                });

                newValue.Id = DBService.InsertValue(command);
            }

            AllItems.Add(newValue);

            return(newValue);
        }
예제 #10
0
 public void Add(CfgNodeValue <TK, TV> value)
 {
     lock (_lock)
     {
         AllItems.Add(value);
         if (!RepeatedItems.ContainsKey(value.Key))
         {
             if (SingleItems.ContainsKey(value.Key))
             {
                 RepeatedItems.Add(value.Key, new List <CfgNodeValue <TK, TV> > {
                     SingleItems[value.Key]
                 });
                 SingleItems.Remove(value.Key);
                 RepeatedItems[value.Key].Add(value);
             }
             else
             {
                 SingleItems.Add(value.Key, value);
             }
         }
         else
         {
             RepeatedItems[value.Key].Add(value);
         }
     }
 }
예제 #11
0
        protected override void OnVehicleSelected()
        {
            AttentionItems.Clear();
            AllItems.Clear();
            var svc = Infrastructure.Container.GetInstance <IVtsWebService>();

            try
            {
                List <VehicleEventViewModel> vms = svc.GetVehicleEvents(SelectedVehicle.Vin).
                                                   Select(VehicleEventAssembler.FromDtoToDomainObject).
                                                   Select(v => new VehicleEventViewModel(v, SelectedVehicle.Model)).
                                                   ToList();
                foreach (VehicleEventViewModel viewModel in vms.OrderByDescending(v => v.Date))
                {
                    AllItems.Add(viewModel);
                    if (RequiresAttention(viewModel, vms))
                    {
                        AttentionItems.Add(viewModel);
                    }
                }
            }
            catch (Exception e)
            {
                ErrorWindow w = new ErrorWindow(e, "Cannot get vehicle events");
                w.ShowDialog();
                Log.Error(e, "Cannot get vehicle events");
            }
            finally
            {
                StopWaiting();
            }
        }
예제 #12
0
        public MenuItem AppendSubMenuItem(MenuItem parent, string label, EventHandler selectedHandler)
        {
            if (menuContainer != null)
            {
                throw new Exception("HUDRadialMenu cannot call AppendSubMenuItem after Create");
            }
            if (AllItems.Contains(parent) == false)
            {
                throw new Exception("HUDRadialMenu does not contain this MenuItem with label " + parent.Label);
            }

            MenuItem i = new MenuItem()
            {
                Label = label
            };

            i.OnSelected += selectedHandler;
            if (parent.SubItems == null)
            {
                parent.SubItems = new List <MenuItem>();
            }
            parent.SubItems.Add(i);
            i.ParentItem = parent;
            AllItems.Add(i);
            return(i);
        }
예제 #13
0
        private void OpenSettings_Click(object sender, RoutedEventArgs e)
        {
            Console.WriteLine("Opening Settings File...");
            OpenFileDialog openFileDialog = new OpenFileDialog();

            openFileDialog.InitialDirectory = System.Windows.Forms.Application.StartupPath;

            if (openFileDialog.ShowDialog() == System.Windows.Forms.DialogResult.OK)
            {
                Console.WriteLine("    " + openFileDialog.FileName);

                SettingsFile = Settings.LoadFromFile(openFileDialog.FileName);

                AllItems.Clear();

                foreach (Item item in SettingsFile.BasicAugments.Concat(SettingsFile.CoreAugs).Concat(SettingsFile.PrimaryWeapons).Concat(SettingsFile.Prototypes))
                {
                    AllItems.Add(item);
                }

                List <Item> removeItems = AllItems.Where((item) => item.Name == String.Empty || item.Lockable == false).ToList();
                foreach (Item item in removeItems)
                {
                    AllItems.Remove(item); // <-- remove placeholders and non-lockable items
                }

                SettingsPathToUse = openFileDialog.FileName;

                Console.WriteLine("    File Opened.");
            }
        }
예제 #14
0
        //将数据库中的Item导入
        public async Task AddTodoItems(Models.TodoItem item)
        {
            await item.setImg();

            AllItems.Add(item);
            TileService.UpdateTileItem();   //更新磁贴
        }
예제 #15
0
        /// <summary>
        /// Adds a child KmlItem to this nodes lists of children, depending of its
        /// derived class KmlNode or KmlAttrib or further derived from these.
        /// When an KmlAttrib "Name" is found, its value will be used for the "Name" property
        /// of this node.
        /// </summary>
        /// <param name="item">The KmlItem to add</param>
        public virtual void Add(KmlItem item)
        {
            AllItems.Add(item);
            if (item is KmlNode)
            {
                Children.Add((KmlNode)item);
            }
            else if (item is KmlAttrib)
            {
                KmlAttrib attrib = (KmlAttrib)item;
                if (attrib.Name.ToLower() == "name")
                {
                    Name = attrib.Value;

                    // Get notified when Name changes
                    attrib.AttribValueChanged += Name_Changed;
                    attrib.CanBeDeleted        = false;
                }
                Attribs.Add(attrib);
            }
            else
            {
                Unknown.Add(item);
                Syntax.Warning(this, "Unknown line in persistence file: " + item.ToString());
            }
        }
 private void Add()
 {
     if (!AllItems.Any(x => x.IsEmpty))
     {
         AllItems.Add(new NamespaceItem());
     }
 }
예제 #17
0
        private async Task <bool> LoadMoreItems()
        {
            Page += 1;
            var result = await _dataService.GetMoreItems(IndexType, Page);

            if (result.Result == LoadedResultType.Failed)
            {
                return(false);
            }
            var items = result.Items;

            items.ForEach(x =>
            {
                x.Ranking = this;
                AllItems.Add(x);
            });
            items.ForEach(x =>
            {
                x.Ranking = this;
                AllItemsWithoutFirst.Add(x);
            });
            if (Page == 10)
            {
                return(false);
            }
            return(true);
        }
예제 #18
0
 /// <summary>
 /// Use this function to add a new item into the 'AllItems' list.
 /// </summary>
 /// <param name="item"></param>
 public void AddItem(GlobalItem item)
 {
     if (item == null)
     {
         return;
     }
     //if (!(sideItem is PathEventItem) && !(sideItem is SideStartItem))
     if (item.asMetadata)
     {
         if (routeItems.IndexOf(item) < 0)
         {
             routeItems.Add(item);
         }
     }
     if (AllItems.IndexOf(item) < 0)
     {
         AllItems.Add(item);
     }
     toSave = true;
     if (item.GetType() == typeof(StationItem))
     {
         foreach (StationAreaItem SAItem in ((StationItem)item).stationArea)
         {
             AllItems.Add(SAItem);
         }
     }
 }
예제 #19
0
        public LedItem()
        {
            AllItems.Add(this);

            MainWindow.ActiveWindow.itemStackPanel.Children.Add(this);

            Name = $"Item{LedItem.AllItems.Count}";

            foreach (LedItem item in LedItem.AllItems)
            {
                if (item.ItemName == "LED")
                {
                    ItemName = $"LED{LedItem.AllItems.Count}";
                }
            }

            ID = MainWindow.IDCounter;

            LedItem.RefreshSyncableItems();

            //make item selected if its the first
            if (LedItem.AllItems.Count == 1)
            {
                MainWindow.ActiveWindow.SelectedLedItem = this;
            }

            MainWindow.IDCounter++;

            DataContext = this;

            InitializeComponent();
        }
예제 #20
0
        private void 扫描项目(XmlNodeList list, string pattern)
        {
            var lastTime = Settings.Default.次更新;

            Settings.Default.次更新 = Convert.ToDateTime(((XmlElement)list[0]).GetElementsByTagName("pubDate")[0].InnerText);
            Settings.Default.Save();
            var temp = DateTime.Now;

            foreach (XmlNode node in list)
            {
                XmlElement ele   = (XmlElement)node;
                string     title = ele.GetElementsByTagName("title")[0].InnerText;
                string     url   = ele.GetElementsByTagName("enclosure")[0].Attributes["url"].Value;
                DateTime   time  = DateTime.Parse(ele.GetElementsByTagName("pubDate")[0].InnerText);
                temp = time;
                if (time <= lastTime)
                {
                    Message = "扫描已达上次更新时间:" + temp.ToString();
                    return;
                }
                AllItems.Add(new STuple(title, url));
                if (Regex.IsMatch(title, pattern, RegexOptions.IgnoreCase))
                {
                    SelectedItems.Add(new STuple(title, url));
                }
            }
            Message = "扫描完成。起始时间:" + temp.ToString();
        }
예제 #21
0
        private void AddItem(FolderViewModel folder)
        {
            folder.OnOpened  += OnItemOpened;
            folder.OnDeleted += OnItemDeleted;

            SubDirectories.Add(folder);
            AllItems.Add(folder);
        }
예제 #22
0
 /// <summary>
 /// Adds an object to the collection. Also makes modifications to the object.
 /// </summary>
 /// <param name="currObject">The object to be added to the collection.</param>
 /// <returns>The object added to the collection.</returns>
 public T Add(T currObject)
 {
     MakeDocumentDirty();
     currObject.Owner = this.Owner;
     PropagateInDocument(currObject, this.Owner.InDocument);
     AllItems.Add(currObject);
     return(currObject);
 }
예제 #23
0
        private void AddItem(FileViewModel file)
        {
            file.OnOpened  += OnItemOpened;
            file.OnDeleted += OnItemDeleted;

            Files.Add(file);
            AllItems.Add(file);
        }
예제 #24
0
        //创建新Item
        public void AddTodoItem(ImageSource _image, double picSize, string imgName, string title, string description, DateTimeOffset dateTime, bool?isChecked = false, string _id = "")
        {
            string id = Guid.NewGuid().ToString(); //生成id

            AllItems.Add(new Models.TodoItem(id, _image, picSize, imgName, title, description, dateTime, isChecked));
            App.db.addItem(new Models.TodoItem(id, _image, picSize, imgName, title, description, dateTime, isChecked));
            TileService.UpdateTileItem();   //更新磁贴
        }
예제 #25
0
 public void AddItem()
 {
     if (!string.IsNullOrEmpty(ItemToAdd) && !AllItems.Contains(ItemToAdd))
     {
         AllItems.Add(ItemToAdd);
     }
     ItemToAdd = "";
 }
예제 #26
0
        private void GenerateRandomItems(int itemsCount, int randomSeed)
        {
            var random = new Random(randomSeed);

            for (var i = 0; i < itemsCount; i++)
            {
                AllItems.Add(new Item(random.Next() % 100, random.NextDouble()));
            }
        }
 public void AddItem(Item item)
 {
     Counter++;
     AllItems.Add(item);
     if ((item.Height <= Height && item.Width <= Width) || (item.Height <= Width && item.Width <= Height))
     {
         Items.Add(item);
     }
 }
예제 #28
0
 public void Load()
 {
     //await Task.Factory.StartNew(() =>
     //{
     foreach (var mediaItem in _mediaCollectionManager.GetAllMediaItems())
     {
         AllItems.Add(mediaItem);
     }
     //});
 }
예제 #29
0
        /// < inheritdoc/>
        public new CdmDocumentDefinition Add(CdmDocumentDefinition document)
        {
            this.AddItemModifications(document);

            // why is this collection unlike all other collections?
            // because documents are in folders. folders are not in documents.
            document.Owner = this.Owner;
            AllItems.Add(document);
            return(document);
        }
예제 #30
0
        private async Task DoLoadAsync()
        {
            IsBusy = true;

            bool couldLoad = false;

            try
            {
                // Need to define the action to call
                var data = await LoadPageFromNetworkAsync();

                foreach (T item in data)
                {
                    AllItems.Add(item);
                }

                couldLoad    = true;
                DataLocation = DataLoadLocation.RemoteService;
            }
            catch (Exception e)
            {
                HandleLoadException(e);
                couldLoad = false;
            }

            if (!couldLoad)
            {
                DataLocation = DataLoadLocation.Cache;

                try
                {
                    AllItems.Clear();

                    var data = await LoadDataFromCacheAsync();

                    foreach (T item in data)
                    {
                        AllItems.Add(item);
                    }

                    HasMoreData = false;
                }
                catch (Exception e)
                {
                    HandleLoadException(e);
                }

                DataLocation = DataLoadLocation.Cache;
            }

            UpdateOfflineIndicator();

            IsBusy    = false;
            IsLoading = false;
        }