I am developing a smart tag for one of my WPF controls. The smart tag is added through an AdornerProvider in the design dlls of the control. What I want to do is to synchronize the zoom level of my smart tag and the Visual Studio designer, because if I zoom in/out the Visual Studio designer, the smart tag remains unchanged. Anyone got an idea?
private DesignerView Designer
{
get
{
return DesignerView.FromContext(this.Context);
}
}
protected override void Activate(ModelItem item)
{
this.adornedControlModel = item;
Designer.ZoomLevelChanged += new EventHandler(Designer_ZoomLevelChanged);
//
// YOUR CODE
//
base.Activate(item);
}
void Designer_ZoomLevelChanged(object sender, EventArgs e)
{
throw new NotImplementedException();
}
Related
I've tried this and it looks like majority of search results reference to Android studio. I'm using visual studio, xamarin forms.
protected override void OnCreate (Bundle bundle)
{
base.OnCreate (bundle);
SetContentView (Resource.Layout.Main);
Spinner spinner = FindViewById<Spinner> (Resource.Id.spinner);
spinner.ItemSelected += new EventHandler<AdapterView.ItemSelectedEventArgs> (spinner_ItemSelected);
var adapter = ArrayAdapter.CreateFromResource (
this, Resource.Array.my_array, Android.Resource.Layout.SimpleSpinnerItem);
adapter.SetDropDownViewResource (Android.Resource.Layout.SimpleSpinnerDropDownItem);
spinner.Adapter = adapter;
}
The spinner loads perfectly but the item selected method opens the activity on loading.
private void spinner_ItemSelected (object sender, AdapterView.ItemSelectedEventArgs e)
{
SetContentView (Resource.Layout.page1);
}
How best can I load the activity on specific item selection. Note: the items are referenced in the Strings.xml.
Because Spinner chooses the first item by default when initialized, it will fire spinner_ItemSelected
You can add a conditional judgment to your spinner_ItemSelected method:
private void spinner_ItemSelected (object sender, AdapterView.ItemSelectedEventArgs e)
{
var index = e.Parent.SelectedItemPosition; //base on the select position
var obj = e.Parent.SelectedItem; // base on the selectitem value(string)
// xxx is your conditions
if(index == xxx)
{
SetContentView (Resource.Layout.page1);
}
// or
if(obj.ToString().Equals("xxx"))
{
SetContentView (Resource.Layout.page1);
}
}
I haven't been able to find an answer for this online, but basically I want to permanently hide the Task List window that pops up whenever I test a Biztalk map. Right now I've found a temp solution by minimizing the window as much as possible, so it doesnt get in the way, but it would be nice to get rid of it entirely.
This is the window in question.
Unfortunately, no (for clarity, the answer is no...unless you want to write an Shell Extension ;).
I'm often as frustrated by this as you but have found that simply tucking it away in a corner or along the status bar is just as good as hiding it.
I presume the activate action is baked into the map designer.
You can try the following extension for Visual Commander to automatically close the Task List window once it is displayed:
public class E : VisualCommanderExt.IExtension
{
public void SetSite(EnvDTE80.DTE2 DTE, Microsoft.VisualStudio.Shell.Package package)
{
events = DTE.Events;
windowEvents = events.WindowEvents;
windowEvents.WindowActivated += OnWindowActivated;
}
public void Close()
{
windowEvents.WindowActivated -= OnWindowActivated;
}
private void OnWindowActivated(EnvDTE.Window gotFocus, EnvDTE.Window lostFocus)
{
try
{
if (gotFocus.Caption == "Task List")
CloseWindow(gotFocus);
}
catch (System.Exception)
{
}
}
private void CloseWindow(EnvDTE.Window w)
{
System.Windows.Threading.Dispatcher.CurrentDispatcher.BeginInvoke(
System.Windows.Threading.DispatcherPriority.Background,
new System.Action(() =>
{
try
{
w.Close();
}
catch (System.Exception)
{
}
}
));
}
private EnvDTE.Events events;
private EnvDTE.WindowEvents windowEvents;
}
Is there a custom circular activity indicator for UWP/ Win10 apps using Xamarin?
Is there a custom circular activity indicator for UWP/ Win10 apps using Xamarin?
You need to create your own View for UWP's ProgressRing:
Shared Project\MyProgressRing.cs:
public class MyProgressRing:View
{
}
UWP Project\MyProgressRingRenderer.cs:
[assembly:ExportRenderer(typeof(MyProgressRing),typeof(MyProgressRingRenderer))]
namespace CircularActivityDemo.UWP
{
public class MyProgressRingRenderer:ViewRenderer<MyProgressRing,ProgressRing>
{
ProgressRing ring;
protected override void OnElementChanged(ElementChangedEventArgs<MyProgressRing> e)
{
base.OnElementChanged(e);
if (Control == null)
{
ring = new ProgressRing();
ring.IsActive = true;
ring.Visibility = Windows.UI.Xaml.Visibility.Visible;
ring.IsEnabled = true;
SetNativeControl(ring);
}
}
}
}
Notes: I hardcoded the properties of ProgressRing Control. You can create DependencyProperties for your custom ProgressRing control.
all. I am trying to develop an application for Windows Phone 7 using Visual Studio 2010. It is a music player that is supposed to be able to play music based on the current event.
I managed to extract the event but when I tried to combine it with the player, the entire player would just crash. Here are the codes.
void Appointments_SearchCompleted(object sender, AppointmentsSearchEventArgs e)
{
try
{
AppointmentResultsDataLINQ.DataContext =
from Appointment appt in e.Results
where appt.IsAllDayEvent == false
select appt;
}
catch (System.Exception)
{
//No results
}
}
private void button2_Click(object sender, RoutedEventArgs e)
{
if ((((Appointment)(AppointmentResultsDataLINQ.DataContext)).Subject).Equals("Meeting"))
{
mediaElement1.Source = new Uri("http://www.opendrive.com/files/NV8zNTMwNDYwX2hxRXZR/Crystallize.mp3", UriKind.Absolute);
}
else
{
mediaElement1.Source = new Uri("https://www.opendrive.com/files/NV8zMjAxODY0X0VBNDJY/Hetken%20tie%20on%20kevyt%20(piano%20cover)%20-%20YouTube.mp3", UriKind.Absolute);
}
mediaElement1.Play();
}
The problem is the cast. You are trying to cast the AppointmentResultsDataLINQ.DataContext to an Appointment. This does not make sense. You need to select one concrete appointment from using LINQ (similar to the code in your Appointments_SearchCompleted that imho does nothing)
How can you tell whether the device is oriented vertically (portrait) or horizontally (landscape)?
Is there an API that simplifies this or do you have to make the determination "by hand" using the accelerometer?
I myself just have looked at windows 7 phones(through vs2010 express phone edition).
It seems to have in the code behind this
public MainPage()
{
InitializeComponent();
// seems to set the supported orientations that your program will support.
SupportedOrientations = SupportedPageOrientation.Portrait | SupportedPageOrientation.Landscape;
}
Then the actual form has
private void PhoneApplicationPage_OrientationChanging(object sender, OrientationChangedEventArgs e)
{
var test = e.Orientation;
}
So when the orientation changes it e.Orientation will tell you what orientation it is. Like for instance LandscapeRight.
Also you don't have to track this only via the event, you can ask for it directly from the PhoneApplicationPage instance:
private void Button_Click(object sender, RoutedEventArgs e)
{
MyCurrentOrientation.Text = this.Orientation.ToString();
}
You can also ask it through this.Orientation when your application starts so you know what the orientation is. Afther the start you can use the OrientationChanged event.
In your main:
OrientationChanged += new EventHandler<OrientationChangedEventArgs>(MainPage_OrientationChanged);
void MainPage_OrientationChanged(object sender, OrientationChangedEventArgs e)
{
Console.WriteLine(e.Orientation.ToString());
}