コード例 #1
0
ファイル: ImageBrushImpl.cs プロジェクト: rdterner/Perspex
        private BitmapBrush CreateDirectBrush(
            ImageBrush brush,
            SharpDX.Direct2D1.RenderTarget target,
            Bitmap image, 
            Rect sourceRect, 
            Rect destinationRect)
        {
            var tileMode = brush.TileMode;
            var scale = brush.Stretch.CalculateScaling(destinationRect.Size, sourceRect.Size);
            var translate = CalculateTranslate(brush, sourceRect, destinationRect, scale);
            var transform = Matrix.CreateTranslation(-sourceRect.Position) *
                Matrix.CreateScale(scale) *
                Matrix.CreateTranslation(translate);

            var opts = new BrushProperties
            {
                Transform = transform.ToDirect2D(),
                Opacity = (float)brush.Opacity,
            };

            var bitmapOpts = new BitmapBrushProperties
            {
                ExtendModeX = GetExtendModeX(tileMode),
                ExtendModeY = GetExtendModeY(tileMode),                
            };

            return new BitmapBrush(target, image, bitmapOpts, opts);
        }
		public static void UpdateImageSource(FrameworkElement content, Grid hostBody, ImageSource imageSource, Stretch stretch)
		{
			if (hostBody == null || content == null)
				return;

			var imgRects = hostBody.Children.OfType<Rectangle>().ToArray();

			for (int i = imgRects.Count() - 1; i >= 0; i--)
			{
				hostBody.Children.Remove(imgRects[i]);
			}

			if (imageSource == null)
				return;

			var imgBrush = new ImageBrush { ImageSource = imageSource, Stretch = stretch };
			var imgRect = new Rectangle
			{
				OpacityMask = imgBrush
			};

			hostBody.Children.Add(imgRect);

			ApplyForegroundToFillBinding(content, imgRect);

			//var sb = new Storyboard();
			//ControlHelper.CreateDoubleAnimations(sb, imgBrush, "Opacity", 0.2, 1, 75);
			//hostBody.Dispatcher.BeginInvoke(sb.Begin);
		}
コード例 #3
0
 public MapImage()
 {
     Fill = new ImageBrush
     {
         RelativeTransform = new MatrixTransform
         {
             Matrix = new Matrix(1d, 0d, 0d, -1d, 0d, 1d)
         }
     };
 }
コード例 #4
0
ファイル: MapImage.cs プロジェクト: bhanu475/XamlMapControl
        private void SourceChanged(ImageSource image)
        {
            var transform = new MatrixTransform
            {
                Matrix = new Matrix(1d, 0d, 0d, -1d, 0d, 1d)
            };
            transform.Freeze();

            Fill = new ImageBrush
            {
                ImageSource = image,
                RelativeTransform = transform
            };
        }
コード例 #5
0
ファイル: ImageBrushImpl.cs プロジェクト: rdterner/Perspex
        public ImageBrushImpl(
            ImageBrush brush,
            SharpDX.Direct2D1.RenderTarget target,
            Size targetSize)
        {
            if (brush.Source == null)
            {
                return;
            }

            var image = ((BitmapImpl)brush.Source.PlatformImpl).GetDirect2DBitmap(target);
            var imageSize = new Size(brush.Source.PixelWidth, brush.Source.PixelHeight);
            var tileMode = brush.TileMode;
            var sourceRect = brush.SourceRect.ToPixels(imageSize);
            var destinationRect = brush.DestinationRect.ToPixels(targetSize);
            var scale = brush.Stretch.CalculateScaling(destinationRect.Size, sourceRect.Size);
            var translate = CalculateTranslate(brush, sourceRect, destinationRect, scale);
            var intermediateSize = CalculateIntermediateSize(tileMode, targetSize, destinationRect.Size);
            var brtOpts = CompatibleRenderTargetOptions.None;

            // TODO: There are times where we don't need to draw an intermediate bitmap. Identify
            // them and directly use 'image' in those cases.
            using (var intermediate = new BitmapRenderTarget(target, brtOpts, intermediateSize))
            {
                Rect drawRect;
                var transform = CalculateIntermediateTransform(
                    tileMode,
                    sourceRect,
                    destinationRect,
                    scale,
                    translate,
                    out drawRect);

                intermediate.BeginDraw();
                intermediate.PushAxisAlignedClip(drawRect.ToDirect2D(), AntialiasMode.Aliased);
                intermediate.Transform = transform.ToDirect2D();
                intermediate.DrawBitmap(image, 1, BitmapInterpolationMode.Linear);
                intermediate.PopAxisAlignedClip();
                intermediate.EndDraw();

                this.PlatformBrush = new BitmapBrush(
                    target, 
                    intermediate.Bitmap,
                    GetBitmapBrushProperties(brush),
                    GetBrushProperties(brush, destinationRect));
            }
        }
コード例 #6
0
        private void AddDirectories_Click(object sender, RoutedEventArgs e)
        {
            try
            {
                using (var folderBrowserDialog = new System.Windows.Forms.FolderBrowserDialog())
                {
                    folderBrowserDialog.Description = "\r\nChoose a directory:";
                    System.Windows.Forms.DialogResult result = folderBrowserDialog.ShowDialog();

                    if (result == System.Windows.Forms.DialogResult.OK && !string.IsNullOrWhiteSpace(folderBrowserDialog.SelectedPath))
                    {
                        string[] IncomingFiles;
                        if (MessageBox.Show("If the selected directory has subdirectories, do you want to include them?", "Malware Or Not?", MessageBoxButton.YesNo, MessageBoxImage.Question) == MessageBoxResult.Yes)
                        {
                            IncomingFiles = Directory.GetFiles(folderBrowserDialog.SelectedPath, "*.*", SearchOption.AllDirectories);
                        }
                        else
                        {
                            IncomingFiles = Directory.GetFiles(folderBrowserDialog.SelectedPath, "*.*");
                        }

                        if (SuspiciousFilesList.Items.Count == 0)
                        {
                            foreach (string File in IncomingFiles)
                            {
                                SuspiciousFilesCounter++;
                                SuspiciousFiles.Add((new FileData()
                                {
                                    Id = SuspiciousFilesCounter, ImageData = LoadImage("Resources/Images/GreyDot.png"), Status = "Ready", Filename = System.IO.Path.GetFileName(File), Path = System.IO.Path.GetFullPath(File), Annotations = "Waiting to be scanned..."
                                }));
                            }
                        }
                        else
                        {
                            bool alreadyExistsInSuspiciousFiles = false;

                            bool alreadyExistsInFilteredFiles = false;

                            foreach (string File in IncomingFiles)
                            {
                                foreach (var Item in SuspiciousFiles)
                                {
                                    if (Item.Path == System.IO.Path.GetFullPath(File))
                                    {
                                        alreadyExistsInSuspiciousFiles = true;
                                    }
                                }
                                if (!alreadyExistsInSuspiciousFiles)
                                {
                                    SuspiciousFilesCounter++;
                                    SuspiciousFiles.Add((new FileData()
                                    {
                                        Id = SuspiciousFilesCounter, ImageData = LoadImage("Resources/Images/GreyDot.png"), Status = "Ready", Filename = System.IO.Path.GetFileName(File), Path = System.IO.Path.GetFullPath(File), Annotations = "Waiting to be scanned..."
                                    }));
                                }
                                else
                                {
                                    foreach (var Item in FilteredFiles)
                                    {
                                        if (Item.Path == System.IO.Path.GetFullPath(File))
                                        {
                                            alreadyExistsInFilteredFiles = true;
                                        }
                                    }
                                    if (!alreadyExistsInFilteredFiles)
                                    {
                                        FilteredFilesCounter++;
                                        FilteredFiles.Add((new FileData()
                                        {
                                            Id = FilteredFilesCounter, Filename = System.IO.Path.GetFileName(File), Path = System.IO.Path.GetFullPath(File), Annotations = "The file was already in the queue."
                                        }));
                                    }
                                }
                                alreadyExistsInSuspiciousFiles = false;
                                alreadyExistsInFilteredFiles   = false;
                            }
                        }

                        if (SuspiciousFilesCounter > 0)
                        {
                            StartProcess.IsEnabled = true;
                            StopProcess.IsEnabled  = true;
                        }

                        if (FilteredFilesCounter > 0)
                        {
                            ToggleNotifications.IsEnabled = true;
                        }

                        var brush = new ImageBrush();
                        brush.ImageSource      = LoadImage("Resources/Images/Delete.png");
                        StopProcess.Background = brush;

                        StopProcess.IsEnabled = true;

                        toggleNotifications = false;

                        SuspiciousFilesList.ItemsSource = SuspiciousFiles;
                        SuspiciousFilesList.Items.Refresh();

                        FilteredFilesList.ItemsSource = FilteredFiles;
                        FilteredFilesList.Items.Refresh();
                    }
                }
            }
            catch (Exception ex)
            {
                if (ex is UnauthorizedAccessException)
                {
                    MessageBox.Show("You have no permission to work with some of the directories selected due to user privileges.\r\n\r\nPlease, select a more specific group of files.", "Critical exception", MessageBoxButton.OK, MessageBoxImage.Information);
                }
                else
                {
                    MessageBox.Show(ex.ToString(), "Unhandled exception", MessageBoxButton.OK, MessageBoxImage.Information);
                    Environment.Exit(0);
                }
            }
        }
コード例 #7
0
        private void AnalysisProcess()
        {
            try
            {
                while (isActivated == true)
                {
                    FileData pathData = (FileData)SuspiciousFilesList.Items[currentSuspiciousListIndex];
                    string   filePath = pathData.Path;

                    Dispatcher.BeginInvoke(new Action(delegate()
                    {
                        pathData.Status      = "Processing...";
                        pathData.ImageData   = LoadImage("Resources/Images/YellowDot.png");
                        pathData.Annotations = "Waiting for the result...";

                        SuspiciousFilesList.Items.Refresh();

                        SuspiciousFilesList.SelectedIndex = currentSuspiciousListIndex;
                        SuspiciousFilesList.ScrollIntoView(SuspiciousFilesList.SelectedItem);
                    }));

                    using (Process process = new Process())
                    {
                        process.StartInfo.FileName               = "python.exe";
                        process.StartInfo.Arguments              = "reqres_api.py " + filePath.Replace(" ", "%20");
                        process.StartInfo.UseShellExecute        = false;
                        process.StartInfo.RedirectStandardOutput = true;
                        process.StartInfo.CreateNoWindow         = true;
                        process.StartInfo.Verb = "runas";
                        process.Start();

                        string Output = "";

                        while (!process.StandardOutput.EndOfStream)
                        {
                            Output = process.StandardOutput.ReadLine();
                        }

                        process.WaitForExit();

                        while (isPaused == true)
                        {
                        }

                        string[] receivedData = Output.Split(',');

                        if (receivedData[0] == "succeeded") // if it was succeeded...
                        {
                            // Updating data in the Listview.

                            if (int.Parse(receivedData[3]) == 1) // Malware
                            {
                                Dispatcher.BeginInvoke(new Action(delegate()
                                {
                                    pathData.Status      = "Done";
                                    pathData.ImageData   = LoadImage("Resources/Images/RedDot.png");
                                    pathData.Annotations = "Malicious executable. Probability: " + receivedData[2];
                                }));
                            }
                            else // Not malware
                            {
                                Dispatcher.BeginInvoke(new Action(delegate()
                                {
                                    pathData.Status      = "Done";
                                    pathData.ImageData   = LoadImage("Resources/Images/GreenDot.png");
                                    pathData.Annotations = "Benign executable. Probability: " + receivedData[2];
                                }));
                            }
                        }
                        else if (receivedData[0] == "failed") // if it was "failed"...
                        {
                            if (receivedData[1] == "server")  // ...because of the server
                            {
                                Dispatcher.BeginInvoke(new Action(delegate()
                                {
                                    pathData.Status      = "Done";
                                    pathData.ImageData   = LoadImage("Resources/Images/GreyDot.png");
                                    pathData.Annotations = "Server error. Details: " + receivedData[2];
                                }));
                            }
                            else // ...because of the "file" = tag name
                            {
                                if (receivedData[2] == "nopeheader")
                                {
                                    Dispatcher.BeginInvoke(new Action(delegate()
                                    {
                                        pathData.Status      = "Done";
                                        pathData.ImageData   = LoadImage("Resources/Images/GreyDot.png");
                                        pathData.Annotations = "Not an executable. The file does not contains a PE header.";
                                    }));
                                }
                                else if (receivedData[2] == "nopermission")
                                {
                                    Dispatcher.BeginInvoke(new Action(delegate()
                                    {
                                        pathData.Status      = "Skipped";
                                        pathData.ImageData   = LoadImage("Resources/Images/YellowDot.png");
                                        pathData.Annotations = "Unable to read the file due to user privileges.";
                                    }));
                                }
                                else // failed,file,others,ERROR_DESCRIPTION
                                {
                                    Dispatcher.BeginInvoke(new Action(delegate()
                                    {
                                        pathData.Status      = "Skipped";
                                        pathData.ImageData   = LoadImage("Resources/Images/YellowDot.png");
                                        pathData.Annotations = receivedData[3];
                                    }));
                                }
                            }
                        }
                        else // if you wanted to debug a received data. FORMAT:        debug,ERROR_DESCRIPTION
                        {
                            try
                            {
                                MessageBox.Show("Standard output result: " + receivedData[1], "Debugger", MessageBoxButton.OK, MessageBoxImage.Information);
                            }
                            catch (Exception e)
                            {
                                if (e is IndexOutOfRangeException)
                                {
                                    Dispatcher.BeginInvoke(new Action(delegate()
                                    {
                                        pathData.Status      = "Skipped";
                                        pathData.ImageData   = LoadImage("Resources/Images/YellowDot.png");
                                        pathData.Annotations = "Unable to reach the file. Verify the access to it.";
                                    }));
                                }
                                else
                                {
                                    MessageBox.Show(e.ToString(), "Unidentified exception", MessageBoxButton.OK, MessageBoxImage.Information);
                                    Environment.Exit(0);
                                }
                            }
                        }
                        Dispatcher.BeginInvoke(new Action(delegate()
                        {
                            SuspiciousFilesList.Items.Refresh();
                        }));
                    }

                    currentSuspiciousListIndex++;

                    if (currentSuspiciousListIndex == SuspiciousFilesCounter)
                    {
                        Dispatcher.BeginInvoke(new Action(delegate()
                        {
                            StartProcess.IsEnabled = false;
                            PauseProcess.IsEnabled = false;
                            StopProcess.IsEnabled  = true;

                            isPaused = false;

                            SuspiciousFilesCounter = 0;

                            FilteredFilesCounter = 0;

                            currentSuspiciousListIndex = 0;

                            ClassifierLoadingAnimation.Stop();

                            isActivated = false;

                            ShowingLabelStatus.Text = "Suspicious files.";

                            var brush              = new ImageBrush();
                            brush.ImageSource      = LoadImage("Resources/Images/Delete.png");
                            StopProcess.Background = brush;
                        }));

                        MessageBox.Show("Process finished!", "Notification", MessageBoxButton.OK, MessageBoxImage.Information);

                        break;
                    }
                }
            }
            catch (Exception e)
            {
                if (e is System.ArgumentOutOfRangeException)
                {
                    // Just ignore to keep going.
                }
                else
                {
                    MessageBox.Show(e.ToString(), "Unidentified exception", MessageBoxButton.OK, MessageBoxImage.Information);
                    Environment.Exit(0);
                }
            }
        }
コード例 #8
0
        private void ButtonSend_Click(object sender, EventArgs e)
        {
            textLabel   = new TextBlock();
            DateLabel   = new TextBlock();
            AuthorLabel = new TextBlock();
            userAvatar  = new Border();

            //Затычка, нужно из БД

            AuthorLabel.Text = "Виталий";

            //Настройка тени

            DropShadowEffect textShadow = new DropShadowEffect();

            textShadow.BlurRadius  = 1;
            textShadow.ShadowDepth = 3;
            textShadow.Opacity     = 0.5;
            textShadow.Color       = Colors.White;

            userAvatar.Height = 100;
            userAvatar.Width  = 100;
            userAvatar.HorizontalAlignment = HorizontalAlignment.Left;
            userAvatar.CornerRadius        = new CornerRadius(100);
            userAvatar.Margin = new Thickness(50, 0, 0, 0);


            Grid message = new Grid();


            message.ColumnDefinitions.Add(new ColumnDefinition());
            message.ColumnDefinitions.Add(new ColumnDefinition());
            message.ColumnDefinitions.Add(new ColumnDefinition());

            message.RowDefinitions.Add(new RowDefinition());
            message.RowDefinitions.Add(new RowDefinition());
            message.RowDefinitions.Add(new RowDefinition());
            message.Height = 200;

            //Grid info = new Grid();
            //info.ColumnDefinitions.Add(new ColumnDefinition());
            //info.ColumnDefinitions.Add(new ColumnDefinition());
            //info.Background = new SolidColorBrush(Colors.Red);

            Grid.SetColumn(userAvatar, 0);
            Grid.SetRowSpan(userAvatar, 3);

            Grid.SetColumn(textLabel, 1);
            Grid.SetColumnSpan(textLabel, 2);
            Grid.SetRow(textLabel, 1);

            Grid.SetColumn(DateLabel, 2);
            Grid.SetRow(DateLabel, 0);

            Grid.SetColumn(AuthorLabel, 1);
            Grid.SetRow(AuthorLabel, 0);


            message.Children.Add(userAvatar);
            message.Children.Add(textLabel);
            message.Children.Add(DateLabel);
            message.Children.Add(AuthorLabel);

            var        filename    = @"Assets\userChat.png";
            ImageBrush imageAvatar = new ImageBrush();

            imageAvatar.ImageSource = new BitmapImage(new Uri(filename, UriKind.Relative));   //
            userAvatar.Background   = Brushes.AliceBlue;
            {
                textLabel.Text                = tb_chat.Text;
                textLabel.TextWrapping        = TextWrapping.Wrap;
                textLabel.VerticalAlignment   = VerticalAlignment.Center;
                DateLabel.Effect              = textShadow;
                AuthorLabel.Effect            = textShadow;
                AuthorLabel.VerticalAlignment = VerticalAlignment.Bottom;
                DateLabel.VerticalAlignment   = VerticalAlignment.Bottom;
                DateLabel.Text                = DateTime.Now.ToString();
            }
            StackPanel1.Children.Add(message);
            tb_chat.Text = null;
            //sre_def = Recognition();



            if (sre_def != null)
            {
                StopMet(sre_def);
            }

            tb_chat.Text = " ";
            //Love Ne
        }
コード例 #9
0
        protected override void Invoke(object parameter)
        {
            if ((parameter as SelectionChangedEventArgs) != null && (parameter as SelectionChangedEventArgs).Source is ComboBox)
            {
                var comboBox = (parameter as SelectionChangedEventArgs).Source as ComboBox;
                if (comboBox != null)
                {
                    if (comboBox.Name == "comboChartWidth")
                    {
                        string selectedValue = comboBox.SelectedItem.ToString().Replace("System.Windows.Controls.ComboBoxItem: ", "");
                        Target.BorderThickness = new Thickness(double.Parse(selectedValue));
                    }
                    if (comboBox.Name == "comboSeriesBorderWidth")
                    {
                        string selectedValue = comboBox.SelectedItem.ToString().Replace("System.Windows.Controls.ComboBoxItem: ", "");
                        foreach (ChartSeries series in Target.Series)
                        {
                            series.StrokeThickness = double.Parse(selectedValue);
                        }
                    }
                    if (comboBox.Name == "comboChartColor")
                    {
                        string selectedValue = comboBox.SelectedItem.ToString().Replace("System.Windows.Controls.ComboBoxItem: ", "");
                        var    color         = ColorConverter.ConvertFromString(selectedValue);
                        if (color != null)
                        {
                            SolidColorBrush brush = new SolidColorBrush((Color)color);
                            Target.BorderBrush = brush;
                        }
                    }
                    if (comboBox.Name == "comboSeriesborderColor")
                    {
                        string selectedValue = comboBox.SelectedItem.ToString().Replace("System.Windows.Controls.ComboBoxItem: ", "");
                        foreach (ChartSeries series in Target.Series)
                        {
                            var color = ColorConverter.ConvertFromString(selectedValue);
                            if (color != null)
                            {
                                SolidColorBrush brush = new SolidColorBrush((Color)color);
                                series.Stroke = brush;
                            }
                        }
                    }
                    if (comboBox.Name == "combo_FontColor")
                    {
                        string selectedValue = comboBox.SelectedItem.ToString().Replace("System.Windows.Controls.ComboBoxItem: ", "");

                        var color = ColorConverter.ConvertFromString(selectedValue);
                        if (color != null)
                        {
                            SolidColorBrush brush = new SolidColorBrush((Color)color);
                            Target.PrimaryAxis.LabelForeground = brush;
                            if (Target.SecondaryAxis != null)
                            {
                                Target.SecondaryAxis.LabelForeground = brush;
                            }
                        }
                    }
                    if (comboBox.Name == "SeriesPalette")
                    {
                        string selectedValue = comboBox.SelectedItem.ToString().Replace("System.Windows.Controls.ComboBoxItem: ", "");
                        if (selectedValue == "Custom")
                        {
                            Target.ColorModel.CustomPalette = new Brush[]
                            {
                                new SolidColorBrush(Colors.Violet),
                                new SolidColorBrush(Colors.Indigo),
                                new SolidColorBrush(Colors.Blue),
                                new SolidColorBrush(Colors.Green),
                                new SolidColorBrush(Colors.Yellow),
                                new SolidColorBrush(Colors.Orange),
                                new SolidColorBrush(Colors.Red),
                            };
                            Target.ColorModel.Palette = ChartColorPalette.Custom;
                        }
                        else
                        {
                            Target.ColorModel.Palette = (ChartColorPalette)comboBox.SelectedItem;
                        }
                    }
                    var gradientSetting = comboBox.Name;
                    if (gradientSetting == "combo_StartColor" || gradientSetting == "combo_EndColor" || gradientSetting == "combo_InteriorStartColor" || gradientSetting == "combo_InteriorEndColor" || gradientSetting == "combo_GradientStyle")
                    {
                        string selectedValue = comboBox.SelectedItem.ToString().Replace("System.Windows.Controls.ComboBoxItem: ", "");
                        if (gradientSetting == "combo_StartColor")
                        {
                            var color = ColorConverter.ConvertFromString(selectedValue);
                            if (color != null)
                            {
                                startColor = (Color)color;
                            }
                        }
                        else if (gradientSetting == "combo_EndColor")
                        {
                            var color = ColorConverter.ConvertFromString(selectedValue);
                            if (color != null)
                            {
                                endColor = (Color)color;
                            }
                        }
                        else if (gradientSetting == "combo_InteriorStartColor")
                        {
                            var color = ColorConverter.ConvertFromString(selectedValue);
                            if (color != null)
                            {
                                startInteriorColor = (Color)color;
                            }
                        }
                        else if (gradientSetting == "combo_InteriorEndColor")
                        {
                            var color = ColorConverter.ConvertFromString(selectedValue);
                            if (color != null)
                            {
                                endInteriorColor = (Color)color;
                            }
                        }
                        else if (gradientSetting == "combo_GradientStyle")
                        {
                            gradientAngle = selectedValue;
                        }
                        Target.Background     = gradientAngle == "Horizontal" ? new LinearGradientBrush(startColor, endColor, 0) : new LinearGradientBrush(startColor, endColor, 90);
                        Target.GridBackground = gradientAngle == "Horizontal" ? new LinearGradientBrush(startInteriorColor, endInteriorColor, 0) : new LinearGradientBrush(startInteriorColor, endInteriorColor, 90);
                    }
                }
            }
            else if (parameter is RoutedEventArgs)
            {
                if ((parameter as RoutedEventArgs).Source is CheckBox)
                {
                    var checkBox = (parameter as RoutedEventArgs).Source as CheckBox;
                    if (checkBox != null)
                    {
                        if (checkBox.Name == "GridHorizontalCheckBox1" && checkBox.IsChecked != null)
                        {
                            bool selectedValue = (bool)checkBox.IsChecked;
                            Target.Series[0].Area.SecondaryAxis.SetValue(ChartArea.ShowGridLinesProperty, selectedValue);
                        }
                        if (checkBox.Name == "GridVerticalCheckBox1" && checkBox.IsChecked != null)
                        {
                            bool selectedValue = (bool)checkBox.IsChecked;
                            Target.Series[0].Area.PrimaryAxis.SetValue(ChartArea.ShowGridLinesProperty, selectedValue);
                        }
                        if (checkBox.Name == "chkclr" && checkBox.IsChecked != null)
                        {
                            bool selectedvalue = (bool)checkBox.IsChecked;
                            if (selectedvalue == false)
                            {
                                Target.Background     = new SolidColorBrush(Colors.White);
                                Target.GridBackground = new SolidColorBrush(Colors.White);
                            }
                            else
                            {
                                Target.Background     = gradientAngle == "Horizontal" ? new LinearGradientBrush(startColor, endColor, 0) : new LinearGradientBrush(startColor, endColor, 90);
                                Target.GridBackground = gradientAngle == "Horizontal" ? new LinearGradientBrush(startInteriorColor, endInteriorColor, 0) : new LinearGradientBrush(startInteriorColor, endInteriorColor, 90);
                            }
                        }
                        if (checkBox.Name == "checkBox_ShowLegend" && checkBox.IsChecked != null)
                        {
                            bool selectedValue = (bool)checkBox.IsChecked;
                            if (selectedValue)
                            {
                                Target.Legend.Visibility = Visibility.Visible;
                            }
                            else
                            {
                                Target.Legend.Visibility         = Visibility.Collapsed;
                                Target.Legend.CheckBoxVisibility = Visibility.Collapsed;
                            }
                        }
                        if (checkBox.Name == "checkBox_ShowCheck" && checkBox.IsChecked != null)
                        {
                            bool selectedValue = (bool)checkBox.IsChecked;
                            Target.Legend.CheckBoxVisibility = selectedValue ? Visibility.Visible : Visibility.Collapsed;
                        }
                    }
                }
                else if ((parameter as RoutedEventArgs).Source is Button)
                {
                    OpenFileDialog ofd = new OpenFileDialog();
                    ofd.Filter = "BackGround files (*.jpg)|*.jpg|All files (*.*)|*.*";
                    bool validate;
                    do
                    {
                        validate = true;
                        if (ofd.ShowDialog() == true)
                        {
                            System.Drawing.Imaging.ImageFormat imageFormat = null;
                            string extension = System.IO.Path.GetExtension(ofd.FileName);
                            if (extension != null && (extension.ToLower() == ".jpg" || extension.ToLower() == ".jpeg"))
                            {
                                imageFormat = System.Drawing.Imaging.ImageFormat.Jpeg;
                            }
                            validate = imageFormat != null;
                            if (!validate)
                            {
                                MessageBox.Show("*" + extension + " is not a valid image format", "Appearance", MessageBoxButton.OK, MessageBoxImage.Error);
                            }
                            else
                            {
                                ImageBrush myBrush = new ImageBrush();
                                myBrush.ImageSource   = new BitmapImage(new Uri(ofd.FileName, UriKind.RelativeOrAbsolute));
                                Target.GridBackground = myBrush;
                            }
                        }
                    } while (!validate);
                }
            }
        }
コード例 #10
0
        private void ChangeImage()
        {
            try
            {
                SetCanvasBackground();
                FindWpfTextView(_editorCanvas as DependencyObject);
                if (_wpfTextViewHost == null)
                {
                    return;
                }

                var newimage = _imageProvider.GetBitmap();
                var opacity  = _settings.ExpandToIDE && _isMainWindow ? 0.0 : _settings.Opacity;

                Microsoft.VisualStudio.Shell.ThreadHelper.JoinableTaskFactory.Run(async() =>
                {
                    await Microsoft.VisualStudio.Shell.ThreadHelper.JoinableTaskFactory.SwitchToMainThreadAsync();
                    try
                    {
                        if (_isRootWindow)
                        {
                            var grid = new Grid()
                            {
                                Name = "ClaudiaIdeImage",
                                HorizontalAlignment = HorizontalAlignment.Stretch,
                                VerticalAlignment   = VerticalAlignment.Stretch,
                                IsHitTestVisible    = false
                            };
                            var ni = new Image()
                            {
                                Source              = newimage,
                                Stretch             = _settings.ImageStretch.ConvertTo(),
                                HorizontalAlignment = _settings.PositionHorizon.ConvertToHorizontalAlignment(),
                                VerticalAlignment   = _settings.PositionVertical.ConvertToVerticalAlignment(),
                                Opacity             = opacity,
                                IsHitTestVisible    = false
                            };
                            grid.Children.Insert(0, ni);
                            Grid.SetRowSpan(grid, 3);
                            Grid.SetColumnSpan(grid, 3);
                            var p = VisualTreeHelper.GetParent(_wpfTextViewHost) as Grid;
                            if (p != null)
                            {
                                foreach (var c in p.Children)
                                {
                                    if ((c as Grid)?.Name == "ClaudiaIdeImage")
                                    {
                                        p.Children.Remove(c as UIElement);
                                        break;
                                    }
                                }
                                p.Children.Insert(0, grid);
                            }
                        }
                        else
                        {
                            var nib = new ImageBrush(newimage)
                            {
                                Stretch    = _settings.ImageStretch.ConvertTo(),
                                AlignmentX = _settings.PositionHorizon.ConvertTo(),
                                AlignmentY = _settings.PositionVertical.ConvertTo(),
                                Opacity    = opacity,
                                Viewbox    = new Rect(new Point(_settings.ViewBoxPointX, _settings.ViewBoxPointY), new Size(1, 1))
                            };
                            _wpfTextViewHost.SetValue(Panel.BackgroundProperty, nib);
                        }
                        _hasImage = true;
                        if (_settings.ImageBackgroundType == ImageBackgroundType.SingleEach)
                        {
                            ((SingleImageEachProvider)_imageProvider).NextImage();
                        }
                    }
                    catch
                    {
                    }
                });
            }
            catch
            {
            }
        }
コード例 #11
0
ファイル: BasicUI.xaml.cs プロジェクト: EmptyKeys/UI_Examples
 private static System.Collections.ObjectModel.ObservableCollection<object> Get_TabControl_Items()
 {
     System.Collections.ObjectModel.ObservableCollection<object> items = new System.Collections.ObjectModel.ObservableCollection<object>();
     // e_3 element
     TabItem e_3 = new TabItem();
     e_3.Name = "e_3";
     e_3.HorizontalContentAlignment = HorizontalAlignment.Stretch;
     e_3.Header = "Controls";
     // e_4 element
     Grid e_4 = new Grid();
     e_3.Content = e_4;
     e_4.Name = "e_4";
     RowDefinition row_e_4_0 = new RowDefinition();
     row_e_4_0.Height = new GridLength(1F, GridUnitType.Auto);
     e_4.RowDefinitions.Add(row_e_4_0);
     RowDefinition row_e_4_1 = new RowDefinition();
     row_e_4_1.Height = new GridLength(1F, GridUnitType.Auto);
     e_4.RowDefinitions.Add(row_e_4_1);
     RowDefinition row_e_4_2 = new RowDefinition();
     row_e_4_2.Height = new GridLength(1F, GridUnitType.Auto);
     e_4.RowDefinitions.Add(row_e_4_2);
     RowDefinition row_e_4_3 = new RowDefinition();
     row_e_4_3.Height = new GridLength(1F, GridUnitType.Auto);
     e_4.RowDefinitions.Add(row_e_4_3);
     RowDefinition row_e_4_4 = new RowDefinition();
     row_e_4_4.Height = new GridLength(1F, GridUnitType.Auto);
     e_4.RowDefinitions.Add(row_e_4_4);
     RowDefinition row_e_4_5 = new RowDefinition();
     row_e_4_5.Height = new GridLength(1F, GridUnitType.Auto);
     e_4.RowDefinitions.Add(row_e_4_5);
     RowDefinition row_e_4_6 = new RowDefinition();
     row_e_4_6.Height = new GridLength(1F, GridUnitType.Auto);
     e_4.RowDefinitions.Add(row_e_4_6);
     RowDefinition row_e_4_7 = new RowDefinition();
     row_e_4_7.Height = new GridLength(1F, GridUnitType.Auto);
     e_4.RowDefinitions.Add(row_e_4_7);
     RowDefinition row_e_4_8 = new RowDefinition();
     row_e_4_8.Height = new GridLength(1F, GridUnitType.Auto);
     e_4.RowDefinitions.Add(row_e_4_8);
     RowDefinition row_e_4_9 = new RowDefinition();
     row_e_4_9.Height = new GridLength(1F, GridUnitType.Auto);
     e_4.RowDefinitions.Add(row_e_4_9);
     RowDefinition row_e_4_10 = new RowDefinition();
     row_e_4_10.Height = new GridLength(1F, GridUnitType.Auto);
     e_4.RowDefinitions.Add(row_e_4_10);
     RowDefinition row_e_4_11 = new RowDefinition();
     row_e_4_11.Height = new GridLength(1F, GridUnitType.Auto);
     e_4.RowDefinitions.Add(row_e_4_11);
     ColumnDefinition col_e_4_0 = new ColumnDefinition();
     col_e_4_0.Width = new GridLength(1F, GridUnitType.Auto);
     e_4.ColumnDefinitions.Add(col_e_4_0);
     ColumnDefinition col_e_4_1 = new ColumnDefinition();
     e_4.ColumnDefinitions.Add(col_e_4_1);
     // e_5 element
     TextBlock e_5 = new TextBlock();
     e_4.Children.Add(e_5);
     e_5.Name = "e_5";
     e_5.VerticalAlignment = VerticalAlignment.Center;
     e_5.Text = "Button";
     // button1 element
     Button button1 = new Button();
     e_4.Children.Add(button1);
     button1.Name = "button1";
     button1.Height = 30F;
     button1.Width = 200F;
     button1.Margin = new Thickness(5F, 5F, 5F, 5F);
     button1.HorizontalAlignment = HorizontalAlignment.Left;
     button1.TabIndex = 1;
     button1.Content = "Button 1";
     button1.CommandParameter = "Click Button 1";
     Grid.SetColumn(button1, 1);
     Grid.SetRow(button1, 0);
     Binding binding_button1_Command = new Binding("ButtonCommand");
     button1.SetBinding(Button.CommandProperty, binding_button1_Command);
     // button2 element
     Button button2 = new Button();
     e_4.Children.Add(button2);
     button2.Name = "button2";
     button2.Height = 30F;
     button2.Width = 200F;
     button2.Margin = new Thickness(5F, 5F, 5F, 5F);
     button2.HorizontalAlignment = HorizontalAlignment.Left;
     button2.TabIndex = 2;
     button2.Content = "Button 2";
     button2.CommandParameter = "Click Button 2";
     Grid.SetColumn(button2, 1);
     Grid.SetRow(button2, 1);
     Binding binding_button2_IsEnabled = new Binding("ButtonEnabled");
     button2.SetBinding(Button.IsEnabledProperty, binding_button2_IsEnabled);
     Binding binding_button2_Command = new Binding("ButtonCommand");
     button2.SetBinding(Button.CommandProperty, binding_button2_Command);
     // buttonResult element
     TextBlock buttonResult = new TextBlock();
     e_4.Children.Add(buttonResult);
     buttonResult.Name = "buttonResult";
     buttonResult.HorizontalAlignment = HorizontalAlignment.Left;
     Grid.SetColumn(buttonResult, 1);
     Grid.SetRow(buttonResult, 2);
     Binding binding_buttonResult_Text = new Binding("ButtonResult");
     buttonResult.SetBinding(TextBlock.TextProperty, binding_buttonResult_Text);
     // e_6 element
     TextBlock e_6 = new TextBlock();
     e_4.Children.Add(e_6);
     e_6.Name = "e_6";
     e_6.VerticalAlignment = VerticalAlignment.Center;
     e_6.Text = "CheckBox";
     Grid.SetRow(e_6, 3);
     // checkBox element
     CheckBox checkBox = new CheckBox();
     e_4.Children.Add(checkBox);
     checkBox.Name = "checkBox";
     checkBox.Margin = new Thickness(5F, 5F, 5F, 5F);
     checkBox.HorizontalAlignment = HorizontalAlignment.Left;
     checkBox.TabIndex = 3;
     checkBox.Content = "Check Box";
     Grid.SetColumn(checkBox, 1);
     Grid.SetRow(checkBox, 3);
     // e_7 element
     TextBlock e_7 = new TextBlock();
     e_4.Children.Add(e_7);
     e_7.Name = "e_7";
     e_7.VerticalAlignment = VerticalAlignment.Center;
     e_7.Text = "ProgressBar";
     Grid.SetRow(e_7, 4);
     // e_8 element
     ProgressBar e_8 = new ProgressBar();
     e_4.Children.Add(e_8);
     e_8.Name = "e_8";
     e_8.Height = 30F;
     e_8.Width = 200F;
     e_8.Margin = new Thickness(5F, 5F, 5F, 5F);
     e_8.HorizontalAlignment = HorizontalAlignment.Left;
     Grid.SetColumn(e_8, 1);
     Grid.SetRow(e_8, 4);
     Binding binding_e_8_Value = new Binding("ProgressValue");
     e_8.SetBinding(ProgressBar.ValueProperty, binding_e_8_Value);
     // e_9 element
     TextBlock e_9 = new TextBlock();
     e_4.Children.Add(e_9);
     e_9.Name = "e_9";
     e_9.VerticalAlignment = VerticalAlignment.Center;
     e_9.Text = "Slider";
     Grid.SetRow(e_9, 5);
     // slider element
     Slider slider = new Slider();
     e_4.Children.Add(slider);
     slider.Name = "slider";
     slider.Width = 200F;
     slider.HorizontalAlignment = HorizontalAlignment.Left;
     slider.TabIndex = 4;
     slider.Minimum = 5F;
     slider.Maximum = 20F;
     Grid.SetColumn(slider, 1);
     Grid.SetRow(slider, 5);
     Binding binding_slider_Value = new Binding("SliderValue");
     slider.SetBinding(Slider.ValueProperty, binding_slider_Value);
     // e_10 element
     TextBlock e_10 = new TextBlock();
     e_4.Children.Add(e_10);
     e_10.Name = "e_10";
     e_10.VerticalAlignment = VerticalAlignment.Center;
     e_10.Text = "TextBox";
     Grid.SetRow(e_10, 6);
     // textBox element
     TextBox textBox = new TextBox();
     e_4.Children.Add(textBox);
     textBox.Name = "textBox";
     textBox.Width = 200F;
     textBox.Margin = new Thickness(5F, 5F, 5F, 5F);
     textBox.HorizontalAlignment = HorizontalAlignment.Left;
     textBox.TabIndex = 5;
     textBox.SelectionBrush = new SolidColorBrush(new ColorW(255, 0, 0, 255));
     textBox.UndoLimit = 20;
     Grid.SetColumn(textBox, 1);
     Grid.SetRow(textBox, 6);
     Binding binding_textBox_Text = new Binding("TextBoxText");
     textBox.SetBinding(TextBox.TextProperty, binding_textBox_Text);
     // e_11 element
     TextBlock e_11 = new TextBlock();
     e_4.Children.Add(e_11);
     e_11.Name = "e_11";
     e_11.VerticalAlignment = VerticalAlignment.Center;
     e_11.Text = "Numeric";
     Grid.SetRow(e_11, 7);
     // numTextBox element
     NumericTextBox numTextBox = new NumericTextBox();
     e_4.Children.Add(numTextBox);
     numTextBox.Name = "numTextBox";
     numTextBox.Width = 200F;
     numTextBox.Margin = new Thickness(5F, 5F, 5F, 5F);
     numTextBox.HorizontalAlignment = HorizontalAlignment.Left;
     numTextBox.TabIndex = 6;
     numTextBox.ValueFormat = "F0";
     numTextBox.ValueStyle = ((System.Globalization.NumberStyles)(7));
     Grid.SetColumn(numTextBox, 1);
     Grid.SetRow(numTextBox, 7);
     Binding binding_numTextBox_Value = new Binding("NumericTextBoxValue");
     numTextBox.SetBinding(NumericTextBox.ValueProperty, binding_numTextBox_Value);
     // e_12 element
     TextBlock e_12 = new TextBlock();
     e_4.Children.Add(e_12);
     e_12.Name = "e_12";
     e_12.VerticalAlignment = VerticalAlignment.Center;
     e_12.Text = "PasswordBox";
     Grid.SetRow(e_12, 8);
     // e_13 element
     PasswordBox e_13 = new PasswordBox();
     e_4.Children.Add(e_13);
     e_13.Name = "e_13";
     e_13.Width = 200F;
     e_13.Margin = new Thickness(5F, 5F, 5F, 5F);
     e_13.HorizontalAlignment = HorizontalAlignment.Left;
     e_13.TabIndex = 7;
     Grid.SetColumn(e_13, 1);
     Grid.SetRow(e_13, 8);
     Binding binding_e_13_Password = new Binding("Password");
     e_13.SetBinding(PasswordBox.PasswordProperty, binding_e_13_Password);
     // e_14 element
     TextBlock e_14 = new TextBlock();
     e_4.Children.Add(e_14);
     e_14.Name = "e_14";
     e_14.VerticalAlignment = VerticalAlignment.Center;
     e_14.Text = "ComboBox";
     Grid.SetRow(e_14, 9);
     // combo element
     ComboBox combo = new ComboBox();
     e_4.Children.Add(combo);
     combo.Name = "combo";
     combo.Width = 200F;
     combo.Margin = new Thickness(5F, 5F, 5F, 5F);
     combo.HorizontalAlignment = HorizontalAlignment.Left;
     combo.TabIndex = 8;
     combo.ItemsSource = Get_combo_Items();
     combo.SelectedIndex = 2;
     Grid.SetColumn(combo, 1);
     Grid.SetRow(combo, 9);
     // e_15 element
     TextBlock e_15 = new TextBlock();
     e_4.Children.Add(e_15);
     e_15.Name = "e_15";
     e_15.VerticalAlignment = VerticalAlignment.Center;
     e_15.Text = "ListBox";
     Grid.SetRow(e_15, 10);
     // e_16 element
     Grid e_16 = new Grid();
     e_4.Children.Add(e_16);
     e_16.Name = "e_16";
     ColumnDefinition col_e_16_0 = new ColumnDefinition();
     e_16.ColumnDefinitions.Add(col_e_16_0);
     ColumnDefinition col_e_16_1 = new ColumnDefinition();
     e_16.ColumnDefinitions.Add(col_e_16_1);
     Grid.SetColumn(e_16, 1);
     Grid.SetRow(e_16, 10);
     // e_17 element
     ListBox e_17 = new ListBox();
     e_16.Children.Add(e_17);
     e_17.Name = "e_17";
     e_17.TabIndex = 9;
     DragDrop.SetIsDragSource(e_17, true);
     DragDrop.SetIsDropTarget(e_17, true);
     Binding binding_e_17_ItemsSource = new Binding("DataOne");
     e_17.SetBinding(ListBox.ItemsSourceProperty, binding_e_17_ItemsSource);
     // e_18 element
     ListBox e_18 = new ListBox();
     e_16.Children.Add(e_18);
     e_18.Name = "e_18";
     e_18.TabIndex = 10;
     Grid.SetColumn(e_18, 1);
     DragDrop.SetIsDragSource(e_18, true);
     DragDrop.SetIsDropTarget(e_18, true);
     Binding binding_e_18_ItemsSource = new Binding("DataTwo");
     e_18.SetBinding(ListBox.ItemsSourceProperty, binding_e_18_ItemsSource);
     // e_19 element
     TextBlock e_19 = new TextBlock();
     e_4.Children.Add(e_19);
     e_19.Name = "e_19";
     e_19.VerticalAlignment = VerticalAlignment.Center;
     e_19.Text = "RadioButton";
     Grid.SetRow(e_19, 11);
     // e_20 element
     StackPanel e_20 = new StackPanel();
     e_4.Children.Add(e_20);
     e_20.Name = "e_20";
     e_20.Orientation = Orientation.Horizontal;
     Grid.SetColumn(e_20, 1);
     Grid.SetRow(e_20, 11);
     // e_21 element
     RadioButton e_21 = new RadioButton();
     e_20.Children.Add(e_21);
     e_21.Name = "e_21";
     e_21.Margin = new Thickness(5F, 5F, 5F, 5F);
     e_21.Content = "Radio Button 1";
     e_21.GroupName = "testGroup1";
     // e_22 element
     RadioButton e_22 = new RadioButton();
     e_20.Children.Add(e_22);
     e_22.Name = "e_22";
     e_22.Margin = new Thickness(5F, 5F, 5F, 5F);
     e_22.Content = "Radio Button 2";
     e_22.GroupName = "testGroup1";
     // e_23 element
     RadioButton e_23 = new RadioButton();
     e_20.Children.Add(e_23);
     e_23.Name = "e_23";
     e_23.Margin = new Thickness(5F, 5F, 5F, 5F);
     e_23.Content = "Radio Button 3";
     e_23.GroupName = "testGroup1";
     // e_24 element
     RadioButton e_24 = new RadioButton();
     e_20.Children.Add(e_24);
     e_24.Name = "e_24";
     e_24.Margin = new Thickness(5F, 5F, 5F, 5F);
     e_24.Content = "Radio Button 4";
     e_24.GroupName = "testGroup2";
     // e_25 element
     RadioButton e_25 = new RadioButton();
     e_20.Children.Add(e_25);
     e_25.Name = "e_25";
     e_25.Margin = new Thickness(5F, 5F, 5F, 5F);
     e_25.Content = "Radio Button 5";
     e_25.GroupName = "testGroup2";
     // e_26 element
     RadioButton e_26 = new RadioButton();
     e_20.Children.Add(e_26);
     e_26.Name = "e_26";
     e_26.Margin = new Thickness(5F, 5F, 5F, 5F);
     e_26.Content = "Radio Button 6";
     e_26.GroupName = "testGroup2";
     items.Add(e_3);
     // e_27 element
     TabItem e_27 = new TabItem();
     e_27.Name = "e_27";
     e_27.Header = "DataGrid";
     // e_28 element
     DataGrid e_28 = new DataGrid();
     e_27.Content = e_28;
     e_28.Name = "e_28";
     e_28.AutoGenerateColumns = false;
     DataGridTextColumn e_28_Col0 = new DataGridTextColumn();
     e_28_Col0.Header = "#";
     Binding e_28_Col0_b = new Binding("Number");
     e_28_Col0.Binding = e_28_Col0_b;
     e_28.Columns.Add(e_28_Col0);
     DataGridTextColumn e_28_Col1 = new DataGridTextColumn();
     e_28_Col1.Width = 200F;
     e_28_Col1.Header = "Text";
     Style e_28_Col1_e_s = new Style(typeof(DataGridCell));
     Setter e_28_Col1_e_s_S_0 = new Setter(DataGridCell.BackgroundProperty, new SolidColorBrush(new ColorW(128, 128, 128, 255)));
     e_28_Col1_e_s.Setters.Add(e_28_Col1_e_s_S_0);
     Setter e_28_Col1_e_s_S_1 = new Setter(DataGridCell.HorizontalAlignmentProperty, HorizontalAlignment.Center);
     e_28_Col1_e_s.Setters.Add(e_28_Col1_e_s_S_1);
     Setter e_28_Col1_e_s_S_2 = new Setter(DataGridCell.VerticalAlignmentProperty, VerticalAlignment.Center);
     e_28_Col1_e_s.Setters.Add(e_28_Col1_e_s_S_2);
     e_28_Col1.ElementStyle = e_28_Col1_e_s;
     Binding e_28_Col1_b = new Binding("Text");
     e_28_Col1.Binding = e_28_Col1_b;
     e_28.Columns.Add(e_28_Col1);
     DataGridCheckBoxColumn e_28_Col2 = new DataGridCheckBoxColumn();
     e_28_Col2.Width = DataGridLength.SizeToHeader;
     e_28_Col2.Header = "Bool";
     Binding e_28_Col2_b = new Binding("Boolean");
     e_28_Col2.Binding = e_28_Col2_b;
     e_28.Columns.Add(e_28_Col2);
     DataGridTemplateColumn e_28_Col3 = new DataGridTemplateColumn();
     e_28_Col3.Width = new DataGridLength(1F, DataGridLengthUnitType.Star);
     // e_29 element
     TextBlock e_29 = new TextBlock();
     e_29.Name = "e_29";
     e_29.Text = "Template Column";
     e_28_Col3.Header = e_29;
     Style e_28_Col3_h_s = new Style(typeof(DataGridColumnHeader));
     Setter e_28_Col3_h_s_S_0 = new Setter(DataGridColumnHeader.ForegroundProperty, new SolidColorBrush(new ColorW(255, 165, 0, 255)));
     e_28_Col3_h_s.Setters.Add(e_28_Col3_h_s_S_0);
     e_28_Col3.HeaderStyle = e_28_Col3_h_s;
     Func<UIElement, UIElement> e_28_Col3_ct_dtFunc = e_28_Col3_ct_dtMethod;
     e_28_Col3.CellTemplate = new DataTemplate(e_28_Col3_ct_dtFunc);
     e_28.Columns.Add(e_28_Col3);
     Binding binding_e_28_ItemsSource = new Binding("GridData");
     e_28.SetBinding(DataGrid.ItemsSourceProperty, binding_e_28_ItemsSource);
     items.Add(e_27);
     // e_35 element
     TabItem e_35 = new TabItem();
     e_35.Name = "e_35";
     e_35.Header = "TreeView";
     // e_36 element
     TreeView e_36 = new TreeView();
     e_35.Content = e_36;
     e_36.Name = "e_36";
     Binding binding_e_36_ItemsSource = new Binding("TreeItems");
     e_36.SetBinding(TreeView.ItemsSourceProperty, binding_e_36_ItemsSource);
     items.Add(e_35);
     // e_37 element
     TabItem e_37 = new TabItem();
     e_37.Name = "e_37";
     e_37.Header = "Chart";
     // e_38 element
     Chart e_38 = new Chart();
     e_37.Content = e_38;
     e_38.Name = "e_38";
     e_38.AxisYMajorUnit = 50F;
     // e_39 element
     LineSeries2D e_39 = new LineSeries2D();
     e_38.Series.Add(e_39);
     e_39.Name = "e_39";
     // p_40 point
     SeriesPoint p_40 = new SeriesPoint();
     e_39.Points.Add(p_40);
     p_40.Argument = 0F;
     p_40.Value = 0F;
     // p_41 point
     SeriesPoint p_41 = new SeriesPoint();
     e_39.Points.Add(p_41);
     p_41.Argument = 1F;
     p_41.Value = 10F;
     // p_42 point
     SeriesPoint p_42 = new SeriesPoint();
     e_39.Points.Add(p_42);
     p_42.Argument = 2F;
     p_42.Value = 20F;
     // p_43 point
     SeriesPoint p_43 = new SeriesPoint();
     e_39.Points.Add(p_43);
     p_43.Argument = 3F;
     p_43.Value = 50F;
     // p_44 point
     SeriesPoint p_44 = new SeriesPoint();
     e_39.Points.Add(p_44);
     p_44.Argument = 4F;
     p_44.Value = 100F;
     // p_45 point
     SeriesPoint p_45 = new SeriesPoint();
     e_39.Points.Add(p_45);
     p_45.Argument = 5F;
     p_45.Value = 200F;
     // p_46 point
     SeriesPoint p_46 = new SeriesPoint();
     e_39.Points.Add(p_46);
     p_46.Argument = 6F;
     p_46.Value = 500F;
     // e_47 element
     LineSeries2D e_47 = new LineSeries2D();
     e_38.Series.Add(e_47);
     e_47.Name = "e_47";
     e_47.Foreground = new SolidColorBrush(new ColorW(255, 165, 0, 255));
     e_47.LineThickness = 1F;
     Binding binding_e_47_DataSource = new Binding("ChartData");
     e_47.SetBinding(LineSeries2D.DataSourceProperty, binding_e_47_DataSource);
     items.Add(e_37);
     // e_48 element
     TabItem e_48 = new TabItem();
     e_48.Name = "e_48";
     e_48.Header = "Shapes";
     // e_49 element
     Grid e_49 = new Grid();
     e_48.Content = e_49;
     e_49.Name = "e_49";
     RowDefinition row_e_49_0 = new RowDefinition();
     e_49.RowDefinitions.Add(row_e_49_0);
     RowDefinition row_e_49_1 = new RowDefinition();
     e_49.RowDefinitions.Add(row_e_49_1);
     RowDefinition row_e_49_2 = new RowDefinition();
     e_49.RowDefinitions.Add(row_e_49_2);
     ColumnDefinition col_e_49_0 = new ColumnDefinition();
     e_49.ColumnDefinitions.Add(col_e_49_0);
     ColumnDefinition col_e_49_1 = new ColumnDefinition();
     e_49.ColumnDefinitions.Add(col_e_49_1);
     ColumnDefinition col_e_49_2 = new ColumnDefinition();
     e_49.ColumnDefinitions.Add(col_e_49_2);
     // e_50 element
     Rectangle e_50 = new Rectangle();
     e_49.Children.Add(e_50);
     e_50.Name = "e_50";
     e_50.Height = 100F;
     e_50.Width = 200F;
     e_50.Margin = new Thickness(5F, 5F, 5F, 5F);
     e_50.Fill = new SolidColorBrush(new ColorW(0, 128, 0, 255));
     e_50.Stroke = new SolidColorBrush(new ColorW(128, 128, 128, 255));
     e_50.StrokeThickness = 5F;
     e_50.RadiusX = 10F;
     e_50.RadiusY = 10F;
     // e_51 element
     Rectangle e_51 = new Rectangle();
     e_49.Children.Add(e_51);
     e_51.Name = "e_51";
     e_51.Height = 100F;
     e_51.Width = 200F;
     e_51.Margin = new Thickness(5F, 5F, 5F, 5F);
     e_51.Fill = new SolidColorBrush(new ColorW(255, 165, 0, 255));
     Grid.SetColumn(e_51, 1);
     // e_52 element
     Rectangle e_52 = new Rectangle();
     e_49.Children.Add(e_52);
     e_52.Name = "e_52";
     e_52.Height = 100F;
     e_52.Width = 200F;
     e_52.Margin = new Thickness(5F, 5F, 5F, 5F);
     LinearGradientBrush e_52_Fill = new LinearGradientBrush();
     e_52_Fill.StartPoint = new PointF(0F, 0F);
     e_52_Fill.EndPoint = new PointF(1F, 1F);
     e_52_Fill.SpreadMethod = GradientSpreadMethod.Pad;
     e_52_Fill.GradientStops.Add(new GradientStop(new ColorW(255, 165, 0, 255), 0.5F));
     e_52_Fill.GradientStops.Add(new GradientStop(new ColorW(0, 162, 255, 255), 0F));
     e_52.Fill = e_52_Fill;
     LinearGradientBrush e_52_Stroke = new LinearGradientBrush();
     e_52_Stroke.StartPoint = new PointF(0F, 0F);
     e_52_Stroke.EndPoint = new PointF(1F, 1F);
     e_52_Stroke.SpreadMethod = GradientSpreadMethod.Pad;
     e_52_Stroke.GradientStops.Add(new GradientStop(new ColorW(0, 162, 255, 255), 0.5F));
     e_52_Stroke.GradientStops.Add(new GradientStop(new ColorW(255, 165, 0, 255), 0F));
     e_52.Stroke = e_52_Stroke;
     e_52.StrokeThickness = 5F;
     e_52.RadiusX = 10F;
     e_52.RadiusY = 10F;
     Grid.SetColumn(e_52, 2);
     // e_53 element
     Ellipse e_53 = new Ellipse();
     e_49.Children.Add(e_53);
     e_53.Name = "e_53";
     e_53.Height = 100F;
     e_53.Width = 200F;
     e_53.Margin = new Thickness(5F, 5F, 5F, 5F);
     e_53.Fill = new SolidColorBrush(new ColorW(128, 128, 128, 255));
     e_53.Stroke = new SolidColorBrush(new ColorW(0, 128, 0, 255));
     e_53.StrokeThickness = 10F;
     Grid.SetRow(e_53, 1);
     // e_54 element
     Ellipse e_54 = new Ellipse();
     e_49.Children.Add(e_54);
     e_54.Name = "e_54";
     e_54.Height = 100F;
     e_54.Width = 200F;
     e_54.Margin = new Thickness(5F, 5F, 5F, 5F);
     e_54.Stroke = new SolidColorBrush(new ColorW(255, 165, 0, 255));
     e_54.StrokeThickness = 10F;
     Grid.SetColumn(e_54, 1);
     Grid.SetRow(e_54, 1);
     // e_55 element
     Ellipse e_55 = new Ellipse();
     e_49.Children.Add(e_55);
     e_55.Name = "e_55";
     e_55.Height = 100F;
     e_55.Width = 200F;
     e_55.Margin = new Thickness(5F, 5F, 5F, 5F);
     LinearGradientBrush e_55_Fill = new LinearGradientBrush();
     e_55_Fill.StartPoint = new PointF(0F, 0F);
     e_55_Fill.EndPoint = new PointF(1F, 1F);
     e_55_Fill.SpreadMethod = GradientSpreadMethod.Pad;
     e_55_Fill.GradientStops.Add(new GradientStop(new ColorW(255, 165, 0, 255), 0.5F));
     e_55_Fill.GradientStops.Add(new GradientStop(new ColorW(0, 162, 255, 255), 0F));
     e_55.Fill = e_55_Fill;
     LinearGradientBrush e_55_Stroke = new LinearGradientBrush();
     e_55_Stroke.StartPoint = new PointF(0F, 0F);
     e_55_Stroke.EndPoint = new PointF(1F, 1F);
     e_55_Stroke.SpreadMethod = GradientSpreadMethod.Pad;
     e_55_Stroke.GradientStops.Add(new GradientStop(new ColorW(0, 162, 255, 255), 0.5F));
     e_55_Stroke.GradientStops.Add(new GradientStop(new ColorW(255, 165, 0, 255), 0F));
     e_55.Stroke = e_55_Stroke;
     e_55.StrokeThickness = 10F;
     Grid.SetColumn(e_55, 2);
     Grid.SetRow(e_55, 1);
     // e_56 element
     Line e_56 = new Line();
     e_49.Children.Add(e_56);
     e_56.Name = "e_56";
     e_56.Stroke = new SolidColorBrush(new ColorW(128, 128, 128, 255));
     e_56.StrokeThickness = 10F;
     e_56.X1 = 10F;
     e_56.X2 = 150F;
     e_56.Y1 = 10F;
     e_56.Y2 = 150F;
     Grid.SetRow(e_56, 2);
     // e_57 element
     Line e_57 = new Line();
     e_49.Children.Add(e_57);
     e_57.Name = "e_57";
     e_57.Stroke = new SolidColorBrush(new ColorW(128, 128, 128, 255));
     e_57.StrokeThickness = 10F;
     e_57.X1 = 100F;
     e_57.X2 = 100F;
     e_57.Y1 = 10F;
     e_57.Y2 = 100F;
     Grid.SetRow(e_57, 2);
     // e_58 element
     Line e_58 = new Line();
     e_49.Children.Add(e_58);
     e_58.Name = "e_58";
     e_58.Stroke = new SolidColorBrush(new ColorW(128, 128, 128, 255));
     e_58.StrokeThickness = 10F;
     e_58.X1 = 10F;
     e_58.X2 = 100F;
     e_58.Y1 = 100F;
     e_58.Y2 = 100F;
     Grid.SetRow(e_58, 2);
     // e_59 element
     Rectangle e_59 = new Rectangle();
     e_49.Children.Add(e_59);
     e_59.Name = "e_59";
     e_59.Height = 100F;
     e_59.Width = 200F;
     e_59.Margin = new Thickness(5F, 5F, 5F, 5F);
     ImageBrush e_59_Fill = new ImageBrush();
     BitmapImage e_59_Fill_bm = new BitmapImage();
     e_59_Fill_bm.TextureAsset = "Images/MonoGameLogo";
     e_59_Fill.ImageSource = e_59_Fill_bm;
     e_59_Fill.Stretch = Stretch.None;
     e_59.Fill = e_59_Fill;
     e_59.Stroke = new SolidColorBrush(new ColorW(255, 255, 255, 255));
     e_59.StrokeThickness = 1F;
     e_59.RadiusX = 10F;
     e_59.RadiusY = 10F;
     Grid.SetColumn(e_59, 1);
     Grid.SetRow(e_59, 2);
     // e_60 element
     Image e_60 = new Image();
     e_49.Children.Add(e_60);
     e_60.Name = "e_60";
     Grid.SetColumn(e_60, 2);
     Grid.SetRow(e_60, 2);
     Binding binding_e_60_Source = new Binding("RenderTargetSource");
     e_60.SetBinding(Image.SourceProperty, binding_e_60_Source);
     items.Add(e_48);
     // e_61 element
     TabItem e_61 = new TabItem();
     e_61.Name = "e_61";
     e_61.Header = "Animations";
     // e_62 element
     Grid e_62 = new Grid();
     e_61.Content = e_62;
     e_62.Name = "e_62";
     ColumnDefinition col_e_62_0 = new ColumnDefinition();
     e_62.ColumnDefinitions.Add(col_e_62_0);
     ColumnDefinition col_e_62_1 = new ColumnDefinition();
     e_62.ColumnDefinitions.Add(col_e_62_1);
     // e_63 element
     StackPanel e_63 = new StackPanel();
     e_62.Children.Add(e_63);
     e_63.Name = "e_63";
     // animButton1 element
     Button animButton1 = new Button();
     e_63.Children.Add(animButton1);
     animButton1.Name = "animButton1";
     animButton1.TabIndex = 1;
     animButton1.Content = "Mouse Over me!";
     animButton1.SetResourceReference(Button.StyleProperty, "buttonAnimStyle");
     // animButton2 element
     Button animButton2 = new Button();
     e_63.Children.Add(animButton2);
     animButton2.Name = "animButton2";
     animButton2.TabIndex = 2;
     animButton2.Content = "Mouse Over me!";
     animButton2.SetResourceReference(Button.StyleProperty, "buttonAnimStyle");
     // animButton3 element
     Button animButton3 = new Button();
     e_63.Children.Add(animButton3);
     animButton3.Name = "animButton3";
     animButton3.TabIndex = 3;
     animButton3.Content = "Mouse Over me!";
     animButton3.SetResourceReference(Button.StyleProperty, "buttonAnimStyle");
     // animButton4 element
     Button animButton4 = new Button();
     e_63.Children.Add(animButton4);
     animButton4.Name = "animButton4";
     animButton4.TabIndex = 4;
     animButton4.Content = "Mouse Over me!";
     animButton4.SetResourceReference(Button.StyleProperty, "buttonAnimStyle");
     // animBorder1 element
     Border animBorder1 = new Border();
     e_62.Children.Add(animBorder1);
     animBorder1.Name = "animBorder1";
     animBorder1.Height = 100F;
     animBorder1.Width = 200F;
     animBorder1.Margin = new Thickness(0F, 10F, 0F, 10F);
     animBorder1.VerticalAlignment = VerticalAlignment.Top;
     EventTrigger animBorder1_ET_0 = new EventTrigger(Border.LoadedEvent, animBorder1);
     animBorder1.Triggers.Add(animBorder1_ET_0);
     BeginStoryboard animBorder1_ET_0_AC_0 = new BeginStoryboard();
     animBorder1_ET_0_AC_0.Name = "animBorder1_ET_0_AC_0";
     animBorder1_ET_0.AddAction(animBorder1_ET_0_AC_0);
     Storyboard animBorder1_ET_0_AC_0_SB = new Storyboard();
     animBorder1_ET_0_AC_0.Storyboard = animBorder1_ET_0_AC_0_SB;
     animBorder1_ET_0_AC_0_SB.Name = "animBorder1_ET_0_AC_0_SB";
     SolidColorBrushAnimation animBorder1_ET_0_AC_0_SB_TL_0 = new SolidColorBrushAnimation();
     animBorder1_ET_0_AC_0_SB_TL_0.Name = "animBorder1_ET_0_AC_0_SB_TL_0";
     animBorder1_ET_0_AC_0_SB_TL_0.AutoReverse = true;
     animBorder1_ET_0_AC_0_SB_TL_0.Duration = new Duration(new TimeSpan(0, 0, 0, 5, 0));
     animBorder1_ET_0_AC_0_SB_TL_0.RepeatBehavior = RepeatBehavior.Forever;
     animBorder1_ET_0_AC_0_SB_TL_0.From = new ColorW(255, 255, 0, 255);
     animBorder1_ET_0_AC_0_SB_TL_0.To = new ColorW(0, 0, 255, 255);
     ExponentialEase animBorder1_ET_0_AC_0_SB_TL_0_EA = new ExponentialEase();
     animBorder1_ET_0_AC_0_SB_TL_0.EasingFunction = animBorder1_ET_0_AC_0_SB_TL_0_EA;
     Storyboard.SetTargetName(animBorder1_ET_0_AC_0_SB_TL_0, "animBorder1");
     Storyboard.SetTargetProperty(animBorder1_ET_0_AC_0_SB_TL_0, Border.BackgroundProperty);
     animBorder1_ET_0_AC_0_SB.Children.Add(animBorder1_ET_0_AC_0_SB_TL_0);
     Grid.SetColumn(animBorder1, 1);
     // animBorder2 element
     Border animBorder2 = new Border();
     e_62.Children.Add(animBorder2);
     animBorder2.Name = "animBorder2";
     animBorder2.Height = 50F;
     animBorder2.Width = 100F;
     animBorder2.Margin = new Thickness(50F, 35F, 50F, 35F);
     animBorder2.VerticalAlignment = VerticalAlignment.Top;
     EventTrigger animBorder2_ET_0 = new EventTrigger(Border.LoadedEvent, animBorder2);
     animBorder2.Triggers.Add(animBorder2_ET_0);
     BeginStoryboard animBorder2_ET_0_AC_0 = new BeginStoryboard();
     animBorder2_ET_0_AC_0.Name = "animBorder2_ET_0_AC_0";
     animBorder2_ET_0.AddAction(animBorder2_ET_0_AC_0);
     Storyboard animBorder2_ET_0_AC_0_SB = new Storyboard();
     animBorder2_ET_0_AC_0.Storyboard = animBorder2_ET_0_AC_0_SB;
     animBorder2_ET_0_AC_0_SB.Name = "animBorder2_ET_0_AC_0_SB";
     SolidColorBrushAnimation animBorder2_ET_0_AC_0_SB_TL_0 = new SolidColorBrushAnimation();
     animBorder2_ET_0_AC_0_SB_TL_0.Name = "animBorder2_ET_0_AC_0_SB_TL_0";
     animBorder2_ET_0_AC_0_SB_TL_0.AutoReverse = true;
     animBorder2_ET_0_AC_0_SB_TL_0.Duration = new Duration(new TimeSpan(0, 0, 0, 3, 0));
     animBorder2_ET_0_AC_0_SB_TL_0.RepeatBehavior = RepeatBehavior.Forever;
     animBorder2_ET_0_AC_0_SB_TL_0.From = new ColorW(255, 0, 0, 255);
     animBorder2_ET_0_AC_0_SB_TL_0.To = new ColorW(255, 255, 255, 255);
     CubicEase animBorder2_ET_0_AC_0_SB_TL_0_EA = new CubicEase();
     animBorder2_ET_0_AC_0_SB_TL_0.EasingFunction = animBorder2_ET_0_AC_0_SB_TL_0_EA;
     Storyboard.SetTargetName(animBorder2_ET_0_AC_0_SB_TL_0, "animBorder2");
     Storyboard.SetTargetProperty(animBorder2_ET_0_AC_0_SB_TL_0, Border.BackgroundProperty);
     animBorder2_ET_0_AC_0_SB.Children.Add(animBorder2_ET_0_AC_0_SB_TL_0);
     FloatAnimation animBorder2_ET_0_AC_0_SB_TL_1 = new FloatAnimation();
     animBorder2_ET_0_AC_0_SB_TL_1.Name = "animBorder2_ET_0_AC_0_SB_TL_1";
     animBorder2_ET_0_AC_0_SB_TL_1.AutoReverse = true;
     animBorder2_ET_0_AC_0_SB_TL_1.Duration = new Duration(new TimeSpan(0, 0, 0, 4, 0));
     animBorder2_ET_0_AC_0_SB_TL_1.RepeatBehavior = RepeatBehavior.Forever;
     animBorder2_ET_0_AC_0_SB_TL_1.From = 1F;
     animBorder2_ET_0_AC_0_SB_TL_1.To = 0F;
     Storyboard.SetTargetName(animBorder2_ET_0_AC_0_SB_TL_1, "animBorder2");
     Storyboard.SetTargetProperty(animBorder2_ET_0_AC_0_SB_TL_1, Border.OpacityProperty);
     animBorder2_ET_0_AC_0_SB.Children.Add(animBorder2_ET_0_AC_0_SB_TL_1);
     Grid.SetColumn(animBorder2, 1);
     items.Add(e_61);
     // e_64 element
     TabItem e_64 = new TabItem();
     e_64.Name = "e_64";
     e_64.Header = "Tetris";
     // e_65 element
     Border e_65 = new Border();
     e_64.Content = e_65;
     e_65.Name = "e_65";
     // e_66 element
     Grid e_66 = new Grid();
     e_65.Child = e_66;
     e_66.Name = "e_66";
     e_66.Margin = new Thickness(10F, 10F, 10F, 10F);
     RowDefinition row_e_66_0 = new RowDefinition();
     row_e_66_0.Height = new GridLength(1F, GridUnitType.Auto);
     e_66.RowDefinitions.Add(row_e_66_0);
     RowDefinition row_e_66_1 = new RowDefinition();
     row_e_66_1.Height = new GridLength(420F, GridUnitType.Pixel);
     e_66.RowDefinitions.Add(row_e_66_1);
     ColumnDefinition col_e_66_0 = new ColumnDefinition();
     e_66.ColumnDefinitions.Add(col_e_66_0);
     ColumnDefinition col_e_66_1 = new ColumnDefinition();
     e_66.ColumnDefinitions.Add(col_e_66_1);
     ColumnDefinition col_e_66_2 = new ColumnDefinition();
     e_66.ColumnDefinitions.Add(col_e_66_2);
     // e_67 element
     StackPanel e_67 = new StackPanel();
     e_66.Children.Add(e_67);
     e_67.Name = "e_67";
     e_67.HorizontalAlignment = HorizontalAlignment.Right;
     e_67.Orientation = Orientation.Vertical;
     Grid.SetRow(e_67, 1);
     // e_68 element
     TextBlock e_68 = new TextBlock();
     e_67.Children.Add(e_68);
     e_68.Name = "e_68";
     e_68.Text = "Next";
     // e_69 element
     Border e_69 = new Border();
     e_67.Children.Add(e_69);
     e_69.Name = "e_69";
     e_69.Height = 81F;
     e_69.Width = 81F;
     e_69.BorderBrush = new SolidColorBrush(new ColorW(255, 255, 255, 255));
     e_69.BorderThickness = new Thickness(0F, 0F, 1F, 1F);
     // tetrisNextContainer1 element
     Canvas tetrisNextContainer1 = new Canvas();
     e_69.Child = tetrisNextContainer1;
     tetrisNextContainer1.Name = "tetrisNextContainer1";
     tetrisNextContainer1.Height = 80F;
     tetrisNextContainer1.Width = 80F;
     // e_70 element
     Border e_70 = new Border();
     e_66.Children.Add(e_70);
     e_70.Name = "e_70";
     e_70.Height = 401F;
     e_70.Width = 201F;
     e_70.BorderBrush = new SolidColorBrush(new ColorW(255, 255, 255, 255));
     e_70.BorderThickness = new Thickness(0F, 0F, 1F, 1F);
     Grid.SetColumn(e_70, 1);
     Grid.SetRow(e_70, 1);
     // tetrisContainer1 element
     Canvas tetrisContainer1 = new Canvas();
     e_70.Child = tetrisContainer1;
     tetrisContainer1.Name = "tetrisContainer1";
     tetrisContainer1.Height = 400F;
     tetrisContainer1.Width = 200F;
     tetrisContainer1.HorizontalAlignment = HorizontalAlignment.Left;
     tetrisContainer1.VerticalAlignment = VerticalAlignment.Top;
     // e_71 element
     Grid e_71 = new Grid();
     e_66.Children.Add(e_71);
     e_71.Name = "e_71";
     RowDefinition row_e_71_0 = new RowDefinition();
     row_e_71_0.Height = new GridLength(1F, GridUnitType.Auto);
     e_71.RowDefinitions.Add(row_e_71_0);
     RowDefinition row_e_71_1 = new RowDefinition();
     row_e_71_1.Height = new GridLength(1F, GridUnitType.Auto);
     e_71.RowDefinitions.Add(row_e_71_1);
     ColumnDefinition col_e_71_0 = new ColumnDefinition();
     col_e_71_0.Width = new GridLength(1F, GridUnitType.Auto);
     e_71.ColumnDefinitions.Add(col_e_71_0);
     ColumnDefinition col_e_71_1 = new ColumnDefinition();
     col_e_71_1.Width = new GridLength(1F, GridUnitType.Star);
     e_71.ColumnDefinitions.Add(col_e_71_1);
     ColumnDefinition col_e_71_2 = new ColumnDefinition();
     col_e_71_2.Width = new GridLength(1F, GridUnitType.Auto);
     e_71.ColumnDefinitions.Add(col_e_71_2);
     Grid.SetColumnSpan(e_71, 3);
     Binding binding_e_71_DataContext = new Binding("Tetris");
     e_71.SetBinding(Grid.DataContextProperty, binding_e_71_DataContext);
     // e_72 element
     Button e_72 = new Button();
     e_71.Children.Add(e_72);
     e_72.Name = "e_72";
     e_72.Height = 30F;
     e_72.Content = "Start";
     Grid.SetColumnSpan(e_72, 3);
     Binding binding_e_72_Command = new Binding("StartCommand");
     e_72.SetBinding(Button.CommandProperty, binding_e_72_Command);
     // e_73 element
     Grid e_73 = new Grid();
     e_71.Children.Add(e_73);
     e_73.Name = "e_73";
     RowDefinition row_e_73_0 = new RowDefinition();
     row_e_73_0.Height = new GridLength(1F, GridUnitType.Auto);
     e_73.RowDefinitions.Add(row_e_73_0);
     ColumnDefinition col_e_73_0 = new ColumnDefinition();
     e_73.ColumnDefinitions.Add(col_e_73_0);
     ColumnDefinition col_e_73_1 = new ColumnDefinition();
     col_e_73_1.Width = new GridLength(70F, GridUnitType.Pixel);
     e_73.ColumnDefinitions.Add(col_e_73_1);
     ColumnDefinition col_e_73_2 = new ColumnDefinition();
     e_73.ColumnDefinitions.Add(col_e_73_2);
     Grid.SetColumn(e_73, 1);
     Grid.SetRow(e_73, 1);
     // spPlayer1 element
     StackPanel spPlayer1 = new StackPanel();
     e_73.Children.Add(spPlayer1);
     spPlayer1.Name = "spPlayer1";
     spPlayer1.HorizontalAlignment = HorizontalAlignment.Right;
     spPlayer1.Orientation = Orientation.Vertical;
     // e_74 element
     TextBlock e_74 = new TextBlock();
     spPlayer1.Children.Add(e_74);
     e_74.Name = "e_74";
     Binding binding_e_74_Text = new Binding("Score");
     e_74.SetBinding(TextBlock.TextProperty, binding_e_74_Text);
     // e_75 element
     TextBlock e_75 = new TextBlock();
     spPlayer1.Children.Add(e_75);
     e_75.Name = "e_75";
     Binding binding_e_75_Text = new Binding("Lines");
     e_75.SetBinding(TextBlock.TextProperty, binding_e_75_Text);
     // e_76 element
     TextBlock e_76 = new TextBlock();
     spPlayer1.Children.Add(e_76);
     e_76.Name = "e_76";
     Binding binding_e_76_Text = new Binding("Level");
     e_76.SetBinding(TextBlock.TextProperty, binding_e_76_Text);
     // e_77 element
     StackPanel e_77 = new StackPanel();
     e_73.Children.Add(e_77);
     e_77.Name = "e_77";
     e_77.HorizontalAlignment = HorizontalAlignment.Center;
     e_77.Orientation = Orientation.Vertical;
     Grid.SetColumn(e_77, 1);
     // e_78 element
     TextBlock e_78 = new TextBlock();
     e_77.Children.Add(e_78);
     e_78.Name = "e_78";
     e_78.Text = "SCORE";
     // e_79 element
     TextBlock e_79 = new TextBlock();
     e_77.Children.Add(e_79);
     e_79.Name = "e_79";
     e_79.Text = "LINES";
     // e_80 element
     TextBlock e_80 = new TextBlock();
     e_77.Children.Add(e_80);
     e_80.Name = "e_80";
     e_80.Text = "LEVEL";
     // e_81 element
     StackPanel e_81 = new StackPanel();
     e_73.Children.Add(e_81);
     e_81.Name = "e_81";
     e_81.HorizontalAlignment = HorizontalAlignment.Left;
     e_81.Orientation = Orientation.Horizontal;
     // e_82 element
     TextBlock e_82 = new TextBlock();
     e_81.Children.Add(e_82);
     e_82.Name = "e_82";
     e_82.Text = "Use A,S,D,W for left, down, right, rotate";
     items.Add(e_64);
     // e_83 element
     TabItem e_83 = new TabItem();
     e_83.Name = "e_83";
     e_83.Header = "User Control";
     // e_84 element
     UserControlTest e_84 = new UserControlTest();
     e_83.Content = e_84;
     e_84.Name = "e_84";
     items.Add(e_83);
     return items;
 }
コード例 #12
0
        private void InitNodeSurround()
        {
            picSkillSurround     = new DrawingVisual();
            picSkillBaseSurround = new DrawingVisual();

            if (!_Initialized)
            {
                Size sizeNot;
                var  brNot = new ImageBrush();
                brNot.Stretch = Stretch.Uniform;
                BitmapImage PImageNot = _assets[NodeBackgrounds["notable"]].PImage;
                brNot.ImageSource = PImageNot;
                sizeNot           = new Size(PImageNot.PixelWidth, PImageNot.PixelHeight);

                var brNotH = new ImageBrush();
                brNotH.Stretch = Stretch.Uniform;
                BitmapImage PImageNotH = _assets[NodeBackgroundsActive["notable"]].PImage;
                brNotH.ImageSource = PImageNotH;
                Size sizeNotH = new Size(PImageNotH.PixelWidth, PImageNotH.PixelHeight);


                var brKS = new ImageBrush();
                brKS.Stretch = Stretch.Uniform;
                BitmapImage PImageKr = _assets[NodeBackgrounds["keystone"]].PImage;
                brKS.ImageSource = PImageKr;
                Size sizeKs = new Size(PImageKr.PixelWidth, PImageKr.PixelHeight);

                var brKSH = new ImageBrush();
                brKSH.Stretch = Stretch.Uniform;
                BitmapImage PImageKrH = _assets[NodeBackgroundsActive["keystone"]].PImage;
                brKSH.ImageSource = PImageKrH;
                Size sizeKsH = new Size(PImageKrH.PixelWidth, PImageKrH.PixelHeight);

                var brNorm = new ImageBrush();
                brNorm.Stretch = Stretch.Uniform;
                BitmapImage PImageNorm = _assets[NodeBackgrounds["normal"]].PImage;
                brNorm.ImageSource = PImageNorm;
                Size isizeNorm = new Size(PImageNorm.PixelWidth, PImageNorm.PixelHeight);

                var brNormA = new ImageBrush();
                brNormA.Stretch = Stretch.Uniform;
                BitmapImage PImageNormA = _assets[NodeBackgroundsActive["normal"]].PImage;
                brNormA.ImageSource = PImageNormA;
                Size isizeNormA = new Size(PImageNormA.PixelWidth, PImageNormA.PixelHeight);

                var brJewel = new ImageBrush();
                brJewel.Stretch = Stretch.Uniform;
                BitmapImage PImageJewel = _assets[NodeBackgrounds["jewel"]].PImage;
                brJewel.ImageSource = PImageJewel;
                Size isSizeJewel = new Size(PImageJewel.PixelWidth, PImageJewel.PixelHeight);

                var brJewelA = new ImageBrush();
                brJewelA.Stretch = Stretch.Uniform;
                BitmapImage PImageJewelA = _assets[NodeBackgroundsActive["jewel"]].PImage;
                brJewelA.ImageSource = PImageJewelA;
                Size isSizeJewelA = new Size(PImageJewelA.PixelWidth, PImageJewelA.PixelHeight);

                NodeSurroundBrush.Add(new KeyValuePair <Size, ImageBrush>(isizeNorm, brNorm));
                NodeSurroundBrush.Add(new KeyValuePair <Size, ImageBrush>(isizeNormA, brNormA));
                NodeSurroundBrush.Add(new KeyValuePair <Size, ImageBrush>(sizeKs, brKS));
                NodeSurroundBrush.Add(new KeyValuePair <Size, ImageBrush>(sizeNot, brNot));
                NodeSurroundBrush.Add(new KeyValuePair <Size, ImageBrush>(sizeKsH, brKSH));
                NodeSurroundBrush.Add(new KeyValuePair <Size, ImageBrush>(sizeNotH, brNotH));
                NodeSurroundBrush.Add(new KeyValuePair <Size, ImageBrush>(isSizeJewel, brJewel));
                NodeSurroundBrush.Add(new KeyValuePair <Size, ImageBrush>(isSizeJewelA, brJewelA));



                //outline generator
                foreach (var item in NodeSurroundBrush)
                {
                    var  outlinecolor = _treeComparisonColor;
                    uint omask        = (uint)outlinecolor.B | (uint)outlinecolor.G << 8 | (uint)outlinecolor.R << 16;

                    var bitmap = (BitmapImage)item.Value.ImageSource;
                    var wb     = new WriteableBitmap(bitmap.PixelWidth, bitmap.PixelHeight, bitmap.DpiX, bitmap.DpiY, PixelFormats.Bgra32, null);
                    if (wb.Format == PixelFormats.Bgra32)//BGRA is byte order .. little endian in uint reverse it
                    {
                        uint[] pixeldata = new uint[wb.PixelHeight * wb.PixelWidth];
                        bitmap.CopyPixels(pixeldata, wb.PixelWidth * 4, 0);
                        for (int i = 0; i < pixeldata.Length; i++)
                        {
                            pixeldata[i] = pixeldata[i] & 0xFF000000 | omask;
                        }
                        wb.WritePixels(new Int32Rect(0, 0, wb.PixelWidth, wb.PixelHeight), pixeldata, wb.PixelWidth * 4, 0);

                        var ibr = new ImageBrush();
                        ibr.Stretch     = Stretch.Uniform;
                        ibr.ImageSource = wb;

                        NodeSurroundHighlightBrush.Add(new KeyValuePair <Size, ImageBrush>(item.Key, ibr));
                    }
                    else
                    {
                        //throw??
                    }
                }
            }
        }
コード例 #13
0
ファイル: VideoList.cs プロジェクト: bharatvaj/File360
 public VideoList(string videoName, TimeSpan videoDuration, ImageBrush preview)
 {
     this.VideoName     = videoName;
     this.VideoDuration = videoDuration.ToString();
     this.Preview       = preview;
 }
コード例 #14
0
        void initData()
        {
            ImageBrush selectBrush = new ImageBrush {
                ImageSource = new BitmapImage(new Uri(@"Resources/bar06.png", UriKind.Relative))
            };


            bool isSucced = PageInfo.RemoveCommad("testPage");

            TestPage = new TestPage();
            PageInfo testPageInfo = new PageInfo(
                "testPage",
                TestPage,
                (ImageBrush)testPage.Background,
                selectBrush,
                testPage,
                null
                );

            if (isSucced)
            {
                return;
            }
            LoadPage = new LoadPage();
            PageInfo workflowPageInfo = new PageInfo(
                "workflowEdit",
                null,
                (ImageBrush)workflowEdit.Background,
                selectBrush,
                workflowEdit,
                repositoryUri);
            PageInfo taskCreatePageInfo = new PageInfo(
                "taskCreate",
                null,
                (ImageBrush)taskCreate.Background,
                selectBrush,
                taskCreate,
                taskcreateUri);
            PageInfo taskManagerPage = new PageInfo(
                "taskManager",
                null,
                (ImageBrush)taskManager.Background,
                selectBrush,
                taskManager,
                taskeditUri);
            PageInfo vioceRecordPage = new PageInfo(
                "voiceRecord",
                null,
                (ImageBrush)taskManager.Background,
                selectBrush,
                voiceRecord,
                loginPageUri);
            PageInfo dataQueryPageInfo = new PageInfo(
                "dataQuery",
                null,
                (ImageBrush)dataQuery.Background,
                selectBrush,
                dataQuery,
                resultUri);
            PageInfo statisticsInfo = new PageInfo(
                "statistics",
                null,
                (ImageBrush)dataQuery.Background,
                selectBrush,
                statistics,
                statisticsUri);
            PageInfo codeManagerPageInfo = new PageInfo(
                "codeMagager",
                null,
                (ImageBrush)codeMagager.Background,
                selectBrush,
                codeMagager,
                activecodeUri);
            PageInfo blacklistPageInfo = new PageInfo(
                "blacklist",
                null,
                (ImageBrush)blacklist.Background,
                selectBrush,
                blacklist,
                blacklistUri);
            PageInfo setupPageInfo = new PageInfo(
                "setup",
                null,
                (ImageBrush)setup.Background,
                selectBrush,
                setup,
                settingUri);
        }
コード例 #15
0
        //Load bitmap from ImageBrush and set it as a bitmapDrawable background on target view
        private static async Task <IDisposable> SetImageBrushAsBackground(CancellationToken ct, BindableView view, ImageBrush background, Windows.Foundation.Rect drawArea, Path maskingPath, Action onImageSet)
        {
            var bitmap = await background.GetBitmap(ct, drawArea, maskingPath);

            onImageSet();

            if (ct.IsCancellationRequested || bitmap == null)
            {
                bitmap?.Recycle();
                bitmap?.Dispose();
                return(Disposable.Empty);
            }

            var bitmapDrawable = new BitmapDrawable(bitmap);

            SetDrawableAlpha(bitmapDrawable, (int)(background.Opacity * __opaqueAlpha));
            ExecuteWithNoRelayout(view, v => v.SetBackgroundDrawable(bitmapDrawable));

            return(Disposable.Create(() =>
            {
                bitmapDrawable?.Bitmap?.Recycle();
                bitmapDrawable?.Dispose();
            }));
        }
コード例 #16
0
        private static IDisposable DispatchSetImageBrushAsBackground(BindableView view, ImageBrush background, Windows.Foundation.Rect drawArea, Action onImageSet, Path maskingPath = null)
        {
            var disposable = new CompositeDisposable();

            Dispatch(
                view?.Dispatcher,
                async ct =>
            {
                var bitmapDisposable = await SetImageBrushAsBackground(ct, view, background, drawArea, maskingPath, onImageSet);
                disposable.Add(bitmapDisposable);
            }
                )
            .DisposeWith(disposable);

            return(disposable);
        }
コード例 #17
0
        private static Material GetPhong(XmlElement e)
        {
            List <Material> l = new List <Material>();

            foreach (XmlNode n in e.ChildNodes)
            {
                string     tag = n.Name;
                XmlElement el  = n as XmlElement;
                if (materialTypes.ContainsKey(tag))
                {
                    Type            t     = materialTypes[tag];
                    ConstructorInfo c     = t.GetConstructor(new Type[0]);
                    Material        mat   = c.Invoke(new object[0]) as Material;
                    Color           color = el.GetColor();
                    PropertyInfo    pi    = t.GetProperty("Color");
                    pi.SetValue(mat, color, null);
                    if (mat is SpecularMaterial)
                    {
                        try
                        {
                            double           refl = e.ToDouble("reflectivity");
                            SpecularMaterial sm   = mat as SpecularMaterial;
                            sm.SpecularPower = refl;
                        }
                        finally
                        {
                        }
                    }
                    XmlElement texture = el.GetChild("texture");
                    if (texture != null)
                    {
                        ImageSource im  = null;
                        string      tex = texture.GetAttribute("texture");
                        XmlElement  et  = null;
                        if (parameters.ContainsKey(tex))
                        {
                            et = parameters[tex].ChildNodes[0] as XmlElement;
                            if (et.Name.Equals("sampler2D"))
                            {
                                string si = et.GetChild("source").InnerText;
                                if (parameters.ContainsKey(si))
                                {
                                    XmlElement ess = parameters[si];
                                    im = ess.InnerText.ToIdName().Find <ImageSource>();
                                    if (im == null)
                                    {
                                        return(null);
                                    }
                                    if (mat is DiffuseMaterial)
                                    {
                                        ImageBrush br = new ImageBrush(im);
                                        br.ViewportUnits = BrushMappingMode.Absolute;
                                        br.Opacity       = 1;
                                        DiffuseMaterial dm = mat as DiffuseMaterial;
                                        dm.Brush = br;
                                    }
                                    else
                                    {
                                        PropertyInfo pib = mat.GetType().GetProperty("Brush");
                                        if (pib != null)
                                        {
                                            ImageBrush br = new ImageBrush(im);
                                            br.Opacity = 1;
                                            pib.SetValue(mat, br, null);
                                        }
                                    }
                                }
                            }
                        }
                        else
                        {
                        }
                        if (et.Name.Equals("surface"))
                        {
                        }
                    }
                    if (mat == null)
                    {
                        return(null);
                    }
                    l.Add(mat);
                }
            }
            if (l.Count == 1)
            {
                return(l[0]);
            }
            MaterialGroup gr = new MaterialGroup();

            foreach (Material m in l)
            {
                gr.Children.Add(m);
            }
            return(gr);
        }
コード例 #18
0
ファイル: StyleConverter.cs プロジェクト: jdeksup/Mapsui.Net4
        private static ImageBrush CreateImageBrush(Styles.Brush brush)
        {
            var bmp = BitmapRegistry.Instance.Get(brush.BitmapId).CreateBitmapImage();

            var imageBrush = new ImageBrush(bmp)
            {
                Viewbox = new Rect(0, 0, bmp.PixelWidth, bmp.PixelHeight),
                Viewport = new Rect(0, 0, bmp.PixelWidth, bmp.PixelHeight),
                ViewportUnits = BrushMappingMode.Absolute,
                ViewboxUnits = BrushMappingMode.Absolute,
                TileMode = TileMode.Tile
            };

            return imageBrush;
        }
コード例 #19
0
ファイル: UIExtensions.cs プロジェクト: jarkkom/awfuldotnet
 public static void SetImageBrushOpenedStoryboard(ImageBrush element, Storyboard value)
 {
     element.SetValue(ImageBrushOpenedStoryboardProperty, value);
 }
コード例 #20
0
        private void DrawBackgroundLayer()
        {
            picBackground = new DrawingVisual();
            using (var drawingContext = picBackground.RenderOpen())
            {
                BitmapImage[] iscr =
                {
                    _assets["PSGroupBackground1"].PImage,
                    _assets["PSGroupBackground2"].PImage,
                    _assets["PSGroupBackground3"].PImage
                };
                var orbitBrush = new Brush[3];
                orbitBrush[0] = new ImageBrush(_assets["PSGroupBackground1"].PImage);
                orbitBrush[1] = new ImageBrush(_assets["PSGroupBackground2"].PImage);
                orbitBrush[2] = new ImageBrush(_assets["PSGroupBackground3"].PImage);
                (orbitBrush[2] as ImageBrush).TileMode = TileMode.FlipXY;
                (orbitBrush[2] as ImageBrush).Viewport = new Rect(0, 0, 1, .5f);

                var backgroundBrush = new ImageBrush(_assets["Background1"].PImage);
                backgroundBrush.TileMode = TileMode.Tile;
                backgroundBrush.Viewport = new Rect(0, 0,
                                                    6 * backgroundBrush.ImageSource.Width / TRect.Width,
                                                    6 * backgroundBrush.ImageSource.Height / TRect.Height);
                drawingContext.DrawRectangle(backgroundBrush, null, TRect);

                var topGradient = new LinearGradientBrush();
                topGradient.GradientStops.Add(new GradientStop(Colors.Black, 1.0));
                topGradient.GradientStops.Add(new GradientStop(new Color(), 0.0));
                topGradient.StartPoint = new Point(0, 1);
                topGradient.EndPoint   = new Point(0, 0);

                var leftGradient = new LinearGradientBrush();
                leftGradient.GradientStops.Add(new GradientStop(Colors.Black, 1.0));
                leftGradient.GradientStops.Add(new GradientStop(new Color(), 0.0));
                leftGradient.StartPoint = new Point(1, 0);
                leftGradient.EndPoint   = new Point(0, 0);

                var bottomGradient = new LinearGradientBrush();
                bottomGradient.GradientStops.Add(new GradientStop(Colors.Black, 1.0));
                bottomGradient.GradientStops.Add(new GradientStop(new Color(), 0.0));
                bottomGradient.StartPoint = new Point(0, 0);
                bottomGradient.EndPoint   = new Point(0, 1);

                var rightGradient = new LinearGradientBrush();
                rightGradient.GradientStops.Add(new GradientStop(Colors.Black, 1.0));
                rightGradient.GradientStops.Add(new GradientStop(new Color(), 0.0));
                rightGradient.StartPoint = new Point(0, 0);
                rightGradient.EndPoint   = new Point(1, 0);

                const int gradientWidth = 200;
                var       topRect       = new Rect2D(TRect.Left, TRect.Top, TRect.Width, gradientWidth);
                var       leftRect      = new Rect2D(TRect.Left, TRect.Top, gradientWidth, TRect.Height);
                var       bottomRect    = new Rect2D(TRect.Left, TRect.Bottom - gradientWidth, TRect.Width, gradientWidth);
                var       rightRect     = new Rect2D(TRect.Right - gradientWidth, TRect.Top, gradientWidth, TRect.Height);

                drawingContext.DrawRectangle(topGradient, null, topRect);
                drawingContext.DrawRectangle(leftGradient, null, leftRect);
                drawingContext.DrawRectangle(bottomGradient, null, bottomRect);
                drawingContext.DrawRectangle(rightGradient, null, rightRect);
                foreach (var skillNodeGroup in NodeGroups)
                {
                    if (skillNodeGroup.OcpOrb == null)
                    {
                        skillNodeGroup.OcpOrb = new Dictionary <int, bool>();
                    }
                    var cgrp = skillNodeGroup.OcpOrb.Keys.Where(ng => ng <= 3);
                    if (!cgrp.Any())
                    {
                        continue;
                    }
                    var maxr = cgrp.Max(ng => ng);
                    if (maxr == 0)
                    {
                        continue;
                    }
                    maxr = maxr > 3 ? 2 : maxr - 1;
                    var maxfac = maxr == 2 ? 2 : 1;
                    drawingContext.DrawRectangle(orbitBrush[maxr], null,
                                                 new Rect(
                                                     skillNodeGroup.Position -
                                                     new Vector2D(iscr[maxr].PixelWidth * 1.25, iscr[maxr].PixelHeight * 1.25 * maxfac),
                                                     new Size(iscr[maxr].PixelWidth * 2.5, iscr[maxr].PixelHeight * 2.5 * maxfac)));
                }
            }
        }
コード例 #21
0
ファイル: NewCore.cs プロジェクト: pimier15/PLInspector
 public async void DisplayBuf(ImageBrush img)
 {
 }
コード例 #22
0
        private void Target_Placement(int x, int y)
        {
            if (gameflg == false)
            {
                this.target1 = new Thumb()
                {
                    Width = 100, Height = 100, Background = System.Windows.Media.Brushes.Black
                };
                this.target2 = new Thumb()
                {
                    Width = 100, Height = 100, Background = System.Windows.Media.Brushes.Black
                };
                this.target3 = new Thumb()
                {
                    Width = 100, Height = 100, Background = System.Windows.Media.Brushes.Black
                };
                this.target4 = new Thumb()
                {
                    Width = 100, Height = 100, Background = System.Windows.Media.Brushes.Black
                };
                this.target5 = new Thumb()
                {
                    Width = 100, Height = 100, Background = System.Windows.Media.Brushes.Black
                };
            }

            ImageBrush imageBrush1 = new ImageBrush();
            string     abstag1     = System.IO.Path.GetFullPath("Image/1.png"); //絶対パスを取得

            imageBrush1.ImageSource = new BitmapImage(new Uri(abstag1));

            ImageBrush imageBrush2 = new ImageBrush();
            string     abstag2     = System.IO.Path.GetFullPath("Image/2.png"); //絶対パスを取得

            imageBrush2.ImageSource = new BitmapImage(new Uri(abstag2));

            ImageBrush imageBrush3 = new ImageBrush();
            string     abstag3     = System.IO.Path.GetFullPath("Image/3.png"); //絶対パスを取得

            imageBrush3.ImageSource = new BitmapImage(new Uri(abstag3));

            ImageBrush imageBrush4 = new ImageBrush();
            string     abstag4     = System.IO.Path.GetFullPath("Image/4.png"); //絶対パスを取得

            imageBrush4.ImageSource = new BitmapImage(new Uri(abstag4));

            ImageBrush imageBrush5 = new ImageBrush();
            string     abstag5     = System.IO.Path.GetFullPath("Image/5.png"); //絶対パスを取得

            imageBrush5.ImageSource = new BitmapImage(new Uri(abstag5));

            target1.Background = imageBrush1;
            target2.Background = imageBrush2;
            target3.Background = imageBrush3;
            target4.Background = imageBrush4;
            target5.Background = imageBrush5;

            Canvas.SetLeft(target1, ta1[x, 0]);
            Canvas.SetTop(target1, ta1[y, 1]);
            this.beback.Children.Add(target1);


            Canvas.SetLeft(target2, ta2[x, 0]);
            Canvas.SetTop(target2, ta2[y, 1]);
            this.beback.Children.Add(target2);


            Canvas.SetLeft(target3, ta3[x, 0]);
            Canvas.SetTop(target3, ta3[y, 1]);
            this.beback.Children.Add(target3);


            Canvas.SetLeft(target4, ta4[x, 0]);
            Canvas.SetTop(target4, ta4[y, 1]);
            this.beback.Children.Add(target4);


            Canvas.SetLeft(target5, ta5[x, 0]);
            Canvas.SetTop(target5, ta5[y, 1]);
            this.beback.Children.Add(target5);
        }
コード例 #23
0
 public Block(double x, double y, Color color, ImageBrush imageBrush = null)
 {
     Position   = new Point(x, y);
     Color      = color;
     ImageBrush = imageBrush;
 }
コード例 #24
0
        /// <summary>
        /// Handle a left mouse button down event on a face rectangle.
        /// </summary>
        /// <param name="sender">the face rectangle that sent the event.</param>
        /// <param name="e">The event arguments.</param>
        private void Rectangle_MouseLeftButtonDown(object sender, System.Windows.Input.MouseButtonEventArgs e)
        {
            // helper method to convert glasses type to string
            string GlassesToString(Glasses glasses)
            {
                switch (glasses)
                {
                case Microsoft.ProjectOxford.Face.Contract.Glasses.NoGlasses:
                    return("none");

                case Microsoft.ProjectOxford.Face.Contract.Glasses.ReadingGlasses:
                    return("reading glasses");

                case Microsoft.ProjectOxford.Face.Contract.Glasses.Sunglasses:
                    return("sunglasses");

                case Microsoft.ProjectOxford.Face.Contract.Glasses.SwimmingGoggles:
                    return("swimming goggles");

                default:
                    return("unknown glasses");
                }
            }

            // helper method to convert accessory type to string
            string AccessoryToString(AccessoryType accessory)
            {
                switch (accessory)
                {
                case AccessoryType.Glasses:
                    return("glasses");

                case AccessoryType.Headwear:
                    return("headwear");

                case AccessoryType.Mask:
                    return("mask");

                default:
                    return("unknown accessory");
                }
            }

            // find the face instance describing this rectangle
            var rectangle = (System.Windows.Shapes.Rectangle)sender;
            var face      = (from f in faces
                             where f.FaceId == (Guid)rectangle.Tag
                             select f).FirstOrDefault();

            // update labels
            if (face != null)
            {
                var attr = face.FaceAttributes;
                Gender.Content    = $"Gender: {attr.Gender}";
                Age.Content       = $"Age: {attr.Age}";
                Emotion.Content   = $"Emotion: {attr.Emotion.ToRankedList().First().Key.ToLower()}";
                Hair.Content      = $"Hair: {attr.Hair.HairColor.OrderByDescending(h => h.Confidence).FirstOrDefault()?.Color.ToString().ToLower()}";
                Beard.Content     = $"Beard: {100 * attr.FacialHair.Beard}%";
                Moustache.Content = $"Moustache: {100 * attr.FacialHair.Moustache}%";
                Glasses.Content   = $"Glasses: {GlassesToString(attr.Glasses)}";
                EyeMakeup.Content = $"Eye Makeup: {(attr.Makeup.EyeMakeup ? "yes" : "no")}";
                LipMakeup.Content = $"Lip Makeup: {(attr.Makeup.LipMakeup ? "yes" : "no")}";

                // show accessories
                var accessories = from a in attr.Accessories select AccessoryToString(a.Type);

                Accessories.Content = $"Accessories: {string.Join(",", accessories) }";

                // update the image
                var cropped = new CroppedBitmap(image, new Int32Rect(face.FaceRectangle.Left, face.FaceRectangle.Top, face.FaceRectangle.Width, face.FaceRectangle.Height));
                var brush   = new ImageBrush(cropped);
                brush.Stretch        = Stretch.Uniform;
                FaceImage.Background = brush;
            }
        }
コード例 #25
0
        public UIElement[] BuildMainPanelItem(MenuTreeNode Node)
        {
            if (!Node.IsVisible)
            {
                return(null);
            }
            List <UIElement>    NewItems = new List <UIElement>();
            LauncherCommandInfo Command  = App.AppConfig.FindCommandInfo(Node.CommandInfoID);

            if (Command != null && Command.Type != CommandExecuteType.None)
            {
                string[] Commands = App.Executer.ParseCommandList(Command);
                if (Commands.Length != 0)
                {
                    System.Windows.Controls.Button NewButton = new System.Windows.Controls.Button();
                    MenuNodeDictionary.Add(NewButton, Node);
                    NewButton.Click += NewButton_Click;

                    NewButton.Width  = System.Windows.SystemParameters.WorkArea.Width / App.AppConfig.HorizonalTileSize;
                    NewButton.Height = NewButton.Width;
                    NewButton.VerticalContentAlignment = VerticalAlignment.Bottom;
                    NewButton.Content = Command.Name;
                    NewButton.ToolTip = Command.Description;

                    if (Command.Type == CommandExecuteType.Command)
                    {
                        NewButton.Background         = CommandImageBrush;
                        NewButton.Background.Opacity = 1.0;
                    }
                    else if (Command.Type == CommandExecuteType.FileOpen)
                    {
                        App.Executer.ParseFileCommand(Commands[0], out string FilePath, out string Args);
                        if (System.IO.File.Exists(FilePath))
                        {
                            ImageBrush iconImageBrush = new ImageBrush()
                            {
                                Stretch     = Stretch.Uniform,
                                Viewport    = new Rect(0.25, 0.25, 0.5, 0.5),
                                ImageSource = Misc.IconImageStorage.FindSystemIconImage(FilePath)
                            };
                            NewButton.Background         = iconImageBrush;
                            NewButton.Background.Opacity = 1.0;
                        }
                        else if (System.IO.Directory.Exists(FilePath))
                        {
                            NewButton.Background         = FolderImageBrush;
                            NewButton.Background.Opacity = 1.0;
                        }
                        else
                        {
                            NewButton.Background         = UnknownFileImageBrush;
                            NewButton.Background.Opacity = 1.0;
                        }
                    }

                    NewItems.Add(NewButton);
                }
            }
            foreach (var Child in Node.Children)
            {
                var ChildItems = BuildMainPanelItem(Child);
                if (ChildItems != null)
                {
                    NewItems.AddRange(ChildItems);
                }
            }

            return(NewItems.ToArray());
        }
コード例 #26
0
        //test retate labels
        public void initLabels()
        {
            TranslateTransform translate = new TranslateTransform(-140, -60);

            wheelZone.RenderTransform = translate;

            //8개의 label 생성
            double offsetDegree = 360.0 / (double)FERRIS;

            string[] imgUris = { "./images/blue.png", "./images/yellow.png", "./images/red.png", "./images/green.png" };
            {
                var lb = new TextBox();
                lb.Text       = "Wheel";
                lb.FontSize   = 20;
                lb.Width      = 75;
                lb.Height     = 60;
                lb.IsReadOnly = true;

                LinearGradientBrush linearGradientBrush = new LinearGradientBrush();
                linearGradientBrush.StartPoint = new Point(0, 0);
                linearGradientBrush.EndPoint   = new Point(1, 1);
                linearGradientBrush.GradientStops.Add(new GradientStop(Color.FromArgb(255, 255, 255, 255), 0.0));  //Yellow
                linearGradientBrush.GradientStops.Add(new GradientStop(Color.FromArgb(255, 255, 255, 255), 0.55)); //Green

                lb.Background                 = linearGradientBrush;
                lb.Foreground                 = Brushes.Black;
                lb.FontWeight                 = FontWeights.Bold;
                lb.BorderThickness            = new Thickness(0, 0, 0, 0);
                lb.VerticalContentAlignment   = VerticalAlignment.Center;
                lb.HorizontalContentAlignment = HorizontalAlignment.Center;

                wheelZone.Children.Add(lb);

                translate          = new TranslateTransform(FERRIS_POS_OFFSET_X + 5, FERRIS_POS_OFFSET_Y - 10);
                lb.RenderTransform = translate;
            }
            for (int i = 0; i < FERRIS; i++)
            {
                var lb = new TextBox();
                //lb.Content = "Ferris No." + (i + 1).ToString();
                lb.Text   = "Ferris No." + (i + 1).ToString();
                lb.Width  = 75;
                lb.Height = 75;

                // Create a diagonal linear gradient with four stops.
                //LinearGradientBrush myLinearGradientBrush =
                //    new LinearGradientBrush();
                //myLinearGradientBrush.StartPoint = new Point(0, 0);
                //myLinearGradientBrush.EndPoint = new Point(1, 1);
                //myLinearGradientBrush.GradientStops.Add(
                //    new GradientStop(Colors.Yellow, 0.0));
                //myLinearGradientBrush.GradientStops.Add(
                //    new GradientStop(Colors.Red, 0.25));
                //myLinearGradientBrush.GradientStops.Add(
                //    new GradientStop(Colors.Blue, 0.75));
                //myLinearGradientBrush.GradientStops.Add(
                //    new GradientStop(Colors.LimeGreen, 1.0));

                lb.IsReadOnly = true;
                //lb.Background = Brushes.Coral;
                BitmapImage theImage = new BitmapImage(new Uri(imgUris[i % 4], UriKind.Relative));
                ImageBrush  img      = new ImageBrush(theImage);
                lb.Background                 = img;
                lb.Foreground                 = Brushes.GhostWhite;
                lb.FontWeight                 = FontWeights.Bold;
                lb.BorderThickness            = new Thickness(0, 0, 0, 0);
                lb.VerticalContentAlignment   = VerticalAlignment.Center;
                lb.HorizontalContentAlignment = HorizontalAlignment.Center;

                wheelZone.Children.Add(lb);
                //setTranslate(wheelZone, lb, (offsetDegree * i));
                wheelImg.RenderSize = new Size(600, 600);
                setTranslate(wheelImg, lb, (offsetDegree * (i + 1)));
            }
        }
コード例 #27
0
        private void GameEngine(object sender, EventArgs e)
        {
            StringBuilder scoreBuilder = new StringBuilder("Score: ");

            scoreBuilder.Append(score);
            scoreText.Content = scoreBuilder.ToString();

            intervals -= 5;

            if (intervals < 1)
            {
                ImageBrush carImage = new ImageBrush();

                if (score > 50)
                {
                    carSkins = rand.Next(1, 11);
                }
                else
                {
                    carSkins = rand.Next(1, 6);
                }

                switch (carSkins)
                {
                case 1:
                    carImage.ImageSource = new BitmapImage(new Uri(BaseUriHelper.GetBaseUri(this), "/Resources/Images/BlueCar.png"));
                    break;

                case 2:
                    carImage.ImageSource = new BitmapImage(new Uri(BaseUriHelper.GetBaseUri(this), "/Resources/Images/RedCar.png"));
                    break;

                case 3:
                    carImage.ImageSource = new BitmapImage(new Uri(BaseUriHelper.GetBaseUri(this), "/Resources/Images/YellowCar.png"));
                    break;

                case 4:
                    carImage.ImageSource = new BitmapImage(new Uri(BaseUriHelper.GetBaseUri(this), "/Resources/Images/GreenCar.png"));
                    break;

                case 5:
                    carImage.ImageSource = new BitmapImage(new Uri(BaseUriHelper.GetBaseUri(this), "/Resources/Images/PurpleCar.png"));
                    break;

                case 6:
                    carImage.ImageSource = new BitmapImage(new Uri(BaseUriHelper.GetBaseUri(this), "/Resources/Images/BlueCarBomb.png"));
                    break;

                case 7:
                    carImage.ImageSource = new BitmapImage(new Uri(BaseUriHelper.GetBaseUri(this), "/Resources/Images/RedCarBomb.png"));
                    break;

                case 8:
                    carImage.ImageSource = new BitmapImage(new Uri(BaseUriHelper.GetBaseUri(this), "/Resources/Images/YellowCarBomb.png"));
                    break;

                case 9:
                    carImage.ImageSource = new BitmapImage(new Uri(BaseUriHelper.GetBaseUri(this), "/Resources/Images/GreenCarBomb.png"));
                    break;

                case 10:
                    carImage.ImageSource = new BitmapImage(new Uri(BaseUriHelper.GetBaseUri(this), "/Resources/Images/PurpleCarBomb.png"));
                    break;
                }

                Rectangle newCar = new Rectangle
                {
                    Tag    = "car",
                    Height = 90,
                    Width  = 50,
                    Fill   = carImage
                };

                if (carSkins > 5)
                {
                    newCar.Tag = "bomb";
                }

                Canvas.SetLeft(newCar, rails[rand.Next(0, 4)]);
                Canvas.SetTop(newCar, 600);

                MyCanvas.Children.Add(newCar);

                intervals = levelIntervals;
            }

            foreach (var x in MyCanvas.Children.OfType <Rectangle>())
            {
                if (x.Tag.ToString() == "car" || x.Tag.ToString() == "bomb")
                {
                    Canvas.SetTop(x, Canvas.GetTop(x) - speed);
                }

                if (Canvas.GetTop(x) < -80 && x.Tag.ToString() == "car")
                {
                    itemRemover.Add(x);
                    missedCars++;
                    StringBuilder missedCarsBuilder = new StringBuilder("Misses: ");
                    missedCarsBuilder.Append(missedCars.ToString());
                    missesText.Content = missedCarsBuilder.ToString();
                }
            }

            if (missedCars == 10)
            {
                GameOver();
            }

            CheckLevels();

            foreach (Rectangle item in itemRemover)
            {
                MyCanvas.Children.Remove(item);
            }
        }
コード例 #28
0
 static async Task SetBackgroundImageBytesAsync(byte[] imageBytes, Panel control, PositionLength horizontal, PositionLength vertical)
 {
     var bmpImage = await ByteArrayToImageAsync(imageBytes);
     var imageBrush = new ImageBrush() { ImageSource = bmpImage, Stretch = Stretch.None };
     if (horizontal != null)
     {
         switch (horizontal.Unit)
         {
             case PositionLengthUnit.CenterAlign:
                 imageBrush.AlignmentX = AlignmentX.Center;
                 break;
             case PositionLengthUnit.NearAlign:
                 imageBrush.AlignmentX = AlignmentX.Left;
                 break;
             case PositionLengthUnit.FarAlign:
                 imageBrush.AlignmentX = AlignmentX.Right;
                 break;
             case PositionLengthUnit.Absolute:
                 imageBrush.AlignmentX = AlignmentX.Left;
                 imageBrush.Transform = new TranslateTransform() { X = horizontal.Value };
                 break;
             case PositionLengthUnit.Percentage:
                 imageBrush.AlignmentX = AlignmentX.Left;
                 imageBrush.RelativeTransform = new TranslateTransform() { X = horizontal.Value };
                 break;
         }
     }
     if (vertical != null)
     {
         switch (vertical.Unit)
         {
             case PositionLengthUnit.CenterAlign:
                 imageBrush.AlignmentY = AlignmentY.Center;
                 break;
             case PositionLengthUnit.NearAlign:
                 imageBrush.AlignmentY = AlignmentY.Top;
                 break;
             case PositionLengthUnit.FarAlign:
                 imageBrush.AlignmentY = AlignmentY.Bottom;
                 break;
             case PositionLengthUnit.Absolute:
                 imageBrush.AlignmentY = AlignmentY.Top;
                 var transform = imageBrush.Transform as TranslateTransform;
                 if (transform == null)
                 {
                     transform = new TranslateTransform();
                     imageBrush.Transform = transform;
                 }
                 transform.Y = vertical.Value;
                 break;
             case PositionLengthUnit.Percentage:
                 imageBrush.AlignmentY = AlignmentY.Top;
                 var relativeTransform = imageBrush.RelativeTransform as TranslateTransform;
                 if (relativeTransform == null)
                 {
                     relativeTransform = new TranslateTransform();
                     imageBrush.RelativeTransform = relativeTransform;
                 }
                 relativeTransform.Y = vertical.Value;
                 break;
         }
     }
     control.Background = imageBrush;
 }
コード例 #29
0
        void BuildPrimaryPlane(InspectTreeState state)
        {
            var   displayMode = state.Mode;
            Brush brush       = new SolidColorBrush(EmptyColor);
            var   view        = Node.View;
            var   parent      = Node.View.Parent;
            var   matrix      = Matrix3D.Identity;

            if (view.Layer != null)
            {
                view = view.Layer;
            }

            var zFightOffset = childIndex * zFightIncrement;
            var zOffset      = ZSpacing + zFightOffset;

            if (view.Transform != null)
            {
                var render = view.Transform;
                matrix = new Matrix3D {
                    M11     = render.M11,
                    M12     = render.M12,
                    M13     = render.M13,
                    M14     = render.M14,
                    M21     = render.M21,
                    M22     = render.M22,
                    M23     = render.M23,
                    M24     = render.M24,
                    M31     = render.M31,
                    M32     = render.M32,
                    M33     = render.M33,
                    M34     = render.M34,
                    OffsetX = render.OffsetX,
                    OffsetY = render.OffsetY,
                    OffsetZ = render.OffsetZ + zOffset
                };
            }

            var size   = new Size(view.Width, view.Height);
            var visual = new DrawingVisual();

            using (var context = visual.RenderOpen()) {
                if (view.BestCapturedImage != null && displayMode.HasFlag(DisplayMode.Content))
                {
                    var bitmap = new BitmapImage();
                    bitmap.BeginInit();
                    bitmap.StreamSource = new MemoryStream(view.BestCapturedImage);
                    bitmap.EndInit();

                    context.DrawImage(bitmap, new Rect(size));
                }

                if (displayMode.HasFlag(DisplayMode.Frames))
                {
                    context.DrawRectangle(
                        null,
                        new Pen(new SolidColorBrush(Color.FromRgb(0xd3, 0xd3, 0xd3)), 0.5),
                        new Rect(size));
                }
            }

            brush = new ImageBrush {
                ImageSource = new DrawingImage(visual.Drawing)
            };

            var geometry = new MeshGeometry3D()
            {
                Positions = new Point3DCollection {
                    new Point3D(0, 0, 0),
                    new Point3D(0, -size.Height, 0),
                    new Point3D(size.Width, -size.Height, 0),
                    new Point3D(size.Width, 0, 0)
                },
                TextureCoordinates = new PointCollection {
                    new Point(0, 0),
                    new Point(0, 1),
                    new Point(1, 1),
                    new Point(1, 0)
                },
                TriangleIndices = new Int32Collection {
                    0, 1, 2, 0, 2, 3
                },
            };

            var backGeometry = new MeshGeometry3D()
            {
                Positions          = geometry.Positions,
                TextureCoordinates = geometry.TextureCoordinates,
                TriangleIndices    = geometry.TriangleIndices,
                Normals            = new Vector3DCollection {
                    new Vector3D(0, 0, -1),
                    new Vector3D(0, 0, -1),
                    new Vector3D(0, 0, -1),
                    new Vector3D(0, 0, -1)
                }
            };

            material = new DiffuseMaterial(brush)
            {
                Color = BlurColor
            };

            Content = new Model3DGroup()
            {
                Children = new Model3DCollection {
                    new GeometryModel3D {
                        Geometry = geometry,
                        Material = material
                    },
                    new GeometryModel3D {
                        Geometry     = backGeometry,
                        BackMaterial = material,
                    },
                },
                Transform = new ScaleTransform3D {
                    ScaleX = Math.Ceiling(view.Width) / size.Width,
                    ScaleY = -Math.Ceiling(view.Height) / size.Height,
                    ScaleZ = 1
                }
            };

            var group = new Transform3DGroup();

            if ((parent == null && !Node.View.IsFakeRoot) || (parent?.IsFakeRoot ?? false))
            {
                var unitScale = 1.0 / Math.Max(view.Width, view.Height);
                group.Children = new Transform3DCollection {
                    new TranslateTransform3D {
                        OffsetX = -view.Width / 2.0,
                        OffsetY = -view.Height / 2.0,
                        OffsetZ = zOffset
                    },
                    new ScaleTransform3D(unitScale, -unitScale, 1),
                    expandTransform
                };
            }
            else
            {
                if (view.Transform != null)
                {
                    group.Children = new Transform3DCollection {
                        new MatrixTransform3D()
                        {
                            Matrix = matrix
                        },
                        expandTransform
                    };
                }
                else
                {
                    group.Children = new Transform3DCollection {
                        new TranslateTransform3D(view.X, view.Y, zOffset),
                        expandTransform
                    };
                }
            }
            Transform = group;
        }
コード例 #30
0
ファイル: MainWindow.xaml.cs プロジェクト: TudorMutiu1/School
        private void BuyColorChanger(Building item)
        {
            ImageBrush image = new ImageBrush();

            if ((owner.PlayerColor == blue) && (item.IndexImg == 1))
            {
                image.ImageSource   = new BitmapImage(new Uri("../../resources/_1x1_Blue.bmp", UriKind.Relative));
                item.IMG.Background = image;
            }
            else if ((owner.PlayerColor == blue) && (item.IndexImg == 2))
            {
                image.ImageSource   = new BitmapImage(new Uri("../../resources/_1x2_Blue.bmp", UriKind.Relative));
                item.IMG.Background = image;
            }
            else if ((owner.PlayerColor == blue) && (item.IndexImg == 3))
            {
                image.ImageSource   = new BitmapImage(new Uri("../../resources/_2x1_Blue.bmp", UriKind.Relative));
                item.IMG.Background = image;
            }
            else if ((owner.PlayerColor == black) && (item.IndexImg == 1))
            {
                image.ImageSource   = new BitmapImage(new Uri("../../resources/_1x1_Black.bmp", UriKind.Relative));
                item.IMG.Background = image;
            }
            else if ((owner.PlayerColor == black) && (item.IndexImg == 2))
            {
                image.ImageSource   = new BitmapImage(new Uri("../../resources/_1x2_Black.bmp", UriKind.Relative));
                item.IMG.Background = image;
            }
            else if ((owner.PlayerColor == black) && (item.IndexImg == 3))
            {
                image.ImageSource   = new BitmapImage(new Uri("../../resources/_2x1_Black.bmp", UriKind.Relative));
                item.IMG.Background = image;
            }
            else if ((owner.PlayerColor == green) && (item.IndexImg == 1))
            {
                image.ImageSource   = new BitmapImage(new Uri("../../resources/_1x1_Green.bmp", UriKind.Relative));
                item.IMG.Background = image;
            }
            else if ((owner.PlayerColor == green) && (item.IndexImg == 2))
            {
                image.ImageSource   = new BitmapImage(new Uri("../../resources/_1x2_Green.bmp", UriKind.Relative));
                item.IMG.Background = image;
            }
            else if ((owner.PlayerColor == green) && (item.IndexImg == 3))
            {
                image.ImageSource   = new BitmapImage(new Uri("../../resources/_2x1_Green.bmp", UriKind.Relative));
                item.IMG.Background = image;
            }
            else if ((owner.PlayerColor == yellow) && (item.IndexImg == 1))
            {
                image.ImageSource   = new BitmapImage(new Uri("../../resources/_1x1_Yellow.bmp", UriKind.Relative));
                item.IMG.Background = image;
            }
            else if ((owner.PlayerColor == yellow) && (item.IndexImg == 2))
            {
                image.ImageSource   = new BitmapImage(new Uri("../../resources/_1x2_Yellow.bmp", UriKind.Relative));
                item.IMG.Background = image;
            }
            else if ((owner.PlayerColor == yellow) && (item.IndexImg == 3))
            {
                image.ImageSource   = new BitmapImage(new Uri("../../resources/_2x1_Yellow.bmp", UriKind.Relative));
                item.IMG.Background = image;
            }
        }
コード例 #31
0
        private void AddFiles_Click(object sender, RoutedEventArgs e)
        {
            try
            {
                OpenFileDialog openFileDialog = new OpenFileDialog();
                openFileDialog.Multiselect      = true;
                openFileDialog.Filter           = "All files (*.*)|*.*";
                openFileDialog.InitialDirectory = Environment.GetFolderPath(Environment.SpecialFolder.Desktop);

                if (openFileDialog.ShowDialog() == true)
                {
                    var IncomingFiles = openFileDialog.FileNames;

                    if (SuspiciousFilesList.Items.Count == 0)
                    {
                        foreach (string File in IncomingFiles)
                        {
                            SuspiciousFilesCounter++;
                            SuspiciousFiles.Add((new FileData()
                            {
                                Id = SuspiciousFilesCounter, ImageData = LoadImage("Resources/Images/GreyDot.png"), Status = "Ready", Filename = System.IO.Path.GetFileName(File), Path = System.IO.Path.GetFullPath(File), Annotations = "Waiting to be scanned..."
                            }));
                        }
                    }
                    else
                    {
                        bool alreadyExistsInSuspiciousFiles = false;

                        bool alreadyExistsInFilteredFiles = false;

                        foreach (string File in IncomingFiles)
                        {
                            foreach (var Item in SuspiciousFiles)
                            {
                                if (Item.Path == System.IO.Path.GetFullPath(File))
                                {
                                    alreadyExistsInSuspiciousFiles = true;
                                }
                            }
                            if (!alreadyExistsInSuspiciousFiles)
                            {
                                SuspiciousFilesCounter++;
                                SuspiciousFiles.Add((new FileData()
                                {
                                    Id = SuspiciousFilesCounter, ImageData = LoadImage("Resources/Images/GreyDot.png"), Status = "Ready", Filename = System.IO.Path.GetFileName(File), Path = System.IO.Path.GetFullPath(File), Annotations = "Waiting to be scanned..."
                                }));
                            }
                            else
                            {
                                foreach (var Item in FilteredFiles)
                                {
                                    if (Item.Path == System.IO.Path.GetFullPath(File))
                                    {
                                        alreadyExistsInFilteredFiles = true;
                                    }
                                }
                                if (!alreadyExistsInFilteredFiles)
                                {
                                    FilteredFilesCounter++;
                                    FilteredFiles.Add((new FileData()
                                    {
                                        Id = FilteredFilesCounter, Filename = System.IO.Path.GetFileName(File), Path = System.IO.Path.GetFullPath(File), Annotations = "The file was already in the queue."
                                    }));
                                }
                            }
                            alreadyExistsInSuspiciousFiles = false;
                            alreadyExistsInFilteredFiles   = false;
                        }
                    }

                    if (SuspiciousFilesCounter > 0)
                    {
                        StartProcess.IsEnabled = true;
                        StopProcess.IsEnabled  = true;
                    }

                    if (FilteredFilesCounter > 0)
                    {
                        ToggleNotifications.IsEnabled = true;
                    }

                    var brush = new ImageBrush();
                    brush.ImageSource      = LoadImage("Resources/Images/Delete.png");
                    StopProcess.Background = brush;

                    StopProcess.IsEnabled = true;

                    toggleNotifications = false;

                    SuspiciousFilesList.ItemsSource = SuspiciousFiles;
                    SuspiciousFilesList.Items.Refresh();

                    FilteredFilesList.ItemsSource = FilteredFiles;
                    FilteredFilesList.Items.Refresh();
                }
            }
            catch (Exception ex)
            {
                if (ex is UnauthorizedAccessException)
                {
                    MessageBox.Show("You have no permission to work with some of the files selected due to user privileges.\r\n\r\nPlease, select a more specific group of files.", "Critical exception", MessageBoxButton.OK, MessageBoxImage.Information);
                }
                else
                {
                    MessageBox.Show(ex.ToString(), "Unhandled exception", MessageBoxButton.OK, MessageBoxImage.Information);
                    Environment.Exit(0);
                }
            }
        }
コード例 #32
0
ファイル: MainWindow.xaml.cs プロジェクト: TudorMutiu1/School
        public void MapGenerator()
        {
            int resx = -750;
            int resy = -500;

            TotalMapItems = 0;
            Grid grid = this.ButonInsider as Grid;

            for (int i = 0; i < BorGsL - 5; i++)
            {
                for (int j = 0; j < BorGsL; j++)
                {
                    TotalMapItems++;
                    ImageBrush image = new ImageBrush();
                    resx              += Building.DrawSize;
                    BorGs[i, j]        = new Button();
                    BorGs[i, j].Margin = new Thickness(resx * 2, resy * 2, 0, 0);
                    BorGs[i, j].Name   = "Img" + i.ToString();
                    BorGs[i, j].Height = Building.DrawSize;
                    BorGs[i, j].Width  = Building.DrawSize;
                    BorGsItem          = r.Next(0, 10);
                    if (BorGsItem >= 2)
                    {
                        BorGsIndex = r.Next(1, 4);
                        if (BorGsIndex == 1)
                        {
                            image.ImageSource      = new BitmapImage(new Uri(@"../../resources/_1x1_White.bmp", UriKind.Relative));
                            BorGs[i, j].Background = image;
                            image.Stretch          = Stretch.Fill;
                            BorGs[i, j].Visibility = Visibility.Visible;
                        }
                        else if (BorGsIndex == 2)
                        {
                            image.ImageSource      = new BitmapImage(new Uri(@"../../resources/_1x2_White.bmp", UriKind.Relative));
                            BorGs[i, j].Background = image;
                            image.Stretch          = Stretch.Fill;
                            BorGs[i, j].Visibility = Visibility.Visible;
                        }
                        else if (BorGsIndex == 3)
                        {
                            image.ImageSource      = new BitmapImage(new Uri(@"../../resources/_2x1_White.bmp", UriKind.Relative));
                            BorGs[i, j].Background = image;
                            image.Stretch          = Stretch.Fill;
                            BorGs[i, j].Visibility = Visibility.Visible;
                        }
                    }
                    else
                    {
                        BorGs[i, j].Background = greenBrush;
                        BorGs[i, j].Visibility = Visibility.Visible;
                    }
                    if (BorGsItem >= 2)
                    {
                        BorGs[i, j].AddHandler(Button.ClickEvent, new RoutedEventHandler(Building_Click));
                    }
                    else
                    {
                        BorGs[i, j].AddHandler(Button.ClickEvent, new RoutedEventHandler(Grass_Click));
                    }
                    grid.Children.Add(BorGs[i, j]);
                    ButtonList.Add(BorGs[i, j]);
                    progressBar1.Value++;
                }
                resx  = -750;
                resy += Building.DrawSize;
            }
            BuildingList   = new List <Building>();
            TotalBuildings = 0;
            for (int i = 0; i < ButtonList.Count; i++)
            {
                if (ButtonList[i].Background != greenBrush)
                {
                    BorGsIndex = r.Next(1, 4);
                    if (BorGsIndex == 1)
                    {
                        Price = r.Next(20000, 25000);
                        BuildingList.Add(new Building(ButtonList[i], Price, false, false, 1, null, TotalBuildings++));
                    }
                    else if (BorGsIndex == 2)
                    {
                        Price = r.Next(30000, 45000);
                        BuildingList.Add(new Building(ButtonList[i], Price, false, false, 3, null, TotalBuildings++));
                    }
                    else if (BorGsIndex == 3)
                    {
                        Price = r.Next(50000, 75000);
                        BuildingList.Add(new Building(ButtonList[i], Price, false, false, 2, null, TotalBuildings++));
                    }
                    progressBar1.Value++;
                }
            }
        }
コード例 #33
0
ファイル: WpfGdi.cs プロジェクト: bbowyersmyth/WMF2WPF
        private void ApplyStyle(Shape shape, bool fillShape)
        {
            if (_currentState.CurrentPen == null)
            {
                // Stock Pen
                var newBrush = new SolidColorBrush(Colors.Black);
            #if !NETFX_CORE
                newBrush.Freeze();
            #endif
                shape.Stroke = newBrush;
                shape.StrokeThickness = 1;
            }
            else
            {
                LogPen currentPen = _currentState.CurrentPen;

                if (currentPen.Width > 0)
                {
                    shape.StrokeThickness = ScaleWidth(currentPen.Width);
                }

                // Style
                if ((PenStyle)(currentPen.Style & 0x000F) == PenStyle.PS_NULL)
                {
                    // Do nothing, null is the default
                    //shape.Stroke = null;
                }
                else
                {
                    var newBrush = new SolidColorBrush(currentPen.Colour);
            #if !NETFX_CORE
                    newBrush.Freeze();
            #endif
                    shape.Stroke = newBrush;

                    if ((PenStyle)(currentPen.Style & 0x000F) == PenStyle.PS_DASH)
                    {
                        shape.StrokeDashArray.Add(30);
                        shape.StrokeDashArray.Add(10);
                    }
                    else if ((PenStyle)(currentPen.Style & 0x000F) == PenStyle.PS_DASHDOT)
                    {
                        shape.StrokeDashArray.Add(30);
                        shape.StrokeDashArray.Add(10);
                        shape.StrokeDashArray.Add(10);
                        shape.StrokeDashArray.Add(10);
                        shape.StrokeDashArray.Add(10);
                        shape.StrokeDashArray.Add(10);
                    }
                    else if ((PenStyle)(currentPen.Style & 0x000F) == PenStyle.PS_DASHDOTDOT)
                    {

                        shape.StrokeDashArray.Add(30);
                        shape.StrokeDashArray.Add(10);
                        shape.StrokeDashArray.Add(10);
                        shape.StrokeDashArray.Add(10);
                        shape.StrokeDashArray.Add(10);
                        shape.StrokeDashArray.Add(10);
                        shape.StrokeDashArray.Add(10);
                        shape.StrokeDashArray.Add(10);
                    }
                    else if ((PenStyle)(currentPen.Style & 0x000F) == PenStyle.PS_DOT)
                    {
                        shape.StrokeDashArray.Add(10);
                        shape.StrokeDashArray.Add(10);
                        shape.StrokeDashCap = PenLineCap.Round;
                    }
                }

                // Join
                if ((PenStyle)(currentPen.Style & 0xF000) == PenStyle.PS_JOIN_BEVEL)
                {
                    shape.StrokeLineJoin = PenLineJoin.Bevel;
                }
                else if ((PenStyle)(currentPen.Style & 0xF000) == PenStyle.PS_JOIN_MITER)
                {
                    // Do nothing, miter is the default
                    shape.StrokeLineJoin = PenLineJoin.Miter;

                    if (_miterLimit != 0)
                    {
                        shape.StrokeMiterLimit = _miterLimit;
                    }
                }
                else if ((PenStyle)(currentPen.Style & 0xF000) == PenStyle.PS_JOIN_ROUND)
                {
                    shape.StrokeLineJoin = PenLineJoin.Round;
                }

                // End cap
                if ((PenStyle)(currentPen.Style & 0x0F00) == PenStyle.PS_ENDCAP_FLAT)
                {
                    // Do nothing, flat is the default
                    // shape.StrokeEndLineCap = PenLineCap.Flat;
                    // shape.StrokeStartLineCap = PenLineCap.Flat;
                }
                else if ((PenStyle)(currentPen.Style & 0x0F00) == PenStyle.PS_ENDCAP_SQUARE)
                {
                    shape.StrokeEndLineCap = PenLineCap.Square;
                    shape.StrokeStartLineCap = PenLineCap.Square;
                }
                else if ((PenStyle)(currentPen.Style & 0x0F00) == PenStyle.PS_ENDCAP_ROUND)
                {
                    shape.StrokeEndLineCap = PenLineCap.Round;
                    shape.StrokeStartLineCap = PenLineCap.Round;
                }
            }

            if (_currentState.CurrentBrush == null & fillShape)
            {
                // Stock brush
                var newBrush = new SolidColorBrush(Colors.White);
            #if !NETFX_CORE
                newBrush.Freeze();
            #endif
                shape.Fill = newBrush;
            }
            else if (fillShape)
            {
                LogBrush currentBrush = _currentState.CurrentBrush;

                if (currentBrush.Style == BrushStyle.BS_NULL)
                {
                    // Do nothing, null is the default
                    // shape.Fill = null;
                }
                else if (currentBrush.Image != null)
                {
            #if !NETFX_CORE
                    var imgBrush = new ImageBrush
                                       {
                                           ImageSource = currentBrush.Image,
                                           Stretch = Stretch.None,
                                           TileMode = TileMode.Tile,
                                           Viewport =
                                               new Rect(0, 0, ScaleWidth(currentBrush.Image.Width),
                                                        ScaleHeight(currentBrush.Image.Height)),
                                           ViewportUnits = BrushMappingMode.Absolute,
                                           Viewbox =
                                               new Rect(0, 0, ScaleWidth(currentBrush.Image.Width),
                                                        ScaleHeight(currentBrush.Image.Height)),
                                           ViewboxUnits = BrushMappingMode.Absolute
                                       };

                    imgBrush.Freeze();

                    shape.Fill = imgBrush;
            #endif
                    // TODO: Figure out a way to stop the tile anti-aliasing
                }
                else if (currentBrush.Style == BrushStyle.BS_PATTERN
                    | currentBrush.Style == BrushStyle.BS_DIBPATTERN
                    | currentBrush.Style == BrushStyle.BS_DIBPATTERNPT)
                {
                    var newBrush = new SolidColorBrush(Colors.Black);
            #if !NETFX_CORE
                    newBrush.Freeze();
            #endif
                    shape.Fill = newBrush;
                }
                else if (currentBrush.Style == BrushStyle.BS_HATCHED)
                {
            #if !NETFX_CORE
                    var patternBrush = new VisualBrush();
                    var patternTile = new Canvas();
                    var stroke1 = new Path();
                    var stroke2 = new Path();
                    var figure1 = new PathFigure();
                    var figure2 = new PathFigure();
                    var segments1 = new PathSegmentCollection();
                    var segments2 = new PathSegmentCollection();

                    patternBrush.TileMode = TileMode.Tile;
                    patternBrush.Viewport = new Rect(0, 0, 10, 10);
                    patternBrush.ViewportUnits = BrushMappingMode.Absolute;
                    patternBrush.Viewbox = new Rect(0, 0, 10, 10);
                    patternBrush.ViewboxUnits = BrushMappingMode.Absolute;

                    stroke1.Data = new PathGeometry();
                    stroke2.Data = new PathGeometry();

                    switch (currentBrush.Hatch)
                    {
                        case HatchStyle.HS_BDIAGONAL:
                            // A 45-degree upward, left-to-right hatch.
                            figure1.StartPoint = new Point(0, 10);

                            var up45Segment = new LineSegment
                                {
                                    Point = new Point(10, 0)
                                };
                            segments1.Add(up45Segment);
                            figure1.Segments = segments1;

                            ((PathGeometry)stroke1.Data).Figures.Add(figure1);
                            patternTile.Children.Add(stroke1);
                            break;

                        case HatchStyle.HS_CROSS:
                            // A horizontal and vertical cross-hatch.
                            figure1.StartPoint = new Point(5, 0);
                            figure2.StartPoint = new Point(0, 5);

                            var downXSegment = new LineSegment
                                {
                                    Point = new Point(5, 10)
                                };
                            segments1.Add(downXSegment);
                            figure1.Segments = segments1;
                            var rightXSegment = new LineSegment
                                {
                                    Point = new Point(10, 5)
                                };
                            segments2.Add(rightXSegment);
                            figure1.Segments = segments1;
                            figure2.Segments = segments2;

                            ((PathGeometry)stroke1.Data).Figures.Add(figure1);
                            ((PathGeometry)stroke2.Data).Figures.Add(figure2);

                            patternTile.Children.Add(stroke1);
                            patternTile.Children.Add(stroke2);
                            break;

                        case HatchStyle.HS_DIAGCROSS:
                            // A 45-degree crosshatch.
                            figure1.StartPoint = new Point(0, 0);
                            figure2.StartPoint = new Point(0, 10);

                            var downDXSegment = new LineSegment
                                {
                                    Point = new Point(10, 10)
                                };
                            segments1.Add(downDXSegment);
                            figure1.Segments = segments1;
                            var rightDXSegment = new LineSegment
                                {
                                    Point = new Point(10, 0)
                                };
                            segments2.Add(rightDXSegment);
                            figure1.Segments = segments1;
                            figure2.Segments = segments2;

                            ((PathGeometry)stroke1.Data).Figures.Add(figure1);
                            ((PathGeometry)stroke2.Data).Figures.Add(figure2);

                            patternTile.Children.Add(stroke1);
                            patternTile.Children.Add(stroke2);
                            break;

                        case HatchStyle.HS_FDIAGONAL:
                            // A 45-degree downward, left-to-right hatch.
                            figure1.StartPoint = new Point(0, 0);

                            var down45Segment = new LineSegment
                                {
                                    Point = new Point(10, 10)
                                };
                            segments1.Add(down45Segment);
                            figure1.Segments = segments1;

                            ((PathGeometry)stroke1.Data).Figures.Add(figure1);
                            patternTile.Children.Add(stroke1);
                            break;

                        case HatchStyle.HS_HORIZONTAL:
                            // A horizontal hatch.
                            figure1.StartPoint = new Point(0, 10);

                            var bottomSegment = new LineSegment
                                {
                                    Point = new Point(10, 10)
                                };
                            segments1.Add(bottomSegment);
                            figure1.Segments = segments1;

                            ((PathGeometry)stroke1.Data).Figures.Add(figure1);
                            patternTile.Children.Add(stroke1);
                            break;

                        case HatchStyle.HS_VERTICAL:
                            // A vertical hatch.
                            figure1.StartPoint = new Point(10, 0);

                            var verticalSegment = new LineSegment
                                {
                                    Point = new Point(10, 10)
                                };
                            segments1.Add(verticalSegment);
                            figure1.Segments = segments1;

                            ((PathGeometry)stroke1.Data).Figures.Add(figure1);
                            patternTile.Children.Add(stroke1);
                            break;
                    }

                    patternBrush.Visual = patternTile;
                    //patternBrush.Freeze();  // Cant freeze a visual brush
                    shape.Fill = patternBrush;
            #endif
                }
                else
                {
                    var newBrush = new SolidColorBrush(currentBrush.Colour);
            #if !NETFX_CORE
                    newBrush.Freeze();
            #endif
                    shape.Fill = newBrush;
                }
            }
        }
コード例 #34
0
        /// <summary>
        /// Se termina la manipuralción de la ficha y determina si puede o no ubicarse en el lugar
        /// indicado, de lo contrario vuelve a su posición inicial.
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void Ellipse_ManipulationCompleted(object sender, System.Windows.Input.ManipulationCompletedEventArgs e)
        {
            if (this.canMove)
            {
                Pieces p = (from b in boardPieces
                            where b.Name.Equals(this.ellipse.GetValue(NameProperty))
                            select b).Single();

                RowColl initialPosition = new RowColl(p.Position);
                RowColl finalPosition   = new RowColl(p.Position);

                CompositeTransform cp = this.ellipse.RenderTransform as CompositeTransform;

                #region Set_Move
                if (p.Color == ColorPeace.black)
                {
                    if (e.TotalManipulation.Translation.Y > 0)
                    {
                        //Evaluamos si debemos sumar o restar una columna
                        if (e.TotalManipulation.Translation.X > 0)
                        {
                            if (e.TotalManipulation.Translation.Y > 40.5 && e.TotalManipulation.Translation.X > 40.5)
                            {
                                finalPosition.col = initialPosition.col + 1;
                                finalPosition.row = initialPosition.row + 1;
                            }
                        }
                        else
                        {
                            if (e.TotalManipulation.Translation.Y > 40.5 && e.TotalManipulation.Translation.X < -40.5)
                            {
                                finalPosition.col = initialPosition.col - 1;
                                finalPosition.row = initialPosition.row + 1;
                            }
                        }
                    }
                }
                else
                {
                    if (e.TotalManipulation.Translation.Y < 0)
                    {
                        //Evaluamos si debemos sumar o restar una columna
                        if (e.TotalManipulation.Translation.X > 0)
                        {
                            if (e.TotalManipulation.Translation.Y < -40.5 && e.TotalManipulation.Translation.X > 40.5)
                            {
                                finalPosition.col = initialPosition.col + 1;
                                finalPosition.row = initialPosition.row - 1;
                            }
                        }
                        else
                        {
                            if (e.TotalManipulation.Translation.Y < -40.5 && e.TotalManipulation.Translation.X < -40.5)
                            {
                                finalPosition.col = initialPosition.col - 1;
                                finalPosition.row = initialPosition.row - 1;
                            }
                        }
                    }
                }
                #endregion

                #region Movement
                if (PlayMove.IsEmptyPlace(finalPosition.GetPosition(), boardPieces))
                {
                    cp.TranslateX -= e.TotalManipulation.Translation.X;
                    cp.TranslateY -= e.TotalManipulation.Translation.Y;
                    this.ellipse.SetValue(Grid.ColumnProperty, finalPosition.col);
                    this.ellipse.SetValue(Grid.RowProperty, finalPosition.row);
                    (boardPieces.Where(piece => piece.Name.Equals(this.ellipse.GetValue(NameProperty))).ToList <Pieces>()).ForEach(pi => pi.Position = finalPosition.GetPosition());
                    this.turn = !this.turn;
                }
                else
                {
                    if (PlayMove.TakePiece(finalPosition.GetPosition(), p, boardPieces))
                    {
                        Pieces tp         = (from t in boardPieces where t.Position.Equals(finalPosition.GetPosition()) && t.IsActive select t).Single();
                        bool   takedPiece = false;

                        #region Take_Piece
                        if (p.Color == ColorPeace.black)
                        {
                            if (e.TotalManipulation.Translation.Y > 0)
                            {
                                //Evaluamos si debemos sumar o restar una columna
                                if (e.TotalManipulation.Translation.X > 0)
                                {
                                    if (e.TotalManipulation.Translation.Y > 94.5 && e.TotalManipulation.Translation.X > 94.5)
                                    {
                                        finalPosition.col = initialPosition.col + 2;
                                        finalPosition.row = initialPosition.row + 2;
                                        takedPiece        = true;
                                    }
                                }
                                else
                                {
                                    if (e.TotalManipulation.Translation.Y > 94.5 && e.TotalManipulation.Translation.X < -94.5)
                                    {
                                        finalPosition.col = initialPosition.col - 2;
                                        finalPosition.row = initialPosition.row + 2;
                                        takedPiece        = true;
                                    }
                                }
                            }
                        }
                        else
                        {
                            if (e.TotalManipulation.Translation.Y < 0)
                            {
                                //Evaluamos si debemos sumar o restar una columna
                                if (e.TotalManipulation.Translation.X > 0)
                                {
                                    if (e.TotalManipulation.Translation.Y < -94.5 && e.TotalManipulation.Translation.X > 94.5)
                                    {
                                        finalPosition.col = initialPosition.col + 2;
                                        finalPosition.row = initialPosition.row - 2;
                                        takedPiece        = true;
                                    }
                                }
                                else
                                {
                                    if (e.TotalManipulation.Translation.Y < -94.5 && e.TotalManipulation.Translation.X < -94.5)
                                    {
                                        finalPosition.col = initialPosition.col - 2;
                                        finalPosition.row = initialPosition.row - 2;
                                        takedPiece        = true;
                                    }
                                }
                            }
                        }
                        #endregion

                        if (takedPiece)
                        {
                            foreach (var item in Board.Children)
                            {
                                // Solo nos interesan los objetos tipo Ellipse
                                if (item.GetType() == typeof(Ellipse))
                                {
                                    Ellipse eli = item as Ellipse;
                                    if (eli.GetValue(NameProperty).ToString() == tp.Name)
                                    {
                                        ImageBrush hib = new ImageBrush();
                                        hib.ImageSource = new BitmapImage(new Uri(@"pieceEmpty.png", UriKind.Relative));
                                        eli.Fill        = hib;
                                        eli.SetValue(Grid.ColumnProperty, 0);
                                        eli.SetValue(Grid.RowProperty, 0);
                                        boardPieces.Where(pc => pc.Name.Equals(tp.Name)).ToList().ForEach(ph => ph.IsActive = false);
                                        break;
                                    }
                                }
                            }
                            cp.TranslateX -= e.TotalManipulation.Translation.X;
                            cp.TranslateY -= e.TotalManipulation.Translation.Y;
                            this.ellipse.SetValue(Grid.ColumnProperty, finalPosition.col);
                            this.ellipse.SetValue(Grid.RowProperty, finalPosition.row);
                            boardPieces.Where(pc => pc.Name.Equals(this.ellipse.Name)).ToList().ForEach(ph => ph.Position = finalPosition.GetPosition());
                            this.turn = !this.turn;
                        }
                        else
                        {
                            cp.TranslateX -= e.TotalManipulation.Translation.X;
                            cp.TranslateY -= e.TotalManipulation.Translation.Y;
                        }
                    }
                    else
                    {
                        cp.TranslateX -= e.TotalManipulation.Translation.X;
                        cp.TranslateY -= e.TotalManipulation.Translation.Y;
                    }
                }
                #endregion

                if (PlayMove.IsCrow(finalPosition.GetPosition(), p.Color))
                {
                    ImageBrush qib = new ImageBrush();
                    boardPieces.Where(pc => pc.Name.Equals(this.ellipse.Name)).ToList <Pieces>().ForEach(pi => pi.IsQueen = true);
                    if (p.Color == ColorPeace.black)
                    {
                        qib.ImageSource = new BitmapImage(new Uri(@"blackCrown.png", UriKind.Relative));
                    }
                    else
                    {
                        qib.ImageSource = new BitmapImage(new Uri(@"whiteCrown.png", UriKind.Relative));
                    }
                    this.ellipse.Fill = qib;
                    this.txt1.Text    = string.Format("Damas Blancas {0} vs Damas Negras {1}",
                                                      boardPieces.Where(pc => pc.Color == ColorPeace.white && pc.IsActive && pc.IsQueen).ToList().Count.ToString(),
                                                      boardPieces.Where(pc => pc.Color == ColorPeace.black && pc.IsActive && pc.IsQueen).ToList().Count.ToString());
                }
            }

            this.txt.Text = string.Format("Blancas {0} vs Negras {1}",
                                          boardPieces.Where(p => p.Color == ColorPeace.white && p.IsActive).ToList().Count.ToString(),
                                          boardPieces.Where(p => p.Color == ColorPeace.black && p.IsActive).ToList().Count.ToString());

            if (boardPieces.Where(p => p.Color == ColorPeace.white && p.IsActive).ToList().Count == 0)
            {
                this.txt.Text = "Ganan las Rojas";
            }
            if (boardPieces.Where(p => p.Color == ColorPeace.black && p.IsActive).ToList().Count == 0)
            {
                this.txt.Text = "Ganan las Amarillas";
            }
        }
コード例 #35
0
ファイル: UIExtensions.cs プロジェクト: jarkkom/awfuldotnet
 public static Storyboard GetImageBrushOpenedStoryboard(ImageBrush element)
 {
     return element.GetValue(ImageBrushOpenedStoryboardProperty) as Storyboard;
 }
コード例 #36
0
        public void MakeMaze(Model3DGroup m3Dg)
        {
            ImageBrush Base_bmp = new ImageBrush()
            {
                ImageSource = new BitmapImage(new Uri(Path.Combine(Environment.CurrentDirectory, "Images", "Base.jpg")))
            };

            Base_bmp.Opacity = 0.5;
            ImageBrush Top_bmp = new ImageBrush()
            {
                ImageSource = new BitmapImage(new Uri(Path.Combine(Environment.CurrentDirectory, "Images", "Top.jpg")))
            };
            ImageBrush Inner_bmp = new ImageBrush()
            {
                ImageSource = new BitmapImage(new Uri(Path.Combine(Environment.CurrentDirectory, "Images", "Inner.jpg")))
            };

            Inner_bmp.Opacity = 0.65;
            ImageBrush Outer_bmp = new ImageBrush()
            {
                ImageSource = new BitmapImage(new Uri(Path.Combine(Environment.CurrentDirectory, "Images", "Outer.jpg")))
            };
            //Outer_bmp.Opacity = 0.1;

            Material Base_Material  = new DiffuseMaterial(Base_bmp);
            Material Top_Material   = new DiffuseMaterial(Top_bmp);
            Material Outer_Material = new DiffuseMaterial(Outer_bmp);
            Material Inner_Material = new DiffuseMaterial(Inner_bmp);

            MeshGeometry3D Base_mg3  = CreateMg3(m3Dg, Base_Material);
            MeshGeometry3D Top_mg3   = CreateMg3(m3Dg, Top_Material);
            MeshGeometry3D Outer_mg3 = CreateMg3(m3Dg, Outer_Material);
            MeshGeometry3D Inner_mg3 = CreateMg3(m3Dg, Inner_Material);

            int minX = -15, minZ = -15;

            // Base
            for (int x = minX; x <= 3; x += 2)
            {
                for (int z = minZ; z <= 3; z += 2)
                {
                    Triangulate(Base_mg3, new Point3D(x, Base, z), new Point3D(x, Base, z + 2), new Point3D(x + 2, Base, z + 2), new Point3D(x + 2, Base, z), new Point(0, 0), new Point(0, 1), new Point(1, 1), new Point(1, 0));
                }
            }

            // Top.
            for (int x = minX; x <= 4; x += 1)
            {
                for (int z = minZ; z <= 4; z += 1)
                {
                    Triangulate(Top_mg3, new Point3D(x, Top, z), new Point3D(x + 1, Top, z), new Point3D(x + 1, Top, z + 1), new Point3D(x, Top, z + 1), new Point(0, 0), new Point(0, 1), new Point(1, 1), new Point(1, 0));
                }
            }

            //var sky = Top;
            //sky = 20;
            //// Top.
            //for (int x = -150; x <= 150; x++)
            //    for (int z = -150; z <= 150; z++)
            //        Triangulate(Top_mg3, new Point3D(x, sky, z), new Point3D(x + 1, sky, z), new Point3D(x + 1, sky, z + 1), new Point3D(x, sky, z + 1), new Point(0, 0), new Point(0, 1), new Point(1, 1), new Point(1, 0));



            // Outer pair 1:2
            for (int x = minX; x <= 3; x += 2)
            {
                Triangulate(Outer_mg3, new Point3D(x, Top, -5), new Point3D(x, Base, -5), new Point3D(x + 2, Base, -5), new Point3D(x + 2, Top, -5), new Point(0, 0), new Point(0, 1), new Point(0.5, 1), new Point(0.5, 0));
                Triangulate(Outer_mg3, new Point3D(x + 2, Top, 5), new Point3D(x + 2, Base, 5), new Point3D(x, Base, 5), new Point3D(x, Top, 5), new Point(0, 0), new Point(0, 1), new Point(0.5, 1), new Point(0.5, 0));
            }

            // Outer pair 2:2
            for (int z = -5; z <= 3; z += 2)
            {
                Triangulate(Outer_mg3, new Point3D(5, Top, z), new Point3D(5, Base, z), new Point3D(5, Base, z + 2), new Point3D(5, Top, z + 2), new Point(0, 0), new Point(0, 1), new Point(0.5, 1), new Point(0.5, 0));
                Triangulate(Outer_mg3, new Point3D(-5, Top, z + 2), new Point3D(-5, Base, z + 2), new Point3D(-5, Base, z), new Point3D(-5, Top, z), new Point(0, 0), new Point(0, 1), new Point(0.5, 1), new Point(0.5, 0));
            }

            List <int> K = new List <int>()
            {
                -1, -5, -1, -4, -2, -4, -2, -3, -1, -4, -1, -3, 4, -4, 4, -3, -2, -3, -2, -2, 3, -3, 3, -2, 4, -3, 4, -2, -3, -2, -3, -1, 1, -2, 1, -1, 2, -2, 2, -1, 3, -2, 3, -1, 4, -2, 4, -1, -3, -1, -3, 0, -2, -1, -2, 0, -1, -1, -1, 0, 0, -1, 0, 0, 1, -1, 1, 0, 2, -1, 2, 0, 4, -1, 4, 0, -4, 0, -4, 1, -3, 0, -3, 1, -2, 0, -2, 1, 0, 0, 0, 1, 1, 0, 1, 1, 2, 0, 2, 1, 3, 0, 3, 1, 4, 0, 4, 1, -4, 1, -4, 2, -3, 1, -3, 2, -2, 1, -2, 2, -1, 1, -1, 2, 1, 1, 1, 2, 2, 1, 2, 2, 3, 1, 3, 2, -4, 2, -4, 3, -3, 2, -3, 3, -2, 2, -2, 3, 2, 2, 2, 3, 4, 2, 4, 3, -4, 3, -4, 4, -2, 3, -2, 4, -1, 3, -1, 4, 3, 3, 3, 4, 4, 3, 4, 4, -1, 4, -1, 5, 4, 4, 4, 5, -5, -3, -4, -3, -5, -1, -4, -1, -4, -4, -3, -4, -4, -3, -3, -3, -4, -2, -3, -2, -4, 4, -3, 4, -3, -4, -2, -4, -3, -2, -2, -2, -3, 4, -2, 4, -2, -2, -1, -2, -2, 2, -1, 2, -1, -3, -0, -3, -1, -2, -0, -2, -1, -1, -0, -1, -1, 1, -0, 1, -1, 3, -0, 3, 0, -4, 1, -4, 0, -3, 1, -3, 0, -2, 1, -2, 0, 2, 1, 2, 0, 3, 1, 3, 0, 4, 1, 4, 1, -4, 2, -4, 1, -3, 2, -3, 1, 4, 2, 4, 2, -4, 3, -4, 2, -3, 3, -3, 2, 3, 3, 3, 2, 4, 3, 4, 3, -4, 4, -4, 3, 2, 4, 2
            };

            for (int i = 0; i + 4 < K.Count; i += 4)
            {
                ExtrudeSurface(ref Inner_mg3, new Surface()
                {
                    X1 = K[i], Z1 = K[i + 1], X2 = K[i + 2], Z2 = K[i + 3]
                });
            }
        }
コード例 #37
0
 private BrushAnimator(Stream sourceStream, Uri sourceUri, GifDataStream metadata, RepeatBehavior repeatBehavior) : base(sourceStream, sourceUri, metadata, repeatBehavior)
 {
     Brush = new ImageBrush {ImageSource = Bitmap};
 }
コード例 #38
0
ファイル: TileSizeExample.cs プロジェクト: zhimaqiao51/docs
        public TileSizeExample()
        {
            // <SnippetRelativeTileSizeExample>

            //
            // Create an ImageBrush and set the size of each
            // tile to 50% by 50% of the area being painted.
            //
            ImageBrush relativeTileSizeImageBrush = new ImageBrush();

            relativeTileSizeImageBrush.ImageSource =
                new BitmapImage(new Uri(@"sampleImages\cherries_larger.jpg", UriKind.Relative));
            relativeTileSizeImageBrush.TileMode = TileMode.Tile;

            // Specify the size of the base tile.
            // By default, the size of the Viewport is
            // relative to the area being painted,
            // so a value of 0.5 indicates 50% of the output
            // area.
            relativeTileSizeImageBrush.Viewport = new Rect(0, 0, 0.5, 0.5);

            // Create a rectangle and paint it with the ImageBrush.
            Rectangle relativeTileSizeExampleRectangle = new Rectangle();

            relativeTileSizeExampleRectangle.Width           = 200;
            relativeTileSizeExampleRectangle.Height          = 150;
            relativeTileSizeExampleRectangle.Stroke          = Brushes.LimeGreen;
            relativeTileSizeExampleRectangle.StrokeThickness = 1;
            relativeTileSizeExampleRectangle.Fill            = relativeTileSizeImageBrush;
            // </SnippetRelativeTileSizeExample>

            // <SnippetAbsoluteTileSizeExample>

            //
            // Create an ImageBrush and set the size of each
            // tile to 25 by 25 pixels.
            //
            ImageBrush absoluteTileSizeImageBrush = new ImageBrush();

            absoluteTileSizeImageBrush.ImageSource =
                new BitmapImage(new Uri(@"sampleImages\cherries_larger.jpg", UriKind.Relative));
            absoluteTileSizeImageBrush.TileMode = TileMode.Tile;

            // Specify that the Viewport is to be interpreted as
            // an absolute value.
            absoluteTileSizeImageBrush.ViewportUnits = BrushMappingMode.Absolute;

            // Set the size of the base tile. Had we left ViewportUnits set
            // to RelativeToBoundingBox (the default value),
            // each tile would be 25 times the size of the area being
            // painted. Because ViewportUnits is set to Absolute,
            // the following line creates tiles that are 25 by 25 pixels.
            absoluteTileSizeImageBrush.Viewport = new Rect(0, 0, 25, 25);

            // Create a rectangle and paint it with the ImageBrush.
            Rectangle absoluteTileSizeExampleRectangle = new Rectangle();

            absoluteTileSizeExampleRectangle.Width           = 200;
            absoluteTileSizeExampleRectangle.Height          = 150;
            absoluteTileSizeExampleRectangle.Stroke          = Brushes.LimeGreen;
            absoluteTileSizeExampleRectangle.StrokeThickness = 1;
            absoluteTileSizeExampleRectangle.Fill            = absoluteTileSizeImageBrush;
            // </SnippetAbsoluteTileSizeExample>

            StackPanel mainPanel = new StackPanel();

            mainPanel.Children.Add(relativeTileSizeExampleRectangle);
            mainPanel.Children.Add(absoluteTileSizeExampleRectangle);
            Content = mainPanel;

            Title      = "Tile Size Example";
            Background = Brushes.White;
            Margin     = new Thickness(20);
        }
コード例 #39
0
ファイル: BasicUI.xaml.cs プロジェクト: Mike-EEE/UI_Examples
 private static System.Collections.ObjectModel.ObservableCollection<object> Get_TabControl_Items()
 {
     System.Collections.ObjectModel.ObservableCollection<object> items = new System.Collections.ObjectModel.ObservableCollection<object>();
     // e_3 element
     TabItem e_3 = new TabItem();
     e_3.Name = "e_3";
     e_3.HorizontalContentAlignment = HorizontalAlignment.Stretch;
     e_3.Header = "Controls";
     // e_4 element
     Grid e_4 = new Grid();
     e_3.Content = e_4;
     e_4.Name = "e_4";
     RowDefinition row_e_4_0 = new RowDefinition();
     row_e_4_0.Height = new GridLength(1F, GridUnitType.Auto);
     e_4.RowDefinitions.Add(row_e_4_0);
     RowDefinition row_e_4_1 = new RowDefinition();
     row_e_4_1.Height = new GridLength(1F, GridUnitType.Auto);
     e_4.RowDefinitions.Add(row_e_4_1);
     RowDefinition row_e_4_2 = new RowDefinition();
     row_e_4_2.Height = new GridLength(1F, GridUnitType.Auto);
     e_4.RowDefinitions.Add(row_e_4_2);
     RowDefinition row_e_4_3 = new RowDefinition();
     row_e_4_3.Height = new GridLength(1F, GridUnitType.Auto);
     e_4.RowDefinitions.Add(row_e_4_3);
     RowDefinition row_e_4_4 = new RowDefinition();
     row_e_4_4.Height = new GridLength(1F, GridUnitType.Auto);
     e_4.RowDefinitions.Add(row_e_4_4);
     RowDefinition row_e_4_5 = new RowDefinition();
     row_e_4_5.Height = new GridLength(1F, GridUnitType.Auto);
     e_4.RowDefinitions.Add(row_e_4_5);
     RowDefinition row_e_4_6 = new RowDefinition();
     row_e_4_6.Height = new GridLength(1F, GridUnitType.Auto);
     e_4.RowDefinitions.Add(row_e_4_6);
     RowDefinition row_e_4_7 = new RowDefinition();
     row_e_4_7.Height = new GridLength(1F, GridUnitType.Auto);
     e_4.RowDefinitions.Add(row_e_4_7);
     RowDefinition row_e_4_8 = new RowDefinition();
     row_e_4_8.Height = new GridLength(1F, GridUnitType.Auto);
     e_4.RowDefinitions.Add(row_e_4_8);
     RowDefinition row_e_4_9 = new RowDefinition();
     row_e_4_9.Height = new GridLength(1F, GridUnitType.Auto);
     e_4.RowDefinitions.Add(row_e_4_9);
     ColumnDefinition col_e_4_0 = new ColumnDefinition();
     col_e_4_0.Width = new GridLength(1F, GridUnitType.Auto);
     e_4.ColumnDefinitions.Add(col_e_4_0);
     ColumnDefinition col_e_4_1 = new ColumnDefinition();
     e_4.ColumnDefinitions.Add(col_e_4_1);
     // e_5 element
     TextBlock e_5 = new TextBlock();
     e_4.Children.Add(e_5);
     e_5.Name = "e_5";
     e_5.VerticalAlignment = VerticalAlignment.Center;
     e_5.Text = "Button";
     // button1 element
     Button button1 = new Button();
     e_4.Children.Add(button1);
     button1.Name = "button1";
     button1.Height = 30F;
     button1.Width = 200F;
     button1.Margin = new Thickness(5F, 5F, 5F, 5F);
     button1.HorizontalAlignment = HorizontalAlignment.Left;
     button1.TabIndex = 1;
     button1.Content = "Button 1";
     button1.CommandParameter = "Click Button 1";
     Grid.SetColumn(button1, 1);
     Grid.SetRow(button1, 0);
     Binding binding_button1_Command = new Binding("ButtonCommand");
     button1.SetBinding(Button.CommandProperty, binding_button1_Command);
     // button2 element
     Button button2 = new Button();
     e_4.Children.Add(button2);
     button2.Name = "button2";
     button2.Height = 30F;
     button2.Width = 200F;
     button2.Margin = new Thickness(5F, 5F, 5F, 5F);
     button2.HorizontalAlignment = HorizontalAlignment.Left;
     button2.TabIndex = 2;
     button2.Content = "Button 2";
     button2.CommandParameter = "Click Button 2";
     Grid.SetColumn(button2, 1);
     Grid.SetRow(button2, 1);
     Binding binding_button2_IsEnabled = new Binding("ButtonEnabled");
     button2.SetBinding(Button.IsEnabledProperty, binding_button2_IsEnabled);
     Binding binding_button2_Command = new Binding("ButtonCommand");
     button2.SetBinding(Button.CommandProperty, binding_button2_Command);
     // buttonResult element
     TextBlock buttonResult = new TextBlock();
     e_4.Children.Add(buttonResult);
     buttonResult.Name = "buttonResult";
     buttonResult.HorizontalAlignment = HorizontalAlignment.Left;
     Grid.SetColumn(buttonResult, 1);
     Grid.SetRow(buttonResult, 2);
     Binding binding_buttonResult_Text = new Binding("ButtonResult");
     buttonResult.SetBinding(TextBlock.TextProperty, binding_buttonResult_Text);
     // e_6 element
     TextBlock e_6 = new TextBlock();
     e_4.Children.Add(e_6);
     e_6.Name = "e_6";
     e_6.VerticalAlignment = VerticalAlignment.Center;
     e_6.Text = "CheckBox";
     Grid.SetRow(e_6, 3);
     // checkBox element
     CheckBox checkBox = new CheckBox();
     e_4.Children.Add(checkBox);
     checkBox.Name = "checkBox";
     checkBox.Margin = new Thickness(5F, 5F, 5F, 5F);
     checkBox.HorizontalAlignment = HorizontalAlignment.Left;
     checkBox.TabIndex = 3;
     checkBox.Content = "Check Box";
     Grid.SetColumn(checkBox, 1);
     Grid.SetRow(checkBox, 3);
     // e_7 element
     TextBlock e_7 = new TextBlock();
     e_4.Children.Add(e_7);
     e_7.Name = "e_7";
     e_7.VerticalAlignment = VerticalAlignment.Center;
     e_7.Text = "ProgressBar";
     Grid.SetRow(e_7, 4);
     // e_8 element
     ProgressBar e_8 = new ProgressBar();
     e_4.Children.Add(e_8);
     e_8.Name = "e_8";
     e_8.Height = 30F;
     e_8.Width = 200F;
     e_8.Margin = new Thickness(5F, 5F, 5F, 5F);
     e_8.HorizontalAlignment = HorizontalAlignment.Left;
     Grid.SetColumn(e_8, 1);
     Grid.SetRow(e_8, 4);
     Binding binding_e_8_Value = new Binding("ProgressValue");
     e_8.SetBinding(ProgressBar.ValueProperty, binding_e_8_Value);
     // e_9 element
     TextBlock e_9 = new TextBlock();
     e_4.Children.Add(e_9);
     e_9.Name = "e_9";
     e_9.VerticalAlignment = VerticalAlignment.Center;
     e_9.Text = "Slider";
     Grid.SetRow(e_9, 5);
     // slider element
     Slider slider = new Slider();
     e_4.Children.Add(slider);
     slider.Name = "slider";
     slider.Width = 200F;
     slider.HorizontalAlignment = HorizontalAlignment.Left;
     slider.TabIndex = 4;
     slider.Minimum = 5F;
     slider.Maximum = 20F;
     Grid.SetColumn(slider, 1);
     Grid.SetRow(slider, 5);
     Binding binding_slider_Value = new Binding("SliderValue");
     slider.SetBinding(Slider.ValueProperty, binding_slider_Value);
     // e_10 element
     TextBlock e_10 = new TextBlock();
     e_4.Children.Add(e_10);
     e_10.Name = "e_10";
     e_10.VerticalAlignment = VerticalAlignment.Center;
     e_10.Text = "TextBox";
     Grid.SetRow(e_10, 6);
     // textBox element
     TextBox textBox = new TextBox();
     e_4.Children.Add(textBox);
     textBox.Name = "textBox";
     textBox.Width = 200F;
     textBox.Margin = new Thickness(5F, 5F, 5F, 5F);
     textBox.HorizontalAlignment = HorizontalAlignment.Left;
     textBox.TabIndex = 5;
     Grid.SetColumn(textBox, 1);
     Grid.SetRow(textBox, 6);
     Binding binding_textBox_Text = new Binding("TextBoxText");
     textBox.SetBinding(TextBox.TextProperty, binding_textBox_Text);
     // e_11 element
     TextBlock e_11 = new TextBlock();
     e_4.Children.Add(e_11);
     e_11.Name = "e_11";
     e_11.VerticalAlignment = VerticalAlignment.Center;
     e_11.Text = "PasswordBox";
     Grid.SetRow(e_11, 7);
     // e_12 element
     PasswordBox e_12 = new PasswordBox();
     e_4.Children.Add(e_12);
     e_12.Name = "e_12";
     e_12.Width = 200F;
     e_12.Margin = new Thickness(5F, 5F, 5F, 5F);
     e_12.HorizontalAlignment = HorizontalAlignment.Left;
     e_12.TabIndex = 6;
     Grid.SetColumn(e_12, 1);
     Grid.SetRow(e_12, 7);
     // e_13 element
     TextBlock e_13 = new TextBlock();
     e_4.Children.Add(e_13);
     e_13.Name = "e_13";
     e_13.VerticalAlignment = VerticalAlignment.Center;
     e_13.Text = "ComboBox";
     Grid.SetRow(e_13, 8);
     // combo element
     ComboBox combo = new ComboBox();
     e_4.Children.Add(combo);
     combo.Name = "combo";
     combo.Width = 200F;
     combo.Margin = new Thickness(5F, 5F, 5F, 5F);
     combo.HorizontalAlignment = HorizontalAlignment.Left;
     combo.TabIndex = 7;
     combo.ItemsSource = Get_combo_Items();
     combo.SelectedIndex = 2;
     Grid.SetColumn(combo, 1);
     Grid.SetRow(combo, 8);
     // e_14 element
     TextBlock e_14 = new TextBlock();
     e_4.Children.Add(e_14);
     e_14.Name = "e_14";
     e_14.VerticalAlignment = VerticalAlignment.Center;
     e_14.Text = "ListBox";
     Grid.SetRow(e_14, 9);
     // e_15 element
     ListBox e_15 = new ListBox();
     e_4.Children.Add(e_15);
     e_15.Name = "e_15";
     e_15.TabIndex = 8;
     e_15.ItemsSource = Get_e_15_Items();
     Grid.SetColumn(e_15, 1);
     Grid.SetRow(e_15, 9);
     items.Add(e_3);
     // e_22 element
     TabItem e_22 = new TabItem();
     e_22.Name = "e_22";
     e_22.Header = "DataGrid";
     // e_23 element
     DataGrid e_23 = new DataGrid();
     e_22.Content = e_23;
     e_23.Name = "e_23";
     e_23.AutoGenerateColumns = false;
     DataGridTextColumn e_23_Col0 = new DataGridTextColumn();
     e_23_Col0.Header = "#";
     Binding e_23_Col0_b = new Binding("Number");
     e_23_Col0.Binding = e_23_Col0_b;
     e_23.Columns.Add(e_23_Col0);
     DataGridTextColumn e_23_Col1 = new DataGridTextColumn();
     e_23_Col1.Header = "Text";
     Style e_23_Col1_e_s = new Style(typeof(DataGridCell));
     Setter e_23_Col1_e_s_S_0 = new Setter(DataGridCell.BackgroundProperty, new SolidColorBrush(new ColorW(128, 128, 128, 255)));
     e_23_Col1_e_s.Setters.Add(e_23_Col1_e_s_S_0);
     Setter e_23_Col1_e_s_S_1 = new Setter(DataGridCell.HorizontalAlignmentProperty, HorizontalAlignment.Center);
     e_23_Col1_e_s.Setters.Add(e_23_Col1_e_s_S_1);
     Setter e_23_Col1_e_s_S_2 = new Setter(DataGridCell.VerticalAlignmentProperty, VerticalAlignment.Center);
     e_23_Col1_e_s.Setters.Add(e_23_Col1_e_s_S_2);
     e_23_Col1.ElementStyle = e_23_Col1_e_s;
     Binding e_23_Col1_b = new Binding("Text");
     e_23_Col1.Binding = e_23_Col1_b;
     e_23.Columns.Add(e_23_Col1);
     DataGridCheckBoxColumn e_23_Col2 = new DataGridCheckBoxColumn();
     e_23_Col2.Header = "Bool";
     Binding e_23_Col2_b = new Binding("Boolean");
     e_23_Col2.Binding = e_23_Col2_b;
     e_23.Columns.Add(e_23_Col2);
     DataGridTemplateColumn e_23_Col3 = new DataGridTemplateColumn();
     e_23_Col3.Width = 200F;
     // e_24 element
     TextBlock e_24 = new TextBlock();
     e_24.Name = "e_24";
     e_24.Text = "Template Column";
     e_23_Col3.Header = e_24;
     Style e_23_Col3_h_s = new Style(typeof(DataGridColumnHeader));
     Setter e_23_Col3_h_s_S_0 = new Setter(DataGridColumnHeader.ForegroundProperty, new SolidColorBrush(new ColorW(255, 165, 0, 255)));
     e_23_Col3_h_s.Setters.Add(e_23_Col3_h_s_S_0);
     e_23_Col3.HeaderStyle = e_23_Col3_h_s;
     Func<UIElement, UIElement> e_23_Col3_ct_dtFunc = e_23_Col3_ct_dtMethod;
     e_23_Col3.CellTemplate = new DataTemplate(e_23_Col3_ct_dtFunc);
     e_23.Columns.Add(e_23_Col3);
     Binding binding_e_23_ItemsSource = new Binding("GridData");
     e_23.SetBinding(DataGrid.ItemsSourceProperty, binding_e_23_ItemsSource);
     items.Add(e_22);
     // e_30 element
     TabItem e_30 = new TabItem();
     e_30.Name = "e_30";
     e_30.Header = "TreeView";
     // e_31 element
     TreeView e_31 = new TreeView();
     e_30.Content = e_31;
     e_31.Name = "e_31";
     Binding binding_e_31_ItemsSource = new Binding("TreeItems");
     e_31.SetBinding(TreeView.ItemsSourceProperty, binding_e_31_ItemsSource);
     items.Add(e_30);
     // e_32 element
     TabItem e_32 = new TabItem();
     e_32.Name = "e_32";
     e_32.Header = "Shapes";
     // e_33 element
     Grid e_33 = new Grid();
     e_32.Content = e_33;
     e_33.Name = "e_33";
     RowDefinition row_e_33_0 = new RowDefinition();
     e_33.RowDefinitions.Add(row_e_33_0);
     RowDefinition row_e_33_1 = new RowDefinition();
     e_33.RowDefinitions.Add(row_e_33_1);
     RowDefinition row_e_33_2 = new RowDefinition();
     e_33.RowDefinitions.Add(row_e_33_2);
     ColumnDefinition col_e_33_0 = new ColumnDefinition();
     e_33.ColumnDefinitions.Add(col_e_33_0);
     ColumnDefinition col_e_33_1 = new ColumnDefinition();
     e_33.ColumnDefinitions.Add(col_e_33_1);
     ColumnDefinition col_e_33_2 = new ColumnDefinition();
     e_33.ColumnDefinitions.Add(col_e_33_2);
     // e_34 element
     Rectangle e_34 = new Rectangle();
     e_33.Children.Add(e_34);
     e_34.Name = "e_34";
     e_34.Height = 100F;
     e_34.Width = 200F;
     e_34.Margin = new Thickness(5F, 5F, 5F, 5F);
     e_34.Fill = new SolidColorBrush(new ColorW(0, 128, 0, 255));
     e_34.Stroke = new SolidColorBrush(new ColorW(128, 128, 128, 255));
     e_34.StrokeThickness = 5F;
     e_34.RadiusX = 10F;
     e_34.RadiusY = 10F;
     // e_35 element
     Rectangle e_35 = new Rectangle();
     e_33.Children.Add(e_35);
     e_35.Name = "e_35";
     e_35.Height = 100F;
     e_35.Width = 200F;
     e_35.Margin = new Thickness(5F, 5F, 5F, 5F);
     e_35.Fill = new SolidColorBrush(new ColorW(255, 165, 0, 255));
     Grid.SetColumn(e_35, 1);
     // e_36 element
     Rectangle e_36 = new Rectangle();
     e_33.Children.Add(e_36);
     e_36.Name = "e_36";
     e_36.Height = 100F;
     e_36.Width = 200F;
     e_36.Margin = new Thickness(5F, 5F, 5F, 5F);
     LinearGradientBrush e_36_Fill = new LinearGradientBrush();
     e_36_Fill.StartPoint = new PointF(0F, 0F);
     e_36_Fill.EndPoint = new PointF(1F, 1F);
     e_36_Fill.SpreadMethod = GradientSpreadMethod.Pad;
     e_36_Fill.GradientStops.Add(new GradientStop(new ColorW(255, 165, 0, 255), 0.5F));
     e_36_Fill.GradientStops.Add(new GradientStop(new ColorW(0, 162, 255, 255), 0F));
     e_36.Fill = e_36_Fill;
     LinearGradientBrush e_36_Stroke = new LinearGradientBrush();
     e_36_Stroke.StartPoint = new PointF(0F, 0F);
     e_36_Stroke.EndPoint = new PointF(1F, 1F);
     e_36_Stroke.SpreadMethod = GradientSpreadMethod.Pad;
     e_36_Stroke.GradientStops.Add(new GradientStop(new ColorW(0, 162, 255, 255), 0.5F));
     e_36_Stroke.GradientStops.Add(new GradientStop(new ColorW(255, 165, 0, 255), 0F));
     e_36.Stroke = e_36_Stroke;
     e_36.StrokeThickness = 5F;
     e_36.RadiusX = 10F;
     e_36.RadiusY = 10F;
     Grid.SetColumn(e_36, 2);
     // e_37 element
     Ellipse e_37 = new Ellipse();
     e_33.Children.Add(e_37);
     e_37.Name = "e_37";
     e_37.Height = 100F;
     e_37.Width = 200F;
     e_37.Margin = new Thickness(5F, 5F, 5F, 5F);
     e_37.Fill = new SolidColorBrush(new ColorW(128, 128, 128, 255));
     e_37.Stroke = new SolidColorBrush(new ColorW(0, 128, 0, 255));
     e_37.StrokeThickness = 10F;
     Grid.SetRow(e_37, 1);
     // e_38 element
     Ellipse e_38 = new Ellipse();
     e_33.Children.Add(e_38);
     e_38.Name = "e_38";
     e_38.Height = 100F;
     e_38.Width = 200F;
     e_38.Margin = new Thickness(5F, 5F, 5F, 5F);
     e_38.Stroke = new SolidColorBrush(new ColorW(255, 165, 0, 255));
     e_38.StrokeThickness = 10F;
     Grid.SetColumn(e_38, 1);
     Grid.SetRow(e_38, 1);
     // e_39 element
     Ellipse e_39 = new Ellipse();
     e_33.Children.Add(e_39);
     e_39.Name = "e_39";
     e_39.Height = 100F;
     e_39.Width = 200F;
     e_39.Margin = new Thickness(5F, 5F, 5F, 5F);
     LinearGradientBrush e_39_Fill = new LinearGradientBrush();
     e_39_Fill.StartPoint = new PointF(0F, 0F);
     e_39_Fill.EndPoint = new PointF(1F, 1F);
     e_39_Fill.SpreadMethod = GradientSpreadMethod.Pad;
     e_39_Fill.GradientStops.Add(new GradientStop(new ColorW(255, 165, 0, 255), 0.5F));
     e_39_Fill.GradientStops.Add(new GradientStop(new ColorW(0, 162, 255, 255), 0F));
     e_39.Fill = e_39_Fill;
     LinearGradientBrush e_39_Stroke = new LinearGradientBrush();
     e_39_Stroke.StartPoint = new PointF(0F, 0F);
     e_39_Stroke.EndPoint = new PointF(1F, 1F);
     e_39_Stroke.SpreadMethod = GradientSpreadMethod.Pad;
     e_39_Stroke.GradientStops.Add(new GradientStop(new ColorW(0, 162, 255, 255), 0.5F));
     e_39_Stroke.GradientStops.Add(new GradientStop(new ColorW(255, 165, 0, 255), 0F));
     e_39.Stroke = e_39_Stroke;
     e_39.StrokeThickness = 10F;
     Grid.SetColumn(e_39, 2);
     Grid.SetRow(e_39, 1);
     // e_40 element
     Line e_40 = new Line();
     e_33.Children.Add(e_40);
     e_40.Name = "e_40";
     e_40.Stroke = new SolidColorBrush(new ColorW(128, 128, 128, 255));
     e_40.StrokeThickness = 10F;
     e_40.X1 = 10F;
     e_40.X2 = 150F;
     e_40.Y1 = 10F;
     e_40.Y2 = 150F;
     Grid.SetRow(e_40, 2);
     // e_41 element
     Line e_41 = new Line();
     e_33.Children.Add(e_41);
     e_41.Name = "e_41";
     e_41.Stroke = new SolidColorBrush(new ColorW(128, 128, 128, 255));
     e_41.StrokeThickness = 10F;
     e_41.X1 = 100F;
     e_41.X2 = 100F;
     e_41.Y1 = 10F;
     e_41.Y2 = 100F;
     Grid.SetRow(e_41, 2);
     // e_42 element
     Line e_42 = new Line();
     e_33.Children.Add(e_42);
     e_42.Name = "e_42";
     e_42.Stroke = new SolidColorBrush(new ColorW(128, 128, 128, 255));
     e_42.StrokeThickness = 10F;
     e_42.X1 = 10F;
     e_42.X2 = 100F;
     e_42.Y1 = 100F;
     e_42.Y2 = 100F;
     Grid.SetRow(e_42, 2);
     // e_43 element
     Rectangle e_43 = new Rectangle();
     e_33.Children.Add(e_43);
     e_43.Name = "e_43";
     e_43.Height = 100F;
     e_43.Width = 200F;
     e_43.Margin = new Thickness(5F, 5F, 5F, 5F);
     ImageBrush e_43_Fill = new ImageBrush();
     BitmapImage e_43_Fill_bm = new BitmapImage();
     e_43_Fill_bm.TextureAsset = "Images/MonoGameLogo";
     e_43_Fill.ImageSource = e_43_Fill_bm;
     e_43_Fill.Stretch = Stretch.None;
     e_43.Fill = e_43_Fill;
     e_43.Stroke = new SolidColorBrush(new ColorW(255, 255, 255, 255));
     e_43.StrokeThickness = 1F;
     e_43.RadiusX = 10F;
     e_43.RadiusY = 10F;
     Grid.SetColumn(e_43, 1);
     Grid.SetRow(e_43, 2);
     items.Add(e_32);
     // e_44 element
     TabItem e_44 = new TabItem();
     e_44.Name = "e_44";
     e_44.Header = "Animations";
     // e_45 element
     Grid e_45 = new Grid();
     e_44.Content = e_45;
     e_45.Name = "e_45";
     ColumnDefinition col_e_45_0 = new ColumnDefinition();
     e_45.ColumnDefinitions.Add(col_e_45_0);
     ColumnDefinition col_e_45_1 = new ColumnDefinition();
     e_45.ColumnDefinitions.Add(col_e_45_1);
     // e_46 element
     StackPanel e_46 = new StackPanel();
     e_45.Children.Add(e_46);
     e_46.Name = "e_46";
     // animButton1 element
     Button animButton1 = new Button();
     e_46.Children.Add(animButton1);
     animButton1.Name = "animButton1";
     animButton1.TabIndex = 1;
     animButton1.Content = "Mouse Over me!";
     animButton1.SetResourceReference(Button.StyleProperty, "buttonAnimStyle");
     // animButton2 element
     Button animButton2 = new Button();
     e_46.Children.Add(animButton2);
     animButton2.Name = "animButton2";
     animButton2.TabIndex = 2;
     animButton2.Content = "Mouse Over me!";
     animButton2.SetResourceReference(Button.StyleProperty, "buttonAnimStyle");
     // animButton3 element
     Button animButton3 = new Button();
     e_46.Children.Add(animButton3);
     animButton3.Name = "animButton3";
     animButton3.TabIndex = 3;
     animButton3.Content = "Mouse Over me!";
     animButton3.SetResourceReference(Button.StyleProperty, "buttonAnimStyle");
     // animButton4 element
     Button animButton4 = new Button();
     e_46.Children.Add(animButton4);
     animButton4.Name = "animButton4";
     animButton4.TabIndex = 4;
     animButton4.Content = "Mouse Over me!";
     animButton4.SetResourceReference(Button.StyleProperty, "buttonAnimStyle");
     // animBorder1 element
     Border animBorder1 = new Border();
     e_45.Children.Add(animBorder1);
     animBorder1.Name = "animBorder1";
     animBorder1.Height = 100F;
     animBorder1.Width = 200F;
     animBorder1.Margin = new Thickness(0F, 10F, 0F, 10F);
     animBorder1.VerticalAlignment = VerticalAlignment.Top;
     EventTrigger animBorder1_ET_0 = new EventTrigger(Border.LoadedEvent, animBorder1);
     animBorder1.Triggers.Add(animBorder1_ET_0);
     BeginStoryboard animBorder1_ET_0_AC_0 = new BeginStoryboard();
     animBorder1_ET_0_AC_0.Name = "animBorder1_ET_0_AC_0";
     animBorder1_ET_0.AddAction(animBorder1_ET_0_AC_0);
     Storyboard animBorder1_ET_0_AC_0_SB = new Storyboard();
     animBorder1_ET_0_AC_0.Storyboard = animBorder1_ET_0_AC_0_SB;
     animBorder1_ET_0_AC_0_SB.Name = "animBorder1_ET_0_AC_0_SB";
     SolidColorBrushAnimation animBorder1_ET_0_AC_0_SB_TL_0 = new SolidColorBrushAnimation();
     animBorder1_ET_0_AC_0_SB_TL_0.Name = "animBorder1_ET_0_AC_0_SB_TL_0";
     animBorder1_ET_0_AC_0_SB_TL_0.AutoReverse = true;
     animBorder1_ET_0_AC_0_SB_TL_0.Duration = new Duration(new TimeSpan(0, 0, 0, 5, 0));
     animBorder1_ET_0_AC_0_SB_TL_0.RepeatBehavior = RepeatBehavior.Forever;
     animBorder1_ET_0_AC_0_SB_TL_0.From = new ColorW(255, 255, 0, 255);
     animBorder1_ET_0_AC_0_SB_TL_0.To = new ColorW(0, 0, 255, 255);
     ExponentialEase animBorder1_ET_0_AC_0_SB_TL_0_EA = new ExponentialEase();
     animBorder1_ET_0_AC_0_SB_TL_0.EasingFunction = animBorder1_ET_0_AC_0_SB_TL_0_EA;
     Storyboard.SetTargetName(animBorder1_ET_0_AC_0_SB_TL_0, "animBorder1");
     Storyboard.SetTargetProperty(animBorder1_ET_0_AC_0_SB_TL_0, Border.BackgroundProperty);
     animBorder1_ET_0_AC_0_SB.Children.Add(animBorder1_ET_0_AC_0_SB_TL_0);
     Grid.SetColumn(animBorder1, 1);
     // animBorder2 element
     Border animBorder2 = new Border();
     e_45.Children.Add(animBorder2);
     animBorder2.Name = "animBorder2";
     animBorder2.Height = 50F;
     animBorder2.Width = 100F;
     animBorder2.Margin = new Thickness(50F, 35F, 50F, 35F);
     animBorder2.VerticalAlignment = VerticalAlignment.Top;
     EventTrigger animBorder2_ET_0 = new EventTrigger(Border.LoadedEvent, animBorder2);
     animBorder2.Triggers.Add(animBorder2_ET_0);
     BeginStoryboard animBorder2_ET_0_AC_0 = new BeginStoryboard();
     animBorder2_ET_0_AC_0.Name = "animBorder2_ET_0_AC_0";
     animBorder2_ET_0.AddAction(animBorder2_ET_0_AC_0);
     Storyboard animBorder2_ET_0_AC_0_SB = new Storyboard();
     animBorder2_ET_0_AC_0.Storyboard = animBorder2_ET_0_AC_0_SB;
     animBorder2_ET_0_AC_0_SB.Name = "animBorder2_ET_0_AC_0_SB";
     SolidColorBrushAnimation animBorder2_ET_0_AC_0_SB_TL_0 = new SolidColorBrushAnimation();
     animBorder2_ET_0_AC_0_SB_TL_0.Name = "animBorder2_ET_0_AC_0_SB_TL_0";
     animBorder2_ET_0_AC_0_SB_TL_0.AutoReverse = true;
     animBorder2_ET_0_AC_0_SB_TL_0.Duration = new Duration(new TimeSpan(0, 0, 0, 3, 0));
     animBorder2_ET_0_AC_0_SB_TL_0.RepeatBehavior = RepeatBehavior.Forever;
     animBorder2_ET_0_AC_0_SB_TL_0.From = new ColorW(255, 0, 0, 255);
     animBorder2_ET_0_AC_0_SB_TL_0.To = new ColorW(255, 255, 255, 255);
     CubicEase animBorder2_ET_0_AC_0_SB_TL_0_EA = new CubicEase();
     animBorder2_ET_0_AC_0_SB_TL_0.EasingFunction = animBorder2_ET_0_AC_0_SB_TL_0_EA;
     Storyboard.SetTargetName(animBorder2_ET_0_AC_0_SB_TL_0, "animBorder2");
     Storyboard.SetTargetProperty(animBorder2_ET_0_AC_0_SB_TL_0, Border.BackgroundProperty);
     animBorder2_ET_0_AC_0_SB.Children.Add(animBorder2_ET_0_AC_0_SB_TL_0);
     FloatAnimation animBorder2_ET_0_AC_0_SB_TL_1 = new FloatAnimation();
     animBorder2_ET_0_AC_0_SB_TL_1.Name = "animBorder2_ET_0_AC_0_SB_TL_1";
     animBorder2_ET_0_AC_0_SB_TL_1.AutoReverse = true;
     animBorder2_ET_0_AC_0_SB_TL_1.Duration = new Duration(new TimeSpan(0, 0, 0, 4, 0));
     animBorder2_ET_0_AC_0_SB_TL_1.RepeatBehavior = RepeatBehavior.Forever;
     animBorder2_ET_0_AC_0_SB_TL_1.From = 1F;
     animBorder2_ET_0_AC_0_SB_TL_1.To = 0F;
     Storyboard.SetTargetName(animBorder2_ET_0_AC_0_SB_TL_1, "animBorder2");
     Storyboard.SetTargetProperty(animBorder2_ET_0_AC_0_SB_TL_1, Border.OpacityProperty);
     animBorder2_ET_0_AC_0_SB.Children.Add(animBorder2_ET_0_AC_0_SB_TL_1);
     Grid.SetColumn(animBorder2, 1);
     items.Add(e_44);
     // e_47 element
     TabItem e_47 = new TabItem();
     e_47.Name = "e_47";
     e_47.Header = "Tetris";
     // e_48 element
     Border e_48 = new Border();
     e_47.Content = e_48;
     e_48.Name = "e_48";
     // e_49 element
     Grid e_49 = new Grid();
     e_48.Child = e_49;
     e_49.Name = "e_49";
     e_49.Margin = new Thickness(10F, 10F, 10F, 10F);
     RowDefinition row_e_49_0 = new RowDefinition();
     row_e_49_0.Height = new GridLength(1F, GridUnitType.Auto);
     e_49.RowDefinitions.Add(row_e_49_0);
     RowDefinition row_e_49_1 = new RowDefinition();
     row_e_49_1.Height = new GridLength(420F, GridUnitType.Pixel);
     e_49.RowDefinitions.Add(row_e_49_1);
     ColumnDefinition col_e_49_0 = new ColumnDefinition();
     e_49.ColumnDefinitions.Add(col_e_49_0);
     ColumnDefinition col_e_49_1 = new ColumnDefinition();
     e_49.ColumnDefinitions.Add(col_e_49_1);
     ColumnDefinition col_e_49_2 = new ColumnDefinition();
     e_49.ColumnDefinitions.Add(col_e_49_2);
     // e_50 element
     StackPanel e_50 = new StackPanel();
     e_49.Children.Add(e_50);
     e_50.Name = "e_50";
     e_50.HorizontalAlignment = HorizontalAlignment.Right;
     e_50.Orientation = Orientation.Vertical;
     Grid.SetRow(e_50, 1);
     // e_51 element
     TextBlock e_51 = new TextBlock();
     e_50.Children.Add(e_51);
     e_51.Name = "e_51";
     e_51.Text = "Next";
     // e_52 element
     Border e_52 = new Border();
     e_50.Children.Add(e_52);
     e_52.Name = "e_52";
     e_52.Height = 81F;
     e_52.Width = 81F;
     e_52.BorderBrush = new SolidColorBrush(new ColorW(255, 255, 255, 255));
     e_52.BorderThickness = new Thickness(0F, 0F, 1F, 1F);
     // tetrisNextContainer1 element
     Canvas tetrisNextContainer1 = new Canvas();
     e_52.Child = tetrisNextContainer1;
     tetrisNextContainer1.Name = "tetrisNextContainer1";
     tetrisNextContainer1.Height = 80F;
     tetrisNextContainer1.Width = 80F;
     // e_53 element
     Border e_53 = new Border();
     e_49.Children.Add(e_53);
     e_53.Name = "e_53";
     e_53.Height = 401F;
     e_53.Width = 201F;
     e_53.BorderBrush = new SolidColorBrush(new ColorW(255, 255, 255, 255));
     e_53.BorderThickness = new Thickness(0F, 0F, 1F, 1F);
     Grid.SetColumn(e_53, 1);
     Grid.SetRow(e_53, 1);
     // tetrisContainer1 element
     Canvas tetrisContainer1 = new Canvas();
     e_53.Child = tetrisContainer1;
     tetrisContainer1.Name = "tetrisContainer1";
     tetrisContainer1.Height = 400F;
     tetrisContainer1.Width = 200F;
     tetrisContainer1.HorizontalAlignment = HorizontalAlignment.Left;
     tetrisContainer1.VerticalAlignment = VerticalAlignment.Top;
     // e_54 element
     Grid e_54 = new Grid();
     e_49.Children.Add(e_54);
     e_54.Name = "e_54";
     RowDefinition row_e_54_0 = new RowDefinition();
     row_e_54_0.Height = new GridLength(1F, GridUnitType.Auto);
     e_54.RowDefinitions.Add(row_e_54_0);
     RowDefinition row_e_54_1 = new RowDefinition();
     row_e_54_1.Height = new GridLength(1F, GridUnitType.Auto);
     e_54.RowDefinitions.Add(row_e_54_1);
     ColumnDefinition col_e_54_0 = new ColumnDefinition();
     col_e_54_0.Width = new GridLength(1F, GridUnitType.Auto);
     e_54.ColumnDefinitions.Add(col_e_54_0);
     ColumnDefinition col_e_54_1 = new ColumnDefinition();
     col_e_54_1.Width = new GridLength(1F, GridUnitType.Star);
     e_54.ColumnDefinitions.Add(col_e_54_1);
     ColumnDefinition col_e_54_2 = new ColumnDefinition();
     col_e_54_2.Width = new GridLength(1F, GridUnitType.Auto);
     e_54.ColumnDefinitions.Add(col_e_54_2);
     Grid.SetColumnSpan(e_54, 3);
     Binding binding_e_54_DataContext = new Binding("Tetris");
     e_54.SetBinding(Grid.DataContextProperty, binding_e_54_DataContext);
     // e_55 element
     Button e_55 = new Button();
     e_54.Children.Add(e_55);
     e_55.Name = "e_55";
     e_55.Height = 30F;
     e_55.Content = "Start";
     Grid.SetColumnSpan(e_55, 3);
     Binding binding_e_55_Command = new Binding("StartCommand");
     e_55.SetBinding(Button.CommandProperty, binding_e_55_Command);
     // e_56 element
     Grid e_56 = new Grid();
     e_54.Children.Add(e_56);
     e_56.Name = "e_56";
     RowDefinition row_e_56_0 = new RowDefinition();
     row_e_56_0.Height = new GridLength(1F, GridUnitType.Auto);
     e_56.RowDefinitions.Add(row_e_56_0);
     ColumnDefinition col_e_56_0 = new ColumnDefinition();
     e_56.ColumnDefinitions.Add(col_e_56_0);
     ColumnDefinition col_e_56_1 = new ColumnDefinition();
     col_e_56_1.Width = new GridLength(70F, GridUnitType.Pixel);
     e_56.ColumnDefinitions.Add(col_e_56_1);
     ColumnDefinition col_e_56_2 = new ColumnDefinition();
     e_56.ColumnDefinitions.Add(col_e_56_2);
     Grid.SetColumn(e_56, 1);
     Grid.SetRow(e_56, 1);
     // spPlayer1 element
     StackPanel spPlayer1 = new StackPanel();
     e_56.Children.Add(spPlayer1);
     spPlayer1.Name = "spPlayer1";
     spPlayer1.HorizontalAlignment = HorizontalAlignment.Right;
     spPlayer1.Orientation = Orientation.Vertical;
     // e_57 element
     TextBlock e_57 = new TextBlock();
     spPlayer1.Children.Add(e_57);
     e_57.Name = "e_57";
     Binding binding_e_57_Text = new Binding("Score");
     e_57.SetBinding(TextBlock.TextProperty, binding_e_57_Text);
     // e_58 element
     TextBlock e_58 = new TextBlock();
     spPlayer1.Children.Add(e_58);
     e_58.Name = "e_58";
     Binding binding_e_58_Text = new Binding("Lines");
     e_58.SetBinding(TextBlock.TextProperty, binding_e_58_Text);
     // e_59 element
     TextBlock e_59 = new TextBlock();
     spPlayer1.Children.Add(e_59);
     e_59.Name = "e_59";
     Binding binding_e_59_Text = new Binding("Level");
     e_59.SetBinding(TextBlock.TextProperty, binding_e_59_Text);
     // e_60 element
     StackPanel e_60 = new StackPanel();
     e_56.Children.Add(e_60);
     e_60.Name = "e_60";
     e_60.HorizontalAlignment = HorizontalAlignment.Center;
     e_60.Orientation = Orientation.Vertical;
     Grid.SetColumn(e_60, 1);
     // e_61 element
     TextBlock e_61 = new TextBlock();
     e_60.Children.Add(e_61);
     e_61.Name = "e_61";
     e_61.Text = "SCORE";
     // e_62 element
     TextBlock e_62 = new TextBlock();
     e_60.Children.Add(e_62);
     e_62.Name = "e_62";
     e_62.Text = "LINES";
     // e_63 element
     TextBlock e_63 = new TextBlock();
     e_60.Children.Add(e_63);
     e_63.Name = "e_63";
     e_63.Text = "LEVEL";
     // e_64 element
     StackPanel e_64 = new StackPanel();
     e_56.Children.Add(e_64);
     e_64.Name = "e_64";
     e_64.HorizontalAlignment = HorizontalAlignment.Left;
     e_64.Orientation = Orientation.Horizontal;
     // e_65 element
     TextBlock e_65 = new TextBlock();
     e_64.Children.Add(e_65);
     e_65.Name = "e_65";
     e_65.Text = "Use A,S,D,W for left, down, right, rotate";
     items.Add(e_47);
     return items;
 }
コード例 #40
0
        /// <summary>
        /// Load the image and transform it to a composition brush or a XAML brush (depends of the UIStrategy)
        /// </summary>
        /// <param name="uri">the uri of the image to load</param>
        /// <returns>A <see cref="Task"/> representing the asynchronous operation.</returns>
        private async Task <bool> LoadImageBrush(Uri uri)
        {
            if (DesignTimeHelpers.IsRunningInLegacyDesignerMode)
            {
                return(false);
            }

            var strategy = Strategy;

            if (strategy == UIStrategy.Composition)
            {
                if (_containerVisual == null || uri == null)
                {
                    return(false);
                }
            }
            else
            {
                if (uri == null)
                {
                    return(false);
                }
            }

            await _flag.WaitAsync();

            try
            {
                bool isAnimated = IsAnimated;

                IsAnimated = false;

                if (_isImageSourceLoaded == true)
                {
                    for (int i = 0; i < _compositionChildren.Count; i++)
                    {
                        if (strategy == UIStrategy.PureXaml)
                        {
                            _xamlChildren[i].Fill = null;
                        }
                        else
                        {
                            _compositionChildren[i].Brush = null;
                        }
                    }

                    if (strategy == UIStrategy.Composition)
                    {
                        _brushVisual.Dispose();
                        _brushVisual = null;

                        _uriSurface.Dispose();
                        _uriSurface = null;
                    }
                }

                _isImageSourceLoaded = false;

                if (strategy == UIStrategy.Composition)
                {
                    var compositor     = _containerVisual.Compositor;
                    var surfaceFactory = SurfaceFactory.GetSharedSurfaceFactoryForCompositor(compositor);

                    var surfaceUri = await surfaceFactory.CreateUriSurfaceAsync(uri);

                    _uriSurface  = surfaceUri;
                    _brushVisual = compositor.CreateSurfaceBrush(surfaceUri.Surface);

                    _imageSize = surfaceUri.Size;
                }
                else
                {
                    BitmapImage image = new BitmapImage();

                    var storageFile = await StorageFile.GetFileFromApplicationUriAsync(uri);

                    using (var stream = await storageFile.OpenReadAsync())
                    {
                        image.SetSource(stream);
                    }

                    _brushXaml = new ImageBrush()
                    {
                        ImageSource = image
                    };
                    _imageSize = new Size(image.PixelWidth, image.PixelHeight);
                }

                _isImageSourceLoaded = true;

                RefreshContainerTile();

                RefreshImageSize(_imageSize.Width, _imageSize.Height);

                if (isAnimated == true)
                {
                    IsAnimated = true;
                }
            }
            finally
            {
                _flag.Release();
            }

            ImageLoaded?.Invoke(this, EventArgs.Empty);

            return(true);
        }
コード例 #41
0
ファイル: BasicUI.xaml.cs プロジェクト: Mike-EEE/UI_Examples
 private void InitializeComponent()
 {
     this.FontSize = 13.33333F;
     this.SetResourceReference(SoundManager.SoundsProperty, "Sounds");
     InitializeElementResources(this);
     // e_0 element
     this.e_0 = new Grid();
     this.Content = this.e_0;
     this.e_0.Name = "e_0";
     RowDefinition row_e_0_0 = new RowDefinition();
     row_e_0_0.Height = new GridLength(110F, GridUnitType.Pixel);
     this.e_0.RowDefinitions.Add(row_e_0_0);
     RowDefinition row_e_0_1 = new RowDefinition();
     this.e_0.RowDefinitions.Add(row_e_0_1);
     ColumnDefinition col_e_0_0 = new ColumnDefinition();
     this.e_0.ColumnDefinitions.Add(col_e_0_0);
     ColumnDefinition col_e_0_1 = new ColumnDefinition();
     this.e_0.ColumnDefinitions.Add(col_e_0_1);
     // e_1 element
     this.e_1 = new StackPanel();
     this.e_0.Children.Add(this.e_1);
     this.e_1.Name = "e_1";
     this.e_1.Background = new SolidColorBrush(new ColorW(0, 0, 0, 255));
     Grid.SetColumnSpan(this.e_1, 2);
     // logo element
     this.logo = new Image();
     this.e_1.Children.Add(this.logo);
     this.logo.Name = "logo";
     this.logo.HorizontalAlignment = HorizontalAlignment.Center;
     BitmapImage logo_bm = new BitmapImage();
     logo_bm.TextureAsset = "Images/EmptyKeysLogoTextSmall";
     this.logo.Source = logo_bm;
     this.logo.Stretch = Stretch.None;
     this.logo.SetResourceReference(Image.SourceProperty, "logoEmptyKeys");
     // e_2 element
     this.e_2 = new TextBlock();
     this.e_1.Children.Add(this.e_2);
     this.e_2.Name = "e_2";
     this.e_2.HorizontalAlignment = HorizontalAlignment.Center;
     this.e_2.VerticalAlignment = VerticalAlignment.Center;
     this.e_2.Foreground = new SolidColorBrush(new ColorW(211, 211, 211, 255));
     this.e_2.TextWrapping = TextWrapping.Wrap;
     this.e_2.FontFamily = new FontFamily("Segoe UI");
     this.e_2.FontSize = 20F;
     this.e_2.FontStyle = FontStyle.Bold;
     this.e_2.SetResourceReference(TextBlock.TextProperty, "TitleResource");
     // e_3 element
     this.e_3 = new StackPanel();
     this.e_0.Children.Add(this.e_3);
     this.e_3.Name = "e_3";
     Grid.SetRow(this.e_3, 1);
     // combo element
     this.combo = new ComboBox();
     this.e_3.Children.Add(this.combo);
     this.combo.Name = "combo";
     this.combo.Width = 200F;
     this.combo.Margin = new Thickness(5F, 5F, 5F, 5F);
     Func<UIElement, UIElement> combo_dtFunc = combo_dtMethod;
     this.combo.ItemTemplate = new DataTemplate(combo_dtFunc);
     Binding binding_combo_ItemsSource = new Binding("ComboBoxSource");
     this.combo.SetBinding(ComboBox.ItemsSourceProperty, binding_combo_ItemsSource);
     Binding binding_combo_SelectedIndex = new Binding("SelectedIndex");
     this.combo.SetBinding(ComboBox.SelectedIndexProperty, binding_combo_SelectedIndex);
     // button1 element
     this.button1 = new Button();
     this.e_3.Children.Add(this.button1);
     this.button1.Name = "button1";
     this.button1.Height = 30F;
     this.button1.Width = 200F;
     this.button1.Margin = new Thickness(5F, 5F, 5F, 5F);
     ToolTip tt_button1 = new ToolTip();
     this.button1.ToolTip = tt_button1;
     tt_button1.Content = "Click Me!";
     this.button1.Content = "1";
     this.button1.CommandParameter = "Click Button 1";
     Binding binding_button1_Command = new Binding("ButtonCommand");
     this.button1.SetBinding(Button.CommandProperty, binding_button1_Command);
     // button2 element
     this.button2 = new Button();
     this.e_3.Children.Add(this.button2);
     this.button2.Name = "button2";
     this.button2.Height = 30F;
     this.button2.Margin = new Thickness(5F, 5F, 5F, 5F);
     this.button2.Content = "2";
     this.button2.CommandParameter = "Click Button 2";
     Binding binding_button2_Command = new Binding("ButtonCommand");
     this.button2.SetBinding(Button.CommandProperty, binding_button2_Command);
     this.button2.SetResourceReference(Button.StyleProperty, "buttonStyle");
     // button3 element
     this.button3 = new Button();
     this.e_3.Children.Add(this.button3);
     this.button3.Name = "button3";
     this.button3.Height = 30F;
     this.button3.Width = 200F;
     this.button3.Margin = new Thickness(5F, 5F, 5F, 5F);
     this.button3.FontFamily = new FontFamily("Segoe UI");
     this.button3.FontSize = 20F;
     this.button3.FontStyle = FontStyle.Bold;
     this.button3.Content = "3";
     this.button3.CommandParameter = "Click Button 3";
     Binding binding_button3_Command = new Binding("OpenMessageBox");
     this.button3.SetBinding(Button.CommandProperty, binding_button3_Command);
     this.button3.SetResourceReference(Button.ToolTipProperty, "ToolTipText");
     // buttonResult element
     this.buttonResult = new TextBlock();
     this.e_3.Children.Add(this.buttonResult);
     this.buttonResult.Name = "buttonResult";
     this.buttonResult.HorizontalAlignment = HorizontalAlignment.Center;
     Binding binding_buttonResult_Text = new Binding("ButtonResult");
     this.buttonResult.SetBinding(TextBlock.TextProperty, binding_buttonResult_Text);
     // slider element
     this.slider = new Slider();
     this.e_3.Children.Add(this.slider);
     this.slider.Name = "slider";
     this.slider.Width = 200F;
     this.slider.Minimum = 5F;
     this.slider.Maximum = 20F;
     Binding binding_slider_Value = new Binding("SliderValue");
     this.slider.SetBinding(Slider.ValueProperty, binding_slider_Value);
     // textBox element
     this.textBox = new TextBox();
     this.e_3.Children.Add(this.textBox);
     this.textBox.Name = "textBox";
     this.textBox.Width = 200F;
     this.textBox.Margin = new Thickness(5F, 5F, 5F, 5F);
     Binding binding_textBox_Text = new Binding("TextBoxText");
     this.textBox.SetBinding(TextBox.TextProperty, binding_textBox_Text);
     // checkBox element
     this.checkBox = new CheckBox();
     this.e_3.Children.Add(this.checkBox);
     this.checkBox.Name = "checkBox";
     this.checkBox.Margin = new Thickness(5F, 5F, 5F, 5F);
     this.checkBox.HorizontalAlignment = HorizontalAlignment.Center;
     this.checkBox.Content = "Check Box";
     // e_5 element
     this.e_5 = new TabControl();
     this.e_3.Children.Add(this.e_5);
     this.e_5.Name = "e_5";
     this.e_5.Height = 150F;
     this.e_5.Width = 400F;
     this.e_5.ItemsSource = Get_e_5_Items();
     // e_18 element
     this.e_18 = new ProgressBar();
     this.e_3.Children.Add(this.e_18);
     this.e_18.Name = "e_18";
     this.e_18.Height = 30F;
     this.e_18.Width = 400F;
     this.e_18.Margin = new Thickness(5F, 5F, 5F, 5F);
     this.e_18.Value = 39F;
     // imageButton element
     this.imageButton = new Button();
     this.e_3.Children.Add(this.imageButton);
     this.imageButton.Name = "imageButton";
     this.imageButton.Height = 68F;
     this.imageButton.Width = 57F;
     ImageBrush imageButton_Background = new ImageBrush();
     BitmapImage imageButton_Background_bm = new BitmapImage();
     imageButton_Background_bm.TextureAsset = "Images/SunBurn";
     imageButton_Background.ImageSource = imageButton_Background_bm;
     imageButton_Background.Stretch = Stretch.None;
     this.imageButton.Background = imageButton_Background;
     // e_19 element
     this.e_19 = new StackPanel();
     this.e_0.Children.Add(this.e_19);
     this.e_19.Name = "e_19";
     Grid.SetColumn(this.e_19, 1);
     Grid.SetRow(this.e_19, 1);
     // animButton1 element
     this.animButton1 = new Button();
     this.e_19.Children.Add(this.animButton1);
     this.animButton1.Name = "animButton1";
     this.animButton1.Content = "Mouse Over me!";
     this.animButton1.SetResourceReference(Button.StyleProperty, "buttonAnimStyle");
     // animButton2 element
     this.animButton2 = new Button();
     this.e_19.Children.Add(this.animButton2);
     this.animButton2.Name = "animButton2";
     this.animButton2.Content = "Mouse Over me!";
     this.animButton2.SetResourceReference(Button.StyleProperty, "buttonAnimStyle");
     // animButton3 element
     this.animButton3 = new Button();
     this.e_19.Children.Add(this.animButton3);
     this.animButton3.Name = "animButton3";
     this.animButton3.Content = "Mouse Over me!";
     this.animButton3.SetResourceReference(Button.StyleProperty, "buttonAnimStyle");
     // animButton4 element
     this.animButton4 = new Button();
     this.e_19.Children.Add(this.animButton4);
     this.animButton4.Name = "animButton4";
     this.animButton4.Content = "Mouse Over me!";
     this.animButton4.SetResourceReference(Button.StyleProperty, "buttonAnimStyle");
     // e_20 element
     this.e_20 = new Grid();
     this.e_19.Children.Add(this.e_20);
     this.e_20.Name = "e_20";
     // animBorder1 element
     this.animBorder1 = new Border();
     this.e_20.Children.Add(this.animBorder1);
     this.animBorder1.Name = "animBorder1";
     this.animBorder1.Height = 100F;
     this.animBorder1.Width = 200F;
     this.animBorder1.Margin = new Thickness(0F, 10F, 0F, 10F);
     EventTrigger animBorder1_ET_0 = new EventTrigger(Border.LoadedEvent, this.animBorder1);
     animBorder1.Triggers.Add(animBorder1_ET_0);
     BeginStoryboard animBorder1_ET_0_AC_0 = new BeginStoryboard();
     animBorder1_ET_0_AC_0.Name = "animBorder1_ET_0_AC_0";
     animBorder1_ET_0.AddAction(animBorder1_ET_0_AC_0);
     Storyboard animBorder1_ET_0_AC_0_SB = new Storyboard();
     animBorder1_ET_0_AC_0.Storyboard = animBorder1_ET_0_AC_0_SB;
     animBorder1_ET_0_AC_0_SB.Name = "animBorder1_ET_0_AC_0_SB";
     SolidColorBrushAnimation animBorder1_ET_0_AC_0_SB_TL_0 = new SolidColorBrushAnimation();
     animBorder1_ET_0_AC_0_SB_TL_0.Name = "animBorder1_ET_0_AC_0_SB_TL_0";
     animBorder1_ET_0_AC_0_SB_TL_0.AutoReverse = true;
     animBorder1_ET_0_AC_0_SB_TL_0.Duration = new Duration(new TimeSpan(0, 0, 0, 5, 0));
     animBorder1_ET_0_AC_0_SB_TL_0.RepeatBehavior = RepeatBehavior.Forever;
     animBorder1_ET_0_AC_0_SB_TL_0.From = new ColorW(255, 255, 0, 255);
     animBorder1_ET_0_AC_0_SB_TL_0.To = new ColorW(0, 0, 255, 255);
     ExponentialEase animBorder1_ET_0_AC_0_SB_TL_0_EA = new ExponentialEase();
     animBorder1_ET_0_AC_0_SB_TL_0.EasingFunction = animBorder1_ET_0_AC_0_SB_TL_0_EA;
     Storyboard.SetTargetName(animBorder1_ET_0_AC_0_SB_TL_0, "animBorder1");
     Storyboard.SetTargetProperty(animBorder1_ET_0_AC_0_SB_TL_0, Border.BackgroundProperty);
     animBorder1_ET_0_AC_0_SB.Children.Add(animBorder1_ET_0_AC_0_SB_TL_0);
     // animBorder2 element
     this.animBorder2 = new Border();
     this.e_20.Children.Add(this.animBorder2);
     this.animBorder2.Name = "animBorder2";
     this.animBorder2.Height = 50F;
     this.animBorder2.Width = 100F;
     this.animBorder2.Margin = new Thickness(50F, 35F, 50F, 35F);
     EventTrigger animBorder2_ET_0 = new EventTrigger(Border.LoadedEvent, this.animBorder2);
     animBorder2.Triggers.Add(animBorder2_ET_0);
     BeginStoryboard animBorder2_ET_0_AC_0 = new BeginStoryboard();
     animBorder2_ET_0_AC_0.Name = "animBorder2_ET_0_AC_0";
     animBorder2_ET_0.AddAction(animBorder2_ET_0_AC_0);
     Storyboard animBorder2_ET_0_AC_0_SB = new Storyboard();
     animBorder2_ET_0_AC_0.Storyboard = animBorder2_ET_0_AC_0_SB;
     animBorder2_ET_0_AC_0_SB.Name = "animBorder2_ET_0_AC_0_SB";
     SolidColorBrushAnimation animBorder2_ET_0_AC_0_SB_TL_0 = new SolidColorBrushAnimation();
     animBorder2_ET_0_AC_0_SB_TL_0.Name = "animBorder2_ET_0_AC_0_SB_TL_0";
     animBorder2_ET_0_AC_0_SB_TL_0.AutoReverse = true;
     animBorder2_ET_0_AC_0_SB_TL_0.Duration = new Duration(new TimeSpan(0, 0, 0, 3, 0));
     animBorder2_ET_0_AC_0_SB_TL_0.RepeatBehavior = RepeatBehavior.Forever;
     animBorder2_ET_0_AC_0_SB_TL_0.From = new ColorW(255, 0, 0, 255);
     animBorder2_ET_0_AC_0_SB_TL_0.To = new ColorW(255, 255, 255, 255);
     CubicEase animBorder2_ET_0_AC_0_SB_TL_0_EA = new CubicEase();
     animBorder2_ET_0_AC_0_SB_TL_0.EasingFunction = animBorder2_ET_0_AC_0_SB_TL_0_EA;
     Storyboard.SetTargetName(animBorder2_ET_0_AC_0_SB_TL_0, "animBorder2");
     Storyboard.SetTargetProperty(animBorder2_ET_0_AC_0_SB_TL_0, Border.BackgroundProperty);
     animBorder2_ET_0_AC_0_SB.Children.Add(animBorder2_ET_0_AC_0_SB_TL_0);
     FloatAnimation animBorder2_ET_0_AC_0_SB_TL_1 = new FloatAnimation();
     animBorder2_ET_0_AC_0_SB_TL_1.Name = "animBorder2_ET_0_AC_0_SB_TL_1";
     animBorder2_ET_0_AC_0_SB_TL_1.AutoReverse = true;
     animBorder2_ET_0_AC_0_SB_TL_1.Duration = new Duration(new TimeSpan(0, 0, 0, 4, 0));
     animBorder2_ET_0_AC_0_SB_TL_1.RepeatBehavior = RepeatBehavior.Forever;
     animBorder2_ET_0_AC_0_SB_TL_1.From = 1F;
     animBorder2_ET_0_AC_0_SB_TL_1.To = 0F;
     Storyboard.SetTargetName(animBorder2_ET_0_AC_0_SB_TL_1, "animBorder2");
     Storyboard.SetTargetProperty(animBorder2_ET_0_AC_0_SB_TL_1, Border.OpacityProperty);
     animBorder2_ET_0_AC_0_SB.Children.Add(animBorder2_ET_0_AC_0_SB_TL_1);
     ImageManager.Instance.AddImage("Images/EmptyKeysLogoTextSmall");
     ImageManager.Instance.AddImage("Images/SunBurn");
     FontManager.Instance.AddFont("Segoe UI", 13.33333F, FontStyle.Regular, "Segoe_UI_10_Regular");
     FontManager.Instance.AddFont("Segoe UI", 20F, FontStyle.Bold, "Segoe_UI_15_Bold");
     FontManager.Instance.AddFont("Segoe UI", 12F, FontStyle.Regular, "Segoe_UI_9_Regular");
 }
コード例 #42
0
ファイル: Message.cs プロジェクト: RobertBrz/ChatApp
        public StackPanel SetMessage(bool mymessage, string message)
        {
            Ellipse ell = new Ellipse();

            ell.Height            = 48;
            ell.Width             = 48;
            ell.VerticalAlignment = VerticalAlignment.Bottom;
            ImageBrush ib = new ImageBrush();

            ib.ImageSource = new BitmapImage(new Uri("ms-appx:///Assets/bezt.png"));
            ell.Fill       = ib;

            Polygon         polygon = new Polygon();
            PointCollection points  = new PointCollection();

            //points.Add(new Windows.Foundation.Point(0, 0));
            //points.Add(new Windows.Foundation.Point(15, 0));
            //points.Add(new Windows.Foundation.Point(15, 15));
            points.Add(new Windows.Foundation.Point(0, 0));
            points.Add(new Windows.Foundation.Point(0, 0));
            points.Add(new Windows.Foundation.Point(0, 0));
            polygon.Points = points;
            polygon.Fill   = new SolidColorBrush(Windows.UI.Colors.LightGray);
            //Thickness t2 = new Thickness(0, 10, 0, 0);
            Thickness t2 = new Thickness(0, 0, 0, 0);

            polygon.Margin = t2;

            TextBlock tb = new TextBlock();

            tb.TextWrapping = TextWrapping.WrapWholeWords;
            tb.Width        = 100;
            tb.Height       = 50;
            tb.Text         = message;

            Border       b = new Border();
            CornerRadius c = new CornerRadius(3, 3, 3, 3);

            b.CornerRadius = c;
            Thickness t = new Thickness(6, 6, 6, 6);

            b.Padding           = t;
            b.VerticalAlignment = VerticalAlignment.Top;
            b.Background        = new SolidColorBrush(Windows.UI.Colors.LightGray);
            b.Child             = tb;

            StackPanel sp = new StackPanel();

            sp.Orientation = Orientation.Horizontal;
            sp.Padding     = t;
            switch (mymessage)
            {
            case true:
                sp.HorizontalAlignment = HorizontalAlignment.Right;
                sp.Children.Add(polygon);
                sp.Children.Add(b);
                sp.Children.Add(ell);
                break;

            case false:
                sp.HorizontalAlignment = HorizontalAlignment.Left;
                sp.Children.Add(ell);
                sp.Children.Add(polygon);
                sp.Children.Add(b);
                break;
            }
            return(sp);
        }
コード例 #43
0
ファイル: MenuBar.cs プロジェクト: shuoniu89/CoLocatedCard
        /// <summary>
        /// Load the buttons and other ui elements on the menu
        /// </summary>
        /// <param name="info"></param>
        private void LoadUI(MenuBarInfo info)
        {
            //Initialize the button to show the keyboard
            createSortingBoxButton                          = new Button();
            createSortingBoxButton.Content                  = "Create a Box";
            createSortingBoxButton.Click                   += KeyboardButton_Click;
            createSortingBoxButton.PointerEntered          += PointerDown;
            createSortingBoxButton.PointerPressed          += PointerDown;
            createSortingBoxButton.PointerMoved            += PointerMove;
            createSortingBoxButton.PointerExited           += PointerUp;
            createSortingBoxButton.PointerReleased         += PointerUp;
            createSortingBoxButton.IsTextScaleFactorEnabled = false;
            UIHelper.InitializeUI(info.KeyboardButtonInfo.Position, 0, 1, info.KeyboardButtonInfo.Size, createSortingBoxButton);
            //Initialize the text block
            textbox = new TextBox();
            textbox.AcceptsReturn = true;
            UIHelper.InitializeUI(info.InputTextBoxInfo.Position, 0, 1, info.InputTextBoxInfo.Size, textbox);
            textbox.Visibility   = Visibility.Collapsed;
            textbox.TextChanged += Textbox_TextChanged;
            textbox.IsEnabled    = false;
            //Initialize the keyboard to create the sorting box
            virtualKeyboard = new OnScreenKeyBoard();
            virtualKeyboard.InitialLayout    = KeyboardLayouts.English;
            virtualKeyboard.Visibility       = Visibility.Collapsed;
            virtualKeyboard.PointerEntered  += PointerDown;
            virtualKeyboard.PointerPressed  += PointerDown;
            virtualKeyboard.PointerMoved    += PointerMove;
            virtualKeyboard.PointerExited   += PointerUp;
            virtualKeyboard.PointerReleased += PointerUp;
            UIHelper.InitializeUI(info.KeyboardInfo.Position, 0, 1, info.KeyboardInfo.Size, virtualKeyboard);
            //Initialize the Deletebutton
            deleteButton                          = new Button();
            deleteButton.Content                  = "Delete";
            deleteButton.Click                   += DeleteButton_Click;
            deleteButton.PointerEntered          += PointerDown;
            deleteButton.PointerPressed          += PointerDown;
            deleteButton.PointerMoved            += PointerMove;
            deleteButton.PointerExited           += PointerUp;
            deleteButton.PointerReleased         += PointerUp;
            deleteButton.IsTextScaleFactorEnabled = false;
            UIHelper.InitializeUI(info.DeleteButtonInfo.Position, 0, 1, info.DeleteButtonInfo.Size, deleteButton);
            //Initialize the notificationBlock + Grid
            grid = new Grid();
            notificationBlock              = new TextBlock();
            grid.Background                = new SolidColorBrush(Colors.White);
            notificationBlock.Text         = "The Sorting Box will be deleted when it's dragged into this.";
            notificationBlock.TextWrapping = TextWrapping.Wrap;
            Point position = new Point(250, -60);

            UIHelper.InitializeUI(position, 0, 1, info.DeleteButtonInfo.Size, grid);
            grid.Children.Add(notificationBlock);
            grid.Visibility = Visibility.Collapsed;
            //Initialize the menubar
            ImageBrush brush = new ImageBrush();

            brush.ImageSource = new BitmapImage(new Uri("ms-appx:///Assets/menu_bg.png"));
            this.Background   = brush;
            this.Children.Add(createSortingBoxButton);
            this.Children.Add(virtualKeyboard);
            this.Children.Add(textbox);
            this.Children.Add(deleteButton);
            this.Children.Add(grid);
        }
コード例 #44
0
        /// <summary>
        /// Read a material.
        /// </summary>
        /// <param name="reader">
        /// The reader.
        /// </param>
        /// <param name="msize">
        /// The size.
        /// </param>
        private void ReadMaterial(BinaryReader reader, int msize)
        {
            int    total = 6;
            string name  = null;

            var    luminance = Colors.Transparent;
            var    diffuse   = Colors.Transparent;
            var    specular  = Colors.Transparent;
            var    shininess = Colors.Transparent;
            string texture   = null;

            while (total < msize)
            {
                ChunkID id   = this.ReadChunkId(reader);
                int     size = this.ReadChunkSize(reader);

                // Debug.WriteLine(id);
                total += size;

                switch (id)
                {
                case ChunkID.MAT_NAME01:
                    name = this.ReadString(reader);

                    // name = ReadString(size - 6);
                    break;

                case ChunkID.MAT_LUMINANCE:
                    luminance = this.ReadColor(reader);
                    break;

                case ChunkID.MAT_DIFFUSE:
                    diffuse = this.ReadColor(reader);
                    break;

                case ChunkID.MAT_SPECULAR:
                    specular = this.ReadColor(reader);
                    break;

                case ChunkID.MAT_SHININESS:
                    byte[] bytes = this.ReadData(reader, size - 6);

                    // shininess = ReadColor(r, size);
                    break;

                case ChunkID.MAT_MAP:
                    texture = this.ReadMatMap(reader, size - 6);
                    break;

                case ChunkID.MAT_MAPFILE:
                    this.ReadData(reader, size - 6);
                    break;

                default:
                    this.ReadData(reader, size - 6);
                    break;
                }
            }

            int specularPower = 100;
            var mg            = new MaterialGroup();

            // mg.Children.Add(new DiffuseMaterial(new SolidColorBrush(luminance)));
            if (texture != null)
            {
                string ext = Path.GetExtension(texture);
                if (ext != null)
                {
                    ext = ext.ToLower();
                }

                // TGA not supported - convert textures to .png!
                if (ext == ".tga")
                {
                    texture = Path.ChangeExtension(texture, ".png");
                }

                var    actualTexturePath = this.TexturePath ?? string.Empty;
                string path = Path.Combine(actualTexturePath, texture);
                if (File.Exists(path))
                {
                    var img          = new BitmapImage(new Uri(path, UriKind.Relative));
                    var textureBrush = new ImageBrush(img)
                    {
                        ViewportUnits = BrushMappingMode.Absolute, TileMode = TileMode.Tile
                    };
                    mg.Children.Add(new DiffuseMaterial(textureBrush));
                }
                else
                {
                    Debug.WriteLine(string.Format("Texture not found: {0}", Path.GetFullPath(path)));
                    mg.Children.Add(new DiffuseMaterial(new SolidColorBrush(diffuse)));
                }
            }
            else
            {
                mg.Children.Add(new DiffuseMaterial(new SolidColorBrush(diffuse)));
            }

            mg.Children.Add(new SpecularMaterial(new SolidColorBrush(specular), specularPower));

            if (name != null)
            {
                this.materials.Add(name, mg);
            }
        }