private void DemoItemsListBox_SelectionChanged(object sender, SelectionChangedEventArgs e) { DemoItem item = (DemoItem)DemoItemsListBox.SelectedItem; var mainwindowviewmodel = Window.GetWindow(this).DataContext as MainWindowViewModel; mainwindowviewmodel.DemoItem = item; }
private void DemoItemsListBox_MouseDown(object sender, MouseButtonEventArgs e) { DemoItem item = (DemoItem)DemoItemsListBox.SelectedItem; var mainwindowviewmodel = Window.GetWindow(this).DataContext as MainWindowViewModel; mainwindowviewmodel.DemoItem = item; }
public IActionResult Create(DemoItem item) { _context.DemoItems.Add(item); _context.SaveChanges(); return(CreatedAtRoute("GetDemo", new { id = item.Id }, item)); }
public void ShowPage(DemoItem item) { item.Control.Dock = DockStyle.Fill; splitContainerView.Panel2.Controls.Clear(); splitContainerView.Panel2.Controls.Add(item.Control); }
public void Start() { Console.WriteLine("==========Add/Remove Demo=========="); // initialize datas uint[] ids = createIDs(10); string idstr = ids[0].ToString(); for (int i = 1; i < ids.Length; i++) { idstr += " " + ids[i].ToString(); } Console.WriteLine("Before add : "); Console.WriteLine(idstr); // add demo KeyedList <uint, DemoItem> list = new KeyedList <uint, DemoItem>(); for (int i = 0; i < ids.Length; i++) { var item = new DemoItem(ids[i], $"Item_{ids[i]}"); list.Add(item); } Console.WriteLine("After add : "); print(list); // remove demo for (int i = 0; i < ids.Length / 2; i++) { list.RemoveByKey(ids[i]); } Console.WriteLine("After remove : "); print(list); }
public void Start() { Console.WriteLine("============Except Demo============"); // initialize datas uint[] ids = createIDs(10); string idstr = ids[0].ToString(); for (int i = 1; i < ids.Length; i++) { idstr += " " + ids[i].ToString(); } // add KeyedList <uint, DemoItem> list = new KeyedList <uint, DemoItem>(); KeyedList <uint, DemoItem> subList = new KeyedList <uint, DemoItem>(); for (int i = 0; i < ids.Length; i++) { var item = new DemoItem(ids[i], $"Item_{ids[i]}"); list.Add(item); if (i < ids.Length / 2) { subList.Add(item); } } Console.WriteLine("Before Except:"); print(list); Console.WriteLine("Sub List:"); print(subList); Console.WriteLine("After Except"); list = KeyedList <uint, DemoItem> .Except(list, subList); print(list); }
public virtual void AddDemoItem(string relativedemopath, List <DemoItem> demos, BinaryReader reader, ResourceType restype) { relativedemopath = relativedemopath.Replace(Path.AltDirectorySeparatorChar, Path.DirectorySeparatorChar); DemoItem di = getdemoinfo(relativedemopath, reader, restype); if (di != null) { if (di.IsInvalid) { demos.Add(di); } else if (!mapnames.Contains(Path.GetFileNameWithoutExtension(di.MapFilePath))) // Check if we have a matching map... { demos.Add(new DemoItem(relativedemopath, "Missing map file: '" + di.MapFilePath + "'", di.ResourceType)); // Add anyway, but with a warning... } else if (!string.IsNullOrEmpty(di.ModName) && string.Compare(modname, di.ModName, StringComparison.OrdinalIgnoreCase) != 0) { demos.Add(new DemoItem(relativedemopath, "Incorrect location: expected to be in '" + di.ModName + "' folder", di.ResourceType)); // Add anyway, but with a warning... } else { demos.Add(di); } } else { // Add anyway, I guess... demos.Add(new DemoItem(relativedemopath, "Unknown demo format", restype)); } }
public void Start() { Console.WriteLine("============Search Demo============"); // initialize datas uint[] ids = createIDs(10); string idstr = ids[0].ToString(); for (int i = 1; i < ids.Length; i++) { idstr += " " + ids[i].ToString(); } // add KeyedList <uint, DemoItem> list = new KeyedList <uint, DemoItem>(); for (int i = 0; i < ids.Length; i++) { var item = new DemoItem(ids[i], $"Item_{ids[i]}"); list.Add(item); } // search demo string itemStr = list.FindByKey(ids[0]).Data.ToString(); for (int i = 1; i < ids.Length; i++) { itemStr += ", " + list.FindByKey(ids[i]).Data.ToString(); } Console.WriteLine($"Search by ({idstr}) :"); Console.WriteLine(itemStr); }
private void MouseLeftButtonDownClassHandler(object sender, RoutedEventArgs e) { DemoItem item = (DemoItem)DemoItemsListBox.SelectedItem; var mainwindowviewmodel = Window.GetWindow(this).DataContext as MainWindowViewModel; mainwindowviewmodel.DemoItem = item; }
private static void DrawNewImage(DrawItemEventArgs e, DemoItem item) { var g = e.Graphics; var r = e.Bounds; if (item.Page.IsNew) { g.DrawImage(Properties.Resources.NewIcon, new Rectangle(r.X, r.Y, 16, 16)); } }
private void RegisterDemos(IList <IDemoPage> demos) { var ordered = demos.OrderByDescending(x => x.IsNew).ThenBy(x => x.Title).ToList(); foreach (var page in ordered) { var item = new DemoItem(page); listBoxDemos.Items.Add(item); } }
private static void DrawString(DrawItemEventArgs e, DemoItem item) { var g = e.Graphics; var r = e.Bounds; using (var brush = new SolidBrush(e.ForeColor)) { var rectangle = item.Page.IsNew ? new Rectangle(r.X + 16, r.Y, r.Width, r.Height) : r; g.DrawString(item.Page.Title, e.Font, brush, rectangle); } }
public MainViewModel() { DemoItems = new DemoItem[] { new DemoItem("Home", new View.Home(), PackIconKind.Home), new DemoItem("Palette", new View.PaletteSelector(), PackIconKind.Palette), new DemoItem("ConvertFile", new View.ConvertFile(), PackIconKind.Key), new DemoItem("Vision", new View.Vision(), PackIconKind.Video), }; ChangeUI(); SR.LanguageChanged += (s, e) => ChangeUI(); }
/// <summary> /// Switches the item. /// </summary> /// <param name="item">The item.</param> public void SwitchItem(DemoItem item) { if (FirstCollection.Contains(item)) { FirstCollection.Remove(item); SecondCollection.Add(item); } else { SecondCollection.Remove(item); FirstCollection.Add(item); } }
private void RegisterDemos(IDemoPage demo) { if (demo.Title == null) { throw new ApplicationException(string.Format("page has no title : {0}", demo.GetType())); } var item = new DemoItem() { Page = demo }; listBoxDemos.Items.Add(item); }
static DemoController() { Items = new List <DemoItem>(); var random = new Random(); for (var x = 0; x < 10; x++) { var item = new DemoItem { Number = random.Next(1, 100) }; item.Text = string.Format("Generated text {0}", item.Number); Items.Add(item); } }
void DeleteItemCore(DemoItem item) { ItemCache.Remove(item.Id); if (item.IsFolder) { List <DemoItem> childItems = ItemCache.Values. Where(cacheItem => !cacheItem.IsRoot && cacheItem.ParentItem.Id == item.Id). ToList(); foreach (DemoItem childItem in childItems) { DeleteItemCore(childItem); } } }
public IHttpActionResult Post([FromBody] DemoItem value) { if (value == null) { return(BadRequest("Item cannot be null.")); } if (Items.Exists(i => i.Id == value.Id)) { return(BadRequest("Id must be unique.")); } Items.Add(value); return(Ok(value)); }
private void AddItem(ListView lv, DemoItem prefab) { var color = new Color() { r = Random.Range(0.0f, 1.0f), g = Random.Range(0.0f, 1.0f), b = Random.Range(0.0f, 1.0f), a = 1.0f, }; var item = Instantiate(prefab); item.SetContent(color.ToString(), color); lv.AddItem(item.gameObject); }
public IHttpActionResult Put(string id, [FromBody] DemoItem value) { if (value == null) { return(BadRequest("Item cannot be null.")); } var item = Items.FirstOrDefault(i => i.Id == value.Id); if (item == null) { return(NotFound()); } item.Number = value.Number; item.Text = value.Text; return(Ok(item)); }
public IActionResult Update(long id, DemoItem item) { var demo = _context.DemoItems.Find(id); if (demo == null) { return(NotFound()); } demo.IsComplete = item.IsComplete; demo.Name = item.Name; _context.DemoItems.Update(demo); _context.SaveChanges(); return(NoContent()); }
public override int GetFileSize(Item fileItem) { DemoItem item = fileItem as DemoItem; if (item.Content != null) { DemoBinaryContent content = item.Content as DemoBinaryContent; if (content.IsLoaded) { string filePath = PrepareContentFilePath(content); lock (this.demoDataLocker) { FileInfo file = new FileInfo(filePath); return((int)file.Length); } } return(SourceDataService.GetFileSize(fileItem)); } return(0); }
public async void PushPage(object viewModel) { Page page = null; DemoItem item = viewModel as DemoItem; if (!demoPagePushed && item != null && item.Module != null && item.Module.IsSubclassOf(typeof(Page))) { demoPagePushed = true; page = (Page)Activator.CreateInstance(item.Module); page.Title = item.PageTitle; } if (page != null) { page.Disappearing += Page_Disappearing; await navigator.PushAsync(page); } }
public async Task <Page> PushPage(object viewModel) { Page page = null; DemoItem item = viewModel as DemoItem; if (!demoPagePushed && item != null && item.Module != null && item.Module.IsSubclassOf(typeof(Page)) ) { demoPagePushed = true; page = (Page)Activator.CreateInstance(item.Module); page.Title = item.PageTitle; } if (page != null) { await PushAsync(page); } return(await Task.FromResult(page)); }
void Awake() { this._itemList = new List <DemoItem>(); GameObject objectItem = null; DemoItem demoItem = null; for (int index = 0; index < 500; index++) { objectItem = new GameObject(); objectItem.name = "item_" + index; demoItem = objectItem.AddComponent <DemoItem>(); demoItem.index = index; this._itemList.Add(demoItem); } this.StartCoroutine(this.AwakeEnumerator()); }
public void Start() { Console.WriteLine("=============Union Demo============"); // initialize datas uint[] ids = createIDs(10); string idstr = ids[0].ToString(); for (int i = 1; i < ids.Length; i++) { idstr += " " + ids[i].ToString(); } // add KeyedList <uint, DemoItem> list = new KeyedList <uint, DemoItem>(); KeyedList <uint, DemoItem> list1 = new KeyedList <uint, DemoItem>(); KeyedList <uint, DemoItem> list2 = new KeyedList <uint, DemoItem>(); for (int i = 0; i < ids.Length; i++) { var item = new DemoItem(ids[i], $"Item_{ids[i]}"); if (i < ids.Length / 2) { list1.Add(item); } else { list2.Add(item); } } Console.WriteLine("List1:"); print(list1); Console.WriteLine("List2:"); print(list2); Console.WriteLine("After Union"); list = KeyedList <uint, DemoItem> .Union(list1, list2); print(list); }
public async Task <Page> PushPage(object viewModel) { Page page = null; DemoItem item = viewModel as DemoItem; if (!this.demoPagePushed && item != null && item.Module != null && item.Module.IsSubclassOf(typeof(Page)) ) { ErrorDialogPage errorDialogPage = this.navigator.CurrentPage as ErrorDialogPage; try { page = (Page)Activator.CreateInstance(item.Module); page.Title = item.PageTitle; if (page != null) { this.demoPagePushed = true; await PushAsync(page); } } catch (Exception e) { #if DEBUG throw e; #else if (errorDialogPage != null) { errorDialogPage.ShowError(e); } else { throw e; } #endif } } return(await Task.FromResult(page)); }
public override void AddItem(Item item) { DemoItem demoItem = new DemoItem(this) { Name = item.Name, IsFolder = item.IsFolder, Owner = item.Owner, OwnerId = item.Owner == null ? (long?)null : item.Owner.Id, ParentItem = item.ParentItem, ParentItemId = item.ParentItem == null ? (long?)null : item.ParentItem.Id, Content = item.Content, ContentId = item.Content == null ? (long?)null : item.Content.Id, CreationTime = item.CreationTime, LastAccessTime = item.LastAccessTime, LastWriteTime = item.LastWriteTime }; lock (this.itemCacheLocker) { MaxItemId++; demoItem.Id = MaxItemId; ItemCache.Add(demoItem.Id, demoItem); } item.Id = demoItem.Id; }
private static void WriteDemoItem(DemoItem item, TextWriter writer) { writer.WriteLine("\"{0}\",{1},\"{2}\"", item.Id, item.Number, item.Text); }
private void OnClickDemoItem(DemoItem arg0) { Debug.LogFormat("移除id为 :{0}的条目", arg0.Id); creater.RemoveItem(arg0); }