Ejemplo n.º 1
0
        //================================================================================
        private ListViewItem getItemView(string item)
        {
            if (aParticleFilePaths == null)
            {
                Debug.WriteLine("getItemView.aTabCheckResults == null");
                return(defaultCheckListItem);
            }
            var    res = new string[2];
            string sEmitters;
            var    node = CajApp.getNode(item);

            if (node != null)
            {
                //getting cache value, it's fast:
                int iEmitters = CajApp.recordsChanger.getEmittersNumber(node);
                sEmitters = iEmitters.ToString();
            }
            else
            {
                Debug.WriteLine("getItemView.node == null: " +
                                item + ", " + aParticleFilePaths.Count);
                sEmitters = "?";
            }
            res[0] = sEmitters;
            res[1] = item;
            return(new ListViewItem(res));
        }
Ejemplo n.º 2
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();
        }
Ejemplo n.º 3
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);
        }
Ejemplo n.º 4
0
        //================================================================================
        private void updateCheckList()
        {
            aParticleFilePaths = CajApp.getParticleFilePaths();
            if (aParticleFilePaths == null)
            {
                return;
            }

            string filter   = txtCheckListFilter.Text;
            Thread thFilter = null;

            if (filter != "" && filter != "filter")
            {
                filter = filter.ToLower(CultureInfo.InvariantCulture);
                //check if format rule set:
                bool isSeparatorMore   = false;
                bool isSeparatorEquals = false;
                bool isSeparatorLess   = false;
                var  separator         = filter.IndexOf("e>", StringComparison.InvariantCulture);
                if (separator != -1)
                {
                    isSeparatorMore = true;
                }
                else
                {
                    separator = filter.IndexOf("e=", StringComparison.InvariantCulture);
                    if (separator != -1)
                    {
                        isSeparatorEquals = true;
                    }
                    else
                    {
                        separator = filter.IndexOf("e<", StringComparison.InvariantCulture);
                        if (separator != -1)
                        {
                            isSeparatorLess = true;
                        }
                    }
                }
                //check filter:
                if (separator == -1)
                {
                    //filter by path text: fast, nn thread:
                    var aFiltered = new List <string>();
                    foreach (var r in aParticleFilePaths)
                    {
                        if (r.Contains(filter))
                        {
                            aFiltered.Add(r);
                        }
                    }
                    aParticleFilePaths = aFiltered;
                }
                else
                {
                    //filter by emitters+:
                    enableActions(false);
                    thFilter = new Thread(() => {
                        int filterEmitters = -1;
                        int.TryParse(filter.Substring(separator + 2), out filterEmitters);
                        if (filterEmitters >= 0)
                        {
                            var aFiltered = new List <string>();
                            foreach (var r in aParticleFilePaths)
                            {
                                var node = CajApp.getNode(r);
                                if (node != null)
                                {
                                    int iEmitters = CajApp.recordsChanger.getEmittersNumber(node);
                                    if ((isSeparatorMore && iEmitters > filterEmitters) ||
                                        (isSeparatorEquals && iEmitters == filterEmitters) ||
                                        (isSeparatorLess && iEmitters < filterEmitters)
                                        )
                                    {
                                        aFiltered.Add(r);
                                    }
                                }
                            }
                            aParticleFilePaths = aFiltered;
                        }
                        Invoke(new Action(() => {
                            onFilterQueryEnd();
                        }));
                        enableActions(true);
                    });
                }
            }

            if (thFilter != null)
            {
                thFilter.Start();
                if (isFirstFilterRuleSearch)
                {
                    isFirstFilterRuleSearch = false;
                    MessageBox.Show("This is the first filter rule search." +
                                    Environment.NewLine + "It can take up to 10 seconds, please wait." +
                                    Environment.NewLine + Environment.NewLine +
                                    "Next queries should be instant until you close the app.",
                                    "poeNullEffects :: format query");
                }
            }
            else
            {
                onFilterQueryEnd();
            }
        }