public override View GetSampleContent(Context context) { Display display = ((Activity)context).WindowManager.DefaultDisplay; DisplayMetrics displayMetrics = new DisplayMetrics(); display.GetMetrics(displayMetrics); var wInches = displayMetrics.WidthPixels / (double)displayMetrics.DensityDpi; var hInches = displayMetrics.HeightPixels / (double)displayMetrics.DensityDpi; double screenDiagonal = Math.Sqrt(Math.Pow(wInches, 2) + Math.Pow(hInches, 2)); isTablet = screenDiagonal >= 7.0; //Create SfDiagram. diagram = new SfDiagram(context); diagram.EnableSelection = false; FillColor = new Dictionary <string, Color>(); FillColor.Add("Managing Director", Color.Rgb(239, 75, 93)); FillColor.Add("Project Manager", Color.Rgb(49, 162, 255)); FillColor.Add("Senior Manager", Color.Rgb(49, 162, 255)); FillColor.Add("Project Lead", Color.Rgb(0, 194, 192)); FillColor.Add("Senior S/W Engg", Color.Rgb(0, 194, 192)); FillColor.Add("Software Engg", Color.Rgb(0, 194, 192)); FillColor.Add("Team Lead", Color.Rgb(0, 194, 192)); FillColor.Add("Project Trainee", Color.Rgb(255, 129, 0)); StrokeColor = new Dictionary <string, Color>(); StrokeColor.Add("Managing Director", Color.Rgb(201, 32, 61)); StrokeColor.Add("Project Manager", Color.Rgb(23, 132, 206)); StrokeColor.Add("Senior Manager", Color.Rgb(23, 132, 206)); StrokeColor.Add("Project Lead", Color.Rgb(4, 142, 135)); StrokeColor.Add("Senior S/W Engg", Color.Rgb(4, 142, 135)); StrokeColor.Add("Software Engg", Color.Rgb(4, 142, 135)); StrokeColor.Add("Team Lead", Color.Rgb(4, 142, 135)); StrokeColor.Add("Project Trainee", Color.Rgb(206, 98, 9)); dataModel = new DataModel(); diagram.BackgroundColor = Color.White; diagram.BeginNodeRender += Dia_BeginNodeRender; dataModel.Data(); //To Represent DataSourceSttings Properties DataSourceSettings settings = new DataSourceSettings(); settings.ParentId = "ReportingPerson"; settings.Id = "Name"; settings.DataSource = dataModel.employee; diagram.DataSourceSettings = settings; //(diagram.LayoutManager.Layout as DirectedTreeLayout).IsDraggable //To Represent LayoutManager Properties diagram.LayoutManager = new LayoutManager() { Layout = new DirectedTreeLayout() { Type = LayoutType.Organization, HorizontalSpacing = 70 * MainActivity.Factor, VerticalSpacing = 70 * MainActivity.Factor } }; for (int i = 0; i < diagram.Connectors.Count; i++) { diagram.Connectors[i].TargetDecoratorType = DecoratorType.None; diagram.Connectors[i].Style.StrokeBrush = new SolidBrush(Color.Rgb(127, 132, 133)); } diagram.NodeClicked += Diagram_NodeClicked; diagram.ItemLongPressed += Diagram_ItemLongPressed; diagram.Loaded += Diagram_Loaded; int width = (int)(context.Resources.DisplayMetrics.WidthPixels - context.Resources.DisplayMetrics.Density) / 3; linearLayout4 = new LinearLayout(context); linearLayout4.Orientation = Android.Widget.Orientation.Vertical; linearLayout4.SetMinimumHeight((int)(190 * currentDensity)); linearLayout4.SetMinimumWidth(width); diagram.LayoutNodeDropped += Diagram_OnLayoutNodeDropped; return(diagram); }
public OrganizationalChart() { selectionPicker1 = new UIPickerView(); this.OptionView = new UIView(); string deviceType = UIDevice.CurrentDevice.Model; overviewLabel = new UILabel(); overviewLabel.Text = "Enable Overview"; overviewLabel.TextColor = UIColor.Black; overviewLabel.TextAlignment = UITextAlignment.Left; overviewLabel.BackgroundColor = UIColor.Clear; overviewLabel.Frame = new CGRect(this.Frame.X + 10, 70, 150, 30); overviewSwitch = new UISwitch(); overviewSwitch.On = true; overviewSwitch.Frame = new CGRect(this.Frame.X + 250, 70, 50, 30); overviewSwitch.TouchUpInside += OverviewSwitch_TouchUpInside; overviewSwitch.BackgroundColor = UIColor.Clear; dragLabel = new UILabel(); dragLabel.Text = "Change Hierarchy"; dragLabel.TextColor = UIColor.Black; dragLabel.TextAlignment = UITextAlignment.Left; dragLabel.BackgroundColor = UIColor.Clear; dragLabel.Frame = new CGRect(this.Frame.X + 10, 10, 150, 30); dragSwitch = new UISwitch(); dragSwitch.On = false; dragSwitch.Frame = new CGRect(this.Frame.X + 250, 10, 50, 30); dragSwitch.TouchUpInside += dragSwitch_TouchUpInside; dragSwitch.BackgroundColor = UIColor.Clear; diagram = new SfDiagram(); //Dictionary collection FillColor = new Dictionary <string, UIColor>(); FillColor.Add("Managing Director", UIColor.FromRGB(239, 75, 93)); FillColor.Add("Project Manager", UIColor.FromRGB(49, 162, 255)); FillColor.Add("Senior Manager", UIColor.FromRGB(49, 162, 255)); FillColor.Add("Project Lead", UIColor.FromRGB(0, 194, 192)); FillColor.Add("Senior S/W Engg", UIColor.FromRGB(0, 194, 192)); FillColor.Add("Software Engg", UIColor.FromRGB(0, 194, 192)); FillColor.Add("Team Lead", UIColor.FromRGB(0, 194, 192)); FillColor.Add("Project Trainee", UIColor.FromRGB(255, 129, 0)); StrokeColor = new Dictionary <string, CGColor>(); StrokeColor.Add("Managing Director", UIColor.FromRGB(201, 32, 61).CGColor); StrokeColor.Add("Project Manager", UIColor.FromRGB(23, 132, 206).CGColor); StrokeColor.Add("Senior Manager", UIColor.FromRGB(23, 132, 206).CGColor); StrokeColor.Add("Project Lead", UIColor.FromRGB(4, 142, 135).CGColor); StrokeColor.Add("Senior S/W Engg", UIColor.FromRGB(4, 142, 135).CGColor); StrokeColor.Add("Software Engg", UIColor.FromRGB(4, 142, 135).CGColor); StrokeColor.Add("Team Lead", UIColor.FromRGB(4, 142, 135).CGColor); StrokeColor.Add("Project Trainee", UIColor.FromRGB(206, 98, 9).CGColor); diagram.BeginNodeRender += Dia_BeginNodeRender; diagram.ItemLongPressed += Dia_ItemLongPressed; diagram.LayoutNodeDropped += Diagram_OnLayoutNodeDropped; diagram.BackgroundColor = UIColor.White; diagram.EnableSelectors = false; diagram.NodeClicked += Dia_NodeClicked; diagram.Loaded += Dia_Loaded; //Initialize Method datamodel = new DataModel(); datamodel.Data(); //To Represent DataSourceSttings Properties DataSourceSettings settings = new DataSourceSettings(); settings.ParentId = "ReportingPerson"; settings.Id = "Name"; settings.DataSource = datamodel.employee; diagram.DataSourceSettings = settings; //To Represent LayoutManager Properties diagram.LayoutManager = new LayoutManager() { Layout = new DirectedTreeLayout() { Type = LayoutType.Organization, HorizontalSpacing = 35, } }; for (int i = 0; i < diagram.Connectors.Count; i++) { diagram.Connectors[i].TargetDecoratorType = DecoratorType.None; diagram.Connectors[i].Style.StrokeBrush = new SolidBrush(UIColor.FromRGB(127, 132, 133)); diagram.Connectors[i].Style.StrokeWidth = 1; } this.AddSubview(diagram); diagram.Width = (float)this.Frame.Width; diagram.Height = (float)this.Frame.Height; OptionView.AddSubview(dragLabel); OptionView.AddSubview(dragSwitch); if (deviceType == "iPad") { OptionView.AddSubview(overviewLabel); OptionView.AddSubview(overviewSwitch); overviewPanel = new OverviewPanel(); overviewPanel.Layer.BorderColor = UIColor.Orange.CGColor; overviewPanel.Layer.BorderWidth = 2; overviewPanel.Frame = new CGRect(0, 0, UIScreen.MainScreen.Bounds.Width / 2, UIScreen.MainScreen.Bounds.Height / 4); diagram.AddSubview(overviewPanel); diagram.OverviewPanel = overviewPanel; } }
public OrganizationalChart() { parentView = new UIView(this.Frame); //Initialize the sfdiagram diagram = new SfDiagram(); //Dictionary collection FillColor = new Dictionary <string, UIColor>(); FillColor.Add("Managing Director", UIColor.FromRGB(239, 75, 93)); FillColor.Add("Project Manager", UIColor.FromRGB(49, 162, 255)); FillColor.Add("Senior Manager", UIColor.FromRGB(49, 162, 255)); FillColor.Add("Project Lead", UIColor.FromRGB(0, 194, 192)); FillColor.Add("Senior S/W Engg", UIColor.FromRGB(0, 194, 192)); FillColor.Add("Team Manager", UIColor.FromRGB(0, 194, 192)); FillColor.Add("Project Trainee", UIColor.FromRGB(255, 129, 0)); StrokeColor = new Dictionary <string, CGColor>(); StrokeColor.Add("Managing Director", UIColor.FromRGB(201, 32, 61).CGColor); StrokeColor.Add("Project Manager", UIColor.FromRGB(23, 132, 206).CGColor); StrokeColor.Add("Senior Manager", UIColor.FromRGB(23, 132, 206).CGColor); StrokeColor.Add("Project Lead", UIColor.FromRGB(4, 142, 135).CGColor); StrokeColor.Add("Senior S/W Engg", UIColor.FromRGB(4, 142, 135).CGColor); StrokeColor.Add("Team Manager", UIColor.FromRGB(4, 142, 135).CGColor); StrokeColor.Add("Project Trainee", UIColor.FromRGB(206, 98, 9).CGColor); //Defines the picker selectionPicker1 = new UIPickerView(); this.OptionView = new UIView(); datamodel = new DataModel(); PickerModel model = new PickerModel(verticalOrientationlist); selectionPicker1.Model = model; //Represent the vertical label verticalLabel = new UILabel(); verticalLabel.Text = "Orientation and ChartType"; verticalLabel.TextColor = UIColor.Black; verticalLabel.TextAlignment = UITextAlignment.Left; //Represent the vertical button verticalbutton = new UIButton(); verticalbutton.SetTitle("Vertical", UIControlState.Normal); verticalbutton.SetTitleColor(UIColor.Black, UIControlState.Normal); verticalbutton.HorizontalAlignment = UIControlContentHorizontalAlignment.Center; verticalbutton.Layer.CornerRadius = 8; verticalbutton.Layer.BorderWidth = 2; verticalbutton.TouchUpInside += ShowPicker1; verticalbutton.BackgroundColor = UIColor.Gray; verticalbutton.Layer.BorderColor = UIColor.FromRGB(246, 246, 246).CGColor; //Represent the horizontal button horizontalbutton = new UIButton(); horizontalbutton.SetTitle("Horizontal", UIControlState.Normal); horizontalbutton.SetTitleColor(UIColor.Black, UIControlState.Normal); horizontalbutton.HorizontalAlignment = UIControlContentHorizontalAlignment.Center; horizontalbutton.Layer.CornerRadius = 8; horizontalbutton.Layer.BorderWidth = 2; horizontalbutton.TouchUpInside += ShowPicker1; horizontalbutton.Layer.BorderColor = UIColor.FromRGB(246, 246, 246).CGColor; //Represent the button doneButton.SetTitle("Done\t", UIControlState.Normal); doneButton.SetTitleColor(UIColor.Black, UIControlState.Normal); doneButton.HorizontalAlignment = UIControlContentHorizontalAlignment.Right; doneButton.TouchUpInside += HidePicker; doneButton.Hidden = true; doneButton.BackgroundColor = UIColor.FromRGB(246, 246, 246); model.PickerChanged += SelectedIndexChanged; selectionPicker1.ShowSelectionIndicator = true; selectionPicker1.Hidden = true; this.OptionView = new UIView(); }