public override void Flow(IColorable connection, Color newColor) { /*var notSignalledConnections = GetNotSignalledConnections(); if (notSignalledConnections.Any()) { SplitFlow(Connections, graphConnection => graphConnection.Flow(CurrentColor)); }*/ if (newColor == null) //signalled nil { Connections.Filter(connection); return; } if (!FlowIfCan()) return; bool doFlow; lock (this) { doFlow = !Connections.IsFiltered(connection); } if (doFlow) { base.Flow(connection, newColor); CurrentColor = newColor; if (Parent!=null) Parent.Flow(this,CurrentColor); InvokeOnFlow(); //Flow } else NotifyConnectionBack(connection); }
public string Process(IColorable firstColorable, IColorable secondColorable) { // Фактически исходная задача не решена, т.к. мы лишь определяем во времени выполении тип параметров, // но не выбор одной из полиморфных перегрузок ниже var visitor = new Visitor(); firstColorable.IdentifyItself(visitor); secondColorable.IdentifyItself(visitor); return visitor.ColorCombination; }
public IColorable ConnectTo(IColorable to, int length = 1) { if (to is InPoint) return ConnectTo((InPoint)to, length); if (to is OutPoint) return ConnectTo((OutPoint)to, length); if (to is GraphNode) return ConnectTo((GraphNode)to, length); if (to is GraphConnection) return ConnectTo((GraphConnection)to, length); return this; }
public override void Flow(IColorable connection, Color newColor) { CurrentColor = Input.GetCurrentColor(); if (CurrentColor==null) { Clear(); } else { if (!FlowIfCan()) return; base.Flow(this, CurrentColor); } FlowResult(); }
public override void Flow(IColorable connection, Color newColor) { if (newColor != null && !FlowIfCan()) { NotifyConnectionBack(connection); return; } base.Flow(connection,newColor); if (newColor==null) { Clear(); } CurrentColor = newColor; InvokeOnFlow(); SplitFlow(Connections.All, graphConnection => graphConnection.Flow(this, CurrentColor)); }
public static void SetColors(IColorable colorable, float desiredRed, float desiredGreen, float desiredBlue, string op) { if (op == "AddSigned") { desiredRed -= 127.5f; desiredGreen -= 127.5f; desiredBlue -= 127.5f; op = "Add"; } colorable.ColorOperation = TranslateColorOperation(op); colorable.Red = desiredRed / 255.0f; colorable.Green = desiredGreen / 255.0f; colorable.Blue = desiredBlue / 255.0f; }
private PointScheme ColorBox(IEnumerable <Color> colors) { PointScheme ps = new PointScheme(); ps.Categories.Clear(); foreach (Color color in colors) { IColorable c = _template as IColorable; if (c != null) { c.Color = color; } PointCategory pc = new PointCategory(_template); ps.Categories.Add(pc); } ps.Categories[0].FilterExpression = "[" + _classificationField + "] < "; return(ps); }
public override void Flow(IColorable connection, Color newColor) { //TODO add "this" if (!(connection is InPoint)) return; Input.Filter(connection); /* if (!Input.IsFiltered(connection)); if (doFlow) { base.Flow(connection, newColor); CurrentColor = newColor;Undo() DoWork(); //Flow } else NotifyConnectionBack(connection);*/ }
/// <summary> /// Initializes a new instance of the <see cref="PointCategory"/> class from the list of symbols. /// </summary> /// <param name="symbols">Symbols used for this category.</param> public PointCategory(IEnumerable <ISymbol> symbols) { var symb = symbols as IList <ISymbol> ?? symbols.ToList(); Symbolizer = new PointSymbolizer(symb); List <ISymbol> copy = symb.CloneList(); if (copy.Any()) { IColorable c = symb.Last() as IColorable; if (c != null) { c.Color = Color.Cyan; } } SelectionSymbolizer = new PointSymbolizer(copy); }
private void CbColorSimpleColorChanged(object sender, EventArgs e) { if (_ignoreChanges) { return; } IColorable c = ccSymbols.SelectedSymbol as IColorable; if (c != null) { c.Color = cbColorSimple.Color; sldOpacitySimple.MaximumColor = Color.FromArgb(255, c.Color); sldOpacitySimple.Value = c.Opacity; sldOpacitySimple.Invalidate(); } UpdatePreview(); }
public void SetColorableProperties(IColorable tempParticle) { #region Alpha, Color, and Operations tempParticle.Alpha = mEmissionSettings.Alpha; tempParticle.AlphaRate = mEmissionSettings.AlphaRate; tempParticle.Red = mEmissionSettings.Red; tempParticle.Green = mEmissionSettings.Green; tempParticle.Blue = mEmissionSettings.Blue; tempParticle.RedRate = mEmissionSettings.RedRate; tempParticle.GreenRate = mEmissionSettings.GreenRate; tempParticle.BlueRate = mEmissionSettings.BlueRate; tempParticle.ColorOperation = mEmissionSettings.ColorOperation; tempParticle.BlendOperation = mEmissionSettings.BlendOperation; #endregion }
public override void Flow(IColorable connection, Color newColor) { if (!FlowIfCan() && newColor != null) { NotifyBack(this, new ErrorSignal(new GraphExceptionAlreadyColored(this))); return; } if (newColor == null) { Clear(); } CurrentColor = newColor; base.Flow(From, GetCurrentColor()); if (To != null) { InvokeOnFlow(); To.Flow(this, CurrentColor); } }
public override void Flow(IColorable connection, Color newColor) { if (!FlowIfCan() && newColor!=null) { NotifyBack(this, new ErrorSignal(new GraphExceptionAlreadyColored(this))); return; } if (newColor == null) { Clear(); } CurrentColor = newColor; base.Flow(From,GetCurrentColor()); if (To != null) { InvokeOnFlow(); To.Flow(this, CurrentColor); } }
public IColorable ConnectTo(IColorable to, int length = 1) { if (to is InPoint) { return(ConnectTo((InPoint)to, length)); } if (to is OutPoint) { return(ConnectTo((OutPoint)to, length)); } if (to is GraphNode) { return(ConnectTo((GraphNode)to, length)); } if (to is GraphConnection) { return(ConnectTo((GraphConnection)to, length)); } return(this); }
protected void FlowResult() { if (!CanSignal()) { return; } IColorable nextOut; IEnumerable <IColorable> notFilteredOutput = Output.NotFiltered; if (!notFilteredOutput.Any()) { nextOut = null; } else { //nextOut = notFilteredOutput.MaxBy(outPoint => outPoint.GetLength()); //without MoreLinq: nextOut = null; int?minLength = null; foreach (IColorable outPoint in notFilteredOutput) { int length = (outPoint is IEdge)?((IEdge)outPoint).GetLength():0; if (minLength == null || length < (int)minLength) { minLength = length; nextOut = outPoint; } } } CurrentPath = nextOut; InvokeOnFlow(); if (nextOut == null) { return; } // GoBack(new ErrorSignal(new Exception("All branches failed"))); new Thread(() => nextOut.Flow(this, CurrentColor)) { IsBackground = true }.Start(); }
public override void Flow(IColorable connection, Color newColor) { //TODO add "this" if (!(connection is InPoint)) { return; } Input.Filter(connection); /* * if (!Input.IsFiltered(connection)); * if (doFlow) * { * * base.Flow(connection, newColor); * CurrentColor = newColor;Undo() * DoWork(); //Flow * } * else * NotifyConnectionBack(connection);*/ }
static void Main(string[] args) { Shape[] shapes = new Shape[4]; shapes[0] = new Circle(2, "red", true); shapes[1] = new Rectangle(3, 4, "yellow", false); shapes[2] = new Square(5, "orange", true); shapes[3] = new Square(6, "blue", false); foreach (var shape in shapes) { Console.Write($"Area shape: {shape.GetArea()}\t"); if (shape is IColorable) { IColorable icolorable = (Square)shape; icolorable.HowToColor(); } else { Console.Write("There is no coloring!.\n"); } } }
private void Update() { //get current tile, and be sure is in contact TileBase currentTile = GameManager.instance.labyrinthGrid.GetCurrentTile(transform.position); if (Vector3.Distance(transform.position, currentTile.transform.position) > contactDistance) { return; } //if different tile from last one if (currentTile != lastTile) { lastTile = currentTile; //if there is interface, color tile IColorable colorable = currentTile.GetComponent <IColorable>(); if (colorable != null) { colorable.ColorElement(GetComponentInChildren <Renderer>().material.color); } } }
public override void Flow(IColorable connection, Color newColor) { /*var notSignalledConnections = GetNotSignalledConnections(); * if (notSignalledConnections.Any()) * { * SplitFlow(Connections, graphConnection => graphConnection.Flow(CurrentColor)); * }*/ if (newColor == null) //signalled nil { Connections.Filter(connection); return; } if (!FlowIfCan()) { return; } bool doFlow; lock (this) { doFlow = !Connections.IsFiltered(connection); } if (doFlow) { base.Flow(connection, newColor); CurrentColor = newColor; if (Parent != null) { Parent.Flow(this, CurrentColor); } InvokeOnFlow(); //Flow } else { NotifyConnectionBack(connection); } }
public string GetPathThickness() { float pathThickness = 0; string thickness = "-"; for (int i = 0; i < _currentColorables.Count; i++) { IColorable current = _currentColorables[i]; if (i == 0) { pathThickness = current.GetPathThickness(); thickness = pathThickness.ToString(); } else { if (current.GetPathThickness() != pathThickness) { return("-"); } } } return(thickness); }
public override void UpdateMenu(IColorable colorables) { _colorSelector.UpdateColorable(colorables); }
public GraphExceptionAlreadyColored(IColorable sender) : base(sender) { }
protected abstract void NotifyBack(IColorable from, SerialSignal signal);
public GraphException(IColorable sender) { Sender = sender; }
public GraphExceptionAllPossibilitiesFailed(IColorable sender, Exception[] errors) : base(sender) { Errors = errors; }
protected override void NotifyBack(IColorable from, BroadcastSignal signal) { bool contains; lock (BroadcastSignals) { contains = BroadcastSignals.Contains(signal); if (!contains) BroadcastSignals.Add(signal); } if (contains) System.Diagnostics.Debug.WriteLine(String.Format("\tBroadcast repeated {0} ({1}, color={2})", signal, ToString(), CurrentColor == null ? "null" : CurrentColor.ToStringDemuxed())); else System.Diagnostics.Debug.WriteLine(String.Format("\tBroadcast {0} ({1}, color={2})", signal, ToString(), CurrentColor == null ? "null" : CurrentColor.ToStringDemuxed())); signal.Process(this, contains); InvokeOnNotifyBack(); if (!contains) { SplitNotify(GetPrevPaths(), signal); } }
public void Unselect() { if(selectedObject!=null) selectedObject.ColorIndex=-1; for(int i=0;i<properties.Count;i++) properties[i].ToggleSelected(false,null); selectedObject=null; }
public void NotifyBack(IColorable from, Signal signal) { var serialSignal = signal as SerialSignal; var broadcastSignal = signal as BroadcastSignal; if (serialSignal != null) NotifyBack(from, serialSignal); else if (broadcastSignal != null) NotifyBack(from, broadcastSignal); }
/* public override IEnumerable<KeyValuePair<GraphNode, int>> GetNextNodes() { var connections = GetAllConnections(); return connections.Select(connection => { if (connection == null || connection.To == null || connection.To.Parent == null) return new KeyValuePair<GraphNode, int>(null,0); return new KeyValuePair<GraphNode, int>(connection.To.Parent,connection.Length); }).Where(graphNode => graphNode.Key != null); }*/ // private readonly List<IColorable> _zeroSignalConnections = new List<IColorable>(); protected override void NotifyBack(IColorable from, SerialSignal signal) { signal.StopSending(); Connections.Filter(from); }
protected abstract void NotifyBack(IColorable from, BroadcastSignal signal);
public override void Flow(IColorable connection, Color color) { if (color!=null) Flowed = true; System.Diagnostics.Debug.WriteLine(String.Format("\tFlowing {0} ({1})", color == null ? "null" : color.ToStringDemuxed(), ToString())); }
public int GetLengthBeetween(IColorable to) { var edge = GetNextPaths().FirstOrDefault(path => path == to || (path is IEdge && path.GetNextPaths().Contains(to))); if (edge == null) return -1; var edge1 = edge as IEdge; if (edge1 != null) return edge1.GetLength(); return 1; }
protected void NotifyConnectionBack(IColorable connection) { if (connection != null && connection != this) new Thread(() => connection.NotifyBack(this, Signal)) { IsBackground = true }.Start(); //NotifyBack this connection }
static void Main(string[] args) { IColorable[] colorables = { new Animal(), new Wall() }; foreach (IColorable item in colorables) { item.applyColor(ConsoleColor.Red); } Animal cat = new Animal(); cat.speak(); cat.walk(); IColorable colorable = cat; IColorable colorable2 = new Animal(); Organics org = cat; org.speak(); org.walk(); return; Student std = new Student(); std[0] = "math"; std.subjects[0] = "science"; Console.WriteLine(std.subjects[0]); Person per2 = new Person(); IFillable fillable = new Student(); fillable.fill(ConsoleColor.Red); IFillable[] fillables = { std, fillable }; Person[] perons = { std, per2 }; foreach (Person item in perons) { item.name(); } Person per = std; per.speak(); per.name(); std.speak(); std.name(); }
/* private IEnumerable<GraphPath> GetPossibleOutputs(GraphNode graphNode) * { * if (Color.NullOrBlack(graphNode.Result)) * return new GraphPath[] { }; * * var allConnections = * graphNode.GetAllOutConnections().Where( * graphConnection => * !Color.NullOrBlack(graphConnection.CurrentColor) && * (graphConnection.To != null) && * (graphConnection.To.Parent != null) && * !(graphConnection.To.Parent is FinishNode) && * (graphConnection.To.CurrentColor == graphConnection.CurrentColor)); * return allConnections.Select( * graphConnection => new GraphPath(graphConnection.To.Parent, graphConnection.Length, graphConnection.To.Parent.Result)); * * }*/ private GraphPath GetColorList(IColorable connectionPoint) { GraphPathNode maxPath = new GraphPathNode(null, null); var queue = new Queue <GraphPathNode>(); //adding first item to queue queue.Enqueue(new GraphPathNode(null, connectionPoint)); //work while queue not empty - width search do { //get next item GraphPathNode current = queue.Dequeue(); IColorable[] graphPaths = null; //setMax = true if we need to compare current length with max IColorable last = current.Current; bool setMax = (last is FinishNode); if (!setMax) { //increase length //get all outputs IEnumerable <IColorable> possibleOutputs = last.GetNextPaths(); //null check graphPaths = possibleOutputs as IColorable[] ?? possibleOutputs.ToArray(); //if there is no output from current node or node have no color - we nedd to compare current length with max setMax = !graphPaths.Any() || (last.GetCurrentColor() == null); } if (setMax) { //compare maximal path with current if (maxPath < current) { maxPath = current; } } else { //we have node to explore //get current color //for all branches out of this node foreach (IColorable t in graphPaths) { //make new path to branch GraphPathNode newPath = new GraphPathNode(current, t); /* * //get color of branch * Color newColor = t.GetCurrentColor(); * if (newColor != null) * { * //if color contains previous color * if (newColor.Contains(currentColor)) * //then we set it al last color in path * newPath.LastColor = newColor; * else * //else - color changed and we add it * newPath.PathTo.Add(newColor); * * }*/ //add new path to que to analize if (t != null) { queue.Enqueue(newPath); } } } } while (queue.Count != 0); GraphPath res = MarkAsResult(maxPath); return(res); }
public abstract void Flow(IColorable connection, Color color);
//step back protected override void NotifyBack(IColorable from, SerialSignal signal) { if (!(from is OutPoint) && from!=this) // return; lock (this) { if( Output.IsFiltered(from)) return; } //Signal == true; signal.StopSending(); Output.Filter(from); //if signal==true - we have to signal, otherwise we just need to find other output; if (from == CurrentPath) { FlowResult(); } if (!SignalIfCan()) return; Signal = signal; Output.Filter(from); base.NotifyBack(this, signal); InvokeOnNotifyBack(); Input.NotifyBack(this, signal); }
public ColorSmoother(IColorable target, Color start, Color end, float duration, EaseTypes easeType) : base(start, end, duration, easeType) { this.target = target; }
public static void SetColors(IColorable colorable, float desiredRed, float desiredGreen, float desiredBlue, string op) { if (op == "AddSigned") { desiredRed -= 127.5f; desiredGreen -= 127.5f; desiredBlue -= 127.5f; op = "Add"; } colorable.ColorOperation = TranslateColorOperation(op); #if FRB_MDX colorable.Red = desiredRed; colorable.Green = desiredGreen; colorable.Blue = desiredBlue; #else colorable.Red = desiredRed / 255.0f; colorable.Green = desiredGreen / 255.0f; colorable.Blue = desiredBlue / 255.0f; #endif }
protected override void OnKeyPress(KeyPressEventArgs e) { clearSelected=true; if (!keystrokeProcessed) { char c = e.KeyChar; int cValue = (int) c; if (cValue==8) //backspace backspace(); else if(cValue==13)//enter { if(selectedObject!=null) selectedObject.ColorIndex=-1; for(int i=minSelColumn;i<maxSelColumn && i<over.Length;i++) if(over[i]) properties[i].ToggleSelected(false,selectedObject); enterKey(); if(clearSelected) selectedObject=null; else for(int i=minSelColumn;i<maxSelColumn && i<over.Length;i++) if(over[i]) { selectedObject.ColorIndex=i; properties[i].ToggleSelected(true,selectedObject); } } else { if(c>='0' && c<='9') readDigit((int)(c-'0')); else readChar(c); } Refresh(); } }
protected override void NotifyBack(IColorable @from, SerialSignal signal) { if (SignalIfCan()) { Signal = signal; base.NotifyBack(from, signal); InvokeOnNotifyBack(); From.NotifyBack(this, signal); } }
private void contextMenuStrip2_ItemClicked(object sender, ToolStripItemClickedEventArgs e) { this.contextMenuStrip2.Visible = false; try { if (e.ClickedItem.Text == "文本内容") { IInput input = new InputString(); string def = ""; if (SelectObjects.Count == 1) { IContextable contextable = (IContextable)SelectObjects[0]; def = contextable.Context; } if (input.Input(def, out def) == true) { foreach (IPrintObject ins in SelectObjects) { IContextable contextable = (IContextable)ins; contextable.Context = def; } Record(); } } else if (e.ClickedItem.Text == "文本对齐") { ISelectContextAlign align = new SelectContextAlign(); int def = 0; if (SelectObjects.Count == 1) { IContextAlignAble contextalignable = (IContextAlignAble)SelectObjects[0]; def = contextalignable.Align; } if (align.Select(def, out def) == true) { foreach (IPrintObject ins in SelectObjects) { IContextAlignAble contextalignable = (IContextAlignAble)ins; contextalignable.Align = def; } Record(); } } else if (e.ClickedItem.Text == "区域") { IInput input = new InputString(); int Area = -1; if (SelectObjects.Count == 1) { IChangeAreaAble changeareaable = (IChangeAreaAble)SelectObjects[0]; Area = changeareaable.Area; } IChangePrintArea printarea = new ChangePrintArea(); if (printarea.Change(Area, out Area) == true) { foreach (IPrintObject ins in SelectObjects) { IChangeAreaAble changeareaable = (IChangeAreaAble)ins; changeareaable.Area = Area; } Record(); } } else if (e.ClickedItem.Text == "删除") { List <IPrintObject> lst = new List <IPrintObject>(); foreach (IPrintObject ins in SelectObjects) { lst.Add(ins); } foreach (IPrintObject ins in lst) { IDeleteable deleteable = (IDeleteable)ins; deleteable.Delete(pnl); } Record(); } else if (e.ClickedItem.Text == "字体") { FontDialog f = new FontDialog(); if (SelectObjects.Count == 1) { IFontable fontable = (IFontable)SelectObjects[0]; f.Font = fontable.Font; } if (f.ShowDialog() == DialogResult.OK) { foreach (IPrintObject ins in SelectObjects) { IFontable fontable = (IFontable)ins; fontable.Font = f.Font; } Record(); } } else if (e.ClickedItem.Text == "边框") { IEditBorder border = new EditBorder(); int borderLeft = 0; int borderRight = 0; int borderTop = 0; int borderBottom = 0; if (SelectObjects.Count == 1) { IBorderable borderable = (IBorderable)SelectObjects[0]; borderLeft = borderable.BorderLeft; borderRight = borderable.BorderRight; borderTop = borderable.BorderTop; borderBottom = borderable.BorderBottom; } if (border.EditBorder(borderLeft, borderRight, borderTop, borderBottom, out borderLeft, out borderRight, out borderTop, out borderBottom) == true) { foreach (IPrintObject ins in SelectObjects) { IBorderable borderable = (IBorderable)ins; borderable.BorderLeft = borderLeft; borderable.BorderRight = borderRight; borderable.BorderTop = borderTop; borderable.BorderBottom = borderBottom; } Record(); } } else if (e.ClickedItem.Text == "颜色") { ColorDialog f = new ColorDialog(); Color def = Color.Black; if (SelectObjects.Count == 1) { IColorable colorable = (IColorable)SelectObjects[0]; def = colorable.Color; } f.Color = def; if (f.ShowDialog() == DialogResult.OK) { foreach (IPrintObject ins in SelectObjects) { IColorable colorable = (IColorable)ins; colorable.Color = f.Color; } Record(); } } else if (e.ClickedItem.Text == "左对齐") { ISizeable sizeable2 = (ISizeable)_fistSelectObject; foreach (IPrintObject ins in SelectObjects) { ISizeable sizeable = (ISizeable)ins; sizeable.Location = new Point(sizeable2.Location.X, sizeable.Location.Y); } Record(); } else if (e.ClickedItem.Text == "右对齐") { ISizeable sizeable2 = (ISizeable)_fistSelectObject; foreach (IPrintObject ins in SelectObjects) { ISizeable sizeable = (ISizeable)ins; sizeable.Location = new Point((sizeable2.Location.X + sizeable2.Size.Width) - sizeable.Size.Width, sizeable.Location.Y); } Record(); } else if (e.ClickedItem.Text == "上对齐") { ISizeable sizeable2 = (ISizeable)_fistSelectObject; foreach (IPrintObject ins in SelectObjects) { ISizeable sizeable = (ISizeable)ins; sizeable.Location = new Point(sizeable.Location.X, sizeable2.Location.Y); } Record(); } else if (e.ClickedItem.Text == "下对齐") { ISizeable sizeable2 = (ISizeable)_fistSelectObject; foreach (IPrintObject ins in SelectObjects) { ISizeable sizeable = (ISizeable)ins; sizeable.Location = new Point(sizeable.Location.X, (sizeable2.Location.Y + sizeable2.Size.Height) - sizeable.Size.Height); } Record(); } else if (e.ClickedItem.Text == "表格内容") { IGridable gridable = (IGridable)_fistSelectObject; List <string> lst = new List <string>(); if (tbdetail != null) { foreach (System.Data.DataColumn col in tbdetail.Columns) { if (col.ColumnName.StartsWith("#") == false) { lst.Add(col.ColumnName); } } } if (lst.Contains("#") == false) { lst.Add("#"); } if (lst.Contains("i") == false) { lst.Add("i"); } if (gridable.EditGrid(lst.ToArray()) == true) { Record(); } } else if (e.ClickedItem.Text == "表格格式") { IGridable gridable = (IGridable)_fistSelectObject; if (gridable.SetStyle() == true) { Record(); } } else if (e.ClickedItem.Text == "导入图片") { OpenFileDialog f = new OpenFileDialog(); if (f.ShowDialog() == DialogResult.OK) { var fileInfo = new System.IO.FileInfo(f.FileName); decimal len = Conv.ToDecimal(fileInfo.Length); len = len / 1024; if (len > 500) { throw new Exception("图片文件大于500K"); } var img = Image.FromFile(f.FileName); IImageAble imageable = (IImageAble)_fistSelectObject; imageable.Image = img; Record(); } } else if (e.ClickedItem.Text == "导出图片") { IImageAble imageable = (IImageAble)_fistSelectObject; if (imageable.Image == null) { throw new Exception("无可导出的图片"); } else { SaveFileDialog f = new SaveFileDialog(); f.Filter = "*.jpg|*.jpg"; if (f.ShowDialog() == DialogResult.OK) { imageable.Image.Save(f.FileName, System.Drawing.Imaging.ImageFormat.Jpeg); } } } else if (e.ClickedItem.Text == "属性") { System.Windows.Forms.MessageBox.Show(_fistSelectObject.propertyInfo, "属性"); } else if (e.ClickedItem.Text == "格式化") { IInput input = new InputFormatString(); string def = ""; if (SelectObjects.Count == 1) { IFormatable formatable = (IFormatable)SelectObjects[0]; def = formatable.Format; } if (input.Input(def, out def) == true) { foreach (IPrintObject ins in SelectObjects) { IFormatable formatable = (IFormatable)ins; formatable.Format = def; } Record(); } } else if (e.ClickedItem.Text == "改字段") { string def = ""; if (SelectObjects.Count == 1) { IFieldAble fieldable = (IFieldAble)SelectObjects[0]; def = fieldable.Field; } IChangeField chg = new ChangeField(); List <string> lst = new List <string>(); if (tbmain != null) { foreach (System.Data.DataColumn col in tbmain.Columns) { lst.Add(col.ColumnName); } } if (chg.Change(lst.ToArray(), def, out def) == true) { foreach (IPrintObject ins in SelectObjects) { IFieldAble fieldable = (IFieldAble)ins; fieldable.Field = def; } Record(); } } } catch (Exception ex) { System.Windows.Forms.MessageBox.Show(ex.Message); } }
/// <summary> /// We finished or failed - send result to all preceding colorables. But current have to be last. /// </summary> /// <param name="from"></param> /// <param name="signal"></param> protected override void NotifyBack(IColorable from, SerialSignal signal) { if (!SignalIfCan()) return; Signal = signal; base.NotifyBack(from, signal); List<IColorable> currentColor = new List<IColorable>(); List<IColorable> otherColor = new List<IColorable>(); foreach (var connection in Connections.NotFiltered) { if (connection==null) continue; if (connection.GetCurrentColor() == CurrentColor) currentColor.Add(connection); else otherColor.Add(connection); } SplitNotify(otherColor,signal); SplitNotify(currentColor, signal); InvokeOnNotifyBack(); }
public void UpdateColorable(IColorable colorable) { _colorPicker.UpdatePicker(colorable); }
public ColorInterpolator(IColorable target, EaseTypes easeType, bool isRepeatable = true) : this(target, Color.White, Color.White, easeType, 0, isRepeatable) { }
//step back protected override void NotifyBack(IColorable from, SerialSignal signal) { if (from != Output && from!=this) return; if (!SignalIfCan()) return; Signal = signal; base.NotifyBack(this, signal); InvokeOnNotifyBack(); SplitNotify(Input,signal); }
public void StartAsync() { //enter only one thread lock (StartingLock) { //if working when wait for work to finish StartedEvent.WaitOne(); //Start working StartedEvent.Reset(); } GetStartColors(); if (NodesToNotify.FilteredCount == NodesToNotify.Count) { if (NodesToNotify.Count == 0) { Finish(); } return; } Stop(); ClearGraph(); System.Diagnostics.Debug.WriteLine("Starting"); WasCleared = false; WasStoped = false; PrepareFlow(); NodesToNotify.ClearFilters(); foreach (var notifyNode in NodesToNotify) { notifyNode.OnNotifyBack += OnNotifyNodeFinished; } //Set onNotifyBackEvent for all nodes if (OnGlobalError != null) { Traverse(First, current => current.GetNextPaths(), current => { var colorableClass = current as ColorableClass; if (colorableClass != null) { colorableClass.OnNotifyBack += InvokeGlobalError; } }, null); } foreach (var first in First) { IColorable first1 = first; Color color; if (StartColors.ContainsKey(first)) { color = StartColors[first]; } else { color = null; } new Thread(() => first1.Flow(first1, color)) { IsBackground = true }.Start(); } }
/* public override IEnumerable<KeyValuePair<GraphNode, int>> GetNextNodes() * { * * var connections = GetAllConnections(); * return connections.Select(connection => * { * if (connection == null || connection.To == null || connection.To.Parent == null) * return new KeyValuePair<GraphNode, int>(null,0); * return new KeyValuePair<GraphNode, int>(connection.To.Parent,connection.Length); * }).Where(graphNode => graphNode.Key != null); * * }*/ // private readonly List<IColorable> _zeroSignalConnections = new List<IColorable>(); protected override void NotifyBack(IColorable from, SerialSignal signal) { signal.StopSending(); Connections.Filter(from); }
static void Main(string[] args) { IColorable[] colorables = new IColorable[3]; colorables[0] = new Rectangle(2, 3, "green", ); }
protected override void OnMouseDown(MouseEventArgs e) { for(int i=1;i<locs.Length;i++) { if(e.X>=locs[i]-threshhold && e.X<=locs[i]+threshhold) { movingFlag=true; moving[i]=true; this.Cursor=Cursors.VSplit; break; } } Unselect(); if(overY>=0 && overY<collection.Count && Cursor!=Cursors.VSplit) { for(int i=minSelColumn;i<maxSelColumn && i<over.Length;i++) if(over[i]) { if(selectedObject!=null) { selectedObject.ColorIndex=-1; //properties[i].ToggleSelected(false,null); } selectedObject=collection[overY] as IColorable; if(selectedObject!=null) selectedObject.ColorIndex=i; if(i-properties.Count>=0) OnOptionClick(new OptionClickEventArgs(strList[i-properties.Count],collection[overY],i,e)); else { OnOptionClick(new OptionClickEventArgs(properties[i].Name,collection[overY],i,e)); properties[i].ToggleSelected(true,collection[overY]); } Refresh(); break; } //else // if(i-properties.Count<0) // properties[i].ToggleSelected(false,collection[overY]); } this.Focus(); }
public virtual void UpdateMenu(IColorable colorables) { }
protected void FlowResult() { if (!CanSignal()) return; IColorable nextOut; IEnumerable<IColorable> notFilteredOutput = Output.NotFiltered; if (!notFilteredOutput.Any()) nextOut = null; else { //nextOut = notFilteredOutput.MaxBy(outPoint => outPoint.GetLength()); //without MoreLinq: nextOut = null; int? minLength = null; foreach (IColorable outPoint in notFilteredOutput) { int length = (outPoint is IEdge)?((IEdge)outPoint).GetLength():0; if (minLength == null || length < (int) minLength) { minLength = length; nextOut = outPoint; } } } CurrentPath = nextOut; InvokeOnFlow(); if (nextOut == null) return; // GoBack(new ErrorSignal(new Exception("All branches failed"))); new Thread(() => nextOut.Flow(this, CurrentColor)) { IsBackground = true }.Start(); }
protected override void NotifyBack(IColorable from, SerialSignal signal) { Signalled = true; System.Diagnostics.Debug.WriteLine(String.Format("\tSerial Signalling {0} ({1}, color={2})", signal, ToString(), CurrentColor == null ? "null" : CurrentColor.ToStringDemuxed())); }