Cleaning existing images in PersonPicture WinRT/C++ - c++-winrt

In my application, there are two functions to add and clean image in PersonPicture. However, I don't know of a way to clean up the image that has been added in the PersonPicture. So, how to clean the image that has been added in the PersonPicture?
Example of the code.
// Xaml file
<PersonPicture x:Name="UserProfile"/>
// Cpp file
void MyPage::AddImage(hstring const& path)
{
Windows::UI::Xaml::Media::Imaging::BitmapImage bitmap{ Windows::Foundation::Uri(path) };
UserProfile().ProfilePicture(bitmap);
}
void MyPage::ClearImage()
{
// Clean up the image that has been added in PersonPicture.
// However,
// How to do that here?
}

Related

SwiftUI's Canvas won't appear in Objective-C project

I'm trying to use SwiftUI in my Objective-C project, so I use this following step:
this article
after that, I'm success bridging this 2 files to my Objective-C project. but in my file SwiftUIFile.swift, my canvas cannot be resume. when I try to resume, nothing happened.
here's the code
import SwiftUI
#available (iOS 13.0, *)
struct DetailInterfacesUISwift: View {
var labelName = ""
var body: some View {
Text(labelName)
}
}
#available (iOS 13.0, *)
struct DetailInterfacesUISwift_Previews: PreviewProvider {
static var previews: some View {
DetailInterfacesUISwift()
}
}
note
1. I already delete script in build phases, nothing happen
2. I already clean project and delete core simulator downloaded
3. And still not working.

Intellij Plugin - How to color project view files background?

As seen in the picture. Color Notification is colored. This is done by creating a scope and adding that file in that scope.
However I want to mark files according to my need. For example I will click that color notification and mark that file green or yellow.
I only need to know how I can reach this project view and alter background color programmatically.
I know there arent so many intellij plugin creators but still I will try my luck.
From my investigation there are FileColorManager, ProjectView, UIManager etc but I couldnt find which one is responsible for these color handling changes...
Just a guess. Have you tried to implement the com.intellij.ide.projectView.ProjectViewNodeDecorator extension point? It seems like this lets you decorate the nodes in the project view.
As we found out, setting the background-color is not easily possible. But you can add a string (like a checkmark) at the end of each node that you want to highlight. Here is an example:
public class ProvectViewColorer implements ProjectViewNodeDecorator {
#Override
public void decorate(ProjectViewNode node, PresentationData data) {
final VirtualFile virtualFile = node.getVirtualFile();
if (virtualFile != null && virtualFile.getFileType().equals(MathematicaFileType.INSTANCE)) {
data.setLocationString("✓");
}
}
#Override
public void decorate(PackageDependenciesNode node, ColoredTreeCellRenderer cellRenderer) {
}
}

How to solve Out of memory error in android after using volley lib and image loader?

I am getting out of memory error, App crash frequently even though I used picasso,Volley lib, Universal image loader to view images.
I am using volley lib to make API call.
public class Holder
{
TextView title,Category,Amount;
NetworkImageView img;
}
#Override
public View getView(final int position, View convertView, ViewGroup parent)
{
Holder holder=new Holder();
View rowView;
File cacheDir;
rowView = inflater.inflate(R.layout.solvent_list_forproduct, null);
holder.img=(NetworkImageView)
rowView.findViewById(R.id.productImage);
ImageLoader imageloader =
ImageGetter.getInstance(context).getImageLoader();
holder.img.setImageUrl
(VarproductImageList.get(position)
.replace(" ", "%20").toString(), imageloader);
}
Some time it through Negative Array size exception.

How to response MENU_SELECTED event in an Inherited wxMenuBar?

I had tried DECLARE_EVENT_TABLE() && Connect(),but it dosen't work.My code just like this.How to make it work?
//.h
class MainFrameMenuBar :public wxMenuBar
//...
private:
DECLARE_EVENT_TABLE();
};
/...
//.cpp
BEGIN_EVENT_TABLE(MainFrameMenuBar, wxMenuBar)
EVT_MENU(XRCID("ID_MENU_FIGURE"), MainFrameMenuBar::onMenuItemFigure)
END_EVENT_TABLE()
MainFrameMenuBar::MainFrameMenuBar(wxWindow* parent)
{
wxXmlResource::Get()->LoadMenuBar(parent,wxT("ID_MAIN_MENUBAR"));
//int id = XRCID("ID_MENU_FIGURE");
//Connect(id, wxEVT_COMMAND_MENU_SELECTED, wxCommandEventHandler(MainFrameMenuBar::onMenuItemFigure), NULL, this);
}
void MainFrameMenuBar::onMenuItemFigure(wxCommandEvent& event)
{
printf("abc");
}
This used to be broken in older wxWidgets versions and you had to handle menu events only in the wxFrame containing the menu bar and not the menu bar itself, but it should have been fixed quite some time ago, so perhaps you need to upgrade?
If you do use a version affected by that bug and can't upgrade, handling the events in the frame is the simplest workaround.

Disable copy/paste on Xamarin forms input field i.e. Entry

I am working on disabling copy/paste option menus on xamarin forms Entry, I am able to disable copy option using IsPassword=true attribute but this attribute also converts the normal input field to password field, which is not a requirement.
<Entry IsPassword="true" Placeholder="Password" TextColor="Green" BackgroundColor="#2c3e50" />
Thanks in advance.
This has to do with how Forms functions. Using iOS as the example here, the CanPerform override referred to in the other answer's Bugzilla issue is using the UIMenuController as the withSender and not the UITextField itself that might otherwise be expected. This is because the EntryRenderer class is a ViewRenderer<TView, TNativeView> type and subsequently is using whatever TNativeView (in this case, the UITextView) has in its CanPerform. Because nothing is going to be overridden by default, one still sees all of the cut/copy/paste options in the UIMenuController.
As a result, there would be a couple options. You could first make the modification where if you don't want copy/paste but are fine with getting rid of everything else, you can use UIMenuController.SharedMenuController.SetMenuVisible(false, false) in a custom renderer inheriting from EntryRenderer. If you look around on SO, there are similar questions where this is a possible route.
Alternatively, you can create a "true" custom renderer inheriting from ViewRenderer<TView, TNativeView> as ViewRenderer<Entry, YourNoCopyPasteUITextFieldClassName>. The class inheriting from UITextField can then override CanPerform as something like follows:
public override bool CanPerform(Selector action, NSObject withSender)
{
if(action.Name == "paste:" || action.Name == "copy:" || action.Name == "cut:")
return false;
return base.CanPerform(action, withSender);
}
This will require more effort because the custom renderer will not have the same behavior as the EntryRenderer, but as Xamarin.Forms is now open source, you could look to it for some ideas as to how the EntryRenderer functions normally. Something similar would likely have to be done for Android.
Edit: For Android, you can probably use this SO answer as a starting point: How to disable copy/paste from/to EditText
Another custom renderer, this time inheriting from ViewRenderer<Entry, EditText>, and create a class inside of it like this (in the most basic form):
class Callback : Java.Lang.Object, ActionMode.ICallback
{
public bool OnActionItemClicked(ActionMode mode, IMenuItem item)
{
return false;
}
public bool OnCreateActionMode(ActionMode mode, IMenu menu)
{
return false;
}
public void OnDestroyActionMode(ActionMode mode)
{
}
public bool OnPrepareActionMode(ActionMode mode, IMenu menu)
{
return false;
}
}
Then, in your OnElementChanged method, you can set the native control and the CustomSelectionActionModeCallback value:
protected override void OnElementChanged(ElementChangedEventArgs<Entry> e)
{
base.OnElementChanged(e);
if (Control != null)
{
Control.CustomSelectionActionModeCallback = new Callback();
}
}
Doing something like the following appears to disable all of the copy/paste/cut functionality on the custom entry as far as the toolbar goes. However, you can still long click to show the paste button, to which I've poked around a bit hadn't found an answer yet beyond setting LongClickable to false. If I do find anything else in that regard, I'd make sure to update this.