Пример #1
0
        public CloudSettingsForm(CloudSettings settings)
        {
            Controls.Add(new Button
            {
                Text         = "OK",
                DialogResult = DialogResult.OK,
                Dock         = DockStyle.Bottom
            });

            var layout = new TableLayoutPanel();

            var layouterBox = CreateTypeComboBox <ICloudLayouter>();

            layouterBox.Location = new Point(40, 40);
            Controls.Add(layouterBox);
            layouterBox.SelectedValueChanged                       += (s, a) =>
                                                           settings = settings.WithLayouter(layouterBox.SelectedText);

            var counterBox = CreateTypeComboBox <IWordsCounter>();

            counterBox.Location = new Point(40, 80); //TODO should use layouters
            Controls.Add(counterBox);
            counterBox.SelectedValueChanged                       += (s, a) =>
                                                          settings = settings.WithCounter(counterBox.SelectedText);

            var weightBox = CreateTypeComboBox <IWeightScaler>();

            weightBox.Location = new Point(40, 120);
            Controls.Add(weightBox);
            weightBox.SelectedValueChanged                       += (s, a) =>
                                                         settings = settings.WithScaler(weightBox.SelectedText);
        }
Пример #2
0
 public CircularCloudLayouter(CloudSettings cloudSettings)
 {
     this.cloudSettings = cloudSettings;
     corners.Add(0, new HashSet <Point> {
         cloudSettings.Center
     });
 }
Пример #3
0
        public override void OnInspectorGUI()
        {
            settings = (CloudSettings)target;

            tab = GUILayout.Toolbar(tab, new string[] { "Noise", "Ray-March", "Lighting", "Movement" });
            switch (tab)
            {
            case 0:
                DrawNoiseMenu();
                break;

            case 1:
                DrawRayMarchMenu();
                break;

            case 2:
                DrawLightingMenu();
                break;

            case 3:
                DrawMovementMenu();
                break;
            }
            SceneView.RepaintAll();
        }
Пример #4
0
        /// <summary>
        /// Initializes a new instance of the <see cref="Account" /> class.
        /// </summary>
        public Account(CloudSettings settings, Credentials credentials)
        {
            Credentials = credentials;

            WebRequest.DefaultWebProxy.Credentials = CredentialCache.DefaultCredentials;

            RequestRepo = new RepoFabric(settings, credentials)
                          .Create();
        }
Пример #5
0
        public void SetUp()
        {
            defaultCenter = new Point(0, 0);

            cloudSettingsProvider = A.Fake <ICloudSettingsProvider>();

            var defaultCloudSettings = new CloudSettings
            {
                SpiralFactor = 1 / Math.PI,
                Size         = new Size(1024, 1024)
            };

            A.CallTo(() => cloudSettingsProvider.CloudSettings).Returns(defaultCloudSettings);
            defaultLayouter = new CircularCloudLayouter(cloudSettingsProvider, defaultCenter);
            defaultSize     = new Size(10, 5);
        }
Пример #6
0
        public static void Main(string[] args)
        {
            var container = new ContainerBuilder();

            container.RegisterType <NewFileAction>().As <IGuiAction>();
            container.RegisterType <SaveImageAction>().As <IGuiAction>();
            container.RegisterType <DrawingSettingsAction>().As <IGuiAction>();
            container.RegisterType <ClouderSettingsAction>().As <IGuiAction>();
            container.RegisterType <CloudProcessor>().AsSelf().SingleInstance();
            container.Register(c => CloudSettings.Default()).AsSelf();
            container.Register(c => DrawingSettings.Default()).AsSelf();
            container.RegisterType <MainForm>().AsSelf();
            Application.EnableVisualStyles();
            Application.SetCompatibleTextRenderingDefault(false);
            try
            {
                Application.Run(container.Build().Resolve <MainForm>());
            }
            catch (Exception e)
            {
                MessageBox.Show(e.ToString());
            }
        }
Пример #7
0
 public RepoFabric(CloudSettings settings, Credentials credentials, IWebProxy proxy)
 {
     _settings    = settings;
     _credentials = credentials;
     _proxy       = proxy;
 }
Пример #8
0
 /// <summary>
 /// Get the parameters for overriding the main directional light cookie for one frame.
 /// </summary>
 /// <param name="settings">Current cloud settings.</param>
 /// <param name="cookieParams">Overriden values for cookie parameters.</param>
 /// <returns>True if the cookie should be overriden and RenderSunLightCookie should be called.</returns>
 public virtual bool GetSunLightCookieParameters(CloudSettings settings, ref CookieParameters cookieParams)
 {
     return(false);
 }
Пример #9
0
        public static int Upload(UploadOptions cmdoptions)
        {
            string user       = cmdoptions.Login;
            string password   = cmdoptions.Password;
            string listname   = cmdoptions.FileList;
            string targetpath = cmdoptions.Target;



            if (targetpath.StartsWith(@"\\\"))
            {
                targetpath = Regex.Replace(targetpath, @"\A\\\\\\.*?\\.*?\\", @"\");
            }

            targetpath = WebDavPath.Clean(targetpath);

            var settings = new CloudSettings
            {
                TwoFaHandler = null,
                Protocol     = Protocol.WebM1Bin
            };
            var credentials = new Credentials(user, password);
            var cloud       = new Cloud(settings, credentials);

            using (var file = new StreamReader(listname))
            {
                string line;
                while ((line = file.ReadLine()) != null)
                {
                    System.Console.WriteLine($"Source: {line}");
                    var fileInfo = new FileInfo(line);

                    string targetfile = WebDavPath.Combine(targetpath, fileInfo.Name);
                    System.Console.WriteLine($"Target: {targetfile}");

                    using (var source = System.IO.File.Open(line, FileMode.Open, FileAccess.Read, FileShare.Read))
                    {
                        var hasher = new MailRuSha1Hash();
                        hasher.Append(source);
                        var hash = hasher.HashString;
                        if (cloud.AddFile(hash, targetfile, fileInfo.Length, ConflictResolver.Rename).Result.Success)
                        {
                            System.Console.WriteLine("Added by hash");
                        }
                        else
                        {
                            source.Seek(0, SeekOrigin.Begin);
                            var  buffer = new byte[64000];
                            long wrote  = 0;
                            using (var target = cloud.GetFileUploadStream(WebDavPath.Combine(targetfile, fileInfo.Name), fileInfo.Length).Result)
                            {
                                int read;
                                while ((read = source.Read(buffer, 0, buffer.Length)) > 0)
                                {
                                    target.Write(buffer, 0, read);
                                    wrote += read;
                                    System.Console.Write($"\r{wrote / fileInfo.Length * 100}%");
                                }
                            }
                        }

                        System.Console.WriteLine(" Done.");
                        //source.CopyTo(target);
                    }
                }
            }

            return(0);
        }
Пример #10
0
        static void Main(string[] args)
        {
            var cmdArguments = Parser.Default.ParseArguments <CommandLineOptions>(args);

            var exitCode = cmdArguments
                           .MapResult(
                options =>
            {
                var settings = new CloudSettings
                {
                    Protocol = options.Protocol
                };

                var repoFabric = new RepoFabric(settings, new Credentials(string.Empty, string.Empty));
                var repo       = repoFabric.Create();

                var cards = new List <string>();
                cards.AddRange(options.Files);

                foreach (string filelist in options.Filelists)
                {
                    if (!string.IsNullOrEmpty(filelist))
                    {
                        if (!File.Exists(filelist))
                        {
                            throw new FileNotFoundException($"List file not found {filelist}");
                        }
                        using (TextReader reader = File.OpenText(filelist))
                        {
                            string line;
                            while (!string.IsNullOrEmpty(line = reader.ReadLine()))
                            {
                                cards.Add(line);
                            }
                        }
                    }
                }

                foreach (var card in cards)
                {
                    string pattern = Path.GetFileName(card);
                    string path    = card.Substring(0, card.Length - pattern.Length);
                    string absPath = Path.GetFullPath(string.IsNullOrEmpty(path) ? "." : path);

                    // "Illegal characters in path" exception for wildcard on .Net48
                    //string absPathWithFilename = Path.GetFullPath(card);
                    //string absPath = Path.GetDirectoryName(string.IsNullOrEmpty(path) ? "." : path);

                    string[] filenames = Directory.GetFiles(absPath, pattern,
                                                            options.IsRecursive ? SearchOption.AllDirectories : SearchOption.TopDirectoryOnly);

                    foreach (var filename in filenames)
                    {
                        var hasher = repo.GetHasher();
                        long size;
                        using (FileStream fs = File.OpenRead(filename))
                        {
                            hasher.Append(fs);
                            size = fs.Length;
                        }

                        string hashString = hasher.Hash.ToString();
                        Console.WriteLine($"{hashString}\t{hasher.Name}\t{size}\t{filename}");

                        //Console.WriteLine($"{filename}" );
                    }
                }

                return(0);
            },
                errors => 1);

            if (exitCode > 0)
            {
                Environment.Exit(exitCode);
            }
        }
Пример #11
0
 public ClouderSettingsAction(CloudSettings settings, CloudProcessor imageProcessor)
 {
     this.settings       = settings;
     this.imageProcessor = imageProcessor;
 }
Пример #12
0
 public RepoFabric(CloudSettings settings, Credentials credentials)
 {
     _settings    = settings;
     _credentials = credentials;
 }
 public SmartAlbumController(IOptions <CloudSettings> options)
 {
     CloudSettings = options.Value;
 }
Пример #14
0
 public void RecreateImage(CloudSettings newSettings)
 {
     cloudSettings = newSettings;
     RecreateImage();
 }
Пример #15
0
 /// <summary>
 /// HDRP calls this function once every frame where GetSunLightCookieParameters returns true.
 /// Implement it if your CloudRenderer needs to render a texture to use for the light cookie (for example for cloud shadow rendering).
 /// </summary>
 /// <param name="settings">Current cloud settings.</param>
 /// <param name="sunLight">The main directional light of the scene.</param>
 /// <param name="cmd">Command buffer used for rendering.</param>
 public virtual void RenderSunLightCookie(CloudSettings settings, Light sunLight, CommandBuffer cmd)
 {
 }
	void Awake () {
		_instance = this;
	}
Пример #17
0
 void Awake()
 {
     _instance = this;
 }
Пример #18
0
    public void GenerateClouds(int width, int height, CloudSettings cloudSettings)
    {
        int cloudPadding = 3;

        if (cloudPrefab != null && cloudSettings.cloudCentroids > 0 && cloudSettings.cloundCount > 0)
        {
            Vector2[] cloudCentroids = new Vector2[cloudSettings.cloudCentroids];
            Vector2[] clouds         = new Vector2[cloudSettings.cloundCount];
            for (int i = 0; i < cloudCentroids.Length; i++)
            {
                cloudCentroids[i] = new Vector2(Random.value, Random.value);
            }

            for (int i = 0; i < cloudSettings.cloundCount; i++)
            {
                int index = Random.Range(0, cloudCentroids.Length - 1);
                clouds[i] = cloudCentroids[index] + (Random.insideUnitCircle + Vector2.one) / 2 * cloudSettings.cloudDensity;
            }

            Texture2D waterMaskTexture = new Texture2D(width, height, TextureFormat.RGBA32, false);
            waterMaskTexture.filterMode = FilterMode.Point;

            waterMaskTexture.SetPixels(new Color[width * height]);
            waterMaskTexture.Apply();

            for (int k = 0; k < cloudTextures.Length * cloudPadding; k++)
            {
                Texture2D cloudLayerTexture = new Texture2D(width, height, TextureFormat.RGBA32, false);
                cloudLayerTexture.filterMode = FilterMode.Point;

                Color[] cloudColors = cloudTextures[k / cloudPadding].GetPixels();
                Color[] colors      = new Color[width * height];
                for (int i = 0; i < clouds.Length; i++)
                {
                    for (int j = 0; j < cloudColors.Length; j++)
                    {
                        if (cloudColors[j].a == 0)
                        {
                            continue;
                        }
                        int localX = j % cloudTextures[k / cloudPadding].width;
                        int localY = j / cloudTextures[k / cloudPadding].width;

                        int x = ((int)((clouds[i].x * width) % width) + localX) % width;
                        int y = ((int)((clouds[i].y * height) % height) + localY) % height;

                        int index = x * width + y;
                        colors[index] = cloudColors[j] * cloudSettings.cloudTint.Evaluate(k / (float)(cloudTextures.Length * cloudPadding));
                    }
                }
                cloudLayerTexture.SetPixels(colors);
                cloudLayerTexture.Apply();

                CelestialBodyLayer cloud = Instantiate(planetLayerPrefab, transform).GetComponent <CelestialBodyLayer>();
                cloud.gameObject.name = "Cloud Layer " + k;

                cloud.Configure(k, cloudLayerTexture, waterMaskTexture, celestialBodySettings.shapeSettings, celestialBodySettings.colorSettings);

                //TODO fix to be better
                cloud.radius                  = cloudSettings.cloudRadiusStart + cloudSettings.cloudRadiusChange * k;
                cloud.allowRotate             = true;
                cloud.transform.localPosition = new Vector3(0, 0.01f * k + 0.01f * celestialBodySettings.colorSettings.layers, 0);

                cloud.tint        = cloudSettings.cloudTint.Evaluate(k / (cloudTextures.Length * cloudPadding));
                cloud.shadowColor = new Color(0.05288889f, 0.04848149f, 0.119f);
            }
        }
    }
Пример #19
0
 public CloudProcessor(CloudSettings initialCloudSettings, DrawingSettings initialDrawingSettings)
 {
     cloudSettings   = initialCloudSettings;
     drawingSettings = initialDrawingSettings;
 }