예제 #1
0
        /// ------------------------------------------------------------------------------------
        public int  Compare(LocTreeNode <T> x, LocTreeNode <T> y)
        {
            string xText = string.Empty;
            string yText = string.Empty;

            var prefixToRemove = (x.TreeView != null && x.TreeView.SelectedNode != null ?
                                  x.TreeView.SelectedNode.Name : string.Empty);

            const string kNonsenseIfNoPrefixExists = "5%ij#a";             //replace fails if the pattern is "", so use this

            if (string.IsNullOrEmpty(prefixToRemove))
            {
                prefixToRemove = kNonsenseIfNoPrefixExists;
            }

            var ci = CultureInfo.GetCultureInfo("en");

            switch ((int)_sortField)
            {
            case 0:
                xText = x.Id.Replace(prefixToRemove, string.Empty).Trim('.');
                yText = y.Id.Replace(prefixToRemove, string.Empty).Trim('.');
                break;

            case 1:
                xText = x.GetText(_srcLangId) ?? string.Empty;
                yText = y.GetText(_srcLangId) ?? string.Empty;
                ci    = CultureInfo.GetCultureInfo(_srcLangId);
                break;

            case 2:
                xText = (x.GetTranslatedText(_tgtLangId) ?? x.GetText(_tgtLangId)) ?? string.Empty;
                yText = (y.GetTranslatedText(_tgtLangId) ?? y.GetText(_tgtLangId)) ?? string.Empty;
                ci    = CultureInfo.GetCultureInfo(_tgtLangId);
                break;

            case 3:
                xText = x.GetToolTip(_srcLangId) ?? string.Empty;
                yText = y.GetToolTip(_srcLangId) ?? string.Empty;
                ci    = CultureInfo.GetCultureInfo(_srcLangId);
                break;

            case 4:
                xText = (x.GetTranslatedToolTip(_tgtLangId) ?? x.GetToolTip(_tgtLangId)) ?? string.Empty;
                yText = (y.GetTranslatedToolTip(_tgtLangId) ?? y.GetToolTip(_tgtLangId)) ?? string.Empty;
                ci    = CultureInfo.GetCultureInfo(_tgtLangId);
                break;
            }

            return(_sortOrder == SortOrder.Ascending ?
                   string.Compare(xText, yText, false, ci) :
                   string.Compare(yText, xText, false, ci));
        }
예제 #2
0
        /// ------------------------------------------------------------------------------------
        public void SaveChangesInMemory(LocTreeNode node, LocalizingInfo locInfo)
        {
            if (locInfo == null || locInfo.Id == null ||
                locInfo.UpdateFields == UpdateFields.None || _tgtLangId == _srcLangId)
            {
                return;
            }

            if (locInfo.Text == (node.GetText(_tgtLangId) ?? string.Empty) &&
                locInfo.ToolTipText == (node.GetToolTip(_tgtLangId) ?? string.Empty) &&
                locInfo.ShortcutKeys == (node.GetShortcutKeys(_tgtLangId) ?? string.Empty))
            {
                return;
            }

            locInfo.LangId = _tgtLangId;
            _modifiedLanguages.Add(_tgtLangId);

            if (!node.SavedTranslationInfo.ContainsKey(_tgtLangId))
            {
                node.SavedTranslationInfo[_tgtLangId] = locInfo;
            }
            else
            {
                if ((locInfo.UpdateFields & UpdateFields.Text) == UpdateFields.Text)
                {
                    node.SavedTranslationInfo[_tgtLangId].Text = (locInfo.Text == string.Empty ? null : locInfo.Text);
                }

                if ((locInfo.UpdateFields & UpdateFields.ToolTip) == UpdateFields.ToolTip)
                {
                    node.SavedTranslationInfo[_tgtLangId].ToolTipText = (locInfo.ToolTipText == string.Empty ? null : locInfo.ToolTipText);
                }

                if ((locInfo.UpdateFields & UpdateFields.ShortcutKeys) == UpdateFields.ShortcutKeys)
                {
                    node.SavedTranslationInfo[_tgtLangId].ShortcutKeys = (locInfo.ShortcutKeys == string.Empty ? null : locInfo.ShortcutKeys);
                }

                if ((locInfo.UpdateFields & UpdateFields.Comment) == UpdateFields.Comment)
                {
                    node.SavedComment = (locInfo.Comment == string.Empty ? null : locInfo.Comment);
                }

                node.SavedTranslationInfo[_tgtLangId].UpdateFields |= locInfo.UpdateFields;
            }
        }