private void Initialize() { UpdateButtonStatus(stopButton, false); UpdateButtonStatus(razorButton, false); UpdateButtonStatus(addButton, false); Closing += new CancelEventHandler(MainWindow_Closing); TreeViewUpdater.Initialize(clientTreeView); OptionsWindow.OptionsChangedEvent += new OptionsWindow.dOptionsChanged(OptionsWindow_OptionsChangedEvent); OptionsWindow.OptionsCancelledEvent += new OptionsWindow.dOptionsCancelled(OptionsWindow_OptionsCancelledEvent); ScriptCompiler.ScriptFinishedEvent += new ScriptCompiler.dScriptFinished(ScriptCompiler_ScriptFinished); aboutWindow = new About(); optionsWindow = new OptionsWindow(); myCurrentOptions = OptionsData.Deserialize("options.xml"); CheckOptions(myCurrentOptions); if (!UOM.Initialize(this)) { MessageBox.Show(Strings.Errorinitializing, Strings.Error); UOM.Dispose(); UOM.ShutDown(); return; } PrepareTextEditor(); UpdateButtonStatus(addButton, true); }
private static void OutgoingPackets_TargetSentEvent(int client, int targetType, bool checkCrime, int serial, int x, int y, int z, int ID, byte[] packet) { ClientInfo ci; if (ClientInfoCollection.GetClient(client, out ci)) { ci.LastTarget = serial; ci.LastTargetPacket = packet; TreeViewUpdater.UpdateLastTarget(ci.ProcessID, targetType, checkCrime, serial, x, y, z, ID); } }
public void Dispose() { myThreadRunning = false; Network.RemoveServer(IPCServerIndex); TreeViewUpdater.RemoveParent(this.ProcessID); try { if (myCleanupThread != null) { myCleanupThread.Abort(); } } catch { } }
private static void OutgoingPackets_UseItemRequestedEvent(int client, int serial) { ClientInfo ci; if (!ClientInfoCollection.GetClient(client, out ci)) { return; } if ((serial & ~0x7FFFFFFF) != 0) { serial ^= ~0x7FFFFFFF; if (ci.Player.Serial == serial) { TreeViewUpdater.UpdateLastObject(ci.ProcessID, (WorldItem)ci.Player); return; } } if (UOMath.IsMobile(serial)) { Mobile m; if (ClientInfoCollection.GetMobile(client, serial, out m)) { TreeViewUpdater.UpdateLastObject(ci.ProcessID, (WorldItem)m); } else { Mobile newMobile = new Mobile(serial, client); newMobile.myName = "This mobile not found!"; TreeViewUpdater.UpdateLastObject(ci.ProcessID, (WorldItem)newMobile); } } else { Item i; if (ClientInfoCollection.GetItem(client, serial, out i)) { TreeViewUpdater.UpdateLastObject(ci.ProcessID, (WorldItem)i); } else { Item newItem = new Item(serial); newItem.Name = "This item not found!"; TreeViewUpdater.UpdateLastObject(ci.ProcessID, (WorldItem)newItem); } } }
private void Initialize() { myDropShadow = new DropShadowEffect(); myDropShadow.ShadowDepth = 0; myDropShadow.BlurRadius = 8; myDropShadow.Color = Colors.Black; myStartButtonWidth = startButton.Width; myStopButtonWidth = stopButton.Width; myAddButtonWidth = addButton.Width; myRazorButtonWidth = razorButton.Width; myStartButtonMargin = startButton.Margin; myStopButtonMargin = stopButton.Margin; myAddButtonMargin = addButton.Margin; myRazorButtonMargin = razorButton.Margin; mySteamButtonWidth = steamButton.Width; mySteamButtonMargin = steamButton.Margin; stopButton.IsEnabled = false; razorButton.IsEnabled = false; addButton.IsEnabled = false; stopButton.Opacity = myDisabledOpacity; Closing += new CancelEventHandler(MainWindow_Closing); TreeViewUpdater.Initialize(clientTreeView); OptionsWindow.OptionsChangedEvent += new OptionsWindow.dOptionsChanged(OptionsWindow_OptionsChangedEvent); OptionsWindow.OptionsCancelledEvent += new OptionsWindow.dOptionsCancelled(OptionsWindow_OptionsCancelledEvent); ScriptCompiler.ScriptFinishedEvent += new ScriptCompiler.dScriptFinished(ScriptCompiler_ScriptFinished); aboutWindow = new About(); optionsWindow = new OptionsWindow(); myCurrentOptions = OptionsData.Deserialize("options.xml"); CheckOptions(myCurrentOptions); if (!UOM.Initialize(this)) { MessageBox.Show("Error initializing UO Machine, please try again.", "Error"); UOM.Dispose(); UOM.ShutDown(); return; } PrepareTextEditor(); razorButton.IsEnabled = true; addButton.IsEnabled = true; }
public static bool AddClient(ClientInfo clientInfo, out int instance) { if (Count >= ClientList.Length) { throw new ApplicationException("Maximum number of simultaneous clients exceeded."); } for (int x = 0; x < ClientList.Length; x++) { ClientInfo ci = ThreadHelper.VolatileRead <ClientInfo>(ref ClientList[x]); if (ci == null) { Interlocked.Exchange <ClientInfo>(ref ClientList[x], clientInfo); TreeViewUpdater.AddPlaceHolder(x, clientInfo.ProcessID); Count++; instance = x; return(true); } } instance = -1; return(false); }
public static void UpdateProperties(int index, int serial, string name, Property[] properties, string propertyText) { ClientInfo ci; if (GetClient(index, out ci)) { if (UOMath.IsMobile(serial)) { if (ci.Player.Serial == serial) { ci.Player.Name = name; ci.Player.Properties = properties; ci.Player.PropertyText = propertyText; TreeViewUpdater.EditPlayerNode(index, ClientList[index].Player); } else { Mobile m; if (ci.Mobiles.GetMobile(serial, out m)) { m.Name = name; m.Properties = properties; m.PropertyText = propertyText; } } } else { Item i; if (ci.Items.GetItem(serial, out i)) { i.Name = Cliloc.GetLocalString(name); i.Properties = properties; i.PropertyText = propertyText; } } } }
private static void IncomingPackets_PlayerInitializedEvent(int client, PlayerMobile player) { ClientInfo ci; if (ClientInfoCollection.GetClient(client, out ci)) { if (ci.Player == null) { ci.Player = player; } else { ci.Player.ID = player.ID; ci.Player.Serial = player.Serial; ci.Player.X = player.X; ci.Player.Y = player.Y; ci.Player.Z = player.Z; ci.Player.Direction = player.Direction; ci.Player.Client = client; } TreeViewUpdater.EditPlayerNode(client, ci.Player); } }
private void myCustomGumps_CollectionChangedEvent(int newCount) { TreeViewUpdater.EditNodeHeader(this.ProcessID, 3, 2, "Custom gumps = " + (newCount)); }
private void Mobiles_CollectionChanged(int newCount) { TreeViewUpdater.EditNodeHeader(this.ProcessID, 3, 1, "Tracked mobiles = " + (newCount + 1)); }
private void Items_CollectionChanged(int newCount) { TreeViewUpdater.EditNodeHeader(this.ProcessID, 3, 0, "Tracked items = " + newCount); }
private void Player_PropertyChanged(int headerNum, string header) { TreeViewUpdater.EditNodeHeader(this.ProcessID, 0, headerNum, header); }
public void OnGumpAction(int serial, int gumpID, int buttonID, int[] switches) { TreeViewUpdater.UpdateLastGumpAction(this.ProcessID, serial, gumpID, buttonID, switches); }
public void OnKeyDown(Keys key) { TreeViewUpdater.UpdateKeypress(this.ProcessID, key); }
public void OnMouseMove(int x, int y) { TreeViewUpdater.UpdateMouse(this.ProcessID, x, y); }
private static int TreeViewRec <VM, T> ( StringBuilder sb, StringBuilder sbInit, bool editMode, HtmlHelper <VM> htmlHelper, RenderInfo <IEnumerable <T> > renderInfo, Func <int, string> collectionName, ExternalContainerType itemContainer, string rootClass, object[] itemTemplates, Func <object, int, int> itemTemplateSelector, Func <int, string> itemClassSelector, Func <object, int, TreeViewItemStatus> itemStatus, float opacity, bool canMove, int level, int totalCount, string fatherName, string root_id) { string basicId = BasicHtmlHelper.IdFromName(fatherName); sbInit.Append(renderInfo.PartialRendering); IDictionary <string, object> htmlAttributesContainer = new Dictionary <string, object>(); string externalOpenTag = null; string externalCloseTag = null; string handleClass = basicId + "_handle"; htmlAttributesContainer["id"] = basicId + "_ItemsContainer"; if (level == 0) { htmlAttributesContainer["class"] = rootClass + " mvcct-items-container"; rootClass = null; } else { if (rootClass != null) { htmlAttributesContainer["class"] = rootClass + "_ mvcct-items-container"; } } BasicHtmlHelper.GetContainerTags(ExternalContainerType.ul, htmlAttributesContainer, out externalOpenTag, out externalCloseTag); sb.Append(externalOpenTag); IEnumerable list = renderInfo.Model as IEnumerable; if (list == null) { list = new List <T>(); } string javasctiptOpacity = string.Empty; int sonIndex = -1;; foreach (object o in list) { if (o == null) { continue; } totalCount++; sonIndex++; int templateIndex = itemTemplateSelector(o, level); object initialTemplate = itemTemplates[templateIndex]; string initCollection = collectionName(templateIndex); TreeViewItemStatus status = itemStatus(o, level); if (initCollection == null) { status = TreeViewItemStatus.Hide; } ITreeViewNodeContainer wrapper = null; IUpdateModel uWrapper = null; bool closed = isClosed(status, o, htmlHelper); Type type = TemplateInvoker <string> .ExtractModelType(initialTemplate); if (editMode) { wrapper = typeof(TreeViewUpdater <string>).GetGenericTypeDefinition() .MakeGenericType(new Type[] { type }) .GetConstructor(new Type[0]) .Invoke(new object[0]) as ITreeViewNodeContainer; uWrapper = wrapper as IUpdateModel; uWrapper.ImportFromModel(o, null, null, new object[] { closed }); } else { wrapper = new TreeViewUpdater <T>(false); uWrapper = wrapper as IUpdateModel; } string prefix = renderInfo.Prefix; string partialPrefix = renderInfo.PartialPrefix; if (editMode) { sbInit.Append( BasicHtmlHelper.RenderUpdateInfoI(htmlHelper, uWrapper, ref partialPrefix, new string[0])); } else { BasicHtmlHelper.RenderUpdateInfoI(htmlHelper, uWrapper, ref partialPrefix, new string[0], noOutput: true); } prefix = htmlHelper.ViewData.TemplateInfo.GetFullHtmlFieldName(partialPrefix); if (level == 0) { wrapper.FatherOriginalId = null; } else { wrapper.FatherOriginalId = fatherName; } wrapper.OriginalId = prefix; wrapper.PositionAsSon = sonIndex; wrapper.SonNumber = 0; wrapper.SonCollectionName = null; string itemOpenTag = null; string itemCloseTag = null; string innerItemOpenTag = null; string innerItemCloseTag = null; htmlAttributesContainer["id"] = BasicHtmlHelper.IdFromName(BasicHtmlHelper.AddField(prefix, "Container")); htmlAttributesContainer["class"] = closed ? "closed" : "open"; BasicHtmlHelper.GetContainerTags(ExternalContainerType.li, htmlAttributesContainer, out itemOpenTag, out itemCloseTag); htmlAttributesContainer["id"] = BasicHtmlHelper.IdFromName(BasicHtmlHelper.AddField(prefix, "$.Item_SubContainer")); htmlAttributesContainer["class"] = handleClass; BasicHtmlHelper.GetContainerTags(itemContainer, htmlAttributesContainer, out innerItemOpenTag, out innerItemCloseTag); bool hasCollection = true; string name = initCollection; PropertyInfo property = null; if (name == null) { hasCollection = false; } else { property = o.GetType().GetProperty(name); hasCollection = typeof(IEnumerable).IsAssignableFrom(property.PropertyType); } sb.Append(itemOpenTag); if (canMove && hasCollection) { sb.Append(string.Format("<input type='checkbox' class ='level-select_{0} level-select' />", root_id)); } sb.Append(innerItemOpenTag); sb.Append( (typeof(TemplateInvoker <string>) .GetGenericTypeDefinition() .MakeGenericType(new Type[] { type }) .GetConstructor(new Type[] { typeof(object) }) .Invoke(new object[] { initialTemplate }) as ITemplateInvoker) .Invoke(htmlHelper, o, BasicHtmlHelper.AddField(prefix, "$.Item"))); sb.Append(innerItemCloseTag); if (hasCollection) { string currItemClass = itemClassSelector == null ? null : itemClassSelector(templateIndex); if (currItemClass != null) { currItemClass = currItemClass.Trim() + "_" + BasicHtmlHelper.IdFromName(renderInfo.Prefix); } ICollection innerItem = property.GetValue(o, new object[0]) as ICollection; Type listType = property.PropertyType.GetGenericArguments()[0]; Type allListType = typeof(IEnumerable <string>).GetGenericTypeDefinition().MakeGenericType(listType); if (innerItem == null) { innerItem = allListType.GetConstructor(new Type[0]).Invoke(new object[0]) as ICollection; } wrapper.SonNumber = innerItem.Count; wrapper.SonCollectionName = initCollection; if (editMode) { RenderWrapper <VM>(htmlHelper, partialPrefix, wrapper, sbInit); } totalCount = (int)typeof(TreeViewHelpers).GetMethod("TreeViewRec", BindingFlags.Static | BindingFlags.NonPublic). MakeGenericMethod(new Type[] { typeof(VM), listType }) .Invoke(null, new object[] { sb, sbInit, editMode, htmlHelper, typeof(RenderInfo <string>).GetGenericTypeDefinition().MakeGenericType(allListType) .GetConstructor(new Type[] { typeof(string), typeof(string), typeof(string), allListType }) .Invoke (new object[] { renderInfo.Prefix, renderInfo.PartialPrefix, string.Empty, innerItem }), collectionName, itemContainer, currItemClass, itemTemplates, itemTemplateSelector, itemClassSelector, itemStatus, opacity, canMove, level + 1, totalCount, prefix, root_id }); } else { if (editMode) { RenderWrapper <VM>(htmlHelper, partialPrefix, wrapper, sbInit); } } sb.Append(itemCloseTag); } if (canMove) { if (opacity > 1f) { opacity = 1f; } else if (opacity < 0.01f) { opacity = 0.01f; } if (opacity < 1f) { javasctiptOpacity = string.Format(" opacity: {0}, ", opacity.ToString(CultureInfo.InvariantCulture)); } string javascriptRootClass = string.Empty; if (rootClass != null) { javascriptRootClass = string.Format(" connectWith: '.{0}', ", rootClass); } if (level > 0) { sbInit.Append(string.Format(startScriptFormat, basicId, javasctiptOpacity, javascriptRootClass, root_id)); } } else { if (level > 0) { sbInit.Append(string.Format(startScriptNoMoveFormat, basicId, root_id)); } } sb.Append(externalCloseTag); return(totalCount); }
private void ShowClientList() { if (tcpServer == null) return; TreeViewUpdater updateTreeView = new TreeViewUpdater(UpdateTreeView); tvClientList.Invoke(updateTreeView, new object[] { tvClientList, tcpServer.ClientList }); }