Example #1
0
	IEnumerator WaitAndFindCueController (Preloader preloader)
	{
		cueController = null;
		while(!preloader.isDone)
		{
			yield return null;
		}
		while(!cueController)
		{
			cueController = CueController.FindObjectOfType<CueController>();
			yield return null;
		}
		Debuger.DebugOnScreen("CueController " + (cueController != null).ToString());
		OnFindCueController();
	}
 public void Awake()
 {
     _fetchingDisplayList = false;
     DOWNLOAD_PATH = Application.persistentDataPath + "/downloaded_assets";
     instance = this;
     _screenList = null;
     ServicePointManager.ServerCertificateValidationCallback +=
         new RemoteCertificateValidationCallback(
             (sender, certificate, chain, policyErrors) => { return true; });
 }
Example #3
0
        internal static string[] RetrieveData(string file)
        {
            string name, directoryname, fullname, creationtime, lastwritetime;

            FileInfo fileInfo;

            try
            {
                fileInfo      = new FileInfo(file);
                name          = fileInfo.Name;
                directoryname = fileInfo.DirectoryName;
                fullname      = fileInfo.FullName;
                creationtime  = fileInfo.CreationTime.ToString(CultureInfo.CurrentCulture);
                lastwritetime = fileInfo.LastWriteTime.ToString(CultureInfo.CurrentCulture);
            }
            catch (Exception)
            {
                name          = string.Empty;
                directoryname = string.Empty;
                fullname      = string.Empty;
                creationtime  = string.Empty;
                lastwritetime = string.Empty;
            }

            var image = Preloader.Get(Navigation.Pics[Navigation.FolderIndex]);

            var inchesWidth  = image.PixelWidth / image.DpiX;
            var inchesHeight = image.PixelHeight / image.DpiY;
            var cmWidth      = inchesWidth * 2.54;
            var cmHeight     = inchesHeight * 2.54;

            var    firstRatio  = image.PixelWidth / UILogic.TransformImage.ZoomLogic.GCD(image.PixelWidth, image.PixelHeight);
            var    secondRatio = image.PixelHeight / UILogic.TransformImage.ZoomLogic.GCD(image.PixelWidth, image.PixelHeight);
            string ratioText;

            if (firstRatio == secondRatio)
            {
                ratioText = $"{firstRatio}:{secondRatio} ({Application.Current.Resources["Square"]})";
            }
            else if (firstRatio > secondRatio)
            {
                ratioText = $"{firstRatio}:{secondRatio} ({Application.Current.Resources["Landscape"]})";
            }
            else
            {
                ratioText = $"{firstRatio}:{secondRatio} ({Application.Current.Resources["Portrait"]})";
            }

            object bitdepth, dpiX, dpiY;
            string dpi;

            try
            {
                var so = ShellObject.FromParsingName(file);
                bitdepth = so.Properties.GetProperty(SystemProperties.System.Image.BitDepth).ValueAsObject;
                dpiX     = so.Properties.GetProperty(SystemProperties.System.Image.HorizontalResolution).ValueAsObject;
                dpiY     = so.Properties.GetProperty(SystemProperties.System.Image.VerticalResolution).ValueAsObject;
                so.Dispose();
            }
            catch (Exception)
            {
                bitdepth = string.Empty;
                dpiX     = string.Empty;
                dpiY     = string.Empty;
            }

            if (bitdepth == null)
            {
                bitdepth = string.Empty;
            }

            if (dpiX == null)
            {
                dpi = string.Empty;
            }
            else
            {
                dpi = Math.Round((double)dpiX) + " x " + Math.Round((double)dpiY) + " " + Application.Current.Resources["Dpi"];
            }

            return(new string[]
            {
                // Fileinfo
                name,
                directoryname,
                fullname,
                creationtime,
                lastwritetime,

                // Resolution
                image.PixelWidth + " x " + image.PixelHeight + " " + Application.Current.Resources["Pixels"],

                // DPI
                dpi,

                // Bit dpeth
                bitdepth.ToString(),

                // Megapixels
                ((float)image.PixelHeight * image.PixelWidth / 1000000)
                .ToString("0.##", CultureInfo.CurrentCulture) + " " + Application.Current.Resources["MegaPixels"],

                // Print size cm
                cmWidth.ToString("0.##", CultureInfo.CurrentCulture) + " x " + cmHeight.ToString("0.##", CultureInfo.CurrentCulture)
                + " " + Application.Current.Resources["Centimeters"],

                // Print size inch
                inchesWidth.ToString("0.##", CultureInfo.CurrentCulture) + " x " + inchesHeight.ToString("0.##", CultureInfo.CurrentCulture)
                + " " + Application.Current.Resources["Inches"],

                // Aspect ratio
                ratioText
            });
        }
Example #4
0
        /// <summary>
        /// Goes to next, previous, first or last file in folder
        /// </summary>
        /// <param name="next">Whether it's forward or not</param>
        /// <param name="end">Whether to go to last or first,
        /// depending on the next value</param>
        internal static void Pic(bool next = true, bool end = false)
        {
            // Exit if not intended to change picture
            if (!canNavigate)
            {
                return;
            }

            // exit if browsing PicGallery
            if (picGallery != null)
            {
                if (Properties.Settings.Default.PicGallery == 1)
                {
                    if (PicGalleryLogic.IsOpen)
                    {
                        return;
                    }
                }
            }

            // Make backup?
            var x = FolderIndex;

            // Go to first or last
            if (end)
            {
                FolderIndex = next ? Pics.Count - 1 : 0;

                // Reset preloader values to prevent errors
                if (Pics.Count > 20)
                {
                    Preloader.Clear();
                }

                PreloadCount = 4;
            }
            // Go to next or previous
            else
            {
                if (next)
                {
                    // loop next
                    if (Properties.Settings.Default.Looping)
                    {
                        FolderIndex = FolderIndex == Pics.Count - 1 ? 0 : FolderIndex + 1;
                    }
                    else
                    {
                        // Go to next if able
                        if (FolderIndex + 1 == Pics.Count)
                        {
                            return;
                        }

                        FolderIndex++;
                    }

                    PreloadCount++;
                    reverse = false;
                }
                else
                {
                    // Loop prev
                    if (Properties.Settings.Default.Looping)
                    {
                        FolderIndex = FolderIndex == 0 ? Pics.Count - 1 : FolderIndex - 1;
                    }
                    else
                    {
                        // Go to prev if able
                        if (FolderIndex - 1 < 0)
                        {
                            return;
                        }

                        FolderIndex--;
                    }

                    PreloadCount--;
                    reverse = true;
                }
            }

            // Go to the image!
            Pic(FolderIndex);

            // Update PicGallery selected item, if needed
            if (picGallery != null)
            {
                if (Properties.Settings.Default.PicGallery > 0)
                {
                    if (picGallery.Container.Children.Count > FolderIndex)
                    {
                        var prevItem = picGallery.Container.Children[x] as PicGalleryItem;
                        prevItem.SetSelected(false);

                        var nextItem = picGallery.Container.Children[FolderIndex] as PicGalleryItem;
                        nextItem.SetSelected(true);
                        PicGalleryScroll.ScrollTo();
                    }
                    else
                    {
                        // TODO Find way to get PicGalleryItem an alternative way...
                    }
                }
            }
        }
Example #5
0
        internal static void Click(int id)
        {
            LoadWindows.GetMainWindow.Focus();

            if (Properties.Settings.Default.PicGallery == 1)
            {
                if (Preloader.Contains(Pics[id]))
                {
                    PreviewItemClick(Preloader.Load(Pics[id]), id);
                }
                else
                {
                    var z = GetPicGallery.Container.Children[id] as UserControls.PicGalleryItem;
                    PreviewItemClick(z.img.Source, id);
                }

                if (WindowLogic.AutoFitWindow)
                {
                    GetPicGallery.Width  = xWidth;
                    GetPicGallery.Height = xHeight;
                }

                GetPicGallery.x2.Visibility = Visibility.Hidden;

                LoadWindows.GetMainWindow.MainImage.Source = null;

                var img = new Image()
                {
                    Source              = GetThumb(id),
                    Stretch             = Stretch.Fill,
                    HorizontalAlignment = HorizontalAlignment.Center,
                    VerticalAlignment   = VerticalAlignment.Center
                };

                // Need to add border for background to pictures with transparent background
                var border = new Border()
                {
                    Background = ConfigureSettings.ConfigColors.GetBackgroundColorBrush()
                };
                border.Child = img;
                GetPicGallery.grid.Children.Add(border);

                var from         = picGalleryItem_Size;
                var to           = new double[] { xWidth, xHeight };
                var acceleration = 0.2;
                var deceleration = 0.4;
                var duration     = TimeSpan.FromSeconds(.3);

                var da = new DoubleAnimation
                {
                    From              = 0,
                    To                = to[0],
                    Duration          = duration,
                    AccelerationRatio = acceleration,
                    DecelerationRatio = deceleration,
                    FillBehavior      = FillBehavior.Stop
                };

                var da0 = new DoubleAnimation
                {
                    From              = 0,
                    To                = to[1],
                    Duration          = duration,
                    AccelerationRatio = acceleration,
                    DecelerationRatio = deceleration,
                    FillBehavior      = FillBehavior.Stop
                };

                var da1 = new DoubleAnimation
                {
                    From         = 1,
                    To           = 0,
                    Duration     = duration,
                    FillBehavior = FillBehavior.Stop
                };

                da.Completed += delegate
                {
                    ItemClick(id);
                    GetPicGallery.grid.Children.Remove(border);
                    img    = null;
                    IsOpen = false;
                };

                border.BeginAnimation(FrameworkElement.WidthProperty, da);
                border.BeginAnimation(FrameworkElement.HeightProperty, da0);
                GetPicGallery.Container.BeginAnimation(UIElement.OpacityProperty, da1);
            }
            else
            {
                ItemClick(id);
            }
        }
Example #6
0
        /// <summary>
        /// Loads image based on overloaded int.
        /// </summary>
        /// <param name="x">The index of file to load from Pics</param>
        internal static async void Pic(int x)
        {
            BitmapSource pic;

            // Additional error checking
            if (Pics.Count <= x)
            {
                if (x == 0)
                {
                    var recovery = await RecoverFailedArchiveAsync().ConfigureAwait(true);

                    if (!recovery)
                    {
                        ToolTipStyle("Archive could not be processed");
                        Reload(true);
                        return;
                    }
                }

                // Untested code
                pic = await PicErrorFix(x).ConfigureAwait(true);

                if (pic == null)
                {
                    Reload(true);
                    return;
                }
            }
            if (x < 0)
            {
                pic = await PicErrorFix(x).ConfigureAwait(true);
            }
            //if (!canNavigate)
            //{
            //    Reload(true);
            //    return;
            //}
            else
            {
                /// Add "pic" as local variable used for the image.
                /// Use the Load() function load image from memory if available
                /// if not, it will be null
                pic = Preloader.Load(Pics[x]);
            }


            if (pic == null)
            {
                mainWindow.Title       = Loading;
                mainWindow.Bar.Text    = Loading;
                mainWindow.Bar.ToolTip = Loading;

                TryZoomFit(Pics[x]);

                var thumb = GetThumb();

                if (thumb != null)
                {
                    mainWindow.img.Source = thumb;
                }

                // Dissallow changing image while loading
                canNavigate = false;

                if (freshStartup)
                {
                    // Load new value manually
                    await Task.Run(() => pic = RenderToBitmapSource(Pics[x])).ConfigureAwait(true);
                }
                else
                {
                    do
                    {
                        // Try again while loading?
                        await Task.Delay(20).ConfigureAwait(true);

                        if (x < Pics.Count)
                        {
                            pic = Preloader.Load(Pics[x]);
                        }
                    } while (Preloader.IsLoading);
                }

                // If pic is still null, image can't be rendered
                if (pic == null)
                {
                    // Attempt to load new image
                    pic = await PicErrorFix(x).ConfigureAwait(true);

                    if (pic == null)
                    {
                        if (Pics.Count <= 1)
                        {
                            Unload();
                            return;
                        }

                        DisplayBrokenImage();
                        canNavigate = true;
                        return;
                    }
                }
            }

            // Clear unsupported image window, if shown
            if (mainWindow.img.Source == null && !freshStartup)
            {
                if (mainWindow.topLayer.Children.Count > 0)
                {
                    mainWindow.topLayer.Children.Clear();
                }
            }

            // Show the image! :)
            mainWindow.img.Source = pic;

            ZoomFit(pic.PixelWidth, pic.PixelHeight);

            // Scroll to top if scroll enabled
            if (IsScrollEnabled)
            {
                mainWindow.Scroller.ScrollToTop();
            }

            /// TODO Make it staying flipped a user preference
            //// Prevent picture from being flipped if previous is
            //if (Flipped)
            //    Flip();

            // Update values
            canNavigate = true;
            SetTitleString(pic.PixelWidth, pic.PixelHeight, x);
            FolderIndex = x;
            AjaxLoadingEnd();

            if (Pics.Count > 0)
            {
                Progress(x, Pics.Count);

                // Preload images \\
                if (Preloader.StartPreload())
                {
                    Preloader.Add(pic, Pics[FolderIndex]);
                    await Preloader.PreLoad(x).ConfigureAwait(false);
                }
            }

            if (!freshStartup)
            {
                RecentFiles.Add(Pics[x]);
            }

            freshStartup = false;
        }
Example #7
0
        /// <summary>
        /// Loads a picture from a given file path and does extra error checking
        /// </summary>
        /// <param name="path"></param>
        internal static async void Pic(string path)
        {
            // Set Loading
            mainWindow.Title       = mainWindow.Bar.Text = Loading;
            mainWindow.Bar.ToolTip = Loading;
            if (mainWindow.img.Source == null)
            {
                AjaxLoadingStart();
            }

            // Handle if from web
            if (!File.Exists(path))
            {
                if (Uri.IsWellFormedUriString(path, UriKind.Absolute))
                {
                    LoadFromWeb.PicWeb(path);
                }
                else
                {
                    Unload();
                }

                return;
            }

            // If count not correct or just started, get values
            if (Pics.Count <= FolderIndex || FolderIndex < 0 || freshStartup)
            {
                await GetValues(path).ConfigureAwait(true);
            }
            // If the file is in the same folder, navigate to it. If not, start manual loading procedure.
            else if (!string.IsNullOrWhiteSpace(Pics[FolderIndex]) && Path.GetDirectoryName(path) != Path.GetDirectoryName(Pics[FolderIndex]))
            {
                //// Reset zipped values
                //if (!string.IsNullOrWhiteSpace(TempZipPath))
                //{
                //    DeleteTempFiles();
                //    TempZipPath = string.Empty;
                //    RecentFiles.SetZipped(string.Empty, false);
                //}

                // Reset old values and get new
                ChangeFolder(true);
                await GetValues(path).ConfigureAwait(true);
            }

            // If no need to reset values, get index
            else if (Pics != null)
            {
                FolderIndex = Pics.IndexOf(path);
            }

            if (Pics != null)
            {
                // Fix large archive extraction error
                if (Pics.Count == 0)
                {
                    var recovery = await RecoverFailedArchiveAsync().ConfigureAwait(true);

                    if (!recovery)
                    {
                        if (sexyToolTip.Opacity == 0)
                        {
                            ToolTipStyle("Archive could not be processed");
                        }

                        Reload(true);
                        return;
                    }
                    mainWindow.Focus();
                }
            }
            else
            {
                Reload(true);
                return;
            }

            if (File.Exists(Pics[FolderIndex]))
            {
                if (!freshStartup)
                {
                    Preloader.Clear();
                }

                // Navigate to picture using obtained index
                Pic(FolderIndex);
            }
            else
            {
                Reload(true);
                return;
            }

            // Load images for PicGallery if enabled
            if (Properties.Settings.Default.PicGallery > 0)
            {
                if (!PicGalleryLogic.IsLoading)
                {
                    await PicGalleryLoad.Load().ConfigureAwait(true);
                }
            }

            prevPicResource = null; // Make sure to not waste memory
        }
        /// <summary>
        /// A TestSessionConfiguration specifies test session configuration properties
        /// for a test.
        /// </summary>
        /// <param name="dynamoCoreDirectory">The location of Dynamo's core directory. If the config file
        /// contains a value for DynamoBasePath, then this parameter will be ignored.</param>
        /// <param name="configFileDirectory">The location of the directory containing the TestServices.dll.config file.
        /// If this parameter is null, the value of dynamoCoreDirectory will be used.</param>
        public TestSessionConfiguration(string dynamoCoreDirectory, string configFileDirectory = null)
        {
            string configPath;

            if (configFileDirectory == null || !Directory.Exists(configFileDirectory))
            {
                configPath = Path.Combine(dynamoCoreDirectory, CONFIG_FILE_NAME);
            }
            else
            {
                configPath = Path.Combine(configFileDirectory, CONFIG_FILE_NAME);
            }

            // If a config file cannot be found, fall back to
            // using the executing assembly's directory for core
            // and version 219 for the shape manager.
            if (!File.Exists(configPath))
            {
                DynamoCorePath = dynamoCoreDirectory;

                var versions = new List <Version>
                {
                    new Version(224, 4, 0),
                    new Version(224, 0, 1),
                    new Version(223, 0, 1),
                    new Version(222, 0, 0),
                    new Version(221, 0, 0)
                };
                var shapeManagerPath = string.Empty;
                RequestedLibraryVersion2 = Utilities.GetInstalledAsmVersion2(versions, ref shapeManagerPath, dynamoCoreDirectory);
                return;
            }

            // Adjust the config file map because the config file
            // might not always be in the same directory as the dll.
            var map = new ExeConfigurationFileMap {
                ExeConfigFilename = configPath
            };
            var config = ConfigurationManager.OpenMappedExeConfiguration(map, ConfigurationUserLevel.None);

            var dir = GetAppSetting(config, "DynamoBasePath");

            DynamoCorePath = string.IsNullOrEmpty(dir) ? dynamoCoreDirectory : dir;

            //if an old client supplies an older format test config we should still load it.
            var versionStrOld = GetAppSetting(config, "RequestedLibraryVersion");
            var versionStr    = GetAppSetting(config, "RequestedLibraryVersion2");

            Version        version;
            LibraryVersion libVersion;

            // first try to load the requested library in the more precise format
            if (Version.TryParse(versionStr, out version))
            {
                RequestedLibraryVersion2 = version;
            }
            // else try to load the older one and convert it to a known precise version
            else if (Enum.TryParse <LibraryVersion>(versionStrOld, out libVersion))
            {
                var realVersion = Preloader.MapLibGVersionEnumToFullVersion(libVersion);
                RequestedLibraryVersion2 = realVersion;
            }
            // fallback to a mid range version
            else
            {
                RequestedLibraryVersion2 = new Version(223, 0, 1);
            }
        }
Example #9
0
 protected void Application_PreStartInit()
 {
     _preloader = new Preloader(this);
     _preloader.Setup();
 }
Example #10
0
 private void OnQueryMapCompleted(object sender, TransactionalNodeService.Proxy.NodesEventArgs e)
 {
     Preloader.InitialiseControllers();
     QueryCompleted(e);
 }
Example #11
0
        internal static void Paste()
        {
            // file

            if (Clipboard.ContainsFileDropList()) // If Clipboard has one or more files
            {
                var files = Clipboard.GetFileDropList().Cast <string>().ToArray();

                if (files != null)
                {
                    if (files.Length >= 1)
                    {
                        var x = files[0];

                        if (Pics.Count != 0)
                        {
                            // If from same folder
                            if (!string.IsNullOrWhiteSpace(Pics[FolderIndex]) && Path.GetDirectoryName(x) == Path.GetDirectoryName(Pics[FolderIndex]))
                            {
                                if (!Preloader.Contains(x))
                                {
                                    PreloadCount = 4;
                                    Preloader.Add(x);
                                }

                                Pic(Pics.IndexOf(x));
                            }
                            else
                            {
                                Pic(x);
                            }
                        }
                        else
                        {
                            Pic(x);
                        }

                        if (files.Length > 1)
                        {
                            for (int i = 1; i < files.Length; i++)
                            {
                                using (var n = new Process())
                                {
                                    n.StartInfo.FileName  = Assembly.GetExecutingAssembly().Location;
                                    n.StartInfo.Arguments = files[i];
                                    n.Start();
                                }
                            }
                        }
                    }
                    return;
                }
            }

            // Clipboard Image
            if (Clipboard.ContainsImage())
            {
                Pic(Clipboard.GetImage(), "Clipboard Image");
                return;
            }

            // text/string/adddress

            var s = Clipboard.GetText(TextDataFormat.Text);

            if (string.IsNullOrEmpty(s))
            {
                return;
            }

            if (FilePathHasInvalidChars(s))
            {
                MakeValidFileName(s);
            }

            s = s.Replace("\"", "");
            s = s.Trim();

            if (File.Exists(s))
            {
                Pic(s);
            }
            else if (Directory.Exists(s))
            {
                ChangeFolder();
                Pics = FileList(s);
                if (Pics.Count > 0)
                {
                    Pic(Pics[0]);
                }
                else if (!string.IsNullOrWhiteSpace(Pics[FolderIndex]))
                {
                    Pic(Pics[FolderIndex]);
                }
                else
                {
                    Unload();
                }
            }
            else if (Uri.IsWellFormedUriString(s, UriKind.Absolute)) // Check if from web
            {
                LoadFromWeb.PicWeb(s);
            }
            else
            {
                ToolTipStyle("An error occured while trying to paste file");
            }
        }
Example #12
0
        internal static Size?ImageSize(string file, bool usePreloader = false, bool advancedFormats = false)
        {
            if (usePreloader)
            {
                var pic = Preloader.Load(Pics[FolderIndex]);
                if (pic != null)
                {
                    return(new Size(pic.PixelWidth, pic.PixelHeight));
                }
            }

            using var magick = new MagickImage();
            var ext = Path.GetExtension(file).ToUpperInvariant();

            switch (ext)
            {
            // Standards
            case ".JPG":
            case ".JPEG":
            case ".JPE":
            case ".JFIF":
                magick.Format = MagickFormat.Jpg;
                break;

            case ".PNG":
                magick.Format = MagickFormat.Png;
                break;

            case ".BMP":
                magick.Format = MagickFormat.Bmp;
                break;

            case ".TIF":
            case ".TIFF":
                magick.Format = MagickFormat.Tif;
                break;

            case ".GIF":
                magick.Format = MagickFormat.Gif;
                break;

            case ".ICO":
                magick.Format = MagickFormat.Ico;
                break;

            default:
                if (!advancedFormats)
                {
                    // don't read advanced formats
                    return(null);
                }

                break;
            }

            try
            {
                magick.Read(file);
            }
#if DEBUG
            catch (MagickException e)
            {
                Trace.WriteLine("ImageSize returned " + file + " null, \n" + e.Message);
                return(null);
            }
#else
            catch (MagickException) { return(null); }
#endif

            return(new Size(magick.Width, magick.Height));
        }