public GServerList(Server[] servers, int x, int y, int width, int height, int gumpID, IFont font, IHue hue, int selectionBorderColor, int selectionFillColor, int selectionFillAlpha) : base(gumpID, width, height, x, y, true) { this.m_xLast = -2147483648; this.m_yLast = -2147483648; int offsetX = base.OffsetX; int offsetY = base.OffsetY; int useWidth = base.UseWidth; this.m_Entries = new GServerEntry[servers.Length]; for (int i = 0; i < servers.Length; i++) { this.m_Entries[i] = new GServerEntry(servers[i], font, hue, offsetX, offsetY, useWidth, selectionBorderColor, selectionFillColor, ((float) selectionFillAlpha) / 255f); offsetY += this.m_Entries[i].Height - 1; base.m_Children.Add(this.m_Entries[i]); } offsetY++; offsetY -= base.OffsetY; if (offsetY > (base.UseHeight - 2)) { base.m_Children.Add(new GImage(0x101, this.Width - 6, 4)); base.m_Children.Add(new GImage(0xff, this.Width - 6, this.Height - 0x25)); for (int j = 0x22; (j + 0x20) < (this.Height - 5); j += 30) { base.m_Children.Add(new GImage(0x100, this.Width - 6, j)); } base.m_NonRestrictivePicking = true; this.m_Slider = new GVSlider(0xfe, this.Width - 5, 0x11, 13, 0xec, 0.0, 0.0, (double) (offsetY - (base.UseHeight - 2)), 1.0); this.m_Slider.OnValueChange = new OnValueChange(this.OnScroll); this.m_Slider.ScrollOffset = 20.0; base.m_Children.Add(this.m_Slider); base.m_Children.Add(new GHotspot(this.Width - 6, 4, 15, this.Height - 9, this.m_Slider)); } }
public GServerEntry(Server server, IFont font, IHue hue, int x, int y, int width, int selectedBorderColor, int selectedFillColor, float selectedFillAlpha) : base(x, y) { this.m_yBase = y; this.m_SelectedBorderColor = selectedBorderColor; this.m_SelectedFillColor = selectedFillColor; this.m_SelectedFillAlpha = selectedFillAlpha; this.m_Server = server; this.m_Name = new GLabel(server.Name, font, hue, 4, 4); this.m_Name.X -= this.m_Name.Image.xMin; base.m_Children.Add(this.m_Name); this.m_PercentFull = new GLabel(string.Format("{0}% full", server.PercentFull), font, hue, width - 5, 4); this.m_PercentFull.X -= this.m_PercentFull.Image.xMax; base.m_Children.Add(this.m_PercentFull); int num = (this.m_Name.Image.yMax - this.m_Name.Image.yMin) + 1; this.m_Height = num; num = (this.m_PercentFull.Image.yMax - this.m_PercentFull.Image.yMin) + 1; if (num > this.m_Height) { this.m_Height = num; } this.m_Height += 8; this.m_Name.Y = ((this.m_Height - ((this.m_Name.Image.yMax - this.m_Name.Image.yMin) + 1)) / 2) - this.m_Name.Image.yMin; this.m_PercentFull.Y = ((this.m_Height - ((this.m_PercentFull.Image.yMax - this.m_PercentFull.Image.yMin) + 1)) / 2) - this.m_PercentFull.Image.yMin; this.m_Width = width; }
public void ServerCreate() { Configure(); server = new Server { Properties = new ServerProperties { Name = ".Net V2 - Test " + DateTime.Now.ToShortTimeString(), Cores = 1, Ram = 256 } }; server = serverApi.Create(datacenter.Id, server); Assert.IsNotNull(server); }
public void serverConnect(Server s, Boolean isRightServer) { if (isRightServer) { RightServer = s; RightServer.Win = Win; RightServer.Side = 1; Win.setConnectionHandler(RightServer); RightServer.Connect(); } else { LeftServer = s; LeftServer.Win = Win; LeftServer.Side = 0; Win.setConnectionHandler(LeftServer); LeftServer.Connect(); } }
public int MouseHookProc(int nCode, IntPtr wParam, IntPtr lParam) { //Marshall the data from the callback. MouseHookStruct MyMouseHookStruct = (MouseHookStruct)Marshal.PtrToStructure(lParam, typeof(MouseHookStruct)); int msg = wParam.ToInt32(); double width = System.Windows.SystemParameters.PrimaryScreenWidth; double height = System.Windows.SystemParameters.PrimaryScreenHeight; MouseStruct mystruct = new MouseStruct(); mystruct.me = msg; mystruct.mhs = MyMouseHookStruct; int y = (int)((mystruct.mhs.pt.y / height) * 65535); short mouseD = (short)(mystruct.mhs.mouseData >> 16); mystruct.mhs.mouseData = mouseD; if (nCode < 0) { return CallNextHookEx(hHook, nCode, wParam, lParam); } else { if ((mystruct.mhs.pt.x >= width || mystruct.mhs.pt.x <= 0) && !isCapturing && ((RightServer != null && RightServer.Status == 1) || (LeftServer != null && LeftServer.Status == 1))) { if (mystruct.mhs.pt.x >= width && RightServer != null && RightServer.Status == 1 && !isCapturing) { Console.WriteLine("RightServer"); isCapturing = true; currentServer = RightServer; mouse_event(0x0001 | 0x8000, (uint)((8 / width) * 65535), (uint)y, 0, UIntPtr.Zero); currentServer.SendLocalClipboard(); Win.Capturing(); return 1; } else if (mystruct.mhs.pt.x <= 0 && LeftServer != null && LeftServer.Status == 1 && !isCapturing) { Console.WriteLine("LeftServer"); isCapturing = true; currentServer = LeftServer; mouse_event(1 | 0x8000, 65520, (uint)y, 0, UIntPtr.Zero); currentServer.SendLocalClipboard(); Win.Capturing(); return 1; } } if (mystruct.mhs.pt.x <= 0 && isCapturing && currentServer == RightServer) { isCapturing = false; currentServer.GetRemoteClipboard(); mouse_event(1 | 0x8000, (uint)(((width - 4) / width) * 65535), (uint)y, 0, UIntPtr.Zero); Win.stopCapturing(); return 1; } else if (mystruct.mhs.pt.x >= width && isCapturing && currentServer == LeftServer) { isCapturing = false; currentServer.GetRemoteClipboard(); mouse_event(1 | 0x8000, (uint)((10 / width) * 65535), (uint)y, 0, UIntPtr.Zero); Win.stopCapturing(); return 1; } if (isCapturing && currentServer != null && currentServer.Status == 1) { try { mystruct.mhs.pt.x = (int)((mystruct.mhs.pt.x / width) * 65535); mystruct.mhs.pt.y = (int)((mystruct.mhs.pt.y / height) * 65535); Mouse.OverrideCursor = System.Windows.Input.Cursors.None; UdpClient uc = currentServer.getUdpClient(); String strCaption = "x = " + MyMouseHookStruct.pt.x.ToString("d") + " y = " + MyMouseHookStruct.pt.y.ToString("d"); Int32 im = 0; byte[] mouse = BitConverter.GetBytes(im); byte[] bytestream = getBytes(mystruct); Console.WriteLine("Transmitting....."); byte[] sending = new byte[bytestream.Length + sizeof(Int32)]; mouse.CopyTo(sending, 0); bytestream.CopyTo(sending, sizeof(Int32)); uc.Send(sending, sending.Length); //You must get the active form because it is a static function. Console.WriteLine(strCaption + " event" + msg); if (wParam != (IntPtr)WM_MOUSEMOVE) return 1; } catch (Exception e) { Console.WriteLine(e.Message); isCapturing = false; Win.connectionProblem(currentServer); } } return CallNextHookEx(hHook, nCode, wParam, lParam); } }
public void addListnewItem(String nickName, String ipAddress, Int32 port, string user, string pass, Boolean Connection) { Server s = new Server(ipAddress, port, nickName, user, pass); items.Add(s); pcRemote.ItemsSource = items; }
public void setConnectionHandler(Server s) { s.PropertyChanged += ConnectionHandler; }
public void connectionProblem(Server s) { if (s.Status != 0) { s.Disconnect(false); stopCapturing(); Dispatcher.Invoke(new Action(() => { if (s != null && s.Side == 0) { System.Windows.Forms.MessageBox.Show("C'è un problema di connessione con il LeftServer", "Errore", System.Windows.Forms.MessageBoxButtons.OK, System.Windows.Forms.MessageBoxIcon.Warning); } else if (s != null && s.Side == 1) { System.Windows.Forms.MessageBox.Show("C'è un problema di connessione con il RightServer", "Errore", System.Windows.Forms.MessageBoxButtons.OK, System.Windows.Forms.MessageBoxIcon.Warning); } })); } }
private void Configure() { Configuration = new Configuration { Username = "******", Password = "******", }; dcApi = new DataCenterApi(configuration); serverApi = new ServerApi(configuration); nicApi = new NetworkInterfacesApi(configuration); lbApi = new LoadBalancerApi(configuration); fwApi = new FirewallRuleApi(configuration); //Create a datacenter. if (datacenter == null) { datacenter = new Datacenter { Properties = new DatacenterProperties { Name = ".Net V2 - Test " + DateTime.Now.ToShortTimeString(), Description = "Unit test for .Net SDK PB REST V2", Location = "us/lasdev" } }; datacenter = dcApi.Create(datacenter); } if (server == null) { server = new Server { Properties = new ServerProperties { Name = ".Net V2 - Test " + DateTime.Now.ToShortTimeString(), Cores = 1, Ram = 256 } }; server = serverApi.Create(datacenter.Id, server); DoWait(server.Request); } if (nic == null) { nic = new Nic { Properties = new NicProperties { Lan = 1 } }; nic = nicApi.Create(datacenter.Id, server.Id, nic); DoWait(nic.Request); } bool isBusy = true; while (isBusy == true) { var temp = dcApi.FindById(datacenter.Id); if (temp.Metadata.State != "BUSY") isBusy = false; Thread.Sleep(5000); } }
/// <summary> /// Create a Server Creates a server within an existing datacenter. You can configure the boot volume and connect the server to an existing LAN. /// </summary> /// <param name="datacenterId"></param> /// <param name="server">Server to be created</param> /// <param name="parameter">Controls whether response is pretty-printed (with indentation and new lines)</param> /// <param name="depth">Controls the details depth of response objects. \nEg. GET /datacenters/[ID]\n - depth=0: only direct properties are included. Children (servers etc.) are not included\n - depth=1: direct properties and children references are included\n - depth=2: direct properties and children properties are included\n - depth=3: direct properties and children properties and children's children are included\n - depth=... and so on</param> /// <returns>Task of ApiResponse (Server)</returns> public async System.Threading.Tasks.Task<ApiResponse<Server>> CreateAsyncWithHttpInfo(string datacenterId, Server server, bool? parameter = null, int? depth = null) { // verify the required parameter 'datacenterId' is set if (datacenterId == null) throw new ApiException(400, "Missing required parameter 'datacenterId' when calling Create"); // verify the required parameter 'server' is set if (server == null) throw new ApiException(400, "Missing required parameter 'server' when calling Create"); var path_ = "/datacenters/{datacenterId}/servers"; var pathParams = new Dictionary<String, String>(); var queryParams = new Dictionary<String, String>(); var headerParams = new Dictionary<String, String>(); var formParams = new Dictionary<String, String>(); var fileParams = new Dictionary<String, FileParameter>(); Object postBody = null; // to determine the Content-Type header String[] httpContentTypes = new String[] { "application/json", "application/vnd.profitbricks.resource+json" }; String httpContentType = Configuration.ApiClient.SelectHeaderContentType(httpContentTypes); // to determine the Accept header String[] httpHeaderAccepts = new String[] { "application/vnd.profitbricks.resource+json" }; String httpHeaderAccept = Configuration.ApiClient.SelectHeaderAccept(httpHeaderAccepts); if (httpHeaderAccept != null) headerParams.Add("Accept", httpHeaderAccept); // set "format" to json by default // e.g. /pet/{petId}.{format} becomes /pet/{petId}.json pathParams.Add("format", "json"); if (datacenterId != null) pathParams.Add("datacenterId", Configuration.ApiClient.ParameterToString(datacenterId)); // path parameter if (parameter != null) queryParams.Add("parameter", Configuration.ApiClient.ParameterToString(parameter)); // query parameter if (depth != null) queryParams.Add("depth", Configuration.ApiClient.ParameterToString(depth)); // query parameter postBody = Configuration.ApiClient.Serialize(server); // http body (model) parameter // authentication (basicAuth) required // http basic authentication required if (!String.IsNullOrEmpty(Configuration.Username) || !String.IsNullOrEmpty(Configuration.Password)) { headerParams["Authorization"] = "Basic " + ApiClient.Base64Encode(Configuration.Username + ":" + Configuration.Password); } // make the HTTP request IRestResponse response = (IRestResponse)await Configuration.ApiClient.CallApiAsync(path_, Method.POST, queryParams, postBody, headerParams, formParams, fileParams, pathParams, httpContentType); int statusCode = (int)response.StatusCode; if (statusCode >= 400) throw new ApiException(statusCode, "Error calling Create: " + response.Content, response.Content); else if (statusCode == 0) throw new ApiException(statusCode, "Error calling Create: " + response.ErrorMessage, response.ErrorMessage); return new ApiResponse<Server>(statusCode, response.Headers.ToDictionary(x => x.Name, x => x.Value.ToString()), (Server)Configuration.ApiClient.Deserialize(response, typeof(Server))); }
/// <summary> /// Create a Server Creates a server within an existing datacenter. You can configure the boot volume and connect the server to an existing LAN. /// </summary> /// <param name="datacenterId"></param> /// <param name="server">Server to be created</param> /// <param name="parameter">Controls whether response is pretty-printed (with indentation and new lines)</param> /// <param name="depth">Controls the details depth of response objects. \nEg. GET /datacenters/[ID]\n - depth=0: only direct properties are included. Children (servers etc.) are not included\n - depth=1: direct properties and children references are included\n - depth=2: direct properties and children properties are included\n - depth=3: direct properties and children properties and children's children are included\n - depth=... and so on</param> /// <returns>Task of Server</returns> public async System.Threading.Tasks.Task<Server> CreateAsync(string datacenterId, Server server, bool? parameter = null, int? depth = null) { ApiResponse<Server> response = await CreateAsyncWithHttpInfo(datacenterId, server, parameter, depth); return response.Data; }
/// <summary> /// Create a Server Creates a server within an existing datacenter. You can configure the boot volume and connect the server to an existing LAN. /// </summary> /// <param name="datacenterId"></param> /// <param name="server">Server to be created</param> /// <param name="parameter">Controls whether response is pretty-printed (with indentation and new lines)</param> /// <param name="depth">Controls the details depth of response objects. \nEg. GET /datacenters/[ID]\n - depth=0: only direct properties are included. Children (servers etc.) are not included\n - depth=1: direct properties and children references are included\n - depth=2: direct properties and children properties are included\n - depth=3: direct properties and children properties and children's children are included\n - depth=... and so on</param> /// <returns>Server</returns> public Server Create(string datacenterId, Server server, bool? parameter = null, int? depth = null) { ApiResponse<Server> response = CreateWithHttpInfo(datacenterId, server, parameter, depth); response.Data.Request = response.Headers["Location"]; return response.Data; }
/// <summary> /// Modify a Server You can use update attributes of a server /// </summary> /// <param name="datacenterId"></param> /// <param name="serverId">The unique ID of the server</param> /// <param name="server">Modified Server</param> /// <param name="parameter">Controls whether response is pretty-printed (with indentation and new lines)</param> /// <param name="depth">Controls the details depth of response objects. \nEg. GET /datacenters/[ID]\n - depth=0: only direct properties are included. Children (servers etc.) are not included\n - depth=1: direct properties and children references are included\n - depth=2: direct properties and children properties are included\n - depth=3: direct properties and children properties and children's children are included\n - depth=... and so on</param> /// <returns>Server</returns> public Server Update(string datacenterId, string serverId, Server server, bool? parameter = null, int? depth = null) { ApiResponse<Server> response = UpdateWithHttpInfo(datacenterId, serverId, server, parameter, depth); return response.Data; }
private void Configure() { configuration = new Configuration { Username = "******", Password = "******", }; dcApi = new DataCenterApi(configuration); serverApi = new ServerApi(configuration); volumeApi = new VolumeApi(configuration); attachedVolumesApi = new AttachedVolumesApi(configuration); //Create a datacenter. if (datacenter == null) { datacenter = new Datacenter { Properties = new DatacenterProperties { Name = ".Net V2 - Test " + DateTime.Now.ToShortTimeString(), Description = "Unit test for .Net SDK PB REST V2", Location = "us/lasdev" } }; datacenter = dcApi.Create(datacenter); } if (server == null) { server = new Server { Properties = new ServerProperties { Name = ".Net V2 - Test " + DateTime.Now.ToShortTimeString(), Cores = 1, Ram = 1024 } }; server = serverApi.Create(datacenter.Id, server); DoWait(server.Request); } }
public PServerSelection(Server server) : base(160, string.Format("Server Selection ({0})", server.Name), 3) { base.m_Stream.Write((short) server.ServerID); }
private static void ServerList(PacketReader pvSrc) { pvSrc.ReadByte(); int num = pvSrc.ReadInt16(); if (num <= 0) { Gumps.Desktop.Children.Clear(); xGumps.SetVariable("FailMessage", "The Ultima Online servers are currently down. Please try again in a few moments."); xGumps.Display("ConnectionFailed"); Cursor.Hourglass = false; } else { Server[] array = new Server[num]; Server server = null; for (int i = 0; i < num; i++) { array[i] = new Server(pvSrc.ReadInt16(), pvSrc.ReadString(0x20), pvSrc.ReadByte(), pvSrc.ReadSByte(), new IPAddress((long) pvSrc.ReadUInt32())); if (array[i].ServerID == NewConfig.LastServerID) { server = array[i]; } } Array.Sort(array); Engine.Servers = array; Engine.LastServer = server; if (Engine.m_QuickLogin) { for (int j = 0; j < array.Length; j++) { if ((array[j].ServerID == Engine.m_QuickEntry.ServerID) && (array[j].Name == Engine.m_QuickEntry.ServerName)) { array[j].Select(); Cursor.Hourglass = true; Gumps.Desktop.Children.Clear(); xGumps.Display("Connecting"); Engine.DrawNow(); return; } } Cursor.Hourglass = false; Gumps.Desktop.Children.Clear(); xGumps.SetVariable("FailMessage", "That server was not found on the server list."); xGumps.Display("ConnectionFailed"); Engine.DrawNow(); } else { Cursor.Hourglass = false; Gumps.Desktop.Children.Clear(); xGumps.Display("ServerList"); } } }
static void Main(string[] args) { var configuration = new Configuration { Username = "******", Password = "******", }; var dcApi = new DataCenterApi(configuration); var serverApi = new ServerApi(configuration); var volumeApi = new VolumeApi(configuration); var attachedVolumesApi = new AttachedVolumesApi(configuration); var nicApi = new NetworkInterfacesApi(configuration); // CreateDataCenterRequest. // The only required field is DataCenterName. // If location parameter is left empty data center will be created in the default region of the customer var datacenter = new Datacenter { Properties = new DatacenterProperties { Name = ".Net V2 - Test " + DateTime.Now.ToShortTimeString(), Description = "Unit test for .Net SDK PB REST V2", Location = "us/lasdev" } }; // Response will contain Id of a newly created data center. datacenter = dcApi.Create(datacenter); // CreateServer. // DataCenterId: Defines the data center wherein the server is to be created. // AvailabilityZone: Selects the zone in which the server is going to be created (AUTO, ZONE_1, ZONE_2). // Cores: Number of cores to be assigned to the specified server. Required field. // InternetAccess: Set to TRUE to connect the server to the Internet via the specified LAN ID. // OsType: Sets the OS type of the server. // Ram: Number of RAM memory (in MiB) to be assigned to the server. var server = new Server { Properties = new ServerProperties { Name = ".Net V2 - Test " + DateTime.Now.ToShortTimeString(), Cores = 1, Ram = 256 } }; // response will contain Id of a newly created server. server = serverApi.Create(datacenter.Id, server); // UpdateServer // ServerId: Id of the server to be updated. // ServerName: Renames target virtual server // Cores: Updates the amount of cores of the target virtual server // Ram: Updates the RAM memory (in MiB) of the target virtual server. The minimum RAM size is 256 MiB server = serverApi.PartialUpdate(datacenter.Id, server.Id, new ServerProperties { Name = server.Properties.Name + " -Updated" }); // CreateVolume // DataCenterId: Defines the data center wherein the storage is to be created. If left empty, the storage will be created in a new data center // Size: Storage size (in GiB). Required Field. // Type: SSD or HDD disk type, Required Field var volume = new Volume { Properties = new VolumeProperties { Size = 4, Image = "fbaae2b2-c899-11e5-aa10-52540005ab80", Type = "HDD", Name = ".Net V2 - Test " + DateTime.Now.ToShortTimeString(), SshKeys = new System.Collections.Generic.List<string> { "hQGOEJeFL91EG3+l9TtRbWNjzhDVHeLuL3NWee6bekA=" } } }; // Response will contain Id of a newly created volume. volume = volumeApi.Create(datacenter.Id, volume); // AttachVolume // ServerId: Identifier of the target virtual storage. Required field. // StorageId: Identifier of the virtual storage to be connected. Required field. // BusType: Bus type to which the storage will be connected attachedVolumesApi.AttachVolume(datacenter.Id, server.Id, new Volume { Id = volume.Id }); attachedVolumesApi.DetachVolume(datacenter.Id, server.Id, volume.Id); // Fetches list of all Data Centers var dcs = dcApi.FindAll(depth: 5); // Fetches list of all Servers var servers = serverApi.FindAll(datacenter.Id, depth: 5); // Fetches list of all Volumes var volumes = volumeApi.FindAll(datacenter.Id, depth: 5); // CreateNicRequest // Identifier of the target virtual server. Required field. // Nic: Names the NIC // Toggles usage of ProfitBricks DHCP // Lan var nic = new Nic { Properties = new NicProperties { Lan = 1 , Dhcp = true, Name = "Nic name"} }; nic = nicApi.Create(datacenter.Id, server.Id, nic); }
private void Configure() { configuration = new Configuration { Username = "******", Password = "******", }; dcApi = new DataCenterApi(configuration); serverApi = new ServerApi(configuration); nicApi = new NetworkInterfacesApi(configuration); lbApi = new LoadBalancerApi(configuration); //Create a datacenter. if (datacenter == null) { datacenter = new Datacenter { Properties = new DatacenterProperties { Name = ".Net V2 - Test " + DateTime.Now.ToShortTimeString(), Description = "Unit test for .Net SDK PB REST V2", Location = "us/lasdev" } }; datacenter = dcApi.Create(datacenter); } if(server == null) { server = new Server { Properties = new ServerProperties { Name = ".Net V2 - Test " + DateTime.Now.ToShortTimeString(), Cores = 1, Ram = 256 } }; server = serverApi.Create(datacenter.Id, server); DoWait(server.Request); } if (lb == null) { lb = new Loadbalancer { Properties = new LoadbalancerProperties { Name = ".Net V2 - Test " + DateTime.Now.ToShortTimeString() } }; lb = lbApi.Create(datacenter.Id, lb); DoWait(lb.Request); } }