Beispiel #1
0
            public FileItem(string name, string filePath)
            {
                FilePath = filePath;

                if (System.IO.Directory.Exists(filePath))
                {
                    Type = FileType.Directory;
                }
                else if (System.IO.Path.GetExtension(filePath).ToLower() == ".efkproj")
                {
                    Type = FileType.EffekseerProject;
                }
                else if (System.IO.Path.GetExtension(filePath).ToLower() == ".efkefc")
                {
                    Type = FileType.EffekseerProject;
                }
                else if (System.IO.Path.GetExtension(filePath).ToLower() == ".png")
                {
                    Type  = FileType.Image;
                    Image = Images.Load(Manager.Native, filePath);
                }
                else
                {
                    Type = FileType.Other;
                }
            }
Beispiel #2
0
        public static void Load(swig.Native native)
        {
            Play     = LoadAppResource(native, "resources/Play.png");
            Stop     = LoadAppResource(native, "resources/Stop.png");
            Pause    = LoadAppResource(native, "resources/Pause.png");
            Step     = LoadAppResource(native, "resources/Step.png");
            BackStep = LoadAppResource(native, "resources/BackStep.png");

            Icons["Copy"]  = LoadAppResource(native, "resources/icons/Copy.png");
            Icons["Paste"] = LoadAppResource(native, "resources/icons/Paste.png");

            Icons["AppIcon"] = LoadAppResource(native, "resources/icon.png");

            Icons["VisibleShow"] = LoadAppResource(native, "resources/icons/Visible_Show.png");
            Icons["VisibleHide"] = LoadAppResource(native, "resources/icons/Visible_Hide.png");

            Icons["EnlargeAnchor"] = LoadAppResource(native, "resources/icons/EnlargeAnchor.png");
            Icons["ShrinkAnchor"]  = LoadAppResource(native, "resources/icons/ShrinkAnchor.png");

            Icons["EnlargeAnchor"] = LoadAppResource(native, "resources/icons/EnlargeAnchor.png");
            Icons["ShrinkAnchor"]  = LoadAppResource(native, "resources/icons/ShrinkAnchor.png");

            Icons["AutoZoom_On"]  = LoadAppResource(native, "resources/icons/AutoZoom_On.png");
            Icons["AutoZoom_Off"] = LoadAppResource(native, "resources/icons/AutoZoom_Off.png");

            Icons["FileViewer_Directory"]     = LoadAppResource(native, "resources/icons/FileViewer_Directory.png");
            Icons["FileViewer_EffekseerProj"] = LoadAppResource(native, "resources/icons/FileViewer_EffekseerProj.png");

            Icons["ButtonMin"]       = LoadAppResource(native, "resources/icons/Button_Min.png");
            Icons["ButtonMax"]       = LoadAppResource(native, "resources/icons/Button_Max.png");
            Icons["ButtonMaxCancel"] = LoadAppResource(native, "resources/icons/Button_MaxCancel.png");
            Icons["ButtonClose"]     = LoadAppResource(native, "resources/icons/Button_Close.png");
        }
Beispiel #3
0
        void UpdateInfo()
        {
            string path = binding.GetAbsolutePath();

            if (System.IO.File.Exists(path))
            {
                image = Images.Load(Manager.Native, path);
            }
            else
            {
                image = null;
            }
        }
Beispiel #4
0
        void UpdateInfo()
        {
            string path = binding.GetAbsolutePath();

            if (System.IO.File.Exists(path))
            {
                image    = Images.Load(Manager.Native, path);
                infoText = "" + image.GetWidth() + "x" + image.GetHeight();
            }
            else
            {
                image    = null;
                infoText = "";
            }
        }
Beispiel #5
0
        public void Initialize(Type enumType)
        {
            if (isInitialized)
            {
                return;
            }
            isInitialized = true;

            // to avoid to change placesGetValues, use  GetFields
            var list   = new List <int>();
            var fields = enumType.GetFields();

            //var iconBitmaps = new List<Bitmap>();
            //bool hasIcon = false;

            foreach (var f in fields)
            {
                if (f.FieldType != enumType)
                {
                    continue;
                }

                var attributes = f.GetCustomAttributes(false);
                var name       = NameAttribute.GetName(attributes);
                if (name == string.Empty)
                {
                    name = f.ToString();
                }

                var iconAttribute       = IconAttribute.GetIcon(attributes);
                swig.ImageResource icon = null;
                if (iconAttribute != null)
                {
                    icon = Images.GetIcon(iconAttribute.resourceName);
                }

                list.Add((int)f.GetValue(null));
                FieldNames.Add(name);
                icons.Add(icon);
            }
            enums = list.ToArray();
        }
Beispiel #6
0
        protected override void UpdateInternal()
        {
            Manager.NativeManager.PushItemWidth(-1);

            // Address bar
            {
                // Back directory (BS shortcut key)
                if (Manager.NativeManager.IsWindowFocused() &&
                    Manager.NativeManager.IsKeyPressed(Manager.NativeManager.GetKeyIndex(swig.Key.Backspace)) &&
                    !String.IsNullOrEmpty(currentPath))
                {
                    UpdateFileListWithProjectPath(currentPath);
                }

                // Back directory
                if (Manager.NativeManager.Button("↑") &&
                    !String.IsNullOrEmpty(currentPath))
                {
                    UpdateFileListWithProjectPath(currentPath);
                }

                Manager.NativeManager.SameLine();

                // Display current directory
                if (Manager.NativeManager.InputText("", (currentPath != null) ? currentPath : ""))
                {
                    string path = Manager.NativeManager.GetInputTextResult();
                    UpdateFileList(path);
                }
            }

            Manager.NativeManager.Separator();

            // Display all files
            for (int i = 0; i < items.Count; i++)
            {
                var item = items[i];

                swig.ImageResource image = null;

                if (item.Type == FileType.Directory)
                {
                    image = Images.GetIcon("FileViewer_Directory");
                }
                if (item.Type == FileType.EffekseerProject)
                {
                    image = Images.GetIcon("FileViewer_EffekseerProj");
                }
                if (item.Type == FileType.Image)
                {
                    image = item.Image;
                }
                if (item.Type == FileType.Other)
                {
                }

                {
                    float iconSize = Manager.NativeManager.GetTextLineHeight();
                    Manager.NativeManager.Image(image, iconSize, iconSize);
                }

                Manager.NativeManager.SameLine();

                string caption = Path.GetFileName(item.FilePath);
                if (Manager.NativeManager.Selectable(caption, i == selectedIndex, swig.SelectableFlags.AllowDoubleClick))
                {
                    selectedIndex = i;

                    if (Manager.NativeManager.IsMouseDoubleClicked(0) ||
                        Manager.NativeManager.IsKeyDown(Manager.NativeManager.GetKeyIndex(swig.Key.Enter)))
                    {
                        OnFilePicked();
                    }
                }

                // File Context Menu
                string menuId = "###FileViewerFilePopupMenu" + i;
                if (Manager.NativeManager.BeginPopupContextItem(menuId))
                {
                    selectedIndex = i;
                    if (Manager.NativeManager.MenuItem(menuOpenFile))
                    {
                        OnFilePicked();
                    }
                    Manager.NativeManager.Separator();

                    if (Manager.NativeManager.MenuItem(menuShowInFileManager))
                    {
                        ShowInFileManager();
                    }
                    Manager.NativeManager.EndPopup();
                }

                // D&D
                DragAndDrops.UpdateImageSrc(item.FilePath);
            }

            Manager.NativeManager.PopItemWidth();
        }
Beispiel #7
0
        protected override void UpdateInternal()
        {
            Manager.NativeManager.PushItemWidth(-1);

            // Address bar
            {
                // Back directory (BS shortcut key)
                if (Manager.NativeManager.IsWindowFocused() &&
                    Manager.NativeManager.IsKeyPressed(Manager.NativeManager.GetKeyIndex(swig.Key.Backspace)) &&
                    !Manager.NativeManager.IsAnyItemActive() &&
                    !string.IsNullOrEmpty(CurrentPath))
                {
                    UpdateFileListWithProjectPath(CurrentPath);
                }

                // Back directory
                if (Manager.NativeManager.Button("↑") &&
                    !String.IsNullOrEmpty(CurrentPath))
                {
                    UpdateFileListWithProjectPath(CurrentPath);
                }

                Manager.NativeManager.SameLine();

                // Display current directory
                if (Manager.NativeManager.InputText("###AddressBar", addressText))
                {
                    addressText = Manager.NativeManager.GetInputTextResult();
                    UpdateFileList(addressText);
                }
                if (Manager.NativeManager.IsItemActivated())
                {
                    addressEditing = true;
                }
                if (Manager.NativeManager.IsItemDeactivated())
                {
                    addressEditing = false;
                    addressText    = CurrentPath;
                }
            }

            Manager.NativeManager.Separator();

            // Display all files
            for (int i = 0; i < items.Count; i++)
            {
                var item = items[i];

                string             icon  = Icons.Empty;
                swig.ImageResource image = null;

                switch (item.Type)
                {
                case FileType.Directory:
                    icon = Icons.FileDirectory;
                    break;

                case FileType.EffekseerProject:
                    icon = Icons.FileEfkefc;
                    break;

                case FileType.Image:
                    image = item.Image;
                    break;

                case FileType.Sound:
                    icon = Icons.FileSound;
                    break;

                case FileType.Model:
                    icon = Icons.FileModel;
                    break;

                case FileType.Material:
                    icon = Icons.FileEfkmat;
                    break;

                default:
                    icon = Icons.FileOther;
                    break;
                }

                float iconPosX = Manager.NativeManager.GetCursorPosX();

                string caption = icon + " " + Path.GetFileName(item.FilePath);
                if (Manager.NativeManager.Selectable(caption, item.Selected, swig.SelectableFlags.AllowDoubleClick))
                {
                    if (Manager.NativeManager.IsCtrlKeyDown())
                    {
                        item.Selected = !item.Selected;
                    }
                    else if (Manager.NativeManager.IsShiftKeyDown() && selectedIndex >= 0)
                    {
                        int min = Math.Min(selectedIndex, i);
                        int max = Math.Max(selectedIndex, i);
                        for (int j = min; j <= max; j++)
                        {
                            items[j].Selected = true;
                        }
                    }
                    else
                    {
                        ResetSelected();
                        item.Selected = true;
                    }

                    selectedIndex = i;

                    if (Manager.NativeManager.IsMouseDoubleClicked(0) ||
                        Manager.NativeManager.IsKeyDown(Manager.NativeManager.GetKeyIndex(swig.Key.Enter)))
                    {
                        OnFilePicked();
                    }
                }

                if (Manager.NativeManager.IsItemFocused())
                {
                    ResetSelected();
                }

                if (Manager.NativeManager.IsItemClicked(1))
                {
                    if (!item.Selected)
                    {
                        ResetSelected();
                        item.Selected = true;
                    }
                    selectedIndex = i;

                    Manager.NativeManager.OpenPopup(ContextMenuPopupId);
                }

                // D&D
                switch (item.Type)
                {
                case FileType.Image:
                    DragAndDrops.UpdateFileSrc(item.FilePath, DragAndDrops.FileType.Image);
                    break;

                case FileType.Sound:
                    DragAndDrops.UpdateFileSrc(item.FilePath, DragAndDrops.FileType.Sound);
                    break;

                case FileType.Model:
                    DragAndDrops.UpdateFileSrc(item.FilePath, DragAndDrops.FileType.Model);
                    break;

                case FileType.Material:
                    DragAndDrops.UpdateFileSrc(item.FilePath, DragAndDrops.FileType.Material);
                    break;

                case FileType.Curve:
                    DragAndDrops.UpdateFileSrc(item.FilePath, DragAndDrops.FileType.Curve);
                    break;

                default:
                    DragAndDrops.UpdateFileSrc(item.FilePath, DragAndDrops.FileType.Other);
                    break;
                }

                if (image != null)
                {
                    Manager.NativeManager.SameLine();
                    Manager.NativeManager.SetCursorPosX(iconPosX);
                    float iconSize = Manager.NativeManager.GetTextLineHeight();
                    Manager.NativeManager.Image(image, iconSize, iconSize);
                }
            }

            UpdateContextMenu();

            Manager.NativeManager.PopItemWidth();

            if (shouldUpdateFileList)
            {
                UpdateFileList();
                shouldUpdateFileList = false;
            }
        }
Beispiel #8
0
        protected override void UpdateInternal()
        {
            Manager.NativeManager.PushItemWidth(-1);

            // Address bar
            {
                if (Manager.NativeManager.Button("↑") &&
                    !String.IsNullOrEmpty(currentPath))
                {
                    UpdateFileListWithProjectPath(currentPath);
                }

                Manager.NativeManager.SameLine();

                // Display current directory
                if (Manager.NativeManager.InputText("", (currentPath != null) ? currentPath : ""))
                {
                    string path = Manager.NativeManager.GetInputTextResult();
                    UpdateFileList(path);
                }
            }

            Manager.NativeManager.Separator();

            // Display all files
            for (int i = 0; i < items.Count; i++)
            {
                var item = items[i];

                swig.ImageResource image = null;

                if (item.Type == FileType.Directory)
                {
                    image = Images.GetIcon("FileViewer_Directory");
                }
                if (item.Type == FileType.EffekseerProject)
                {
                    image = Images.GetIcon("FileViewer_EffekseerProj");
                }
                if (item.Type == FileType.Image)
                {
                    image = item.Image;
                }
                if (item.Type == FileType.Other)
                {
                }

                Manager.NativeManager.Image(image, 32, 32);

                Manager.NativeManager.SameLine();

                string caption = Path.GetFileName(item.FilePath);
                if (Manager.NativeManager.Selectable(caption, i == selectedIndex, swig.SelectableFlags.AllowDoubleClick))
                {
                    selectedIndex = i;

                    if (Manager.NativeManager.IsMouseDoubleClicked(0))
                    {
                        DoubleClick();
                    }
                }

                // D&D
                DragAndDrops.UpdateImageSrc(item.FilePath);
            }

            Manager.NativeManager.PopItemWidth();
        }
Beispiel #9
0
        void UpdateInfo()
        {
            string path = binding.GetAbsolutePath();

            image = Images.Load(Manager.Native, path);
        }
Beispiel #10
0
        public void Initialize(Type enumType)
        {
            if (isInitialized)
            {
                return;
            }
            isInitialized = true;

            // to avoid to change placesGetValues, use  GetFields
            var list   = new List <int>();
            var fields = enumType.GetFields();

            //var iconBitmaps = new List<Bitmap>();
            //bool hasIcon = false;

            foreach (var f in fields)
            {
                if (f.FieldType != enumType)
                {
                    continue;
                }

                var attributes = f.GetCustomAttributes(false);

                object name = f.ToString();


                var key     = KeyAttribute.GetKey(attributes);
                var nameKey = key + "_Name";
                if (string.IsNullOrEmpty(key))
                {
                    nameKey = f.FieldType.ToString() + "_" + f.ToString() + "_Name";
                }

                if (MultiLanguageTextProvider.HasKey(nameKey))
                {
                    name = new MultiLanguageString(nameKey);
                }
                else
                {
                    name = NameAttribute.GetName(attributes);
                    if (name.ToString() == string.Empty)
                    {
                        name = f.ToString();
                    }
                    //System.IO.File.AppendAllText("kv.csv", nameKey + "," + name.ToString() + "\r\n");
                }

                var iconAttribute       = IconAttribute.GetIcon(attributes);
                swig.ImageResource icon = null;
                if (iconAttribute != null)
                {
                    icon = Images.GetIcon(iconAttribute.resourceName);
                }

                list.Add((int)f.GetValue(null));
                FieldNames.Add(name);
                icons.Add(icon);
            }
            enums = list.ToArray();
        }