ReSharper changes intellisense behaviour when initilizing objects - visual-studio-2010

Let's assume I have a class
public class Dummy
{
public int DummyInt { get; set; }
public string DummyString { get; set; }
}
and somewhere in the code I have:
var dummy = new Dummy
{
In VS10, if I press now 'a' I will get a list of members: DummyInt,DummyString. But with ReSharper switched on nothing will be shown if I press 'a'. I must press 'd' to get both fields listed.
I went through ReSharper options, but I can't find it anywhere. Is it possible to switch that off?
R# 7.1

Resharper offers a couple different symbol completions. The basic one is called Symbol Completion and has a default key binding of Ctrl-Space. The more intelligent one is called Smart Completion and has a default key binding of Ctrl-Shift-Space.

Related

Xamarin Memory Limitation or?

Can anyone tell me if they have run into any "memory" limitations with Xamarin Forms App for Android?
I recently decided to give Xamarin another go... A few years back I ran into far too many hurdles and went a different route. I hoped things had changed.
I have an empty Xamarin Forms App for Android ONLY at this point (no OSX or UWP support). I created and updated the initial app (4.3 Xamarin Forms). I modified the mainpage.xaml and the mainpage.xaml.cs. Simple 3 row grid... 2 columns... first row, small header image centered columnspan="2"... Second row is also centered, with a CollectionView to "horizontally" scroll some simple small icon/images... Third row of gird is for detail (not yet implemented). So, with this, you can see the application is still quite small and has no real magic going on... Here is the delimma...
I have 8 c# Objects that are a c# Class... I began building the application using a simplified version of the class... Name, and ImageName only for the purpose of testing the 4.3 CollectionView for a navigation UI... After I had the functionality I wanted and it was running and tested for deployment to device, Everything seemed fine... So, I continued and built out the full class objects (13 fields, all strings no real data entered, just empty quotes for value = "". The only fields I have filled in are the original Name and ImageName is code read only... Running the App in the emulator, it now fails on load... and the emulator asks if I would like to close or try and reload...
It seems that my display class, when the class has more than the first few fields filled in causes some sort of overload:
var displaylist = new List<"DisplayClass"> ();
var dc = New DisplayClass({Name = "This Icon"})... add all 8 and things are working...
var dc = new DisplayClass({Name="This Icon", State="MA", Style="", Definition="", ... all others empty string});
--- add all 8 classes with names only and all empty fields... fails to load app...
public class DisplayClass
{
public string Name { get; set; }
public string State { get; set; }
public string Style { get; set; }
public string Definition { get; set; }
public string Days { get; set; }
public string Time { get; set; }
public DateTime StartDate { get; set; }
public string Imageurl { get; set; }
public string Dataurl { get; set; }
public string Retrievalurl { get; set; }
public string LastRetrievalDate { get; set; }
public string LastInfoData { get; set; }
public string Quantity { get; set; }
public string ImageName
{
get { return Name.Replace(" ", string.Empty).ToLower(); }
}
}
I updated the emulator to use 4GB instead of 1GB, but that had no effect. There are no code errors that I can tell, if I remark out the full object classes and implement the stripped out version it works without error... I do not get an error, only a App failed to start dialog from Android...
Can anyone shed light on this?
My bad... I had an un-instantiated datetime in my class... oops... sorry folks!

Skype Converting Item Numbers to Emoji

My bot is displaying in Skype, but the 6 and 8 appear as emoji.
This is just a normal FormFlow form:
public class WeightsForm
{
public Weight FromUnitType { get; set; }
public double Amount { get; set; }
public Weight ToUnitType { get; set; }
public static IForm<WeightsForm> BuildForm()
{
return new FormBuilder<WeightsForm>()
.Message("Now you can select weight conversion details.")
.AddRemainingFields()
.Build();
}
}
with Weights based on an enum:
public enum Weight
{
None,
Ton,
Slug,
Pound,
Ounce,
Grain,
Picogram,
Nanogram,
Microgram,
Milligram,
Centigram,
Decigram,
Gram,
Dekagram,
Hectogram,
Kilogram,
Megagram,
Gigagram,
Teragram
}
What is the best way to get this to display, on Skype, without the emoji?
To fix this you need to change the template used for generating the numbers so that Skype does not interpret this as an emoji. If you add this annotation on your class:
[Template(TemplateUsage.EnumSelectOne, ChoiceFormat = "{0}. {1}")]
That would fix the problem for single selections. Alternatively you could change the default template in builder.Configuration.Templates. If you wanted to fix EnumSelectMany you could add that as well.
What version of the SDK are you running? If you are running the latest and unless you have tweaked the choice style you should get buttons on skype by default. (The next release will have more style options as well.)

Grouping items in telerik reporting

I'm trying to use grouping in the Telerik reporting so that I display a certain value only once. Here's what I'm going for:
And here's what I'm getting:
I've tried just about everything I could think of with the grouping. I've moved the Name to the group header, I've moved it all to the group header. Just nothing seems to be going my way with this. Is there a way to actually achieve what I'm trying to do?
I don't know of a built in way to do this, but you can achieve it with a small amount of code.
If you switch from the designer to code view
private static string LastValue { get; set; }
public static string SuppressDuplicates(string value)
{
if (LastValue == value) return string.Empty;
LastValue = value;
return value;
}
And then on the designer change your text box from =Fields.FirstName to '= ReportLibrary.ReportName.SuppressDuplicates(Fields.FirstName) via the expression editor.
It would also be possible to achieve the same thing by adding a handler to the items DataBound event.

Validation for items in ObservableCollection bound to DataGrid when validation of one item of collection depends on other items

I am using MVVM and displaying some items on a DataGrid. My model is RecordingInfo and looks like:
public class RecordingInfo : IDataErrorInfo
{
public RecordingInfo(string fullDirectoryName, string recordingName, int recordingNumber)
{
FullDirectoryName = fullDirectoryName;
RecordingName = recordingName;
RecordingNumber = recordingNumber;
}
public string FullDirectoryName { get; internal set; }
public string RecordingName { get; set; }
public int RecordingNumber { get; internal set; }
public string Error
{
get { throw new NotImplementedException(); }
}
public string this[string propertyName]
{
get {
if (propertyName == "RecordingName")
{
if (this.RecordingName.Length < 2)
return "Recording Name must be at least two characters";
}
return null;
}
}
}
I end up with a collection of these RecordingInfo programmatically. The user is not allowed to do much with these but he/she can change the RecordingName subject to the name being 2 characters or more AND that the RecordingName must be unique. I.e. no changing it to match another RecordingName. I have taken care of the first requirement. It's the second one that is giving me grief.
For my ViewModel, I have
public class RecordingListViewModel : ViewModelBase//, IDataErrorInfo
{
private ObservableCollection<RecordingInfo> _recordings = null;
public RecordingListViewModel()
{
}
public ObservableCollection<RecordingInfo> Recordings
{
get
{
return _recordings;
}
}
// more stuff left off for brevity
In my view I bind the collection to a DataGrid and have:
<DataGrid ItemsSource="{Binding Path=Recordings}" AutoGenerateColumns="False" >
<DataGrid.Columns>
<DataGridTextColumn Header="Recording" IsReadOnly="False" EditingElementStyle="{StaticResource CellEditStyle}" ElementStyle="{StaticResource CellNonEditStyle}" Binding="{Binding RecordingName, UpdateSourceTrigger=PropertyChanged, ValidatesOnDataErrors=True}" >
</DataGridTextColumn>
...
</DataGrid.Columns>
My way of checking for 2 or more characters works great. But this doesn't work for checking that the user is not trying to give a recording an existing name. Presumably, I need to somehow handle this at the ViewModel layer since the ViewModel knows about all Recordings. I tried playing with having my ViewModel derive from IDataErrorInfo but the property indexer never gets called, which makes sense as it's the Observable collection and therefore the individual RecordingInfos that are bound. I also thought about doing something with a "Lost Focus" event, but DataGridTextColumn doesn't seem to have that. I would think this is a somewhat common problem: validation must take into account relationships between the items of the collection.
By the way, I'm not wedded to the IDataErrorInfo and I am not opposed to other changes in architecture. Please let me know if I can provide more details. I have tried to provide a minimal amount of code. Clearly, this is part of a much bigger project. Any advice is appreciated.
Thanks,
Dave
I would do the following
1) Make RecordingInfo implement INotifyPropertyChanged
2) Use a BindingList<> instead of ObservableCollection<>
In your viewmodel, subscribe to the BindingList.ListChanged Event. This event will fire when items are added and removed, but also when the top level properties on RecordingInfo changes. In the case of a property being changed, the ListChangedEventArgs.PropertyDescriptor property will contain the name of the property, if you want to run validation for just that property (be careful though, this can be null when the item as added/removed). You'll need to use the ListChangedType property to determine the reason of the event (E.x.: Reset means everything changed, ItemAdded means the item was added, but the ItemChanged means a property changed as occurred on an existing item.
You can have the parent ViewModel (that contains and creates your RecordingInfos) pass a name validation Func in their constructors for them to call when validating their name changes.

UI action in middle of MvxCommand

I am using MvvmCross, but this may be general command binding.
When user click a button, the application require an extra input data before proceed to what I want to do in the actual command. The problem that I cannot call an UI action in middle of ViewModel, so just binding MvxCommand (or any ICommand) would not work.
One may ask why:
1) I don't put an input on the UI and user can enter data before click button -> I don't have space.
2) Make default data, and let user change it later -> This my first though, but user tend to forget to change it later!!
So can someone come up with a solution? The only thing I can think of is forgetting command binding, and have code behind pop the ui for extra data, then call a method in view model!
Thanks
There are several ways to do this.
My personal preferred way is to use an "Interaction Request" - something that I learnt from the Prism framework from Microsoft patterns and practices.
In Mvx, you can do this using an IMvxInteraction property on your ViewModel. An example of this is shown in https://github.com/slodge/BindingTalk/blob/master/BindingTalk.Core/ViewModels/QuestionViewModel.cs
Each time an interaction is requested, the ViewModel provides an object to the View - in this case a YesNoQuestion:
public class YesNoQuestion
{
public Action YesAction { get; set; }
public Action NoAction { get; set; }
public string QuestionText { get; set; }
public YesNoQuestion()
{
YesAction = () => { };
NoAction = () => { };
}
}
The ViewModel exposes the requester using an IMvxInteraction<TQuestion> property:
public class QuestionViewModel
: MvxViewModel
{
private MvxInteraction<YesNoQuestion> _confirm = new MvxInteraction<YesNoQuestion>();
public IMvxInteraction<YesNoQuestion> Confirm
{
get { return _confirm; }
}
public IMvxCommand GoCommand
{
get
{
return new MvxCommand(() =>
{
var question = new YesNoQuestion()
{
QuestionText = "Close me now?",
YesAction = () => Close(this),
};
_confirm.Raise(question);
});
}
}
}
The view on each platform can then bind and subscribe to the interaction request property. This is a little fiddly - because it uses weak references to prevent memory leaks - especially on iOS, but also possible on other platforms too.
Some example Droid code for this is in:
https://github.com/slodge/BindingTalk/blob/master/BindingTalk.Droid/Views/2%20%20More%20Controls/QuestionView.cs
with AXML in https://github.com/slodge/BindingTalk/blob/master/BindingTalk.Droid/Resources/Layout/QuestionView.axml
Sorry for the confusing ConfirmationView and QuestionView names here - the first is an Android View, the second is an Mvvm View and an Android Activity.
Also, please note that when implementing Dialogs in Android, then you need to be careful about screen rotation - as Android's Activity lifecycle can very much confuse things here - easiest mecahnism (I find) is to just handle screen rotation yourself rather than allowing Android to handle it.

Resources