System.Windows.Controls.UIElementCollection.Add(System.Windows.UIElement)

Here are the examples of the csharp api System.Windows.Controls.UIElementCollection.Add(System.Windows.UIElement) taken from open source projects. By voting up you can indicate which examples are most useful and appropriate.

681 Examples 7

19 Source : SciChart3DInteractionToolbar.cs
with MIT License
from ABTSoftware

private void AddExtraContent()
        {
            if (_toolBarWrapPanel != null && !ExtraContent.IsNullOrEmpty())
            {
                foreach (var child in ExtraContent)
                {
                    _toolBarWrapPanel.Children.Add(child);
                }
            }
        }

19 Source : MainViewModel.cs
with MIT License
from ABTSoftware

public void RunNextTest()
        {
            if (_testQueue.Count == 0)
                return;

            var testCase = _testQueue.Dequeue();
            LayoutRoot.Children.Add(testCase.SpeedTestUi);

            testCase.Run((result) =>
                {
                    LayoutRoot.Children.Remove(testCase.SpeedTestUi);

                    // log the test run
                    _testRuns.Add(string.Format("({0:N2}) - {1} - {2}", result, testCase.TestCaseName, testCase.Version));

                    // add results to the table
                    var testResult = _testResults.SingleOrDefault(i => i.TestName == testCase.TestCaseName);
                    if (testResult == null)
                    {
                        testResult = new TestResult()
                        {
                            TestName = testCase.TestCaseName
                        };
                        _testResults.Add(testResult);
                    }
                    testResult[testCase.Version] = result;
                    string strPrefix = "LC";
                    if (_iTestResult % 2 == 0)
                    {
                        strPrefix = "SC";
                    }
                    else
                    {
                        strPrefix = "LC";
                    } 
                    //Write to log 
                    WriteLog(testCase.TestCaseName + ";" + result.ToString("0.0") + ";", System.AppDomain.CurrentDomain.BaseDirectory + "\\"+strPrefix+"_PerformanceComparisonDump.csv");
                    _iTestResult++; 
                    // start the next test
                    TestFinished(testCase, result);
                });
        }

19 Source : MainControl.xaml.cs
with MIT License
from Actipro

private void OnPopupButtonPopupOpening(object sender, RoutedEventArgs e) {
			// Insert random content into the popup
			RibbonControls.PopupButton popupOwner = (RibbonControls.PopupButton)sender;
			if (new Random().NextDouble() < 0.65) {
				// Create a menu
				RibbonControls.Menu menu = new RibbonControls.Menu();
				for (int index = 0; index < 3; index++) {
					RibbonControls.Button button = new RibbonControls.Button();
					button.Label = String.Format("Dynamically created menu item #{0}, created at {1}", index + 1, DateTime.Now);
					menu.Items.Add(button);	
				}
				popupOwner.PopupContent = menu;
			}
			else {
				// Create alternate content, the Actipro logo
				StackPanel panel = new StackPanel();
				panel.Children.Add(new TextBlock(new Run("Anything can be placed in a popup")));
				panel.Children.Add(new ActiproSoftware.Windows.Controls.ActiproLogo());
				popupOwner.PopupContent = panel;
			}
		}

19 Source : MainControl.xaml.cs
with MIT License
from Actipro

private void OnPopupButtonPopupOpening(object sender, RoutedEventArgs e) {
			// Insert random content into the popup
			RibbonControls.PopupButton popupOwner = (RibbonControls.PopupButton)sender;
			if (new Random().NextDouble() < 0.65) {
				// Create a menu
				RibbonControls.Menu menu = new RibbonControls.Menu();
				for (int index = 0; index < 3; index++) {
					RibbonControls.Button button = new RibbonControls.Button();
					button.Label = String.Format("Dynamically created menu item #{0}, created at {1}", index + 1, DateTime.Now);
					menu.Items.Add(button);	
				}
				popupOwner.PopupContent = menu;
			}
			else {
				// Create alternate content, the Actipro logo
				StackPanel panel = new StackPanel();
				panel.Children.Add(new TextBlock(new Run("Anything can be placed in a popup")));
				panel.Children.Add(new ActiproSoftware.Windows.Controls.ActiproLogo());
				popupOwner.PopupContent = panel;
			}
		}

19 Source : CalendarPage.xaml.cs
with MIT License
from Actipro

private void ClearAndPopulateCalendar() {
			coreGrid.Children.Clear();

			Month month = this.Month;
			Day startDay = this.StartDay;

			int totalDays;
			daysPerMonth.TryGetValue(month, out totalDays);
			if (totalDays == 0)
				return;

			// Populate blank day boxes
			Day currentDay = Day.Sunday;
			for (int i = 0; i < (int)startDay; i++) {
				// Create a border and set parameters
				Border border = new Border() {
					BorderBrush = new SolidColorBrush(Colors.Black),
					BorderThickness = new Thickness(0)
				};
				Grid.SetColumn(border, (int)currentDay);
				Grid.SetRow(border, 0);

				// Create a grid
				Grid grid = new Grid();

				// Make the grid a child of the border
				border.Child = grid;

				// Color the current day
				grid.Background = new SolidColorBrush(Color.FromArgb(255, 224, 224, 224));

				// Add the border to the core grid
				coreGrid.Children.Add(border);

				// Increment the current day
				currentDay++;
			}

			// Iterate through all the days of the month
			currentDay = startDay;
			for (int i = 0; i < totalDays; i++) {
				// Create a border and set parameters
				Border border = new Border() {
					BorderBrush = new SolidColorBrush(Colors.Black),
					BorderThickness = new Thickness(1)
				};
				Grid.SetColumn(border, (int)currentDay);
				Grid.SetRow(border, (int)((i + (int)startDay) / 7));

				// Create a grid and configure it
				Grid grid = new Grid();
				grid.RowDefinitions.Add(new RowDefinition() {
					Height = new GridLength(0, GridUnitType.Auto)
				});
				grid.RowDefinitions.Add(new RowDefinition());

				// Make the grid a child of the border
				border.Child = grid;

				// Create the text block that displays the day number and set parameters
				TextBlock textBox = new TextBlock() {
					Text = (i + 1).ToString(),
					FontSize = 10,
					Margin = new Thickness(1, 1, 0, 0)
				};

				// Make the text block that displays the day number a child of the grid
				grid.Children.Add(textBox);

				// Generate this day's holiday string
				string holidayString = "";
				foreach (var holiday in holidays) {
					if (holiday.Day == i + 1)
						holidayString += holiday.HolidayName + Environment.NewLine;
				}
				if (!String.IsNullOrEmpty(holidayString))
					holidayString = holidayString.Remove(holidayString.Length - 2);

				// Create the text block that displays holiday information
				textBox = new TextBlock() {
					Text = holidayString,
					FontSize = 8,
					Margin = new Thickness(1, 0, 0, 0),
					VerticalAlignment = VerticalAlignment.Bottom
				};

				// Set the grid row of the text block that displays holiday information to 1
				Grid.SetRow(textBox, 1);

				// Make the text block that displays the holiday information a child of the grid
				grid.Children.Add(textBox);

				// Color the current day
				if ((DateTime.Now.Month == ((int)Month) + 1) && (DateTime.Now.Day == (i + 1)))
					grid.Background = new SolidColorBrush(Color.FromArgb(255, 255, 255, 150));
				// Color days that contain holidays
				else if (!String.IsNullOrEmpty(holidayString))
					grid.Background = new SolidColorBrush(Color.FromArgb(255, 158, 211, 255));

				// Add the border to the core grid
				coreGrid.Children.Add(border);

				// Increment the current day
				if (currentDay != Day.Saturday)
					currentDay++;
				else
					currentDay = Day.Sunday;
			}

			int cell = (int)startDay + totalDays;
			int row = (int)(cell / 7);
			int column = cell % 7;
			while (row < 6) {
				// Create a border and set parameters
				Border border = new Border() {
					BorderBrush = new SolidColorBrush(Colors.Black),
					BorderThickness = new Thickness(0)
				};
				Grid.SetColumn(border, column);
				Grid.SetRow(border, row);

				// Create a grid
				Grid grid = new Grid();

				// Make the grid a child of the border
				border.Child = grid;

				// Color the current day
				grid.Background = new SolidColorBrush(Color.FromArgb(255, 224, 224, 224));

				// Add the border to the core grid
				coreGrid.Children.Add(border);

				// Increment the cell
				column++;
				if (column > 6) {
					column = 0;
					row++;
				}
			}
		}

19 Source : ContentsBrowser.cs
with MIT License
from alaabenfatma

private ContextMenu BuildContextMenu()
        {
            var sp = new Separator {Foreground = Brushes.Gray};
            var sp1 = new Separator {Foreground = Brushes.Gray};
            var cMenu = new ContextMenu();
            var open = new MenuItem
            {
                Header = new TextBlock {Foreground = Brushes.WhiteSmoke, Text = "Open"}
            };
            open.Click += (s, e) => { Process.Start(Path); };
            cMenu.Items.Add(open);

            cMenu.Items.Add(sp);
            var addToVirtualControl = new MenuItem();
            var addNodeStack = new StackPanel {Orientation = Orientation.Horizontal};
            addNodeStack.Children.Add(new TextBlock {Text = "◰", FontSize = 18, Foreground = Brushes.DarkCyan});
            addNodeStack.Children.Add(new TextBlock
            {
                Text = "Create node.",
                Foreground = Brushes.WhiteSmoke,
                VerticalAlignment = VerticalAlignment.Center
            });
            addToVirtualControl.Header = addNodeStack;
            addToVirtualControl.Click += (s, e) =>
            {
                var node = new ReadFile(Hub.CurrentHost, false);
                node.OutputPorts[0].Data.Value = Path;
                Hub.CurrentHost.AddNode(node, Hub.CurrentHost.ActualWidth / 2 - node.ActualWidth / 2,
                    Hub.CurrentHost.ActualHeight / 2);
            };
            cMenu.Items.Add(addToVirtualControl);
            cMenu.Items.Add(sp1);
            var cut = new MenuItem
            {
                Header = new TextBlock
                {
                    Foreground = Brushes.WhiteSmoke,
                    Text = "Cut"
                }
            };
            var copy = new MenuItem
            {
                Header = new TextBlock
                {
                    Foreground = Brushes.WhiteSmoke,
                    Text = "Copy"
                }
            };


            var rename = new MenuItem
            {
                Header = new TextBlock
                {
                    Foreground = Brushes.WhiteSmoke,
                    Text = "Rename"
                }
            };
            var deleteTextBlock = new TextBlock();
            deleteTextBlock.Inlines.Add(new TextBlock {Text = "X", Foreground = Brushes.Red});
            deleteTextBlock.Inlines.Add(new TextBlock
            {
                Text = $" Delete {ItemCategory}",
                Foreground = Brushes.WhiteSmoke
            });
            var delete = new MenuItem
            {
                Header = deleteTextBlock
            };
            delete.Click += (s, e) =>
            {
                var res = MessageBox.Show($"Do you really want to delete this {ItemCategory}?", "Delete",
                    MessageBoxButton.YesNo, MessageBoxImage.Exclamation);
                if (res == MessageBoxResult.No) return;
                try
                {
                    if (Folder)
                    {
                        Directory.Delete(Path);
                        Task.Factory.StartNew(() =>
                        {
                            Dispatcher.BeginInvoke(DispatcherPriority.Background, new Action(() =>
                            {
                                Parent.Container.GetNode(Parent.Path, Parent.Container.FoldersTree.Items).Items
                                    .Remove(Parent.Container.GetNode(Path, Parent.Container.FoldersTree.Items));
                            }));
                        });
                    }
                    else
                    {
                        File.Delete(Path);
                    }
                    Parent.Items.Remove(this);
                }
                catch (Exception exception)
                {
                    if (!exception.Message.Contains("The directory is not empty."))
                    {
                        MessageBox.Show(exception.Message, $"Could not delete the {ItemCategory}",
                            MessageBoxButton.OK, MessageBoxImage.Error);
                    }
                    else
                    {
                        var answer = MessageBox.Show(exception.Message + "\n" + "Delete everything in this directory?",
                            $"Could not delete the {ItemCategory}",
                            MessageBoxButton.YesNo, MessageBoxImage.Error);
                        if (answer == MessageBoxResult.Yes)
                        {
                            Directory.Delete(Path, true);
                            Parent.Container.GetNode(Parent.Path, Parent.Container.FoldersTree.Items).Items
                                .Remove(Parent.Container.GetNode(Path, Parent.Container.FoldersTree.Items));
                            Parent.Items.Remove(this);
                        }
                    }
                }
            };
            cut.Click += (s, e) => { Parent.Container.PathToCut = Path; };
            copy.Click += (s, e) =>
            {
                Parent.Container.PathToCut = "";
                Parent.Container.PathToCopy = Path;
            };

            rename.Click += (ss, e) => { Rename(); };
            cMenu.Items.Add(cut);
            cMenu.Items.Add(copy);
            cMenu.Items.Add(rename);
            var sp2 = new Separator();
            cMenu.Items.Add(sp2);
            cMenu.Items.Add(delete);
            return cMenu;
        }

19 Source : CanvasCamera.cs
with MIT License
from alaabenfatma

public void AddChildren(UIElement child)
        {
            Initialize(child);
            if (!Children.Contains(child)) Children.Add(child);
        }

19 Source : CanvasCamera.cs
with MIT License
from alaabenfatma

public void AddChildren(UIElement child, double x, double y)
        {
            Initialize(child);
            if (!Children.Contains(child))
                Children.Add(child);
            SetLeft(child, x);
            SetTop(child, y);
        }

19 Source : Node.cs
with MIT License
from alaabenfatma

public void FuncNodeInit()
        {
            ApplyTemplate();
            _backgroundBorder = (Border) Template.FindName("BackgroundBorder", this);
            IsSelected = true;
            InExecPortsPanel = (StackPanel) Template.FindName("InExecPorts", this);
            OutExecPortsPanel = (StackPanel) Template.FindName("OutExecPorts", this);
            InputPortsPanel = (StackPanel) Template.FindName("InputPorts", this);
            InputPortsControls = (StackPanel) Template.FindName("InputPortsControl", this);
            OutputPortsPanel = (StackPanel) Template.FindName("OutputPorts", this);
            BottomControl = (Control) Template.FindName("BottomControl", this);
            foreach (var port in InExecPorts)
                InExecPortsPanel?.Children.Add(port);
            foreach (var port in OutExecPorts)
                OutExecPortsPanel?.Children.Add(port);
            foreach (var port in InputPorts)
                if (!InputPortsPanel.Children.Contains(port))
                    InputPortsPanel?.Children.Add(port);
            foreach (var port in OutputPorts)
                if (!OutputPortsPanel.Children.Contains(port))
                    try
                    {
                        OutputPortsPanel.Children.Add(port);
                    }
                    catch (Exception e)
                    {
                        Console.WriteLine(e);
                        throw;
                    }
            var inPortsPanel = (StackPanel) Template.FindName("InputPorts", this);
            var outPortsPanel = (StackPanel) Template.FindName("OutputPorts", this);

            if (OutExecPortsPanel != null) OutExecPortsPanel.SizeChanged += (sender, args) => OnChangedSize();

            if (inPortsPanel != null) inPortsPanel.SizeChanged += (sender, args) => OnChangedSize();
            if (outPortsPanel != null) outPortsPanel.SizeChanged += (sender, args) => OnChangedSize();
            OnChangedSize();
        }

19 Source : Node.cs
with MIT License
from alaabenfatma

public void AddObjectPort(Node node, string text, PortTypes porttype, RTypes type, bool multiconnections)
        {
            var port = new ObjectPort(Host, porttype, text, type)
            {
                MultipleConnectionsAllowed = multiconnections
            };
            port.ParentNode = node;
            if (port.PortTypes == PortTypes.Input)
            {
                InputPorts?.Add(port);
                InputPortsPanel?.Children.Add(port);
            }
            else
            {
                OutputPorts?.Add(port);
                OutputPortsPanel?.Children.Add(port);
            }
            OnPropertyChanged();
        }

19 Source : ImageContentHelper.cs
with MIT License
from Aleksbgbg

private static StackPanel GetStackPanel(Button button)
        {
            if (button.Content is StackPanel panel)
            {
                return panel;
            }

            StackPanel buttonStackPanel = new StackPanel
            {
                Orientation = Orientation.Horizontal
            };

            buttonStackPanel.Children.Add(new Image
            {
                Height = 20
            });

            TextBlock buttonTextBlock = new TextBlock
            {
                Margin = new Thickness(5, 0, 5, 0)
            };

            buttonStackPanel.Children.Add(buttonTextBlock);

            if (button.Content is string buttonText)
            {
                buttonTextBlock.Text = buttonText;
            }

            button.Content = buttonStackPanel;

            return buttonStackPanel;
        }

19 Source : BarChartNodeModel.cs
with MIT License
from alfarok

public void CustomizeView(BarChartNodeModel model, NodeView nodeView)
        {
            barChartControl = new BarChartControl(model);
            nodeView.inputGrid.Children.Add(barChartControl);

            MenuItem exportImage = new MenuItem();
            exportImage.Header = "Export Chart as Image";
            exportImage.Click += ExportImage_Click;

            var contextMenu = (nodeView.Content as Grid).ContextMenu;
            contextMenu.Items.Add(exportImage);
        }

19 Source : HeatSeriesNodeModel.cs
with MIT License
from alfarok

public void CustomizeView(HeatSeriesNodeModel model, NodeView nodeView)
        {
            heatSeriesControl = new HeatSeriesControl(model);
            nodeView.inputGrid.Children.Add(heatSeriesControl);

            MenuItem exportImage = new MenuItem();
            exportImage.Header = "Export Chart as Image";
            exportImage.Click += ExportImage_Click;

            var contextMenu = (nodeView.Content as Grid).ContextMenu;
            contextMenu.Items.Add(exportImage);
        }

19 Source : XYLineChartNodeModel.cs
with MIT License
from alfarok

public void CustomizeView(XYLineChartNodeModel model, NodeView nodeView)
        {
            xyLineChartControl = new XYLineChartControl(model);
            nodeView.inputGrid.Children.Add(xyLineChartControl);

            MenuItem exportImage = new MenuItem();
            exportImage.Header = "Export Chart as Image";
            exportImage.Click += ExportImage_Click;

            var contextMenu = (nodeView.Content as Grid).ContextMenu;
            contextMenu.Items.Add(exportImage);
        }

19 Source : BasicLineChartNodeModel.cs
with MIT License
from alfarok

public void CustomizeView(BasicLineChartNodeModel model, NodeView nodeView)
        {
            basicLineChartControl = new BasicLineChartControl(model);
            nodeView.inputGrid.Children.Add(basicLineChartControl);

            MenuItem exportImage = new MenuItem();
            exportImage.Header = "Export Chart as Image";
            exportImage.Click += ExportImage_Click;

            var contextMenu = (nodeView.Content as Grid).ContextMenu;
            contextMenu.Items.Add(exportImage);
        }

19 Source : PieChartNodeModel.cs
with MIT License
from alfarok

public void CustomizeView(PieChartNodeModel model, NodeView nodeView)
        {
            pieChartControl = new PieChartControl(model);
            nodeView.inputGrid.Children.Add(pieChartControl);

            MenuItem exportImage = new MenuItem();
            exportImage.Header = "Export Chart as Image";
            exportImage.Click += ExportImage_Click;

            var contextMenu = (nodeView.Content as Grid).ContextMenu;
            contextMenu.Items.Add(exportImage);
        }

19 Source : ScatterPlotNodeModel.cs
with MIT License
from alfarok

public void CustomizeView(ScatterPlotNodeModel model, NodeView nodeView)
        {
            scatterPlotControl = new ScatterPlotControl(model);
            nodeView.inputGrid.Children.Add(scatterPlotControl);

            MenuItem exportImage = new MenuItem();
            exportImage.Header = "Export Chart as Image";
            exportImage.Click += ExportImage_Click;

            var contextMenu = (nodeView.Content as Grid).ContextMenu;
            contextMenu.Items.Add(exportImage);
        }

19 Source : GridViewBehaviorExtension.cs
with GNU General Public License v3.0
from AndreiFedarets

private void BuildLayout()
        {
            GridViewBuilder layout = new GridViewBuilder(_viewModel);
            layout.BuildGrid();
            Grid grid = new Grid();
            grid.HorizontalAlignment = HorizontalAlignment.Stretch;
            grid.VerticalAlignment = VerticalAlignment.Stretch;
            if (layout.Rows > 1)
            {
                for (int row = 0; row < layout.Rows; row++)
                {
                    RowDefinition rowDefinition = new RowDefinition();
                    bool isFixedHeight = layout.GetIsFixedHeight(row);
                    if (isFixedHeight)
                    {
                        rowDefinition.Height = GridLength.Auto;
                    }
                    else
                    {
                        rowDefinition.Height = new GridLength(1, GridUnitType.Star);
                    }
                    grid.RowDefinitions.Add(rowDefinition);
                }
            }
            if (layout.Columns > 1)
            {
                for (int column = 0; column < layout.Columns; column++)
                {
                    ColumnDefinition columnDefinition = new ColumnDefinition();
                    bool isFixedHeight = layout.GetIsFixedWidth(column);
                    if (isFixedHeight)
                    {
                        columnDefinition.Width = GridLength.Auto;
                    }
                    else
                    {
                        columnDefinition.Width = new GridLength(1, GridUnitType.Star);
                    }
                    grid.ColumnDefinitions.Add(columnDefinition);
                }
            }
            foreach (GridViewItem item in layout)
            {
                grid.Children.Add(item.View);
            }
            ContentControl contentControl = ViewsManager.FindViewContent(_view);
            contentControl.Content = grid;
        }

19 Source : KanjiView.xaml.cs
with Apache License 2.0
from AnkiUniversal

private void CreateGridPathXaml(List<Geometry> dataPaths, int length)
        {
            var grid = new Grid();
            grid.Width = GRID_MAXWIDTH;
            grid.Height = GRID_MAXHEIGHT;
            grid.Margin = gridMargin;

            var border = GetDefaultBorder();
            grid.Children.Add(border);
            Path path;
            for (int i = 0; i < length - 1; i++)
            {
                path = GetDefaultPath();                
                path.Data = dataPaths[i];                
                grid.Children.Add(path);
            }
            path = GetDefaultPath();
            path.Stroke = lastStrokeBrush;
            path.Data = dataPaths[length - 1];
            grid.Children.Add(path);

            kanjiImageView.Children.Add(grid);
        }

19 Source : CanvasRenderContext.cs
with Apache License 2.0
from anmcgrath

public void DrawString(string text, double x, double y, double size, DicomColor color)
        {
            TextBlock tb = new TextBlock();
            var dse = new DropShadowEffect();
            dse.BlurRadius = 1;
            dse.ShadowDepth = 4;
            dse.Direction = 0;
            tb.FontSize = size;
            tb.Foreground = new SolidColorBrush(DicomColorConverter.FromDicomColor(color));
            tb.Text = text;
            Canvas.SetLeft(tb, x * Canvas.ActualWidth);
            Canvas.SetTop(tb, y * Canvas.ActualHeight);

            FormattedText fm = new FormattedText(tb.Text, System.Globalization.CultureInfo.CurrentCulture, System.Windows.FlowDirection.LeftToRight, new Typeface(tb.FontFamily, tb.FontStyle, tb.FontWeight, tb.FontStretch),tb.FontSize,tb.Foreground);

            FillRect(x , y , x + fm.Width/Canvas.ActualWidth, y + fm.Height /Canvas.ActualHeight, DicomColor.FromArgb(128, 0, 0, 0),DicomColor.FromArgb(0,0,0,0));

            Canvas?.Children.Add(tb);
        }

19 Source : CanvasRenderContext.cs
with Apache License 2.0
from anmcgrath

public void DrawRect(double x0, double y0, double x1, double y1, DicomColor color)
        {
            x0 *= Canvas.ActualWidth;
            x1 *= Canvas.ActualWidth;
            y1 *= Canvas.ActualHeight;
            y0 *= Canvas.ActualHeight;

            Rectangle rectangle = new Rectangle();
            rectangle.Stroke = new SolidColorBrush(DicomColorConverter.FromDicomColor(color));
            rectangle.Width = Math.Abs(x1 - x0);
            rectangle.Height = Math.Abs(y1 - y0);
            Canvas.SetLeft(rectangle, Math.Min(x0, x1));
            Canvas.SetTop(rectangle, Math.Min(y0, y1));
            Canvas?.Children.Add(rectangle);
        }

19 Source : CanvasRenderContext.cs
with Apache License 2.0
from anmcgrath

public void DrawLine(double x0, double y0, double x1, double y1, DicomColor color, LineType lineType)
        {
            x0 *= Canvas.ActualWidth;
            x1 *= Canvas.ActualWidth;
            y1 *= Canvas.ActualHeight;
            y0 *= Canvas.ActualHeight;
            Line line = new Line();
            line.Stroke = new SolidColorBrush(DicomColorConverter.FromDicomColor(color));
            if (lineType != LineType.Normal)
            {
                line.StrokeDashArray = new DoubleCollection();
                if (lineType == LineType.Dotted)
                {
                    line.StrokeDashArray.Add(1);
                    line.StrokeDashArray.Add(1);
                }else if(lineType == LineType.Dashed)
                {
                    line.StrokeDashArray.Add(2);
                    line.StrokeDashArray.Add(2);
                }
            }
            line.StrokeThickness = 1;
            line.X1 = x0;
            line.X2 = x1;
            line.Y1 = y0;
            line.Y2 = y1;
            Canvas?.Children.Add(line);
        }

19 Source : CanvasRenderContext.cs
with Apache License 2.0
from anmcgrath

public void FillRect(double x0, double y0, double x1, double y1, DicomColor fill, DicomColor stroke)
        {
            x0 *= Canvas.ActualWidth;
            x1 *= Canvas.ActualWidth;
            y1 *= Canvas.ActualHeight;
            y0 *= Canvas.ActualHeight;

            Rectangle rectangle = new Rectangle();
            rectangle.Fill = new SolidColorBrush(DicomColorConverter.FromDicomColor(fill));
            rectangle.Stroke = new SolidColorBrush(DicomColorConverter.FromDicomColor(stroke));
            rectangle.Width = Math.Abs(x1 - x0);
            rectangle.Height = Math.Abs(y1 - y0);
            Canvas.SetLeft(rectangle, Math.Min(x0, x1));
            Canvas.SetTop(rectangle, Math.Min(y0, y1));
            Canvas?.Children.Add(rectangle);
        }

19 Source : CanvasRenderContext.cs
with Apache License 2.0
from anmcgrath

public void DrawEllipse(double x0, double y0, double radiusX, double radiusY, DicomColor color)
        {
            x0 *= Canvas.ActualWidth;
            y0 *= Canvas.ActualHeight;
            radiusX *= Canvas.ActualWidth;
            radiusY *= Canvas.ActualHeight;

            Ellipse ellipse = new Ellipse();
            ellipse.Stroke = new SolidColorBrush(DicomColorConverter.FromDicomColor(color));
            ellipse.Width = Math.Abs(radiusX);
            ellipse.Height = Math.Abs(radiusY);
            Canvas.SetLeft(ellipse, x0-radiusX/2);
            Canvas.SetTop(ellipse, y0-radiusY/2);
            Canvas?.Children.Add(ellipse);
        }

19 Source : ChatLogModel.cs
with MIT License
from anoyetta

private FlowDoreplacedent CreateChatDoreplacedent()
        {
#if DEBUG
            chatLogSeq++;
            Debug.WriteLine($"CreateChatDoreplacedent() Seq {chatLogSeq}");
#endif
            var doc = new FlowDoreplacedent();

            var para1 = new Paragraph() { Margin = ZeroMargin };

            if (this.ParentOverlaySettings != null &&
                this.ParentOverlaySettings.IsShowTimestamp)
            {
                para1.Inlines.Add(new Run(this.Timestamp.ToString(this.ParentOverlaySettings.TimestampFormat) + " ")
                {
                    FontSize = this.ParentOverlaySettings.Font.Size * 0.9,
                    BaselineAlignment = BaselineAlignment.Center,
                    Foreground = this.TimestampBrush,
                });
            }

            if (this.IsExistChatCodeIndicator)
            {
                para1.Inlines.Add(this.ParentOverlaySettings != null ?
                    new Run(this.ChatCodeIndicator + " ")
                    {
                        FontSize = this.ParentOverlaySettings.Font.Size * 0.9,
                        BaselineAlignment = BaselineAlignment.Center,
                    } :
                    new Run(this.ChatCodeIndicator + " "));
            }

            if (this.IsExistSpeaker)
            {
                para1.Inlines.Add(CreateSpeakerElement());

                if (this.IsExistSpeakerAlias)
                {
                    para1.Inlines.Add(new Run($"( {this.SpeakerAlias} )" + " "));
                }

                para1.Inlines.Add(new Run(": "));
            }

            para1.Inlines.Add(new Run($"{this.Message}"));
            doc.Blocks.Add(para1);

            if (this.discordLog == null)
            {
                return doc;
            }

            var headerBrush = this.HeaderBrush;
            var hyperLinkBrush = this.HyperlinkBrush;

            var fontSize = this.ParentOverlaySettings != null ?
                this.ParentOverlaySettings.Font.Size * 1.0 :
                15;

            var contentWidth = this.ParentOverlaySettings != null ?
                this.ParentOverlaySettings.W * 0.8 :
                350;

            var files = this.discordLog.Attachments.Where(x => !x.Url.IsImage());
            var imagesAtta = this.discordLog.Attachments.Where(x => x.Url.IsImage());

            // Attachments
            foreach (var atta in files)
            {
                var para = CreateSubParagraph();
                AddHyperLink(para, "File", atta.Filename, atta.Url);
                doc.Blocks.Add(para);
            }

            var imagesEmbeds = this.discordLog.Embeds
                .Where(x => x.Image.HasValue)
                .Select(x => x.Image.Value);

            var videos = this.discordLog.Embeds
                .Where(x => x.Video.HasValue)
                .Select(x => x.Video.Value);

            var links = this.discordLog.Embeds
                .Where(x =>
                    x.Url != null &&
                    !imagesEmbeds.Any(image => image.Url == x.Url) &&
                    !videos.Any(video => video.Url == x.Url))
                .Select(x => x.Url);

            // Attachments Images
            if (imagesAtta.Any())
            {
                var panel = new WrapPanel()
                {
                    Orientation = Orientation.Horizontal,
                    Margin = new Thickness(0, 5, 0, 2),
                };

                foreach (var image in imagesAtta)
                {
                    var bitmap = new BitmapImage();
                    bitmap.BeginInit();
                    bitmap.UriSource = new Uri(image.Url);
                    bitmap.EndInit();

                    var inline = new InlineUIContainer(new Image()
                    {
                        Source = bitmap,
                        Opacity = Config.Instance.ImageOpacity,
                    });

                    var hyperlink = new Hyperlink(inline)
                    {
                        NavigateUri = new Uri(image.Url),
                    };

                    hyperlink.RequestNavigate += this.HyperlinkElement_RequestNavigate;

                    var view = new Viewbox()
                    {
                        Child = new TextBlock(hyperlink),
                        MaxWidth = this.ParentOverlaySettings != null ?
                            this.ParentOverlaySettings.W * AttachmentImageWidthRatio :
                            250.0d,
                        HorizontalAlignment = HorizontalAlignment.Left,
                        Margin = new Thickness(0, 2, 4, 2)
                    };

                    panel.Children.Add(view);
                }

                doc.Blocks.Add(new BlockUIContainer(panel));
            }

            // Embeds Images
            if (imagesEmbeds.Any())
            {
                var panel = new WrapPanel()
                {
                    Orientation = Orientation.Horizontal
                };

                foreach (var image in imagesEmbeds)
                {
                    var bitmap = new BitmapImage();
                    bitmap.BeginInit();
                    bitmap.UriSource = new Uri(image.Url);
                    bitmap.EndInit();

                    var inline = new InlineUIContainer(new Image()
                    {
                        Source = bitmap
                    });

                    var hyperlink = new Hyperlink(inline)
                    {
                        NavigateUri = new Uri(image.Url),
                    };

                    hyperlink.RequestNavigate += this.HyperlinkElement_RequestNavigate;

                    var view = new Viewbox()
                    {
                        Child = new TextBlock(hyperlink),
                        MaxWidth = 250,
                        HorizontalAlignment = HorizontalAlignment.Left,
                        Margin = new Thickness(0, 2, 4, 2)
                    };

                    panel.Children.Add(view);
                }

                doc.Blocks.Add(new BlockUIContainer(panel));
            }

            // Videos
            foreach (var video in videos)
            {
                var para = CreateSubParagraph();
                AddHyperLink(para, "Video", video.Url, video.Url);
                doc.Blocks.Add(para);
            }

            // Links
            foreach (var url in links)
            {
                var para = CreateSubParagraph();
                AddHyperLink(para, "Link", url, url);
                doc.Blocks.Add(para);
            }

            return doc;

            Paragraph CreateSubParagraph()
            {
                return new Paragraph()
                {
                    FontSize = fontSize,
                    Margin = ZeroMargin,
                    FontFamily = new FontFamily("Consolas")
                };
            }

            void AddHyperLink(
                Paragraph para,
                string header,
                string text,
                string url)
            {
                var headerElement = new Run($" {header}: ")
                {
                    BaselineAlignment = BaselineAlignment.Subscript,
                    Foreground = headerBrush
                };

                var hyperlinkElement = new Hyperlink()
                {
                    Foreground = hyperLinkBrush
                };

                hyperlinkElement.Inlines.Add(new TextBlock()
                {
                    Text = text,
                    MaxWidth = contentWidth,
                    TextTrimming = TextTrimming.CharacterEllipsis,
                });

                hyperlinkElement.NavigateUri = new Uri(url);
                hyperlinkElement.RequestNavigate += this.HyperlinkElement_RequestNavigate;

                para.Inlines.Add(headerElement);
                para.Inlines.Add(hyperlinkElement);
            }

            Inline CreateSpeakerElement()
            {
                if (this.discordLog != null ||
                    string.IsNullOrEmpty(this.SpeakerCharacterName) ||
                    this.ChatCode == ChatCodes.NPC ||
                    this.ChatCode == ChatCodes.NPCAnnounce ||
                    this.ChatCode == ChatCodes.CustomEmotes ||
                    this.ChatCode == ChatCodes.StandardEmotes)
                {
                    return new Run(this.Speaker + " ");
                }

                var url = string.Empty;
                var server = Uri.EscapeDataString(this.SpeakerServer);
                var name = this.SpeakerCharacterName;

                var first = string.Empty;
                var family = string.Empty;

                if (name.Contains(" "))
                {
                    var parts = name.Split(' ');
                    first = parts[0].Replace(".", string.Empty);
                    family = parts[1].Replace(".", string.Empty);
                }
                else
                {
                    return new Run(this.Speaker + " ");
                }

                var isInitialized = first.Length <= 1 || family.Length <= 1;

                if (!string.IsNullOrEmpty(this.SpeakerCharacterName) &&
                    !string.IsNullOrEmpty(server) &&
                    !isInitialized)
                {
                    var nameArgument = Uri.EscapeDataString($"{first} {family}");
                    url = $@"https://ja.fflogs.com/character/jp/{server}/{nameArgument}";
                }
                else
                {
                    url = $@"https://ja.fflogs.com/search/?term=";

                    if (!isInitialized)
                    {
                        url += Uri.EscapeDataString($"{first} {family}");
                    }
                    else
                    {
                        if (first.Length > 1)
                        {
                            url += Uri.EscapeDataString(first);
                        }
                        else
                        {
                            return new Run(this.Speaker + " ");
                        }
                    }
                }

                var text = new Run()
                {
                    Text = this.Speaker,
                    Cursor = Cursors.Arrow,
                    TextDecorations = TextDecorations.Underline,
                    ToolTip = url,
                    Tag = new Uri(url),
                };

                text.MouseLeftButtonDown += this.Speaker_MouseLeftButtonDown;

                var span = new Span();
                span.Inlines.Add(text);
                span.Inlines.Add(new Run(" "));

                return span;
            }
        }

19 Source : TabControlEx.cs
with MIT License
from anoyetta

private ContentPresenter CreateChildContentPresenter(object item)
        {
            if (item == null)
                return null;

            ContentPresenter cp = FindChildContentPresenter(item);

            if (cp != null)
                return cp;

            // the actual child to be added.  cp.Tag is a reference to the TabItem
            cp = new ContentPresenter();
            cp.Content = (item is TabItem) ? (item as TabItem).Content : item;
            cp.ContentTemplate = this.SelectedContentTemplate;
            cp.ContentTemplateSelector = this.SelectedContentTemplateSelector;
            cp.ContentStringFormat = this.SelectedContentStringFormat;
            cp.Visibility = Visibility.Collapsed;
            cp.Tag = (item is TabItem) ? item : (this.ItemContainerGenerator.ContainerFromItem(item));
            ItemsHolderPanel.Children.Add(cp);
            return cp;
        }

19 Source : ClockControl.cs
with MIT License
from AntonyCorbett

private static void GenerateHourNumbers(Canvas canvas)
        {
            var clockRadius = canvas.Width / 2;
            var centrePointRadius = clockRadius - 50;
            const double borderSize = 80;

            for (int n = 0; n < 12; ++n)
            {
                var angle = n * 30;
                var pt = PointOnCircle(centrePointRadius, angle, ClockOrigin);

                var hour = n == 0 ? 12 : n;

                var t = CreateHourNumberTextBlock(hour);
                var b = new Border
                {
                    Width = borderSize,
                    Height = borderSize,
                    Child = t
                };

                canvas.Children.Add(b);
                Canvas.SetLeft(b, pt.X - (borderSize / 2));
                Canvas.SetTop(b, pt.Y - (borderSize / 2));
            }
        }

19 Source : ClockControl.cs
with MIT License
from AntonyCorbett

private static void GenerateHourMarkers(Canvas canvas)
        {
            var angle = 0;
            for (var n = 0; n < 4; ++n)
            {
                var line = CreateMajorHourMarker();
                angle += 90;
                line.RenderTransform = new RotateTransform(angle, ClockRadius, ClockRadius);
                canvas.Children.Add(line);
            }

            for (var n = 0; n < 12; ++n)
            {
                if (n % 3 > 0)
                {
                    var line = CreateMinorHourMarker();
                    line.RenderTransform = new RotateTransform(angle, ClockRadius, ClockRadius);
                    canvas.Children.Add(line);
                }

                angle += 30;
            }

            for (var n = 0; n < 60; ++n)
            {
                if (n % 5 > 0)
                {
                    var line = CreateMinuteMarker();
                    line.RenderTransform = new RotateTransform(angle, ClockRadius, ClockRadius);
                    canvas.Children.Add(line);
                }

                angle += 6;
            }
        }

19 Source : CountdownControl.cs
with MIT License
from AntonyCorbett

private void AddGeometryToCanvas(Canvas canvas)
        {
            var revealedColor = ToColor("#c0c5c1");
            var externalRingColor = ToColor("#74546a");
            var ballColor = ToColor("#eaf0ce");
            var ringStrokeColor = ToColor("#473341");
            var innerHighlightColor = Colors.White;

            var gs1 = new GradientStopCollection(2)
            {
                new GradientStop(innerHighlightColor, 0.7),
                new GradientStop(revealedColor, 1)
            };

            _donut = new Path
            {
                Fill = new RadialGradientBrush(gs1),
                Name = "Donut"
            };

            _pie = new Path
            {
                Stroke = new SolidColorBrush(ringStrokeColor),
                StrokeThickness = 1,
                Fill = new SolidColorBrush(externalRingColor),
                Name = "Pie"
            };

            _secondsBall = new Ellipse
            {
                Fill = new SolidColorBrush(ballColor),
                Name = "SecondsBall"
            };

            canvas.Children.Add(_donut);
            canvas.Children.Add(_pie);
            canvas.Children.Add(_secondsBall);
            
            var textColor = ToColor("#eaf0ce");
            _time = new TextBlock { Foreground = new SolidColorBrush(textColor), Name = "TimeTxt" };
            canvas.Children.Add(_time);
        }

19 Source : AddDynamicThemeTask.xaml.cs
with MIT License
from Apollo199999999

public void AddAction(string time, string mode, string theme)
        {
            //create a Grid
            Grid ActionItem = new Grid();
            ActionItem.Height = 150;
            ActionItem.Width = 560;

            //create a label that says "Dynamic Theme Event"
            Label label1 = new Label();
            label1.Content = "Dynamic Theme Event:";
            label1.FontWeight = FontWeights.Bold;
            label1.HorizontalAlignment = HorizontalAlignment.Left;
            label1.VerticalAlignment = VerticalAlignment.Top;

            //create a label that says "Trigger this event at:"
            Label label2 = new Label();
            label2.Content = "Trigger this event at:";
            label2.HorizontalAlignment = HorizontalAlignment.Left;
            label2.VerticalAlignment = VerticalAlignment.Top;
            label2.Margin = new Thickness(0, 31, 0, 0);

            //create a TimePicker and set the initial time
            TimePicker TriggerTimePicker = new TimePicker();
            TriggerTimePicker.Margin = new Thickness(140, 25, 0, 0);
            TriggerTimePicker.HorizontalAlignment = HorizontalAlignment.Left;
            TriggerTimePicker.VerticalAlignment = VerticalAlignment.Top;
            TriggerTimePicker.SetTimereplacedtring(time);

            //create a label that says "When this event is triggered:"
            Label label3 = new Label();
            label3.Content = "When this event is triggered:";
            label3.HorizontalAlignment = HorizontalAlignment.Left;
            label3.VerticalAlignment = VerticalAlignment.Top;
            label3.Margin = new Thickness(0, 70, 0, 0);
            label3.FontWeight = FontWeights.Bold;

            //create a label that says "Change the"
            Label label4 = new Label();
            label4.Content = "Change the";
            label4.HorizontalAlignment = HorizontalAlignment.Left;
            label4.VerticalAlignment = VerticalAlignment.Top;
            label4.Margin = new Thickness(0, 111, 0, 0);

            //create a combobox for picking the system or app theme
            ComboBox SystemOrAppThemePicker = new ComboBox();
            SystemOrAppThemePicker.HorizontalAlignment = HorizontalAlignment.Left;
            SystemOrAppThemePicker.Margin = new Thickness(86, 105, 0, 0);
            SystemOrAppThemePicker.VerticalAlignment = VerticalAlignment.Top;
            SystemOrAppThemePicker.Width = 203;
            SystemOrAppThemePicker.Height = 32;

            //add items to the combo box
            ComboBoxItem SystemThemeItem = new ComboBoxItem();
            ComboBoxItem AppsThemeItem = new ComboBoxItem();
            SystemThemeItem.Content = "Default Windows mode";
            AppsThemeItem.Content = "Default app mode";

            SystemOrAppThemePicker.Items.Add(SystemThemeItem);
            SystemOrAppThemePicker.Items.Add(AppsThemeItem);

            //set the default selected item
            if (mode == "windows")
            {
                SystemOrAppThemePicker.SelectedItem = SystemThemeItem;
            }
            else if (mode == "apps")
            {
                SystemOrAppThemePicker.SelectedItem = AppsThemeItem;
            }

            //create a label that says "to"
            Label label5 = new Label();
            label5.Content = "to";
            label5.HorizontalAlignment = HorizontalAlignment.Left;
            label5.VerticalAlignment = VerticalAlignment.Top;
            label5.Margin = new Thickness(302, 111, 0, 0);

            //create a combobox for picking light theme or dark theme
            ComboBox LightDarkThemePicker = new ComboBox();
            LightDarkThemePicker.HorizontalAlignment = HorizontalAlignment.Left;
            LightDarkThemePicker.Margin = new Thickness(338, 105, 0, 0);
            LightDarkThemePicker.VerticalAlignment = VerticalAlignment.Top;
            LightDarkThemePicker.Width = 136;
            LightDarkThemePicker.Height = 32;

            //add items to the combo box
            ComboBoxItem LightThemeItem = new ComboBoxItem();
            ComboBoxItem DarkThemeItem = new ComboBoxItem();
            LightThemeItem.Content = "Light Theme";
            DarkThemeItem.Content = "Dark Theme";

            LightDarkThemePicker.Items.Add(LightThemeItem);
            LightDarkThemePicker.Items.Add(DarkThemeItem);

            //set the default selected item
            if (theme == "light")
            {
                LightDarkThemePicker.SelectedItem = LightThemeItem;
            }
            else if (theme == "dark")
            {
                LightDarkThemePicker.SelectedItem = DarkThemeItem;
            }


            //add everything to the grid
            ActionItem.Children.Add(label1);
            ActionItem.Children.Add(label2);
            ActionItem.Children.Add(TriggerTimePicker);
            ActionItem.Children.Add(label3);
            ActionItem.Children.Add(label4);
            ActionItem.Children.Add(SystemOrAppThemePicker);
            ActionItem.Children.Add(label5);
            ActionItem.Children.Add(LightDarkThemePicker);

            //add the grid to the actionlistbox
            ActionsListBox.Items.Add(ActionItem);

            //make the action item the selected item and scroll to the selected item
            ActionsListBox.SelectedItem = ActionItem;
            ActionsListBox.ScrollIntoView(ActionsListBox.SelectedItem);
        }

19 Source : AddDynamicThemeTask.xaml.cs
with MIT License
from Apollo199999999

public void AddAction(string time, string mode, string theme)
        {
            //create a Grid
            Grid ActionItem = new Grid();
            ActionItem.Height = 150;
            ActionItem.Width = 560;

            //create a label that says "Dynamic Theme Event"
            Label label1 = new Label();
            label1.Content = "Dynamic Theme Event:";
            label1.FontWeight = FontWeights.Bold;
            label1.HorizontalAlignment = HorizontalAlignment.Left;
            label1.VerticalAlignment = VerticalAlignment.Top;

            //create a label that says "Trigger this event at:"
            Label label2 = new Label();
            label2.Content = "Trigger this event at:";
            label2.HorizontalAlignment = HorizontalAlignment.Left;
            label2.VerticalAlignment = VerticalAlignment.Top;
            label2.Margin = new Thickness(0, 31, 0, 0);

            //create a TimePicker and set the initial time
            TimePicker TriggerTimePicker = new TimePicker();
            TriggerTimePicker.Margin = new Thickness(140, 25, 0, 0);
            TriggerTimePicker.HorizontalAlignment = HorizontalAlignment.Left;
            TriggerTimePicker.VerticalAlignment = VerticalAlignment.Top;
            TriggerTimePicker.SetTimereplacedtring(time);

            //create a label that says "When this event is triggered:"
            Label label3 = new Label();
            label3.Content = "When this event is triggered:";
            label3.HorizontalAlignment = HorizontalAlignment.Left;
            label3.VerticalAlignment = VerticalAlignment.Top;
            label3.Margin = new Thickness(0, 70, 0, 0);
            label3.FontWeight = FontWeights.Bold;

            //create a label that says "Change the"
            Label label4 = new Label();
            label4.Content = "Change the";
            label4.HorizontalAlignment = HorizontalAlignment.Left;
            label4.VerticalAlignment = VerticalAlignment.Top;
            label4.Margin = new Thickness(0, 111, 0, 0);

            //create a combobox for picking the system or app theme
            ComboBox SystemOrAppThemePicker = new ComboBox();
            SystemOrAppThemePicker.HorizontalAlignment = HorizontalAlignment.Left;
            SystemOrAppThemePicker.Margin = new Thickness(86, 105, 0, 0);
            SystemOrAppThemePicker.VerticalAlignment = VerticalAlignment.Top;
            SystemOrAppThemePicker.Width = 203;
            SystemOrAppThemePicker.Height = 32;

            //add items to the combo box
            ComboBoxItem SystemThemeItem = new ComboBoxItem();
            ComboBoxItem AppsThemeItem = new ComboBoxItem();
            SystemThemeItem.Content = "Default Windows mode";
            AppsThemeItem.Content = "Default app mode";

            SystemOrAppThemePicker.Items.Add(SystemThemeItem);
            SystemOrAppThemePicker.Items.Add(AppsThemeItem);

            //set the default selected item
            if (mode == "windows")
            {
                SystemOrAppThemePicker.SelectedItem = SystemThemeItem;
            }
            else if (mode == "apps")
            {
                SystemOrAppThemePicker.SelectedItem = AppsThemeItem;
            }

            //create a label that says "to"
            Label label5 = new Label();
            label5.Content = "to";
            label5.HorizontalAlignment = HorizontalAlignment.Left;
            label5.VerticalAlignment = VerticalAlignment.Top;
            label5.Margin = new Thickness(302, 111, 0, 0);

            //create a combobox for picking light theme or dark theme
            ComboBox LightDarkThemePicker = new ComboBox();
            LightDarkThemePicker.HorizontalAlignment = HorizontalAlignment.Left;
            LightDarkThemePicker.Margin = new Thickness(338, 105, 0, 0);
            LightDarkThemePicker.VerticalAlignment = VerticalAlignment.Top;
            LightDarkThemePicker.Width = 136;
            LightDarkThemePicker.Height = 32;

            //add items to the combo box
            ComboBoxItem LightThemeItem = new ComboBoxItem();
            ComboBoxItem DarkThemeItem = new ComboBoxItem();
            LightThemeItem.Content = "Light Theme";
            DarkThemeItem.Content = "Dark Theme";

            LightDarkThemePicker.Items.Add(LightThemeItem);
            LightDarkThemePicker.Items.Add(DarkThemeItem);

            //set the default selected item
            if (theme == "light")
            {
                LightDarkThemePicker.SelectedItem = LightThemeItem;
            }
            else if (theme == "dark")
            {
                LightDarkThemePicker.SelectedItem = DarkThemeItem;
            }


            //add everything to the grid
            ActionItem.Children.Add(label1);
            ActionItem.Children.Add(label2);
            ActionItem.Children.Add(TriggerTimePicker);
            ActionItem.Children.Add(label3);
            ActionItem.Children.Add(label4);
            ActionItem.Children.Add(SystemOrAppThemePicker);
            ActionItem.Children.Add(label5);
            ActionItem.Children.Add(LightDarkThemePicker);

            //add the grid to the actionlistbox
            ActionsListBox.Items.Add(ActionItem);

            //make the action item the selected item and scroll to the selected item
            ActionsListBox.SelectedItem = ActionItem;
            ActionsListBox.ScrollIntoView(ActionsListBox.SelectedItem);
        }

19 Source : AddDynamicWallpaperTask.xaml.cs
with MIT License
from Apollo199999999

public void AddTimeEvent(string SelectedTime, string wallpaperPath)
        {
            //create a grid
            Grid TimeEventGrid = new Grid();
            TimeEventGrid.Width = 480;
            TimeEventGrid.Height = 415;

            //add a Label that says "Time Event:"
            Label label1 = new Label();
            label1.Content = "Time Event:";
            label1.FontSize = 16;
            label1.FontWeight = FontWeights.Bold;
            label1.VerticalAlignment = VerticalAlignment.Top;
            label1.HorizontalAlignment = HorizontalAlignment.Left;

            //create a label that says "Trigger this event"
            Label label2 = new Label();
            label2.Content = "Trigger this event when the time is";
            label2.HorizontalAlignment = HorizontalAlignment.Left;
            label2.VerticalAlignment = VerticalAlignment.Top;
            label2.Margin = new Thickness(0, 35, 0, 0);

            //create a timepicker
            TimePicker timePicker = new TimePicker();
            timePicker.SetTimereplacedtring(SelectedTime);
            timePicker.HorizontalAlignment = HorizontalAlignment.Left;
            timePicker.VerticalAlignment = VerticalAlignment.Top;
            timePicker.Margin = new Thickness(220, 29, 0, 0);

            //create a label that says "When this event is triggered"
            Label label3 = new Label();
            label3.Content = "When this event is triggered:";
            label3.HorizontalAlignment = HorizontalAlignment.Left;
            label3.VerticalAlignment = VerticalAlignment.Top;
            label3.FontWeight = FontWeights.Bold;
            label3.Margin = new Thickness(0, 125, 0, 0);

            //create a label that says "Change Wallpaper to:"
            Label label4 = new Label();
            label4.Content = "Change wallpaper to:";
            label4.HorizontalAlignment = HorizontalAlignment.Left;
            label4.VerticalAlignment = VerticalAlignment.Top;
            label4.Margin = new Thickness(0, 155, 0, 0);

            //create an image control
            Image WallpaperImage = new Image();
            WallpaperImage.StretchDirection = StretchDirection.Both;
            WallpaperImage.Stretch = Stretch.Uniform;
            WallpaperImage.Height = 170;
            WallpaperImage.Width = 440;
            //try and set the source of the image control
            try { WallpaperImage.Source = new BitmapImage(new Uri(wallpaperPath)); }
            catch (Exception e)
            {
                //show an error message
                MessageBox.Show("An error occured while trying to add the event with the wallpaper: " + wallpaperPath + "\n" +
                    "with the exception: " + "\n" + e.Message + "\n" + "Check that the file exists and change the wallpaper under the 'Events' " +
                    "section when you are done.", "Error", MessageBoxButton.OK, MessageBoxImage.Error);

                //set the placeholder wallpaper as image source
                WallpaperImage.Source = new BitmapImage(new Uri(GetPlaceholderWallpaperPath()));
            }

            WallpaperImage.HorizontalAlignment = HorizontalAlignment.Center;
            WallpaperImage.VerticalAlignment = VerticalAlignment.Top;
            WallpaperImage.Margin = new Thickness(0, 185, 0, 0);

            //create a button that says "Pick Image"
            Button PickImageBtn = new Button();
            PickImageBtn.Click += PickImageBtn_Click;
            PickImageBtn.Content = "Pick Image";
            PickImageBtn.HorizontalAlignment = HorizontalAlignment.Center;
            PickImageBtn.VerticalAlignment = VerticalAlignment.Top;
            //store the image control in the tag so that we can access it later
            PickImageBtn.Tag = WallpaperImage;
            PickImageBtn.Margin = new Thickness(0, 375, 0, 0);

            //add the controls to grid
            TimeEventGrid.Children.Add(label1);
            TimeEventGrid.Children.Add(label2);
            TimeEventGrid.Children.Add(label3);
            TimeEventGrid.Children.Add(label4);
            TimeEventGrid.Children.Add(WallpaperImage);
            TimeEventGrid.Children.Add(PickImageBtn);
            TimeEventGrid.Children.Add(timePicker);

            //add the grid to the listbox
            ActionsListBox.Items.Add(TimeEventGrid);

            //make the timeeventgrid the selected item and scrool it into view
            ActionsListBox.SelectedItem = TimeEventGrid;
            ActionsListBox.ScrollIntoView(ActionsListBox.SelectedItem);
        }

19 Source : AddDynamicWallpaperTask.xaml.cs
with MIT License
from Apollo199999999

public void AddBatteryEvent(int batteryPercentage, string wallpaperPath)
        {
            //create a grid
            Grid BatteryEventGrid = new Grid();
            BatteryEventGrid.Width = 480;
            BatteryEventGrid.Height = 415;

            //add a Label that says "Time Event:"
            Label label1 = new Label();
            label1.Content = "Battery Event:";
            label1.FontSize = 16;
            label1.FontWeight = FontWeights.Bold;
            label1.VerticalAlignment = VerticalAlignment.Top;
            label1.HorizontalAlignment = HorizontalAlignment.Left;

            //create a label that says "Trigger this event"
            Label label2 = new Label();
            label2.Content = "Trigger this event when the battery percentage is";
            label2.HorizontalAlignment = HorizontalAlignment.Left;
            label2.VerticalAlignment = VerticalAlignment.Top;
            label2.Margin = new Thickness(0, 35, 0, 0);

            //create a numberbox (from ModernWPF)
            ModernWpf.Controls.NumberBox BatteryPercentageNumberBox = new ModernWpf.Controls.NumberBox();
            BatteryPercentageNumberBox.AcceptsExpression = true;
            BatteryPercentageNumberBox.SpinButtonPlacementMode =
                ModernWpf.Controls.NumberBoxSpinButtonPlacementMode.Compact;
            BatteryPercentageNumberBox.Value = batteryPercentage;
            BatteryPercentageNumberBox.Maximum = 100;
            BatteryPercentageNumberBox.Minimum = 1;
            BatteryPercentageNumberBox.HorizontalAlignment = HorizontalAlignment.Left;
            BatteryPercentageNumberBox.VerticalAlignment = VerticalAlignment.Top;
            BatteryPercentageNumberBox.Margin = new Thickness(315, 29, 0, 0);
            BatteryPercentageNumberBox.Height = 32;
            BatteryPercentageNumberBox.Width = 100;

            //create a label that says "%"
            Label label5 = new Label();
            label5.Content = "%";
            label5.HorizontalAlignment = HorizontalAlignment.Left;
            label5.VerticalAlignment = VerticalAlignment.Top;
            label5.Margin = new Thickness(420, 35, 0, 0);

            //create a label that says "When this event is triggered"
            Label label3 = new Label();
            label3.Content = "When this event is triggered:";
            label3.HorizontalAlignment = HorizontalAlignment.Left;
            label3.VerticalAlignment = VerticalAlignment.Top;
            label3.FontWeight = FontWeights.Bold;
            label3.Margin = new Thickness(0, 125, 0, 0);

            //create a label that says "Change Wallpaper to:"
            Label label4 = new Label();
            label4.Content = "Change wallpaper to:";
            label4.HorizontalAlignment = HorizontalAlignment.Left;
            label4.VerticalAlignment = VerticalAlignment.Top;
            label4.Margin = new Thickness(0, 155, 0, 0);

            //create an image control
            Image WallpaperImage = new Image();
            WallpaperImage.StretchDirection = StretchDirection.Both;
            WallpaperImage.Stretch = Stretch.Uniform;
            WallpaperImage.Height = 170;
            WallpaperImage.Width = 440;
            //try and set the source of the image control
            try { WallpaperImage.Source = new BitmapImage(new Uri(wallpaperPath)); } 
            catch (Exception e)
            {
                //show an error message
                MessageBox.Show("An error occured while trying to add the event with the wallpaper: " + wallpaperPath + "\n" +
                    "with the exception: " + "\n" + e.Message + "\n" + "Check that the file exists and change the wallpaper under the 'Events' " +
                    "section when you are done.", "Error", MessageBoxButton.OK, MessageBoxImage.Error);

                //set the placeholder wallpaper as image source
                WallpaperImage.Source = new BitmapImage(new Uri(GetPlaceholderWallpaperPath()));
            }

            WallpaperImage.HorizontalAlignment = HorizontalAlignment.Center;
            WallpaperImage.VerticalAlignment = VerticalAlignment.Top;
            WallpaperImage.Margin = new Thickness(0, 185, 0, 0);

            //create a button that says "Pick Image"
            Button PickImageBtn = new Button();
            PickImageBtn.Click += PickImageBtn_Click;
            PickImageBtn.Content = "Pick Image";
            PickImageBtn.HorizontalAlignment = HorizontalAlignment.Center;
            PickImageBtn.VerticalAlignment = VerticalAlignment.Top;
            //store the image control in the tag so that we can access it later
            PickImageBtn.Tag = WallpaperImage;
            PickImageBtn.Margin = new Thickness(0, 375, 0, 0);

            //add the controls to grid
            BatteryEventGrid.Children.Add(label1);
            BatteryEventGrid.Children.Add(label2);
            BatteryEventGrid.Children.Add(label3);
            BatteryEventGrid.Children.Add(label4);
            BatteryEventGrid.Children.Add(label5);
            BatteryEventGrid.Children.Add(WallpaperImage);
            BatteryEventGrid.Children.Add(PickImageBtn);
            BatteryEventGrid.Children.Add(BatteryPercentageNumberBox);

            //add the grid to the listbox
            ActionsListBox.Items.Add(BatteryEventGrid);

            //make the batteryeventgrid the selected item and scroll it into view
            ActionsListBox.SelectedItem = BatteryEventGrid;
            ActionsListBox.ScrollIntoView(ActionsListBox.SelectedItem);
        }

19 Source : AddDynamicWallpaperTask.xaml.cs
with MIT License
from Apollo199999999

public void AddBatteryEvent(int batteryPercentage, string wallpaperPath)
        {
            //create a grid
            Grid BatteryEventGrid = new Grid();
            BatteryEventGrid.Width = 480;
            BatteryEventGrid.Height = 415;

            //add a Label that says "Time Event:"
            Label label1 = new Label();
            label1.Content = "Battery Event:";
            label1.FontSize = 16;
            label1.FontWeight = FontWeights.Bold;
            label1.VerticalAlignment = VerticalAlignment.Top;
            label1.HorizontalAlignment = HorizontalAlignment.Left;

            //create a label that says "Trigger this event"
            Label label2 = new Label();
            label2.Content = "Trigger this event when the battery percentage is";
            label2.HorizontalAlignment = HorizontalAlignment.Left;
            label2.VerticalAlignment = VerticalAlignment.Top;
            label2.Margin = new Thickness(0, 35, 0, 0);

            //create a numberbox (from ModernWPF)
            ModernWpf.Controls.NumberBox BatteryPercentageNumberBox = new ModernWpf.Controls.NumberBox();
            BatteryPercentageNumberBox.AcceptsExpression = true;
            BatteryPercentageNumberBox.SpinButtonPlacementMode =
                ModernWpf.Controls.NumberBoxSpinButtonPlacementMode.Compact;
            BatteryPercentageNumberBox.Value = batteryPercentage;
            BatteryPercentageNumberBox.Maximum = 100;
            BatteryPercentageNumberBox.Minimum = 1;
            BatteryPercentageNumberBox.HorizontalAlignment = HorizontalAlignment.Left;
            BatteryPercentageNumberBox.VerticalAlignment = VerticalAlignment.Top;
            BatteryPercentageNumberBox.Margin = new Thickness(315, 29, 0, 0);
            BatteryPercentageNumberBox.Height = 32;
            BatteryPercentageNumberBox.Width = 100;

            //create a label that says "%"
            Label label5 = new Label();
            label5.Content = "%";
            label5.HorizontalAlignment = HorizontalAlignment.Left;
            label5.VerticalAlignment = VerticalAlignment.Top;
            label5.Margin = new Thickness(420, 35, 0, 0);

            //create a label that says "When this event is triggered"
            Label label3 = new Label();
            label3.Content = "When this event is triggered:";
            label3.HorizontalAlignment = HorizontalAlignment.Left;
            label3.VerticalAlignment = VerticalAlignment.Top;
            label3.FontWeight = FontWeights.Bold;
            label3.Margin = new Thickness(0, 125, 0, 0);

            //create a label that says "Change Wallpaper to:"
            Label label4 = new Label();
            label4.Content = "Change wallpaper to:";
            label4.HorizontalAlignment = HorizontalAlignment.Left;
            label4.VerticalAlignment = VerticalAlignment.Top;
            label4.Margin = new Thickness(0, 155, 0, 0);

            //create an image control
            Image WallpaperImage = new Image();
            WallpaperImage.StretchDirection = StretchDirection.Both;
            WallpaperImage.Stretch = Stretch.Uniform;
            WallpaperImage.Height = 170;
            WallpaperImage.Width = 440;
            //try and set the source of the image control
            try { WallpaperImage.Source = new BitmapImage(new Uri(wallpaperPath)); } 
            catch (Exception e)
            {
                //show an error message
                MessageBox.Show("An error occured while trying to add the event with the wallpaper: " + wallpaperPath + "\n" +
                    "with the exception: " + "\n" + e.Message + "\n" + "Check that the file exists and change the wallpaper under the 'Events' " +
                    "section when you are done.", "Error", MessageBoxButton.OK, MessageBoxImage.Error);

                //set the placeholder wallpaper as image source
                WallpaperImage.Source = new BitmapImage(new Uri(GetPlaceholderWallpaperPath()));
            }

            WallpaperImage.HorizontalAlignment = HorizontalAlignment.Center;
            WallpaperImage.VerticalAlignment = VerticalAlignment.Top;
            WallpaperImage.Margin = new Thickness(0, 185, 0, 0);

            //create a button that says "Pick Image"
            Button PickImageBtn = new Button();
            PickImageBtn.Click += PickImageBtn_Click;
            PickImageBtn.Content = "Pick Image";
            PickImageBtn.HorizontalAlignment = HorizontalAlignment.Center;
            PickImageBtn.VerticalAlignment = VerticalAlignment.Top;
            //store the image control in the tag so that we can access it later
            PickImageBtn.Tag = WallpaperImage;
            PickImageBtn.Margin = new Thickness(0, 375, 0, 0);

            //add the controls to grid
            BatteryEventGrid.Children.Add(label1);
            BatteryEventGrid.Children.Add(label2);
            BatteryEventGrid.Children.Add(label3);
            BatteryEventGrid.Children.Add(label4);
            BatteryEventGrid.Children.Add(label5);
            BatteryEventGrid.Children.Add(WallpaperImage);
            BatteryEventGrid.Children.Add(PickImageBtn);
            BatteryEventGrid.Children.Add(BatteryPercentageNumberBox);

            //add the grid to the listbox
            ActionsListBox.Items.Add(BatteryEventGrid);

            //make the batteryeventgrid the selected item and scroll it into view
            ActionsListBox.SelectedItem = BatteryEventGrid;
            ActionsListBox.ScrollIntoView(ActionsListBox.SelectedItem);
        }

19 Source : AddDynamicWallpaperTask.xaml.cs
with MIT License
from Apollo199999999

public void AddTimeEvent(string SelectedTime, string wallpaperPath)
        {
            //create a grid
            Grid TimeEventGrid = new Grid();
            TimeEventGrid.Width = 480;
            TimeEventGrid.Height = 415;

            //add a Label that says "Time Event:"
            Label label1 = new Label();
            label1.Content = "Time Event:";
            label1.FontSize = 16;
            label1.FontWeight = FontWeights.Bold;
            label1.VerticalAlignment = VerticalAlignment.Top;
            label1.HorizontalAlignment = HorizontalAlignment.Left;

            //create a label that says "Trigger this event"
            Label label2 = new Label();
            label2.Content = "Trigger this event when the time is";
            label2.HorizontalAlignment = HorizontalAlignment.Left;
            label2.VerticalAlignment = VerticalAlignment.Top;
            label2.Margin = new Thickness(0, 35, 0, 0);

            //create a timepicker
            TimePicker timePicker = new TimePicker();
            timePicker.SetTimereplacedtring(SelectedTime);
            timePicker.HorizontalAlignment = HorizontalAlignment.Left;
            timePicker.VerticalAlignment = VerticalAlignment.Top;
            timePicker.Margin = new Thickness(220, 29, 0, 0);

            //create a label that says "When this event is triggered"
            Label label3 = new Label();
            label3.Content = "When this event is triggered:";
            label3.HorizontalAlignment = HorizontalAlignment.Left;
            label3.VerticalAlignment = VerticalAlignment.Top;
            label3.FontWeight = FontWeights.Bold;
            label3.Margin = new Thickness(0, 125, 0, 0);

            //create a label that says "Change Wallpaper to:"
            Label label4 = new Label();
            label4.Content = "Change wallpaper to:";
            label4.HorizontalAlignment = HorizontalAlignment.Left;
            label4.VerticalAlignment = VerticalAlignment.Top;
            label4.Margin = new Thickness(0, 155, 0, 0);

            //create an image control
            Image WallpaperImage = new Image();
            WallpaperImage.StretchDirection = StretchDirection.Both;
            WallpaperImage.Stretch = Stretch.Uniform;
            WallpaperImage.Height = 170;
            WallpaperImage.Width = 440;
            //try and set the source of the image control
            try { WallpaperImage.Source = new BitmapImage(new Uri(wallpaperPath)); }
            catch (Exception e)
            {
                //show an error message
                MessageBox.Show("An error occured while trying to add the event with the wallpaper: " + wallpaperPath + "\n" +
                    "with the exception: " + "\n" + e.Message + "\n" + "Check that the file exists and change the wallpaper under the 'Events' " +
                    "section when you are done.", "Error", MessageBoxButton.OK, MessageBoxImage.Error);

                //set the placeholder wallpaper as image source
                WallpaperImage.Source = new BitmapImage(new Uri(GetPlaceholderWallpaperPath()));
            }

            WallpaperImage.HorizontalAlignment = HorizontalAlignment.Center;
            WallpaperImage.VerticalAlignment = VerticalAlignment.Top;
            WallpaperImage.Margin = new Thickness(0, 185, 0, 0);

            //create a button that says "Pick Image"
            Button PickImageBtn = new Button();
            PickImageBtn.Click += PickImageBtn_Click;
            PickImageBtn.Content = "Pick Image";
            PickImageBtn.HorizontalAlignment = HorizontalAlignment.Center;
            PickImageBtn.VerticalAlignment = VerticalAlignment.Top;
            //store the image control in the tag so that we can access it later
            PickImageBtn.Tag = WallpaperImage;
            PickImageBtn.Margin = new Thickness(0, 375, 0, 0);

            //add the controls to grid
            TimeEventGrid.Children.Add(label1);
            TimeEventGrid.Children.Add(label2);
            TimeEventGrid.Children.Add(label3);
            TimeEventGrid.Children.Add(label4);
            TimeEventGrid.Children.Add(WallpaperImage);
            TimeEventGrid.Children.Add(PickImageBtn);
            TimeEventGrid.Children.Add(timePicker);

            //add the grid to the listbox
            ActionsListBox.Items.Add(TimeEventGrid);

            //make the timeeventgrid the selected item and scrool it into view
            ActionsListBox.SelectedItem = TimeEventGrid;
            ActionsListBox.ScrollIntoView(ActionsListBox.SelectedItem);
        }

19 Source : SettingsWindow.xaml.cs
with MIT License
from Apollo199999999

public void UpdateTaskListBox(ListBox listBox, int DynamicThemeOrDynamicDesktop)
        {
            //clear listbox items EXCEPT the first one
            var listBoxFirsreplacedem = listBox.Items[0];
            listBox.Items.Clear();
            listBox.Items.Add(listBoxFirsreplacedem);

            //string to store directory where all the tasks are located
            string TaskDirectories;

            //check where the tasks are stored
            if (DynamicThemeOrDynamicDesktop == 0)
            {
                TaskDirectories = DataDynamicThemeRootDir;
            }
            else
            {
                TaskDirectories = DataDynamicWallpaperRootDir;
            }

            //iterate through directories in TaskDirectory, getting the name of the tasks
            foreach (string TaskDirectory in Directory.GetDirectories(TaskDirectories))
            {
                //create a grid, populate it with controls, and add it to the listbox
                Grid TaskGrid = new Grid();
                //I have no idea why you need to minus 30, i do this so that the button fits ok
                TaskGrid.Width = listBox.Width - 30;
                TaskGrid.Height = 30;

                //Create an Image control and display the dynamicthemetaskicon or dynamicwallpapertaskicon
                System.Windows.Controls.Image icon = new System.Windows.Controls.Image();

                //display the correct icon
                if (DynamicThemeOrDynamicDesktop == 0)
                {
                    //display the dynamic theme icon
                    icon.Source = new BitmapImage(new Uri("pack://siteoforigin:,,,/Resources/DynamicThemeTaskIcon.png"));
                }
                else
                {
                    //display the dynamicwallpapericon
                    icon.Source = new BitmapImage(new Uri("pack://siteoforigin:,,,/Resources/DynamicWallpaperTaskIcon.png"));
                }

                icon.Height = 23;
                icon.Width = 23;
                icon.HorizontalAlignment = HorizontalAlignment.Left;

                //create a Label
                Label label1 = new Label();
                label1.Content = new DirectoryInfo(TaskDirectory).Name;
                label1.HorizontalAlignment = HorizontalAlignment.Left;
                label1.VerticalAlignment = VerticalAlignment.Center;
                label1.FontSize = 14;
                label1.FontWeight = FontWeights.Bold;
                label1.Margin = new Thickness(30, 0, 0, 0);
                label1.HorizontalContentAlignment = HorizontalAlignment.Center;

                //create a tooltip for the more button
                ToolTip toolTip = new ToolTip();
                toolTip.Content = "More";

                //create a more button
                Button MoreBtn = new Button();

                //set the tooltip service
                MoreBtn.ToolTip = toolTip;
                
                MoreBtn.Content = "\xE712";
                MoreBtn.HorizontalAlignment = HorizontalAlignment.Right;
                MoreBtn.VerticalAlignment = VerticalAlignment.Center;
                MoreBtn.FontFamily = new System.Windows.Media.FontFamily("Segoe MDL2 replacedets");
                MoreBtn.FontSize = 18;
                MoreBtn.FontWeight = FontWeights.Bold;
                MoreBtn.Background = System.Windows.Media.Brushes.Transparent;

                //store the filepath in the button tag
                MoreBtn.Tag = TaskDirectory;
                MoreBtn.Click += MoreBtn_Click;
               
                TaskGrid.Children.Add(icon);
                TaskGrid.Children.Add(label1);
                TaskGrid.Children.Add(MoreBtn);

                //add the item to the listbox and unselect all items
                listBox.Items.Add(TaskGrid);
                listBox.UnselectAll();
            }
        }

19 Source : ChildWindowManager.cs
with GNU General Public License v3.0
from atomex-me

private static Task AddDialogToContainerAsync(
            ChildWindow dialog,
            Panel container)
        {
            return Task.Factory.StartNew(() => dialog.Dispatcher.Invoke(new Action(() => container.Children.Add(dialog))));
        }

19 Source : AyDateBoxMonth.cs
with MIT License
from ay2015

public void CreatePopupList()
        {
            RootGrid.Children.Clear();

            GridService.SetColumns(RootGrid, "? ?");
            GridService.SetRows(RootGrid, "? ? ? ? ? ?");
            //currentMonth =this.Text.ToInt();
            var _11 = CreateButtons(Langs.ay_MonthName1.Lang(), 1);
            GridService.SetRowColumn(_11, "0 0");
            var _12 = CreateButtons(Langs.ay_MonthName2.Lang(), 2);
            GridService.SetRowColumn(_12, "1 0");
            var _13 = CreateButtons(Langs.ay_MonthName3.Lang(), 3);
            GridService.SetRowColumn(_13, "2 0");
            var _14 = CreateButtons(Langs.ay_MonthName4.Lang(), 4);
            GridService.SetRowColumn(_14, "3 0");
            var _15 = CreateButtons(Langs.ay_MonthName5.Lang(), 5);
            GridService.SetRowColumn(_15, "4 0");
            var _16 = CreateButtons(Langs.ay_MonthName6.Lang(), 6);
            GridService.SetRowColumn(_16, "5 0");

            var _17 = CreateButtons(Langs.ay_MonthName7.Lang(), 7);
            GridService.SetRowColumn(_17, "0 1");
            var _18 = CreateButtons(Langs.ay_MonthName8.Lang(), 8);
            GridService.SetRowColumn(_18, "1 1");
            var _19 = CreateButtons(Langs.ay_MonthName9.Lang(), 9);
            GridService.SetRowColumn(_19, "2 1");
            var _20 = CreateButtons(Langs.ay_MonthName10.Lang(), 10);
            GridService.SetRowColumn(_20, "3 1");
            var _21 = CreateButtons(Langs.ay_MonthName11.Lang(), 11);
            GridService.SetRowColumn(_21, "4 1");
            var _22 = CreateButtons(Langs.ay_MonthName12.Lang(), 12);
            GridService.SetRowColumn(_22, "5 1");

            RootGrid.Children.Add(_11);
            RootGrid.Children.Add(_12);
            RootGrid.Children.Add(_13);
            RootGrid.Children.Add(_14);
            RootGrid.Children.Add(_15);
            RootGrid.Children.Add(_16);
            RootGrid.Children.Add(_17);
            RootGrid.Children.Add(_18);
            RootGrid.Children.Add(_19);
            RootGrid.Children.Add(_20);
            RootGrid.Children.Add(_21);
            RootGrid.Children.Add(_22);

        }

19 Source : AyDateBoxSecond.cs
with MIT License
from ay2015

public void CreatePopupList()
        {
            RootGrid.Children.Clear();
            GridService.SetColumns(RootGrid, "? ? ? ? ? ?");

            int _1 = 0;
         
                for (int i = 0; i < 4; i++)
                {
                    //创建按钮
                    var _11 = CreateButtons(_1);
                    GridService.SetRowColumn(_11, "0 " + i);
                    _1 = _1 + 15;
                RootGrid.Children.Add(_11);
                }

        }

19 Source : AyDateBoxYear.cs
with MIT License
from ay2015

public void CreateTenYearList(int beginYear)
        {
            RootGrid.Children.Clear();
            GridService.SetColumns(RootGrid, "? ?");
            GridService.SetRows(RootGrid, "? ? ? ? ? ?");
            fiveBefore = beginYear - 5;
            endBefore = beginYear + 5;
            int _1 = 0;
            for (int i = fiveBefore; i < endBefore; i++)
            {
                //创建按钮
                var _11 = CreateButtons(i);
                if (_1 > 4)
                {
                    GridService.SetRowColumn(_11, (_1 - 5) + " 1");
                }
                else
                {
                    GridService.SetRowColumn(_11, _1 + " 0");
                }
                _1++;
                RootGrid.Children.Add(_11);
            }

            Grid gridbottom = new Grid();
            Grid.SetColumnSpan(gridbottom, 2);
            Grid.SetRow(gridbottom, 5);
            RootGrid.Children.Add(gridbottom);

            GridService.SetColumns(gridbottom, "? ? ?");
            prewtenbutton = CreatePageButtons("more_ay_yearLeft", Langs.ay_Last10.Lang());
            if (isCreateLessMinValue)
            {
                prewtenbutton.IsEnabled = false;
            }
            prewtenbutton.Click += _2_Click;
            Grid.SetColumn(prewtenbutton, 0);

            var _3 = CreatePageButtons("path_ay_yearClose", Langs.share_close.Lang());
            _3.Click += _3_Click;
            Grid.SetColumn(_3, 1);


            nexttenbutton = CreatePageButtons("more_ay_yearRight", Langs.ay_Next10.Lang());
            if (isCreateLessMaxValue)
            {
                nexttenbutton.IsEnabled = false;
            }
            nexttenbutton.Click += _4_Click;


            Grid.SetColumn(nexttenbutton, 2);
            gridbottom.Children.Add(prewtenbutton);
            gridbottom.Children.Add(_3);
            gridbottom.Children.Add(nexttenbutton);
        }

19 Source : AyDateBoxCalendar.cs
with MIT License
from ay2015

public void CreatePopupList()
        {

            if (DateRule == "")            //如果是空白,默认选中今天,啥也不限制
            {

                AyCalendar ac = new AyCalendar();
                ac.BorderBrush = Brushes.Transparent;
                ac.MinDateReferToElement = this.MinDateReferToElement;
                ac.MaxDateReferToElement = this.MaxDateReferToElement;
                ac.DateBoxInput = this;
                //ac.DisabledDatesStrings = this.DisabledDatesStrings;
                ac.HorizontalAlignment = HorizontalAlignment.Center;
                ac.VerticalAlignment = VerticalAlignment.Center;
                ac.SelectMode = AyDatePickerSelectMode.OnlySelectDate;
                if (!this.Text.IsNullAndTrimAndEmpty())
                {
                    DateTime? date = ReverseDateTimeFromText(ac);
                    if (date.HasValue)
                    {
                        ac.SelectedDateTime = date;
                    }
                }
                RootGrid.Children.Add(ac);
            }
            else
            {
                if (DateRuleObjects.IsNotNull())
                {
                    _fmt = AyCalendarService.GetAyCalendarFMT(DateRuleObjects.dateFmt);
                    switch (_fmt)
                    {
                        case AyCalendarFMT.None:
                            break;
                        default:
                            AyCalendar ac = CreateAyCalendar();
                            RootGrid.Children.Add(ac);
                            break;
                    }
                }
            }

        }

19 Source : AyDateBoxMinute.cs
with MIT License
from ay2015

public void CreatePopupList()
        {
            RootGrid.Children.Clear();
            GridService.SetColumns(RootGrid, "? ? ? ? ? ?");
            GridService.SetRows(RootGrid, "? ?");

            int _1 = 0;
            for (int j = 0; j < 2; j++)
            {
                for (int i = 0; i < 6; i++)
                {
                    //创建按钮
                    var _11 = CreateButtons(_1);
                    GridService.SetRowColumn(_11, j + " " + i);
                    _1 = _1 + 5;
                    RootGrid.Children.Add(_11);
                }
            }
        
        }

19 Source : AyCalendarService.cs
with MIT License
from ay2015

[Pure]
        public static Grid CreateWeekHeadLabel2(string cnt)
        {
            Grid g = new Grid();
            g.Height = 40;
            g.Width = UIGeneric.DayWidth.Value;

            AyText label = new AyText();
            label.HorizontalAlignment = HorizontalAlignment.Center;
            label.VerticalAlignment = VerticalAlignment.Center;
            label.Text = cnt;
            label.SetResourceReference(AyText.ForegroundProperty, "colorsuccess");
            g.Children.Add(label);
            return g;
        }

19 Source : AyLayer.xaml.cs
with MIT License
from ay2015

private void SetAyLayerBase(object owner, object content, string replacedle, AyLayerOptions options, bool isDiaglog)
        {
            if (options == null)
            {
                options = AyLayerOptions.DefaultAyLayerOptions;
            }

            _options = options;
            //this.Topmost = true;
            //this.ShowInTaskbar = true;
            //if (owner != null)
            //{
            //    Owner = owner;
            //}

            if (owner == null)
            {
                if (Application.Current.MainWindow is AyWindow)
                {
                    AyWindow mainWindow = Application.Current.MainWindow as AyWindow;
                    Owner = mainWindow.ayLayerArea;
                }
            }
            else
            {
                var _Owner = owner as Grid;
                if (_Owner != null)
                {
                    Owner = _Owner;
                }
                else
                {
                    var _Wn = owner as AyWindow;
                    if (_Wn.IsNotNull())
                        Owner = _Wn.ayLayerArea;
                }
            }

            userPresenter.Content = content;
            ItemContent = content;

            if (options.LayerId.IsNotNull())
            {
                AYUI.Session[options.LayerId] = this;
            }
            if (options.Direction.HasValue)
            {
                switch (options.Direction.Value)
                {
                    case AyLayerDockDirect.LT:
                        body.HorizontalAlignment = HorizontalAlignment.Left;
                        body.VerticalAlignment = VerticalAlignment.Top;
                        break;
                    case AyLayerDockDirect.CT:
                        //中间位置计算
                        body.HorizontalAlignment = HorizontalAlignment.Center;
                        body.VerticalAlignment = VerticalAlignment.Top;
                        break;
                    case AyLayerDockDirect.RT:
                        //中间位置计算
                        body.HorizontalAlignment = HorizontalAlignment.Right;
                        body.VerticalAlignment = VerticalAlignment.Top;
                        break;
                    case AyLayerDockDirect.LC:
                        body.HorizontalAlignment = HorizontalAlignment.Left;
                        body.VerticalAlignment = VerticalAlignment.Center;
                        break;
                    case AyLayerDockDirect.CC:
                        body.HorizontalAlignment = HorizontalAlignment.Center;
                        body.VerticalAlignment = VerticalAlignment.Center;
                        break;
                    case AyLayerDockDirect.RC:
                        body.HorizontalAlignment = HorizontalAlignment.Right;
                        body.VerticalAlignment = VerticalAlignment.Center;
                        break;
                    case AyLayerDockDirect.LB:
                        body.HorizontalAlignment = HorizontalAlignment.Left;
                        body.VerticalAlignment = VerticalAlignment.Bottom;
                        break;
                    case AyLayerDockDirect.CB:
                        body.HorizontalAlignment = HorizontalAlignment.Center;
                        body.VerticalAlignment = VerticalAlignment.Bottom;
                        break;
                    case AyLayerDockDirect.RB:
                        body.HorizontalAlignment = HorizontalAlignment.Right;
                        body.VerticalAlignment = VerticalAlignment.Bottom;
                        break;
                    default:
                        break;
                }
            }

            if (options.IsContainsreplacedleBar)
            {

                d.Height = "40.00".ToGridLength();
                Border b = new Border();
                b.SetResourceReference(Border.BorderBrushProperty, "bordercolorlight");
                b.BorderThickness = options.replacedleBarBorderThickness;
                if (options.CanDrag)
                {
                    SetDragMove(b);
                }
                if (options.LayerCornerRadius.HasValue)
                {
                    b.CornerRadius = new CornerRadius(options.LayerCornerRadius.Value.TopLeft, options.LayerCornerRadius.Value.TopRight, 0, 0);
                }

                b.HorizontalAlignment = HorizontalAlignment.Stretch;
                b.VerticalAlignment = VerticalAlignment.Stretch;
                Grid g = new Grid();
                if (!replacedle.IsNullOrWhiteSpace())
                {
                    AyText tb = new AyText();
                    tb.Width = 200;
                    tb.VerticalAlignment = VerticalAlignment.Center;
                    tb.HorizontalAlignment = HorizontalAlignment.Left;
                    tb.Margin = new Thickness(16, 0, 0, 0);
                    tb.TextWrapping = TextWrapping.NoWrap;
                    tb.SetResourceReference(AyText.FontSizeProperty, "WindowreplacedleFontSize");
                    tb.TextTrimming = TextTrimming.CharacterEllipsis;
                    tb.Text = replacedle;
                    g.Children.Add(tb);
                }

                if (options.CanClose)
                {
                    Button ab = new Button();
                    ab.SetResourceReference(Button.StyleProperty, "AYWin_CLOSE");
                    ab.Click += closewindow_Click;
                    ab.VerticalAlignment = VerticalAlignment.Center;
                    ab.HorizontalAlignment = HorizontalAlignment.Right;
                    ab.Content = Langs.share_close.Lang();
                    ab.Width = 32;
                    ab.Height = 32;
                    ab.Margin = new Thickness(0, 0, 5, 0);
                    g.Children.Add(ab);
                }
                b.Child = g;
                b.SetResourceReference(Border.BackgroundProperty, "colorwhite");
                bodyConent.Children.Add(b);
            }
            else
            {
                if (options.replacedleBar.IsNotNull() && options.CanDrag)
                {
                    SetDragMove(options.replacedleBar);
                }
            }

            if (options.MaskBrush.IsNotNull())
            {
                layoutMain.Background = options.MaskBrush;
            }
            if (isDiaglog)
            {
                if (options.MaskBrush.IsNull())
                {
                    layoutMain.Background = SolidColorBrushConverter.From16JinZhi("#8C000000");
                }
                if (options.WhenShowDialogNeedShake)
                    layoutMain.MouseLeftButtonDown += LayoutMain_MouseLeftButtonDown;
            }

            if (options.IsShowLayerBorder)
            {
                body.SetResourceReference(Border.BorderBrushProperty, "bordercolorlight");

                if (options.LayerBorderThickness.HasValue)
                {
                    body.BorderThickness = options.LayerBorderThickness.Value;
                }
                else
                {
                    body.BorderThickness = new Thickness(1);
                }
            }
            if (options.LayerCornerRadius.HasValue)
            {
                body.CornerRadius = options.LayerCornerRadius.Value;
            }
            options.LayerBackground.Freeze();
            body.Background = options.LayerBackground;

            if (options.ShowAnimateIndex == 0)
            {
                body.Visibility = Visibility.Visible;
                if (options.Opened.IsNotNull())
                {
                    options.Opened();
                }
                body.Loaded += Body_Loaded;

                DropShadowEffect de = new DropShadowEffect();
                de.Color = options.ShadowColor;
                de.ShadowDepth = options.ShadowDepth;
                de.Opacity = 0.1;
                body.Effect = de;
                de.BlurRadius = options.ShadowRadius;
                SetRealPoint(options);

            }
            else if (options.ShowAnimateIndex == 1)
            {
                var sc = new AyAniScale(body, () =>
                {
                    ShowShadow(options);
                });
                sc.AutoDestory = true;
                sc.AnimateSpeed = 450;
                sc.ScaleXFrom = 0;

                sc.ScaleYFrom = 0;
                sc.ScaleXTo = 1;
                sc.ScaleYTo = 1;
                sc.EasingFunction = new System.Windows.Media.Animation.CubicEase { EasingMode = EasingMode.EaseOut };
                sc.Begin();


            }
            else if (options.ShowAnimateIndex == 2)
            {
                var sc = new AyAniSlideInDown(body, () =>
                {
                    ShowShadow(options);
                });
                sc.AutoDestory = true;
                sc.AnimateSpeed = 750;
                sc.FromDistance = -4000;
                sc.OpacityNeed = false;
                sc.EasingFunction = new System.Windows.Media.Animation.CubicEase { EasingMode = EasingMode.EaseOut };
                sc.Begin();
            }
            else if (options.ShowAnimateIndex == 3)
            {
                var sc = new AyAniSlideInUp(body, () =>
                {

                    ShowShadow(options);
                });
                sc.AutoDestory = true;
                sc.AnimateSpeed = 750;
                sc.FromDistance = 4000;
                sc.OpacityNeed = false;
                sc.EasingFunction = new System.Windows.Media.Animation.CubicEase { EasingMode = EasingMode.EaseOut };
                sc.Begin();
            }
            else if (options.ShowAnimateIndex == 4)
            {
                var sc = new AyAniSlideInLeft(body, () =>
                {

                    ShowShadow(options);
                });
                sc.AutoDestory = true;
                sc.AnimateSpeed = 750;
                sc.FromDistance = -4000;
                sc.OpacityNeed = false;
                sc.EasingFunction = new System.Windows.Media.Animation.CubicEase { EasingMode = EasingMode.EaseOut };
                sc.Begin();
            }
            else if (options.ShowAnimateIndex == 5)
            {
                var sc = new AyAniSlideInRight(body, () =>
                {

                    ShowShadow(options);
                });
                sc.AutoDestory = true;
                sc.AnimateSpeed = 750;
                sc.FromDistance = 4000;
                sc.OpacityNeed = false;
                sc.EasingFunction = new System.Windows.Media.Animation.CubicEase { EasingMode = EasingMode.EaseOut };
                sc.Begin();
            }
            else if (options.ShowAnimateIndex == 6)
            {
                var sc = new AyAniBounceInDown(body, () =>
                {

                    ShowShadow(options);
                });
                sc.AutoDestory = true;
                sc.Begin();
            }
            else if (options.ShowAnimateIndex == 7)
            {
                var sc = new AyAniBounceInUp(body, () =>
                {

                    ShowShadow(options);
                });
                sc.AutoDestory = true;
                sc.Begin();
            }
            else if (options.ShowAnimateIndex == 8)
            {
                var sc = new AyAniBounceInLeft(body, () =>
                {

                    ShowShadow(options);
                });
                sc.AutoDestory = true;
                sc.Begin();
            }
            else if (options.ShowAnimateIndex == 9)
            {
                var sc = new AyAniBounceInRight(body, () =>
                {
                    ShowShadow(options);
                });
                sc.AutoDestory = true;
                sc.Begin();
            }
            else if (options.ShowAnimateIndex == 10)
            {
                var sc = new AyAniRotateIn(body, () =>
                {
                    ShowShadow(options);

                });
                sc.AnimateSpeed = 750;
                sc.EasingFunction = new System.Windows.Media.Animation.CubicEase { EasingMode = EasingMode.EaseOut };
                sc.Begin();
            }
            else if (options.ShowAnimateIndex == 11)
            {
                var sc = new AyAniBounceIn(body, () =>
                {
                    ShowShadow(options);
                });
                sc.AutoDestory = true;
                sc.AnimateSpeed = 750;
                sc.Begin();
            }
            else if (options.ShowAnimateIndex == 12)
            {
                var sc = new AyAniBounceInLeft(body, () =>
                {
                    ShowShadow(options);
                });
                sc.AutoDestory = true;
                sc.AnimateSpeed = 750;
                sc.Begin();
            }
            else if (options.ShowAnimateIndex == 13)
            {
                var sc = new AyAniBounceInRight(body, () =>
                {
                    ShowShadow(options);
                });
                sc.AutoDestory = true;
                sc.AnimateSpeed = 750;
                sc.Begin();
            }
            else if (options.ShowAnimateIndex == 14)
            {
                var sc = new AyAniBounceInDown(body, () =>
                {
                    ShowShadow(options);
                });
                sc.AutoDestory = true;
                sc.AnimateSpeed = 750;
                sc.Begin();
            }
            else if (options.ShowAnimateIndex == 15)
            {
                var sc = new AyAniBounceInUp(body, () =>
                {
                    ShowShadow(options);
                });
                sc.AutoDestory = true;
                sc.AnimateSpeed = 750;
                sc.Begin();
            }


        }

19 Source : AyLayer.xaml.cs
with MIT License
from ay2015

public void Show()
        {
            var _1 = Owner.Children.Count;
            var zIndex = _1 + 1;
            Panel.SetZIndex(this, zIndex);
            this.Visibility = Visibility.Visible;
            this.Opacity = 1;
            Owner.Children.Add(this);
        }

19 Source : AyDateBoxDay.cs
with MIT License
from ay2015

public void CreatePopupList()
        {
            RootGrid.Children.Clear();

            GridService.SetColumns(RootGrid, "? ? ? ? ? ? ?");
            GridService.SetRows(RootGrid, "? ? ? ? ?");
            int _1 = 1;
            for (int j = 0; j < 5; j++)
            {
                for (int i = 0; i < 7; i++)
                {
                    if (_1 < 32)
                    {
                        var _11 = CreateButtons(_1.ToString(), _1);
                        GridService.SetRowColumn(_11, j + " " + i);
                        _1++;
                        RootGrid.Children.Add(_11);
                    }
                }
            }
        }

19 Source : AyDateBoxHour.cs
with MIT License
from ay2015

public void CreatePopupList()
        {
            RootGrid.Children.Clear();

            GridService.SetColumns(RootGrid, "? ? ? ? ? ?");
            GridService.SetRows(RootGrid, "? ? ? ?");

            int _1 = 0;
            for (int j = 0; j < 4; j++)
            {
                for (int i = 0; i < 6; i++)
                {
                    //创建按钮
                    var _11 = CreateButtons(_1);
                    GridService.SetRowColumn(_11, j + " " + i);
                    _1++;
                    RootGrid.Children.Add(_11);
                }
            }

        }

19 Source : AyLayer.xaml.cs
with MIT License
from ay2015

private void SetAyLayerBase(object owner, object content, string replacedle, AyLayerOptions options, bool isDiaglog)
        {
            if (options == null)
            {
                options = AyLayerOptions.DefaultAyLayerOptions;
            }

            _options = options;
            //this.Topmost = true;
            //this.ShowInTaskbar = true;
            //if (owner != null)
            //{
            //    Owner = owner;
            //}

            if (owner == null)
            {
                if (Application.Current.MainWindow is AyWindow)
                {
                    AyWindow mainWindow = Application.Current.MainWindow as AyWindow;
                    Owner = mainWindow.ayLayerArea;
                }
            }
            else
            {
                var _Owner = owner as Grid;
                if (_Owner != null)
                {
                    Owner = _Owner;
                }
                else
                {
                    var _Wn = owner as AyWindow;
                    if (_Wn.IsNotNull())
                        Owner = _Wn.ayLayerArea;
                }
            }

            userPresenter.Content = content;
            ItemContent = content;

            if (options.LayerId.IsNotNull())
            {
                AYUI.Session[options.LayerId] = this;
            }
            if (options.Direction.HasValue)
            {
                switch (options.Direction.Value)
                {
                    case AyLayerDockDirect.LT:
                        body.HorizontalAlignment = HorizontalAlignment.Left;
                        body.VerticalAlignment = VerticalAlignment.Top;
                        break;
                    case AyLayerDockDirect.CT:
                        //中间位置计算
                        body.HorizontalAlignment = HorizontalAlignment.Center;
                        body.VerticalAlignment = VerticalAlignment.Top;
                        break;
                    case AyLayerDockDirect.RT:
                        //中间位置计算
                        body.HorizontalAlignment = HorizontalAlignment.Right;
                        body.VerticalAlignment = VerticalAlignment.Top;
                        break;
                    case AyLayerDockDirect.LC:
                        body.HorizontalAlignment = HorizontalAlignment.Left;
                        body.VerticalAlignment = VerticalAlignment.Center;
                        break;
                    case AyLayerDockDirect.CC:
                        body.HorizontalAlignment = HorizontalAlignment.Center;
                        body.VerticalAlignment = VerticalAlignment.Center;
                        break;
                    case AyLayerDockDirect.RC:
                        body.HorizontalAlignment = HorizontalAlignment.Right;
                        body.VerticalAlignment = VerticalAlignment.Center;
                        break;
                    case AyLayerDockDirect.LB:
                        body.HorizontalAlignment = HorizontalAlignment.Left;
                        body.VerticalAlignment = VerticalAlignment.Bottom;
                        break;
                    case AyLayerDockDirect.CB:
                        body.HorizontalAlignment = HorizontalAlignment.Center;
                        body.VerticalAlignment = VerticalAlignment.Bottom;
                        break;
                    case AyLayerDockDirect.RB:
                        body.HorizontalAlignment = HorizontalAlignment.Right;
                        body.VerticalAlignment = VerticalAlignment.Bottom;
                        break;
                    default:
                        break;
                }
            }

            if (options.IsContainsreplacedleBar)
            {

                d.Height = "40.00".ToGridLength();
                Border b = new Border();
                b.SetResourceReference(Border.BorderBrushProperty, "bordercolorlight");
                b.BorderThickness = options.replacedleBarBorderThickness;
                if (options.CanDrag)
                {
                    SetDragMove(b);
                }
                if (options.LayerCornerRadius.HasValue)
                {
                    b.CornerRadius = new CornerRadius(options.LayerCornerRadius.Value.TopLeft, options.LayerCornerRadius.Value.TopRight, 0, 0);
                }

                b.HorizontalAlignment = HorizontalAlignment.Stretch;
                b.VerticalAlignment = VerticalAlignment.Stretch;
                Grid g = new Grid();
                if (!replacedle.IsNullOrWhiteSpace())
                {
                    AyText tb = new AyText();
                    tb.Width = 200;
                    tb.VerticalAlignment = VerticalAlignment.Center;
                    tb.HorizontalAlignment = HorizontalAlignment.Left;
                    tb.Margin = new Thickness(16, 0, 0, 0);
                    tb.TextWrapping = TextWrapping.NoWrap;
                    tb.SetResourceReference(AyText.FontSizeProperty, "WindowreplacedleFontSize");
                    tb.TextTrimming = TextTrimming.CharacterEllipsis;
                    tb.Text = replacedle;
                    g.Children.Add(tb);
                }

                if (options.CanClose)
                {
                    Button ab = new Button();
                    ab.SetResourceReference(Button.StyleProperty, "AYWin_CLOSE");
                    ab.Click += closewindow_Click;
                    ab.VerticalAlignment = VerticalAlignment.Center;
                    ab.HorizontalAlignment = HorizontalAlignment.Right;
                    ab.Content = Langs.share_close.Lang();
                    ab.Width = 32;
                    ab.Height = 32;
                    ab.Margin = new Thickness(0, 0, 5, 0);
                    g.Children.Add(ab);
                }
                b.Child = g;
                b.SetResourceReference(Border.BackgroundProperty, "colorwhite");
                bodyConent.Children.Add(b);
            }
            else
            {
                if (options.replacedleBar.IsNotNull() && options.CanDrag)
                {
                    SetDragMove(options.replacedleBar);
                }
            }

            if (options.MaskBrush.IsNotNull())
            {
                layoutMain.Background = options.MaskBrush;
            }
            if (isDiaglog)
            {
                if (options.MaskBrush.IsNull())
                {
                    layoutMain.Background = SolidColorBrushConverter.From16JinZhi("#8C000000");
                }
                if (options.WhenShowDialogNeedShake)
                    layoutMain.MouseLeftButtonDown += LayoutMain_MouseLeftButtonDown;
            }

            if (options.IsShowLayerBorder)
            {
                body.SetResourceReference(Border.BorderBrushProperty, "bordercolorlight");

                if (options.LayerBorderThickness.HasValue)
                {
                    body.BorderThickness = options.LayerBorderThickness.Value;
                }
                else
                {
                    body.BorderThickness = new Thickness(1);
                }
            }
            if (options.LayerCornerRadius.HasValue)
            {
                body.CornerRadius = options.LayerCornerRadius.Value;
            }
            options.LayerBackground.Freeze();
            body.Background = options.LayerBackground;

            if (options.ShowAnimateIndex == 0)
            {
                body.Visibility = Visibility.Visible;
                if (options.Opened.IsNotNull())
                {
                    options.Opened();
                }
                body.Loaded += Body_Loaded;

                DropShadowEffect de = new DropShadowEffect();
                de.Color = options.ShadowColor;
                de.ShadowDepth = options.ShadowDepth;
                de.Opacity = 0.1;
                body.Effect = de;
                de.BlurRadius = options.ShadowRadius;
                SetRealPoint(options);

            }
            else if (options.ShowAnimateIndex == 1)
            {
                var sc = new AyAniScale(body, () =>
                {
                    ShowShadow(options);
                });
                sc.AutoDestory = true;
                sc.AnimateSpeed = 450;
                sc.ScaleXFrom = 0;

                sc.ScaleYFrom = 0;
                sc.ScaleXTo = 1;
                sc.ScaleYTo = 1;
                sc.EasingFunction = new System.Windows.Media.Animation.CubicEase { EasingMode = EasingMode.EaseOut };
                sc.Begin();


            }
            else if (options.ShowAnimateIndex == 2)
            {
                var sc = new AyAniSlideInDown(body, () =>
                {
                    ShowShadow(options);
                });
                sc.AutoDestory = true;
                sc.AnimateSpeed = 750;
                sc.FromDistance = -4000;
                sc.OpacityNeed = false;
                sc.EasingFunction = new System.Windows.Media.Animation.CubicEase { EasingMode = EasingMode.EaseOut };
                sc.Begin();
            }
            else if (options.ShowAnimateIndex == 3)
            {
                var sc = new AyAniSlideInUp(body, () =>
                {

                    ShowShadow(options);
                });
                sc.AutoDestory = true;
                sc.AnimateSpeed = 750;
                sc.FromDistance = 4000;
                sc.OpacityNeed = false;
                sc.EasingFunction = new System.Windows.Media.Animation.CubicEase { EasingMode = EasingMode.EaseOut };
                sc.Begin();
            }
            else if (options.ShowAnimateIndex == 4)
            {
                var sc = new AyAniSlideInLeft(body, () =>
                {

                    ShowShadow(options);
                });
                sc.AutoDestory = true;
                sc.AnimateSpeed = 750;
                sc.FromDistance = -4000;
                sc.OpacityNeed = false;
                sc.EasingFunction = new System.Windows.Media.Animation.CubicEase { EasingMode = EasingMode.EaseOut };
                sc.Begin();
            }
            else if (options.ShowAnimateIndex == 5)
            {
                var sc = new AyAniSlideInRight(body, () =>
                {

                    ShowShadow(options);
                });
                sc.AutoDestory = true;
                sc.AnimateSpeed = 750;
                sc.FromDistance = 4000;
                sc.OpacityNeed = false;
                sc.EasingFunction = new System.Windows.Media.Animation.CubicEase { EasingMode = EasingMode.EaseOut };
                sc.Begin();
            }
            else if (options.ShowAnimateIndex == 6)
            {
                var sc = new AyAniBounceInDown(body, () =>
                {

                    ShowShadow(options);
                });
                sc.AutoDestory = true;
                sc.Begin();
            }
            else if (options.ShowAnimateIndex == 7)
            {
                var sc = new AyAniBounceInUp(body, () =>
                {

                    ShowShadow(options);
                });
                sc.AutoDestory = true;
                sc.Begin();
            }
            else if (options.ShowAnimateIndex == 8)
            {
                var sc = new AyAniBounceInLeft(body, () =>
                {

                    ShowShadow(options);
                });
                sc.AutoDestory = true;
                sc.Begin();
            }
            else if (options.ShowAnimateIndex == 9)
            {
                var sc = new AyAniBounceInRight(body, () =>
                {
                    ShowShadow(options);
                });
                sc.AutoDestory = true;
                sc.Begin();
            }
            else if (options.ShowAnimateIndex == 10)
            {
                var sc = new AyAniRotateIn(body, () =>
                {
                    ShowShadow(options);

                });
                sc.AnimateSpeed = 750;
                sc.EasingFunction = new System.Windows.Media.Animation.CubicEase { EasingMode = EasingMode.EaseOut };
                sc.Begin();
            }
            else if (options.ShowAnimateIndex == 11)
            {
                var sc = new AyAniBounceIn(body, () =>
                {
                    ShowShadow(options);
                });
                sc.AutoDestory = true;
                sc.AnimateSpeed = 750;
                sc.Begin();
            }
            else if (options.ShowAnimateIndex == 12)
            {
                var sc = new AyAniBounceInLeft(body, () =>
                {
                    ShowShadow(options);
                });
                sc.AutoDestory = true;
                sc.AnimateSpeed = 750;
                sc.Begin();
            }
            else if (options.ShowAnimateIndex == 13)
            {
                var sc = new AyAniBounceInRight(body, () =>
                {
                    ShowShadow(options);
                });
                sc.AutoDestory = true;
                sc.AnimateSpeed = 750;
                sc.Begin();
            }
            else if (options.ShowAnimateIndex == 14)
            {
                var sc = new AyAniBounceInDown(body, () =>
                {
                    ShowShadow(options);
                });
                sc.AutoDestory = true;
                sc.AnimateSpeed = 750;
                sc.Begin();
            }
            else if (options.ShowAnimateIndex == 15)
            {
                var sc = new AyAniBounceInUp(body, () =>
                {
                    ShowShadow(options);
                });
                sc.AutoDestory = true;
                sc.AnimateSpeed = 750;
                sc.Begin();
            }


        }

19 Source : TransitionPresenter.cs
with MIT License
from ay2015

private void BeginTransition()
        {
            TransitionSelector selector = TransitionSelector;

            Transition transition = selector != null ?
                selector.SelectTransition(CurrentContentPresenter.Content, Content) :
                Transition;

            if (transition != null)
            {
                // Swap content presenters
                AdornerDecorator temp = _previousHost;
                _previousHost = _currentHost;
                _currentHost = temp;
            }

            ContentPresenter currentContent = CurrentContentPresenter;
            // Set the current content
            currentContent.Content = Content;
            currentContent.ContentTemplate = ContentTemplate;
            currentContent.ContentTemplateSelector = ContentTemplateSelector;

            if (transition != null)
            {
                ContentPresenter previousContent = PreviousContentPresenter;

                if (transition.IsNewContentTopmost)
                    Children.Add(_currentHost);
                else
                    Children.Insert(0, _currentHost);

                IsTransitioning = true;
                _activeTransition = transition;
                CoerceValue(TransitionProperty);
                CoerceValue(ClipToBoundsProperty);
                transition.BeginTransition(this, previousContent, currentContent);
            }
        }

19 Source : AyIconAll.cs
with MIT License
from ay2015

public Viewbox GetMoreIcon()
        {
            var xc = (from c in PathIcon.Instance.xmlDoc.Descendants(Icon)
                      select c).FirstOrDefault();
            if (xc != null)
            {
                //拆分path
                string nv = $"<ay>{xc.Value}</ay>";
                var xd = XDoreplacedent.Parse(nv);
                var results = from c in xd.Descendants("path")
                              select c;
                Viewbox vb = new Viewbox();
                Binding bindingWidth = new Binding { Path = new PropertyPath("Width"), Source = this, Mode = BindingMode.TwoWay, TargetNullValue = 16.00 };
                vb.SetBinding(Viewbox.WidthProperty, bindingWidth);
                Binding bindingHeight = new Binding { Path = new PropertyPath("Height"), Source = this, Mode = BindingMode.TwoWay, TargetNullValue = 16.00 };
                vb.SetBinding(Viewbox.HeightProperty, bindingHeight);
                Grid g = new Grid();
                vb.Child = g;
                Brush defaultFil = null;

                var _hasbg = xc.Attribute("main");
                if (_hasbg != null && _hasbg.Value == "1")
                {
                    Foreground = null;
                }
                if (Foreground == null)
                {
                    var _hasFill = xc.Attribute("fil");
                    if (_hasFill != null && _hasFill.Value != "")
                    {
                        defaultFil = HexToBrush.FromHex(_hasFill.Value);
                    }

                    foreach (var result in results)
                    {
                        if (!string.IsNullOrEmpty(result.Attribute("d").Value))
                        {
                            Path p = new Path();
                            p.Data = PathGeometry.Parse(result.Attribute("d").Value);
                            if (defaultFil != null)
                            {
                                p.Fill = defaultFil;
                            }
                            else
                            {
                                var yanse = result.Attribute("fill");
                                if (yanse != null && yanse.Value != "")
                                {
                                    p.Fill = HexToBrush.FromHex(yanse.Value);
                                }
                                else
                                {

                                    var _hasEFill = xc.Attribute("efil");
                                    if (_hasEFill != null && _hasEFill.Value != "")
                                    {
                                        p.Fill = HexToBrush.FromHex(_hasEFill.Value);
                                    }
                                    else
                                    {
                                        if (EFil != null)
                                        {
                                            Binding bindingEfill = new Binding { Path = new PropertyPath("EFil"), Source = this, Mode = BindingMode.TwoWay };
                                            p.SetBinding(Path.FillProperty, bindingEfill);
                                        }
                                    }


                                }
                            }
                            g.Children.Add(p);
                        }
                    }
                }
                else
                {
                    foreach (var result in results)
                    {
                        if (!string.IsNullOrEmpty(result.Attribute("d").Value))
                        {
                            Path p = new Path();
                            p.Data = PathGeometry.Parse(result.Attribute("d").Value);
                            Binding bindingFill = new Binding { Path = new PropertyPath("Foreground"), Source = this, Mode = BindingMode.TwoWay };
                            p.SetBinding(Path.FillProperty, bindingFill);
                            Binding bindingStroke = new Binding { Path = new PropertyPath("Stroke"), Source = this, Mode = BindingMode.TwoWay };
                            p.SetBinding(Path.StrokeProperty, bindingStroke);

                            Binding bindingStrokeThickness = new Binding { Path = new PropertyPath("StrokeThickness"), Source = this, Mode = BindingMode.TwoWay };
                            p.SetBinding(Path.StrokeThicknessProperty, bindingStrokeThickness);

                            g.Children.Add(p);
                        }
                    }
                }
                Binding bindingStretch = new Binding { Path = new PropertyPath("Stretch"), Source = this, Mode = BindingMode.TwoWay };
                vb.SetBinding(Viewbox.StretchProperty, bindingStretch);
                return vb;
            }
            return null;
        }

See More Examples