or
//COnstructor accepting string
public
ucCsvEditor(
string
csv)
{
InitializeComponent();
using
(StringReader sr =
new
StringReader(csv))
{
var reader =
new
CsvReader(sr);
//CSVReader will now read the whole file into an enumerable
while
(reader.Read())
{
string
[] records = reader.CurrentRecord;
string
[] headers = reader.FieldHeaders;
variablesValue.Add(records);
variablesHeader.Add(headers);
}
//ObservableCollection<string[]> myCollection = new ObservableCollection<string[]>(variablesValue);
radGridView.ItemsSource = variablesValue;
//reader.FieldHeaders
}
}
<
Grid
>
<
telerik:RadGridView
x:Name
=
"radGridView"
Grid.Row
=
"0"
AutoGenerateColumns
=
"True"
IsReadOnly
=
"False"
CanUserDeleteRows
=
"False"
/>
</
Grid
>
if
(!
string
.IsNullOrEmpty(csvData))
{
RadWindow winCsvEditor =
new
RadWindow();
ucCsvEditor temp =
new
ucCsvEditor(csvData);
winCsvEditor.Content = temp;
winCsvEditor.Header =
"CSV Editor"
;
winCsvEditor.Owner =
this
;
winCsvEditor.WindowStartupLocation = System.Windows.WindowStartupLocation.CenterOwner;
winCsvEditor.CanClose =
true
;
winCsvEditor.ShowDialog();
}
else
{
MessageBox.Show(
"No Variables available to edit"
);
}
<
telerik:RadSplitContainer
InitialPosition
=
"DockedRight"
telerik:ProportionalStackPanel.RelativeSize
=
"200, 10"
>
<
telerik:RadPaneGroup
prism:RegionManager.RegionName
=
"{x:Static inf:RegionNames.RightSidebarRegion}"
/>
</
telerik:RadSplitContainer
>
When we inject this view that has IsPinned="False"
<
Telerik:RadPane
…............…..
IsPinned
=
"False"
>
<
Grid
>
<
TextBlock
Text
=
"some text"
/>
</
Grid
>
</
Telerik:RadPane
>
IRegion sidebarRegion = RegionManager.Regions[RegionNames.RightSidebarRegion];
SideBars.ToList().ForEach(sidebarRegion.Remove);
public
BackgroundWorker worker =
new
BackgroundWorker();
public
Window1()
{
InitializeComponent();
InitializeBackgroundWorker();
}
// Set up the BackgroundWorker object by
// attaching event handlers.
private
void
InitializeBackgroundWorker()
{
worker.DoWork +=
new
DoWorkEventHandler(worker_DoWork);
worker.RunWorkerCompleted +=
new
RunWorkerCompletedEventHandler(worker_RunWorkerCompleted);
}
//Define a New Chart Data Class for each graph
public
class
ChartDataClass1
{
public
double
X1 {
get
;
set
; }
public
double
Y1 {
get
;
set
; }
public
ChartDataClass1()
{
}
}
public
class
ChartDataClass2
{
public
double
X2 {
get
;
set
; }
public
double
Y2 {
get
;
set
; }
public
ChartDataClass2()
{
}
}
private
void
btn1_Click(
object
sender, RoutedEventArgs e)
{
worker.RunWorkerAsync();
}
void
worker_DoWork(
object
sender, DoWorkEventArgs e)
{
// On the worker thread...cannot make UI calls from here.
e.Result = MTLB(worker,e);
}
private
void
worker_RunWorkerCompleted(
object
sender, RunWorkerCompletedEventArgs e)
{
// First, handle the case where an exception was thrown.
if
(e.Error !=
null
)
{
MessageBox.Show(e.Error.Message);
}
else
{
// Finally, handle the case where the operation
// succeeded.
xline.Series[0].ItemsSource = (System.Collections.IEnumerable)e.Result;
}
}
public
System.Collections.Generic.List<ChartDataClass1> MTLB(BackgroundWorker worker, DoWorkEventArgs e)
{
int
st = 1;
int
sp = 20;
//MATLAB inputs
MWNumericArray start = 1;
MWNumericArray stop = 20;
//MATLAB fn
Reactor.Class1 rxtr_lib =
new
Reactor.Class1();
MWArray[] result = rxtr_lib.rxtr(1, start, stop);
System.Array NH3 =
new
double
[2 * (sp - st + 1)];
NH3 = ((MWNumericArray)result[0]).ToVector(MWArrayComponent.Real);
List<ChartDataClass1> chartData1 =
new
List<ChartDataClass1>();
List<ChartDataClass2> chartData2 =
new
List<ChartDataClass2>();
for
(
int
i = 0; i < (sp - st); i++)
{
ChartDataClass1 cdc =
new
ChartDataClass1();
ChartDataClass2 cdc2 =
new
ChartDataClass2();
cdc.X1 = i;
cdc.Y1 = Convert.ToDouble(NH3.GetValue(2 * i));
cdc2.X2 = i;
cdc2.Y2 = Convert.ToDouble(NH3.GetValue(2 * i + 1));
chartData1.Add(cdc);
chartData2.Add(cdc2);
}
return
chartData1;
}
I am using the Office2013 theme.What is the easiest way to change the application font?
I can see that the Windows8 themes have an option for this:
//Windows8 Resources
Windows8Palette.Palette.FontSizeXS = 10;
Windows8Palette.Palette.FontFamily = new FontFamily("Segoe UI");
private
void
Button_Click(
object
sender, RoutedEventArgs e)
{
ChartBaseParameter ChartParam =
new
ChartBaseParameter()
{
XAxisField =
"x"
,
YAxisFields =
new
List<
string
>() {
"y"
}
};
DataTable dt =
new
DataTable();
dt.Columns.Add(
"x"
,
typeof
(
int
));
dt.Columns.Add(
"y"
,
typeof
(
int
));
dt.Rows.Add(1, 1);
dt.Rows.Add(2, 2);
this
.ChartPanel.SeriesMappings.Clear();
this
.ChartPanel.SortDescriptors.Clear();
this
.ChartPanel.ItemsSource =
null
;
var chart = InitChart(
this
.ChartPanel, ChartParam,
true
, dt);
var fileName =
"C:\\myChart.jpg"
;
chart.ExportToImage(fileName,
new
PngBitmapEncoder());
}
public
static
RadChart InitChart(RadChart chartPanel, ChartBaseParameter chartParam,
bool
showError, System.Data.DataTable chartTable)
{
bool
showItemLabels =
true
;
AnimationManager.IsGlobalAnimationEnabled =
false
;
chartPanel.DefaultView.ChartArea.EnableAnimations =
false
;
chartPanel.BeginInit();
chartPanel.Width = 300;
chartPanel.Height = 300;
BarLabelSettings barLabelSetting =
new
BarLabelSettings();
barLabelSetting.Distance = 10;
barLabelSetting.LabelDisplayMode = LabelDisplayMode.Outside;
barLabelSetting.ShowConnectors =
true
;
foreach
(var YItem
in
chartParam.YAxisFields)
{
SeriesMapping seriesmappingi =
new
SeriesMapping() { LegendLabel = YItem };
seriesmappingi.SeriesDefinition =
new
BarSeriesDefinition() { ShowItemLabels = showItemLabels, LabelSettings = barLabelSetting };
seriesmappingi.ItemMappings.Add(
new
ItemMapping(
"y"
, DataPointMember.YValue) { FieldType =
typeof
(
int
) });
seriesmappingi.ItemMappings.Add(
new
ItemMapping(
"x"
, DataPointMember.XCategory) { FieldType =
typeof
(
int
) });
seriesmappingi.ItemMappings.Add(
new
ItemMapping(
"x"
, DataPointMember.LegendLabel) { FieldType =
typeof
(
int
) });
chartPanel.SeriesMappings.Add(seriesmappingi);
}
chartPanel.DefaultView.ChartArea.AxisX.LabelRotationAngle = -90;
chartPanel.DefaultView.ChartArea.ZoomScrollSettingsX.MinZoomRange = 0.01;
chartPanel.DefaultView.ChartArea.AxisX.Title = chartParam.XAxisField;
chartPanel.DefaultView.ChartArea.ZoomScrollSettingsX.ScrollMode = ScrollMode.ScrollAndZoom;
chartPanel.DefaultView.ChartArea.AxisY.ExtendDirection = AxisExtendDirection.Both;
chartPanel.DefaultView.ChartArea.LabelFormatBehavior = LabelFormatBehavior.None;
chartPanel.DefaultSeriesDefinition.LegendDisplayMode = LegendDisplayMode.DataPointLabel;
chartPanel.EndInit();
chartPanel.Measure(
new
Size(1024, 768));
chartPanel.Arrange(
new
System.Windows.Rect(
new
Point(0, 0), chartPanel.DesiredSize));
chartPanel.ItemsSource = chartTable;
chartPanel.Rebind();
chartPanel.UpdateLayout();
return
chartPanel;
}
}
public
class
ChartBaseParameter
{
public
string
XAxisField;
public
List<
string
> YAxisFields;
}