public override bool isEqual(DiagramEntity key) { if (!(key is DiagramKeySlideV)) { return(false); } if (!base.isEqual(key)) { return(false); } DiagramKeySlideV k = (DiagramKeySlideV)key; if (!this.SlideDown.GetKeyCodeString().Equals(k.SlideDown.GetKeyCodeString())) { return(false); } if (!this.SlideDownHold.GetKeyCodeString().Equals(k.SlideDownHold.GetKeyCodeString())) { return(false); } if (!this.SlideUpHold.GetKeyCodeString().Equals(k.SlideUpHold.GetKeyCodeString())) { return(false); } if (!this.SlideUp.GetKeyCodeString().Equals(k.SlideUp.GetKeyCodeString())) { return(false); } return(true); }
public void CopyAllSelected(DiagramEntityContainer container) /* ============================================================ * Function : CDiagramClipboardHandler::CopyAllSelected * Description : Clones all selected object to the paste * array. * Access : Public * * Return : void * Parameters : none * * Usage : Call to copy all selected objects to the * clipboard. "Paste" will put them on screen. * * ============================================================*/ { ClearPaste(); List <object> arr = container.GetData(); int max = arr.Count; for (int t = 0; t < max; t++) { DiagramEntity obj = (DiagramEntity)(arr[t]); if (obj.Selected) { DiagramEntity newobj = obj.Clone(); newobj.Selected = (true); newobj.MoveRect(10, 10); newobj.GroupID = (obj.GroupID); m_paste.Add(newobj); } } }
/// <summary> /// append new overlapped rect to list /// </summary> /// <param name="entity"></param> /// <param name="lstOverlapped"></param> /// <returns></returns> public int GetOverlappedRect2(DiagramEntity entity, List <Rectangle> lstOverlapped) { if (entity == this) { return(0); } Rectangle rect = entity.Bounds; Rectangle rtReturn = new Rectangle(0, 0, 0, 0); for (int i = 0; i < this.Entities.Count; i++) { DiagramEntity d = this.Entities[i]; // GetAt(i); if (d == entity) //its self, skip { continue; } Rectangle rt = d.Bounds; if (rect.IntersectsWith(rt)) { Rectangle r = rect; r.Intersect(rt); lstOverlapped.Add(r); } } return(lstOverlapped.Count); }
/// <summary> /// check anything, include focus, .... /// </summary> /// <param name="undo"></param> /// <returns></returns> public bool isAnythingSame(UndoItem undo) { if (this.getHightlightCount() != undo.getHightlightCount()) { return(false); } if (this.SnapshotItems.Count != undo.SnapshotItems.Count) { return(false); } DiagramEntity entity = this.getHightlightEntity(); DiagramEntity item = undo.getHightlightEntity(); if (entity == item) //all null { return(isEqual(undo)); } if (entity != null && item != null) { if (!entity.isEqual(item)) { return(false); } } return(isEqual(undo)); }
public void focusSamePositionEntity(DiagramEntity entity) { List <object> items = this.SnapshotItems; for (int i = 0; i < items.Count; i++) { DiagramEntity item = (DiagramEntity)items[i]; if (item is DiagramKeyMatrix) { DiagramEntity d = ((DiagramKeyMatrix)item).findSamePositionEntity(entity); if (d != null) { item.Selected = true; d.Selected = true; } } else { if (item.Bounds.Equals(entity.Bounds)) { item.Selected = true; } } } }
public DiagramEntity findSamePositionEntity(DiagramEntity entity) { List <object> items = this.SnapshotItems; for (int i = 0; i < items.Count; i++) { DiagramEntity item = (DiagramEntity)items[i]; if (item is DiagramKeyMatrix) { DiagramEntity d = ((DiagramKeyMatrix)item).findSamePositionEntity(entity); if (d != null) { return(d); } } else { if (item.Bounds.Equals(entity.Bounds)) { return(item); } } } return(null); }
public override bool isEqual(DiagramEntity key) { if (!(key is DiagramKeySlideH)) { return(false); } if (!base.isEqual(key)) { return(false); } DiagramKeySlideH k = (DiagramKeySlideH)key; if (!this.SlideLeft.GetKeyCodeString().Equals(k.SlideLeft.GetKeyCodeString())) { return(false); } if (!this.SlideLeftHold.GetKeyCodeString().Equals(k.SlideLeftHold.GetKeyCodeString())) { return(false); } if (!this.SlideRightHold.GetKeyCodeString().Equals(k.SlideRightHold.GetKeyCodeString())) { return(false); } if (!this.SlideRight.GetKeyCodeString().Equals(k.SlideRight.GetKeyCodeString())) { return(false); } return(true); }
/************************************************************************/ /* * check overlapped error */ /************************************************************************/ public bool ErrorOverlapped() { int ncount = m_objs.GetSize(); List <Rectangle> ar = new List <Rectangle>(); for (int i = 0; i < ncount; i++) { ar.Clear(); if (m_objs.GetOverlappedRect2(m_objs.GetAt(i), ar) > 0) { return(true); } } //check the matrix again for (int i = 0; i < ncount; i++) { //ar.Clear(); DiagramEntity entity = m_objs.GetAt(i); if (entity.TypeName == DiagramKeyMatrix.KEY_MATRIX) { if (((DiagramKeyMatrix)entity).CheckInternalOverlapped()) { return(true); } } //if (m_objs.GetOverlappedRect2(m_objs.GetAt(i), ar) > 0) // return true; } return(false); }
private void unselect_all() { for (int i = 0; i < this.Entities.Count; i++) { DiagramEntity entity = this.Entities[i]; entity.Selected = false; } }
override public string getContentText() { DiagramEntity entity = this.get_selected_entity(); if (entity == null) { return(""); } return(entity.getContentText()); }
///-------------------------------------------------------------------------------- /// <summary>Create the instance with the designer view and other data.</summary> /// /// <param name="diagramEntity">The associated diagram entity.</param> /// <param name="entityViewModel">The associated entity view model.</param> /// <param name="solutionDiagram">The associated solution diagram.</param> ///-------------------------------------------------------------------------------- public DiagramEntityViewModel(DiagramEntity diagramEntity, EntityViewModel entityViewModel, DiagramViewModel solutionDiagram) { EntityViewModel = entityViewModel; EntityViewModel.PropertyChanged += new PropertyChangedEventHandler(EntityViewModel_PropertyChanged); Items.Add(EntityViewModel); LoadDiagramEntity(diagramEntity, false); DiagramEntity.Entity = EntityViewModel.Entity; WorkspaceID = Guid.NewGuid(); Diagram = solutionDiagram; }
/// <summary> /// ungroup the matrix entities to main editor /// </summary> /// <param name="sender"></param> /// <param name="e"></param> override public void OnMatrixUngroup_Click(object sender, EventArgs e) { for (int i = 0; i < this.Entities.Count; i++) { DiagramEntity entity = this.Entities[i].Clone(); this.ParentContainer.Add(entity); } this.Entities.Clear(); this.ParentContainer.Remove(this); }
public DiagramEntity findSamePositionEntity(DiagramEntity entity) { for (int i = 0; i < this.Entities.Count; i++) { if (((DiagramKey)this.Entities[i]).Bounds.Equals(entity.Bounds)) { return(this.Entities[i]); } } return(null); }
public override void Copy(DiagramEntity obj) { base.Copy(obj); DiagramKeySlideV k = (DiagramKeySlideV)obj; bool b = k.ContentModified; this.SlideUp = k.SlideUp; this.SlideUpHold = k.SlideUpHold; this.SlideDown = k.SlideDown; this.SlideDownHold = k.SlideDownHold; this.ContentModified = b; }
public override void Copy(DiagramEntity obj) { base.Copy(obj); DiagramKeyArea k = (DiagramKeyArea)obj; bool b = k.ContentModified; this.KeyCode = k.KeyCode; this.ContentModified = b; this.CapsEffect = k.CapsEffect; //restore contentmodified property }
public DiagramEntity get_selected_entity() { for (int i = 0; i < this.Entities.Count; i++) { DiagramEntity entity = this.Entities[i]; if (entity.Selected) { return(entity); } } return(null); }
public override void Copy(DiagramEntity obj) { base.Copy(obj); DiagramKeySlideH k = (DiagramKeySlideH)obj; bool b = k.ContentModified; this.SlideLeft = k.SlideLeft; this.SlideLeftHold = k.SlideLeftHold; this.SlideRight = k.SlideRight; this.SlideRightHold = k.SlideRightHold; this.ContentModified = b; }
//override public DEHT GetHitCode(Point point, Rectangle rect) //{ // DEHT result = base.GetHitCode(point, rect); // if (result == DEHT.DEHT_NONE) // return result; // for (int i = 0; i < this.Entities.Count; i++) // { // DiagramEntity entity = this.Entities[i]; // entity.Selected = false; // } // for (int i=0; i< this.Entities.Count; i++) // { // DiagramEntity entity = this.Entities[i]; // if (entity.GetHitCode(point) == DiagramEntity.DEHT.DEHT_BODY) // { // entity.Selected = true; // } // } // return result; //} public DiagramEntity hit_child(Point point) { unselect_all(); for (int i = 0; i < this.Entities.Count; i++) { DiagramEntity entity = this.Entities[i]; if (entity.GetHitCode(point) == DiagramEntity.DEHT.DEHT_BODY) { entity.Selected = true; //MessageBox.Show(i.ToString()); return(entity); } } return(null); }
/************************************************************************/ /* * resize them according to the new container's rectangle. * */ /************************************************************************/ private void resize_all_entities() { if (this.Rows <= 0 || this.Cols <= 0) { return; } if (this.Entities.Count != (this.Rows * this.Cols)) { build_all_entities(); } //for (int i=0; i< this.Entities.Count ; i++) //{ // this.Entities[i].ParentContainer = this.ParentContainer; //} Rectangle rtContainer = this.PhyBounds; //get all rows height, int nrows = this.Rows; int[] rows_h = new int[nrows]; if (!calculate_average(rtContainer.Height, nrows, this.RowSpacing, rows_h)) { return; } //get all cols width, int ncols = this.Cols; int[] cols_w = new int[ncols]; if (!calculate_average(rtContainer.Width, ncols, this.ColSpacing, cols_w)) { return; } for (int row = 0; row < nrows; row++) { for (int col = 0; col < ncols; col++) { int index = row * ncols + col; DiagramEntity entity = this.Entities[index]; Rectangle rtEntity = calculate_entity_rect(rtContainer, row, col, rows_h, cols_w); entity.PhyBounds = rtEntity; } } }
/// <summary> /// /// </summary> /// <returns>hightlight entities count</returns> public int getHightlightCount() { List <object> items = this.SnapshotItems; int ncount = 0; for (int i = 0; i < items.Count; i++) { DiagramEntity entity = (DiagramEntity)items[i]; if (entity.Selected) { ncount++; } } return(ncount); }
public bool CheckInternalOverlapped() { List <Rectangle> ar = new List <Rectangle>(); for (int i = 0; i < this.Entities.Count; i++) { DiagramEntity d = this.Entities[i]; // GetAt(i); ar.Clear(); if (GetOverlappedRect2(d, ar) > 0) { return(true); } } return(false); }
protected void OnSubEntityPropertiesWillChange(DiagramEntity entity, bool bPausedEvent, bool bJustRefreshPropertiesGrid) { if (this.ParentContainer != null) { if (this.ParentContainer.ParentEditor != null) { if (this.ParentContainer.ParentEditor.GetInteractMode() != DiagramEditor.MouseMode.MODE_NONE) { return; } } } if (this.OnEntityPropertiesBeforeChange != null) { this.OnEntityPropertiesBeforeChange(entity, bPausedEvent, bJustRefreshPropertiesGrid); } }
//[Category("Legend Sheet")] //[DisplayName("Background color")] //[Editor(typeof(ColorEditorUI), typeof(UITypeEditor))] //[TypeConverter(typeof(ColorConverterUI))] //public new Color BackColor //{ // get { return base.BackColor; } // set // { // if (base.BackColor != value) // { // if (m_objs != null) // m_objs.Snapshot(); // base.BackColor = value; // this.Modified = true; // if (this.OnRefreshPropertiesGrid != null) // this.OnRefreshPropertiesGrid(this, null); // //Refresh(); // } // } //} //public enum PS2Code //{ // AT = 1, //AT,XT,PS2 // XT, // PS2, //} //private PS2Code _PS2Set = PS2Code.XT ; //[DisplayName("PS/2 Set")] //[Description("PS/2 code set")] //public PS2Code PS2Set //{ // get { return _PS2Set; } // set // { // if (_PS2Set != value) // { // _PS2Set = value; // this.Modified = true; // } // } //} #endregion public void set_all_keys_beep_duration(int nDuration) { int ncount = m_objs.GetSize(); for (int i = 0; i < ncount; i++) { DiagramEntity entity = (DiagramEntity)m_objs.GetAt(i); if (entity.TypeName == DiagramKeyMatrix.KEY_MATRIX) { ((DiagramKeyMatrix)entity).set_all_child_beep_duration(nDuration); } else { DiagramKey key = (DiagramKey)m_objs.GetAt(i); key.BeepDuration = nDuration; } } }
public override bool isEqual(DiagramEntity key) { if (!(key is DiagramKeyArea)) { return(false); } DiagramKeyArea k = (DiagramKeyArea)key; if (!base.isEqual(k)) { return(false); } if (!this.KeyCode.ToString().Equals(k.KeyCode.ToString())) { return(false); } return(true); }
///-------------------------------------------------------------------------------- /// <summary>This property returns a copy of the forward engineering data for the solution.</summary> ///-------------------------------------------------------------------------------- public Diagram GetForwardInstance(Solution forwardSolution) { bool isCustomized = false; Diagram forwardItem = new Diagram(); if (ForwardInstance != null) { forwardItem.TransformDataFromObject(ForwardInstance, null, false); isCustomized = true; } else if (IsAutoUpdated == false) { forwardItem.TransformDataFromObject(this, null, false); isCustomized = true; } else { forwardItem.DiagramID = DiagramID; } foreach (DiagramEntity item in DiagramEntityList) { item.Diagram = this; DiagramEntity forwardChildItem = item.GetForwardInstance(forwardSolution); if (forwardChildItem != null) { forwardItem.DiagramEntityList.Add(forwardChildItem); isCustomized = true; } } if (isCustomized == false) { return(null); } forwardItem.SpecSourceName = DefaultSourceName; if (forwardSolution.ReferencedModelIDs.Find("ItemName", forwardItem.SpecSourceName) == null) { forwardSolution.ReferencedModelIDs.Add(CreateIDReference()); } #region protected #endregion protected return(forwardItem); }
/// <summary> /// create cvs text, /// See http://baike.baidu.com/subview/468993/5926031.htm?fromId=468993&from=rdtself /// for cvs text format /// For KB9000 format: /// 0 [0,0,1,1][0][0][Macro key contents] <0x0d> <0x0a> Macro1 //1 [0,0,1,1][0][0][Macro key contents] <0x0d> <0x0a> Macro2 //2 [0,0,1,1][0][0][Macro key contents] <0x0d> <0x0a> Macro3 //3 [0,0,1,1][0][0][Macro key contents] <0x0d> <0x0a> Macro4 //4 [0,0,1,1][0][0][Macro key contents] <0x0d> <0x0a> Macro5 //5 [Key rectangle][Beep pitch][Beep duration][Key content 0] ... [Key content n]<0x0d><0x0a> Key definitions //... ... ... //... ... ... //Last [PS2 code set][Inter-Code-Delay][Touch sensitivity][Touch delay]<0x0d><0x0a> Properties definition /// </summary> /// <returns></returns> public string CreateCVS() { DiagramEntity key = null; string strReturn = ""; strReturn = CreateMacroCVS();// for (int i = 0; i < m_objs.GetSize(); i++) { key = (DiagramEntity)(m_objs.GetAt(i)); string s = key.ExportCVS();// CreateCVS(); if (s != string.Empty) { strReturn += s; } } strReturn += CreateKB9000CVS(); return(strReturn); }
public void SetEntity(DiagramEntity entity) /* ============================================================ * Function : CDiagramPropertyDlg::SetEntity * Description : Sets the "CDiagramEntity"-entity derived * object that is associated with this dialog. * Access : Public * * Return : void * Parameters : CDiagramEntity* entity - Set the object * for this dialog. * * Usage : Call to set the "CDiagramEntity"-derived * object to be associated with this dialog. * * ============================================================*/ { m_entity = entity; }
/************************************************************************/ /* * export data to xml file. */ /************************************************************************/ public override void Export(int nLayerIndex, CLCIXML xml) { //create this matrix base.Export(nLayerIndex, xml); //export its entities xml.set_attribute("rows", this.Rows.ToString()); xml.set_attribute("rowspacing", this.RowSpacing.ToString()); xml.set_attribute("cols", this.Cols.ToString()); xml.set_attribute("colspacing", this.ColSpacing.ToString()); xml.set_attribute("count", this.Entities.Count.ToString()); for (int i = 0; i < this.Entities.Count; i++) { DiagramEntity entity = this.Entities[i]; entity.Export(i, xml); } xml.back_to_parent(); }
/* ========================================================================== * Class : CDiagramPropertyDlg * * Author : Johan Rosengren, Abstrakt Mekanik AB * * Date : 2004-03-31 * * Purpose : "CDiagramPropertyDlg" represents a property dialog for a * "CDiagramEntity" object. * * Description : The class is a pure virtual class derived from "CDialog". * * Usage : Create a property dialog in the resource editor, but * map it to "CDiagramPropertyDlg" instead of "CDialog". Add * an override of the pure virtual function "SetValues". * This function is expected to put data from "m_entity" in * appropriate fields in the dialog. Set data in "m_entity" * as appropriate (from an Apply-button handler or * whatever appropriate), and call "Redraw()" * if needed. * * In the "CDiagramEntity"-derived class, add a member of * the "CDiagramPropertyDlg"-derived class, and call * "SetPropertyDialog" in the constructor. * * The dialog is displayed as a modeless dialog. * "CDiagramEditor" will hide the dialog automatically when * another object is selected, no special Close-button is * necessary. * * ========================================================================*/ DiagramPropertyDlg(int res, Control parent) /* ============================================================ * Function : CDiagramPropertyDlg::CDiagramPropertyDlg * Description : constructor * Access : Public * * Return : void * Parameters : UINT res - Resource ID of the * dialog template. * CWnd* parent - Parent of the dialog - * the "CDiagramEditor". * * Usage : * * ============================================================*/ { m_entity = null; m_redrawWnd = null; }
public DiagramEntity getHightlightEntity() { List <object> items = this.SnapshotItems; for (int i = 0; i < items.Count; i++) { DiagramEntity entity = (DiagramEntity)items[i]; if (entity.Selected) { if (entity is DiagramKeyMatrix) { return(((DiagramKeyMatrix)entity).get_selected_entity()); } else { return(entity); } } } return(null); }