logo
down
shadow

How to change orientation of one component in windows phone 8 page with locked orientation


How to change orientation of one component in windows phone 8 page with locked orientation

By : user2948582
Date : November 14 2020, 04:51 PM
will help you So, I've figured one way to do it on my own.
I'm going to put the answer as community wiki so that anyone who comes later can edit and add more options to do this.
code :
//Create a transformation
RotateTransform rt = new RotateTransform();
//and set the rotation angle
rt.Angle = 90; //number of degrees to rotate clockwise
               //for counterclockwise rotation use negative number

//default rotation is around top left corner of the control,
//but you sometimes want to rotate around the center of the control
//to do that, you need to set the RenderTransFormOrigin
//of the item you're going to rotate
//I did not test this approach, maybe You're going to need to use actual coordinates
//so this bit is for information purposes only
controlToRotate.RenderTransformOrigin = new Point(0.5,0.5);

//the name of the control is controlToRotate in this instance
controlToRotate.RenderTransform = rt;
<Grid x:Name="ContentPanel">            
  <phone:WebBrowser x:Name="controlToRotate"
                    VerticalAlignment="Center"
                    HorizontalAlignment="Center"
                    RenderTransformOrigin=".5, .5"
                    Width="{Binding ElementName=ContentPanel, Path=ActualHeight}"
                    Height="{Binding ElementName=ContentPanel, Path=ActualWidth}">
    <phone:WebBrowser.RenderTransform>
      <RotateTransform Angle="90"/>
    </phone:WebBrowser.RenderTransform>
  </phone:WebBrowser>
</Grid>


Share : facebook icon twitter icon
Android: Pressing ad causes Activity with locked orientation to change orientation

Android: Pressing ad causes Activity with locked orientation to change orientation


By : RKZZD
Date : March 29 2020, 07:55 AM
will be helpful for those in need All of the Activities in my app are locked into portrait orientation using:
code :
    @Override
    public void onConfigurationChanged(Configuration newConfig) {
        super.onConfigurationChanged(newConfig);

        this.setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT);
    }
Get phone orientation when locked into one orientation

Get phone orientation when locked into one orientation


By : Julieta
Date : March 29 2020, 07:55 AM
To fix the issue you can do So after I thought about it, I realized I could just implement a similar algorithm as what Android itself uses to figure out the orientation. I do it using the onSenseorChanged callback
code :
public static final int UPSIDE_DOWN = 3;
public static final int LANDSCAPE_RIGHT = 4;
public static final int PORTRAIT = 1;
public static final int LANDSCAPE_LEFT = 2;
public int mOrientationDeg; //last rotation in degrees
public int mOrientationRounded; //last orientation int from above 
private static final int _DATA_X = 0;
private static final int _DATA_Y = 1;
private static final int _DATA_Z = 2;
private int ORIENTATION_UNKNOWN = -1;
@Override
public void onSensorChanged(SensorEvent event) 
{
    Log.d(TAG, "Sensor Changed");
    float[] values = event.values;
    int orientation = ORIENTATION_UNKNOWN;
    float X = -values[_DATA_X];
    float Y = -values[_DATA_Y];
    float Z = -values[_DATA_Z];        
    float magnitude = X*X + Y*Y;
    // Don't trust the angle if the magnitude is small compared to the y value
    if (magnitude * 4 >= Z*Z) {
        float OneEightyOverPi = 57.29577957855f;
        float angle = (float)Math.atan2(-Y, X) * OneEightyOverPi;
        orientation = 90 - (int)Math.round(angle);
        // normalize to 0 - 359 range
        while (orientation >= 360) {
            orientation -= 360;
        } 
        while (orientation < 0) {
            orientation += 360;
        }
    }
    //^^ thanks to google for that code
    //now we must figure out which orientation based on the degrees
    Log.d("Oreination", ""+orientation);
    if (orientation != mOrientationDeg) 
    {
        mOrientationDeg = orientation;
        //figure out actual orientation
        if(orientation == -1){//basically flat

        }
        else if(orientation <= 45 || orientation > 315){//round to 0
            tempOrientRounded = 1;//portrait
        }
        else if(orientation > 45 && orientation <= 135){//round to 90
            tempOrientRounded = 2; //lsleft
        }
        else if(orientation > 135 && orientation <= 225){//round to 180
            tempOrientRounded = 3; //upside down
        }
        else if(orientation > 225 && orientation <= 315){//round to 270
            tempOrientRounded = 4;//lsright
        }

    }

    if(mOrientationRounded != tempOrientRounded){
            //Orientation changed, handle the change here
        mOrientationRounded = tempOrientRounded;

    }
}
Camera Orientation Change When Picture Taken. Even When Orientation is locked.

Camera Orientation Change When Picture Taken. Even When Orientation is locked.


By : user2715949
Date : March 29 2020, 07:55 AM
around this issue Just an initial thought, have you considered rotating the picture after it's taken? I'm not sure whether this is the right solution for you as the display will still be oriented on the side when the photo is being taken. this would certainly get around the screen locking issue.
I hope this helps. Kiran
Windows Phone 8 Page Orientation

Windows Phone 8 Page Orientation


By : Preethi shreeya
Date : March 29 2020, 07:55 AM
I wish did fix the issue. Simply put your code in a distinct method, and call this method both from the OrientationChanged and Loaded events:
code :
private void PhoneApplicationPage_Loaded(object sender, RoutedEventArgs e)
{
    this.SetOrientation(this.Orientation);
}

private void PhoneApplicationPage_OrientationChanged(object sender, OrientationChangedEventArgs e)
{
    this.SetOrientation(e.Orientation);
}

private void SetOrientation(PageOrientation orientation)
{
    if (orientation == PageOrientation.Landscape || orientation == PageOrientation.LandscapeLeft || orientation == PageOrientation.LandscapeRight)
    {
        SwitchPanel.Margin = new Thickness(12, 100, 250, 0);
        StatusPanel.HorizontalAlignment = System.Windows.HorizontalAlignment.Right;
    }
    else
    {
        SwitchPanel.Margin = new Thickness(12, 100, 12, 0);
        StatusPanel.HorizontalAlignment = System.Windows.HorizontalAlignment.Stretch;
    }
}
Admob Interstitial orientation is locked to the initial device orientation on startup

Admob Interstitial orientation is locked to the initial device orientation on startup


By : Mustafa ÖZVER
Date : March 29 2020, 07:55 AM
seems to work fine I fixed this. In the end it came down to re-requesting the ad on orientation change, and importantly, running that request in the UI thread.
Related Posts Related Posts :
  • C# correct exception handling
  • "Could not open macro storage" when accessing using file on another machine
  • How to access other directories of hosted server
  • C# Jagged Array check if value exists/true
  • Why can't I type Clone() properly?
  • exception on accessing dictionary from list
  • Getting the immediate response from server without waiting to 200 message
  • Why am I getting exception Directory Is Not empty?
  • Could not load file or assembly 'CefSharp.dll' or one of its dependencies
  • Sending Email By Using C# in unity3D?
  • Correct usage of await async in webapi
  • Program update code issue
  • Marshal.Copy attempted to read or write protected memory At Random Times
  • Restrict Type variable to specific class or subclass
  • Horizontal text alignment in a PdfPCell
  • C# crashing with Form.show() command, ObjectDisposedException - Deeper look / explanation please
  • Will the result of a LINQ query always be guaranteed to be in the correct order?
  • "Could not find default endpoint element that references contract"
  • Umbraco Request.QueryString is null if it's the first time the page is loaded
  • Error inconsistent accessibility method C#
  • How to program Intel Xeon Phi with C#?
  • remove nested element using regular expression
  • Is there a C# alternative to Java's vararg parameters?
  • Clear particular column values in DataTable
  • how to add event handler to programatically created checkboxes
  • Cannot apply indexing with [] to an expression of type 'System.Collections.Specialized.NameValueCollection'
  • Check for key in pre-existing dictionary in case insensitive manner
  • How to remove year from datetime object?
  • Accessing Settings in different ways
  • "This project is empty" error in Sonarqube
  • How to create reusable icon menu in Xamarin
  • Value Cannot be null in Ado.Net connectivity
  • Adding a custom/dynamic attribute when using XSD.exe
  • How to convert object to correct type
  • Automatically sign out from Forms Authentication in ASP.NET when browser is closed
  • Can a WCF service support both Buffered and Streamed transfer modes?
  • Verify a CA Certificate with a public key in C#
  • How to invoke a Web Service that requires the "patch" verb using the C# WebClient wrapper?
  • Proper way a implementing property based on generic type
  • Closing a form that is created in another thread
  • How Can You Bind a List<String> to a StackPanel
  • WPF Application Update Best Practices - Architectural Explanation
  • System.UnauthorizedAccessException in Server.MapPath()
  • Connecting and Using SQL Compact Edition in a WPF application
  • C#: weird ref in constructor to behave like "virtual field"
  • C# XDocument Load with multiple roots
  • How to decide what goes in the Domain or Application Project in a "DDD" solution?
  • How to get/set a property of an interface that is not always implemented
  • Read-only array field in unsafe struct
  • i got "Invalid attempt to call Read when reader is closed" when using sqldatareader how to solve it in a three
  • Why should I encapsulate objects in using if there is garbage collection
  • How to load Word document from byte array
  • Caliburn.Micro and ContextMenu for DataGrid Row
  • Linq "join" with a IList<T> getting "Error Unable to create a constant value.."
  • How to draw red wavy line under words in RichTextBox c# winform
  • HttpPostedFileBase returns Null MVC3
  • Refresh Dropdownlist in webform
  • How to convert serialized byte array back to its text form
  • How to do a loop to check all the variables at the same time for C#?
  • Facebook Sentiment Analysis API
  • shadow
    Privacy Policy - Terms - Contact Us © ourworld-yourmove.org