Ejemplo n.º 1
0
        public override async void Execute()
        {
            var files = import.ShowImportImageDialog();

            if (files == null)
            {
                return;
            }

            // nothing imported yet => show in same window
            if (models.Images.NumImages == 0)
            {
                foreach (var file in files)
                {
                    await import.ImportImageAsync(file);
                }
                return;
            }

            // already images imported => show in new window
            var args = "";

            foreach (var file in files)
            {
                args += $"\"{file}\" ";
            }

            var info = new System.Diagnostics.ProcessStartInfo(models.Window.AssemblyPath, args);

            System.Diagnostics.Process.Start(info);
        }
Ejemplo n.º 2
0
        private async void LoadStartupArgsAsync()
        {
            var import = new ImportDialogController(models);

            foreach (var arg in App.StartupArgs)
            {
                await import.ImportImageAsync(arg);
            }
        }
Ejemplo n.º 3
0
        public override async void Execute()
        {
            var files = importDialog.ShowImportImageDialog();

            if (files == null)
            {
                return;
            }

            foreach (var file in files)
            {
                await importDialog.ImportImageAsync(file);
            }
        }
Ejemplo n.º 4
0
        public async Task ApplyToModels(ModelsEx models)
        {
            // clear images
            if (ImportMode == ViewerConfig.ImportMode.Replace)
            {
                models.Images.Clear();
            }

            var import       = new ImportDialogController(models);
            var layerMipmaps = new LayerMipmapCount(NumLayers, NumMipmaps);
            var imgSize      = new Size3(Width, Height, Depth);

            // add images from config
            foreach (var img in Images)
            {
                if (img.Data == null)
                {
                    await import.ImportImageAsync(img.Filename, img.Alias);
                }
                else
                {
                    Debug.Assert(img.Format != null);
                    var fmt = new ImageFormat(img.Format.Value);

                    // load base 64 bytes
                    var bytes = System.Convert.FromBase64String(img.Data);
                    bytes = Compression.Decompress(bytes);
                    var      bi  = new ByteImageData(bytes, layerMipmaps, imgSize, fmt);
                    ITexture tex = null;
                    if (bi.Is3D)
                    {
                        tex = new Texture3D(bi);
                    }
                    else
                    {
                        tex = new TextureArray2D(bi);
                    }

                    try
                    {
                        models.Images.AddImage(tex, false, img.Filename, fmt.GliFormat, img.Alias);
                    }
                    catch (Exception e)
                    {
                        tex?.Dispose();
                        models.Window.ShowErrorDialog(e);
                    }
                }
            }
        }
Ejemplo n.º 5
0
        public async void Drop(IDropInfo dropInfo)
        {
            if (dropInfo.Data is ImageItemViewModel vm)
            {
                // move images
                var idx1 = ImageListItems.IndexOf(vm);
                var idx2 = dropInfo.InsertIndex;
                if (idx1 < 0 || idx2 < 0)
                {
                    return;
                }
                // did the order change?
                if (idx1 == idx2)
                {
                    return;
                }

                // move image want the final position of the moved image
                if (idx1 < idx2)
                {
                    idx2--;
                }

                // put item from idx1 into the position it was dragged to
                models.Images.MoveImage(idx1, idx2);
            }
            else if (dropInfo.Data is DataObject obj)
            {
                var items = obj.GetFileDropList();

                int desiredPosition = dropInfo.InsertIndex;

                foreach (var file in items)
                {
                    await import.ImportImageAsync(file);

                    // put inserted image into correct position
                    models.Images.MoveImage(models.Images.NumImages - 1, desiredPosition++);
                }
            }
        }
Ejemplo n.º 6
0
 private async void LoadStartupArgsAsync()
 {
     try
     {
         var import = new ImportDialogController(models);
         foreach (var arg in App.StartupArgs)
         {
             if (arg.EndsWith(".icfg"))
             {
                 var cfg = ViewerConfig.LoadFromFile(arg);
                 await cfg.ApplyToModels(models);
             }
             else
             {
                 await import.ImportImageAsync(arg);
             }
         }
     }
     catch (Exception e)
     {
         models.Window.ShowErrorDialog(e);
     }
 }