public override void LoadContent() { base.LoadContent(); Sprite buttonSprite = Resources.GetSprite("button_idle"); Sprite[] buttonSpriteTab = new Sprite[] { buttonSprite, Resources.GetSprite("button_over"), Resources.GetSprite("button_pressed") }; font = Manager.Game.Content.Load <SpriteFont>("Fonts/Hud"); panel = new Panel(this, new Rectangle(0, 0, Manager.Width, Manager.Height), buttonSprite); submitButton = new Button(this, new Rectangle(0, 60, 100, 20), buttonSpriteTab) { Text = "Submit" }; panel.AddControl("submitButton", submitButton); addTileButton = new Button(this, new Rectangle(110, 60, 100, 20), buttonSpriteTab) { Text = "Add Tile" }; panel.AddControl("addSpriteButton", addTileButton); panel.AddControl("tileNameLabel", new TextBlock(this, new Vector2(0, 0), "Name :")); tileName = new TextBox(this, new Rectangle(100, 0, 140, 20), buttonSpriteTab); panel.AddControl("tileName", tileName); panel.AddControl("tileTypeLabel", new TextBlock(this, new Vector2(0, 25), "Type :")); tileType = new ListButton(this, new Rectangle(100, 25, 140, 20), buttonSprite, Tile.GetTileTypes().ToList()); panel.AddControl("tileType", tileType); panel.Pading = 10; Resize(Manager.Game.Viewport.Width, Manager.Game.Viewport.Height); }
void Page_Selected(ListButton lb) { if (lb.DataObject != null) { var info = (IConfigurationInfo)lb.DataObject; var page = ConfigurationPages.Find(x => x.Title == info.Title); if (page == null) { page = CreatePage(info); page.SendData += page_SendData; page.SettingChanged += page_SettingChanged; page.GetSentData(GetProbeHeader()); page.GetSentData(GetProbeDataItems()); page.GetSentData(CreateCurrentUserEventData()); ConfigurationPages.Add(page); } LoadPage(page); foreach (ListButton olb in PageList.ToList()) { if (olb != lb) { olb.IsSelected = false; } } lb.IsSelected = true; CurrentPage = page; } }
public CustomCell () { var label1 = new Label { Text = "Label 1", Font = Font.SystemFontOfSize(NamedSize.Small, FontAttributes.Bold) }; label1.SetBinding(Label.TextProperty, new Binding(".")); var label2 = new Label { Text = "Label 2", Font = Font.SystemFontOfSize(NamedSize.Small) }; var button = new ListButton { Text = "X", BackgroundColor = Color.Gray, HorizontalOptions = LayoutOptions.EndAndExpand }; button.SetBinding(Button.CommandParameterProperty, new Binding(".")); button.Clicked += (sender, e) => { var b = (Button)sender; var t = b.CommandParameter; ((ContentPage)((ListView)((StackLayout)b.ParentView).ParentView).ParentView).DisplayAlert("Clicked", t + " button was clicked", "OK"); Debug.WriteLine("clicked" + t); }; View = new StackLayout { Orientation = StackOrientation.Horizontal, HorizontalOptions = LayoutOptions.StartAndExpand, Padding = new Thickness (15, 5, 5, 15), Children = { new StackLayout { Orientation = StackOrientation.Vertical, Children = { label1, label2 } }, button } }; }
public void Plugins_Load(PluginConfiguration config) { if (Plugins != null) { if (!enabledPlugins.Contains(config)) { IClientPlugin plugin = Plugins.Find(x => x.Title.ToUpper() == config.Name.ToUpper()); if (plugin != null) { try { plugin.SubCategories = config.SubCategories; plugin.SendData += Plugin_SendData; plugin.Initialize(); } catch { } var bt = new ListButton(); if (plugin.Image != null) { bt.Image = new BitmapImage(plugin.Image); } bt.Text = plugin.Title; bt.Selected += PageSelected; bt.DataObject = plugin; Pages.Add(bt); SortPageList(); enabledPlugins.Add(config); } } } }
void ReleaseDesignerOutlets() { if (ImageView != null) { ImageView.Dispose(); ImageView = null; } if (ListButton != null) { ListButton.Dispose(); ListButton = null; } if (SelectButton != null) { SelectButton.Dispose(); SelectButton = null; } if (UploadButton != null) { UploadButton.Dispose(); UploadButton = null; } }
public void RecruitWithButton(ListButton lb) { hangerManager.modifiedRequisition += orderTotal; if (!lb.chosen) { lb.transform.SetParent(acceptedGrid.transform); orderTotal += perRecruitCost; } else { lb.transform.SetParent(applicantGrid.transform); orderTotal -= perRecruitCost; } hangerManager.modifiedRequisition -= orderTotal; requisitionText.text = (hangerManager.modifiedRequisition + orderTotal).ToString(); orderText.text = "-" + orderTotal.ToString(); remainingText.text = hangerManager.modifiedRequisition.ToString(); lb.chosen = !lb.chosen; applicantsChosen [lb.index] = lb.chosen; GameObject myEventSystem = GameObject.Find("EventSystem"); myEventSystem.GetComponent <UnityEngine.EventSystems.EventSystem>().SetSelectedGameObject(null); }
void AddPageButton(IConfigurationInfo info) { var bt = new ListButton(); bt.Text = info.Title; if (info.Image != null) { bt.Image = new BitmapImage(info.Image); } else { bt.Image = new BitmapImage(new Uri("pack://application:,,,/TrakHound_Dashboard.Pages.DeviceManager;component/Resources/Plug_01.png")); } bt.Selected += Page_Selected; bt.DataObject = info; if (info.Title == "Description") { Page_Selected(bt); } PageList.Add(bt); PageList.Sort(); }
private void UserControl_Loaded(object sender, RoutedEventArgs e) { int selectedPage = Properties.Settings.Default.DashboardSelectedPage; if (Pages.Count > selectedPage) { ListButton lb = Pages[selectedPage]; SelectPage(lb); } }
private void AddButtons() { foreach (var item in items) { GameObject newButton = buttonObjectPool.GetObject(); newButton.transform.SetParent(contentPanel); ListButton button = newButton.GetComponent <ListButton>(); button.Setup(item, this); } }
public static Attachment PrepareCardWithAttachment(ExpenseReport expenseReport, Employee employee, bool isManagerCard = false, bool isAdminCard = false) { var card = new ListCard(); card.content = new Content(); var list = new List <Item>(); card.content.title = "Uploaded Expenses"; foreach (var exp in expenseReport.ExpenseItems) { Item item = new Item(); item.title = exp.ReportName; item.subtitle = "Total Amount: Rs." + exp.TotalAmount; item.type = "resultItem"; item.icon = ConfigurationManager.AppSettings["BaseUri"] + "/Images/Expense.PNG"; var url = "pendingdates"; //item.tap = new Tap() //{ // type = "invoke", // title = item.id, // value = "{ \"type\": \"task/fetch\", \"data\": \"" + url + "\"}" //}; list.Add(item); } if (isManagerCard) { var approve = new ListButton() { title = "Approve", type = "messageBack", value = "{ \"type\": \"ApproveReport\", \"reportId\": \"" + expenseReport.Id + "\", \"employeeId\": \"" + employee.EmailId + "\"}" }; var reject = new ListButton() { title = "Reject", type = "messageBack", value = "{ \"type\": \"RejectReport\", \"reportId\": \"" + expenseReport.Id + "\", \"employeeId\": \"" + employee.EmailId + "\"}" }; var buttonLists = new List <ListButton>() { approve, reject }; card.content.buttons = buttonLists.ToArray(); card.content.title = employee.DisplayName + " has uploaded " + expenseReport.ExpenseItems.Count() + " bills"; } if (isAdminCard) { card.content.title = employee.DisplayName + " has uploaded " + expenseReport.ExpenseItems.Count() + " bills. Approved by manager"; } card.content.items = list.ToArray(); Attachment attachment = new Attachment(); attachment.ContentType = card.contentType; attachment.Content = card.content; return(attachment); }
public TipSelectCell() { var check = new Checkbox { Scale = 1.2 }; check.SetBinding(Checkbox.CheckedProperty, "Enabled"); var text = new Label { YAlign = TextAlignment.Center, Style = StyleKit.AutoDarkLabelStyles.Body }; text.SetBinding(Label.TextProperty, "Title"); var info = new ListButton { Text = "info", FontSize = 18 }; info.Clicked += (sender, args) => { var parent = Parent; while (!(parent is Page)) { parent = parent.Parent; } ((Page)parent).Navigation.PushAsync(new TipInfoPage((Tip)BindingContext)); }; var layout = new Grid { ColumnDefinitions = { new ColumnDefinition { Width = new GridLength(1, GridUnitType.Star) }, new ColumnDefinition { Width = GridLength.Auto } } }; layout.Children.Add(new StackLayout { Orientation = StackOrientation.Horizontal, Padding = 10, Spacing = 15, Children = { check, text } }, 0, 0); layout.Children.Add(info, 1, 0); View = layout; }
public IEnumerator setGames() { yield return(new WaitForSeconds(2)); for (int c = 0; c < gameslist.transform.childCount; c++) { GameObject.Destroy(gameslist.transform.GetChild(c).gameObject); } currentGames = sm.currentGames; List <Button> buttons = new List <Button>(); for (int i = 0; i < currentGames.Count; i++) { ServerManager.gameInfo game = currentGames[i]; Debug.Log("creating button"); GameObject button = Instantiate(listButtonPrefab, gameslist.transform); ListButton lstbtn = button.GetComponent <ListButton>(); lstbtn.lobby_name.text = game.game_name + "'s game"; //lstbtn.map_name.text = "Dust 2"; button.GetComponent <RectTransform>().anchoredPosition = new Vector2(8.5f, 280 - (i * 150)); lstbtn.index = i; buttons.Add(button.GetComponent <Button>()); } //for each button for (int b = 0; b < buttons.Count; b++) { int temp = b; buttons[b].onClick.AddListener(() => { buttonClicked = temp; }); } /* * currentGames = sm.currentGames; * * gameslist.ClearOptions(); * List<string> options = new List<string>(); * * for(int i = 0; i < currentGames.Count; i++) { * string str = currentGames[i].game_name; * options.Add(str); * * * } * * gameslist.AddOptions(options); */ }
private void Adapter_Selected(ListButton bt) { foreach (var obt in Adapters) { if (obt != bt) { obt.IsSelected = false; } } bt.IsSelected = true; DeviceInfo = new DeviceInfo(); DeviceInfo.Adapter = bt.Text; DeviceInfo.AdapterPath = bt.DataObject.ToString(); }
public CustomCell() { var label1 = new Label { Text = "Label 1", FontSize = Device.GetNamedSize(NamedSize.Small, typeof(Label)), FontAttributes = FontAttributes.Bold }; label1.SetBinding(Label.TextProperty, new Binding(".")); var label2 = new Label { Text = "Label 2", FontSize = Device.GetNamedSize(NamedSize.Small, typeof(Label)) }; var button = new ListButton { Text = "X", BackgroundColor = Color.Gray, HorizontalOptions = LayoutOptions.EndAndExpand }; button.SetBinding(Button.CommandParameterProperty, new Binding(".")); button.Clicked += (sender, e) => { var b = (Button)sender; var t = b.CommandParameter; ((ContentPage)((ListView)((StackLayout)b.Parent).Parent).Parent).DisplayAlert("Clicked", t + " button was clicked", "OK"); Debug.WriteLine("clicked" + t); }; View = new StackLayout { Orientation = StackOrientation.Horizontal, HorizontalOptions = LayoutOptions.StartAndExpand, Padding = new Thickness(15, 5, 5, 15), Children = { new StackLayout { Orientation = StackOrientation.Vertical, Children = { label1, label2 } }, button } }; }
public void HoverDeployButton(ListButton lb) { //fill everything in statsParent.transform.localScale = new Vector3(1.8f, 1.8f, 1); deployName.text = crew[lb.index].name; deployAge.text = crew [lb.index].age.ToString(); deploySex.text = crew [lb.index].sex; gradeTexts [0].text = grades[crew [lb.index].combat]; gradeTexts [1].text = grades[crew [lb.index].psychology]; gradeTexts [2].text = grades[crew [lb.index].management]; gradeTexts [3].text = grades[crew [lb.index].computers]; gradeTexts [4].text = grades[crew [lb.index].medicine]; gradeTexts [5].text = grades[crew [lb.index].mechanics]; }
// Start is called before the first frame update public void OnEnable() { Debug.Log("當物件為可用或是被調用狀態時此函數被調用"); GameObject Easy = GameObject.Find("Easy"); ListButton setEasy = (ListButton)Easy.GetComponent(typeof(ListButton)); setEasy.isPresence(); GameObject Normal = GameObject.Find("Normal"); ListButton setNormal = (ListButton)Easy.GetComponent(typeof(ListButton)); setNormal.isPresence(); GameObject Hard = GameObject.Find("Hard"); ListButton setHard = (ListButton)Easy.GetComponent(typeof(ListButton)); setHard.isPresence(); }
public void HoverRecruitButton(ListButton lb) { //fill everything in statsParent.transform.localScale = new Vector3(2, 2, 1); recruitName.text = applicants[lb.index].name; recruitAge.text = applicants [lb.index].age.ToString(); recruitSex.text = applicants [lb.index].sex; gradeTexts [0].text = grades[applicants [lb.index].combat]; gradeTexts [1].text = grades[applicants [lb.index].psychology]; gradeTexts [2].text = grades[applicants [lb.index].management]; gradeTexts [3].text = grades[applicants [lb.index].computers]; gradeTexts [4].text = grades[applicants [lb.index].medicine]; gradeTexts [5].text = grades[applicants [lb.index].mechanics]; }
public override void ViewDidLoad() { try { base.ViewDidLoad(); LogoText.Text = LangEnglish.LogoText; LoginEmailText.Text = LangEnglish.LoginEmail; LoginPasswordText.Text = LangEnglish.LoginPassword; LoginDone.SetTitle(LangEnglish.LoginDone, UIControlState.Normal); ResetPassword.SetTitle(LangEnglish.ResetPassword, UIControlState.Normal); ResetEmailText.Text = LangEnglish.ResetEmail; ResetSendButton.SetTitle(LangEnglish.ResetSend, UIControlState.Normal); RegisterButton.SetTitle(LangEnglish.RegisterButton, UIControlState.Normal); ListButton.SetTitle(LangEnglish.ListButton, UIControlState.Normal); LoginDone.Layer.MasksToBounds = true; ResetPassword.Layer.MasksToBounds = true; ResetSendButton.Layer.MasksToBounds = true; RegisterButton.Layer.MasksToBounds = true; ListButton.Layer.MasksToBounds = true; c.CollapseY(ResetSection); resetSectionVisible = false; c.AddViews(Snackbar, Snackbar.SnackText, Snackbar.SnackButton); LoginPassword.Delegate = this; LoginDone.TouchUpInside += LoginDone_Click; ResetPassword.TouchUpInside += ResetPassword_Click; ResetEmail.Delegate = this; ResetSendButton.TouchUpInside += ResetSendButton_Click; RegisterButton.TouchUpInside += RegisterButton_Click; ListButton.TouchUpInside += ListButton_Click; RoundBottom_Base = RoundBottom; Snackbar_Base = Snackbar; BottomConstraint_Base = BottomConstraint; SnackTopConstraint_Base = SnackTopConstraint; SnackBottomConstraint_Base = SnackBottomConstraint; } catch (Exception ex) { c.ReportErrorSilent(ex.Message + Environment.NewLine + ex.StackTrace); } }
private void ListButton_Selected(ListButton LB) { foreach (ListButton oLB in Pages) { if (oLB == LB) { oLB.IsSelected = true; } else { oLB.IsSelected = false; } } var page = LB.DataObject as IPage; PageContent = page; }
public void ClickDeploymentButton(ListButton lb) { if (!lb.chosen) { if (deployed < 3) { lb.transform.SetParent(deployGrid.transform); deployed += 1; lb.chosen = !lb.chosen; deploymentsChosen [lb.index] = lb.chosen; } else { //flash error or something } GameObject myEventSystem = GameObject.Find("EventSystem"); myEventSystem.GetComponent <UnityEngine.EventSystems.EventSystem> ().SetSelectedGameObject(null); } else { lb.transform.SetParent(holdingGrid.transform); deployed -= 1; lb.chosen = !lb.chosen; deploymentsChosen [lb.index] = lb.chosen; GameObject myEventSystem = GameObject.Find("EventSystem"); myEventSystem.GetComponent <UnityEngine.EventSystems.EventSystem> ().SetSelectedGameObject(null); } for (int i = 0; i < deployed; i++) { crewSprites [i].transform.localScale = new Vector3(0, 0, 1); } for (int i = 0; i < deployed; i++) { crewSprites [i].transform.localScale = new Vector3(1.5f, 1.5f, 1); } Debug.Log(deployed); }
private void calcsize() { double W = background.ActualWidth; double Sep = W / Parent.Children.Count; for (int i = 0; Parent.Children.Count > i; i++) { ListButton Item = Parent.Children[i] as ListButton; if (Item != null) { Item.HorizontalAlignment = HorizontalAlignment.Left; Item.VerticalAlignment = VerticalAlignment.Top; Item.Width = Sep; Item.Height = background.ActualHeight; Item.Margin = new Thickness(Sep * i, 0, 0, 0); } } }
private void pagemanager_Loaded(object sender, RoutedEventArgs e) { if (Pages.Count > 0 && PageContent == null) { ListButton lb = (ListButton)Pages[0]; foreach (ListButton oLB in Pages) { if (oLB == lb) { oLB.IsSelected = true; } else { oLB.IsSelected = false; } } var page = lb.DataObject as IPage; PageContent = page; } }
private void SelectPage(ListButton lb) { foreach (var olb in Pages) { if (olb == lb) { olb.IsSelected = true; } else { olb.IsSelected = false; } } foreach (var category in SubCategories) { var config = category.PluginConfigurations.Find(x => GetPluginName(x.Name) == GetPluginName(lb.Text)); if (config != null) { currentPage = config; break; } } // Set Page as PageContent PageContent = lb.DataObject as UserControl; // Save selected page int index = Pages.ToList().FindIndex(x => x == lb); if (index >= 0) { Properties.Settings.Default.DashboardSelectedPage = index; Properties.Settings.Default.Save(); } // Load Saved Zoom Level ZoomLevel = MainWindow.LoadSavedPageZoomValue(lb.DataObject as IPage); }
public void AddPage(IPage page) { var lb = new ListButton(); // Bind ListButton.Text to PageName property var pageImageBinding = new Binding(); pageImageBinding.Source = page; pageImageBinding.Path = new PropertyPath("Image"); BindingOperations.SetBinding(lb, ListButton.ImageProperty, pageImageBinding); // Bind ListButton.Text to PageName property var pageTitleBinding = new Binding(); pageTitleBinding.Source = page; pageTitleBinding.Path = new PropertyPath("Title"); BindingOperations.SetBinding(lb, ListButton.TextProperty, pageTitleBinding); lb.Selected += ListButton_Selected; lb.DataObject = page; Pages.Add(lb); }
private void ReadAdapterFiles() { string path = Paths.ADAPTER_TEMPLATES; if (Directory.Exists(path)) { var files = Directory.GetFiles(path, Files.ADAPTER_INI, SearchOption.AllDirectories); if (files != null) { foreach (var file in files) { string type = Directory.GetParent(file).Name; var info = AdapterInfo.Read(file); var bt = new ListButton(); bt.Selected += Adapter_Selected; bt.Text = type; bt.DataObject = Directory.GetParent(file).FullName; Adapters.Add(bt); } } } }
public void Plugins_Unload(PluginConfiguration config) { if (config != null) { if (!config.Enabled) { ListButton lb = Pages.ToList().Find(x => GetPluginName(x.Text) == GetPluginName(config.Name)); if (lb != null) { Pages.Remove(lb); } if (config == currentPage) { PageContent = null; } if (enabledPlugins.Contains(config)) { enabledPlugins.Remove(config); } } } }
// Use this for initialization void Start() { //update itemList's transform according to canvas first //gameObject.GetComponent<RectTransform>().position = gameObject.transform.parent.GetComponent<RectTransform>().position // +new Vector3(-30f,0,0); //get parent canvas's width and height to arrange the menu position GameObject parent = GameObject.Find("furniture"); RectTransform canvas = gameObject.transform.parent.GetComponent <RectTransform>(); canvasWidth = canvas.rect.width; canvasHeight = canvas.rect.height; RectTransform menu = gameObject.GetComponent <RectTransform>(); float posTopLeftX = -canvasWidth / 2; float posTopLeftY = canvasHeight / 2; //Debug.Log(posTopLeftX); //Debug.Log(posTopLeftY); //calculate column count int maxColumnCnt = Mathf.FloorToInt(canvasWidth / (itemWidth + 2 * interval)); //to store the current position of each item int row = 0; int column = 0; //generate and align the items for (var i = 0; i < items.Length; i++) { //新建子物品,命名 GameObject tmpItem = new GameObject(items[i].name, typeof(Button)); ListButton listButton = new ListButton(items[i]); tmpItem.GetComponent <Button>().onClick.AddListener(listButton.ListButtonClick); parent.GetComponent <Button>().onClick.AddListener(listButton.DeleteButton); tmpItem.transform.SetParent(gameObject.transform); //设置物品名称的text GameObject tmpText = new GameObject("Name", typeof(Text)); tmpText.GetComponent <Text>().text = items[i].name; tmpText.GetComponent <Text>().font = m_Font; tmpText.GetComponent <Text>().alignment = TextAnchor.MiddleCenter; tmpText.GetComponent <RectTransform>().sizeDelta = new Vector2(itemWidth + interval, 2 * interval); tmpText.transform.SetParent(tmpItem.transform); //给子物品赋封面图 //Texture2D t = AssetPreview.GetAssetPreview(items[i]); //Sprite temp = Sprite.Create(t, new Rect(0, 0,itemWidth, itemHeight), new Vector2(0.5f, 0.5f)); GameObject tmpImg = new GameObject("Thumbnail", typeof(RawImage)); tmpImg.GetComponent <RawImage>().texture = t[i]; tmpImg.GetComponent <RectTransform>().sizeDelta = new Vector2(itemWidth, itemHeight); tmpImg.GetComponent <RectTransform>().pivot = new Vector2(0.5f, 0.5f); tmpImg.transform.SetParent(tmpItem.transform); //TODO 排版?改变transform tmpItem.transform.position = gameObject.transform.position + new Vector3((float)(posTopLeftX + (column + 0.5) * (itemWidth + 2 * interval) + interval), (float)(posTopLeftY - (0.5 + row) * (itemHeight + 2 * interval) - interval), 0); //Debug.Log(tmpItem.transform.position); tmpText.transform.position = tmpItem.transform.position + new Vector3(0f, (float)-0.5 * (itemHeight + 2 * interval), 0f); column++; if (column >= maxColumnCnt) { row++; column = 0; } } }
public void AddTextButton(string text, string value) { Button = new ListButton().ToTextButton(text, value); }
public ListModel() { BottomButton = null; Items = new List <Item>(); HighlightHeader = false; }
public void FurnButtonClick(ListButton button) { clickedButton = button; }
private void PageSelected(ListButton lb) { StopSlideshow(); SelectPage(lb); }
void ButtonClick() { if(Mathf.Abs(scrollOffset - oldScrollPositionY) > 15){ clickedButton = null; return; } if(clickedButton is CategoryButton){ FurnitureCollection.CategoryString = ((CategoryButton)clickedButton).label; CategoryClick(); } else { if(!cartButton.toggled && SpawnFurniture != null){ SpawnFurniture(((FurnitureButton)clickedButton).furniture); visible = false; } else if(cartButton.toggled && ShowInfo != null) ShowInfo(((FurnitureButton)clickedButton).furniture); } updateButtons(); clickedButton = null; }
public void Insert(int Index, ListButton Button) { Parent.Children.Insert(Index, Button); calcsize(); }