Ejemplo n.º 1
0
        /*
         * Use this code to perform own security checks
         * protected virtual void CheckCustomRights()
         * {
         *
         * bool userCheckedForCustomLogic = false;
         * //write here a custom logic to check if user has enough rights to access application page
         * //if yes, set userCheckedForCustomLogic to true;
         *
         * if (!userCheckedForCustomLogic)
         * {
         *  SPUtility.HandleAccessDenied(new UnauthorizedAccessException());
         * }
         * }
         *
         * protected override void OnLoad(EventArgs e)
         * {
         * this.CheckCustomRights();
         * }
         */

        public override TabDefinition GetTabDefinition()
        {
            return(new TabDefinition()
            {
                Id = "TestRibbon",
                Title = "Test",
                Groups = new GroupDefinition[]
                {
                    new GroupDefinition()
                    {
                        Id = "TestGroup",
                        Title = "Test group",
                        Template = GroupTemplateLibrary.SimpleTemplate,
                        Controls = new ControlDefinition[]
                        {
                            new ButtonDefinition()
                            {
                                Id = "TestButton",
                                Title = "Test button",
                                CommandJavaScript = "alert('test!');",
                                Image = ImageLibrary.GetStandardImage(6, 0)
                            }
                        }
                    }
                }
            });
        }
Ejemplo n.º 2
0
        private async void LoadStudyLocal_Click(object sender, RoutedEventArgs e)
        {
            this.LoadSettings.Hide();

            var parser = new ImageLibrary();

            parser.ReadyToLoad += async(s, num) =>
            {
                await this.RunOnUi(() =>
                {
                    this.LoadBarPanel.Show();

                    this.LoadingBar.Maximum = num;
                });
            };

            parser.LoadedImage += async(s, a) =>
            {
                await this.RunOnUi(() =>
                {
                    this.LoadingBar.Value++;
                });
            };

            this.sbimg = await parser.GetStudyAsCollection();

            await this.OnStudyLoaded();
        }
Ejemplo n.º 3
0
        private async Task LoadImages()
        {
            this.Load.Hide();
            this.LoadingBlock.Show();

            var parser = new ImageLibrary();

            parser.ReadyToLoad += async(s, num) =>
            {
                await this.Dispatcher.RunAsync(CoreDispatcherPriority.Normal, () =>
                {
                    this.LoadingBar.Show();

                    this.LoadingBar.Maximum = num;
                });
            };

            parser.LoadedImage += async(s, a) =>
            {
                await this.Dispatcher.RunAsync(CoreDispatcherPriority.Normal, () =>
                {
                    this.LoadingBar.Value++;
                });
            };

            this.images = await parser.GetStudyRaw();

            this.LoadingBar.Hide();
            this.LoadingBlock.Hide();
        }
Ejemplo n.º 4
0
 private void CreateLibrary()
 {
     library = new ImageLibrary {
         Location = new Point(1, 70)
     };
     library.PictureSelected += library_PictureSelected;
 }
Ejemplo n.º 5
0
        static void searchImageLibrary(string targetPath)
        {
            string[] guids = AssetDatabase.FindAssets("t:ImageLibrary", null);

            if (guids.Length > 0)
            {
                List <TrackableImage> totalTrackables = new List <TrackableImage>();

                foreach (var g in guids)
                {
                    string       path               = AssetDatabase.GUIDToAssetPath(g);
                    ImageLibrary library            = AssetDatabase.LoadAssetAtPath <ImageLibrary>(path);
                    var          completeImagesPath = Path.Combine(targetPath, imagesPath);

                    foreach (var t in library.trackables)
                    {
                        var assetPath       = AssetDatabase.GetAssetPath(t.image);
                        var destinationPath = Path.Combine(completeImagesPath, $"{t.name}.jpg");
                        // Debug.Log($"{t.name} : {assetPath} : {destinationPath}");
                        // FileUtil.CopyFileOrDirectory(assetPath, destinationPath);
                        FileUtil.ReplaceFile(assetPath, destinationPath);
                        totalTrackables.Add(t);
                    }
                }

                generateImagesHTML(targetPath, totalTrackables);
            }
        }
Ejemplo n.º 6
0
        public BitmapSource GetImage(string imageLibraryPath, int imageIndex)
        {
            ImageLibrary ilb       = GetImageLibrary(imageLibraryPath);
            AowImage     imageData = ilb[imageIndex];

            return(ImageLoader.LoadBitmap(imageData, ilb));
        }
Ejemplo n.º 7
0
        private DesktopRuntime(bool enableVisibleStyles)
        {
            // set the name of the thread...
            try
            {
                Thread.CurrentThread.Name = "Main UI Thread";
            }
            catch
            {
                // ignore exceptions here...
            }

            // initialize application style...
            if (enableVisibleStyles)
            {
                Application.EnableVisualStyles();

                // a lot of community chat re EnableVisualStyles says you have to do this...
                Application.DoEvents();
            }

            // initialize exception handling...
            Application.ThreadException += new System.Threading.ThreadExceptionEventHandler(Application_ThreadException);
            AppDomain.CurrentDomain.UnhandledException += new UnhandledExceptionEventHandler(CurrentDomain_UnhandledException);

//			// create a thread for operation dialog...
//			this.StartSharedOperationDialogThread();

            // setup the default icon...
            _defaultFormIcon = ImageLibrary.GetDefaultIcon();
        }
Ejemplo n.º 8
0
 public void a_simple_project_can_be_build_a_second_time()
 {
     Assume.That(TestHelper.IsExplicitAllowed);
     ImageLibrary.minimal_solution_second_ci_build(
         (universe) =>
     {
     }, TestHelper.IsExplicitAllowed);
 }
Ejemplo n.º 9
0
 public void Clear()
 {
     LoadOk = false;
     if (m_ImgLib != null)
     {
         m_ImgLib.Dispose();
         m_ImgLib = null;
     }
 }
Ejemplo n.º 10
0
 public ImageLibraryManager()
 {
     this.imageCollection     = new List <CustomImage>();
     this.libraryPath         = Settings.LibraryPath;
     this.winnerImagePath     = Settings.WinnerImagePath;
     this.closedCardImagePath = Settings.ClosedCardImagePath;
     this.fileManager         = new FileManager();
     this.imageLib            = new ImageLibrary();
 }
Ejemplo n.º 11
0
 public void ckli_save_branch_state_on_restart()
 {
     ImageLibrary.minimal_solution_switched_to_local((universe, world) =>
     {
         world.CheckGlobalGitStatus(TestHelper.Monitor, StandardGitStatus.Local).Should().BeTrue();
         universe.UserHost.WorldSelector.CloseWorld(TestHelper.Monitor);
         var reopenedWorld = universe.EnsureWorldOpened(world.WorldName.Name);
         reopenedWorld.CheckGlobalGitStatus(TestHelper.Monitor, StandardGitStatus.Local).Should().BeTrue();
     }, TestHelper.IsExplicitAllowed);
 }
Ejemplo n.º 12
0
 public void dll_should_not_change_after_rebuild()
 {
     ImageLibrary.minimal_solution_second_ci_build((universe, world) => { }, TestHelper.IsExplicitAllowed);  //We are now sure this image, and it's base exist.
     using (var compare = ImageManager.CompareBuildedImages(
                nameof(ImageLibrary.minimal_solution_first_ci_build),
                nameof(ImageLibrary.minimal_solution_second_ci_build)))
     {
         compare.AExceptB.Where(p => IsFileThatShouldBeDeterministic(p.FullName)).Should().BeEmpty();
     }
 }
Ejemplo n.º 13
0
 public void a_simple_project_can_be_build_a_second_time()
 {
     ImageLibrary.minimal_solution_second_ci_build(
         (universe, world) =>
     {
         var files = Directory.EnumerateFiles(universe.DevDirectory.Combine("LocalFeed/CI"));
         files.Should().HaveCount(1);   //We didn't made any modification: the version should not change.
         Path.GetFileName(files.Single()).Should().Be("CKTest.Code.Cake.0.1.1--0007-develop.nupkg");
     }, TestHelper.IsExplicitAllowed);
 }
Ejemplo n.º 14
0
        public void building_the_same_sln_from_two_dirs_should_be_deterministic()
        {
            bool isExplicit = TestHelper.IsExplicitAllowed;
            var  imageA     = ImageLibrary.minimal_solution_second_ci_build(null, isExplicit);
            var  imageB     = ImageLibrary.another_minimal_solution_second_ci_build(null, isExplicit);

            using (var compare = ImageManager.CompareBuildedImages(imageA, imageB))
            {
                compare.AExceptB.Where(p => IsFileThatShouldBeDeterministic(p.FullName)).Should().BeEmpty();
            }
        }
Ejemplo n.º 15
0
        public void running_apply_settings_does_not_throw(int seed)
        {
            if (seed == -1)
            {
                seed = new Random().Next();
            }
            bool isExplicit = TestHelper.IsExplicitAllowed;

            ImageLibrary.full_apply_settings(null, isExplicit);
            ImageLibrary.full_apply_settings_randomly_applied(null, isExplicit, seed);
        }
Ejemplo n.º 16
0
    public void Init()
    {
        Clear();

        m_ImgLib = new ImageLibrary(Is32BitPallet);
        DefaultLoaderPlayer loadPlayer = GetComponent <DefaultLoaderPlayer> ();
        var    player     = loadPlayer.GetGlobalPayer();
        string spriteName = GlobalConfigMgr.GetConfigFileNameNoExt(player.PlayerCfg.Files.sprite);

        LoadOk = m_ImgLib.LoadChar(loadPlayer.GetPlayerName(), player.AirCfg, spriteName);
    }
Ejemplo n.º 17
0
        private void openFileMenu_Click(object sender, RoutedEventArgs e)
        {
            OpenFileDialog ofd = new OpenFileDialog();

            ofd.Filter = "Файлы рисунков (*.bmp, *.jpg, *.png)|*.bmp;*.jpg;*.png";
            if (ofd.ShowDialog().Value)
            {
                img          = new WriteableBitmap(new BitmapImage(new Uri(ofd.FileName)));
                image.Source = img;
                double          percent = double.Parse(noiseTb.Text, CultureInfo.InvariantCulture);
                WriteableBitmap noised  = ImageLibrary.Noise(img, percent);
                imageNoised.Source = noised;

                List <int> color = binTb.Text.Split(',').ToList().ConvertAll(c => int.Parse(c));

                WriteableBitmap binabinarizated = ImageLibrary.Binarization(noised, color);
                imageBinarizated.Source = binabinarizated;

                ImageLib.Matrix m = new ImageLib.Matrix();
                m.arr1 = m1Tb.Text.Split(',').ToList().ConvertAll(n => double.Parse(n, CultureInfo.InvariantCulture)).ToArray();
                m.arr2 = m2Tb.Text.Split(',').ToList().ConvertAll(n => double.Parse(n, CultureInfo.InvariantCulture)).ToArray();

                WriteableBitmap filtered = ImageLibrary.ApplyMatrix(binabinarizated, m);
                imageFiltered.Source = filtered;

                List <Detection> dets = ImageLibrary.Detect(filtered, int.Parse(minCountPicselTb.Text), int.Parse(minSquareTb.Text));
                StringBuilder    sb   = new StringBuilder();
                foreach (Detection det in dets)
                {
                    sb.AppendLine($"x={det.x}, y={det.y}, width={det.width}, height={det.height}");
                }
                MessageBox.Show(sb.ToString());
                FormatConvertedBitmap bmp32 = new FormatConvertedBitmap();

                // BitmapSource objects like FormatConvertedBitmap can only have their properties
                // changed within a BeginInit/EndInit block.
                bmp32.BeginInit();

                // Use the BitmapSource object defined above as the source for this new
                // BitmapSource (chain the BitmapSource objects together).
                bmp32.Source = img;

                // Set the new format to Gray32Float (grayscale).
                bmp32.DestinationFormat = PixelFormats.Bgr32;
                bmp32.EndInit();
                WriteableBitmap wbmp = new WriteableBitmap(bmp32);
                foreach (Detection det in dets)
                {
                    wbmp.DrawRectangle(det.x, det.y, det.x + det.width, det.y + det.height, Colors.Red);
                }
                imageDetected.Source = wbmp;
            }
        }
Ejemplo n.º 18
0
        public void issue_20()
        {
            ImageLibrary.minimal_solution_first_ci_build((universe, world) =>
            {
                universe
                .RunCommands(TestHelper.Monitor, world.WorldName.Name, "*pull*")
                .RunCommands(TestHelper.Monitor, world.WorldName.Name, "*command*", "git checkout master")
                .RunCommands(TestHelper.Monitor, world.WorldName.Name, "*command*", "git pull");

                world.DumpWorldState(TestHelper.Monitor).Should().BeTrue();
            }, TestHelper.IsExplicitAllowed);
        }
Ejemplo n.º 19
0
        /// <summary>
        /// Description : Get type from string
        /// </summary>
        /// <param name="pEnumName"></param>
        /// <returns></returns>
        public Type GetEnum(ImageLibrary pImageLibrary)
        {
            if (false == IsExist(pImageLibrary))
            {
                return(null);
            }

            ImageModel lImageModel = GetImageModel(pImageLibrary);

            Type lResult = GetEnumType(lImageModel.GetEnum());

            return(lResult);
        }
Ejemplo n.º 20
0
        /// <summary>
        /// Description : The library exist in the enum list
        /// </summary>
        /// <param name="pImageLibrary"></param>
        /// <returns></returns>
        public bool IsExist(ImageLibrary pImageLibrary)
        {
            bool lResult = false;

            foreach (ImageModel lImageModel in GetImageModels())
            {
                if (lImageModel.GetImageLibrary() == pImageLibrary)
                {
                    lResult = true;
                }
            }

            return(lResult);
        }
Ejemplo n.º 21
0
        /// <summary>
        /// Description : return a image model from a image library
        /// </summary>
        /// <param name="pImageLibrary"></param>
        /// <returns></returns>
        private ImageModel GetImageModel(ImageLibrary pImageLibrary)
        {
            ImageModel lResult = null;

            foreach (ImageModel lImageModel in GetImageModels())
            {
                if (lImageModel.GetImageLibrary() == pImageLibrary)
                {
                    lResult = lImageModel;
                }
            }

            return(lResult);
        }
Ejemplo n.º 22
0
 public void a_simple_project_can_be_build_once()
 {
     Assume.That(TestHelper.IsExplicitAllowed);
     EnsureCallbackIsCalled(
         (Action <TestUniverse> action, object[] parameters) => ImageLibrary.minimal_solution_first_ci_build(action, (bool)parameters[0]),
         (universe) =>
     {
         var files = Directory.EnumerateFiles(universe.DevDirectory.Combine("LocalFeed/CI"));
         files.Should().HaveCount(1);
         Path.GetFileName(files.Single()).Should().Be("CKTest.Code.Cake.0.1.1--0003-develop.nupkg");
     },
         TestHelper.IsExplicitAllowed
         );
 }
Ejemplo n.º 23
0
    private void LoadResources()
    {
        CreateTileBrush = (Texture2D)Resources.Load(@"EditorIcons/CreateTileIcon");
        DeleteTileBrush = (Texture2D)Resources.Load(@"EditorIcons/DeleteTileIcon");
        CopyTileBrush   = (Texture2D)Resources.Load(@"EditorIcons/CopyTileIcon");
        ResetTileBrush  = (Texture2D)Resources.Load(@"EditorIcons/ResetTileIcon");

        TilePrefab = Resources.Load(@"[Prefabs]/TilePrefab"); //The base prefab that is being used to build upon.

        savedEditorWindowDataLocation = AssetDatabase.GetAssetPath(Resources.Load("SaveData/EditorWindowSettings"));

        savedRowTagDataLocation = AssetDatabase.GetAssetPath(Resources.Load("SaveData/TagData"));
        ImageLibrary.GetSpriteAndTextureData();
    }
Ejemplo n.º 24
0
            /// <summary>
            /// 按原图产生指定的截图
            /// </summary>
            /// <param name="oderimgurl">原图路径</param>
            /// <param name="width">指定宽</param>
            /// <param name="height"></param>
            /// <param name="mode"></param>
            /// <param name="newimgurl">新图路径</param>
            /// <returns>截图后的文件名</returns>
            public bool getnewimage(string oderimgurl, int width, int height, MakeImageMode mode, string newimgurl, string Extension)
            {
                bool status = true;

                System.Drawing.Image img;//定义一个图片对象
                System.Drawing.Image newimg;
                System.Drawing.Image temp;
                Image        bitmapnew;
                MemoryStream ms = new MemoryStream();

                img              = System.Drawing.Image.FromFile(oderimgurl);        //写入对象
                newimg           = ImageLibrary.MakeImage(img, width, height, mode); //切图产生了一个新的图片对象
                _resimg.imgwidth = newimg.Width;                                     //图片宽
                _resimg.imghidth = newimg.Height;                                    //图片高
                temp             = img;                                              //引用旧图
                temp.Dispose();                                                      //释放旧图
                img = newimg;                                                        //把新图放到img
                img.Save(ms, System.Drawing.Imaging.ImageFormat.Jpeg);
                bitmapnew = ((Image) new Bitmap(ms));                                //文件流转换为图片对象
                img.Dispose();                                                       //释放
                byte[] bytes         = ms.ToArray();
                int    imgsize       = int.Parse(ms.Length.ToString());
                string newimgname    = ImageLibrary.md5(bytes);//文件流加密md5
                string newimgfileurl = newimgurl + newimgname + Extension;

                try
                {
                    bitmapnew.Save(newimgfileurl, System.Drawing.Imaging.ImageFormat.Jpeg);
                    status = true;
                }
                catch (System.Exception e)
                {
                    status = false;
                    throw e;
                }
                finally
                {
                    temp.Dispose();
                    img.Dispose();
                    ms.Close();
                    ms.Dispose();
                    bitmapnew.Dispose();
                }
                _resimg.imgmd5  = newimgname;
                _resimg.imgname = newimgname + Extension;
                _resimg.imgsize = imgsize / 1024;

                return(status);
            }
Ejemplo n.º 25
0
    public bool LoadScene(string fileName, SceneConfig config)
    {
        Clear();
        if (string.IsNullOrEmpty(fileName) || config == null || config.BgCfg == null)
        {
            return(false);
        }

        m_ImgLib = new ImageLibrary(Is32BitPallet, true);
        if (!m_ImgLib.LoadScene(fileName, config))
        {
            return(false);
        }
        LoadOk = true;
        return(true);
    }
Ejemplo n.º 26
0
        public TabDefinition GetTabDefinition()
        {
            var updatePanelScript   = Page.ClientScript.GetPostBackEventReference(MultiViewUpdatePanel, "{0}") + ";";
            var ribbonRefreshScript = "SP.Ribbon.PageManager.get_instance().get_commandDispatcher().executeCommand(Commands.CommandIds.ApplicationStateChanged, null);";

            return(new TabDefinition()
            {
                Id = "Tab1",
                Title = "Toggle",
                Groups = new GroupDefinition[]
                {
                    new GroupDefinition()
                    {
                        Id = "Group1",
                        Title = "Switch view",
                        Template = GroupTemplateLibrary.SimpleTemplate,
                        Controls = new ControlDefinition[]
                        {
                            new ToggleButtonDefinition()
                            {
                                Id = "View1",
                                Title = "View 1",
                                Image = ImageLibrary.GetStandardImage(6, 3),
                                InitialValueJavaScript = "return (window.fr_CurrentView || 1) == 1",
                                CommandJavaScript = "window.fr_CurrentView = 1;" + ribbonRefreshScript + String.Format(updatePanelScript, 1)
                            },
                            new ToggleButtonDefinition()
                            {
                                Id = "View2",
                                Title = "View 2",
                                Image = ImageLibrary.GetStandardImage(6, 3),
                                InitialValueJavaScript = "return (window.fr_CurrentView || 1) == 2",
                                CommandJavaScript = "window.fr_CurrentView = 2;" + ribbonRefreshScript + String.Format(updatePanelScript, 2)
                            },
                            new ToggleButtonDefinition()
                            {
                                Id = "View3",
                                Title = "View 3",
                                Image = ImageLibrary.GetStandardImage(6, 3),
                                InitialValueJavaScript = "return (window.fr_CurrentView || 1) == 3",
                                CommandJavaScript = "window.fr_CurrentView = 3;" + ribbonRefreshScript + String.Format(updatePanelScript, 3)
                            }
                        }
                    }
                }
            });
        }
Ejemplo n.º 27
0
        public void apply_settings_should_be_idempotent(int seed)
        {
            if (seed == -1)
            {
                seed = new Random().Next();
            }
            bool isExplicit = TestHelper.IsExplicitAllowed;

            ImageLibrary.full_apply_settings(null, isExplicit);
            ImageLibrary.full_apply_settings_randomly_applied(null, isExplicit, seed);
            using (var compare = ImageManager.CompareBuildedImages(
                       nameof(ImageLibrary.full_apply_settings),
                       nameof(ImageLibrary.full_apply_settings_randomly_applied)))
            {
                compare.AExceptB.Where(p => p.FullName.EndsWith(".git"));
            }
        }
Ejemplo n.º 28
0
        // 上传img
        private string uploadImg()
        {
            HttpContext    context = System.Web.HttpContext.Current;
            HttpPostedFile file    = context.Request.Files[0];
            myJson         json    = new myJson();

            try
            {
                if (file.ContentLength <= 0 || string.IsNullOrEmpty(file.FileName))
                {
                    json.flag = 0;
                    json.msg  = "上传错误,没有选择文件";
                    return(JsonConvert.SerializeObject(json));
                }

                string Extension = Path.GetExtension(file.FileName).ToLower();
                if (Extension == ".jpg" || Extension == ".jpeg" || Extension == ".png" || Extension == ".bmp")
                {
                    byte[] buffer = new byte[file.InputStream.Length];
                    file.InputStream.Read(buffer, 0, buffer.Length);
                    string name         = ImageLibrary.md5(buffer);
                    string path         = imgfilePath + "/" + date + "/";
                    string absolutePath = context.Server.MapPath(path);
                    if (!Directory.Exists(absolutePath))
                    {
                        Directory.CreateDirectory(absolutePath);
                    }
                    file.SaveAs(absolutePath + name + Extension);
                    json.flag = 1;
                    json.obj  = path + name + Extension;
                    return(JsonConvert.SerializeObject(json));
                }
                else
                {
                    json.flag = 0;
                    json.msg  = "类型错误,只能上传图片";
                    return(JsonConvert.SerializeObject(json));
                }
            }
            catch (Exception ex)
            {
                json.flag = 0;
                json.msg  = "上传失败:" + ex.Message;
                return(JsonConvert.SerializeObject(json));
            }
        }
Ejemplo n.º 29
0
        public ActionResult Index(ImageLibraries model)
        {
            Debug.WriteLine(model);
            ImageLibrary img = new ImageLibrary();

            img.id = model.id;
            entity.ImageLibraries.Add(img);

            if (model.listImage != null)
            {
                foreach (var image in model.listImage)
                {
                    uploadImage(image.image, img.id);
                }
            }
            entity.SaveChanges();
            return(View());
        }
        public override void OnInspectorGUI()
        {
            serializedObject.Update();

            EditorGUILayout.LabelField("SPRITE EXTENSION");
            EditorGUILayout.LabelField("This extension can allow to get a sprite from an image Library");

            _enumLibrary  = serializedObject.FindProperty("_enumLibrary");
            _imageLibrary = serializedObject.FindProperty("_imageLibrary");
            _keyType      = serializedObject.FindProperty("_keyType");
            _enumIndex    = serializedObject.FindProperty("_enumIndex");
            _enumChoice   = serializedObject.FindProperty("_enumChoice");

            EditorGUILayout.Space(10);

            DisplaySpriteData();

            // Sprite Data is set
            if (true == IsConditionsOK())
            {
                EnumLibrary  lEnumLibrary  = (EnumLibrary)_enumLibrary.objectReferenceValue;
                ImageLibrary lImageLibrary = (ImageLibrary)_imageLibrary.objectReferenceValue;

                if (true == lEnumLibrary.IsExist(lImageLibrary))
                {
                    EditorGUILayout.BeginHorizontal();

                    DisplayEnum();

                    EditorGUILayout.EndHorizontal();
                }
                else
                {
                    EditorGUILayout.BeginHorizontal();
                    EditorGUILayout.LabelField("This library is not in the enum library, please verify your data", _warningInfos);
                    EditorGUILayout.EndHorizontal();
                }
            }

            EditorGUILayout.Space(10);

            // Apply modifications
            serializedObject.ApplyModifiedProperties();
        }