void UpdateSelectedType()
        {
            Metadata.TypeInfo newType = null;
            bool newTypeCanSelect     = false;

            ContentBrowser.Item item = null;
            if (contentBrowser1.SelectedItems.Length != 0)
            {
                item = contentBrowser1.SelectedItems[0];
            }

            if (item != null)
            {
                item.CalculateReferenceValue(null, MetadataManager.GetTypeOfNetType(typeof(Metadata.TypeInfo)),
                                             out string referenceValue, out bool canSet);

                if (canSet)
                {
                    if (!string.IsNullOrEmpty(referenceValue))
                    {
                        newType = (Metadata.TypeInfo)MetadataManager.GetValueByReference(
                            contentBrowser1.SetReferenceModeData.demandedType.GetNetType(), null, referenceValue);
                        newTypeCanSelect = true;
                    }
                    else
                    {
                        newTypeCanSelect = true;
                    }
                }

                //check can be selected
                if (newType != null && !creationData.initDemandedType.IsAssignableFrom(newType))
                {
                    newType          = null;
                    newTypeCanSelect = false;
                }
            }

            //change
            if (selectedType != newType || selectedTypeCanSelect != newTypeCanSelect)
            {
                selectedType          = newType;
                selectedTypeCanSelect = newTypeCanSelect;
                SelectedTypeChanged();
            }
        }
        void UpdateSelectedType()
        {
            Metadata.TypeInfo newType = null;

            ContentBrowser.Item item = null;
            if (contentBrowser1.SelectedItems.Length != 0)
            {
                item = contentBrowser1.SelectedItems[0];
            }

            if (item != null)
            {
                item.CalculateReferenceValue(null, MetadataManager.GetTypeOfNetType(typeof(Metadata.TypeInfo)),
                                             out string referenceValue, out bool canSet);

                if (!string.IsNullOrEmpty(referenceValue) && canSet)
                {
                    newType = (Metadata.TypeInfo)MetadataManager.GetValueByReference(
                        contentBrowser1.SetReferenceModeData.demandedType.GetNetType(), null, referenceValue);
                }

                //check can be selected
                if (newType != null)
                {
                    if (!MetadataManager.GetTypeOfNetType(typeof(Component)).IsAssignableFrom(newType) &&
                        !MetadataManager.GetTypeOfNetType(typeof(NewResourceType)).IsAssignableFrom(newType))
                    {
                        newType = null;
                    }
                }
            }

            //change
            if (selectedType != newType)
            {
                selectedType = newType;
                SelectedTypeChanged();
            }
        }
        void UpdateSelectedReference()
        {
            //!!!!не только компоненты?

            //!!!!multiselection
            ContentBrowser.Item item = null;
            if (contentBrowser1.SelectedItems.Length != 0)
            {
                item = contentBrowser1.SelectedItems[0];
            }

            string newSelection = null;
            bool   canSet       = false;

            if (item != null)
            {
                //!!!!multiselection?

                item.CalculateReferenceValue(setReferenceModeData.selectedComponents[0], setReferenceModeData.property.TypeUnreferenced, out newSelection, out canSet);

                //make relative file path
                if (kryptonCheckBoxCanMakeRelativeFilePath.Checked && !string.IsNullOrEmpty(newSelection))
                {
                    if (!newSelection.Contains(':'))                       //ignore references
                    {
                        var fromResource       = ComponentUtility.GetOwnedFileNameOfComponent(setReferenceModeData.selectedComponents[0]);
                        var fromResourceFolder = "";
                        if (!string.IsNullOrEmpty(fromResource))
                        {
                            fromResourceFolder = Path.GetDirectoryName(fromResource);
                        }

                        int commonChars = GetEqualPart(new string[] { fromResourceFolder, newSelection });

                        var path = "";

                        //go up (dots)
                        {
                            var c = fromResourceFolder.Substring(commonChars).Split(new char[] { '\\', '/' }, StringSplitOptions.RemoveEmptyEntries).Length;
                            for (int n = 0; n < c; n++)
                            {
                                path = Path.Combine(path, "..");
                            }
                        }

                        //go down
                        {
                            var s = newSelection.Substring(commonChars);
                            if (s.Length != 0 && (s[0] == '\\' || s[0] == '/'))
                            {
                                s = s.Substring(1);
                            }

                            //can't use Path.Combine, invalid character exception
                            if (path.Length != 0 && path[path.Length - 1] != '\\' && path[path.Length - 1] != '/')
                            {
                                path += "\\";
                            }
                            path += s;
                            //path = Path.Combine( path, s );
                        }

                        newSelection = "relative:" + path;
                    }
                }
            }

            //update
            selectedReference       = newSelection;
            selectedReferenceCanSet = canSet;
            UpdateSetButtons();
            UpdateTextBox();
            TextBoxSetError(false);
            ////change
            //if( string.Compare( selectedReference, newSelection ) != 0 )
            //{
            //	selectedReference = newSelection;
            //	selectedReferenceCanSet = canSet;
            //	SelectedReferenceChanged();
            //}
        }