Telerik GanttView Timeline GUI - modification - user-interface

i want to change the behavior of my Telerik GanttView TimeLineContainer. The problem is, when i load data into GanttView with long duration (years) the TimeLine scales very bad. That means that it zooms in and not like I would have to zoom out.
So in best case I would like to have the TimeLine scrollbar so that the user can adjust the size on runtime.
So far I tried this, but it doesnt scales right.
this.radGanttView.GanttViewElement.GraphicalViewElement.TimelineContainer.StretchHorizontally = false;
this.radGanttView.GanttViewElement.GraphicalViewElement.TimelineContainer.AutoSizeMode = Telerik.WinControls.RadAutoSizeMode.FitToAvailableSize;

Solved this by adding a RadTrackBar:
private void radTrackBar_ValueChanged(object sender, EventArgs e)
{
int zoomfaktor = 10;
double value = 51 + zoomfaktor * Math.Pow(this.radTrackBarZoom.Value, 2d);
Console.WriteLine(string.Format("{0} - {1}", this.radTrackBarZoom.Value, value));
TimeSpan time = new TimeSpan(0, (int)value, 0); this.radGanttView.GanttViewElement.GraphicalViewElement.OnePixelTime = time;
this.radGanttView.GanttViewElement.GraphicalViewElement.OnePixelTime = time;
}

Related

Make image disappear after X seconds (processing)

I'm currently working on a project in which I want an image to pop up after 3 seconds. Once that image has popped up the user has to click on the image to make a "done" image pop up that will disappear automatically after 3 seconds.
I've got most of it working except for the disappearing part. Does anyone know how I can time the image to disappear after 3 seconds?
PImage medic;
PImage medicD;
float time;
float startTime;
final int waitpopup = 3000;
final int DISPLAY_DURATION = 3000;
boolean showimage = true;
boolean showclock = true;
boolean showimagedone = true;
boolean hasClicked;
Clock clock;
void setup (){
size (1080, 1920);
medic = loadImage("medic.png");
medicD = loadImage("medicD.png");
clock = new Clock(width /2, height /2);
time = millis();
}
void draw() {
background (0);
imageMode(CENTER);
if (showclock) clock.display();
if (showimage && millis() - time > waitpopup) {
image(medic, width/2, height/2, 540, 540);
} if (hasClicked == true) {
showimage = false;
image(medicD, width/2, height/2, 540, 540);
} if (millis() > startTime + DISPLAY_DURATION) {
showimagedone = false;
}
}
void mousePressed() {
hasClicked = true;
startTime = time;
}
You can use the millis() function or the frameCount variable to check how much time has gone by, then do something after X seconds or after X frames.
You're already doing some of the work with the showimagedone variable, but you need to use that variable to conditionally draw your image.
I recommend starting with a simpler example and getting that working. Here's one example:
int clickedFrame;
boolean on = false;
int duration = 60;
void draw(){
if(on){
background(255);
if(frameCount > clickedFrame + duration){
on = false;
}
}
else{
background(0);
}
}
void mousePressed(){
clickedFrame = frameCount;
on = true;
}
This code show a white background for one second whenever the user clicks the mouse. You need to do something similar with your images.
Related posts:
How to make a delay in processing project?
How can I draw only every x frames?
Removing element from ArrayList every 500 frames
Timing based events in Processing
How to add +1 to variable every 10 seconds in Processing?
How to create something happen when time = x
making a “poke back” program in processing
Processing: How do i create an object every “x” time
Timer using frameRate and frame counter reliable?
Adding delay in Processing
Please also consult the Processing reference for more information.
If you still can't get it working, please post a MCVE (not your full project!) in a new question and we'll go from there. Good luck.

Custom ListPopupWindow rendered in different widths

I am using Android.Support.V7.Widget.ListPopupWindow as a Drop-Down Menu from a Button within my layout. Here is the code snippet I am using
void MenuIcon_Click (object sender, EventArgs e)
{
popupWindow = new Android.Support.V7.Widget.ListPopupWindow (this);
popupAdapter = new MenuPopUpAdapter (this,selectedIndex,menuList);
popupAdapter.ItemClick+= PopupAdapter_ItemClick;
popupWindow.SetAdapter (popupAdapter);
popupWindow.AnchorView = menuButton;
Display display = WindowManager.DefaultDisplay;
Point size = new Point();
display.GetSize (size);
int width = size.X;
popupWindow.Width =160;
popupWindow.Show ();
}
But while debugging I noted that, even though I have given it a static width, it is rendered differently in different devices. What is causing this issue ?
This is because of the different screen densities in Android devices. You need to mention dimensions in DPs(Density Independent Pixels) to overcome this issue. This documentation from Google will be a nice read
You can get the corresponding pixel value to be mentioned while setting dimensions programatically from this method.
public int dpToPx(int dp) {
DisplayMetrics displayMetrics = Resources.DisplayMetrics;
int px = (int)Math.Round(dp * (displayMetrics.Density));
return px;
}
You may modify the code as above to fix the issue
popupWindow.Width =dpToPx(160);

Xamarin Forms fade to hidden?

In my current app, I have a bunch of buttons which can hide or show their corresponding stackLayout.
First, i tried using IsVisble property, but this causes a flash,
now im at using LayoutTo() which also flashes?
My code is as below:
async void btnStrike_Clicked(object sender, EventArgs args)
{
var layout = this.FindByName<StackLayout>("stkStrikeInfo");
var rect = new Rectangle(layout.X, layout.Y, layout.Width, layout.Height - layout.Height);
await layout.LayoutTo(rect, 2500, Easing.Linear);
}
Id like to animate the height!
Edit:
I found the following piece of code, which removes the Stacklayout from the page.
The issue now is that the view isnt updating?
I think you'll have better luck with just a default animation that reduces the height of the layout you want to hide to zero.
void btnStrike_Clicked(object sender, EventArgs args)
{
// get reference to the layout to animate
var layout = this.FindByName<StackLayout>("stkStrikeInfo");
// setup information for animation
Action<double> callback = input => { layout.HeightRequest = input; }; // update the height of the layout with this callback
double startingHeight = layout.Height; // the layout's height when we begin animation
double endingHeight = 0; // final desired height of the layout
uint rate = 16; // pace at which aniation proceeds
uint length = 1000; // one second animation
Easing easing = Easing.CubicOut; // There are a couple easing types, just tried this one for effect
// now start animation with all the setup information
layout.Animate("invis", callback, startingHeight, endingHeight, rate, length, easing);
}
If the layout is already hidden and you want to show it, you would replace
double startingHeight = layout.Height;
double endingHeight = 0;
with
double startingHeight = 0;
double endingHeight = 55;
The 55 is just an arbitrary height, if you want it to go back to the height from before, you would save the previous height to a variable before you hide it and use that saved height instead of 55.

Win10 App - Holding & Releasing the map to manipulate an element on the interface

I working on an UWP (Win10) App with a simple location picker function. The user can drag the map on the wanted location. A basic Pushpin thats always in the center of the Map window acts as the location indicator. It works just like the free location pick in WhatsApp.
To give the user feedback that he is moving the center pin, I want to raise the pin when the user is moving the map and lower it again on release.
Here the simple code to raise the pin (and manipulate the shadow):
private void MyMap_MapHolding(MapControl sender, MapInputEventArgs args)
{
iconSwitch = true;
if(iconSwitch == true) {
centerPin.Margin = new Thickness(0, 0, 0, 60);
centerPinShadow.Opacity = 0.3;
centerPinShadow.Width = 25;
}
But this event doesn't seem to be affected on click & hold or tap & hold. Am I missing something?
FYI: I tried this out with the MyMap_MapTapped(...) method, and it worked just fine, but I need it when the map is dragged not just tapped.
Chees!
I've tested and debugged, MapHolding event can't work by me either. For your purpose, CenterChangedLink event maybe helpful, I've tested it too.
Here is part of my sample code:
RandomAccessStreamReference mapIconStreamReference;
public Maptest()
{
this.InitializeComponent();
myMap.Loaded += MyMap_Loaded;
myMap.MapTapped += MyMap_MapTapped;
myMap.MapHolding += MyMap_MapHolding;
myMap.CenterChanged += MyMap_CenterChanged;
mapIconStreamReference = RandomAccessStreamReference.CreateFromUri(new Uri("ms-appx:///Assets/MapPin.png"));
}
private void MyMap_Loaded(object sender, RoutedEventArgs e)
{
myMap.Center =
new Geopoint(new BasicGeoposition()
{
//Geopoint for Seattle
Latitude = 47.604,
Longitude = -122.329
});
myMap.ZoomLevel = 12;
}
private void MyMap_MapTapped(Windows.UI.Xaml.Controls.Maps.MapControl sender, Windows.UI.Xaml.Controls.Maps.MapInputEventArgs args)
{
var tappedGeoPosition = args.Location.Position;
string status = "MapTapped at \nLatitude:" + tappedGeoPosition.Latitude + "\nLongitude: " + tappedGeoPosition.Longitude;
rootPage.NotifyUser( status, NotifyType.StatusMessage);
}
private void MyMap_MapHolding(Windows.UI.Xaml.Controls.Maps.MapControl sender, Windows.UI.Xaml.Controls.Maps.MapInputEventArgs args)
{
var holdingGeoPosition = args.Location.Position;
string status = "MapHolding at \nLatitude:" + holdingGeoPosition.Latitude + "\nLongitude: " + holdingGeoPosition.Longitude;
rootPage.NotifyUser(status, NotifyType.StatusMessage);
}
private void MyMap_CenterChanged(Windows.UI.Xaml.Controls.Maps.MapControl sender, object obj)
{
MapIcon mapIcon = new MapIcon();
mapIcon.Location = myMap.Center;
mapIcon.NormalizedAnchorPoint = new Point(0.5, 1.0);
mapIcon.Title = "Here";
mapIcon.Image = mapIconStreamReference;
mapIcon.ZIndex = 0;
myMap.MapElements.Add(mapIcon);
}
At first I thought, even when the MapHoling event can't work, the Tapped action before holding should handled by MapTapped event, but it is seems this action is ignored. So remember, if a user hold the Map but not move it, nothing will happen.

How to refresh images in every second in windows 7 phone

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...

Resources