private void Form1_Load(object sender, EventArgs e) {
CreateStarSchemaObjects(); DoSpringLayout(); }
private void CreateStarSchemaObjects() { Box boxFact1 = CreateFact("Fact1",100, 100, 100, 100); Box boxFact2 = CreateFact("Fact2",250, 100, 100, 100);
Box boxDim1 = CreateDimension("Dim1", 100, 300, 100, 100); Box boxDim2 = CreateDimension("Dim2", 250, 300, 100, 100); Box boxDim3 = CreateDimension("Dim3", 400, 300, 100, 100); Box boxDim4 = CreateDimension("Dim4", 550, 300, 100, 100);
//Create some relationships (arrows) Arrow arwFact1Dim1 = flowChart1.CreateArrow(boxFact1, boxDim1); Arrow arwFact1Dim2 = flowChart1.CreateArrow(boxFact1, boxDim2); Arrow arwFact1Dim3 = flowChart1.CreateArrow(boxFact1, boxDim3); Arrow arwFact1Dim4 = flowChart1.CreateArrow(boxFact1, boxDim4);
Arrow arwFact2Dim1 = flowChart1.CreateArrow(boxFact2, boxDim1); Arrow arwFact2Dim2 = flowChart1.CreateArrow(boxFact2, boxDim2); Arrow arwFact2Dim4 = flowChart1.CreateArrow(boxFact2, boxDim4);
}
private Box CreateFact(string FactName, float x, float y, float width, float height) { Box fact = flowChart1.CreateBox(x,y,width,height);
fact.Font = new Font("Verdana", 8); fact.Text = FactName.ToUpper() + CRLF;
for (int i = 0; i <= 10; i++ ) fact.Text += CRLF + "Column" + i.ToString(); fact.Text += CRLF + CRLF;
fact.FitSizeToText(FitSize.KeepWidth);
fact.Brush = new MindFusion.FlowChartX.LinearGradientBrush(Color.FromArgb(255, 128, 0), Color.FromArgb(255, 255, 0), 315); return fact; }
private Box CreateDimension(string DimName, float x, float y, float width, float height) { Box dim = flowChart1.CreateBox(x, y, width, height);
dim.Font = new Font("Verdana", 8);
dim.Text = DimName.ToUpper() + CRLF;
for (int i = 0; i <= 5; i++) dim.Text += CRLF + "Column" + i.ToString(); dim.Text += CRLF + CRLF;
dim.FitSizeToText(FitSize.KeepWidth);
//dim.Brush = new LinearGradientBrush(Color.AliceBlue, Color.CadetBlue, 45); dim.Brush = new MindFusion.FlowChartX.LinearGradientBrush(Color.FromArgb(0, 128, 255), Color.FromArgb(0, 255, 255), 315);
return dim; }
private void DoSpringLayout() {
// Create the layouter object SpringLayout layout = new SpringLayout();
// Adjust the attributes of the layouter layout.IterationCount = Int32.Parse(txtIterations.Text); //textbox layout.NodeDistance = Int32.Parse(txtNodeSpace.Text); //textbox layout.MinimizeCrossings = cboMinimiseCrossings.Checked; //checkbox layout.RepulsionFactor = 100; layout.EnableClusters = true;
// Perform the actual arrangement layout.Arrange(flowChart1);
}
|