how to switch from one tab to another tab Xamarin IOS - c#

I created UITabBarController class to have 5 ViewControllers
controller1 = new Controller1();
controller2 = new Controller2();
controller3 = new Controller3();
controller4 = new Controller4();
controller5 = new Controller5();
controller1.TabBarItem = new UITabBarItem ("first", UIImage.FromFile("/Images/first.png"), 0);
controller5.TabBarItem = new UITabBarItem ("second", UIImage.FromFile("/Images/four.png"), 1);
controller5.TabBarItem = new UITabBarItem ("third", UIImage.FromFile("/Images/four.png"), 2);
controller5.TabBarItem = new UITabBarItem ("four", UIImage.FromFile("/Images/four.png"), 3);
controller5.TabBarItem = new UITabBarItem ("five", UIImage.FromFile("/Images/four.png"), 4);
var tabs = new UIViewController[] {
controller1, controller2, controller3, controller4, controller5
};
ViewControllers = tabs;
In the third controller I have a submit button.
On submit button action, I would like to switch tab from controller3 to controller5.
How would I go about doing this?

Something like this:
this.TabBarController.SelectedIndex = 4;

Related

c# Help creating a new tab with new rdp session in side of it

Any advice greatly appreciated.
I'm trying to dynamically create a tab, and inside of that tab, create a new rdp control.
I've got the tab creation fine. The RDP session seems like it's running through the code, but it never renders anything on the screen and never errors out.
I have the tab presented, but with no content.
Thanks.
TabPage myTabPage = new TabPage(tabtitle);
tabControl1.TabPages.Add(myTabPage);
AxMsTscAxNotSafeForScripting rdp4 = new AxMSTSCLib.AxMsTscAxNotSafeForScripting();
((System.ComponentModel.ISupportInitialize)(rdp4)).BeginInit();
rdp4.CreateControl();
myTabPage.Controls.Add(rdp4);
rdp4.Dock = System.Windows.Forms.DockStyle.Fill;
rdp4.Enabled = true;
rdp4.Location = new System.Drawing.Point(3, 3);
rdp4.Name= targetdevice;
rdp4.OcxState = ((System.Windows.Forms.AxHost.State)(new ComponentResourceManager(typeof(Form1)).GetObject("rdp4.OcxState")));
rdp4.Size = new System.Drawing.Size(574, 529);
rdp4.TabIndex = 0;
var settings = (MSTSCLib.IMsRdpClientAdvancedSettings8)rdp4.AdvancedSettings;
settings.allowBackgroundInput = 1;
settings.ClientProtocolSpec = MSTSCLib.ClientSpec.FullMode;
settings.ConnectToServerConsole = true;
settings.EnableCredSspSupport = true;
settings.EncryptionEnabled = 1;
settings.SmartSizing = true;
rdp4.DesktopHeight = 768;
rdp4.DesktopWidth = 1366;
rdp4.Server = targetdevice;
rdp4.UserName = txt_user.Text;
IMsTscNonScriptable secured = (IMsTscNonScriptable)rdp4.GetOcx();
secured.ClearTextPassword = txt_password.Text;
rdp4.Connect();
tabControl1.SelectedTab = myTabPage;

How to customize a tooltip for each individual datapoint in a wpf toolkit lineseries chart?

I have seen several questions about doing a custom tooltip for a single line series.
I need a custom tool-tip for each data-point. I would like to add more to the tool-tip than just the dependent value path and the independent value path.
Example I have 2 data points on the same line one with a value(Y-axis)
of 2, date(x-axis) of 4/28/2016, and configuration of A. The other has
a value of 3, date of 4/29/2016, and configuration of B.
How would I also show the configurations? This is all done in code behind because I have a dynamic number of lineseries. So I can't just assign a style to each lineseries in the xaml.
var MyLineSeries = new LineSeries();
lMyLineSeries.DependentValuePath = "Y";
lMyLineSeries.IndependentValuePath = "X";
lMyLineSeries.DataPointStyle = lToolTipDataPointStyle;
This is my code for creating the tool tip style.
var lToolTipDataPointStyle = new Style(typeof(LineDataPoint));
var lTemplate = new ControlTemplate(typeof(LineDataPoint));
var lGridElement = new FrameworkElementFactory(typeof(Border));
//Tooltip
var lStackPanel = new StackPanel();
var lValueContentControl = new ContentControl();
lValueContentControl.SetBinding(ContentControl.ContentProperty, new Binding(myLineSeries.DependentValuePath));
lValueContentControl.ContentStringFormat = "Value: {0}";
var lConfigurationContentControl = new ContentControl();
lConfigurationContentControl.SetBinding(ContentControl.ContentProperty, new Binding())//This is what Idk what to bind to???
lConfigurationContentControl.ContentStringFormat = "Configuration: {0}";
lStackPanel.Children.Add(lValueContentControl);
lStackPanel.Children.Add(lConfigurationContentControl);
lGridElement.SetValue(ToolTipService.ToolTipProperty, lStackPanel);
var lEllipseElement = new FrameworkElementFactory(typeof(Ellipse));
lEllipseElement.SetValue(Ellipse.StrokeThicknessProperty, new TemplateBindingExtension(Border.BorderThicknessProperty));
lEllipseElement.SetValue(Ellipse.StrokeProperty, new TemplateBindingExtension(Border.BorderBrushProperty));
lEllipseElement.SetValue(Ellipse.FillProperty, new TemplateBindingExtension(Grid.BackgroundProperty));
lGridElement.AppendChild(lEllipseElement);
lTemplate.VisualTree = lGridElement;
var lTemplateSetter = new Setter();
lTemplateSetter.Property = LineDataPoint.TemplateProperty;
lTemplateSetter.Value = lTemplate;
lToolTipDataPointStyle.Setters.Add(lTemplateSetter);
return lToolTipDataPointStyle;
I figured it out by using the Tag on the Line series.
myLineSeries.Tag = "Configuration";
var lConfigurationContentControl = new ContentControl();
lConfigurationContentControl.SetBinding(ContentControl.ContentProperty, new Binding(myLineSeries.Tag.ToString()))
lConfigurationContentControl.ContentStringFormat = "Configuration: {0}";

Persist Dynamically Added Controls w/ DataTriggers WPF

I am currently working on a WPF project that uses Caliburn.Micro and have hit a snag I was hoping you could help with. I have a form that allows the user to add new fields to a separate form with the intention that these new fields will persist. I am able to create these controls dynamically with the following code:
Grid tmpOuterGrid = new Grid();
RowDefinition rowDefinition1 = new RowDefinition();
RowDefinition rowDefinition2 = new RowDefinition();
rowDefinition1.Height = new GridLength(45, GridUnitType.Star);
rowDefinition2.Height = new GridLength(55, GridUnitType.Star);
tmpOuterGrid.RowDefinitions.Add(rowDefinition1);
tmpOuterGrid.RowDefinitions.Add(rowDefinition2);
tmpOuterGrid.Margin = new Thickness(0,0,0,10);
Grid tmpInnerGrid = new Grid();
Grid.SetRow(tmpInnerGrid, 0);
tmpInnerGrid.Margin = new Thickness(10,0,0,5);
tmpInnerGrid.Opacity = 0;
DataTrigger d = new DataTrigger();
Binding b = new Binding("DisplayFieldName");
b.Source = _fieldNames[primaryNameBase + "FieldTextBox"];
d.Binding = b;
d.Value = true;
Storyboard sbEnter = new Storyboard();
DoubleAnimation opAnimShow = new DoubleAnimation(1,new Duration(new TimeSpan(0,0,0,1)));
Storyboard.SetTargetProperty(sbEnter, new PropertyPath(UIElement.OpacityProperty));
sbEnter.Children.Add(opAnimShow);
Storyboard sbExit = new Storyboard();
DoubleAnimation opAnimHide = new DoubleAnimation(0, new Duration(new TimeSpan(0, 0, 0, 1)));
Storyboard.SetTargetProperty(sbExit, new PropertyPath(UIElement.OpacityProperty));
sbExit.Children.Add(opAnimHide);
BeginStoryboard bsEnter = new BeginStoryboard { Storyboard = sbEnter, Name = "beginStoryboardEnter" };
BeginStoryboard bsExit = new BeginStoryboard { Storyboard = sbExit, Name = "beginStoryboardExit" };
d.EnterActions.Add(bsEnter);
d.ExitActions.Add(bsExit);
Style st = new Style(typeof(Grid));
st.Triggers.Add(d);
tmpInnerGrid.Style = st;
TextBlock tb = new TextBlock();
tb.Name = primaryNameBase + "FieldHeaderText";
tb.Foreground = new SolidColorBrush(Color.FromArgb(136,255,255,255));
tb.FontSize = 14;
tb.Style = (Style) App.Current.Resources["NexaLightTextBlock"];
tb.HorizontalAlignment = HorizontalAlignment.Center;
tb.Text = fieldTextBox.DisplayText;
Border underline = new Border();
underline.BorderThickness = new Thickness(0, 0, 0, 1);
underline.BorderBrush = new SolidColorBrush(Color.FromArgb(136,49,250,250));
underline.VerticalAlignment = VerticalAlignment.Bottom;
underline.HorizontalAlignment = HorizontalAlignment.Center;
Binding binding = new Binding
{
Source = tb,
Path = new PropertyPath("ActualWidth"),
};
underline.SetBinding(FrameworkElement.WidthProperty, binding);
tmpInnerGrid.Children.Add(tb);
tmpInnerGrid.Children.Add(underline);
LowBorderTextBox lbtb = new LowBorderTextBox();
lbtb.Name = primaryNameBase + "FieldTextBox";
Grid.SetRow(lbtb, 1);
lbtb.Width = 140;
lbtb.Margin = new Thickness(10,0,0,0);
lbtb.FontColor = new SolidColorBrush(Colors.White);
lbtb.DisplayFontSize = 22;
lbtb.Style = (Style) App.Current.Resources["NexaLightCustomTextBox"];
lbtb.DisplayText = fieldTextBox.DisplayText;
lbtb.LostFocus += FieldLostFocus;
tmpOuterGrid.Children.Add(tmpInnerGrid);
tmpOuterGrid.Children.Add(lbtb);
wrapPanel.Children.Add(tmpOuterGrid);
I would then like these new controls to be persisted through application shutdowns. The approach I was thinking of taking was serializing the object into xaml and storing that in a file, and then reading this file and deserializing it to obtain the control object again, which would be added to my surrounding WrapPanel. This is all fine and dandy except for one detail. The controls that are created have a style with a datatrigger that is bound to a property of a NoteField object, there being one NoteField object for each of these types of control. I was planning on serializing the NoteField objects as well, so that I could just pull them back and hope that the binding would still be intact, but they implement the PropertyChangedBase interface of the Caliburn.Micro framework, and the NotifyOfPropertyChange() method is not marked as serializable. Here is the NoteField class:
[Serializable]
class NoteField : PropertyChangedBase
{
private string _controlName;
private bool _displayFieldName;
public bool DisplayFieldName
{
get { return _displayFieldName; }
set
{
_displayFieldName = value;
NotifyOfPropertyChange(() => DisplayFieldName);
}
}
private string _fieldName;
public string FieldName
{
get { return _fieldName; }
set
{
_fieldName = value;
NotifyOfPropertyChange(() => FieldName);
}
}
public NoteField(string controlName, string displayText)
{
DisplayFieldName = false;
_controlName = controlName;
FieldName = displayText;
}
public string GetControlName()
{
return _controlName;
}
public void SetControlName(string name)
{
_controlName = name;
}
}
I am not attached to using this class, but it was the only way I could think of having dynamically generated properties to bind to from the xaml. So, I guess my question is: is there a way that I can dynamically create controls that have bindings in them that can persist through application shutdowns? Am I on the right track, or should I do something else all together? Any help would be greatly appreciated. Thank you so much for your time.

How to store user-controls for future editing

Can somebody help me to figure out with - how to store correctly Array of Controls added programmatically in my application?
To be more explicitly, I have a function that create programmatically some Labels and PictureBoxes, and added it to Panel Control.
var lbLip = new Label { Text = #"LIP :", Location = new Point(5, 20), Size = new Size(29, 13) };
var lbLipVar = new Label { Text = "", Location = new Point(32, 20), Size = new Size(79, 13) };
var lbRip = new Label { Text = #"RIP :", Location = new Point(5, 40), Size = new Size(31, 13) };
var lbRipVar = new Label { Text = "", Location = new Point(32, 40), Size = new Size(70, 13) };
var imgBox = new PictureBox { Image = Image.FromFile(#"data\icon\red.png"), Location = new Point(100, 40), Size = new Size(16, 11) };
var lbPid = new Label { Text = #"PID :", Location = new Point(5, 60), Size = new Size(31, 13) };
var lbPidVar = new Label { Text = "", Location = new Point(32, 60), Size = new Size(37, 13) };
var lbTime = new Label { Text = #"Time :", Location = new Point(80, 60), Size = new Size(39, 13) };
var lbTimeVar = new Label { Text = "", Location = new Point(115, 60), Size = new Size(49, 13) };
var arrayLb = new Control[9];
arrayLb[0] = lbLip;
arrayLb[1] = lbLipVar;
arrayLb[2] = lbRip;
arrayLb[3] = lbRipVar;
arrayLb[4] = imgBox;
arrayLb[5] = lbPid;
arrayLb[6] = lbPidVar;
arrayLb[7] = lbTime;
arrayLb[8] = lbTimeVar;
plObject.Controls.AddRange(arrayLb);
And now the problem is - how to store this array of Controls for the future updating (editing/removing).
Can somebody suggests a solution how to do this right?
My idea was to create a list of controls
public static List<Control> LiControls = new List<Control>();
and store in it. However I have a lots of Controls to add (~200) - and its hard to handle them all.
I would have create a seperate Serializable class with the properties you need to persist. You can save it to an xml file with the XmlSerializer and if you need to save more properties in the future, just add them to the class and the XmlSerializer will save and load the new properties properly. Good luck !

Set DateTimeCreate with EWS Proxy classes

Is it possible to change CreationDateTime, SentDateTime, etc.????
I`m tring to create/update message. All run fine, but i need to set field ItemType.CreateDateTime with my values (eg. I need to create message that has time creation not today, but year ego).
I have next code:
//Update created item
ItemIdType itemId = new ItemIdType();
itemId.Id = savedMessageId;
itemId.ChangeKey = savedMessageChangeKey;
ItemType setCreateDT = new ItemType();
setCreateDT.DateTimeCreated = new System.DateTime(2000, 10, 10, 12, 12, 12);
setCreateDT.DateTimeCreatedSpecified = true;
SetItemFieldType setItemField = new SetItemFieldType();
setItemField.Item = new PathToUnindexedFieldType();
(setItemField.Item as PathToUnindexedFieldType).FieldURI = UnindexedFieldURIType.itemDateTimeCreated;
setItemField.Item1 = setCreateDT;
UpdateItemType request = new UpdateItemType();
request.ItemChanges = new ItemChangeType[1] { new ItemChangeType() };
request.ItemChanges[0].Item = itemId;
request.ItemChanges[0].Updates = new ItemChangeDescriptionType[1];
request.ItemChanges[0].Updates[0] = setItemField;
request.MessageDisposition = MessageDispositionType.SaveOnly;
request.MessageDispositionSpecified = true;
UpdateItemResponseType updateItemResponse = m_mailbox.UpdateItem(request);
That request return Error: "Set action is invalid for property."
If im tring to change Subject, all run OK.
[UPDATE]
Found next solution, but it doesn`t work.
There is using extended properties and their ids.
PathToExtendedFieldType q = new PathToExtendedFieldType();
q.PropertyId = 3590; //DeliveryTime
q.PropertyType = MapiPropertyTypeType.SystemTime;
q.PropertyIdSpecified = true;
newItem.ExtendedProperty[0] = new ExtendedPropertyType();
newItem.ExtendedProperty[0].ExtendedFieldURI = q;
newItem.ExtendedProperty[0].ExtendedFieldURI.DistinguishedPropertySetIdSpecified = true;
newItem.ExtendedProperty[0].Item = new System.DateTime(2013, 5, 5, 5, 5, 5).ToString("yyyy-MM-ddTHH:mm:ssZ");
...
CreateItemResponseType createItemResponse = m_mailbox.CreateItem(createItemType);
It works fine, but i don`t see any changes..
Second solution is correct, but there are some mistakes.
1) It's better to get access to properties by PropertyTag.
2) You should only set up PropertyTag and PropertyType.
Here is working code:
ItemType newItem = xmlParser.LoadItem(); //info for newItem takes from xml
newItem.ExtendedProperty = new ExtendedPropertyType[1];
PathToExtendedFieldType q = new PathToExtendedFieldType();
q.PropertyTag = "3590"; //DeliveryTime
q.PropertyType = MapiPropertyTypeType.SystemTime;
newItem.ExtendedProperty[0] = new ExtendedPropertyType();
newItem.ExtendedProperty[0].ExtendedFieldURI = q;
newItem.ExtendedProperty[0].Item = new System.DateTime(2014, 5, 5, 5, 5, 5).ToString("yyyy-MM-ddTHH:mm:ssZ");

Categories

Resources