public ViewEngineResult FindView(ControllerContext controllerContext, string viewName, string masterName, bool useCache) { var viewResult = _themeAwareViewEngine.FindPartialView(controllerContext, viewName, useCache, true); if (viewResult.View == null) { return viewResult; } if (!ThemeFilter.IsApplied(controllerContext.RequestContext)) { return viewResult; } var layoutView = new LayoutView((viewContext, writer, viewDataContainer) => { Logger.Information("Rendering layout view"); var childContentWriter = new HtmlStringWriter(); var childContentViewContext = new ViewContext( viewContext, viewContext.View, viewContext.ViewData, viewContext.TempData, childContentWriter); viewResult.View.Render(childContentViewContext, childContentWriter); _workContext.Layout.Metadata.ChildContent = childContentWriter; var display = _displayHelperFactory.CreateHelper(viewContext, viewDataContainer); IHtmlString result = display(_workContext.Layout); writer.Write(result.ToHtmlString()); Logger.Information("Done rendering layout view"); }, (context, view) => viewResult.ViewEngine.ReleaseView(context, viewResult.View)); return new ViewEngineResult(layoutView, this); }
public virtual ActionResult CreateLayout(LayoutView created) { var startnode = _entities.FlowSteps.SingleOrDefault(x => x.FlowType==1 && x.StepType == 0); if (ModelState.IsValid) { var newlayout = created.ToModel(); newlayout.FlowState = startnode.StepID; var js = " $('.info_div').hide();$('#successbaseinfo').fadeIn('slow');"; try { _entities.Layouts.AddObject(newlayout); _entities.SaveChanges(); var log = new FlowLog { LayoutID = newlayout.LayoutID, Startdate = DateTime.Now, ActiveFlag = true, ToDoby = _entities.Users.SingleOrDefault( x => x.UserName.Trim() == User.Identity.Name.Trim()).UserID, LogStep = startnode.StepID }; _entities.FlowLogs.AddObject(log); _entities.SaveChanges(); return JavaScript(js); } catch { js = " $('.info_div').hide();$('#failbaseinfo').fadeIn('slow');"; return JavaScript(js); } } return JavaScript(" $('.info_div').hide(); $('#warningbaseinfo').fadeIn('slow');"); }
public LayoutViewModel(LayoutView layoutView) { LayoutView = layoutView; AddWorkerCommand = new RelayCommand(ExecAddWorker, CanAdd); AddCustomerCommand = new RelayCommand(ExecAddCustomer, CanAdd); AddCPUCommand = new RelayCommand(ExecAddCPU, CanAdd); AddGPUCommand = new RelayCommand(ExecAddGPU, CanAdd); AddMotherboardCommand = new RelayCommand(ExecAddMotherboard, CanAdd); AddMemoryCommand = new RelayCommand(ExecAddMemory, CanAdd); AddStorageCommand = new RelayCommand(ExecAddStorage, CanAdd); AddPSUCommand = new RelayCommand(ExecAddPSU, CanAdd); AddCaseCommand = new RelayCommand(ExecAddCase, CanAdd); NewCartCommand = new RelayCommand(ExecNewCart, CanAdd); }
public async Task <IActionResult> SetLayoutView(LayoutView view) { Response.Cookies.Append(LayoutCookieKey, view.GetEnumMemberValue()); var user = await _userManager.GetUserAsync(HttpContext.User); if (user == null) { return(Json(new { Success = true })); } user.Settings.LayoutView = view; await _userManager.UpdateAsync(user); return(Json(new { Success = true })); }
private void setReload() { try { DataTable dt; using (var ds = new System.Data.DataSet()) { using (SqlDataAdapter ada = new SqlDataAdapter("SELECT Name,ProfileID FROM Receipt.tblProfile ", Logic.ConnectionString)) { ada.Fill(ds, "Profile"); } using (SqlDataAdapter ada1 = new SqlDataAdapter("SELECT ProfileID,AgencyName,BranchName,Description,Bank,Revenue,Agency,BankBranch FROM dbo.ViewProflieCriteria", Logic.ConnectionString)) { ada1.Fill(ds, "Criteria"); } DataColumn keyColumn = ds.Tables["Profile"].Columns["ProfileID"]; DataColumn foreignKeyColumn = ds.Tables["Criteria"].Columns["ProfileID"]; ds.Relations.Add("Profile1", keyColumn, foreignKeyColumn); dt = ds.Tables[0]; if (dt != null && dt.Rows.Count > 0) { //gridControl3.DataSource = ds.Tables["office"]; //gridControl3.ForceInitialize(); gridControl1.DataSource = ds.Tables["Profile"]; gridControl1.ForceInitialize(); LayoutView lView = new LayoutView(gridControl1); gridControl1.LevelTree.Nodes.Add("Name", lView); lView.ViewCaption = "Proflie Criteria"; gridView1.OptionsBehavior.Editable = false; gridView1.Columns["ProfileID"].Visible = false; //gridView1.Columns["ProfileID"].Visible = false; gridView1.BestFitColumns(); } } } catch (Exception ex) { Tripous.Sys.ErrorBox(ex.Message.ToString()); return; } }
private void layoutView1_MouseMove(object sender, MouseEventArgs e) { LayoutView view = sender as LayoutView; if (e.Button == MouseButtons.Left && downHitInfo != null) { Size dragSize = SystemInformation.DragSize; Rectangle dragRect = new Rectangle(new Point(downHitInfo.HitPoint.X - dragSize.Width / 2, downHitInfo.HitPoint.Y - dragSize.Height / 2), dragSize); if (!dragRect.Contains(new Point(e.X, e.Y))) { view.GridControl.DoDragDrop(downHitInfo, DragDropEffects.All); downHitInfo = null; } } }
private ColumnView CreateView() { if (viewType == ViewType.Card) { detailView = new CardView(DetailGrid); } else if (viewType == ViewType.Grid) { detailView = new GridView(DetailGrid); ((GridView)detailView).OptionsView.ShowGroupPanel = false; } else { detailView = new LayoutView(DetailGrid); } return(detailView); }
private void gridControl1_DragOver(object sender, DragEventArgs e) { e.Effect = DragDropEffects.None; LayoutViewHitInfo downHitInfo = e.Data.GetData(typeof(LayoutViewHitInfo)) as LayoutViewHitInfo; if (downHitInfo != null) { GridControl grid = sender as GridControl; LayoutView view = grid.MainView as LayoutView; LayoutViewHitInfo hitInfo = view.CalcHitInfo(grid.PointToClient(new Point(e.X, e.Y))); if (hitInfo.InCard && hitInfo.RowHandle != downHitInfo.RowHandle) { e.Effect = DragDropEffects.Move; } } }
private void gridControl_DragOver(object sender, DragEventArgs e) { e.Effect = DragDropEffects.None; var gridControl = sender as GridControl; string dragData = e.Data.GetData(DataFormats.Text).ToString(); // Lookup dragged row with dragged ID in source table. var rowDropped = this.boardDataList.AsEnumerable().FirstOrDefault(row => row.GetType().GetProperty("TaskId").GetValue(row, null).ToString() == dragData); if (rowDropped == null) { return; } bool validataResult = true; if (OnValidataStatus != null) { validataResult = OnValidataStatus(rowDropped, GetSatusCode(gridControl.Tag.ToString())); } if (!validataResult) { return; } // Obtain the view over which the card is being dragged. Point point = gridControl.PointToClient(new Point(e.X, e.Y)); LayoutView view = gridControl.GetViewAt(point) as LayoutView; // Valid drop location if over a LayoutView if (view != null) { SetColumnHoverColor(gridControl, true); e.Effect = DragDropEffects.Move; if (null != this.customCursorWrapper && Cursor.Current != this.customCursorWrapper.Cursor) { Cursor.Current = this.customCursorWrapper.Cursor; Cursor.Position.Offset(point); Debug.WriteLine("Set cursor to custom icon."); } Debug.WriteLine("Dragging over " + gridControl.Name + " " + e.Effect); } }
private void layoutView1_MouseDown(object sender, MouseEventArgs e) { LayoutView view = sender as LayoutView; downHitInfo = null; LayoutViewHitInfo hitInfo = view.CalcHitInfo(new Point(e.X, e.Y)); if (Control.ModifierKeys != Keys.None) { return; } if (e.Button == MouseButtons.Left && hitInfo.InCard) { downHitInfo = hitInfo; } GetPicture(); }
void SetColumnHoverColor(GridControl gridControl, bool hovering) { LayoutView view = (LayoutView)gridControl.MainView; LookBoardColumn oppCol = (LookBoardColumn)gridControl.Parent; if (hovering) { Color backColor = Color.FromArgb(242, 242, 242); view.Appearance.ViewBackground.BackColor = backColor; // Color.FromArgb(61, 61, 61); oppCol.BackColor = backColor; // Color.FromArgb(61, 61, 61); } else { Color activeColor = Color.FromArgb(204, 204, 204); view.Appearance.ViewBackground.BackColor = activeColor; // Color.FromArgb(51, 51, 51); oppCol.BackColor = activeColor; // Color.FromArgb(51, 51, 51); } }
private void StartCardDrag(LayoutView view, Point clickLocation, int rowHandle, Rectangle rowBounds) { string id = view.GetRowCellValue(rowHandle, view.Columns["TaskId"]).ToString(); // Create a cursor from the card bitmap. using (var gridBitmap = new Bitmap(view.GridControl.Width, view.GridControl.Height)) { view.GridControl.DrawToBitmap(gridBitmap, new Rectangle(0, 0, view.GridControl.Width, view.GridControl.Height)); using (var cardBitmap = CropBitmap(gridBitmap, rowBounds)) { this.customCursorWrapper = CustomCursorWrapper.CreateFromBitmap(cardBitmap, Point.Subtract(clickLocation, new Size(rowBounds.Location))); } } // Start drag and drop view.GridControl.DoDragDrop(id, DragDropEffects.Move); }
private void layoutView1_CustomUnboundColumnData(object sender, CustomColumnDataEventArgs e) { if (e.Column == colProducts) { if (e.IsGetData) { int personId = (int)dataSet.Tables["Persons"].Rows[e.ListSourceRowIndex]["ID"]; Bitmap img = null; if (unboundData.ContainsKey(personId)) { img = unboundData[personId]; } else { DataView dataView = dataSet.Tables["Products"].DefaultView; dataView.RowFilter = string.Format("ID = {0}", personId); foreach (Series s in chart.Series) { s.DataSource = dataView; } chart.RefreshData(); LayoutView view = (LayoutView)sender; LayoutViewInfo viewInfo = (LayoutViewInfo)view.GetViewInfo(); Size chartSize = Size.Empty; foreach (LayoutViewField field in view.TemplateCard.Items) { if (field.FieldName == "colProducts") { chartSize = field.Size; break; } } chart.Size = chartSize; img = new Bitmap(chartSize.Width, chartSize.Height); chart.DrawToBitmap(img, new Rectangle(Point.Empty, chartSize)); unboundData.Add(personId, img); } e.Value = img; } } }
public ViewEngineResult FindView(ControllerContext controllerContext, string viewName, string masterName, bool useCache) { var viewResult = themeAwareViewEngine.FindPartialView(controllerContext, viewName, useCache, true); if (viewResult.View == null) { return(viewResult); } ThemedAttribute attribute; if (!ThemeFilter.IsApplied(controllerContext.RequestContext, out attribute)) { return(viewResult); } var layoutView = new LayoutView((viewContext, writer, viewDataContainer) => { Logger.Info("Rendering layout view"); var childContentWriter = new HtmlStringWriter(); var childContentViewContext = new ViewContext( viewContext, viewContext.View, viewContext.ViewData, viewContext.TempData, childContentWriter); viewResult.View.Render(childContentViewContext, childContentWriter); workContext.Layout.Metadata.ChildContent = childContentWriter; var display = displayHelperFactory.CreateHelper(viewContext, viewDataContainer); IHtmlString result = display(workContext.Layout); writer.Write(result.ToHtmlString()); Logger.Info("Done rendering layout view"); }, (context, view) => viewResult.ViewEngine.ReleaseView(context, viewResult.View)); return(new ViewEngineResult(layoutView, this)); }
public FormDodajKomentar(Task _task, GridControl gridcontrol, LayoutView layoutView, XtraScrollableControl xtraScrollableControl) { InitializeComponent(); Baza = new AbacusSUPEntities(); task = _task; imageCollection = richEditControl1.Document.Images; gridControl1 = gridcontrol; layoutView1 = layoutView; xtraScrollableControl1 = xtraScrollableControl; #region Da olaksa .rtf! brisanje styleova i sl //richEditControl1.Document.BeginUpdate(); //try //{ // for (int i = richEditControl1.Document.TableStyles.Count - 1; i >= 1; i--) // richEditControl1.Document.TableStyles.Delete(richEditControl1.Document.TableStyles[i]); // for (int i = richEditControl1.Document.ParagraphStyles.Count - 1; i >= 1; i--) // richEditControl1.Document.ParagraphStyles.Delete(richEditControl1.Document.ParagraphStyles[i]); // for (int i = richEditControl1.Document.CharacterStyles.Count - 1; i >= 1; i--) // richEditControl1.Document.CharacterStyles.Delete(richEditControl1.Document.CharacterStyles[i]); //} //finally //{ // richEditControl1.Document.EndUpdate(); //} #endregion kom = new Komentar { datum = DateTime.Now, sadrzaj = null, id_login = OperaterLogin.operater.id, id_task = task.id_task }; Baza.Komentar.Add(kom); Baza.SaveChanges(); tempid = kom.id; }
public MainController() { /* initialize child controllers */ this.MenuController = new MenuController(); this.ActiveControllers.Add(typeof(MenuController), this.MenuController); this.ProjectCtrl = new ProjectController(); this.ActiveControllers.Add(typeof(ProjectController), this.ProjectCtrl); this.MenuController.AddMenuEntry(this.ProjectCtrl.Menu); FinancesController financesCtrl = new FinancesController(); this.ActiveControllers.Add(typeof(FinancesController), financesCtrl); this.MenuController.AddMenuEntry(financesCtrl.Menu); /* create the layout and assign the created views */ this.LayoutView = new LayoutView(); this.LayoutView.Navigation(this.MenuController.View); this.LayoutView.Content(this.ProjectCtrl.View); this.View = this.LayoutView; }
private void OnGridViewControlsCreated(object sender, EventArgs e){ var listview = ((ListView) View); var gridListEditor = ((GridListEditor) listview.Editor); gridView = gridListEditor.GridView; var riPictureEdit = ((RepositoryItemPictureEdit) gridView.GridControl.RepositoryItems.Add("PictureEdit")); riPictureEdit.SizeMode = PictureSizeMode.Squeeze; LayoutView layoutView = new LayoutView(gridView.GridControl); string layoutString = Info.GetAttributeValue(LayoutViewCustomizationAttributeName, string.Empty); if (!string.IsNullOrEmpty(layoutString)) { using (MemoryStream stream = new MemoryStream(Encoding.UTF8.GetBytes(layoutString))) { gridView.GridControl.MainView.RestoreLayoutFromStream(stream); } } gridView.GridControl.MainView = layoutView; ((LayoutView) gridView.GridControl.MainView).CustomRowCellEdit += CustomRowCellEdit; gridView.GridControl.MainView.DataSourceChanged += MainView_DataSourceChanged; }
private void layoutView1_CustomCardLayout(object sender, DevExpress.XtraGrid.Views.Layout.Events.LayoutViewCustomCardLayoutEventArgs e) { LayoutView view = sender as LayoutView; Person p = view.GetRow(e.RowHandle) as Person; string colTitleName = view.Columns["Title"].LayoutViewField.Name; string colTotalTurnover = view.Columns["TotalTurnover"].LayoutViewField.Name; if (p.GetType() == typeof(Employee)) { e.CardDifferences.AddItemDifference(colTitleName, LayoutItemDifferenceType.ItemVisibility, true); e.CardDifferences.AddItemDifference(colTotalTurnover, LayoutItemDifferenceType.ItemVisibility, false); } if (p.GetType() == typeof(Customer)) { e.CardDifferences.AddItemDifference(colTitleName, LayoutItemDifferenceType.ItemVisibility, false); e.CardDifferences.AddItemDifference(colTotalTurnover, LayoutItemDifferenceType.ItemVisibility, true); } }
void OnRepaint(IView View, IPaintTo3D paintTo3D) { BoundingRect ext; if (layoutPatch.Area == null) { ext = new BoundingRect(0.0, 0.0, layoutView.Layout.PaperWidth, layoutView.Layout.PaperHeight); } else { ext = layoutPatch.Area.Extent; } LayoutView lv = View as LayoutView; if (lv != null) { GeoPoint2D clipll = lv.layoutToScreen * ext.GetLowerLeft(); GeoPoint2D clipur = lv.layoutToScreen * ext.GetUpperRight(); paintTo3D.SetColor(Color.LightGray); paintTo3D.FillRect2D(clipll.PointF, clipur.PointF); } }
private void MoveRow(int sourceRow, int targetRow) { if (sourceRow == targetRow || sourceRow == targetRow + 1) { return; } LayoutView view = layoutView1; DataRow row1 = view.GetDataRow(targetRow); DataRow row2 = view.GetDataRow(targetRow + 1); DataRow dragRow = view.GetDataRow(sourceRow); decimal val1 = (decimal)row1[OrderFieldName]; if (row2 == null) { dragRow[OrderFieldName] = val1 + 1; } else { decimal val2 = (decimal)row2[OrderFieldName]; dragRow[OrderFieldName] = (val1 + val2) / 2; } }
async public static Task <bool> OpenLayoutView(string LayoutName) { //Reference a layoutitem in a project by name LayoutProjectItem layoutItem = Project.Current.GetItems <LayoutProjectItem>().FirstOrDefault(item => item.Name.Equals(LayoutName)); if (layoutItem == null) { return(false); } //Reference and load the layout associated with the layout item Layout lyt = await QueuedTask.Run(() => layoutItem.GetLayout()); //Iterate through each pane to see if one already references the layout, if so, activate it foreach (var pane in ProApp.Panes) { var layoutPane = pane as ILayoutPane; if (layoutPane == null) { continue; } LayoutView lytView = layoutPane.LayoutView; if (lytView.Layout == lyt) { (layoutPane as Pane).Activate(); await QueuedTask.Run(() => lytView.ZoomTo100Percent()); return(true); } } //Open a new pane, activate it, and zoom to 100% var newPane = await QueuedTask.Run(() => ProApp.Panes.CreateLayoutPaneAsync(lyt)); await QueuedTask.Run(() => newPane.LayoutView.ZoomTo100Percent()); return(true); }
async protected override void OnClick() { //Prevent tool from executing if layout view doesn't exist LayoutView layoutView = LayoutView.Active; if (layoutView == null) { System.Windows.MessageBox.Show("Can't find layout view, try clicking New Game Board"); return; } //Prevent tool from executing if puzzle pieces are not scrambled Layout layout = layoutView.Layout; MapFrame mfTest = layout.FindElement("MF1") as MapFrame; if (mfTest == null) { System.Windows.MessageBox.Show("Game board not scrambled"); return; } if (mfTest.IsVisible == false) { System.Windows.MessageBox.Show("Game finished, click New Game"); return; } Globals.selEvents = true; await FrameworkApplication.SetCurrentToolAsync("esri_mapping_selectByRectangleTool"); //Update Instructions TextElement instr = layout.FindElement("Instructions") as TextElement; string text = "<bol>Instructions: </bol> \n\n Select a Map Frame puzzle piece" as String; var instrProp = instr.TextProperties; instrProp.Text = text; await QueuedTask.Run(() => instr.SetTextProperties(instrProp)); }
public BaseController() { layoutView = LayoutView.GetLayoutView(); }
public void snippets_elements() { #region Find an element on a layout // Reference a layoutitem in a project by name LayoutProjectItem layoutItem = Project.Current.GetItems <LayoutProjectItem>().FirstOrDefault(item => item.Name.Equals("MyLayout")); if (layoutItem != null) { QueuedTask.Run(() => { // Reference and load the layout associated with the layout item Layout layout = layoutItem.GetLayout(); if (layout != null) { //Find a single specific element Element rect = layout.FindElement("Rectangle") as Element; //Or use the Elements collection Element rect2 = layout.Elements.FirstOrDefault(item => item.Name.Equals("Rectangle")); } }); } #endregion Element element = null; #region Update element properties QueuedTask.Run(() => { // update an element's name element.SetName("New Name"); // update and element's visibility element.SetVisible(true); }); #endregion { #region Get element selection count //Count the number of selected elements on the active layout view LayoutView activeLayoutView = LayoutView.Active; if (activeLayoutView != null) { var selectedElements = activeLayoutView.GetSelectedElements(); ArcGIS.Desktop.Framework.Dialogs.MessageBox.Show($@"Selected elements: {selectedElements.Count}"); } #endregion } { #region Set element selection //The the active layout view's selection to include 2 rectangle elements LayoutView activeLayoutView = LayoutView.Active; if (activeLayoutView != null) { QueuedTask.Run(() => { Layout lyt = activeLayoutView.Layout; Element rec = lyt.FindElement("Rectangle"); Element rec2 = lyt.FindElement("Rectangle 2"); List <Element> elmList = new List <Element> { rec, rec2 }; activeLayoutView.SelectElements(elmList); }); } #endregion } { #region Clear the layout selection //If the a layout view is active, the clear its selection LayoutView activeLayoutView = LayoutView.Active; if (activeLayoutView != null) { activeLayoutView.ClearElementSelection(); } #endregion } Layout aLayout = null; Element elm = null; #region Delete an element or elements on a layout QueuedTask.Run(() => { //Delete a specific element on a layout aLayout.DeleteElement(elm); //Or delete a group of elements using a filter aLayout.DeleteElements(item => item.Name.Contains("Clone")); //Or delete all elements on a layout aLayout.DeleteElements(item => true); }); #endregion #region Set Halo property of North Arrow //Assuming the selected item is a north arrow var northArrow = LayoutView.Active.GetSelectedElements().First(); QueuedTask.Run(() => { //Get definition of north arrow... var cim = northArrow.GetDefinition() as CIMMarkerNorthArrow; //this halo symbol is 50% transparent, no outline (i.e. 0 width) //First construct a polygon symbol to use in the Halo //Polygon symbol will need a fill and a stroke var polyFill = SymbolFactory.Instance.ConstructSolidFill(ColorFactory.Instance.CreateRGBColor(0, 0, 0, 50)); var polyStroke = SymbolFactory.Instance.ConstructStroke(ColorFactory.Instance.BlackRGB, 0); var haloPoly = SymbolFactory.Instance.ConstructPolygonSymbol(polyFill, polyStroke); //Set the north arrow defintion of HaloSymbol and HaloSize ((CIMPointSymbol)cim.PointSymbol.Symbol).HaloSymbol = haloPoly; ((CIMPointSymbol)cim.PointSymbol.Symbol).HaloSize = 3; //size of the halo //set it back northArrow.SetDefinition(cim); }); #endregion }
private void ResetLayoutView(LayoutView layoutView) { try { layoutView.OptionsCustomization.AllowFilter = false; layoutView.OptionsCustomization.AllowSort = false; LayoutViewOptionsView layoutViewOptionsView = (LayoutViewOptionsView)layoutView.OptionsView; layoutViewOptionsView.ViewMode = LayoutViewMode.Carousel; layoutViewOptionsView.ShowHeaderPanel = false; layoutViewOptionsView.ShowCardExpandButton = false; layoutViewOptionsView.ShowCardExpandButton = false; layoutView.Columns.Clear(); } catch { } }
public virtual ActionResult EditLayout(LayoutView layoutView) { try { var layout = _entities.Layouts.SingleOrDefault(x => x.LayoutID == layoutView.LayoutID); layout.ReAreaName = layoutView.ResidentialName; layout.ApplyCompany = layoutView.CompanyName; layout.ApplyDate = layoutView.ApplyDate; layout.ContactorName = layoutView.ContactPerson; layout.ContactorTel = layoutView.ContactTel; // layout.Memo = layoutView.Memo; layout.Address = layoutView.Address; layout.SignOn = layoutView.SignOn; _entities.SaveChanges(); return Content("已经保存"); } catch { return Content("未能保存"); } }
async protected override void OnClick() { LayoutView layoutView = LayoutView.Active; //Prevent tool from executing based on some conditions if (layoutView == null) { System.Windows.MessageBox.Show("Can't find layout view, try clicking New Game Board"); return; } if (layoutView.Layout.Name != "Game Board") { System.Windows.MessageBox.Show("Wrong layout view: should be Game Board"); return; } await QueuedTask.Run(() => { //Reference the layout for moving map frames and adding new layout elements Layout layout = layoutView.Layout; //Check to see if elements were already scrambled MapFrame mfTest = layout.FindElement("MF1") as MapFrame; if (mfTest != null) { System.Windows.MessageBox.Show("Game pieces already scrambled"); return; } //Build 6 envelopes to represent the locations of puzzle pieces along the outer edges Coordinate2D env1_ll = new Coordinate2D(0.5, 0.5); Coordinate2D env1_ur = new Coordinate2D(3.5, 3.5); Envelope env1 = EnvelopeBuilder.CreateEnvelope(env1_ll, env1_ur); Coordinate2D env2_ll = new Coordinate2D(0.5, 4); Coordinate2D env2_ur = new Coordinate2D(3.5, 7); Envelope env2 = EnvelopeBuilder.CreateEnvelope(env2_ll, env2_ur); Coordinate2D env3_ll = new Coordinate2D(0.5, 7.5); Coordinate2D env3_ur = new Coordinate2D(3.5, 10.5); Envelope env3 = EnvelopeBuilder.CreateEnvelope(env3_ll, env3_ur); Coordinate2D env4_ll = new Coordinate2D(13.5, 0.5); Coordinate2D env4_ur = new Coordinate2D(16.5, 3.5); Envelope env4 = EnvelopeBuilder.CreateEnvelope(env4_ll, env4_ur); Coordinate2D env5_ll = new Coordinate2D(13.5, 4); Coordinate2D env5_ur = new Coordinate2D(16.5, 7); Envelope env5 = EnvelopeBuilder.CreateEnvelope(env5_ll, env5_ur); Coordinate2D env6_ll = new Coordinate2D(13.5, 7.5); Coordinate2D env6_ur = new Coordinate2D(16.5, 10.5); Envelope env6 = EnvelopeBuilder.CreateEnvelope(env6_ll, env6_ur); //Randomize the envelopes by assigning new envelope variables used for map frame creation //Also remove the assigned env before selecting the next random env List <Envelope> envList = new List <Envelope> { env1, env2, env3, env4, env5, env6 }; Random r1 = new Random(); int i1 = r1.Next(envList.Count); Envelope e1 = envList[i1]; envList.Remove(e1); Random r2 = new Random(); int i2 = r2.Next(envList.Count); Envelope e2 = envList[i2]; envList.Remove(e2); Random r3 = new Random(); int i3 = r3.Next(envList.Count); Envelope e3 = envList[i3]; envList.Remove(e3); Random r4 = new Random(); int i4 = r4.Next(envList.Count); Envelope e4 = envList[i4]; envList.Remove(e4); Random r5 = new Random(); int i5 = r5.Next(envList.Count); Envelope e5 = envList[i5]; envList.Remove(e5); Random r6 = new Random(); int i6 = r6.Next(envList.Count); Envelope e6 = envList[i6]; envList.Remove(e6); //Reference the active map view and gets its center location //MapView map = MapView.Active; MapFrame mapFrame = layout.FindElement("Main MF") as MapFrame; Camera cam = mapFrame.Camera; double x = cam.X; double y = cam.Y; double scale = cam.Scale; double delta = scale * 1.5 / 12 / 3.28084; //scale * 1/2 of a 3" MF / 12" per foot / 3.28084 feet per meter //Insert Map Frame 1 at random location MapFrame mf1Elm = LayoutElementFactory.Instance.CreateMapFrame(layout, e1, mapFrame.Map); mf1Elm.SetName("MF1"); Camera mf1cam = mf1Elm.Camera; mf1cam.X = x - (delta * 2); mf1cam.Y = y - delta; mf1cam.Scale = scale; mf1Elm.SetCamera(mf1cam); //Insert Map Frame 2 at random location MapFrame mf2Elm = LayoutElementFactory.Instance.CreateMapFrame(layout, e2, mapFrame.Map); mf2Elm.SetName("MF2"); Camera mf2cam = mf2Elm.Camera; mf2cam.X = x; mf2cam.Y = y - delta; mf2cam.Scale = scale; mf2Elm.SetCamera(mf2cam); //Insert Map Frame 3 at random location MapFrame mf3Elm = LayoutElementFactory.Instance.CreateMapFrame(layout, e3, mapFrame.Map); mf3Elm.SetName("MF3"); Camera mf3cam = mf3Elm.Camera; mf3cam.X = x + (delta * 2); mf3cam.Y = y - delta; mf3cam.Scale = scale; mf3Elm.SetCamera(mf3cam); //Insert Map Frame 4 at random location MapFrame mf4Elm = LayoutElementFactory.Instance.CreateMapFrame(layout, e4, mapFrame.Map); mf4Elm.SetName("MF4"); Camera mf4cam = mf4Elm.Camera; mf4cam.X = x + (delta * 2); mf4cam.Y = y + delta; mf4cam.Scale = scale; mf4Elm.SetCamera(mf4cam); //Insert Map Frame 5 at random location MapFrame mf5Elm = LayoutElementFactory.Instance.CreateMapFrame(layout, e5, mapFrame.Map); mf5Elm.SetName("MF5"); Camera mf5cam = mf5Elm.Camera; mf5cam.X = x; mf5cam.Y = y + delta; mf5cam.Scale = scale; mf5Elm.SetCamera(mf5cam); //Insert Map Frame 6 at random location MapFrame mf6Elm = LayoutElementFactory.Instance.CreateMapFrame(layout, e6, mapFrame.Map); mf6Elm.SetName("MF6"); Camera mf6cam = mf6Elm.Camera; mf6cam.X = x - (delta * 2); mf6cam.Y = y + delta; mf6cam.Scale = scale; mf6Elm.SetCamera(mf6cam); //Create 6 polygon boxes that represent where the outer map frames need to be placed. Coordinate2D box1_ll = new Coordinate2D(4, 0.5); Coordinate2D box1_ur = new Coordinate2D(7, 3.5); Envelope box1_env = EnvelopeBuilder.CreateEnvelope(box1_ll, box1_ur); GraphicElement box1 = LayoutElementFactory.Instance.CreateRectangleGraphicElement(layout, box1_env); box1.SetName("Rectangle 1"); Coordinate2D box2_ll = new Coordinate2D(7, 0.5); Coordinate2D box2_ur = new Coordinate2D(10, 3.5); Envelope box2_env = EnvelopeBuilder.CreateEnvelope(box2_ll, box2_ur); GraphicElement box2 = LayoutElementFactory.Instance.CreateRectangleGraphicElement(layout, box2_env); box2.SetName("Rectangle 2"); Coordinate2D box3_ll = new Coordinate2D(10, 0.5); Coordinate2D box3_ur = new Coordinate2D(13, 3.5); Envelope box3_env = EnvelopeBuilder.CreateEnvelope(box3_ll, box3_ur); GraphicElement box3 = LayoutElementFactory.Instance.CreateRectangleGraphicElement(layout, box3_env); box3.SetName("Rectangle 3"); Coordinate2D box4_ll = new Coordinate2D(10, 3.5); Coordinate2D box4_ur = new Coordinate2D(13, 6.5); Envelope box4_env = EnvelopeBuilder.CreateEnvelope(box4_ll, box4_ur); GraphicElement box4 = LayoutElementFactory.Instance.CreateRectangleGraphicElement(layout, box4_env); box4.SetName("Rectangle 4"); Coordinate2D box5_ll = new Coordinate2D(7, 3.5); Coordinate2D box5_ur = new Coordinate2D(10, 6.5); Envelope box5_env = EnvelopeBuilder.CreateEnvelope(box5_ll, box5_ur); GraphicElement box5 = LayoutElementFactory.Instance.CreateRectangleGraphicElement(layout, box5_env); box5.SetName("Rectangle 5"); Coordinate2D box6_ll = new Coordinate2D(4, 3.5); Coordinate2D box6_ur = new Coordinate2D(7, 6.5); Envelope box6_env = EnvelopeBuilder.CreateEnvelope(box6_ll, box6_ur); GraphicElement box6 = LayoutElementFactory.Instance.CreateRectangleGraphicElement(layout, box6_env); box6.SetName("Rectangle 6"); //Find MainMF and set invisible MapFrame mainMF = layout.FindElement("Main MF") as MapFrame; mainMF.SetVisible(false); //Update Instructions TextElement steps = layout.FindElement("Instructions") as TextElement; string text = "<bol>Instructions: </bol>\n\n - Click the 'Play Game' command" as String; var stepsProp = steps.TextProperties; stepsProp.Text = text; steps.SetTextProperties(stepsProp); }); layoutView.ClearElementSelection(); }
private void SetGridControlView(string imageFloderPath, Size cardSize) { string[] filePathes = Directory.GetFiles(imageFloderPath, "*.jpg"); DataTable dt = CreatDatatableOfFiles(filePathes, new Size(400, 300)); this.gridControl1.DataSource = dt; this.gridControl1.ViewCollection.Clear(); LayoutView lView = new LayoutView(this.gridControl1); this.gridControl1.MainView = lView; ResetLayoutView(lView); lView.CardMinSize = cardSize; LayoutViewColumn colFileName = lView.Columns.AddField("文件名"); LayoutViewColumn colFilePath = lView.Columns.AddField("文件路径"); LayoutViewColumn colPhoto = lView.Columns.AddField("图片文件"); LayoutViewField fieldFileName = colFileName.LayoutViewField; LayoutViewField fieldFilePath = colFilePath.LayoutViewField; LayoutViewField fieldPhoto = colPhoto.LayoutViewField; colFileName.Visible = true; fieldPhoto.Move(new LayoutItemDragController(fieldPhoto, fieldFileName, InsertLocation.After, LayoutType.Vertical)); //fieldFilePath.Move(new LayoutItemDragController(fieldFilePath, fieldPhoto, InsertLocation.After, LayoutType.Vertical)); RepositoryItemPictureEdit riPictureEdit = this.gridControl1.RepositoryItems.Add("PictureEdit") as RepositoryItemPictureEdit; riPictureEdit.SizeMode = PictureSizeMode.Stretch; colPhoto.ColumnEdit = riPictureEdit; fieldFileName.TextVisible = false; fieldFilePath.TextVisible = false; fieldPhoto.Text = " "; colFileName.OptionsColumn.ReadOnly = true; colFilePath.OptionsColumn.ReadOnly = true; colPhoto.OptionsColumn.ReadOnly = true; colFileName.Visible = false; colFilePath.Visible = false; lView.CardCaptionFormat = "{2} 第{0}幅,共{1}幅"; }
async public void MoveMF(string elmName) { Globals.i_correct = Globals.i_correct + 1; LayoutView layoutView = LayoutView.Active; Layout layout = layoutView.Layout; if (elmName == "Rectangle 1") { MapFrame mf1 = layout.FindElement("MF1") as MapFrame; await QueuedTask.Run(() => mf1.SetX(4)); await QueuedTask.Run(() => mf1.SetY(0.5)); } if (elmName == "Rectangle 2") { MapFrame mf2 = layout.FindElement("MF2") as MapFrame; await QueuedTask.Run(() => mf2.SetX(7)); await QueuedTask.Run(() => mf2.SetY(0.5)); } if (elmName == "Rectangle 3") { MapFrame mf3 = layout.FindElement("MF3") as MapFrame; await QueuedTask.Run(() => mf3.SetX(10)); await QueuedTask.Run(() => mf3.SetY(0.5)); } if (elmName == "Rectangle 4") { MapFrame mf4 = layout.FindElement("MF4") as MapFrame; await QueuedTask.Run(() => mf4.SetX(10)); await QueuedTask.Run(() => mf4.SetY(3.5)); } if (elmName == "Rectangle 5") { MapFrame mf5 = layout.FindElement("MF5") as MapFrame; await QueuedTask.Run(() => mf5.SetX(7)); await QueuedTask.Run(() => mf5.SetY(3.5)); } if (elmName == "Rectangle 6") { MapFrame mf6 = layout.FindElement("MF6") as MapFrame; await QueuedTask.Run(() => mf6.SetX(4)); await QueuedTask.Run(() => mf6.SetY(3.5)); } TextElement statusText = layout.FindElement("Status") as TextElement; TextProperties statusProp = statusText.TextProperties; if (Globals.i_correct == 1) { statusProp.Text = "Nice job! You got " + Globals.i_correct.ToString() + " correct out of " + Globals.i_guesses + " attempt."; } else { statusProp.Text = "Nice job! You got " + Globals.i_correct.ToString() + " correct out of " + Globals.i_guesses + " attempts."; } await QueuedTask.Run(() => statusText.SetTextProperties(statusProp)); if (Globals.i_correct == 6) //YOU WIN { statusProp.Text = "GAME OVER! You got " + Globals.i_correct.ToString() + " correct out of " + Globals.i_guesses + " attempts."; await QueuedTask.Run(() => statusText.SetTextProperties(statusProp)); //Turn off rectangles GraphicElement rec1 = layout.FindElement("Rectangle 1") as GraphicElement; await QueuedTask.Run(() => rec1.SetVisible(false)); GraphicElement rec2 = layout.FindElement("Rectangle 2") as GraphicElement; await QueuedTask.Run(() => rec2.SetVisible(false)); GraphicElement rec3 = layout.FindElement("Rectangle 3") as GraphicElement; await QueuedTask.Run(() => rec3.SetVisible(false)); GraphicElement rec4 = layout.FindElement("Rectangle 4") as GraphicElement; await QueuedTask.Run(() => rec4.SetVisible(false)); GraphicElement rec5 = layout.FindElement("Rectangle 5") as GraphicElement; await QueuedTask.Run(() => rec5.SetVisible(false)); GraphicElement rec6 = layout.FindElement("Rectangle 6") as GraphicElement; await QueuedTask.Run(() => rec6.SetVisible(false)); //Toggle MFs MapFrame mf1 = layout.FindElement("MF1") as MapFrame; await QueuedTask.Run(() => mf1.SetVisible(false)); MapFrame mf2 = layout.FindElement("MF2") as MapFrame; await QueuedTask.Run(() => mf2.SetVisible(false)); MapFrame mf3 = layout.FindElement("MF3") as MapFrame; await QueuedTask.Run(() => mf3.SetVisible(false)); MapFrame mf4 = layout.FindElement("MF4") as MapFrame; await QueuedTask.Run(() => mf4.SetVisible(false)); MapFrame mf5 = layout.FindElement("MF5") as MapFrame; await QueuedTask.Run(() => mf5.SetVisible(false)); MapFrame mf6 = layout.FindElement("MF6") as MapFrame; await QueuedTask.Run(() => mf6.SetVisible(false)); MapFrame mainMF = layout.FindElement("Main MF") as MapFrame; await QueuedTask.Run(() => mainMF.SetVisible(true)); //Update title TextElement titleText = layout.FindElement("Title") as TextElement; TextProperties titleProp = titleText.TextProperties; titleProp.Text = "Not any more!"; await QueuedTask.Run(() => titleText.SetTextProperties(titleProp)); //New Game TextElement instrText = layout.FindElement("Instructions") as TextElement; TextProperties instrProp = instrText.TextProperties; instrProp.Text = "<bol>Instructions: </bol> " + "\n\n\n\n\n\n\n\n\n - Click the 'New Game' command if you want to play again."; await QueuedTask.Run(() => instrText.SetTextProperties(instrProp)); //Zoomto finished puzzle area Coordinate2D ll = new Coordinate2D(3, 0); Coordinate2D ur = new Coordinate2D(14, 7.5); await QueuedTask.Run(() => { Envelope env = EnvelopeBuilderEx.CreateEnvelope(ll, ur); layoutView.ZoomTo(env); }); //Turn off selection changed events Globals.selEvents = false; } }
async public void LayoutSelectionCallBack(ElementEventArgs args) { if (args.Hint != ElementEventHint.SelectionChanged) { return; } if (Globals.selEvents) { LayoutView layoutView = LayoutView.Active; Layout layout = layoutView.Layout; TextElement txtElm = layout.FindElement("Instructions") as TextElement; TextProperties txtProp = txtElm.TextProperties; TextElement statusText = layout.FindElement("Status") as TextElement; TextProperties statusProp = statusText.TextProperties; if (!(args.Container is Layout theLayoutView)) { return; } var selElm = theLayoutView.GetSelectedElements().ToList().FirstOrDefault(); // could also use layoutView.GetSelectedElements().FirstOrDefault(); if (Globals.elmType == "MF" && selElm is MapFrame) //Select appropriate Map Frame { txtProp.Text = "<bol>Instructions:</bol> \n\n - Select the rectangle where the map frame should be placed."; await QueuedTask.Run(() => txtElm.SetTextProperties(txtProp)); Globals.elmType = "REC"; Globals.mf_Name = selElm.Name; return; } if (Globals.elmType == "MF" && selElm is GraphicElement) { System.Windows.MessageBox.Show("Hey Bonehead: will you please follow instuctions, you selected the wrong thing!"); return; } else if (Globals.elmType == "REC" && selElm is GraphicElement) //Select appropriate Rectangle { txtProp.Text = "<bol>Instructions: </bol> \n\n - Select another map frame."; await QueuedTask.Run(() => txtElm.SetTextProperties(txtProp)); Globals.elmType = "MF"; Globals.i_guesses = Globals.i_guesses + 1; if (selElm.Name == "Rectangle 1" && Globals.mf_Name == "MF1") { MoveMF(selElm.Name); } else if (selElm.Name == "Rectangle 2" && Globals.mf_Name == "MF2") { MoveMF(selElm.Name); } else if (selElm.Name == "Rectangle 3" && Globals.mf_Name == "MF3") { MoveMF(selElm.Name); } else if (selElm.Name == "Rectangle 4" && Globals.mf_Name == "MF4") { MoveMF(selElm.Name); } else if (selElm.Name == "Rectangle 5" && Globals.mf_Name == "MF5") { MoveMF(selElm.Name); } else if (selElm.Name == "Rectangle 6" && Globals.mf_Name == "MF6") { MoveMF(selElm.Name); } else { statusProp.Text = "<bol><clr red='255'> WRONG!!! </clr></bol> <_bol> Try again. You are not very 'spatial'</_bol>"; await QueuedTask.Run(() => statusText.SetTextProperties(statusProp)); } return; } if (Globals.elmType == "REC" && selElm is MapFrame) { System.Windows.MessageBox.Show("Hey Bonehead: will you please follow instuctions, you selected the wrong thing!"); return; } } }
public LayoutViewTest() { _renderer = new TestRenderer(); _layoutViewComponent = new LayoutView(); _layoutViewComponentId = _renderer.AssignRootComponentId(_layoutViewComponent); }
private void RenderWithLayout() { Execute(); LayoutView.ExecuteLayout(this); }
private void Initialize() { _GridView = new GridView() { Name = "GridView" }; _BandedGridView = new BandedGridView() { Name = "BandedGridView" }; _AdvBandedGridView = new AdvBandedGridView() { Name = "AdvBandedGridView" }; _CardView = new CardView() { Name = "CardView" }; _LayoutView = new LayoutView() { Name = "LayoutView" }; _TileView = new TileView() { Name = "TileView" }; _WinExplorerView = new WinExplorerView() { Name = "WinExplorerView" }; _GridView.GridControl = Grid; _BandedGridView.GridControl = Grid; _AdvBandedGridView.GridControl = Grid; _CardView.GridControl = Grid; _LayoutView.GridControl = Grid; _TileView.GridControl = Grid; _WinExplorerView.GridControl = Grid; Grid.ViewCollection.AddRange(new BaseView[] { _GridView, _BandedGridView, _AdvBandedGridView, _CardView, _LayoutView, _TileView, _WinExplorerView }); Grid.MainView = _GridView; View.OptionsView.ShowGroupPanel = false; _GridView.OptionsView.ShowGroupPanel = false; _BandedGridView.OptionsView.ShowGroupPanel = false; _AdvBandedGridView.OptionsView.ShowGroupPanel = false; if (View != null) { View.Dispose(); } _PrintingSystem = new PrintingSystem(); _PrintableComponentLink = new PrintableComponentLink(_PrintingSystem) { Component = Grid, PaperKind = PaperKind.A4 }; }
//确定挑选 private void btnComfirm_Click(object sender, EventArgs e) { PmIds = string.Empty; BaseView ViewType = gridCMain.MainView; if (ViewType.GetType().ToString() == "DevExpress.XtraGrid.Views.Grid.GridView") { GridView grid = ViewType as GridView; for (int i = 0; i < grid.RowCount; i++) { if (grid.GetDataRow(i)["Checked"].ToString() == "True") { PmIds += grid.GetDataRow(i)["PM_Id"].ToString() + ","; } } } if (ViewType.GetType().ToString() == "DevExpress.XtraGrid.Views.Layout.LayoutView") { LayoutView layout = ViewType as LayoutView; for (int i = 0; i < layout.RowCount; i++) { if (layout.GetDataRow(i)["Checked"].ToString() == "True") { PmIds += layout.GetDataRow(i)["PM_Id"].ToString() + ","; } } } if (ViewType.GetType().ToString() == "DevExpress.XtraGrid.Views.Card.CardView") { CardView cardView1 = ViewType as CardView; for (int i = 0; i < cardView1.RowCount; i++) { if (cardView1.GetDataRow(i)["Checked"].ToString() == "True") { PmIds += cardView1.GetDataRow(i)["PM_Id"].ToString() + ","; } } } //if (PmIds.TrimEnd(',').Split(',').Length == 1 && PmIds.Trim().Length > 0) //{ // DataTable dtOne = dt.Select("PM_Id = '" + PmIds.TrimEnd(',') + "' AND Fy_Id='" + dplFy.EditValue.ToString().Trim() + "' ").CopyToDataTable(); // frmSelectProdOne frmOne = new frmSelectProdOne(dsLoad.Tables[1], dtOne, PmIds.TrimEnd(',')); // if (frmOne.ShowDialog() == DialogResult.OK) // { // if (frmOne.IsSelect == true) // { // dtProd.Rows.Remove(dtProd.Select("PM_Id = '" + PmIds.TrimEnd(',') + "' ")[0]); // gridCMain.DataSource = dtProd; // } // } //} //else //{ //自动生成营销款号插入数据库 if (PmIds == string.Empty) { MessageBox.Show("请先选择款式"); return; } frmSelectProdMany frmMany = new frmSelectProdMany(dt, PmIds); if (frmMany.ShowDialog() == DialogResult.OK) { if (frmMany.IsSelect == true) { string[] pmPmIds = PmIds.TrimEnd(',').Split(','); for (int i = 0; i < pmPmIds.Length; i++) { dtProd.Rows.Remove(dtProd.Select("PM_Id = '" + pmPmIds[i].ToString() + "' ")[0]); } gridCMain.DataSource = dtProd; } this.grpPic.Controls.Clear(); x = 10; y = 25; path = string.Empty; } //} }
public void snippets_CreateLayoutElements() { LayoutView layoutView = LayoutView.Active; Layout layout = layoutView.Layout; #region Create point graphic with symbology //Create a simple 2D point graphic and apply an existing point style item as the symbology. //An alternative simple symbol is also provided below. This would completely elminate the 4 lines of code that reference a style. QueuedTask.Run(() => { //Build 2D point geometry Coordinate2D coord2D = new Coordinate2D(2.0, 10.0); //Reference a point symbol in a style StyleProjectItem ptStylePrjItm = Project.Current.GetItems <StyleProjectItem>().FirstOrDefault(item => item.Name == "ArcGIS 2D"); SymbolStyleItem ptSymStyleItm = ptStylePrjItm.SearchSymbols(StyleItemType.PointSymbol, "City Hall")[0]; CIMPointSymbol pointSym = ptSymStyleItm.Symbol as CIMPointSymbol; pointSym.SetSize(50); //Set symbolology, create and add element to layout //CIMPointSymbol pointSym = SymbolFactory.Instance.ConstructPointSymbol(ColorFactory.Instance.RedRGB, 25.0, SimpleMarkerStyle.Star); //Alternative simple symbol GraphicElement ptElm = LayoutElementFactory.Instance.CreatePointGraphicElement(layout, coord2D, pointSym); ptElm.SetName("New Point"); }); #endregion #region Create line graphic with symbology //Create a simple 2D line graphic and apply an existing line style item as the symbology. //An alternative simple symbol is also provided below. This would completely elminate the 4 lines of code that reference a style. QueuedTask.Run(() => { //Build 2d line geometry List <Coordinate2D> plCoords = new List <Coordinate2D>(); plCoords.Add(new Coordinate2D(1, 8.5)); plCoords.Add(new Coordinate2D(1.66, 9)); plCoords.Add(new Coordinate2D(2.33, 8.1)); plCoords.Add(new Coordinate2D(3, 8.5)); Polyline linePl = PolylineBuilder.CreatePolyline(plCoords); //Reference a line symbol in a style StyleProjectItem lnStylePrjItm = Project.Current.GetItems <StyleProjectItem>().FirstOrDefault(item => item.Name == "ArcGIS 2D"); SymbolStyleItem lnSymStyleItm = lnStylePrjItm.SearchSymbols(StyleItemType.LineSymbol, "Line with 2 Markers")[0]; CIMLineSymbol lineSym = lnSymStyleItm.Symbol as CIMLineSymbol; lineSym.SetSize(20); //Set symbolology, create and add element to layout //CIMLineSymbol lineSym = SymbolFactory.Instance.ConstructLineSymbol(ColorFactory.Instance.BlueRGB, 4.0, SimpleLineStyle.Solid); //Alternative simple symbol GraphicElement lineElm = LayoutElementFactory.Instance.CreateLineGraphicElement(layout, linePl, lineSym); lineElm.SetName("New Line"); }); #endregion #region Create rectangle graphic with simple symbology //Create a simple 2D rectangle graphic and apply simple fill and outline symbols. QueuedTask.Run(() => { //Build 2D envelope geometry Coordinate2D rec_ll = new Coordinate2D(1.0, 4.75); Coordinate2D rec_ur = new Coordinate2D(3.0, 5.75); Envelope rec_env = EnvelopeBuilder.CreateEnvelope(rec_ll, rec_ur); //Set symbolology, create and add element to layout CIMStroke outline = SymbolFactory.Instance.ConstructStroke(ColorFactory.Instance.BlackRGB, 5.0, SimpleLineStyle.Solid); CIMPolygonSymbol polySym = SymbolFactory.Instance.ConstructPolygonSymbol(ColorFactory.Instance.GreenRGB, SimpleFillStyle.DiagonalCross, outline); GraphicElement recElm = LayoutElementFactory.Instance.CreateRectangleGraphicElement(layout, rec_env, polySym); recElm.SetName("New Rectangle"); }); #endregion #region Create text element with basic font properties //Create a simple point text element and assign basic symbology as well as basic text settings. QueuedTask.Run(() => { //Build 2D point geometry Coordinate2D coord2D = new Coordinate2D(3.5, 10); //Set symbolology, create and add element to layout CIMTextSymbol sym = SymbolFactory.Instance.ConstructTextSymbol(ColorFactory.Instance.RedRGB, 32, "Arial", "Regular"); string textString = "Point text"; GraphicElement ptTxtElm = LayoutElementFactory.Instance.CreatePointTextGraphicElement(layout, coord2D, textString, sym); ptTxtElm.SetName("New Point Text"); //Change additional text properties ptTxtElm.SetAnchor(Anchor.CenterPoint); ptTxtElm.SetX(4.5); ptTxtElm.SetY(9.5); ptTxtElm.SetRotation(45); }); #endregion #region Create rectangle text with more advanced symbol settings //Create rectangle text with background and border symbology. Also notice how formatting tags are using within the text string. QueuedTask.Run(() => { //Build 2D polygon geometry List <Coordinate2D> plyCoords = new List <Coordinate2D>(); plyCoords.Add(new Coordinate2D(3.5, 7)); plyCoords.Add(new Coordinate2D(4.5, 7)); plyCoords.Add(new Coordinate2D(4.5, 6.7)); plyCoords.Add(new Coordinate2D(5.5, 6.7)); plyCoords.Add(new Coordinate2D(5.5, 6.1)); plyCoords.Add(new Coordinate2D(3.5, 6.1)); Polygon poly = PolygonBuilder.CreatePolygon(plyCoords); //Set symbolology, create and add element to layout CIMTextSymbol sym = SymbolFactory.Instance.ConstructTextSymbol(ColorFactory.Instance.GreyRGB, 10, "Arial", "Regular"); string text = "Some Text String that is really long and is <BOL>forced to wrap to other lines</BOL> so that we can see the effects." as String; GraphicElement polyTxtElm = LayoutElementFactory.Instance.CreatePolygonParagraphGraphicElement(layout, poly, text, sym); polyTxtElm.SetName("New Polygon Text"); //(Optionally) Modify paragraph border CIMGraphic polyTxtGra = polyTxtElm.Graphic; CIMParagraphTextGraphic cimPolyTxtGra = polyTxtGra as CIMParagraphTextGraphic; cimPolyTxtGra.Frame.BorderSymbol = new CIMSymbolReference(); cimPolyTxtGra.Frame.BorderSymbol.Symbol = SymbolFactory.Instance.ConstructLineSymbol(ColorFactory.Instance.GreyRGB, 1.0, SimpleLineStyle.Solid); polyTxtElm.SetGraphic(polyTxtGra); }); #endregion #region Create a new picture element with advanced symbol settings //Create a picture element and also set background and border symbology. QueuedTask.Run(() => { //Build 2D envelope geometry Coordinate2D pic_ll = new Coordinate2D(6, 1); Coordinate2D pic_ur = new Coordinate2D(8, 2); Envelope env = EnvelopeBuilder.CreateEnvelope(pic_ll, pic_ur); //Create and add element to layout string picPath = @"C:\Temp\WhitePass.jpg"; GraphicElement picElm = LayoutElementFactory.Instance.CreatePictureGraphicElement(layout, env, picPath); picElm.SetName("New Picture"); //(Optionally) Modify the border and shadow CIMGraphic picGra = picElm.Graphic; CIMPictureGraphic cimPicGra = picGra as CIMPictureGraphic; cimPicGra.Frame.BorderSymbol = new CIMSymbolReference(); cimPicGra.Frame.BorderSymbol.Symbol = SymbolFactory.Instance.ConstructLineSymbol(ColorFactory.Instance.BlueRGB, 2.0, SimpleLineStyle.Solid); cimPicGra.Frame.ShadowSymbol = new CIMSymbolReference(); cimPicGra.Frame.ShadowSymbol.Symbol = SymbolFactory.Instance.ConstructPolygonSymbol(ColorFactory.Instance.BlackRGB, SimpleFillStyle.Solid); picElm.SetGraphic(picGra); }); #endregion #region Create a map frame and zoom to a bookmark //Create a map frame and also sets its extent by zooming the the extent of an existing bookmark. QueuedTask.Run(() => { //Build 2D envelope geometry Coordinate2D mf_ll = new Coordinate2D(6.0, 8.5); Coordinate2D mf_ur = new Coordinate2D(8.0, 10.5); Envelope mf_env = EnvelopeBuilder.CreateEnvelope(mf_ll, mf_ur); //Reference map, create MF and add to layout MapProjectItem mapPrjItem = Project.Current.GetItems <MapProjectItem>().FirstOrDefault(item => item.Name.Equals("Map")); Map mfMap = mapPrjItem.GetMap(); MapFrame mfElm = LayoutElementFactory.Instance.CreateMapFrame(layout, mf_env, mfMap); mfElm.SetName("New Map Frame"); //Zoom to bookmark Bookmark bookmark = mfElm.Map.GetBookmarks().FirstOrDefault(b => b.Name == "Great Lakes"); mfElm.SetCamera(bookmark); }); #endregion #region Create a legend for a specifc map frame //Create a legend for an associated map frame. QueuedTask.Run(() => { //Build 2D envelope geometry Coordinate2D leg_ll = new Coordinate2D(6, 2.5); Coordinate2D leg_ur = new Coordinate2D(8, 4.5); Envelope leg_env = EnvelopeBuilder.CreateEnvelope(leg_ll, leg_ur); //Reference MF, create legend and add to layout MapFrame mapFrame = layout.FindElement("New Map Frame") as MapFrame; if (mapFrame == null) { ArcGIS.Desktop.Framework.Dialogs.MessageBox.Show("Map frame not found", "WARNING"); return; } Legend legendElm = LayoutElementFactory.Instance.CreateLegend(layout, leg_env, mapFrame); legendElm.SetName("New Legend"); }); #endregion #region Creating group elements //Create an empty group element at the root level of the contents pane //Note: call within QueuedTask.Run() GroupElement grp1 = LayoutElementFactory.Instance.CreateGroupElement(layout); grp1.SetName("Group"); //Create a group element inside another group element //Note: call within QueuedTask.Run() GroupElement grp2 = LayoutElementFactory.Instance.CreateGroupElement(grp1); grp2.SetName("Group in Group"); #endregion Creating group elements { #region Create scale bar Coordinate2D llScalebar = new Coordinate2D(6, 2.5); MapFrame mapframe = layout.FindElement("New Map Frame") as MapFrame; //Note: call within QueuedTask.Run() LayoutElementFactory.Instance.CreateScaleBar(layout, llScalebar, mapframe); #endregion } #region How to search for scale bars in a style var arcgis_2d = Project.Current.GetItems <StyleProjectItem>().First(si => si.Name == "ArcGIS 2D"); QueuedTask.Run(() => { var scaleBarItems = arcgis_2d.SearchScaleBars("Double Alternating Scale Bar"); }); #endregion #region How to add a scale bar from a style to a layout var arcgis_2dStyle = Project.Current.GetItems <StyleProjectItem>().First(si => si.Name == "ArcGIS 2D"); QueuedTask.Run(() => { //Imperial Double Alternating Scale Bar //Metric Double Alternating Scale Bar //or just use empty string to list them all... var scaleBarItem = arcgis_2d.SearchScaleBars("Double Alternating Scale Bar").FirstOrDefault(); Coordinate2D coord2D = new Coordinate2D(10.0, 7.0); MapFrame myMapFrame = layout.FindElement("Map Frame") as MapFrame; LayoutElementFactory.Instance.CreateScaleBar(layout, coord2D, myMapFrame, scaleBarItem); }); #endregion #region Create NorthArrow Coordinate2D llNorthArrow = new Coordinate2D(6, 2.5); MapFrame mf = layout.FindElement("New Map Frame") as MapFrame; //Note: call within QueuedTask.Run() var northArrow = LayoutElementFactory.Instance.CreateNorthArrow(layout, llNorthArrow, mf); #endregion #region How to search for North Arrows in a style var arcgis_2dStyles = Project.Current.GetItems <StyleProjectItem>().First(si => si.Name == "ArcGIS 2D"); QueuedTask.Run(() => { var scaleBarItems = arcgis_2dStyles.SearchNorthArrows("ArcGIS North 13"); }); #endregion #region How to add a North Arrow from a style to a layout var arcgis2dStyles = Project.Current.GetItems <StyleProjectItem>().First(si => si.Name == "ArcGIS 2D"); QueuedTask.Run(() => { var northArrowStyleItem = arcgis2dStyles.SearchNorthArrows("ArcGIS North 13").FirstOrDefault(); Coordinate2D nArrow = new Coordinate2D(6, 2.5); MapFrame newFrame = layout.FindElement("New Map Frame") as MapFrame; //Note: call within QueuedTask.Run() var newNorthArrow = LayoutElementFactory.Instance.CreateNorthArrow(layout, nArrow, newFrame, northArrowStyleItem); }); #endregion #region Create dynamic text var title = @"<dyn type = ""page"" property = ""name"" />"; Coordinate2D llTitle = new Coordinate2D(6, 2.5); //Note: call within QueuedTask.Run() var titleGraphics = LayoutElementFactory.Instance.CreatePointTextGraphicElement(layout, llTitle, null) as TextElement; titleGraphics.SetTextProperties(new TextProperties(title, "Arial", 24, "Bold")); #endregion #region Create dynamic table QueuedTask.Run(() => { //Build 2D envelope geometry Coordinate2D tab_ll = new Coordinate2D(6, 2.5); Coordinate2D tab_ur = new Coordinate2D(12, 6.5); Envelope tab_env = EnvelopeBuilder.CreateEnvelope(tab_ll, tab_ur); MapFrame mapFrame = layout.FindElement("New Map Frame") as MapFrame; // get the layer MapProjectItem mapPrjItem = Project.Current.GetItems <MapProjectItem>().FirstOrDefault(item => item.Name.Equals("Map")); Map theMap = mapPrjItem?.GetMap(); var lyrs = theMap?.FindLayers("Inspection Point Layer", true); if (lyrs?.Count > 0) { Layer lyr = lyrs[0]; var table1 = LayoutElementFactory.Instance.CreateTableFrame(layout, tab_env, mapFrame, lyr, new string[] { "No", "Type", "Description" }); } }); #endregion }
public virtual ActionResult EditLayoutczinfo(LayoutView layoutView) { try { var layout = _entities.Layouts.SingleOrDefault(x => x.LayoutID == layoutView.LayoutID); layout.ErpAccount = layoutView.ErpAccount; layout.SdDate = layoutView.SDDate; // layout.CzHaveDone = layoutView.CzHaveDone; layout.CzDoneDate = layoutView.CzDnodeDate; layout.TJDoneDate = layoutView.TJDoneDate; layout.SubStationDoneDate = layoutView.SubStationDoneDate; layout.PgdDoneDate = layoutView.PgDoneDate; _entities.SaveChanges(); return Content("已经保存"); } catch { return Content("未能保存"); } }
async public void snippets_ProjectItems() { #region Reference layout project items //A layout project item is an item that appears in the Layouts folder in the Catalog pane //Reference all the layout project items IEnumerable <LayoutProjectItem> layouts = Project.Current.GetItems <LayoutProjectItem>(); //Or reference a specific layout project item by name LayoutProjectItem layoutItem = Project.Current.GetItems <LayoutProjectItem>().FirstOrDefault(item => item.Name.Equals("MyLayout")); #endregion #region Open a layout project item in a new view //A layout project item may be in a project but it may not be open in a view and/or active //First get the layout associated with the layout project item Layout layout = layoutItem.GetLayout(); //Open a new pane ILayoutPane iNewLayoutPane = await ProApp.Panes.CreateLayoutPaneAsync(layout); #endregion #region Activate an already open layout view //A layout view may exist but it may not be active //Iterate through each pane in the application and check to see if the layout is already open and if so, activate it foreach (var pane in ProApp.Panes) { var layoutPane = pane as ILayoutPane; if (layoutPane == null) //if not a layout view, continue to the next pane { continue; } if (layoutPane.LayoutView.Layout == layout) //if there is a match, activate the view { (layoutPane as Pane).Activate(); return; } } #endregion #region Reference the active layout view //First check to see if the current, active view is a layout view. If it is, use it LayoutView activeLayoutView = LayoutView.Active; if (activeLayoutView != null) { // use activeLayoutView } #endregion #region Create a new, basic layout and open it //Create a new layout project item layout in the project Layout newLayout = await QueuedTask.Run <Layout>(() => { newLayout = LayoutFactory.Instance.CreateLayout(8.5, 11, LinearUnit.Inches); newLayout.SetName("New 8.5x11 Layout"); return(newLayout); }); //Open new layout on the GUI thread await ProApp.Panes.CreateLayoutPaneAsync(newLayout); #endregion #region Create a new layout using a modified CIM and open it //Create a new layout project item layout in the project Layout newCIMLayout = await QueuedTask.Run <Layout>(() => { //Set up a CIM page CIMPage newPage = new CIMPage { //required parameters Width = 8.5, Height = 11, Units = LinearUnit.Inches, //optional rulers ShowRulers = true, SmallestRulerDivision = 0.5, //optional guides ShowGuides = true }; CIMGuide guide1 = new CIMGuide { Position = 1, Orientation = Orientation.Vertical }; CIMGuide guide2 = new CIMGuide { Position = 6.5, Orientation = Orientation.Vertical }; CIMGuide guide3 = new CIMGuide { Position = 1, Orientation = Orientation.Horizontal }; CIMGuide guide4 = new CIMGuide { Position = 10, Orientation = Orientation.Horizontal }; List <CIMGuide> guideList = new List <CIMGuide> { guide1, guide2, guide3, guide4 }; newPage.Guides = guideList.ToArray(); //Create a new page newCIMLayout = LayoutFactory.Instance.CreateLayout(newPage); newCIMLayout.SetName("New 8.5x11 Layout"); return(newCIMLayout); }); //Open new layout on the GUI thread await ProApp.Panes.CreateLayoutPaneAsync(newCIMLayout); #endregion #region Import a pagx into a project //Create a layout project item from importing a pagx file IProjectItem pagx = ItemFactory.Instance.Create(@"C:\Temp\Layout.pagx") as IProjectItem; Project.Current.AddItem(pagx); #endregion #region Remove a layout project item //Remove a layout from the project completely Project.Current.RemoveItem(layoutItem); #endregion }