public int CompareTo(object obj) { IComparer _comp = new StringLogicalComparer(); //System.Collections.IComparer _comp = System.Collections.Comparer.Default; return(_comp.Compare(ToString(), obj.ToString())); }
/// <summary> /// This method is inherited from the IComparer interface. It compares the two objects passed using a case insensitive comparison. /// </summary> /// <param name="x">First object to be compared</param> /// <param name="y">Second object to be compared</param> /// <returns>The result of the comparison. "0" if equal, negative if 'x' is less than 'y' and positive if 'x' is greater than 'y'</returns> public int Compare(object x, object y) { int compareResult; ListViewItem listviewX, listviewY; // Cast the objects to be compared to ListViewItem objects listviewX = (ListViewItem)x; listviewY = (ListViewItem)y; // Compare the two items compareResult = StringLogicalComparer.Compare(listviewX.SubItems[ColumnToSort].Text, listviewY.SubItems[ColumnToSort].Text); // Calculate correct return value based on object comparison if (OrderOfSort == SortOrder.Ascending) { // Ascending sort is selected, return normal result of compare operation return(compareResult); } else if (OrderOfSort == SortOrder.Descending) { // Descending sort is selected, return negative result of compare operation return(-compareResult); } else { // Return '0' to indicate they are equal return(0); } }
private void TreeProjectFiles_CustomColumnSort(object sender, CustomColumnSortEventArgs e) { if (e.NodeValue1 is string && e.NodeValue2 is string) { e.Result = StringLogicalComparer.Compare(Convert.ToString(e.NodeValue1), Convert.ToString(e.NodeValue2)); } }
public int Compare(object x, object y) { if ((x is string) && (y is string)) { return StringLogicalComparer.Compare((string)x, (string)y); } return -1; }
public int Compare(object x, object y) { if ((x is TreeNode) && (y is TreeNode)) { return(StringLogicalComparer.Compare(((TreeNode)x).Text, ((TreeNode)y).Text)); } return(-1); }
public int Compare(object x, object y) { var info = x as PhysicalControlInfo; if (info != null && y is PhysicalControlInfo) { return(StringLogicalComparer.Compare(info.Alias, ((PhysicalControlInfo)y).Alias)); } return(-1); }
public int Compare(object x, object y) { var node = x as TreeNode; if (node != null && y is TreeNode) { return(StringLogicalComparer.Compare(node.Text, ((TreeNode)y).Text)); } return(-1); }
public static int Compare(Object x, Object y) { var xs = Convert.ToString(x); var ys = Convert.ToString(y); if (String.IsNullOrEmpty(xs) && String.IsNullOrEmpty(ys)) { return(0); } var xDate = DataConverter.ToNullableDateTime(x); var yDate = DataConverter.ToNullableDateTime(y); if (xDate != null && yDate != null) { return(xDate.Value.CompareTo(yDate.Value)); } if (xDate != null && yDate == null && String.IsNullOrEmpty(ys)) { return(1); } if (yDate != null && xDate == null && String.IsNullOrEmpty(xs)) { return(-1); } var xNum = DataConverter.ToNullableDouble(x); var yNum = DataConverter.ToNullableDouble(y); if (xNum != null && yNum != null) { return(xNum.Value.CompareTo(yNum.Value)); } if (xNum != null && yNum == null && String.IsNullOrEmpty(ys)) { return(1); } if (yNum != null && xNum == null && String.IsNullOrEmpty(xs)) { return(-1); } var order = ordinalComparer.Compare(xs, ys); if (order != 0) { order = defaultComparer.Compare(xs, ys); } return(order); }
public int Compare(DataObjectFriend x, DataObjectFriend y) { if (!blnDesc) { return(StringLogicalComparer.Compare(x.Nickname, y.Nickname)); } else { return(StringLogicalComparer.Compare(y.Nickname, x.Nickname)); } }
protected static string GetProcessPath(bool isScript) { var rKey = Registry.CurrentUser.OpenSubKey(@"SOFTWARE\R-core\R64"); if (rKey == null) { rKey = Registry.LocalMachine.OpenSubKey(@"SOFTWARE\R-core\R64"); } bool is_x64 = rKey != null; if (rKey == null) { rKey = Registry.CurrentUser.OpenSubKey(@"SOFTWARE\R-core\R"); } if (rKey == null) { rKey = Registry.LocalMachine.OpenSubKey(@"SOFTWARE\R-core\R"); } if (rKey == null) { return(null); } string path = null; try { path = Convert.ToString(rKey.GetValue("InstallPath")); var version = Convert.ToString(rKey.GetValue("Current Version")); path = Path.Combine(path, "bin"); if (StringLogicalComparer.Compare(version, "2.12.0.0", true) >= 0) { path = Path.Combine(path, is_x64 ? "x64" : "i386"); } var cmdFile = isScript ? "Rscript.exe" : "Rterm.exe"; path = Path.Combine(path, cmdFile); } finally { rKey.Close(); } return(path); }
public int Compare(TaggedText x, TaggedText y) { if (Column < 1 || Column >= x.Fields.Length + 1) { return(0); } int result = StringLogicalComparer.Compare( x.Fields[Column - 1], y.Fields[Column - 1]); // If the sort order is descending then return inverted // value that was returned by String.Compare. // return(Sorting == SortOrder.Descending ? -result : result); }
private void _sort() { if (this.Count < 2) { return; } Action <int, int> sort = null; sort = (low, high) => { int i = low; int j = high; ConnectionViewModel m = this[(i + j) / 2]; do { while (StringLogicalComparer.Compare(this[i].Name, m.Name) < 0) { i++; } while (StringLogicalComparer.Compare(this[j].Name, m.Name) > 0) { j--; } if (i <= j) { ConnectionViewModel temp = this[i]; this[i] = this[j]; this[j] = temp; i++; j--; } } while (i <= j); if (low < j) { sort(low, j); } if (i < high) { sort(i, high); } }; sort(0, this.Count - 1); }
public int CompareTo(TableBlock other) { //sort by group, object type, name, modified int groupComparison = this.Group.CompareTo(other.Group); if (groupComparison == 0) { int objectTypeComparison = this.ObjectType.CompareTo(other.ObjectType); if (objectTypeComparison == 0) { int nameComparison = StringLogicalComparer.Compare(this.Name, other.Name); if (nameComparison == 0) { return(this.Modified.CompareTo(other.Modified)); } return(nameComparison); } return(objectTypeComparison); } return(groupComparison); }
public ScriptEditorPopupForm(SyntaxBoxControl editor, ScriptIntellisense intellisense) { InitializeComponent(); _Editor = editor; _Intellisense = intellisense; if (_Intellisense.Help != null && (_Intellisense.Help.SupportsHelp || _Intellisense.Help.SupportsOnlineHelp)) { if (_Intellisense.Help.SupportsHelp && _Intellisense.Help.SupportsOnlineHelp) { lblComments.Text = "Press<b>F1</b> for more help, <b>F2</b> for online help"; } else if (_Intellisense.Help.SupportsHelp) { lblComments.Text = "Press<b>F1</b> for more help"; } else if (_Intellisense.Help.SupportsOnlineHelp) { lblComments.Text = "Press <b>F2</b> for online help"; } } else { lblComments.Visible = false; } _StartSearchPosition = new TextPoint() { X = _Editor.Caret.Position.X, Y = _Editor.Caret.Position.Y }; _StartSearchPosition.X = FindStartSymbol(_Editor.Caret.CurrentRow.Text, Math.Max(_StartSearchPosition.X - 1, 0), intellisense.UsePeriodInIntellisense, out _LastPartStart); _Intellisense.Items.Sort((x, y) => { if (x.DisplayOrder != y.DisplayOrder) { return(x.DisplayOrder.CompareTo(y.DisplayOrder)); } if (x.IsMandatory.CompareTo(y.IsMandatory) != 0) { return(-x.IsMandatory.CompareTo(y.IsMandatory)); } if (x.Position.HasValue && !y.Position.HasValue) { return(-1); } if (!x.Position.HasValue && y.Position.HasValue) { return(1); } if (x.Position.HasValue && y.Position.HasValue && x.Position.Value.CompareTo(y.Position.Value) != 0) { return(x.Position.Value.CompareTo(y.Position.Value)); } return(StringLogicalComparer.Compare(x.Caption, y.Caption)); }); Grid.DataSource = _Intellisense.Items; lblDescription.DataBindings.Add(nameof(lblDescription.Text), _Intellisense.Items, nameof(ScriptIntellisenseItem.Description)); _Editor.CaretChange += new EventHandler(Editor_CaretChange); }
public int Compare(string x, string y) { return(StringLogicalComparer.Compare(x, y)); }
public int CompareTo(object obj) { return(StringLogicalComparer.Compare(Text, ((DbSchemaBaseNode)obj)?.Text)); }
public override int Compare(string param1, string param2) { return(StringLogicalComparer.Compare(param1, param2, false)); }