Пример #1
0
        private void Dispose(bool isDisposing)
        {
            if (isDisposing)
            {
                foreach (var createdWindow in CreatedWindows.Values)
                {
                    createdWindow.Dispose();
                }
            }

            if (_classAtom != 0)
            {
                var lpClassName = (LPWSTR)(_classAtom);
                UnregisterClass(lpClassName, EntryModuleHandle);
                _classAtom = 0;
            }

            if (_lpWindowName != null)
            {
                Marshal.FreeHGlobal((IntPtr)(_lpWindowName));
                _lpWindowName = null;
            }

            if (_lpClassName != null)
            {
                Marshal.FreeHGlobal((IntPtr)(_lpClassName));
                _lpClassName = null;
            }
        }
Пример #2
0
        public WindowManager(
            [Import] Lazy <IDispatchManager> dispatchManager
            )
        {
            _lpClassName     = (WCHAR *)(Marshal.StringToHGlobalUni($"TerraFX.Interop.Provider.Win32.UI.Window.{EntryModuleHandle}"));
            _lpWindowName    = (WCHAR *)(Marshal.StringToHGlobalUni($"TerraFX Win32 Window"));
            _dispatchManager = dispatchManager;

            var wndClassEx = new WNDCLASSEX()
            {
                cbSize        = unchecked ((uint)(Marshal.SizeOf <WNDCLASSEX>())),
                style         = CS.VREDRAW | CS.HREDRAW,
                lpfnWndProc   = WndProc,
                cbClsExtra    = 0,
                cbWndExtra    = 0,
                hInstance     = EntryModuleHandle,
                hIcon         = HICON.NULL,
                hCursor       = HCURSOR.NULL,
                hbrBackground = (IntPtr)(COLOR.WINDOW + 1),
                lpszMenuName  = LPWSTR.NULL,
                lpszClassName = _lpClassName,
                hIconSm       = HICON.NULL
            };

            var classAtom = RegisterClassEx(ref wndClassEx);

            if (classAtom == 0)
            {
                ExceptionUtilities.ThrowExternalExceptionForLastError(nameof(RegisterClassEx));
            }

            _classAtom = classAtom;
        }
    // Read the data and store it in ATOM structure array
    public void ReadAsciiData()
    {
        // Data path
        string _path = Application.dataPath;

        if (Application.platform == RuntimePlatform.OSXPlayer)
        {
            _path += "/../../";
        }
        else if (Application.platform == RuntimePlatform.WindowsEditor)
        {
            _path += "/../";
        }
        else if (Application.platform == RuntimePlatform.WindowsPlayer)
        {
            _path += "/../";
        }
        _path += "DELTAMBD_GAG_PROTEIN.txt";

        // ---------------------------------------- Count data rows
        int _particleCount = 0;

        string[] _allLines = File.ReadAllLines(@_path);
        for (int _i = 0; _i < _allLines.Length; _i++)
        {
            if (_allLines[_i].Length > 0)
            {
                _particleCount++;
            }
        }

        // ---------------------------------------- Prepare ATOM structure array for data points
        ATOM[] _Atoms = new ATOM[_particleCount];

        // ---------------------------------------- store data in ATOM structure array
        int _k = 0;

        for (int _i = 0; _i < _allLines.Length; _i++)
        {
            if (_allLines[_i].Length > 0)
            {
                string[] _data = _allLines[_i].Split();
                _Atoms[_k]._position = new Vector3(float.Parse(_data[0]), float.Parse(_data[1]), float.Parse(_data[2]));
                _Atoms[_k]._radius   = float.Parse(_data[3]);
                _Atoms[_k]._rgb      = new Color(float.Parse(_data[4]), float.Parse(_data[5]), float.Parse(_data[6]), 1);
                _k++;
            }
        }

        // ---------------------------------------- Initialize the compute buffer and set the ATOM structure
        _cBuffer_render = new ComputeBuffer(_particleCount, Marshal.SizeOf(typeof(ATOM)));
        _cBuffer_render.SetData(_Atoms);
        // ---------------------------------------- Set compute buffer to material
        _mat_particle.SetBuffer("_atoms", _cBuffer_render);
    }
Пример #4
0
        public bool RegisterWindowClass()
        {//此处错误,不是注册ClassEx
            WNDCLASSEX wc = new WNDCLASSEX();

            wc.style       = GetClassStyle();
            wc.cbClsExtra  = 0;
            wc.cbWndExtra  = 0;
            wc.hIcon       = IntPtr.Zero;
            wc.lpfnWndProc = __WndProc;
            wc.hInstance   = DuiUIManager.GetInstance();
            wc.hCursor     = NativeMethods.LoadCursor(IntPtr.Zero, (UINT)CursorType.IDC_ARROW);
            int COLOR_WINDOW = 5;

            wc.hbrBackground = new IntPtr(COLOR_WINDOW + 1);
            wc.lpszMenuName  = null;
            wc.lpszClassName = GetWindowClassName();
            ATOM ret = NativeMethods.RegisterClassEx(ref wc);

            Debug.Assert(Marshal.GetLastWin32Error() == ERROR_CLASS_ALREADY_EXISTS);
            return(Marshal.GetLastWin32Error() == ERROR_CLASS_ALREADY_EXISTS);
        }
Пример #5
0
 public static extern uint GlobalGetAtomName(ATOM atom, StringBuilder strAtomName, int cbSize);
Пример #6
0
 public static extern ATOM GlobalDeleteAtom(ATOM a);
Пример #7
0
            public override void BuildFromStream(Stream strm, long length)
            {
                long p = 0;

                while (p < length)
                {
                    byte[] header = new byte[NODE_LIST_HEADER_SIZE];
                    strm.Read(header, 0, NODE_LIST_HEADER_SIZE);
                    uint atom_size = BEToUInt32(header, 0) - NODE_LIST_HEADER_SIZE;
                    string atom_name = Encoding.ASCII.GetString(header, 4, 4);
                    p += atom_size + NODE_LIST_HEADER_SIZE;

                    long initial_pos = strm.Position;
                    ATOM atom = null;
                    switch (atom_name)
                    {
                        case "ftyp":
                            atom = new ATOM_ftyp();
                            break;
                        case "moov":
                            atom = new ATOM_moov();
                            break;
                        case "trak":
                            atom = new ATOM_moov();
                            break;
                        case "mdia":
                            atom = new ATOM_mdia();
                            break;
                        case "minf":
                            atom = new ATOM_minf();
                            break;
                        case "stbl":
                            atom = new ATOM_stbl();
                            break;
                        case "stco":
                            atom = new ATOM_stco();
                            break;
                        case "udta":
                            atom = new ATOM_udta();
                            break;
                        case "meta":
                            atom = new ATOM_meta();
                            break;
                        case "ilst":
                            atom = new ATOM_ilst();
                            break;
                        case "data":
                            atom = new ATOM_data();
                            break;
                        case "trkn":
                            atom = new ATOM_trkn();
                            break;
                        case "disk":
                            atom = new ATOM_disk();
                            break;
                        case "covr":
                            atom = new ATOM_covr();
                            break;
                        case "----":
                            atom = new ATOM_____();
                            break;
                        case "ID32":
                            atom = new ATOM_ID32();
                            break;
                        case "hdlr":
                            atom = new ATOM_hdlr();
                            break;
                        //                        case "name":
//                            atom = new ATOM_name();
//                            break;
//                        case "mean":
//                            atom = new ATOM_mean();
//                            break;
                        default:
                            switch (BitConverter.ToUInt32(header, 4)) // NOTICE: for Little Endian
                            {
                                case 0x545241A9: // .ART Artist
                                    atom = new ATOM__ART();
                                    break;
                                case 0x6D616EA9: // .nam Track
                                    atom = new ATOM__nam();
                                    break;
                                case 0x626C61A9: // .alb Album
                                    atom = new ATOM__alb();
                                    break;
                                case 0x6E6567A9: // .gen Genre
                                    atom = new ATOM__gen();
                                    break;
                                case 0x796164A9: // .dat Date
                                    atom = new ATOM__dat();
                                    break;
                                default:
                                    atom = new ATOM_raw();
//                                    Logger.Debug("There's no rule to read " + atom_name);
                                    break;
                            }
                            break;
                    }
                    try
                    {
                        if (atom != null)
                        {
                            atom.AtomCode = new byte[] { header[4], header[5], header[6], header[7]};
                            this.AddChild(atom);
                            atom.BuildFromStream(strm, atom_size);
                        }
                    }
                    finally
                    {
                        strm.Seek(initial_pos += atom_size, SeekOrigin.Begin);
                    }
                }
            }
Пример #8
0
 public static extern uint GetAtomName(ATOM nAtom, StringBuilder lpBuffer, int nSize);
Пример #9
0
 /// <summary>Retrieves a copy of the character string associated with the specified local atom.</summary>
 /// <param name="nAtom">
 /// <para>Type: <c>ATOM</c></para>
 /// <para>The local atom that identifies the character string to be retrieved.</para>
 /// </param>
 /// <returns>On success, the character string associated with the specified local atom. On failure, <see langword="null"/>.</returns>
 public static string GetAtomName(ATOM nAtom) => FunctionHelper.CallMethodWithStrBuf((sb, sz) => GetAtomName(nAtom, sb, sz), 255, out var result) > 0 ? result : null;
Пример #10
0
 public static extern ATOM DeleteAtom(ATOM nAtom);
Пример #11
0
 public static extern ATOM GlobalDeleteAtom(ATOM nAtom);
Пример #12
0
 public void RemoveATOM(ATOM atom)
 {
     atom.Loc = null;
     ATOMs.Remove(atom.ID);
 }
Пример #13
0
 public void AddATOM(ATOM atom)
 {
     ATOMs.Add(atom.ID, atom);
 }
Пример #14
0
    // Read the data and store it in ATOM structure array
    public void ReadAsciiData()
    { //We associate with Valeur_sup and Y the index in the ATOM table corresponding to the color chosen as parameter in the table
        // Data path
        string _path = Application.dataPath;

        if (Application.platform == RuntimePlatform.OSXPlayer)
        {
            _path += "/../../";
        }
        else if (Application.platform == RuntimePlatform.WindowsEditor)
        {
            _path += "/../";
        }
        else if (Application.platform == RuntimePlatform.WindowsPlayer)
        {
            _path += "/../";
        }
        _path += "file1" +
                 "" +
                 ".txt";

        // ---------------------------------------- Count data rows
        int _particleCount = 0;

        string[] _allLines = File.ReadAllLines(@_path);
        for (int _i = 0; _i < _allLines.Length; _i++)
        {
            if (_allLines[_i].Length > 0)
            {
                _particleCount += nb_bille;
            }
        }

        // ---------------------------------------- Prepare ATOM structure array for data points
        ATOM[] _Atoms = new ATOM[_particleCount];

        // ---------------------------------------- store data in ATOM structure array
        int _k = 0;

        for (int _i = 0; _i < _allLines.Length; _i++)
        {
            for (int _j = 0; _j < nb_bille; _j++)
            {
                if (_allLines[_i].Length > 0)
                {
                    if (grey == false)
                    {
                        string[] _data = _allLines[_i].Split();
                        _Atoms[_k]._position = new Vector3(float.Parse(_data[0]), (CoefRouge * float.Parse(_data[3]) + CoefVert * float.Parse(_data[4]) + CoefBleu * float.Parse(_data[5])) * (_j * decalage_bille + offset), float.Parse(_data[1]));
                        _Atoms[_k]._radius   = taille;
                        _Atoms[_k]._rgb      = new Color(float.Parse(_data[3]), float.Parse(_data[4]), float.Parse(_data[5]), 1F);
                        _k++;
                    }
                    else
                    {
                        string[] _data = _allLines[_i].Split();
                        _Atoms[_k]._position = new Vector3(float.Parse(_data[0]), (0.7152f * float.Parse(_data[4]) + 0.0722f * float.Parse(_data[5]) + 0.2126f * float.Parse(_data[3])) * (_j * decalage_bille + offset), float.Parse(_data[1]));
                        _Atoms[_k]._radius   = taille;
                        _Atoms[_k]._rgb      = new Color(0.7152f * float.Parse(_data[4]) + 0.0722f * float.Parse(_data[5]) + 0.2126f * float.Parse(_data[3]), 0.7152f * float.Parse(_data[4]) + 0.0722f * float.Parse(_data[5]) + 0.2126f * float.Parse(_data[3]), 0.7152f * float.Parse(_data[4]) + 0.0722f * float.Parse(_data[5]) + 0.2126f * float.Parse(_data[3]), 1F);
                        _k++;
                    }
                }
            }
        }

        // ---------------------------------------- Initialize the compute buffer and set the ATOM structure
        _cBuffer_render = new ComputeBuffer(_particleCount, Marshal.SizeOf(typeof(ATOM)));
        _cBuffer_render.SetData(_Atoms);
        // ---------------------------------------- Set compute buffer to material
        _mat_particle.SetBuffer("_atoms", _cBuffer_render);
    }