Пример #1
0
        private void textBox_TextChanged(object sender, TextChangedEventArgs e)
        {
            int indexer = ((StackPanel)(sender as TextBox).Parent).Children.IndexOf(sender as TextBox);

            if ((sender as TextBox).Text.Length > 0)
            {
                if (double.TryParse((sender as TextBox).Text, out _double))
                {
                    Styler.ListCount[indexer] = (sender as TextBox).Text.Length;
                    TempListValue.RemoveAt(indexer);
                    TempListValue.Insert(indexer, Convert.ToDouble((sender as TextBox).Text));
                }
            }
            else
            {
                Styler.ListCount[indexer] = (sender as TextBox).Text.Length;
            }
            if (Styler.ListCount.Any(a => a == 0))
            {
                try
                {
                    ((Button)((StackPanel)Grid1.Children[Grid1.Children.Count - 1]).Children[1]).IsEnabled = false;
                }
                catch (Exception) { }
            }
            else
            {
                try
                {
                    ((Button)((StackPanel)Grid1.Children[Grid1.Children.Count - 1]).Children[1]).IsEnabled = true;
                }
                catch (Exception) { }
            }
        }
Пример #2
0
        private void called(int count, List <double> item)
        {
            _count = 0;
            RowDefinition rowDefinition1 = new RowDefinition()
            {
                Height = GridLength.Auto
            };
            RowDefinition rowDefinition2 = new RowDefinition()
            {
                Height = GridLength.Auto
            };
            RowDefinition rowDefinition3 = new RowDefinition()
            {
                Height = GridLength.Auto
            };
            RowDefinition rowDefinition4 = new RowDefinition()
            {
                Height = GridLength.Auto
            };
            RowDefinition rowDefinition5 = new RowDefinition()
            {
                Height = GridLength.Auto
            };

            Grid1.RowDefinitions.Add(rowDefinition1);
            Grid1.RowDefinitions.Add(rowDefinition2);
            Grid1.RowDefinitions.Add(rowDefinition3);
            Grid1.RowDefinitions.Add(rowDefinition4);
            Grid1.RowDefinitions.Add(rowDefinition5);
            //TextBlock textBlock = new TextBlock() { Margin = new Thickness(5, 20, 20, 20), FontSize = 20, Text = "Sample 1 Alert:" };
            Separator separator = new Separator()
            {
                Margin = new Thickness(0, 25, 0, 25)
            };
            Separator separator1 = new Separator()
            {
                Margin = new Thickness(0, 25, 0, 25)
            };
            StackPanel stackPanel = new StackPanel()
            {
                HorizontalAlignment = HorizontalAlignment.Center, Orientation = Orientation.Horizontal
            };
            StackPanel stackPanel1 = new StackPanel()
            {
                VerticalAlignment = VerticalAlignment.Center, HorizontalAlignment = HorizontalAlignment.Stretch
            };
            ScrollViewer scrollViewer = new ScrollViewer()
            {
                VerticalScrollBarVisibility = ScrollBarVisibility.Auto, HorizontalScrollBarVisibility = ScrollBarVisibility.Disabled, Height = 170, VerticalContentAlignment = VerticalAlignment.Center
            };

            scrollViewer.Content = stackPanel1;
            Button Back = new Button()
            {
                Content = " Back ", Margin = new Thickness(0, 0, 5, 0)
            };
            Button Next = new Button()
            {
                Content = " Done ", Margin = new Thickness(5, 0, 5, 0)
            };
            Button Close = new Button()
            {
                Content = " Close ", Margin = new Thickness(5, 0, 0, 0)
            };

            Back.Click  += Back_Click;
            Next.Click  += Next_Click;
            Close.Click += Close_Click;
            stackPanel.Children.Add(Back);
            stackPanel.Children.Add(Next);
            stackPanel.Children.Add(Close);
            // Grid.SetRow(textBlock, 0);
            Grid.SetRow(separator, 1);
            Grid.SetRow(scrollViewer, 2);
            Grid.SetRow(separator1, 3);
            Grid.SetRow(stackPanel, 4);
            //Grid1.Children.Add(textBlock);
            Grid1.Children.Add(separator);
            Grid1.Children.Add(scrollViewer);
            Grid1.Children.Add(separator1);
            Grid1.Children.Add(stackPanel);
            List <double> tempList = new List <double>();

            if (count == item.Count)
            {
                while (_count < count)
                {
                    TextBox textBox = new TextBox()
                    {
                        Margin = new Thickness(5, 10, 5, 10), Height = 25, Name = "TextBox" + _count
                    };
                    textBox.TextChanged      += textBox_TextChanged;
                    textBox.PreviewTextInput += textBox_PreviewTextInput;
                    try
                    {
                        textBox.Text = Convert.ToString(item[_count]);
                    }
                    catch (Exception) { }
                    Styler.ListCount.Add(textBox.Text.Length);
                    tempList.Add(item[_count]);
                    stackPanel1.Children.Add(textBox);
                    _count++;
                }
            }
            else
            {
                while (_count < count)
                {
                    TextBox textBox = new TextBox()
                    {
                        Margin = new Thickness(5, 10, 5, 10), Height = 25, Name = "TextBox" + _count
                    };
                    textBox.TextChanged      += textBox_TextChanged;
                    textBox.PreviewTextInput += textBox_PreviewTextInput;
                    try
                    {
                        textBox.Text = "0";
                    }
                    catch (Exception) { }
                    Styler.ListCount.Add(textBox.Text.Length);
                    tempList.Add(Convert.ToDouble(textBox.Text));
                    stackPanel1.Children.Add(textBox);
                    _count++;
                }
            }
            Styler.Lists.RemoveAt(Styler.Indexes);
            Styler.Lists.Insert(Styler.Indexes, tempList);
            if (TempListValue.Count == Styler.Lists[Styler.Indexes].Count)
            {
                int calls = 0;
                foreach (double content in Styler.Lists[Styler.Indexes])
                {
                    TempListValue.RemoveAt(calls);
                    TempListValue.Insert(calls, content);
                    calls++;
                }
            }
            else
            {
                TempListValue.Clear();
                foreach (double content in Styler.Lists[Styler.Indexes])
                {
                    TempListValue.Add(content);
                }
            }
        }