示例#1
0
        /// <summary>
        /// Molto incasinato, in poche parole mi permette di interagire con la GUI dal codice
        /// Inoltre cambio icona all'app
        /// </summary>
        private void InitializeComponent()
        {
            AvaloniaXamlLoader.Load(this);


            tab         = this.FindControl <TabControl>("tabControl1");
            nome        = this.FindControl <TextBox>("NameTxt");
            token       = this.FindControl <TextBox>("TokenTxt");
            status      = this.FindControl <TextBlock>("StatusTextBlock");
            configBtn   = this.FindControl <Button>("ConfigBtn");
            download    = this.FindControl <Button>("DownloadBtn");
            bar         = this.FindControl <ProgressBar>("DownloadPB");
            modpackCBox = this.FindControl <ComboBox>("ModpackCBox");
            modpackCBox.SelectionChanged += ModpackCBox_SelectionChanged;
            modList         = this.FindControl <TextBox>("Modlist");
            link            = this.FindControl <TextBlock>("LinkTextBlock");
            link.Foreground = Brushes.Blue;
            link.Tapped    += Link_Tapped;
            image           = this.FindControl <Avalonia.Controls.Image>("ModpackIcon");
            image.Tapped   += Image_Tapped;
            ForgeU          = this.FindControl <TextBox>("ForgeTxtU");
            ModU            = this.FindControl <TextBox>("ModsTxtU");
            NomeU           = this.FindControl <TextBox>("NameTxtU");
            DropboxU        = this.FindControl <TextBox>("TokenTxtU");
            SelectForge     = this.FindControl <Button>("ForgeBtn");
            SelectMods      = this.FindControl <Button>("ModsBtn");
            Upload          = this.FindControl <Button>("UploadBtn");
            UploadPB        = this.FindControl <ProgressBar>("UploadPB");
            statusU         = this.FindControl <TextBlock>("StatusTextBlockU");
            var        assets = AvaloniaLocator.Current.GetService <IAssetLoader>();
            Bitmap     bitmap = new Bitmap(assets.Open(new Uri("resm:ModpackUpdater4.AppIcon.png")));
            WindowIcon icon   = new WindowIcon(bitmap);

            this.Icon = icon;
        }
示例#2
0
        private void InitializeComponent()
        {
            clockTimer = new DispatcherTimer
            {
                Interval = TimeSpan.FromMilliseconds(1000)
            };
            clockTimer.Tick += UpdateClock;

            weatherTimer = new DispatcherTimer
            {
                Interval = TimeSpan.FromSeconds(5)
            };
            weatherTimer.Tick += UpdateWeather;

            AvaloniaXamlLoader.Load(this);

            dateText = this.FindControl <TextBlock>("MainDateText");
            dateWeek = this.FindControl <TextBlock>("MainDateWeek");

            clockLayout = this.FindControl <StackPanel>("MainClockLayout");
            clockHour   = this.FindControl <TextBlock>("MainClockHour");
            clockMin    = this.FindControl <TextBlock>("MainClockMin");
            clockPoint  = this.FindControl <Ellipse>("MainClockPoint");

            weatherLayout = this.FindControl <StackPanel>("MainWeatherLayout");
            weatherIcon   = this.FindControl <Avalonia.Controls.Image>("WeatherIcon");
            weatherTemp   = this.FindControl <TextBlock>("WeatherTemperature");
        }
示例#3
0
        public BudsPopup()
        {
            AvaloniaXamlLoader.Load(this);
            this.AttachDevTools();

            _outerBorder = this.FindControl <Border>("OuterBorder");

            _header    = this.FindControl <Label>("Header");
            _batteryL  = this.FindControl <Label>("BatteryL");
            _batteryR  = this.FindControl <Label>("BatteryR");
            _batteryC  = this.FindControl <Label>("BatteryC");
            _caseLabel = this.FindControl <Label>("CaseLabel");

            _iconLeft  = this.FindControl <Image>("ImageLeft");
            _iconRight = this.FindControl <Image>("ImageRight");

            var cachedStatus = DeviceMessageCache.Instance.BasicStatusUpdate;

            UpdateContent(cachedStatus?.BatteryL ?? 0, cachedStatus?.BatteryR ?? 0, cachedStatus?.BatteryCase ?? 0);

            SPPMessageHandler.Instance.BaseUpdate += InstanceOnBaseUpdate;
            _timer.Elapsed += (sender, args) =>
            {
                Dispatcher.UIThread.Post(Hide, DispatcherPriority.Render);
            };
        }
示例#4
0
        public CSharpOrNotWindow()
        {
            this.InitializeComponent();
#if DEBUG
            this.AttachDevTools();
#endif
            this.codeDisplay = this.Get <TextBox>("CodeDisplay");
            this.codeDisplay.PropertyChanged += this.CodeDisplayOnPropertyChanged;

            this.codeWindow     = this.Get <TextBlock>("CodeWindow");
            this.language       = this.Get <TextBlock>("Language");
            this.languageBox    = this.Get <ContentControl>("LanguageBox");
            this.codeImage      = this.Get <Image>("CodeImage");
            this.openFileButton = this.Get <Button>("OpenFileButton");

            BitmapTools.SetGreyscalePalette(this.renderTarget);
            BitmapTools.SetGreyscalePalette(this.output);

            TensorFlowSetup.Instance.EnsureInitialized();

            this.model = CreateModel(classCount: IncludeExtensions.Length);
            this.model.build(new TensorShape(null, CSharpOrNot.Height, CSharpOrNot.Width, 1));

            this.LoadWeights();
        }
        /// <summary>
        /// Scales the foreground image by X percent
        /// </summary>
        /// <param name="scale">Expects a value between [0.0,1.0]. Beyond 1.0 will scale the image larger.</param>
        private static Image <Rgba32> ScaleImage(Image <Rgba32> sourceImage, double scale)
        {
            var canvasWidth  = UpscaledCanvasWidth;
            var canvasHeight = UpscaledCanvasHeight;
            var resizeWidth  = (int)Math.Max(canvasWidth * scale, 1.0);
            var resizeHeight = (int)Math.Max(canvasHeight * scale, 1.0);

            return(IconResizer.ResizeImage(sourceImage, resizeWidth, resizeHeight, canvasWidth, canvasHeight));
        }
示例#6
0
        static public Point TransformElementPointToImagePoint(this Avalonia.Controls.Image item, System.Windows.Point point)
        {
            double x_factor = item.Source.PixelSize.Width / item.Width;
            double y_factor = item.Source.PixelSize.Height / item.Height;

            return(new Point(
                       (float)(point.X * x_factor),
                       (float)(point.Y * y_factor)
                       ));
        }
        /// <summary>
        /// Converts a <see cref="SixLabors.ImageSharp.Image"/>
        /// to a <see cref="Avalonia.Media.Imaging.Bitmap"/>
        /// Intended for displaying images
        /// </summary>
        /// <param name="sourceImage"></param>
        /// <returns></returns>
        private static Bitmap ConvertToAvaloniaBitmap(Image <Rgba32> sourceImage)
        {
            using (var resizedImageStream = new MemoryStream())
            {
                sourceImage.SaveAsPng(resizedImageStream);
                resizedImageStream.Seek(0, SeekOrigin.Begin);

                return(new Bitmap(resizedImageStream));
            }
        }
示例#8
0
 private void InitializeComponent()
 {
     AvaloniaXamlLoader.Load(this);
     mainImage            = this.FindControl <AvaloniaImage>("MainImage");
     imageBorder          = this.FindControl <Border>("ImageBorder");
     imageSizeText        = this.FindControl <TextBlock>("ImageSize");
     statusText           = this.FindControl <TextBlock>("Status");
     undoButton           = this.FindControl <Button>("UndoButton");
     redoButton           = this.FindControl <Button>("RedoButton");
     undoButton.IsEnabled = false;
     redoButton.IsEnabled = false;
 }
示例#9
0
        // ReSharper restore InconsistentNaming

        private void InitializeComponent()
        {
            AvaloniaXamlLoader.Load(this);

            pictureBox1       = this.FindControl <Image>("pictureBox1");
            pictureBox2       = this.FindControl <Image>("pictureBox2");
            pictureBox3       = this.FindControl <Image>("pictureBox3");
            label1            = this.FindControl <TextBlock>("label1");
            richTextBox1      = this.FindControl <TextBlock>("richTextBox1");
            pb_status_loading = this.FindControl <Image>("pb_status_loading");
            pb_status_error   = this.FindControl <Image>("pb_status_error");
        }
 private void UpdateImages(string directory)
 {
     imgFiles.Clear();
     Images.Clear();
     foreach (var file in Directory.GetFiles(directory).Where(a => a.Split("/").Last()[0] != '.').ToArray())
     {
         Console.WriteLine(file);
         var tmp = new Avalonia.Controls.Image();
         tmp.Source = new Avalonia.Media.Imaging.Bitmap(file);
         Images.Add(tmp);
         imgFiles.Add(file);
     }
     sourcePath.OnNext(imgFiles);
 }
        /// <summary>
        /// Sets the image from a file given the file path
        /// </summary>
        /// <param name="filePath"></param>
        public void SetImage(string filePath)
        {
            if (_workingImage != null)
            {
                _workingImage.Dispose();
            }

            _workingImagePath = filePath;

            var isSvg = System.IO.Path.GetExtension(filePath).ToLower() == ".svg";

            _workingImage = isSvg ?
                            ConvertSvgToImage(filePath) :
                            SixLabors.ImageSharp.Image.Load <Rgba32>(filePath);

            DisplayImage();
        }
        void UpdateContent()
        {
            var text         = Element.Text;
            var elementImage = Element.Image;

            // No image, just the text
            if (elementImage == null)
            {
                Control.Content = text;
                return;
            }

            var image = new AImage
            {
                //Source = new BitmapImage(new Uri("/" + elementImage.File, UriKind.Relative)),
                Width               = 30,
                Height              = 30,
                VerticalAlignment   = VerticalAlignment.Center,
                HorizontalAlignment = HorizontalAlignment.Center
            };

            // No text, just the image
            if (string.IsNullOrEmpty(text))
            {
                Control.Content = image;
                return;
            }

            // Both image and text, so we need to build a container for them
            var layout    = Element.ContentLayout;
            var container = new StackPanel();
            var textBlock = new TextBlock
            {
                Text = text,
                VerticalAlignment   = VerticalAlignment.Center,
                HorizontalAlignment = HorizontalAlignment.Center
            };

            var spacing = layout.Spacing;

            container.HorizontalAlignment = HorizontalAlignment.Center;
            container.VerticalAlignment   = VerticalAlignment.Center;

            switch (layout.Position)
            {
            case Button.ButtonContentLayout.ImagePosition.Top:
                container.Orientation = Orientation.Vertical;
                image.Margin          = new AThickness(0, 0, 0, spacing);
                break;

            case Button.ButtonContentLayout.ImagePosition.Bottom:
                container.Orientation = Orientation.Vertical;
                image.Margin          = new AThickness(0, spacing, 0, 0);
                break;

            case Button.ButtonContentLayout.ImagePosition.Right:
                container.Orientation = Orientation.Horizontal;
                image.Margin          = new AThickness(spacing, 0, 0, 0);
                break;

            default:
                // Defaults to image on the left
                container.Orientation = Orientation.Horizontal;
                image.Margin          = new AThickness(0, 0, spacing, 0);
                break;
            }

            container.Children.Add(image);
            container.Children.Add(textBlock);

            Control.Content = container;
        }
        async void UpdateContent()
        {
            var text         = Element.Text;
            var elementImage = await Element.ImageSource.ToNativeImageSourceAsync();

            // No image, just the text
            if (elementImage == null)
            {
                Control.Content = text;
                Element?.InvalidateMeasureNonVirtual(InvalidationTrigger.RendererReady);
                return;
            }

            var image = new AImage
            {
                Source              = elementImage,
                Width               = 30,
                Height              = 30,
                VerticalAlignment   = VerticalAlignment.Center,
                HorizontalAlignment = HorizontalAlignment.Center
            };

            // No text, just the image
            if (string.IsNullOrEmpty(text))
            {
                Control.Content = image;
                Element?.InvalidateMeasureNonVirtual(InvalidationTrigger.RendererReady);
                return;
            }

            // Both image and text, so we need to build a container for them
            var layout    = Element.ContentLayout;
            var container = new StackPanel();
            var textBlock = new TextBlock
            {
                Text = text,
                VerticalAlignment   = VerticalAlignment.Center,
                HorizontalAlignment = HorizontalAlignment.Center
            };

            var spacing = layout.Spacing;

            container.HorizontalAlignment = HorizontalAlignment.Center;
            container.VerticalAlignment   = VerticalAlignment.Center;

            switch (layout.Position)
            {
            case Button.ButtonContentLayout.ImagePosition.Top:
                container.Orientation = Orientation.Vertical;
                image.Margin          = new AThickness(0, 0, 0, spacing);
                break;

            case Button.ButtonContentLayout.ImagePosition.Bottom:
                container.Orientation = Orientation.Vertical;
                image.Margin          = new AThickness(0, spacing, 0, 0);
                break;

            case Button.ButtonContentLayout.ImagePosition.Right:
                container.Orientation = Orientation.Horizontal;
                image.Margin          = new AThickness(spacing, 0, 0, 0);
                break;

            default:
                // Defaults to image on the left
                container.Orientation = Orientation.Horizontal;
                image.Margin          = new AThickness(0, 0, spacing, 0);
                break;
            }

            container.Children.Add(image);
            container.Children.Add(textBlock);

            Control.Content = container;
            Element?.InvalidateMeasureNonVirtual(InvalidationTrigger.RendererReady);
        }
 /// <summary>
 /// Inverts the colors of the image
 /// </summary>
 /// <param name="sourceImage"></param>
 /// <returns></returns>
 private static Image <Rgba32> InvertImage(Image <Rgba32> sourceImage)
 {
     return(IconResizer.InvertImage(sourceImage));
 }