コード例 #1
0
        private void LoadStartIcons()
        {
            var panel = this.FindControl <DockPanel>("IconPanel");

            foreach (var item in _theme.LaunchItems)
            {
                var iconButton = new Button();
                Projektanker.Icons.Avalonia.Attached.SetIcon(iconButton, item.IconName);
                iconButton.Click   += OnButtonClick;
                iconButton.FontSize = 30;
                iconButton.Width    = 80;
                iconButton.Height   = 80;
                var bgStyle = new Style();
                var bgSet   = new Setter();
                bgSet.Property = BackgroundProperty;
                bgSet.Value    = SolidColorBrush.Parse(_theme.HexTextColor); // change this to a unique setting in Theme.cs
                bgStyle.Setters.Add(bgSet);
                iconButton.Styles.Add(bgStyle);
                iconButton.Click += (sender, args) =>
                {
                    ProcessStartInfo startInfo = new() { FileName = item.LaunchCommand };
                    Process          proc      = new() { StartInfo = startInfo, };
                    proc.Start();
                };
                panel.Children.Add(iconButton);
            }
        }
コード例 #2
0
 void Update_LaunchpadStyle()
 {
     for (int i = 0; i < 100; i++)
     {
         Elements[i].Fill = IsPhantom(i)? SolidColorBrush.Parse("Transparent") : Elements[i].Stroke;
     }
 }
コード例 #3
0
        private Control CreateCallerCell(double x, double y, string text)
        {
            var root = new Border()
            {
                Classes         = Classes.Parse("CallerCell"),
                RenderTransform = new TranslateTransform(x, y),
                Background      = SolidColorBrush.Parse("Transparent"),
                Child           = new Grid()
                {
                    Children =
                    {
                        new Border()
                        {
                            Name = "PointerEnterFeedback",
                        },
                        new TextBlock()
                        {
                            Text = text
                        }
                    }
                }
            };

            return(root);
        }
コード例 #4
0
        /// <summary>
        /// The default template for the <see cref="TextBox"/> control.
        /// </summary>
        /// <param name="control">The control being styled.</param>
        /// <returns>The root of the instantiated template.</returns>
        public static Control Template(TextBox control)
        {
            Border result = new Border
            {
                Name    = "border",
                Padding = new Thickness(2),
                [~Border.BackgroundProperty]      = control[~TemplatedControl.BackgroundProperty],
                [~Border.BorderBrushProperty]     = control[~TemplatedControl.BorderBrushProperty],
                [~Border.BorderThicknessProperty] = control[~TemplatedControl.BorderThicknessProperty],

                Child = new ScrollViewer
                {
                    [~ScrollViewer.CanScrollHorizontallyProperty]         = control[~ScrollViewer.CanScrollHorizontallyProperty],
                    [~ScrollViewer.HorizontalScrollBarVisibilityProperty] = control[~ScrollViewer.HorizontalScrollBarVisibilityProperty],
                    [~ScrollViewer.VerticalScrollBarVisibilityProperty]   = control[~ScrollViewer.VerticalScrollBarVisibilityProperty],
                    Content = new StackPanel
                    {
                        Children = new Controls.Controls
                        {
                            new TextBlock
                            {
                                Name       = "floatingWatermark",
                                Foreground = SolidColorBrush.Parse("#007ACC"),
                                FontSize   = 10,
                                [~TextBlock.TextProperty]      = control[~TextBox.WatermarkProperty],
                                [~TextBlock.IsVisibleProperty] = control[~TextBox.TextProperty].Cast <string>().Select(x => (object)(!string.IsNullOrEmpty(x) && control.UseFloatingWatermark))
                            },
                            new Panel
                            {
                                Children = new Controls.Controls
                                {
                                    new TextBlock
                                    {
                                        Name    = "watermark",
                                        Opacity = 0.5,
                                        [~TextBlock.TextProperty]      = control[~TextBox.WatermarkProperty],
                                        [~TextBlock.IsVisibleProperty] = control[~TextBox.TextProperty].Cast <string>().Select(x => (object)string.IsNullOrEmpty(x))
                                    },
                                    new TextPresenter
                                    {
                                        Name = "textPresenter",
                                        [~TextPresenter.CaretIndexProperty]     = control[~TextBox.CaretIndexProperty],
                                        [~TextPresenter.SelectionStartProperty] = control[~TextBox.SelectionStartProperty],
                                        [~TextPresenter.SelectionEndProperty]   = control[~TextBox.SelectionEndProperty],
                                        [~TextBlock.TextProperty]         = control[~TextBox.TextProperty],
                                        [~TextBlock.TextWrappingProperty] = control[~TextBox.TextWrappingProperty],
                                    }
                                }
                            }
                        }
                    }
                }
            };

            return(result);
        }
コード例 #5
0
ファイル: Radar.cs プロジェクト: SzFMV2020-Osz/AutomatedCar-B
 public Radar(VirtualFunctionBus virtualFunction)
     : base(virtualFunction)
 {
     this.offsetX     = 120;
     this.offsetY     = 0;
     this.rotate      = rotate - 90;
     this.range       = 200 * 50;
     this.angleOfView = 60;
     this.Brush       = SolidColorBrush.Parse("red");
     this.dif         = this.range * Math.Tan((double)this.angleOfView / 2 * (Math.PI / 180));
     this.maxDetect   = Math.Sqrt(Math.Pow(this.range, 2) + Math.Pow(this.range, 2));
 }
コード例 #6
0
ファイル: UndoWindow.cs プロジェクト: vaaski/apollo-studio
        public void HighlightSaved(int?index)
        {
            if (saved.HasValue && saved != current)
            {
                ((UndoEntryInfo)(Contents.Children[saved.Value])).Background = SolidColorBrush.Parse("Transparent");
            }

            if ((saved = index).HasValue && index != current)
            {
                ((UndoEntryInfo)(Contents.Children[saved.Value])).Background = (SolidColorBrush)Application.Current.Styles.FindResource("ThemeControlVeryHighBrush");
            }
        }
コード例 #7
0
ファイル: UndoWindow.cs プロジェクト: vaaski/apollo-studio
        public void HighlightPosition(int index)
        {
            if (current.HasValue)
            {
                ((UndoEntryInfo)(Contents.Children[current.Value])).Background = SolidColorBrush.Parse("Transparent");
            }

            ((UndoEntryInfo)(Contents.Children[(current = index).Value])).Background = (SolidColorBrush)Application.Current.Styles.FindResource("ThemeAccentBrush2");

            if (Program.Project.Undo.SavedPosition.HasValue)
            {
                HighlightSaved(Program.Project.Undo.SavedPosition.Value);
            }
        }
コード例 #8
0
        private void Update_LaunchpadStyle()
        {
            if (LowQuality)
            {
                return;
            }

            for (int i = 0; i < 100; i++)
            {
                if (i == 0 || i == 9 || i == 90 || i == 99)
                {
                    continue;
                }

                ((Path)Grid.Children[i]).Fill = IsPhantom(i)? SolidColorBrush.Parse("Transparent") : ((Path)Grid.Children[i]).Stroke;
            }
        }
コード例 #9
0
        void Update_LaunchpadStyle()
        {
            if (LowQuality)
            {
                return;
            }

            for (int i = 0; i < 100; i++)
            {
                if (i == 0 || i == 9 || i == 90 || i == 99)
                {
                    continue;
                }

                Elements[i].Fill = IsPhantom(i)? SolidColorBrush.Parse("Transparent") : Elements[i].Stroke;
            }
        }
コード例 #10
0
 public static Control TabControlTemplate(TabControl control)
 {
     return(new Grid
     {
         ColumnDefinitions = new ColumnDefinitions
         {
             new ColumnDefinition(GridLength.Auto),
             new ColumnDefinition(new GridLength(1, GridUnitType.Star)),
         },
         Children = new Controls
         {
             new Border
             {
                 Width = 190,
                 Background = SolidColorBrush.Parse("#1976D2"),
                 Child = new ScrollViewer
                 {
                     Content = new TabStrip
                     {
                         Name = "PART_TabStrip",
                         ItemsPanel = new FuncTemplate <IPanel>(() => new StackPanel {
                             Orientation = Orientation.Vertical, Gap = 4
                         }),
                         Margin = new Thickness(0, 10, 0, 0),
                         MemberSelector = TabControl.HeaderSelector,
                         [!ItemsControl.ItemsProperty] = control[!ItemsControl.ItemsProperty],
                         [!!SelectingItemsControl.SelectedItemProperty] = control[!!SelectingItemsControl.SelectedItemProperty],
                     }
                 }
             },
             new Carousel
             {
                 Name = "PART_Content",
                 MemberSelector = TabControl.ContentSelector,
                 [~Carousel.TransitionProperty] = control[~TabControl.TransitionProperty],
                 [!Carousel.ItemsProperty] = control[!ItemsControl.ItemsProperty],
                 [!Carousel.SelectedItemProperty] = control[!SelectingItemsControl.SelectedItemProperty],
                 [Grid.ColumnProperty] = 1,
             }
         }
     });
 }
コード例 #11
0
        private void LoadTheme()
        {
            if (_theme.Source == "File")
            {
                // Background
                //var assets = AvaloniaLocator.Current.GetService<IAssetLoader>();
                var filestream = new FileStream(_theme.BgPath, FileMode.Open);
                var bitmap     = new Bitmap(filestream);
                this.Background = new ImageBrush(bitmap)
                {
                    Stretch = Stretch.UniformToFill
                };                                                                          //! add this to theme settings

                // Text color
                var style = new Style(x => x.OfType <TextBlock>());
                var color = new Setter();
                color.Property = ForegroundProperty;
                color.Value    = SolidColorBrush.Parse(_theme.HexTextColor);
                style.Setters.Add(color);
                var menustyle = new Style(x => x.OfType <MenuItem>());
                menustyle.Setters.Add(color);

                // Text size
                var size = new Setter();
                size.Property = TextBlock.FontSizeProperty;
                size.Value    = _theme.FontSize;
                style.Setters.Add(size);


                this.Styles.Add(style);

                var clock = this.FindControl <TextBlock>("Clock");
                clock.Text = DateTime.Now.ToString("t");

                _clockTimer          = new Timer();
                _clockTimer.Interval = 10000;
                _clockTimer.Elapsed += ChangeTime;
                _clockTimer.Start();
            }
        }
コード例 #12
0
    public SpectrumControl()
    {
        _data = new float[NumBins];
        _auraSpectrumDataSource = new AuraSpectrumDataSource(NumBins);
        _splashEffectDataSource = new SplashEffectDataSource(NumBins);

        _sources = new SpectrumDataSource[] { _auraSpectrumDataSource, _splashEffectDataSource };

        _lineBrush = SolidColorBrush.Parse("#97D234").ToImmutable();

        Background = new RadialGradientBrush()
        {
            GradientStops =
            {
                new GradientStop {
                    Color = Color.Parse("#00000D21"), Offset = 0
                },
                new GradientStop {
                    Color = Color.Parse("#FF000D21"), Offset = 1
                }
            }
        };
    }
コード例 #13
0
     private void OnTimedEventFlash(object sender, EventArgs e)
     {
         // TODO: make avalonia animation instead this method
         if (displayFlash % 2 == 0)
         {
             WidgetColor = new WidgetColor
             {
                 TimeColor     = SolidColorBrush.Parse("#320100"),
                 WeatherColor  = SolidColorBrush.Parse("#320100"),
                 TimerColor    = SolidColorBrush.Parse("#320100"),
                 TodoListColor = SolidColorBrush.Parse("#320100"),
                 NewsColor     = SolidColorBrush.Parse("#320100"),
                 EngWordColor  = SolidColorBrush.Parse("#320100")
             }
         }
         ;
         else
         {
             WidgetColor = new WidgetColor
             {
                 TimeColor     = SolidColorBrush.Parse("#505356"),
                 WeatherColor  = SolidColorBrush.Parse("#3F4041"),
                 TimerColor    = SolidColorBrush.Parse("#282828"),
                 TodoListColor = SolidColorBrush.Parse("#252328"),
                 NewsColor     = SolidColorBrush.Parse("#4E4C48"),
                 EngWordColor  = SolidColorBrush.Parse("#393E41")
             }
         };
         displayFlash++;
         if (displayFlash >= 12)
         {
             displayFlash = 0;
             timerFlash.Stop();
         }
     }
 }
コード例 #14
0
ファイル: MainWindow.cs プロジェクト: Serg2DFX/Perspex
        private static TabItem ImagesTab()
        {
            var imageCarousel = new Carousel
            {
                Width      = 400,
                Height     = 400,
                Transition = new PageSlide(TimeSpan.FromSeconds(0.25)),
                Items      = new[]
                {
                    new Image {
                        Source = new Bitmap(GetImage("github_icon.png")), Width = 400, Height = 400
                    },
                    new Image {
                        Source = new Bitmap(GetImage("pattern.jpg")), Width = 400, Height = 400
                    },
                }
            };

            var next = new Button
            {
                VerticalAlignment = VerticalAlignment.Center,
                Padding           = new Thickness(20),
                Content           = new Perspex.Controls.Shapes.Path
                {
                    Data = StreamGeometry.Parse("M4,11V13H16L10.5,18.5L11.92,19.92L19.84,12L11.92,4.08L10.5,5.5L16,11H4Z"),
                    Fill = Brushes.Black
                }
            };

            var prev = new Button
            {
                VerticalAlignment = VerticalAlignment.Center,
                Padding           = new Thickness(20),
                Content           = new Perspex.Controls.Shapes.Path
                {
                    Data = StreamGeometry.Parse("M20,11V13H8L13.5,18.5L12.08,19.92L4.16,12L12.08,4.08L13.5,5.5L8,11H20Z"),
                    Fill = Brushes.Black
                }
            };

            prev.Click += (s, e) =>
            {
                if (imageCarousel.SelectedIndex == 0)
                {
                    imageCarousel.SelectedIndex = 1;
                }
                else
                {
                    imageCarousel.SelectedIndex--;
                }
            };

            next.Click += (s, e) =>
            {
                if (imageCarousel.SelectedIndex == 1)
                {
                    imageCarousel.SelectedIndex = 0;
                }
                else
                {
                    imageCarousel.SelectedIndex++;
                }
            };

            return(new TabItem
            {
                Header = "Images",
                Content = new ScrollViewer
                {
                    Content = new StackPanel
                    {
                        HorizontalAlignment = HorizontalAlignment.Left,
                        Orientation = Orientation.Vertical,
                        VerticalAlignment = VerticalAlignment.Top,
                        Gap = 4,
                        Margin = new Thickness(10),
                        Children = new Controls
                        {
                            new TextBlock
                            {
                                Text = "Carousel",
                                FontWeight = FontWeight.Medium,
                                FontSize = 20,
                                Foreground = SolidColorBrush.Parse("#212121"),
                            },
                            new TextBlock
                            {
                                Text = "An items control that displays its items as pages that fill the controls.",
                                FontSize = 13,
                                Foreground = SolidColorBrush.Parse("#727272"),
                                Margin = new Thickness(0, 0, 0, 10)
                            },
                            new StackPanel
                            {
                                Name = "carouselVisual",
                                Orientation = Orientation.Horizontal,
                                Gap = 4,
                                Children = new Controls
                                {
                                    prev,
                                    imageCarousel,
                                    next
                                }
                            }
                        }
                    }
                }
            });
        }
コード例 #15
0
ファイル: MainWindow.cs プロジェクト: Serg2DFX/Perspex
 private static TabItem ListsTab()
 {
     return(new TabItem
     {
         Header = "Lists",
         Content = new ScrollViewer()
         {
             CanScrollHorizontally = false,
             Content = new StackPanel
             {
                 HorizontalAlignment = HorizontalAlignment.Left,
                 Orientation = Orientation.Vertical,
                 VerticalAlignment = VerticalAlignment.Top,
                 Gap = 4,
                 Margin = new Thickness(10),
                 DataTemplates = new DataTemplates
                 {
                     new FuncDataTemplate <Item>(x =>
                                                 new StackPanel
                     {
                         Gap = 4,
                         Orientation = Orientation.Horizontal,
                         Children = new Controls
                         {
                             new Image {
                                 Width = 50, Height = 50, Source = new Bitmap(GetImage("github_icon.png"))
                             },
                             new TextBlock {
                                 Text = x.Name, FontSize = 18
                             }
                         }
                     })
                 },
                 Children = new Controls
                 {
                     new TextBlock
                     {
                         Text = "ListBox",
                         FontWeight = FontWeight.Medium,
                         FontSize = 20,
                         Foreground = SolidColorBrush.Parse("#212121"),
                     },
                     new TextBlock
                     {
                         Text = "A list box control.",
                         FontSize = 13,
                         Foreground = SolidColorBrush.Parse("#727272"),
                         Margin = new Thickness(0, 0, 0, 10)
                     },
                     new ListBox
                     {
                         BorderThickness = 2,
                         Items = s_listBoxData,
                         Height = 300,
                         Width = 300,
                     },
                     new TextBlock
                     {
                         Margin = new Thickness(0, 40, 0, 0),
                         Text = "TreeView",
                         FontWeight = FontWeight.Medium,
                         FontSize = 20,
                         Foreground = SolidColorBrush.Parse("#212121"),
                     },
                     new TextBlock
                     {
                         Text = "A tree view control.",
                         FontSize = 13,
                         Foreground = SolidColorBrush.Parse("#727272"),
                         Margin = new Thickness(0, 0, 0, 10)
                     },
                     new TreeView
                     {
                         Name = "treeView",
                         Items = s_treeData,
                         Height = 300,
                         BorderThickness = 2,
                         Width = 300,
                     }
                 }
             },
         }
     });
 }
コード例 #16
0
ファイル: MainWindow.cs プロジェクト: Serg2DFX/Perspex
        private static TabItem TextTab()
        {
            return(new TabItem
            {
                Header = "Input",
                Content = new ScrollViewer()
                {
                    Content = new StackPanel
                    {
                        Margin = new Thickness(10),
                        Orientation = Orientation.Vertical,
                        Gap = 4,
                        Children = new Controls
                        {
                            new TextBlock
                            {
                                Text = "TextBox",
                                FontWeight = FontWeight.Medium,
                                FontSize = 20,
                                Foreground = SolidColorBrush.Parse("#212121"),
                            },
                            new TextBlock
                            {
                                Text = "A text box control",
                                FontSize = 13,
                                Foreground = SolidColorBrush.Parse("#727272"),
                                Margin = new Thickness(0, 0, 0, 10)
                            },

                            new TextBox {
                                Text = "Lorem ipsum dolor sit amet, consectetur adipiscing elit.", Width = 200
                            },
                            new TextBox {
                                Width = 200, Watermark = "Watermark"
                            },
                            new TextBox {
                                Width = 200, Watermark = "Floating Watermark", UseFloatingWatermark = true
                            },
                            new TextBox {
                                AcceptsReturn = true, TextWrapping = TextWrapping.Wrap, Width = 200, Height = 150, Text = "Lorem ipsum dolor sit amet, consectetur adipiscing elit. Vivamus magna. Cras in mi at felis aliquet congue. Ut a est eget ligula molestie gravida. Curabitur massa. Donec eleifend, libero at sagittis mollis, tellus est malesuada tellus, at luctus turpis elit sit amet quam. Vivamus pretium ornare est."
                            },
                            new TextBlock
                            {
                                Margin = new Thickness(0, 40, 0, 0),
                                Text = "CheckBox",
                                FontWeight = FontWeight.Medium,
                                FontSize = 20,
                                Foreground = SolidColorBrush.Parse("#212121"),
                            },
                            new TextBlock
                            {
                                Text = "A check box control",
                                FontSize = 13,
                                Foreground = SolidColorBrush.Parse("#727272"),
                                Margin = new Thickness(0, 0, 0, 10)
                            },
                            new CheckBox {
                                IsChecked = true, Margin = new Thickness(0, 0, 0, 5), Content = "Checked"
                            },
                            new CheckBox {
                                IsChecked = false, Content = "Unchecked"
                            },
                            new TextBlock
                            {
                                Margin = new Thickness(0, 40, 0, 0),
                                Text = "RadioButton",
                                FontWeight = FontWeight.Medium,
                                FontSize = 20,
                                Foreground = SolidColorBrush.Parse("#212121"),
                            },
                            new TextBlock
                            {
                                Text = "A radio button control",
                                FontSize = 13,
                                Foreground = SolidColorBrush.Parse("#727272"),
                                Margin = new Thickness(0, 0, 0, 10)
                            },
                            new RadioButton {
                                IsChecked = true, Content = "Option 1"
                            },
                            new RadioButton {
                                IsChecked = false, Content = "Option 2"
                            },
                            new RadioButton {
                                IsChecked = false, Content = "Option 3"
                            },
                        }
                    }
                }
            });
        }
コード例 #17
0
ファイル: MainWindow.cs プロジェクト: Serg2DFX/Perspex
        private static TabItem HtmlTab()
        {
            return(new TabItem
            {
                Header = "Text",
                Content = new ScrollViewer()
                {
                    CanScrollHorizontally = false,
                    Content = new StackPanel()
                    {
                        Margin = new Thickness(10),
                        Orientation = Orientation.Vertical,
                        Gap = 4,
                        Children = new Controls
                        {
                            new TextBlock
                            {
                                Text = "TextBlock",
                                FontWeight = FontWeight.Medium,
                                FontSize = 20,
                                Foreground = SolidColorBrush.Parse("#212121"),
                            },
                            new TextBlock
                            {
                                Text = "A control for displaying text.",
                                FontSize = 13,
                                Foreground = SolidColorBrush.Parse("#727272"),
                                Margin = new Thickness(0, 0, 0, 10)
                            },
                            new TextBlock
                            {
                                Text = "Lorem ipsum dolor sit amet, consectetuer adipiscing elit.",
                                FontSize = 11
                            },
                            new TextBlock
                            {
                                Text = "Lorem ipsum dolor sit amet, consectetuer adipiscing elit.",
                                FontSize = 11,
                                FontWeight = FontWeight.Medium
                            },
                            new TextBlock
                            {
                                Text = "Lorem ipsum dolor sit amet, consectetuer adipiscing elit.",
                                FontSize = 11,
                                FontWeight = FontWeight.Bold
                            },
                            new TextBlock
                            {
                                Text = "Lorem ipsum dolor sit amet, consectetuer adipiscing elit.",
                                FontSize = 11,
                                FontStyle = FontStyle.Italic,
                            },
                            new TextBlock
                            {
                                Margin = new Thickness(0, 40, 0, 0),
                                Text = "HtmlLabel",
                                FontWeight = FontWeight.Medium,
                                FontSize = 20,
                                Foreground = SolidColorBrush.Parse("#212121"),
                            },
                            new TextBlock
                            {
                                Text = "A label capable of displaying HTML content",
                                FontSize = 13,
                                Foreground = SolidColorBrush.Parse("#727272"),
                                Margin = new Thickness(0, 0, 0, 10)
                            },
                            new HtmlLabel
                            {
                                Background = SolidColorBrush.Parse("#CCCCCC"),
                                Padding = new Thickness(5),
                                Text = @"<p><strong>Pellentesque habitant morbi tristique</strong> senectus et netus et malesuada fames ac turpis egestas. Vestibulum tortor quam, feugiat vitae, ultricies eget, tempor sit amet, ante. Donec eu libero sit amet quam egestas semper. <em>Aenean ultricies mi vitae est.</em> Mauris placerat eleifend leo. Quisque sit amet est et sapien ullamcorper pharetra. Vestibulum erat wisi, condimentum sed, <code>commodo vitae</code>, ornare sit amet, wisi. Aenean fermentum, elit eget tincidunt condimentum, eros ipsum rutrum orci, sagittis tempus lacus enim ac dui. <a href=""#"">Donec non enim</a> in turpis pulvinar facilisis. Ut felis.</p>
										<h2>Header Level 2</h2>
											       
										<ol>
										   <li>Lorem ipsum dolor sit amet, consectetuer adipiscing elit.</li>
										   <li>Aliquam tincidunt mauris eu risus.</li>
										</ol>

										<blockquote><p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Vivamus magna. Cras in mi at felis aliquet congue. Ut a est eget ligula molestie gravida. Curabitur massa. Donec eleifend, libero at sagittis mollis, tellus est malesuada tellus, at luctus turpis elit sit amet quam. Vivamus pretium ornare est.</p></blockquote>

										<h3>Header Level 3</h3>

										<ul>
										   <li>Lorem ipsum dolor sit amet, consectetuer adipiscing elit.</li>
										   <li>Aliquam tincidunt mauris eu risus.</li>
										</ul>"
                            }
                        }
                    }
                }
            });
        }
コード例 #18
0
ファイル: MainWindow.cs プロジェクト: Serg2DFX/Perspex
        private static TabItem ButtonsTab()
        {
            var result = new TabItem
            {
                Header  = "Button",
                Content = new ScrollViewer()
                {
                    CanScrollHorizontally = false,
                    Content = new StackPanel
                    {
                        Margin      = new Thickness(10),
                        Orientation = Orientation.Vertical,
                        Gap         = 4,
                        Children    = new Controls
                        {
                            new TextBlock
                            {
                                Text       = "Button",
                                FontWeight = FontWeight.Medium,
                                FontSize   = 20,
                                Foreground = SolidColorBrush.Parse("#212121"),
                            },
                            new TextBlock
                            {
                                Text       = "A button control",
                                FontSize   = 13,
                                Foreground = SolidColorBrush.Parse("#727272"),
                                Margin     = new Thickness(0, 0, 0, 10)
                            },
                            new Button
                            {
                                Width   = 150,
                                Content = "Button"
                            },
                            new Button
                            {
                                Width     = 150,
                                Content   = "Disabled",
                                IsEnabled = false,
                            },
                            new TextBlock
                            {
                                Margin     = new Thickness(0, 40, 0, 0),
                                Text       = "ToggleButton",
                                FontWeight = FontWeight.Medium,
                                FontSize   = 20,
                                Foreground = SolidColorBrush.Parse("#212121"),
                            },
                            new TextBlock
                            {
                                Text       = "A toggle button control",
                                FontSize   = 13,
                                Foreground = SolidColorBrush.Parse("#727272"),
                                Margin     = new Thickness(0, 0, 0, 10)
                            },
                            new ToggleButton
                            {
                                Width     = 150,
                                IsChecked = true,
                                Content   = "On"
                            },
                            new ToggleButton
                            {
                                Width     = 150,
                                IsChecked = false,
                                Content   = "Off"
                            },
                        }
                    }
                },
            };


            return(result);
        }
コード例 #19
0
        public MainWindow()
        {
            InitializeComponent();
            this.AttachDevTools();

            var tilePanel = new TilePanelViewModel()
            {
                ItemHeight           = 130,
                ItemWidth            = 230,
                MaximumRowsOrColumns = 3,
                Tiles = new ObservableCollection <TileViewModel>()
                {
                    new TileViewModel()
                    {
                        ColumnSpan  = 1,
                        RowSpan     = 1,
                        ColumnSpans = new List <int>()
                        {
                            1, 1, 1
                        },
                        RowSpans = new List <int>()
                        {
                            1, 1, 1
                        },
                        Background = SolidColorBrush.Parse("Red")
                    },
                    new TileViewModel()
                    {
                        ColumnSpan  = 1,
                        RowSpan     = 1,
                        ColumnSpans = new List <int>()
                        {
                            1, 1, 1
                        },
                        RowSpans = new List <int>()
                        {
                            1, 1, 1
                        },
                        Background = SolidColorBrush.Parse("Green")
                    },
                    new TileViewModel()
                    {
                        ColumnSpan  = 1,
                        RowSpan     = 1,
                        ColumnSpans = new List <int>()
                        {
                            1, 1, 1
                        },
                        RowSpans = new List <int>()
                        {
                            1, 1, 1
                        },
                        Background = SolidColorBrush.Parse("Blue")
                    },
                    new TileViewModel()
                    {
                        ColumnSpan  = 1,
                        RowSpan     = 2,
                        ColumnSpans = new List <int>()
                        {
                            1, 1, 1
                        },
                        RowSpans = new List <int>()
                        {
                            1, 2, 2
                        },
                        Background = SolidColorBrush.Parse("Yellow")
                    },
                    new TileViewModel()
                    {
                        ColumnSpan  = 2,
                        RowSpan     = 2,
                        ColumnSpans = new List <int>()
                        {
                            2, 2, 2
                        },
                        RowSpans = new List <int>()
                        {
                            2, 2, 2
                        },
                        Background = SolidColorBrush.Parse("Black")
                    },
                }
            };

            var itemsPanel = this.FindControl <ItemsControl>("ItemsControl");

            double tileAspectRation = 0.5;

            itemsPanel.GetObservable(BoundsProperty).Subscribe(x =>
            {
                var width      = x.Width;
                var itemWidth  = width / tilePanel.MaximumRowsOrColumns;
                var itemHeight = itemWidth * tileAspectRation;

                tilePanel.ItemHeight = itemHeight;
                tilePanel.ItemWidth  = itemWidth;
            });

            DataContext = tilePanel;
        }
コード例 #20
0
 public void OnStartButton()
 {
     // don't allow to start with default values
     if (TimerModel.Hours == 0 && TimerModel.Minutes == 0 && TimerModel.Seconds == 0)
     {
         return;
     }
     if (ButtonStatModel.IsTimerStarted == false)
     {
         ButtonStatModel = new ButtonStatModel {
             IsTimerStarted = true, IsTimerTicking = true, Text = "Пауза", ButtonColor = SolidColorBrush.Parse("#3D2809"), TextColor = SolidColorBrush.Parse("#D67E00")
         };
         timerHours   = TimerModel.Hours;
         timerMinutes = TimerModel.Minutes;
         timerSeconds = TimerModel.Seconds;
         timer        = new TimeSpan(TimerModel.Hours, TimerModel.Minutes, TimerModel.Seconds);
         timerTimer.Start();
     }
     else
     {
         if (ButtonStatModel.IsTimerTicking == true)
         {
             timerTimer.Stop();
             ButtonStatModel = new ButtonStatModel {
                 IsTimerStarted = true, IsTimerTicking = false, Text = "Дальше", ButtonColor = SolidColorBrush.Parse("#1A361F"), TextColor = SolidColorBrush.Parse("#56D45B")
             };
         }
         else
         {
             timerTimer.Start();
             ButtonStatModel = new ButtonStatModel {
                 IsTimerStarted = true, IsTimerTicking = true, Text = "Пауза", ButtonColor = SolidColorBrush.Parse("#3D2809"), TextColor = SolidColorBrush.Parse("#D67E00")
             };
         }
     }
 }
コード例 #21
0
 public void UpdateStyle()
 => Path.Fill = IsPhantom()? SolidColorBrush.Parse("Transparent") : Path.Stroke;
コード例 #22
0
ファイル: MainWindow.cs プロジェクト: Serg2DFX/Perspex
        private static TabItem LayoutTab()
        {
            return(new TabItem
            {
                Header = "Layout",
                Content = new ScrollViewer
                {
                    Content = new StackPanel
                    {
                        HorizontalAlignment = HorizontalAlignment.Left,
                        Orientation = Orientation.Vertical,
                        VerticalAlignment = VerticalAlignment.Top,
                        Gap = 4,
                        Margin = new Thickness(10),
                        Children = new Controls
                        {
                            new TextBlock
                            {
                                Text = "Grid",
                                FontWeight = FontWeight.Medium,
                                FontSize = 20,
                                Foreground = SolidColorBrush.Parse("#212121"),
                            },
                            new TextBlock
                            {
                                Text = "Lays out child controls according to a grid.",
                                FontSize = 13,
                                Foreground = SolidColorBrush.Parse("#727272"),
                                Margin = new Thickness(0, 0, 0, 10)
                            },
                            new Grid
                            {
                                Width = 600,
                                ColumnDefinitions = new ColumnDefinitions
                                {
                                    new ColumnDefinition(1, GridUnitType.Star),
                                    new ColumnDefinition(1, GridUnitType.Star),
                                },

                                RowDefinitions = new RowDefinitions
                                {
                                    new RowDefinition(1, GridUnitType.Auto),
                                    new RowDefinition(1, GridUnitType.Auto)
                                },
                                Children = new Controls
                                {
                                    new Rectangle
                                    {
                                        Fill = SolidColorBrush.Parse("#FF5722"),
                                        [Grid.ColumnSpanProperty] = 2,
                                        Height = 200,
                                        Margin = new Thickness(2.5)
                                    },
                                    new Rectangle
                                    {
                                        Fill = SolidColorBrush.Parse("#FF5722"),
                                        [Grid.RowProperty] = 1,
                                        Height = 100,
                                        Margin = new Thickness(2.5)
                                    },
                                    new Rectangle
                                    {
                                        Fill = SolidColorBrush.Parse("#FF5722"),
                                        [Grid.RowProperty] = 1,
                                        [Grid.ColumnProperty] = 1,
                                        Height = 100,
                                        Margin = new Thickness(2.5)
                                    },
                                },
                            },
                            new TextBlock
                            {
                                Margin = new Thickness(0, 40, 0, 0),
                                Text = "StackPanel",
                                FontWeight = FontWeight.Medium,
                                FontSize = 20,
                                Foreground = SolidColorBrush.Parse("#212121"),
                            },
                            new TextBlock
                            {
                                Text = "A panel which lays out its children horizontally or vertically.",
                                FontSize = 13,
                                Foreground = SolidColorBrush.Parse("#727272"),
                                Margin = new Thickness(0, 0, 0, 10)
                            },
                            new StackPanel
                            {
                                Orientation = Orientation.Vertical,
                                Gap = 4,
                                Width = 300,
                                Children = new Controls
                                {
                                    new Rectangle
                                    {
                                        Fill = SolidColorBrush.Parse("#FFC107"),
                                        Height = 50,
                                    },
                                    new Rectangle
                                    {
                                        Fill = SolidColorBrush.Parse("#FFC107"),
                                        Height = 50,
                                    },
                                    new Rectangle
                                    {
                                        Fill = SolidColorBrush.Parse("#FFC107"),
                                        Height = 50,
                                    },
                                }
                            },
                            new TextBlock
                            {
                                Margin = new Thickness(0, 40, 0, 0),
                                Text = "Canvas",
                                FontWeight = FontWeight.Medium,
                                FontSize = 20,
                                Foreground = SolidColorBrush.Parse("#212121"),
                            },
                            new TextBlock
                            {
                                Text = "A panel which lays out its children by explicit coordinates.",
                                FontSize = 13,
                                Foreground = SolidColorBrush.Parse("#727272"),
                                Margin = new Thickness(0, 0, 0, 10)
                            },
                            new Canvas
                            {
                                Background = Brushes.Yellow,
                                Width = 300,
                                Height = 400,
                                Children = new Controls
                                {
                                    new Rectangle
                                    {
                                        Fill = Brushes.Blue,
                                        Width = 63,
                                        Height = 41,
                                        [Canvas.LeftProperty] = 40,
                                        [Canvas.TopProperty] = 31,
                                    },
                                    new Ellipse
                                    {
                                        Fill = Brushes.Green,
                                        Width = 58,
                                        Height = 58,
                                        [Canvas.LeftProperty] = 130,
                                        [Canvas.TopProperty] = 79,
                                    },
                                }
                            },
                        }
                    }
                }
            });
        }
コード例 #23
0
 // push on cancel button or call from method
 public void OnCancelButton()
 {
     timerTimer.Stop();
     ButtonStatModel = new ButtonStatModel {
         IsTimerStarted = false, IsTimerTicking = false, Text = "Старт", ButtonColor = SolidColorBrush.Parse("#1A361F"), TextColor = SolidColorBrush.Parse("#56D45B")
     };
     TimerModel = new TimerModel {
         Hours = timerHours, Minutes = timerMinutes, Seconds = timerSeconds
     };
 }
コード例 #24
0
ファイル: MainWindow.cs プロジェクト: Serg2DFX/Perspex
        private static TabItem AnimationsTab()
        {
            Border          border1;
            Border          border2;
            RotateTransform rotate;
            Button          button1;

            var result = new TabItem
            {
                Header  = "Animations",
                Content = new StackPanel
                {
                    Orientation = Orientation.Vertical,
                    Gap         = 4,
                    Margin      = new Thickness(10),
                    Children    = new Controls
                    {
                        new TextBlock
                        {
                            Text       = "Animations",
                            FontWeight = FontWeight.Medium,
                            FontSize   = 20,
                            Foreground = SolidColorBrush.Parse("#212121"),
                        },
                        new TextBlock
                        {
                            Text       = "A few animations showcased below",
                            FontSize   = 13,
                            Foreground = SolidColorBrush.Parse("#727272"),
                            Margin     = new Thickness(0, 0, 0, 10)
                        },
                        (button1 = new Button
                        {
                            Content = "Animate",
                            Width = 120,
                            [Grid.ColumnProperty] = 1,
                            [Grid.RowProperty] = 1,
                        }),
                        new Canvas
                        {
                            ClipToBounds = false,
                            Children     = new Controls
                            {
                                (border1 = new Border
                                {
                                    Width = 100,
                                    Height = 100,
                                    HorizontalAlignment = HorizontalAlignment.Center,
                                    VerticalAlignment = VerticalAlignment.Center,
                                    Background = Brushes.Crimson,
                                    RenderTransform = new RotateTransform(),
                                    Child = new Grid
                                    {
                                        Children = new Controls
                                        {
                                            new Ellipse()
                                            {
                                                Width = 100,
                                                Height = 100,
                                                Fill =
                                                    new RadialGradientBrush()
                                                {
                                                    GradientStops =
                                                    {
                                                        new GradientStop(Colors.Blue,  0),
                                                        new GradientStop(Colors.Green, 1)
                                                    },
                                                    Radius = 75
                                                }
                                            },
                                            new Perspex.Controls.Shapes.Path
                                            {
                                                Data =
                                                    StreamGeometry.Parse(
                                                        "F1 M 16.6309,18.6563C 17.1309,8.15625 29.8809,14.1563 29.8809,14.1563C 30.8809,11.1563 34.1308,11.4063 34.1308,11.4063C 33.5,12 34.6309,13.1563 34.6309,13.1563C 32.1309,13.1562 31.1309,14.9062 31.1309,14.9062C 41.1309,23.9062 32.6309,27.9063 32.6309,27.9062C 24.6309,24.9063 21.1309,22.1562 16.6309,18.6563 Z M 16.6309,19.9063C 21.6309,24.1563 25.1309,26.1562 31.6309,28.6562C 31.6309,28.6562 26.3809,39.1562 18.3809,36.1563C 18.3809,36.1563 18,38 16.3809,36.9063C 15,36 16.3809,34.9063 16.3809,34.9063C 16.3809,34.9063 10.1309,30.9062 16.6309,19.9063 Z"),
                                                Fill =
                                                    new LinearGradientBrush()
                                                {
                                                    GradientStops =
                                                    {
                                                        new GradientStop(Colors.Green,         0),
                                                        new GradientStop(Colors.LightSeaGreen, 1)
                                                    }
                                                },
                                                HorizontalAlignment = HorizontalAlignment.Center,
                                                VerticalAlignment = VerticalAlignment.Center,
                                                RenderTransform = new MatrixTransform(Matrix.CreateScale(2, 2))
                                            }
                                        }
                                    },
                                    [Canvas.LeftProperty] = 100,
                                    [Canvas.TopProperty] = 100,
                                }),
                                (border2 = new Border
                                {
                                    Width = 100,
                                    Height = 100,
                                    HorizontalAlignment = HorizontalAlignment.Center,
                                    VerticalAlignment = VerticalAlignment.Center,
                                    Background = Brushes.Coral,
                                    Child = new Image
                                    {
                                        Source = new Bitmap(GetImage("github_icon.png")),
                                        HorizontalAlignment = HorizontalAlignment.Center,
                                        VerticalAlignment = VerticalAlignment.Center,
                                    },
                                    RenderTransform = (rotate = new RotateTransform
                                    {
                                        PropertyTransitions = new PropertyTransitions
                                        {
                                            RotateTransform.AngleProperty.Transition(500),
                                        }
                                    }),
                                    PropertyTransitions = new PropertyTransitions
                                    {
                                        Layoutable.WidthProperty.Transition(300),
                                        Layoutable.HeightProperty.Transition(1000),
                                    },
                                    [Canvas.LeftProperty] = 400,
                                    [Canvas.TopProperty] = 100,
                                }),
                            }
                        }
                    },
                },
            };

            button1.Click += (s, e) =>
            {
                if (border2.Width == 100)
                {
                    border2.Width = border2.Height = 400;
                    rotate.Angle  = 180;
                }
                else
                {
                    border2.Width = border2.Height = 100;
                    rotate.Angle  = 0;
                }
            };

            var start   = Animate.Stopwatch.Elapsed;
            var degrees = Animate.Timer
                          .Select(x =>
            {
                var elapsed  = (x - start).TotalSeconds;
                var cycles   = elapsed / 4;
                var progress = cycles % 1;
                return(360.0 * progress);
            });

            border1.RenderTransform.Bind(
                RotateTransform.AngleProperty,
                degrees,
                BindingPriority.Animation);

            return(result);
        }
コード例 #25
0
ファイル: MainWindow.cs プロジェクト: herasimchuk-aa/Perspex
        private static TabItem LayoutTab()
        {
            var polylinePoints = new Point[] { new Point(0, 0), new Point(5, 0), new Point(6, -2), new Point(7, 3), new Point(8, -3),
                                               new Point(9, 1), new Point(10, 0), new Point(15, 0) };
            var polygonPoints = new Point[] { new Point(5, 0), new Point(8, 8), new Point(0, 3), new Point(10, 3), new Point(2, 8) };

            for (int i = 0; i < polylinePoints.Length; i++)
            {
                polylinePoints[i] = polylinePoints[i] * 13;
            }
            for (int i = 0; i < polygonPoints.Length; i++)
            {
                polygonPoints[i] = polygonPoints[i] * 15;
            }
            return(new TabItem
            {
                Header = "Layout",
                Content = new ScrollViewer
                {
                    Content = new StackPanel
                    {
                        HorizontalAlignment = HorizontalAlignment.Left,
                        Orientation = Orientation.Vertical,
                        VerticalAlignment = VerticalAlignment.Top,
                        Gap = 4,
                        Margin = new Thickness(10),
                        Children = new Controls
                        {
                            new TextBlock
                            {
                                Text = "Grid",
                                FontWeight = FontWeight.Medium,
                                FontSize = 20,
                                Foreground = SolidColorBrush.Parse("#212121"),
                            },
                            new TextBlock
                            {
                                Text = "Lays out child controls according to a grid.",
                                FontSize = 13,
                                Foreground = SolidColorBrush.Parse("#727272"),
                                Margin = new Thickness(0, 0, 0, 10)
                            },
                            new Grid
                            {
                                Width = 600,
                                ColumnDefinitions = new ColumnDefinitions
                                {
                                    new ColumnDefinition(1, GridUnitType.Star),
                                    new ColumnDefinition(1, GridUnitType.Star),
                                },

                                RowDefinitions = new RowDefinitions
                                {
                                    new RowDefinition(1, GridUnitType.Auto),
                                    new RowDefinition(1, GridUnitType.Auto)
                                },
                                Children = new Controls
                                {
                                    new Rectangle
                                    {
                                        Fill = SolidColorBrush.Parse("#FF5722"),
                                        [Grid.ColumnSpanProperty] = 2,
                                        Height = 200,
                                        Margin = new Thickness(2.5)
                                    },
                                    new Rectangle
                                    {
                                        Fill = SolidColorBrush.Parse("#FF5722"),
                                        [Grid.RowProperty] = 1,
                                        Height = 100,
                                        Margin = new Thickness(2.5)
                                    },
                                    new Rectangle
                                    {
                                        Fill = SolidColorBrush.Parse("#FF5722"),
                                        [Grid.RowProperty] = 1,
                                        [Grid.ColumnProperty] = 1,
                                        Height = 100,
                                        Margin = new Thickness(2.5)
                                    },
                                },
                            },
                            new TextBlock
                            {
                                Margin = new Thickness(0, 40, 0, 0),
                                Text = "StackPanel",
                                FontWeight = FontWeight.Medium,
                                FontSize = 20,
                                Foreground = SolidColorBrush.Parse("#212121"),
                            },
                            new TextBlock
                            {
                                Text = "A panel which lays out its children horizontally or vertically.",
                                FontSize = 13,
                                Foreground = SolidColorBrush.Parse("#727272"),
                                Margin = new Thickness(0, 0, 0, 10)
                            },
                            new StackPanel
                            {
                                Orientation = Orientation.Vertical,
                                Gap = 4,
                                Width = 300,
                                Children = new Controls
                                {
                                    new Rectangle
                                    {
                                        Fill = SolidColorBrush.Parse("#FFC107"),
                                        Height = 50,
                                    },
                                    new Rectangle
                                    {
                                        Fill = SolidColorBrush.Parse("#FFC107"),
                                        Height = 50,
                                    },
                                    new Rectangle
                                    {
                                        Fill = SolidColorBrush.Parse("#FFC107"),
                                        Height = 50,
                                    },
                                }
                            },
                            new TextBlock
                            {
                                Margin = new Thickness(0, 40, 0, 0),
                                Text = "Canvas",
                                FontWeight = FontWeight.Medium,
                                FontSize = 20,
                                Foreground = SolidColorBrush.Parse("#212121"),
                            },
                            new TextBlock
                            {
                                Text = "A panel which lays out its children by explicit coordinates.",
                                FontSize = 13,
                                Foreground = SolidColorBrush.Parse("#727272"),
                                Margin = new Thickness(0, 0, 0, 10)
                            },
                            new Canvas
                            {
                                Background = Brushes.Yellow,
                                Width = 300,
                                Height = 400,
                                Children = new Controls
                                {
                                    new Rectangle
                                    {
                                        Fill = Brushes.Blue,
                                        Width = 63,
                                        Height = 41,
                                        [Canvas.LeftProperty] = 40,
                                        [Canvas.TopProperty] = 31,
                                    },
                                    new Ellipse
                                    {
                                        Fill = Brushes.Green,
                                        Width = 58,
                                        Height = 58,
                                        [Canvas.LeftProperty] = 130,
                                        [Canvas.TopProperty] = 79,
                                    },
                                    new Line
                                    {
                                        Stroke = Brushes.Red,
                                        StrokeThickness = 2,
                                        StartPoint = new Point(120, 185),
                                        EndPoint = new Point(30, 115)
                                    },
                                    new Perspex.Controls.Shapes.Path
                                    {
                                        Fill = Brushes.Orange,
                                        Data = StreamGeometry.Parse("M 30,250 c 50,0 50,-50 c 50,0 50,50 h -50 v 50 l -50,-50 Z"),
                                    },
                                    new Polygon
                                    {
                                        Stroke = Brushes.DarkBlue,
                                        Fill = Brushes.Violet,
                                        Points = polygonPoints,
                                        StrokeThickness = 1,
                                        [Canvas.LeftProperty] = 150,
                                        [Canvas.TopProperty] = 180,
                                    },
                                    new Polyline
                                    {
                                        Stroke = Brushes.Brown,
                                        Points = polylinePoints,
                                        StrokeThickness = 5,
                                        StrokeJoin = PenLineJoin.Round,
                                        StrokeStartLineCap = PenLineCap.Triangle,
                                        StrokeEndLineCap = PenLineCap.Triangle,
                                        [Canvas.LeftProperty] = 30,
                                        [Canvas.TopProperty] = 350,
                                    },
                                }
                            },
                        }
                    }
                }
            });
        }
コード例 #26
0
        private static TabItem AnimationsTab()
        {
            Border          border1;
            Border          border2;
            RotateTransform rotate;
            Button          button1;

            var result = new TabItem
            {
                Header  = "Animations",
                Content = new StackPanel
                {
                    Orientation = Orientation.Vertical,
                    Gap         = 4,
                    Margin      = new Thickness(10),
                    Children    = new Controls
                    {
                        new TextBlock
                        {
                            Text       = "Animations",
                            FontWeight = FontWeight.Medium,
                            FontSize   = 20,
                            Foreground = SolidColorBrush.Parse("#212121"),
                        },
                        new TextBlock
                        {
                            Text       = "A few animations showcased below",
                            FontSize   = 13,
                            Foreground = SolidColorBrush.Parse("#727272"),
                            Margin     = new Thickness(0, 0, 0, 10)
                        },
                        (button1 = new Button
                        {
                            Content = "Animate",
                            Width = 120,
                            [Grid.ColumnProperty] = 1,
                            [Grid.RowProperty] = 1,
                        }),
                        new Canvas
                        {
                            ClipToBounds = false,
                            Children     = new Controls
                            {
                                (border1 = new Border
                                {
                                    Width = 100,
                                    Height = 100,
                                    HorizontalAlignment = HorizontalAlignment.Center,
                                    VerticalAlignment = VerticalAlignment.Center,
                                    Background = Brushes.Crimson,
                                    RenderTransform = new RotateTransform(),
                                    Child = new TextBox
                                    {
                                        Background = Brushes.White,
                                        Text = "Hello!",
                                        HorizontalAlignment = HorizontalAlignment.Center,
                                        VerticalAlignment = VerticalAlignment.Center,
                                    },
                                    [Canvas.LeftProperty] = 100,
                                    [Canvas.TopProperty] = 100,
                                }),
                                (border2 = new Border
                                {
                                    Width = 100,
                                    Height = 100,
                                    HorizontalAlignment = HorizontalAlignment.Center,
                                    VerticalAlignment = VerticalAlignment.Center,
                                    Background = Brushes.Coral,
                                    Child = new Image
                                    {
                                        Source = new Bitmap("github_icon.png"),
                                        HorizontalAlignment = HorizontalAlignment.Center,
                                        VerticalAlignment = VerticalAlignment.Center,
                                    },
                                    RenderTransform = (rotate = new RotateTransform
                                    {
                                        PropertyTransitions = new PropertyTransitions
                                        {
                                            RotateTransform.AngleProperty.Transition(500),
                                        }
                                    }),
                                    PropertyTransitions = new PropertyTransitions
                                    {
                                        Layoutable.WidthProperty.Transition(300),
                                        Layoutable.HeightProperty.Transition(1000),
                                    },
                                    [Canvas.LeftProperty] = 400,
                                    [Canvas.TopProperty] = 100,
                                }),
                            }
                        }
                    },
                },
            };

            button1.Click += (s, e) =>
            {
                if (border2.Width == 100)
                {
                    border2.Width = border2.Height = 400;
                    rotate.Angle  = 180;
                }
                else
                {
                    border2.Width = border2.Height = 100;
                    rotate.Angle  = 0;
                }
            };

            var start   = Animate.Stopwatch.Elapsed;
            var degrees = Animate.Timer
                          .Select(x =>
            {
                var elapsed  = (x - start).TotalSeconds;
                var cycles   = elapsed / 4;
                var progress = cycles % 1;
                return(360.0 * progress);
            });

            border1.RenderTransform.Bind(
                RotateTransform.AngleProperty,
                degrees,
                BindingPriority.Animation);

            return(result);
        }
コード例 #27
0
        public MainWindowViewModel(MainWindow mainWindow)
        {
            this.MainWindow = mainWindow;

            // set default values
            WeatherModel = new WeatherModel
            {
                Status = "Weather forecast is loading...",
                Fact   = new Fact
                {
                    Temp        = "Loading...",
                    Feels_like  = "Loading...",
                    Humidity    = "Loading...",
                    Pressure_mm = "Loading...",
                    UvIndex     = "Loading..."
                }
            };

            ToDoListModel = new ToDoListModel
            {
                Status        = "To-do list is loading...",
                toDoListItems = new List <ToDoListItem>()
            };

            TimerModel = new TimerModel
            {
                Hours   = 1,
                Minutes = 30,
                Seconds = 0
            };

            ButtonStatModel = new ButtonStatModel
            {
                IsTimerStarted = false,
                IsTimerTicking = false,
                Text           = "Старт",
                ButtonColor    = SolidColorBrush.Parse("#1A361F"),
                TextColor      = SolidColorBrush.Parse("#56D45B")
            };

            WidgetColor = new WidgetColor
            {
                TimeColor     = SolidColorBrush.Parse("#505356"),
                WeatherColor  = SolidColorBrush.Parse("#3F4041"),
                TimerColor    = SolidColorBrush.Parse("#282828"),
                TodoListColor = SolidColorBrush.Parse("#252328"),
                NewsColor     = SolidColorBrush.Parse("#4E4C48"),
                EngWordColor  = SolidColorBrush.Parse("#393E41")
            };

            EngTranslatedWordModel = new EngTranslatedWordModel
            {
                Status = "Word of the day is loading..."
            };

            NewsModel = new NewsModel
            {
                LatestTitle = "News are loading..."
            };

            // set timers condition
            timerForecast = new DispatcherTimer
            {
                Interval = TimeSpan.FromHours(1)
            };
            timerForecast.Tick += OnTimedEventForecast;
            timerForecast.Start();

            timerToDo = new DispatcherTimer
            {
                Interval = TimeSpan.FromSeconds(5)
            };
            timerToDo.Tick += OnTimedEventToDoList;
            timerToDo.Start();

            timerTime = new DispatcherTimer
            {
                Interval = TimeSpan.FromSeconds(1)
            };
            timerTime.Tick += OnTimedEventTime;
            timerTime.Start();

            timerTimer = new DispatcherTimer
            {
                Interval = TimeSpan.FromSeconds(1)
            };
            timerTimer.Tick += OnTimedEventTimer;

            timerFlash = new DispatcherTimer
            {
                Interval = TimeSpan.FromMilliseconds(250)
            };
            timerFlash.Tick += OnTimedEventFlash;

            timerEngWord = new DispatcherTimer
            {
                Interval = TimeSpan.FromMilliseconds(500)
            };
            timerEngWord.Tick += OnTimedEvent5AM;
            timerEngWord.Start();

            timerNews = new DispatcherTimer
            {
                Interval = TimeSpan.FromMinutes(1)
            };
            timerNews.Tick += OnTimedEventNews;
            timerNews.Start();

            // trigger some events one time at start of project
            OnTimedEventForecast();
            OnTimedEventToDoList();
            OnTimedEventTime();
            OnTimedEvent5AM();
            OnTimedEventNews();
        }