//增加或者减少Order的手数 private void btn_ChangeOrderQty(object sender, RoutedEventArgs e) { Button btn = (Button)sender; Order order = (Order)btn.DataContext; StackPanel panel = (StackPanel)btn.Parent; TextBox tbx = (TextBox)panel.FindName("tbxQty"); if (tbx != null) { double Qty = order.Qty; if (btn.Name == "btnAddOrderQty") { Qty++; } else { if (Qty > 0) { Qty--; } } order.Qty = Qty; tbx.Text = Qty.ToString(); } e.Handled = true; }
/// <summary> /// 改变价格条件单的限价 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void PCOChangeLimitPrice(object sender, RoutedEventArgs e) { e.Handled = true; Button btn = (Button)sender; PriceConditionOrderField cof = (PriceConditionOrderField)btn.DataContext; InstrumentField instrument; this._tradeApi.DictInstrumentField.TryGetValue(cof.InstrumentID, out instrument); double tick = instrument.PriceTick; double Price = 0; StackPanel panel = (StackPanel)btn.Parent; TextBox tbx = (TextBox)panel.FindName("tbxLimitPrice"); if (tbx != null) { double.TryParse(tbx.Text, out Price); if (btn.Name == "btnIncLimitPrice") { Price += tick; } else if (btn.Name == "btnDecLimitPrice") { if (Price > 0) { Price -= tick; } } cof.LimitPrice = Price; tbx.Text = Price.ToString(); } }
//button for sending comments private async void btnSend_Click(object sender, RoutedEventArgs e) { Button btnName = sender as Button; //get the name of the button clicked string name = btnName.Name; int id = Convert.ToInt32(btnName.Tag.ToString()); //var obj=spReply.FindName("breachReply0"); //find the parent element of the button which is stackpanel var obj1 = btnName.Parent; if (obj1 is StackPanel) { StackPanel sp = (StackPanel)obj1; //from the stackpanel , get the textbox from its id var obj2 = sp.FindName("LastComment" + id); TextBox txt = (TextBox)obj2; //get the text of the element string commentsText = txt.Text; if (commentsText.Equals("")) { MessageBox.Show("Please enter comments"); } else { int ret = await objAPIBusinessLayer.PostReply(discussionId.ToString(), userId.ToString(), commentsText, cookie); } } }
public void When_EarlyItems() { var style = new Style(typeof(Windows.UI.Xaml.Controls.ItemsControl)) { Setters = { new Setter <ItemsControl>("Template", t => t.Template = Funcs.Create(() => new ItemsPresenter() ) ) } }; var panel = new StackPanel(); var SUT = new ItemsControl() { Style = style, ItemsPanel = new ItemsPanelTemplate(() => panel), Items = { new Border { Name = "b1" } } }; new Grid().Children.Add(SUT); // This is enough for now, but the `SUT` should be in the visual tree for its template to get applied SUT.ApplyTemplate(); // Search on the panel for now, as the name lookup is not properly // aligned on net46. Assert.IsNotNull(panel.FindName("b1")); }
//增加或者减少Price private void btn_ChangeOrderPrice(object sender, RoutedEventArgs e) { Button btn = (Button)sender; Order order = (Order)btn.DataContext; double tick = Body.instruments[order.InstrumentID].PriceTick; double Price = 0; StackPanel panel = (StackPanel)btn.Parent; TextBox tbx = (TextBox)panel.FindName("tbxPrice"); if (tbx != null) { double.TryParse(tbx.Text, out Price); //Instrument instrument = btn.TemplatedParent. if (btn.Name == "btnIncOrderPrice") { Price += tick; } else { if (Price > 0) { Price -= tick; } } order.Price = Price; tbx.Text = Price.ToString(); } e.Handled = true; }
private void btnSubmit_Tapped(object sender, RoutedEventArgs e) { Ellipse el; // peg_0_0 StackPanel sp = (StackPanel)spAllTurns.FindName("spTurn" + _turnNumber.ToString()); Ellipse elTest = new Ellipse(); elTest.Fill = new SolidColorBrush(Colors.Transparent); // check for complete row for (int i = 0; i < 3; i++) { el = (Ellipse)sp.FindName("peg_" + _turnNumber.ToString() + "_" + i.ToString()); if (el.Fill.Equals(elTest.Fill)) { tblTest.Text = el.Name + " - Invalid Move"; return; } } // check the combination // disable the current turn stack panel _turnNumber++; }
private async Task MediumTileImageAsync(string inputMarkupFilename, string outputImageFilename, Size size) { StorageFile markupFile = await StorageFile.GetFileFromApplicationUriAsync(new Uri("ms-appx:///Assets/" + inputMarkupFilename)); var markupContent = await FileIO.ReadTextAsync(markupFile); Border border = (Border)XamlReader.Load(markupContent); StackPanel stackPanel = (StackPanel)border.Child; TextBlock timeTextBlock = (TextBlock)stackPanel.FindName("TimeTextBlock"); timeTextBlock.Text = DateTime.Now.ToString("HH:mm:ss"); RenderTargetBitmap renderBitmap = new RenderTargetBitmap(); await renderBitmap.RenderAsync(border, (int)size.Width, (int)size.Height); var buffer = await renderBitmap.GetPixelsAsync(); DataReader dataReader = DataReader.FromBuffer(buffer); byte[] data = new byte[buffer.Length]; dataReader.ReadBytes(data); var outputFile = await ApplicationData.Current.LocalFolder.CreateFileAsync(outputImageFilename, CreationCollisionOption.ReplaceExisting); var outputFileStream = await outputFile.OpenAsync(FileAccessMode.ReadWrite); var encodetBits = await BitmapEncoder.CreateAsync(BitmapEncoder.PngEncoderId, outputFileStream); encodetBits.SetPixelData(BitmapPixelFormat.Rgba8, BitmapAlphaMode.Premultiplied, (uint)renderBitmap.PixelWidth, (uint)renderBitmap.PixelHeight, 96, 96, data); await encodetBits.FlushAsync(); }
//增加或者减少Order的手数 private void btn_ChangeOrderQty(object sender, RoutedEventArgs e) { e.Handled = true; Button btn = (Button)sender; ConditionOrderField cof = btn.DataContext as ConditionOrderField; StackPanel panel = (StackPanel)btn.Parent; TextBox tbx = (TextBox)panel.FindName("tbxQty"); if (tbx != null) { int Qty = cof.VolumeTotalOriginal; if (btn.Name == "btnAddOrderQty") { Qty++; } else { if (Qty > 0) { Qty--; } } cof.VolumeTotalOriginal = Qty; tbx.Text = Qty.ToString(); } }
//改变目标价 private void btn_ChangeOrderTargetPrice(object sender, RoutedEventArgs e) { e.Handled = true; Button btn = (Button)sender; ConditionOrderField cof = (ConditionOrderField)btn.DataContext; InstrumentField instrument; Body.trdApi.DicInstrumentField.TryGetValue(cof.InstrumentID, out instrument); double tick = instrument.PriceTick; double Price = 0; StackPanel panel = (StackPanel)btn.Parent; TextBox tbx = (TextBox)panel.FindName("tbxTargetPrice"); if (tbx != null) { double.TryParse(tbx.Text, out Price); //Instrument instrument = btn.TemplatedParent. if (btn.Name == "btnIncOrderTargetPrice") { Price += tick; } else if (btn.Name == "btnDecOrderTargetPrice") { if (Price > 0) { Price -= tick; } } cof.TargetPrice = Price; tbx.Text = Price.ToString(); } }
private void Item_ItemPrepared(object sender, ItemPreparedEventArgs e) { StackPanel stackPanel = (FindVisualChild <StackPanel>(sender as C1TreeViewItem) as StackPanel); Path path = stackPanel.FindName("CollapsedIcon") as Path; if (path.Visibility == Visibility.Collapsed) { path.Visibility = Visibility.Visible; (stackPanel.FindName("ExpandedIcon") as Path).Visibility = Visibility.Collapsed; } else { path.Visibility = Visibility.Collapsed; (stackPanel.FindName("ExpandedIcon") as Path).Visibility = Visibility.Visible; } }
private void Lvit_tapped(object sender, Windows.UI.Xaml.Input.DoubleTappedRoutedEventArgs e) { StackPanel sp = sender as StackPanel; TextBlock tb = sp.FindName("ChatLine") as TextBlock; ReadText(tb.Text); }
private void ToggleSortMode(object sender, RoutedEventArgs e) { StackPanel sp = SortModeButton.Content as StackPanel; if (sp == null) { return; } PackIconModern icon = (PackIconModern)sp.FindName("SortButtonIcon"); if (Model.NoteMenuContext.SortMode == "AZ") { Model.NoteMenuContext.SortMode = "ZA"; icon.Kind = PackIconModernKind.SortAlphabeticalDescending; } else if (Model.NoteMenuContext.SortMode == "ZA") { Model.NoteMenuContext.SortMode = "Index"; icon.Kind = PackIconModernKind.SortNumeric; } else if (Model.NoteMenuContext.SortMode == "Index") { Model.NoteMenuContext.SortMode = "AZ"; icon.Kind = PackIconModernKind.SortAlphabeticalAscending; } }
private void Notiz_bearbeiten_Click(object sender, RoutedEventArgs e) { (StackPanel.FindName("tbNotiz") as TextBox).IsEnabled = true; this.Notiz_bearbeiten.Visibility = Visibility.Collapsed; Notiz_Speichern.Visibility = Visibility.Visible; }
public void When_SingleSelectedItem_Event() { var panel = new StackPanel(); var item = new Border { Name = "b1" }; var SUT = new ListViewBase() { Style = null, Template = new ControlTemplate(() => new ItemsPresenter()), ItemsPanel = new ItemsPanelTemplate(() => panel), ItemContainerStyle = BuildBasicContainerStyle(), Items = { item } }; var model = new MyModel { SelectedItem = (object)null }; SUT.SetBinding( Selector.SelectedItemProperty, new Binding() { Path = "SelectedItem", Source = model, Mode = BindingMode.TwoWay } ); SUT.ApplyTemplate(); // Search on the panel for now, as the name lookup is not properly // aligned on net46. Assert.IsNotNull(panel.FindName("b1")); var selectionChanged = 0; SUT.SelectionChanged += (s, e) => { selectionChanged++; Assert.AreEqual(item, SUT.SelectedItem); // In windows, when programmatically changed, the bindings are updated *after* // the event is raised, but *before* when the SelectedItem is changed from the UI. Assert.IsNull(model.SelectedItem); }; SUT.SelectedIndex = 0; Assert.AreEqual(item, model.SelectedItem); Assert.IsNotNull(SUT.SelectedItem); Assert.AreEqual(1, selectionChanged); Assert.AreEqual(1, SUT.SelectedItems.Count); }
public void When_EarlyItems() { var style = new Style(typeof(Windows.UI.Xaml.Controls.ItemsControl)) { Setters = { new Setter <ItemsControl>("Template", t => t.Template = Funcs.Create(() => new ItemsPresenter() ) ) } }; var panel = new StackPanel(); var SUT = new ItemsControl() { Style = style, ItemsPanel = new ItemsPanelTemplate(() => panel), Items = { new Border { Name = "b1" } } }; // Search on the panel for now, as the name lookup is not properly // aligned on net46. Assert.IsNotNull(panel.FindName("b1")); }
public void When_MultiSelectedItem() { var style = new Style(typeof(Windows.UI.Xaml.Controls.ListViewBase)) { Setters = { new Setter <ItemsControl>("Template", t => t.Template = Funcs.Create(() => new ItemsPresenter() ) ) } }; var panel = new StackPanel(); var SUT = new ListViewBase() { Style = style, ItemsPanel = new ItemsPanelTemplate(() => panel), Items = { new Border { Name = "b1" }, new Border { Name = "b2" } } }; // Search on the panel for now, as the name lookup is not properly // aligned on net46. Assert.IsNotNull(panel.FindName("b1")); Assert.IsNotNull(panel.FindName("b2")); SUT.SelectionMode = ListViewSelectionMode.Multiple; SUT.OnItemClicked(0); Assert.AreEqual(1, SUT.SelectedItems.Count); SUT.OnItemClicked(1); Assert.AreEqual(2, SUT.SelectedItems.Count); }
private void CtrlDataGrid_LoadingRowDetails(object sender, DataGridRowDetailsEventArgs e) { StackPanel panel = e.DetailsElement as StackPanel; Grid grid = panel.Children.ElementAt(0) as Grid; DataGrid innerGrid = panel.FindName("ctrUserRow") as DataGrid; //innerGrid.ItemsSource = Globals._usersData["IBAILA"].Actions; }
public Expander NewExpander(string ExpanderName) { Expander newexpander = null; string NoSpaceString = SpaceCleaningString(ExpanderName); //if expander register name exist if (IsElementExist(NoSpaceString)) { stackpanel.Children.Remove((Expander)stackpanel.FindName(NoSpaceString)); stackpanel.UnregisterName(NoSpaceString); // stackpanel.UpdateLayout(); // MessageBox.Show("Expander Replaced"); } try { newexpander = new Expander(); newexpander.Name = NoSpaceString; newexpander.Header = ExpanderName; //newexpander.Template = (ControlTemplate)Application.Current.Resources["ExpaanderControlTemplat"]; newexpander.HeaderTemplate = (DataTemplate)Application.Current.Resources["ExpanderHeaderStyle"]; //newexpander.Foreground = Brushes.Wheat; //newexpander.MouseEnter += new MouseEventHandler(Expander_MouseEnter); //newexpander.MouseLeave += new MouseEventHandler(Expander_MouseLeave); //////////////////////////// ////Register the name of the element so we can search for it lately stackpanel.RegisterName(NoSpaceString, newexpander); } catch (Exception ex) { MessageBox.Show(ex.ToString()); } return(newexpander); }
private void ShowIsMale(ListViewBase sender, ContainerContentChangingEventArgs args) { // 第 4 阶段绘制 // args.Phase.ToString(); // 3 Employee employee = (Employee)args.Item; SelectorItem itemContainer = (SelectorItem)args.ItemContainer; StackPanel templateRoot = (StackPanel)itemContainer.ContentTemplateRoot; Rectangle placeholderRectangle = (Rectangle)templateRoot.FindName("placeholderRectangle"); TextBlock lblIsMale = (TextBlock)templateRoot.FindName("lblIsMale"); // 绘制第 4 阶段的内容 lblIsMale.Text = employee.IsMale.ToString(); lblIsMale.Opacity = 1; // 隐藏自定义占位符 placeholderRectangle.Opacity = 0; }
private void btnListed_Click(object sender, RoutedEventArgs e) { Button btn = (Button)sender; StackPanel parent = (StackPanel)btn.Parent; Label lbl = (Label)parent.FindName("lbListed"); MessageBox.Show(lbl.Tag.ToString()); MessageBox.Show(((PO.ListedPerson)btn.DataContext).Person.Name); }
/// <summary> /// Deals with populating apps in the My-Apps section. /// </summary> /// <param name="sender">Object Sender is a parameter called Sender that contains a reference to the control/object that raised the event.</param> /// <param name="args">ContainerContentChangingEventArgs args is a parameter called e that contains the event data, see the ContainerContentChangingEventArgs MSDN page for more information.</param> private void GridFeaturedApps_ContentChanging(ListViewBase sender, ContainerContentChangingEventArgs args) { args.Handled = true; if (args.Phase != 0) { throw new Exception("Not in phase 0."); } Apps app = (Apps)args.Item; StackPanel templateRoot = (StackPanel)args.ItemContainer.ContentTemplateRoot; TextBlock appName = (TextBlock)templateRoot.FindName("appName"); TextBlock appAuthor = (TextBlock)templateRoot.FindName("appAuthor"); Image appIcon = (Image)templateRoot.FindName("appIcon"); appName.Text = app.Name; appAuthor.Text = app.Author; appIcon.Source = new BitmapImage(new Uri("ms-appx:///Assets/notavailable.png")); args.RegisterUpdateCallback(ShowImage); }
private void BookButton_Click(object sender, RoutedEventArgs e) { Frame parentFrame = Window.Current.Content as Frame; MainPage mp = parentFrame.Content as MainPage; StackPanel grid = mp.Content as StackPanel; Frame my_frame = grid.FindName("myFrame") as Frame; my_frame.Navigate(typeof(AppointmentBookingView), id, new SuppressNavigationTransitionInfo()); }
private void Set(StackPanel panel, bool isBall, int value, double opacity) { var name = $"{(isBall ? "ball" : "mark")}{value}"; var element = (UIElement)panel.FindName(name); if (element != null) { element.Opacity = opacity; } }
private async void GridView_ItemClick(object sender, ItemClickEventArgs e) { Frame parentFrame = Window.Current.Content as Frame; MainPage mp = parentFrame.Content as MainPage; StackPanel grid = mp.Content as StackPanel; Frame my_frame = grid.FindName("myFrame") as Frame; my_frame.Navigate(typeof(HospitalDetailView), (e.ClickedItem as Hospital).ID, new SuppressNavigationTransitionInfo()); }
private void SetItemCompleted(StackPanel parent, ToDoItem item) { if (item == null || parent == null) { return; } var storyboard = AnimationUtils.GetStoryboard(); FrameworkElement completedLine = parent.FindName("CompletedLine") as FrameworkElement; AnimationUtils.SetWidthAnimation(storyboard, completedLine, 400, 0.3); if (mCurrentItemPanel == parent) { FrameworkElement toolbar = parent.FindName("ToolBar") as FrameworkElement; AnimationUtils.SetHeightAnimation(storyboard, toolbar, AnimationUtils.AnimationHeightHide, 0.3); FrameworkElement modifyButton = parent.FindName("ModifyButton") as FrameworkElement; AnimationUtils.SetOpacityAnimation(storyboard, modifyButton, 0, 0.3); mCurrentItemPanel = null; } var storyboard2 = AnimationUtils.GetStoryboard(); FrameworkElement listItem = parent.FindName("ListItem") as FrameworkElement; AnimationUtils.SetTranslateAnimation(storyboard2, parent, 0, Application.Current.Host.Content.ActualHeight, 0.5); AnimationUtils.SetHeightAnimation(storyboard2, listItem, 0, 0.5); item.IsCompleted = true; storyboard.Completed += delegate(object sender, EventArgs e) { storyboard2.Begin(); }; storyboard2.Completed += delegate(object sender, EventArgs e) { App.ViewModel.ChangeCompletedStatus(item, true); }; storyboard.Begin(); }
public void onInsertSuccess(object source, EventArgs args) { Frame parentFrame = Window.Current.Content as Frame; MainPage mp1 = parentFrame.Content as MainPage; StackPanel grid = mp1.Content as StackPanel; Frame my_frame = grid.FindName("myFrame") as Frame; my_frame.Navigate(typeof(AppointmentsDisplayView), new SuppressNavigationTransitionInfo()); }
private void HospList_ItemClick(object sender, ItemClickEventArgs e) { Frame parentFrame = Window.Current.Content as Frame; MainPage mp1 = parentFrame.Content as MainPage; StackPanel grid = mp1.Content as StackPanel; Frame my_frame = grid.FindName("myFrame") as Frame; //my_frame.Navigate(typeof(HospitalDetailView), (e.ClickedItem as HospitalInDoctorDetails).Hosp_ID, // new SuppressNavigationTransitionInfo()); }
private void ShowItemDetails(StackPanel parent) { var title = parent.FindName("ItemTitleText") as TextBlock; title.TextWrapping = TextWrapping.Wrap; var storyboard = AnimationUtils.GetStoryboard(); FrameworkElement toolbar = parent.FindName("ToolBar") as FrameworkElement; AnimationUtils.SetHeightAnimation(storyboard, toolbar, 80, 0.3); AnimationUtils.SetOpacityAnimation(storyboard, toolbar, 1, 0.3); FrameworkElement modifyButton = parent.FindName("ModifyButton") as FrameworkElement; modifyButton.Visibility = Visibility.Visible; AnimationUtils.SetOpacityAnimation(storyboard, modifyButton, 1, 0.3); storyboard.Begin(); }
/// <summary> /// Change window size from original size to maximum size and vice versa. /// </summary> public void AdjustWindowSize(Button sender) { sender.ToolTip = "Maximize"; StackPanel panel = (StackPanel)sender.FindName("stackPanel"); if (thisPage.WindowState == WindowState.Maximized) { thisPage.WindowState = WindowState.Normal; if (panel != null) { Image maximize = (Image)panel.FindName("maximize"); if (maximize != null) { maximize.Visibility = Visibility.Visible; } Image normalSize = (Image)panel.FindName("normalSize"); if (normalSize != null) { normalSize.Visibility = Visibility.Collapsed; } } } else { thisPage.WindowState = WindowState.Maximized; sender.ToolTip = "Normal Size"; if (panel != null) { Image maximize = (Image)panel.FindName("maximize"); if (maximize != null) { maximize.Visibility = Visibility.Collapsed; } Image normalSize = (Image)panel.FindName("normalSize"); if (normalSize != null) { normalSize.Visibility = Visibility.Visible; } } } }
/// <summary> /// Deals with populating images(app icons) in the AppsPage. /// </summary> /// <param name="sender">Object Sender is a parameter called Sender that contains a reference to the control/object that raised the event.</param> /// <param name="args">ContainerContentChangingEventArgs args is a parameter called e that contains the event data, see the ContainerContentChangingEventArgs MSDN page for more information.</param> private void ShowImage(ListViewBase sender, ContainerContentChangingEventArgs args) { if (args.Phase != 1) { throw new Exception("Not in phase 1."); } Apps app = (Apps)args.Item; StackPanel templateRoot = (StackPanel)args.ItemContainer.ContentTemplateRoot; Image appIcon = (Image)templateRoot.FindName("appIcon"); appIcon.Source = new BitmapImage(new Uri(app.AppIcon)); }