RadDock's SplitContainer does not fill the Windows - c#

I have the following code to create RadDock programmatically:
public void CreateDock(Control parent)
{
RadDock dock = new RadDock();
DocumentContainer docContainerLeft = new DocumentContainer();
docContainerLeft.SizeInfo.SizeMode = Telerik.WinControls.UI.Docking.SplitPanelSizeMode.Fill;
DocumentTabStrip leftDocStrip = new DocumentTabStrip();
DocumentWindow leftDoc = new DocumentWindow("Left");
leftDocStrip.Controls.Add(leftDoc);
docContainerLeft.Controls.Add(leftDocStrip);
DocumentContainer docContainerRight = new DocumentContainer();
docContainerRight.SizeInfo.SizeMode = Telerik.WinControls.UI.Docking.SplitPanelSizeMode.Fill;
DocumentTabStrip rightDocStrip = new DocumentTabStrip();
DocumentWindow rightDoc = new DocumentWindow("Right");
rightDocStrip.Controls.Add(rightDoc);
docContainerRight.Controls.Add(rightDocStrip);
RadSplitContainer middleSplitter = new RadSplitContainer(Orientation.Vertical);
middleSplitter.Dock = DockStyle.Fill;
middleSplitter.SizeInfo.SizeMode = SplitPanelSizeMode.Fill;
middleSplitter.Controls.Add(docContainerLeft);
middleSplitter.Controls.Add(docContainerRight);
dock.Controls.Add(middleSplitter);
ToolWindow transferWindow = new ToolWindow();
transferWindow.Text = "Transfer Queue";
transferWindow.DockState = DockState.Docked;
dock.DockWindow(transferWindow, DockPosition.Bottom);
dock.Dock = DockStyle.Fill;
parent.Controls.Add(dock);
}
I'm trying to make the middleSplitter to fit the window. However there is always an unwanted area at the bottom. I have a picture of it here but SO does not allow me to post an image.
My question is: How to avoid the unwanted area and make the Splitter fill the window?

The DockWindow method of RadDock might be of help in this case. Here is how you can achieve the desired look:
DocumentWindow middleDoc = new DocumentWindow("Middle");
dock.AddDocument(middleDoc);
DocumentWindow leftDoc = new DocumentWindow("Left");
dock.DockWindow(leftDoc, middleDoc, DockPosition.Top);
DocumentWindow rightDoc = new DocumentWindow("Right");
dock.DockWindow(rightDoc, leftDoc, DockPosition.Right);
ToolWindow transferWindow = new ToolWindow();
transferWindow.Text = "Transfer Queue";
transferWindow.DockState = DockState.Docked;
dock.DockWindow(transferWindow, DockPosition.Bottom);
More information and examples are available in the Telerik UI for WinForms documentation

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}";

DexExpress XPF Map in Windows Service

I'm using the DexExpress.Xpf.Map.v15.1 MapControl and trying to create code that will be able to run in a Windows Service (i.e. no front end) to generate maps as images.
I have the following code which creates a map, adds GeoPoints to a PolyLine and then adds that PolyLine to a map. This works fine in my WPF test harness application:
public MapWindow1()
{
InitializeComponent();
var mapControl = new MapControl
{
Name = "TheMap",
ZoomLevel = 4,
CenterPoint = new GeoPoint(47, 5)
};
var imageLayer = new ImageTilesLayer
{
DataProvider = new OpenStreetMapDataProvider()
};
mapControl.Layers.Add(imageLayer);
var vectorLayer = new VectorLayer();
mapControl.Layers.Add(vectorLayer);
var mapItemStorage = new MapItemStorage();
vectorLayer.Data = mapItemStorage;
var polyLineCollection = DbfGenerator.GeneratePolyLineCollection();
polyLineCollection.ForEach(line =>
{
var mapItem = new MapPolyline();
mapItemStorage.Items.Add(mapItem);
mapItem.Points.AddRange(line);
});
mapControl.MouseDoubleClick += mapControl_MouseDoubleClick;
MainGrid.Children.Add(mapControl);
}
This runs and adds the map control to the WPF page without a problem. I've then added double click handler to export the map as an image:
void mapControl_MouseDoubleClick(object sender, MouseButtonEventArgs e)
{
var m = GenerateMapPng((MapControl) sender);
m.Save(#"C:\0Temp\test.bmp");
}
public Bitmap GenerateMapPng(MapControl map)
{
Bitmap bmp;
// export image from map
using (MemoryStream ms = new MemoryStream())
{
var exportOptions = new ImageExportOptions(ImageFormat.Png);
map.ExportToImage(ms, exportOptions);
ms.Position = 0;
bmp = new Bitmap(System.Drawing.Image.FromStream(ms));
}
return bmp;
}
Again - this works without a problem.
However, If I remove the UI element and run the following code:
public MapWindow1()
{
InitializeComponent();
var mapControl = new MapControl
{
Name = "TheMap",
ZoomLevel = 4,
CenterPoint = new GeoPoint(47, 5)
};
var imageLayer = new ImageTilesLayer
{
DataProvider = new OpenStreetMapDataProvider()
};
mapControl.Layers.Add(imageLayer);
var vectorLayer = new VectorLayer();
mapControl.Layers.Add(vectorLayer);
var mapItemStorage = new MapItemStorage();
vectorLayer.Data = mapItemStorage;
var polyLineCollection = DbfGenerator.GeneratePolyLineCollection();
polyLineCollection.ForEach(line =>
{
var mapItem = new MapPolyline();
mapItemStorage.Items.Add(mapItem);
mapItem.Points.AddRange(line);
});
var m = GenerateMapPng(mapControl);
m.Save(#"C:\0Temp\test.bmp");
}
I get a NullReferenceException on the "map.ExportToImage(ms, exportOptions);" line.
I'm assuming that when the WPF application loads it calls a method to initialise the map, but I can't find anything that I can manually do to the control (Load/Init method) to mimic this.
Is there a way to trick the MapControl in to thinking it is in a WPF page when it isn't?
DevExpress said that this was not possible due to the maps reliance on the UI Thread in WPF

Add LayoutAnchorable programmatically on AvalonDock

I'm trying to add a new Control to AvalonDock from code.
Here`s the code:
var test = new LayoutAnchorable();
test.Title = "teste";
test.IsActive = true;
test.IsSelected = true;
test.ContentId = "search12";
test.Content = new TextBox();
test.AddToLayout(dockingManager, AnchorableShowStrategy.Right);
The new panel shows up, but the Content doesn't (just gray panel).
Why?

print preview and print in wpf

I have a WPF Form ,I need to print it ,i use DocumentViewer to print. but when I want to Print it or Preview , I only See the first page while i have more than one page
private void Print(object sender, RoutedEventArgs e)
{
PrintSettings printSettings = PrintSettings.Default;
UIElement container = this.Content as UIElement;
ScrollViewer containerPanel = Helper.FindVisualChildren<ScrollViewer>(container).FirstOrDefault();
var origParentDirection = containerPanel.FlowDirection;
var origDirection = (containerPanel.Content as FrameworkElement).FlowDirection;
if (containerPanel != null && containerPanel.FlowDirection == FlowDirection.RightToLeft)
{
containerPanel.FlowDirection = FlowDirection.LeftToRight;
(containerPanel.Content as FrameworkElement).FlowDirection = FlowDirection.RightToLeft;
}
var window = new Window();
string tempFileName = System.IO.Path.GetTempFileName();
System.IO.File.Delete(tempFileName);
using (XpsDocument xpsDocument = new XpsDocument(tempFileName, FileAccess.ReadWrite, System.IO.Packaging.CompressionOption.Fast))
{
XpsDocumentWriter writer = XpsDocument.CreateXpsDocumentWriter(xpsDocument);
(containerPanel.Content as FrameworkElement).Margin = new Thickness(20);
writer.Write((containerPanel.Content as FrameworkElement), printSettings.PrintTicket);
var doc = xpsDocument.GetFixedDocumentSequence();
doc.PrintTicket = printSettings.PrintTicket;
window.FlowDirection = System.Windows.FlowDirection.RightToLeft;
window.Content = new DocumentViewer { Document = doc };
window.Margin = new Thickness(10);
window.ShowDialog();
}
(containerPanel.Content as FrameworkElement).FlowDirection = origDirection;
containerPanel.FlowDirection = origParentDirection;
}
user1780436, I am currently looking for a similar answer. You are trying to print a panel, correct?
I am finding that scaling the element is the biggest problem. Which brings another issue with scaling what you want to print and not the actual visible element. You will have to copy the element to a new element.
public class Copy<T>
{
public static T DeepCopy<T>(T element)
{
string xaml = XamlWriter.Save(element);
StringReader xamlString = new StringReader(xaml);
XmlTextReader xmlTextReader = new XmlTextReader(xamlString);
var DeepCopyobject = (T)XamlReader.Load(xmlTextReader);
return DeepCopyobject;
}
}
or
myNewElement = XamlReader.Parse(XamlWriter.Save(myOldElement.DataContext)) as ElementType
I have found this answer repeatedly on multiple sites to copy/clone an element, but I have had issues with string xaml = XamlWriter.Save(element); causing stackoverflows.
I am currently using.
myNewElement = new ElementType() { DataContext = myOldElement.DataContext }
Either one you use there becomes the issue of changing the size of the Element. This is what I am looking for.
I tried a rendering pass, but that just pointed out that in my situation to use a copied/cloned element. Although while writing this I did get some of it to work, but gives me a black image, note I am trying to scale a Chart.
myNewElement.Width = newWidth;
myNewElement.Height = newHeight;
myNewElement.Measure(new System.Windows.Size(newWidth, newHeight));
myNewElement.Arrange(new Rect(0, 0, newWidth, newHeight));
I tried a layout pass, and didn't get it.
I am going to keep working on mine and I will post anything new I find. Please do the same if you find the answer.
Edit - Here is what I did. My problem and solution

Categories

Resources