I am totally lost at the moment. What is wrong with my animation? Why is it not running? Any help would be highly appreciated! I want to develop sort of an circular progress bar which is "rolling in" as if the bar was filled up.
The following code runs inside an empty UWP app in the MainPage's Loaded Handler. Nothing else...
ArcSegment myArcSegment = new ArcSegment();
myArcSegment.Size = new Size(90, 80);
myArcSegment.SweepDirection = SweepDirection.Clockwise;
PathSegmentCollection myPathSegmentCollection = new PathSegmentCollection();
myPathSegmentCollection.Add(myArcSegment);
PathFigure myPathFigure = new PathFigure();
myPathFigure.StartPoint = new Point(100, 200);
myPathFigure.Segments = myPathSegmentCollection;
PathFigureCollection myPathFigureCollection = new PathFigureCollection();
myPathFigureCollection.Add(myPathFigure);
PathGeometry myPathGeometry = new PathGeometry();
myPathGeometry.Figures = myPathFigureCollection;
Path myPath = new Path();
myPath.Stroke = new SolidColorBrush(Colors.Aqua);
myPath.StrokeThickness = 1;
myPath.Data = myPathGeometry;
PointAnimation mySizeAnimation = new PointAnimation();
mySizeAnimation.Duration = TimeSpan.FromSeconds(2);
mySizeAnimation.From = new Point(90, 80);
mySizeAnimation.To = new Point(500, 200);
Storyboard.SetTarget(mySizeAnimation, myArcSegment);
Storyboard.SetTargetProperty(mySizeAnimation, nameof(ArcSegment.Point));
Storyboard ellipseStoryboard = new Storyboard();
ellipseStoryboard.Children.Add(mySizeAnimation);
myPath.Loaded += delegate (object o, RoutedEventArgs e)
{
ellipseStoryboard.Begin();
};
Canvas containerCanvas = new Canvas();
containerCanvas.Children.Add(myPath);
Content = containerCanvas;
Thank you for your help!
Oh my... I just read this post: http://blog.jerrynixon.com/2012/06/windows-8-animated-pie-slice.html
By accident I read about the EnableDependendAnimation Property... never heared of it, but Setting it to true just made the Animation run. I will read up on that now. Thanks anyways!
Related
I am adding a down arrow to the xamarin picker. I created a custom iOS renderer for this. I can get the arrow to show up fine, but it is touching the right hand side of the picker. How can I add some padding to the right of the arrow? I have tried the following in my ios renderer.
protected void UpdateBackground(UITextField control)
{
if (control == null) return;
control.Layer.CornerRadius = ElementV2.CornerRadius;
control.Layer.BorderWidth = ElementV2.BorderThickness;
control.Layer.BorderColor = ElementV2.BorderColor.ToCGColor();
var downArrowLabel = new UILabel(new CoreGraphics.CGRect(new CoreGraphics.CGPoint(control.Frame.Size.Width - 20 - 16, 0), new CoreGraphics.CGSize(20, control.Frame.Size.Height)));
downArrowLabel.Font = UIFont.FromName("FontAwesome", 30);
downArrowLabel.Text = "\uf0d7";
downArrowLabel.TextColor = UIColor.Black;
downArrowLabel.TextAlignment = UITextAlignment.Center;
downArrowLabel.ContentMode = UIViewContentMode.ScaleAspectFit;
control.RightView = downArrowLabel;
control.RightViewMode = UITextFieldViewMode.Always;
control.RightView.Bounds = new CoreGraphics.CGRect(0, 0, 20 + 16, control.Frame.Size.Height);
}
I wrote a Picker renderer based on your code and tested it. I found that adding a few spaces after the Text can effectively solve this problem. It looks strange, but it works, like this
downArrowLabel.Text = "\uf0d7 ";
not sure what I am doing wrong, I wanna create a simple custom camera, I'm creating the AVCapturePhotoOutput attaching it to AVCaptureSession, then creating AVCapturePhotoSettings with minimum settings to make taking a picture work, see code below.
I get exception kCVPixelBufferPixelFormatTypeKey is not being define but it is indeed in the NSDictionary I am passing.
I need some light here, thanks
public void TakePicture()
{
var output = new AVCapturePhotoOutput();
_captureSession.AddOutput(output);
var settings = AVCapturePhotoSettings.Create();
var previewPixelType = settings.AvailablePreviewPhotoPixelFormatTypes.First();
var keys = new[]
{
new NSString("kCVPixelBufferPixelFormatTypeKey"),
new NSString("kCVPixelBufferWidthKey"),
new NSString("kCVPixelBufferHeightKey"),
};
var objects = new NSObject[]
{
// don't have to be strings... can be any NSObject.
previewPixelType,
new NSString("160"),
new NSString("160")
};
var dicionary = new NSDictionary<NSString, NSObject>(keys, objects);
settings.PreviewPhotoFormat = dicionary;
output.CapturePhoto(settings,this);
}
It is because kCVPixelBufferPixelFormatTypeKey is not available in Xamarin.
We should use CVPixelBuffer.PixelFormatTypeKey here . It will be convert to kCVPixelBufferPixelFormatTypeKey automatically when compiling.
The same reason for kCVPixelBufferWidthKey and kCVPixelBufferHeightKey , the api is CVPixelBuffer.WidthKey and CVPixelBuffer.HeightKey in Xamarin.iOS.
Designer error screen shot
private void InitializeComponent()
{
System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(MainWindow));
this.TC_mainControl = new System.Windows.Forms.TabControl();
this.TP_Payment = new System.Windows.Forms.TabPage();
this.TP_Manage = new System.Windows.Forms.TabPage();
this.TP_Batch = new System.Windows.Forms.TabPage();
this.TP_Report = new System.Windows.Forms.TabPage();
this.TP_COMM = new System.Windows.Forms.TabPage();
this.TP_LOG = new System.Windows.Forms.TabPage();
this.pay_sample1 = new POSLinkTest.Payment();
this.man_sample1 = new POSLinkTest.Manage();
this.batch_sample1 = new POSLinkTest.Batch();
this.report_sample1 = new POSLinkTest.Report();
this.comm_sample1 = new POSLinkTest.Commset();
this.log_sample1 = new POSLinkTest.LogSetting();
this.TC_mainControl.SuspendLayout();
this.SuspendLayout();
//
// TC_mainControl
//
this.TC_mainControl.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
| System.Windows.Forms.AnchorStyles.Left)
| System.Windows.Forms.AnchorStyles.Right)));
this.TC_mainControl.Controls.Add(this.TP_Payment);
this.TC_mainControl.Controls.Add(this.TP_Manage);
this.TC_mainControl.Controls.Add(this.TP_Batch);
this.TC_mainControl.Controls.Add(this.TP_Report);
this.TC_mainControl.Controls.Add(this.TP_COMM);
this.TC_mainControl.Controls.Add(this.TP_LOG);
this.TC_mainControl.ItemSize = new System.Drawing.Size(148, 20);
this.TC_mainControl.Location = new System.Drawing.Point(0, 0);
this.TC_mainControl.Multiline = true;
this.TC_mainControl.Name = "TC_mainControl";
this.TC_mainControl.Padding = new System.Drawing.Point(6, 0);
this.TC_mainControl.SelectedIndex = 0;
this.TC_mainControl.Size = new System.Drawing.Size(1000, 600);
this.TC_mainControl.SizeMode = System.Windows.Forms.TabSizeMode.Fixed;
this.TC_mainControl.TabIndex = 0;
this.TC_mainControl.SelectedIndexChanged += new System.EventHandler(this.TC_mainControl_SelectedIndexChanged);
//
// TP_Payment
//
this.TP_Payment.AutoScroll = true;
The solution builds without any errors? Why will the form not load into the designer, yet it will compile?
Using Visual Studio 2015, Windows 10 64 bit
I can upload the project if necessary, it is just Sample Project.
The error message on the screenshot says that types from POSLinkTest namespace are not available. So probably add a reference to that namespace.
For future use there are some other potential problems with the designer code:
Removed parameterless constructor. Solution: add the parameterless constructor back as a privet constructor to prevent others from using it but having it available for the designer
Design time code (like OnPaint handler) that references resource not available at that time (like db connection). Solution: try not to handle that in UI related code.
I have a little question, I want to change the background of my application with C#.
I tried this code :
var app = Application.Current as App;
var imageBrush = new ImageBrush
{
ImageSource = new BitmapImage(new Uri(imageName, UriKind.Relative))
};
app.RootFrame.Background = imageBrush;
But it doesn't work, the background is dark.. I tried to do :
app.RootFrame.Background = new SolidColorBrush(Colors.Blue);
And it works well. So I don't understand where is the problem, my image is 480*800 px and I set Build Action to Content and Copy to Output Directory to Copy if newer .
Thanks for all
maybe you can try it
var app = Application.Current as App;
if (app == null)
return;
var imageBrush = new ImageBrush
{
};
var uu = new BitmapImage(new Uri(imageName, UriKind.Relative));
uu.CreateOptions = BitmapCreateOptions.None;
imageBrush.ImageSource = uu;
app.RootFrame.Background = imageBrush;
Mark: uu.CreateOptions = BitmapCreateOptions.None;
I'm doing almost the exact same thing successfully with an image, except I'm setting the image as the background to a panorama control. I know someone else had the same problem you did in this post so I suggested setting the background of the LayoutRoot or other control instead of the app.RootFrame.
Thank you both !!
I had previously tried the two solutions separately and it didn't work. But together it works perfectly!
The code :
var imageBrush = new ImageBrush
{
};
var uu = new BitmapImage(new Uri("/Images/image.png", UriKind.Relative));
uu.CreateOptions = BitmapCreateOptions.None;
imageBrush.ImageSource = uu;
LayoutRoot.Background = imageBrush;
i am showing images from server. In server image is changing in every second. I want that in my application image should be change automatically after one second.M new in windows 7 programming. Kindly suggest me where i am lacking in concept. M using this code.
This process will start when i will tab on my image.
private void image1_Tap(object sender, GestureEventArgs e)
{
System.Windows.Threading.DispatcherTimer dt = new System.Windows.Threading.DispatcherTimer();
dt.Interval = new TimeSpan(0, 0, 0, 0, 1000); // 500 Milliseconds
dt.Tick += new EventHandler(dt_Tick);
dt.Start();
}
This is calling this method .
void dt_Tick(object sender, EventArgs e)
{
status.Text = "chking" + counter++;
// Do Stuff here.
image1.Source = null;
Uri imgUri = new Uri(base_url,UriKind.Absolute);
BitmapImage BI = new BitmapImage(imgUri);
int H = BI.PixelHeight;
int w = BI.PixelWidth;
image1.Source = BI;
}
In this code my Counter is working fine and status.Text is sucessfully change in every second. But image is changing once after that its not changing.
Kinldy suggest me where i am commiting mistake.
Thanks in advance
Gaurav Gupta
I think you should declare System.Windows.Threading.DispatcherTimer dt = new System.Windows.Threading.DispatcherTimer(); as a member variable instead of declaring it in the images tap event.
I do the same thing when grabbing images from a camera in my wp8 app. I hold the URL including the current datetime-value as a url-param in my viewmodel. When i want to refresh, i just reset my URL-property.
Here's my sample:
this.MyUrlProperty = string.Format("{0}?timestamp={1:yyyy-MM-dd HH:mm:ss:fff}", _originalCameraUrl, DateTime.Now);
Works great for me...