示例#1
0
        protected override void OnCreate(Bundle bundle)
        {
            CrushReportEmail = Resources.GetString(Resource.String.CrushReportEmail);
            base.OnCreate(bundle);

            SetContentView(Resource.Layout.Main);
            InitButtonBar();

            _adView = FindViewById<AdView>(Resource.Id.adView);
            InitAdView();

            _horizontalScrollView = FindViewById<HorizontalScrollView>(Resource.Id.horizontalScrollView);
            _formulaTextView = FindViewById<TextView>(Resource.Id.formulaTextView);
            _renderTimeTextView = FindViewById<TextView>(Resource.Id.renderTimeTextView);
            _imageView = FindViewById<ImageView>(Resource.Id.imageView);
            _coresCountTextView = FindViewById<TextView>(Resource.Id.coresCountTextView);
            TextView sizeTextView = FindViewById<TextView>(Resource.Id.sizeTextView);
            TextView launcherTextView = FindViewById<TextView>(Resource.Id.launcherTextView);
            _technicalInfoLayout = FindViewById<LinearLayout>(Resource.Id.technicalInfoLayout);

            launcherTextView.Text = "launcher: " + IntentShortcuts.GetLauncherPackageName(this);
            WallpaperManager wallpaperManager = WallpaperManager.GetInstance(this);
            Point wallpaperSize = wallpaperManager.GetDesiredSize(WindowManager.DefaultDisplay, Resources.Configuration);
            Size imageSize = new Size(wallpaperSize.X, wallpaperSize.Y);
            sizeTextView.Text = "image size: " + imageSize.Width + "x" + imageSize.Height;
            _workflow = new FormulaRenderWorkflow(new FormulaRenderArgumentsGenerationParams(), imageSize, s => new AndroidFormulaBitmap(s));
            
            if (_workflow.FormulaRenderArguments != null)
                _formulaTextView.Text = _workflow.FormulaRenderArguments.ToString();

            _wallpaperFileManager = new AndroidWallpaperFileManager(this);

            AdjustButtons();
            ClearImage();
        }
        public WallpaperGeneratorApplication()
        {
            _workflow = new FormulaRenderWorkflow(new FormulaRenderArgumentsGenerationParams { PredefinedFormulaRenderingArgumentsEnabled = false },
                new Size(700, 700), s => new WindowsFormulaBitmap(s));
            _wallpaperFileManager = new WindowsWallpaperFileManager();
            _mainWindow = new MainWindow { WindowState = WindowState.Maximized };
            _mainWindow.ControlPanel.LoadState(_workflow.GenerationParams);
            _mainWindow.ControlPanel.ImageSizeControl.Size = _workflow.ImageSize;
            
            _mainWindow.ControlPanel.GenerateFormulaButton.Click += async (s, a) =>
            {
                if (_mainWindow.ControlPanel.RandomizeCheckBox.IsChecked.HasValue && _mainWindow.ControlPanel.RandomizeCheckBox.IsChecked.Value)
                {
                    FormulaRenderArgumentsGenerationParams randomParams = RandomizeFormulaRenderArgumentsGenerationParams(new FormulaRenderArgumentsGenerationParams());
                    _mainWindow.ControlPanel.LoadState(randomParams);
                }
                _workflow.GenerationParams = UserInputFormulaRenderArgumentsGenerationParams;
                FormulaRenderArguments formulaRenderArguments = _workflow.GenerateFormulaRenderArguments();
                _mainWindow.FormulaTexBox.Text = formulaRenderArguments.ToString();
                await DrawImageAsync();
            };

            _mainWindow.ControlPanel.TransformButton.Click += async (s, a) =>
            {
                _workflow.GenerationParams = UserInputFormulaRenderArgumentsGenerationParams;
                FormulaRenderArguments formulaRenderArguments = _workflow.TransformRanges();
                _mainWindow.FormulaTexBox.Text = formulaRenderArguments.ToString();
                await DrawImageAsync();
            };

            _mainWindow.ControlPanel.ChangeColorButton.Click += async (s, a) =>
            {
                _workflow.GenerationParams = UserInputFormulaRenderArgumentsGenerationParams;
                FormulaRenderArguments formulaRenderArguments = _workflow.ChangeColors();
                _mainWindow.FormulaTexBox.Text = formulaRenderArguments.ToString();
                await DrawImageAsync();
            };

            _mainWindow.ControlPanel.RenderFormulaButton.Click += async (s, a) =>
            {
                _workflow.FormulaRenderArguments = UserInputFormulaRenderArguments;
                _workflow.ImageSize = _mainWindow.ControlPanel.ImageSizeControl.Size;
                await DrawImageAsync();
            };

            _mainWindow.ControlPanel.StartStopSmoothAnimationButton.Click += (s, a) => StartStopAnimation();

            _mainWindow.ControlPanel.SaveButton.Click += (s, a) => SaveFormulaImage();
        }