/// <summary> /// Создать дубликат объекта /// </summary> /// <returns></returns> public My_Picture Clone() { My_Picture res = ObjectCopier.Clone(this); res.Core = core; return(res); }
public void GetFromClipboard() { IDataObject dataObj = Clipboard.GetDataObject(); List <My_Figure> pasted_figures = new List <My_Figure>(); if (dataObj.GetDataPresent(typeof(byte[]))) { byte[] data = dataObj.GetData(typeof(byte[])) as byte[]; pasted_figures = My_Picture.Deserialize(data); if (pasted_figures == null) { return; } } foreach (My_Figure figure in pasted_figures) { figure.Core = this; picture.FigureList.Add(figure); SelectedFigures.Add(figure); if (figure is My_Port) { (figure as My_Port).TextLabel.Core = this; } } AddToHistory(); form.Invalidate(); }
public My_History(EntityDrawningCore core) { this.core = core; history = new List <My_Picture>(); current = core.Picture.Clone(); savedItem = current; history.Add(current); }
public My_Picture Undo() { int index = history.IndexOf(current); if (index > 0) { current = history.ElementAt <My_Picture>(index - 1); } return(current.Clone()); }
public void ReDo() { My_Picture pict = history.ReDo(); if (pict != null) { picture = pict; } UnselectAll(); form.Invalidate(); }
public void add(My_Picture item) { int index = history.IndexOf(current); current = item.Clone(); if (index == history.Count - 1) { history.Add(current); return; } history.RemoveRange(index + 1, (history.Count - index - 1)); history.Add(current); }
public My_Picture ReDo() { int index = history.IndexOf(current); if (index == history.Count - 1) { current = history.Last <My_Picture>(); } if (index == -1) { current = history.First <My_Picture>(); } current = history.ElementAt <My_Picture>(index + 1); return(current.Clone()); }
public void CopyToClipboard() { // регистрируем свой собственный формат данных либо получаем его, если он уже зарегистрирован List <My_Figure> copy_figure = new List <My_Figure>(); foreach (My_Figure figure in SelectedFigures) { copy_figure.Add(figure); } // копируем в буфер обмена IDataObject dataObj = new DataObject(); dataObj.SetData(My_Picture.Serialize(copy_figure)); Clipboard.SetDataObject(dataObj, false); }
public EntityDrawningCore(EntityDrawningForm form) { this.form = form; Lock = false; picture = new My_Picture(this); history = new My_History(this); selectedFigures = new List <My_Figure>(); group_selector = new GroupSelector(this); paper = new My_Paper(this); //Загрузка настроек по-умолчанию paper.BGColor = Schematix.CommonProperties.Configuration.CurrentConfiguration.EntityDrawningOptions.BGColor; paper.LineColor = Schematix.CommonProperties.Configuration.CurrentConfiguration.EntityDrawningOptions.BorderColor; paper.DrawBorder = Schematix.CommonProperties.Configuration.CurrentConfiguration.EntityDrawningOptions.ShowBorder; paper.DrawGrig = Schematix.CommonProperties.Configuration.CurrentConfiguration.EntityDrawningOptions.ShowGrid; SelectedColor = Schematix.CommonProperties.Configuration.CurrentConfiguration.EntityDrawningOptions.SelectColor; UpdateHistory += new UpdateHistoryDelegate(EntityDrawningCore_UpdateHistory); }
public void openProject(Stream stream) { if (stream.Length == 0) { return; } IFormatter formatter = new BinaryFormatter(); My_Picture pict = (My_Picture)formatter.Deserialize(stream); info = pict.info; stream.Close(); if ((info != null) && (info.IsCorrect() == true)) { foreach (My_Figure fig in pict.FigureList) { fig.Core = core; if (fig is My_Port) { (fig as My_Port).TextLabel.Core = core; } } pict.core = core; this.figureList = pict.FigureList; } else { if (info != null) { core.Picture.openVHDLFile(info.VHDLFileName, info.Entity.name); } } if (core != null) { core.History.ClearHistory(); core.History.add(this); core.History.SetAsSaved(); } }
public void SetAsSaved() { savedItem = current; }