Exemple #1
0
        private void ListViewSGLFrame_SelectedIndexChanged(object sender, EventArgs e)
        {
            if (ListViewSGLImage.SelectedIndices.Count > 1)
            {
                return;
            }
            else if (ListViewSGLImage.SelectedIndices.Count < 1)
            {
                if (PageCurrentImageControl.WorkspaceViewer.Image != null)
                {
                    PageCurrentImageControl.WorkspaceViewer.Image = null;
                }
            }

            if (ListViewSGLFrame.SelectedIndices.Count > 1)
            {
                return;
            }
            else if (ListViewSGLFrame.SelectedIndices.Count < 1)
            {
                if (PageCurrentImageControl.WorkspaceViewer.Image != null)
                {
                    PageCurrentImageControl.WorkspaceViewer.Image = null;
                }
            }

            foreach (int index in ListViewSGLImage.SelectedIndices)
            {
                SGLImage sglImage = m_SglFileInfo.SGLImage[index];

                foreach (int index2 in ListViewSGLFrame.SelectedIndices)
                {
                    SGLFrame sglFrame = sglImage.SGLFrames[index2];

                    ShowImage(sglImage, sglFrame);
                }
            }
        }
Exemple #2
0
        public void BuildPath()
        {
#if !DEMO
            MessageBox.Show("请确保打开的sgl文件名与传奇世界的文件名是对应的,否则产生应用补丁将无法找到该相同文件名!");
            if (m_AddPathList.Count <= 0)
            {
                return;
            }

            //show the save dialog
            m_SaveFileDialog.DefaultExt       = "patch";
            m_SaveFileDialog.Filter           = "Path Data (*.patch)|*.patch";
            m_SaveFileDialog.RestoreDirectory = true;

            if (m_SaveFileDialog.ShowDialog() == DialogResult.OK)
            {
                using (FileStream fileStream = File.Create(m_SaveFileDialog.FileName))
                {
                    byte[] byteSglFileName = Encoding.Unicode.GetBytes(Path.GetFileName(m_SglFileName));

                    byte[] byteUINT = new byte[sizeof(uint)];

                    // FileName string Length
                    byteUINT[0] = (byte)(byteSglFileName.Length & 0xFF);
                    byteUINT[1] = (byte)((byteSglFileName.Length & 0xFF00) >> 8);
                    byteUINT[2] = (byte)((byteSglFileName.Length & 0xFF0000) >> 16);
                    byteUINT[3] = (byte)((byteSglFileName.Length & 0xFF000000) >> 24);
                    fileStream.Write(byteUINT, 0, byteUINT.Length);

                    fileStream.Write(byteSglFileName, 0, byteSglFileName.Length);

                    // Path Count
                    byteUINT[0] = (byte)(m_AddPathList.Count & 0xFF);
                    byteUINT[1] = (byte)((m_AddPathList.Count & 0xFF00) >> 8);
                    byteUINT[2] = (byte)((m_AddPathList.Count & 0xFF0000) >> 16);
                    byteUINT[3] = (byte)((m_AddPathList.Count & 0xFF000000) >> 24);
                    fileStream.Write(byteUINT, 0, byteUINT.Length);

                    foreach (KeyValuePair <int, CommandBarControl> intItem in m_AddPathList)
                    {
                        // Image index
                        byteUINT[0] = (byte)(intItem.Key & 0xFF);
                        byteUINT[1] = (byte)((intItem.Key & 0xFF00) >> 8);
                        byteUINT[2] = (byte)((intItem.Key & 0xFF0000) >> 16);
                        byteUINT[3] = (byte)((intItem.Key & 0xFF000000) >> 24);
                        fileStream.Write(byteUINT, 0, byteUINT.Length);

                        SGLImage sglImage   = m_SglFileInfo.SGLImage[intItem.Key];
                        byte[]   byteBuffer = sglImage.GetOriginBuffer();
                        if (byteBuffer == null)
                        {
                            // Buffer Length
                            byteUINT[0] = (byte)(0 & 0xFF);
                            byteUINT[1] = (byte)((0 & 0xFF00) >> 8);
                            byteUINT[2] = (byte)((0 & 0xFF0000) >> 16);
                            byteUINT[3] = (byte)((0 & 0xFF000000) >> 24);
                            fileStream.Write(byteUINT, 0, byteUINT.Length);

                            continue;
                        }
                        else if (byteBuffer.Length <= 0)
                        {
                            // Buffer Length
                            byteUINT[0] = (byte)(0 & 0xFF);
                            byteUINT[1] = (byte)((0 & 0xFF00) >> 8);
                            byteUINT[2] = (byte)((0 & 0xFF0000) >> 16);
                            byteUINT[3] = (byte)((0 & 0xFF000000) >> 24);
                            fileStream.Write(byteUINT, 0, byteUINT.Length);

                            continue;
                        }
                        else
                        {
                            // Buffer Length
                            byteUINT[0] = (byte)(byteBuffer.Length & 0xFF);
                            byteUINT[1] = (byte)((byteBuffer.Length & 0xFF00) >> 8);
                            byteUINT[2] = (byte)((byteBuffer.Length & 0xFF0000) >> 16);
                            byteUINT[3] = (byte)((byteBuffer.Length & 0xFF000000) >> 24);
                            fileStream.Write(byteUINT, 0, byteUINT.Length);

                            // Buffer
                            fileStream.Write(byteBuffer, 0, byteBuffer.Length);
                        }
                    }
                }
            }
#else
            MessageBox.Show(SGLEditorDocumentForm.TryMessageInfo);
#endif
        }
Exemple #3
0
        /// <summary>
        ///
        /// </summary>
        public void InsertImage()
        {
#if !DEMO
            int x = 0;
            if (int.TryParse(PageOpenImageControl.axFlatEditX.Text, out x) == false)
            {
                MessageBox.Show("打开的图像帧的面板中,中心X输入框中输入的数字");
                return;
            }
            int y = 0;
            if (int.TryParse(PageOpenImageControl.axFlatEditY.Text, out y) == false)
            {
                MessageBox.Show("打开的图像帧的面板中,中心Y输入框中输入的数字");
                return;
            }

            if (ListViewSGLImage.SelectedIndices.Count != 1)
            {
                return;
            }

            byte[] imageBuffer = GetImageData();
            if (imageBuffer == null)
            {
                return;
            }


            foreach (int index in ListViewSGLImage.SelectedIndices)
            {
                SGLImage sglImage = m_SglFileInfo.SGLImage[index];

                foreach (SGLFrame sglFrame in sglImage.SGLFrames)
                {
                    if (sglFrame.SGLFrameFormat11Or12Or22.DecodeFrame32Stream == null)
                    {
                        if (sglFrame.SGLFrameFormat11Or12Or22.LoadImage() == false)
                        {
                            break;
                        }
                    }
                }

                m_SglFileInfo.InsertImage(index, imageBuffer, x, y);

                int iIndex = 0;
                ListViewSGLFrame.Items.Clear();
                foreach (SGLFrame sglFrame in sglImage.SGLFrames)
                {
                    ListViewItem listViewItem = new ListViewItem(iIndex.ToString(), 0);
                    listViewItem.SubItems.Add(sglFrame.FrameWidth.ToString());
                    listViewItem.SubItems.Add(sglFrame.FrameHeight.ToString());
                    listViewItem.SubItems.Add(sglFrame.CenterX.ToString());
                    listViewItem.SubItems.Add(sglFrame.CenterY.ToString());
                    listViewItem.SubItems.Add(sglFrame.BlocksX.ToString());
                    listViewItem.SubItems.Add(sglFrame.BlocksY.ToString());

                    ListViewSGLFrame.Items.Add(listViewItem);

                    if (iIndex == 0)
                    {
                        ShowImage(sglImage, sglFrame);
                    }

                    iIndex++;
                }

                ListViewSGLImage.Items[index].SubItems[1].Text = "18";
                ListViewSGLImage.Items[index].SubItems[2].Text = sglImage.SGLFrames.Length.ToString();
                ListViewSGLImage.RedrawItems(index, index, true);
            }
#else
            MessageBox.Show(TryMessageInfo);
#endif
        }