Exemple #1
0
        private void UpdatePlayerPosition()
        {
            //TODO: this needs to be more global
            if (!IsActive)
            {
                return;
            }
            var playPos = Player.Tr.position.WorldToGenericGrid(_sectorSize);

            if (playPos == _playerPosition)
            {
                return;
            }
            _playerPosition = playPos;
            _currentIndex   = _currentIndex == 0 ? 1 : 0;
            CurrentList.Clear();
            CurrentList.Add(_playerPosition);
            for (int i = 0; i < DirectionsExtensions.DiagonalLength; i++)
            {
                var pos = _playerPosition + ((DirectionsEight)i).ToP3();
                CurrentList.Add(pos);
            }
            SetList(true);
            SetList(false);
        }
Exemple #2
0
        private void AddNewToCurrent()
        {
            try
            {
                if (string.IsNullOrEmpty(NewTagName))
                {
                    return;
                }

                var exists = ds.GetTags(NewTagName);
                if (exists.Count > 0)
                {
                    throw new Exception("The tag already exists.");
                }
                else
                {
                    CurrentList.Add(new Tag()
                    {
                        TagName = NewTagName
                    });
                    NewTagName = "";
                }
            }
            catch (Exception e)
            {
                MessageBoxFactory.ShowError(e);
            }
        }
 /// <summary>
 /// 加入元素到缓存
 /// </summary>
 /// <param name="t"></param>
 public void Add(TU t)
 {
     lock (_lock)
     {
         CurrentList.Add(t);
     }
 }
        public async Task ExecuteLoadItemsCommand()
        {
            IsBusy = true;

            try
            {
                var list1 = await _canteenService.GetMenuOrderListCurrentAsync();

                var list2 = await _canteenService.GetMenuOrderListNextAsync();

                CurrentList.Clear();
                CurrentList.Add(new MenuOrderList {
                    WeekList = new ObservableCollection <MenuOrder>(list1)
                });
                CurrentList.Add(new MenuOrderList {
                    WeekList = new ObservableCollection <MenuOrder>(list2)
                });
                CurrentList.Add(new MenuOrderList {
                    WeekList = null
                });
            }
            catch (Exception ex)
            {
                Debug.WriteLine(ex);
            }
            finally
            {
                IsBusy = false;
            }
        }
Exemple #5
0
        private List <List <int> > GenerateVaildBestPath(List <int> BestPath)
        {
            var BestPathFull = new List <List <int> >();
            var CurrentList  = new List <int>();
            var firstList    = true;

            foreach (var v in BestPath)
            {
                if (v == 0)
                {
                    if (firstList)
                    {
                        firstList   = false;
                        CurrentList = new List <int>();
                    }
                    else
                    {
                        firstList = true;
                        CurrentList.Add(v);
                        BestPathFull.Add(CurrentList);
                        continue;
                    }
                }

                CurrentList.Add(v);
            }

            return(BestPathFull);
        }
Exemple #6
0
 public void CreateNote()
 {
     if (_currentNoteText == null)
     {
         _currentNoteText = "";
     }
     CurrentList.Add(_currentNoteText);
     CurrentNoteText = "";
     Utilities.SavedData.Save(Tabs);
 }
Exemple #7
0
        private void AddProduct()
        {
            var newProduct = new Product(ProductTitle, _currentShoppingList.ShoppingListId);

            using (var db = new ShoppingContext())
            {
                db.Products.Add(newProduct);
                db.SaveChanges();
            }
            CurrentList.Add(new BindableProduct(newProduct));
            ProductTitle = "";
        }
Exemple #8
0
 /// <summary>
 /// 加入元素到缓存
 /// </summary>
 /// <param name="t"></param>
 public void Add(TU t)
 {
     _readerWriterLockSlim.EnterReadLock();
     try
     {
         CurrentList.Add(t);
     }
     finally
     {
         _readerWriterLockSlim.ExitReadLock();
     }
 }
Exemple #9
0
        private void AddExistingToCurrent()
        {
            if (SelectedExisting == null)
            {
                return;
            }

            var tmp = SelectedExisting;

            AllTags.Remove(tmp);
            CurrentList.Add(tmp);
        }
Exemple #10
0
        private void buttonAdd_Click(object sender, EventArgs e)
        {
            Filter newItem;

            try
            {
                newItem = new Filter(Localisation.UninstallListEditor_NewFilter, Localisation.UninstallListEditor_NewFilter);
            }
            catch (Exception ex)
            {
                PremadeDialogs.GenericError(ex);
                return;
            }

            CurrentList.Add(newItem);
            PopulateList();
            OnFiltersChanged(sender, e);
        }
Exemple #11
0
        public static void Load(string[] LangFile)
        {
            Contents = new Dictionary <string, Dictionary <string, string> >();
            Lists    = new Dictionary <string, List <string> >();

            bool ListMode = false;
            Dictionary <string, string> CurrentSection = null;
            List <string> CurrentList = null;

            foreach (string Line in LangFile)
            {
                string CheckLine = Line.Trim();
                if (CheckLine == "")
                {
                    continue;
                }
                if (CheckLine[0] == ';')
                {
                    continue;
                }

                if (CheckLine.StartsWith("[") && CheckLine.EndsWith("]"))
                {
                    string SectionName = CheckLine.Substring(1, CheckLine.Length - 2);

                    if (SectionName.StartsWith("LIST_"))
                    {
                        CurrentList = new List <string>();
                        Lists[SectionName.Substring(5)] = CurrentList;
                        ListMode = true;
                    }
                    else
                    {
                        if (Contents.ContainsKey(SectionName))
                        {
                            CurrentSection = Contents[SectionName];
                        }
                        else
                        {
                            CurrentSection        = new Dictionary <string, string>();
                            Contents[SectionName] = CurrentSection;
                        }
                        ListMode = false;
                    }
                }
                else
                {
                    if (ListMode)
                    {
                        CurrentList.Add(CheckLine);
                    }
                    else
                    {
                        if (CheckLine.Contains("="))
                        {
                            int EqPos = CheckLine.IndexOf('=');
                            CurrentSection[CheckLine.Substring(0, EqPos)] = CheckLine.Substring(EqPos + 1).Replace("\\n", "\n");
                        }
                    }
                }
            }
        }
Exemple #12
0
        /// <summary>
        /// 将Snmp的Walk方法得到的结果转换为DataTable对象
        /// </summary>
        /// <param name="dictResult">结果字典</param>
        /// <param name="dictOidDesc">OID与字符串对照字典</param>
        /// <returns></returns>
        public static DataTable ConvertSnmpWalkResultToDataTable(Dictionary <Oid, AsnType> dictResult, Dictionary <String, String> dictOidDesc)
        {
            if (dictResult == null || dictResult.Count == 0)
            {
                return(null);
            }

            List <KeyValuePair <String, List <AsnType> > > lstDataTable = new List <KeyValuePair <String, List <AsnType> > >();

            String         CurrentOid  = String.Empty;
            List <AsnType> CurrentList = null;

            foreach (var key in dictResult.Keys)
            {
                var value           = dictResult[key];
                var totalKeyString  = key.ToString();
                var totalKeyArray   = totalKeyString.Split(new Char[] { '.' }, StringSplitOptions.RemoveEmptyEntries);
                var lastKey         = totalKeyArray[totalKeyArray.Length - 1];
                var parentKeyString = totalKeyString.Substring(0, totalKeyString.Length - lastKey.Length - 1);

                if (parentKeyString != CurrentOid)
                {
                    CurrentOid  = parentKeyString;
                    CurrentList = new List <AsnType>();

                    //列名称
                    var columnName = CurrentOid;
                    if (dictOidDesc != null)
                    {
                        if (dictOidDesc.ContainsKey(columnName))
                        {
                            columnName = dictOidDesc[columnName];
                        }
                    }
                    lstDataTable.Add(new KeyValuePair <String, List <AsnType> >(columnName, CurrentList));
                }
                CurrentList.Add(value);
            }

            var dt = new DataTable();

            //添加列名称
            foreach (var pair in lstDataTable)
            {
                dt.Columns.Add(pair.Key.ToString());
            }

            //列数量
            var columnCount = lstDataTable.Count;
            //行数量
            var rowCount = lstDataTable[0].Value.Count;

            //添加行
            for (int i = 0; i <= rowCount - 1; i++)
            {
                List <String> lstRowItem = new List <String>();
                for (int j = 0; j <= columnCount - 1; j++)
                {
                    var cellString = lstDataTable[j].Value[i].ToString();
                    if (dictOidDesc != null)
                    {
                        if (dictOidDesc.ContainsKey(cellString))
                        {
                            cellString = dictOidDesc[cellString];
                        }
                    }
                    lstRowItem.Add(cellString);
                }
                dt.Rows.Add(lstRowItem.ToArray());
            }

            return(dt);
        }
Exemple #13
0
 public virtual void Add(T newVal)
 {
     CurrentList.Add(newVal);
 }