示例#1
0
        //================================================================================
        private void showDds(byte[] aDds)
        {
            if (aDds == null || aDds.Length < 8)
            {
                return;
            }

            //is link?:
            if (CajDDS.isDdsGgpkLink(aDds))
            {
                var link = Encoding.UTF8.GetString(aDds, 1, aDds.Length - 1);
                link = link.ToLower(CultureInfo.InvariantCulture);
                link = link.Replace('/', '\\');
                link = "root\\" + link;
                var node = CajApp.getNode(link);
                if (node != null)
                {
                    showDds(CajApp.getByteValueOfNode(link));
                }
                else
                {
                    setTxtValueText("incorrect dds link");
                }
                return;
            }

            //info:
            var sb = new StringBuilder();

            sb.Append("converting dds.");
            int len = aDds.Length;

            if (len > 100 * 1024)
            {
                sb.Append(" size: ");
                sb.Append(len);
                sb.Append(" bytes. Wait please...");
            }
            else
            {
                sb.Append("..");
            }
            setTxtValueText(sb.ToString());

            //cut, decode, convert, can be slow:
            stopThread(thDdsConvert);
            thDdsConvert = new Thread(() => {
                CajDDS.getBitmap(aDds, onDdsConvertFinish);
            });
            thDdsConvert.Start();
        }
示例#2
0
        //================================================================================
        private void onNewSelectedItem(string selName, string key)
        {
            txtValue.Text          = "";
            picValue.Visible       = false;
            mnuSavePicture.Enabled = false;

            if (CajApp.getNode("root\\" + selName) != null ||
                CajApp.getNode(selName) != null)
            {
                if (isExtensionInList(selName, aPictureExtensions))
                {
                    showPicture(CajApp.getByteValueOfNode(key));
                }
                else if (selName.EndsWith(".dds", StringComparison.InvariantCultureIgnoreCase))
                {
                    showDds(CajApp.getByteValueOfNode(key));
                }
                else if (isExtensionInList(selName, aIgnoredExtensions))
                {
                    setTxtValueText("[binary type]");
                }
                else
                {
                    bool isText     = isExtensionInList(selName, aTextFileExtensions);
                    var  dataLength = CajApp.getNodesDataLength(key);

                    if (dataLength > MAX_TEXT_LENGTH_TO_READ ||
                        (!isText && dataLength > MAX_TEXT_LENGTH_TO_SHOW))
                    {
                        onTooBigFile();
                    }
                    else
                    {
                        //most interesting files are text files, so show them as text:
                        setTxtValueText(CajApp.getValueOfNode(key));
                    }
                }
            }

            txtValue.SelectionStart = 0;
            txtValue.ScrollToCaret();
            mnuFile.Enabled     = true;
            txtStatusLabel.Text = "Found: " + foundItems.ToString() +
                                  ". Selected: " + selName;
            Debug.WriteLine(selName);
        }