public static Performance Create(Perform per) { switch (per) { default: return new MSE(); } }
private void owner_changed(SubRec sb, Perform p) { for(int i=_cont.Count-1; i>=0; i--) { _cont[i].changed(sb, p); } if(p.art==Perform.Art.remove) { PLC.instance.DelVar(this); } }
public LevelUpStruct(string inputName, string inputDescription, int inputCost, string inputSpriteName, Perform inputPerformer, LevelUpTypes inputLevelUpType) { name = inputName; description = inputDescription; cost = inputCost; performer = inputPerformer; spriteName = inputSpriteName; levelUpType = inputLevelUpType; }
private void TickStep2(Perform cmd) { if(cmd.art == Perform.Art.remove || cmd.art == Perform.Art.setJson || (cmd.art == Perform.Art.set && !object.Equals(cmd.src._value, cmd.o))) { cmd.old_o = cmd.src._value; if(cmd.art == Perform.Art.setJson) { var jso = cmd.o as JSValue; JSValue ty; if(jso.ValueType == JSValueType.Object && jso.Value != null && (ty = jso.GetProperty("$type")).Defined) { Func<JSValue, Topic, Topic, JSValue> f; if(_knownTypes.TryGetValue(ty.ToString(), out f) && f != null) { cmd.src._value = f(jso, cmd.src, cmd.prim); } else { X13.Log.Warning("{0}.setJson({1}) - unknown $type", cmd.src.path, cmd.o); cmd.src._value = jso; } } else { cmd.src._value = jso; } } else { cmd.src._value = JSValue.Marshal(cmd.o); } if(cmd.art != Perform.Art.remove) { cmd.art = Perform.Art.changed; } } if(cmd.art == Perform.Art.changed) { cmd.src._json = null; } if(cmd.art == Perform.Art.remove || cmd.art == Perform.Art.move) { cmd.src.disposed = true; if(cmd.src.parent != null) { Topic tmp; cmd.src.parent._children.TryRemove(cmd.src.name, out tmp); } } //TODO: save for undo/redo /*IHistory h; if(cmd.prim!=null && cmd.prim._vt==VT.Object && (h=cmd.prim._o as IHistory)!=null) { h.Add(cmd); }*/ }
private void TickStep1(Perform c) { SubRec sr; Topic t; switch(c.art) { case Perform.Art.create: if((t = c.src.parent) != null) { //t._children[c.src.name]=c.src; if(t._subRecords != null) { lock(t._subRecords) { foreach(var st in t._subRecords.Where(z => z.path == t.path && (z.flags & SubRec.SubMask.Chldren) == SubRec.SubMask.Chldren)) { c.src.Subscribe(st); } } } while(t != null) { if(t._subRecords != null) { lock(t._subRecords) { foreach(var st in t._subRecords.Where(z => (z.flags & SubRec.SubMask.All) == SubRec.SubMask.All)) { c.src.Subscribe(st); } } } t = t.parent; } } EnquePerf(c); break; case Perform.Art.subscribe: case Perform.Art.unsubscribe: if((sr = c.o as SubRec) != null) { Topic.Bill b = null; Perform np; if((sr.flags & SubRec.SubMask.Once) == SubRec.SubMask.Once) { EnquePerf(c); } if((sr.flags & SubRec.SubMask.Chldren) == SubRec.SubMask.Chldren) { b = c.src.children; } if((sr.flags & SubRec.SubMask.All) == SubRec.SubMask.All) { b = c.src.all; } if(b != null) { foreach(Topic tmp in b) { if(c.art == Perform.Art.subscribe) { tmp.Subscribe(sr); np = Perform.Create(tmp, c.art, c.src); np.o = c.o; EnquePerf(np); } else { tmp._subRecords.Remove(sr); } } } np = Perform.Create(c.src, c.art == Perform.Art.subscribe ? Perform.Art.subAck : Perform.Art.unsubAck, c.src); np.o = c.o; EnquePerf(np); } break; case Perform.Art.remove: foreach(Topic tmp in c.src.all) { EnquePerf(Perform.Create(tmp, c.art, c.prim)); } break; case Perform.Art.move: if((t = c.o as Topic) != null) { string oPath = c.src.path; string nPath = t.path; t._children = c.src._children; c.src._children = null; t._value = c.src._value; c.src._value = JSValue.Undefined; if(c.src._subRecords != null) { foreach(var st in c.src._subRecords) { if(st.path.StartsWith(oPath)) { t.Subscribe(new SubRec() { path = st.path.Replace(oPath, nPath), flags = st.flags, f = st.f }); } } } foreach(var t1 in t.children) { t1.parent = t; } foreach(var t1 in t.all) { if(t1._subRecords != null) { for(int i = t1._subRecords.Count - 1; i >= 0; i--) { if(t1._subRecords[i].path.StartsWith(oPath)) { t1._subRecords[i].path = t1._subRecords[i].path.Replace(oPath, nPath); } else if(!t1._subRecords[i].path.StartsWith(nPath)) { t1._subRecords.RemoveAt(i); } } } t1.path = t1.parent == Topic.root ? string.Concat("/", t1.name) : string.Concat(t1.parent.path, "/", t1.name); DoCmd(Perform.Create(t1, Perform.Art.create, c.prim), false); } EnquePerf(c); int idx = _prOp.Count - 1; while(idx >= 0) { Perform c1 = _prOp[idx--]; if(c1.src == c.src && (c1.art == Perform.Art.set || c1.art == Perform.Art.setJson)) { var p = Perform.Create(t, c1.art, c1.prim); p.o = c1.o; p.i = c1.i; EnquePerf(p); break; } } } break; case Perform.Art.changed: case Perform.Art.set: case Perform.Art.setJson: EnquePerf(c); break; } }
private void cmds1Fire(Topic t, Perform c) { cmds1.Add(c); }
public ScintillaControl(string fullpath) { try { if (Win32.ShouldUseWin32()) { IntPtr lib = LoadLibrary(fullpath); hwndScintilla = CreateWindowEx(0, "Scintilla", "", WS_CHILD_VISIBLE_TABSTOP, 0, 0, this.Width, this.Height, this.Handle, 0, new IntPtr(0), null); directPointer = (IntPtr)SlowPerform(2185, 0, 0); IntPtr sciFunctionPointer = GetProcAddress(new HandleRef(null, lib), "Scintilla_DirectFunction"); if (sciFunctionPointer == IntPtr.Zero) sciFunctionPointer = GetProcAddress(new HandleRef(null, lib), "_Scintilla_DirectFunction@16"); if (sciFunctionPointer == IntPtr.Zero) { string msg = "The Scintilla module has no export for the 'Scintilla_DirectFunction' procedure."; throw new Win32Exception(msg, new Win32Exception(Marshal.GetLastWin32Error())); } _sciFunction = (Perform)Marshal.GetDelegateForFunctionPointer(sciFunctionPointer, typeof(Perform)); directPointer = DirectPointer; } UpdateUI += new UpdateUIHandler(OnUpdateUI); UpdateUI += new UpdateUIHandler(OnBraceMatch); UpdateUI += new UpdateUIHandler(OnCancelHighlight); DoubleClick += new DoubleClickHandler(OnBlockSelect); CharAdded += new CharAddedHandler(OnSmartIndent); Resize += new EventHandler(OnResize); this.InitScrollBars(this); } catch (Exception ex) { throw ex; } }
internal int EnquePerf(Perform cmd) { int idx=_prOp.BinarySearch(cmd); if(idx<0) { idx=~idx; _prOp.Insert(idx, cmd); } else { var a1=(int)_prOp[idx].art; if(((int)cmd.art)>=a1) { _prOp[idx]=cmd; } else { idx=~idx; } } return idx; }
public LearningAlgorithm(NNetwork nn, Perform per) : this(nn) { Per = Performance.Create(per); }
private void _owner_changed(SubRec sb, Perform p) { if(p.art==Perform.Art.remove) { for(int i=links.Count-1; i>=0; i--) { links[i].owner.Remove(p.prim); } } }
public void changed(SubRec sb, Perform p) { if(p.src==origin.owner && p.art==Perform.Art.remove && _owner!=null) { _owner.Remove(p.prim); } }
private void _Perform(Node n, Perform performFunc) { n.dirty = false; n.data.NeedsRevisit = false; //root node if (n.streamFrom.Count == 0) { IEnumerable <Model.ConnectionData> outputConnections = n.streamTo.Select(v => v.connection); LogUtility.Logger.Log(n.data.Name + " performed(root)"); performFunc(n.data, null, outputConnections, (Model.ConnectionData destination, Dictionary <string, List <AssetReference> > newOutput) => { if (destination != null) { AssetStream output = n.streamTo.Find(v => v.connection == destination); Assert.IsNotNull(output); if (output.assetGroups != newOutput) { output.nodeTo.dirty = true; LogUtility.Logger.LogFormat(LogType.Log, "{0} marked dirty ({1} => {2} updated)", output.nodeTo.data.Name, output.nodeFrom.data.Name, output.nodeTo.data.Name); m_streamManager.AssignAssetGroup(output.connection, newOutput); output.assetGroups = newOutput; } } } ); } else { if (n.streamTo.Count > 0) { IEnumerable <Model.ConnectionData> outputConnections = n.streamTo.Select(v => v.connection); IEnumerable <AssetGroups> inputs = n.streamFrom.Select(v => new AssetGroups(v.connection, v.assetGroups)); LogUtility.Logger.LogFormat(LogType.Log, "{0} perfomed", n.data.Name); performFunc(n.data, inputs, outputConnections, (Model.ConnectionData destination, Dictionary <string, List <AssetReference> > newOutput) => { Assert.IsNotNull(destination); AssetStream output = n.streamTo.Find(v => v.connection == destination); Assert.IsNotNull(output); output.AddNewOutput(newOutput); } ); } else { IEnumerable <AssetGroups> inputs = n.streamFrom.Select(v => new AssetGroups(v.connection, v.assetGroups)); LogUtility.Logger.LogFormat(LogType.Log, "{0} perfomed", n.data.Name); performFunc(n.data, inputs, null, null); } // Test output asset group after all input-output pairs are performed if (n.streamTo.Count > 0) { foreach (var to in n.streamTo) { if (to.IsStreamAssetRequireUpdate) { to.UpdateAssetGroup(m_streamManager); } else { LogUtility.Logger.LogFormat(LogType.Log, "[skipped]stream update skipped. Result is equivarent: {0} -> {1}", n.data.Name, to.nodeTo.data.Name); } } } } }
/// <summary> /// CreateMenuItem() - /// </summary> /// <param name="menuItemName"></param> /// <param name="isLastMenuItem"></param> /// <param name="action"></param> /// <returns></returns> private ToolStripMenuItem CreateMenuItem(string key, string menuItemName, Boolean isLastMenuItem, Perform action) { ToolStripMenuItem item = new ToolStripMenuItem(); item.Name = (++menuId).ToString(); item.Text = menuItemName; if (isLastMenuItem) { item.Click += new EventHandler(Execute); } actionMap.Add(item.Name, action); menuMap.Add(key, item); return(item); }
public void ReceiveMessage(MESSAGE RecievedMessage, object[] Args) { int Sender = Self.GetTree().GetRpcSenderId(); if (Sender == 0) { //When Sender it 0 that means that ReciveMessage was called locally Sender = Self.GetTree().GetNetworkUniqueId(); } if (Self.GetTree().IsNetworkServer()) { //Runs on server, 100% trusted switch (RecievedMessage) { case (MESSAGE.PLAYER_REQUEST_POS): { Perform.RemotePlayerMove(Events.INVOKER.SERVER, Sender, (Vector3)Args[0]); foreach (int Peer in PeerList) { if (Peer != Sender && Peer != Self.GetTree().GetNetworkUniqueId()) //Don't notify original client or server, both already know { Message.ServerUpdatePlayerPos(Peer, Sender, (Vector3)Args[0]); } } return; } case (MESSAGE.PLAYER_REQUEST_ROT): { Perform.RemotePlayerRotate(Events.INVOKER.SERVER, Sender, (float)Args[0]); foreach (int Peer in PeerList) { if (Peer != Sender && Peer != Self.GetTree().GetNetworkUniqueId()) //Don't notify original client or server, both already know { Message.ServerUpdatePlayerRot(Peer, Sender, (float)Args[0]); } } return; } case (MESSAGE.PLACE_REQUEST): { Perform.Place(Events.INVOKER.SERVER, (int)Args[0], (Items.TYPE)Args[1], (Vector3)Args[2], (Vector3)Args[3]); return; } } } switch (RecievedMessage) { case (MESSAGE.PLAYER_UPDATE_POS): { Perform.RemotePlayerMove(Events.INVOKER.CLIENT, (int)Args[0], (Vector3)Args[1]); return; } case (MESSAGE.PLAYER_UPDATE_ROT): { Perform.RemotePlayerRotate(Events.INVOKER.CLIENT, (int)Args[0], (float)Args[1]); return; } case (MESSAGE.PEERLIST_UPDATE): { PeerList.Clear(); foreach (int Peer in (int[])(Args[0])) { PeerList.Add(Peer); } return; } default: { Console.Log("Invalid message '" + RecievedMessage.ToString() + "'"); return; } } }
internal void DoCmd(Perform cmd, bool intern) { if(intern) { if(_prOp.Count > 0 && (_pfPos >= _prOp.Count || _prOp[_pfPos].layer > cmd.layer)) { _tcQueue.Enqueue(cmd); // Published in next tick } else { TickStep1(cmd); TickStep2(cmd); } } else { _tcQueue.Enqueue(cmd); } }
private int EnquePerf(Perform cmd) { int i; for(i = 0; i < _prOp.Count; i++) { if(_prOp[i].EqualsGr(cmd)) { if(_prOp[i].EqualsEx(cmd)) { return i; } if(_prOp[i].art == Perform.Art.changed) { cmd.old_o = _prOp[i].old_o; } _prOp.RemoveAt(i); if(_pfPos >= i) { _pfPos--; } break; } } i = ~_prOp.BinarySearch(cmd); _prOp.Insert(i, cmd); return i; }
public void changed(SubRec sr, Perform p) { if(_owner == null) { return; } if(p.art == Perform.Art.remove) { _owner.Remove(p.prim); } else if(p.art == Perform.Art.changed || p.art==Perform.Art.subscribe) { if(p.src.vType == typeof(PiAlias)) { PiAlias al = p.src.As<PiAlias>(); if(p.src == _ipTopic) { input.DelCont(this); input = al.origin; al.AddLink(this); input.AddCont(this); } else if(p.src == _opTopic) { if(al.origin.ip) { throw new ArgumentException(string.Format("{0} already hat source", _opTopic.path)); } output.DelCont(this); output = al.origin; al.AddLink(this); output.AddCont(this); } else { return; } } else if(p.src != input.owner) { return; } if(input.layer!=0 || input.owner._value.Defined) { output.owner._value=input.owner._value; if(p.src==input.owner) { var c=Perform.Create(output.owner, Perform.Art.changed, this.owner); c.o=input.owner._value; PLC.instance.DoCmd(c, true); } } } }
internal void DoCmd(Perform cmd) { _tcQueue.Enqueue(cmd); }
private void children_changed(SubRec sb, Perform p) { if(_decl==null) { return; } if(p.art == Perform.Art.remove) { PiVar v; if(_pins.TryGetValue(p.src.name, out v)) { _pins.Remove(p.src.name); v.DelCont(this); } } else if(p.art != Perform.Art.unsubscribe) { PinDeclarer pd = AddPin(p.src); if(pd!=null && ((p.art == Perform.Art.changed && pd.ip) || p.art == Perform.Art.subscribe)) { _decl.Calc(this); } } }
internal void DoPlcCmd(Perform cmd) { if(cmd.vt==cmd.src._vt && object.Equals(cmd.src._o, cmd.o) && cmd.src._dt.l!=cmd.dt.l) { return; } int idx=_prOp.BinarySearch(cmd); if(idx<0) { idx=~idx; if(idx<=_pfPos) { cmd.art=Perform.Art.set; cmd.prim=sign; DoCmd(cmd); // Published in next tick return; } _prOp.Insert(idx, cmd); cmd.src._json=null; cmd.old_vt=cmd.src._vt; cmd.old_dt=cmd.src._dt; cmd.old_o=cmd.src._o; } else { if(idx>=_pfPos) { cmd.art=Perform.Art.set; cmd.prim=sign; DoCmd(cmd); // Published in next tick return; } var oCmd=_prOp[idx]; if(oCmd.art==Perform.Art.changed) { cmd.old_vt=oCmd.old_vt; cmd.old_dt=oCmd.old_dt; cmd.old_o=oCmd.old_o; } else { cmd.src._json=null; cmd.old_vt=cmd.src._vt; cmd.old_dt=cmd.src._dt; cmd.old_o=cmd.src._o; } _prOp[idx]=cmd; } cmd.src._vt=cmd.vt; cmd.src._dt=cmd.dt; cmd.src._o=cmd.o; }
public void changed(SubRec sb, Perform p) { }
private void MqChanged(Topic sender, Perform cmd) { if(sender==null || cmd.prim==_sign) { return; } _ch.Enqueue(sender); if(cmd.art!=Perform.Art.create && cmd.art!=Perform.Art.subscribe) { _work.Set(); } }