private void RotateMenu(object sender, RoutedEventArgs e) { //double rotate = props.rotate * Math.PI / 180.0; //rotate = (rotate + (Math.PI / 2)); //props.rotate = (rotate * 180.0 / Math.PI); props._rotate += 90; if (props._rotate > 360) { props._rotate -= 360; } props._myRotateTransform.Angle = props._rotate; props._myTransformGroup.Children[0] = props._myRotateTransform; RenderTransform = props._myTransformGroup; //try { dtBuffer buffer = this.props.bufferDb; List <dtBuffer> buffers = new List <dtBuffer>(); dynamic postApiBody = new JObject(); Point coorLader = Global_Object.CoorLaser(props._posision); postApiBody.x = Math.Round(coorLader.X, 1); postApiBody.y = Math.Round(coorLader.Y, 1); postApiBody.angle = Math.Round(props._rotate, 1); string jsonBufferData = JsonConvert.SerializeObject(postApiBody); buffer.bufferData = jsonBufferData; buffers.Add(buffer); if (buffers.Count == 0) { System.Windows.Forms.MessageBox.Show(String.Format(Global_Object.messageNoDataSave), Global_Object.messageTitileWarning, System.Windows.Forms.MessageBoxButtons.OK, System.Windows.Forms.MessageBoxIcon.Warning); return; } string jsonData = JsonConvert.SerializeObject(buffers); HttpWebRequest request = (HttpWebRequest)WebRequest.Create(Global_Object.url + "buffer/updateListBuffer"); request.Method = "POST"; request.ContentType = "application/json"; System.Text.UTF8Encoding encoding = new System.Text.UTF8Encoding(); Byte[] byteArray = encoding.GetBytes(jsonData); request.ContentLength = byteArray.Length; using (Stream dataStream = request.GetRequestStream()) { dataStream.Write(byteArray, 0, byteArray.Length); dataStream.Flush(); } HttpWebResponse response = request.GetResponse() as HttpWebResponse; using (Stream responseStream = response.GetResponseStream()) { StreamReader reader = new StreamReader(responseStream, Encoding.UTF8); int result = 0; int.TryParse(reader.ReadToEnd(), out result); if (result == 1) { //System.Windows.Forms.MessageBox.Show(String.Format(Global_Object.messageSaveSucced), Global_Object.messageTitileInformation, MessageBoxButtons.OK, MessageBoxIcon.Information); } else if (result == -2) { System.Windows.Forms.MessageBox.Show(String.Format(Global_Object.messageDuplicated, "Buffers Name"), Global_Object.messageTitileError, System.Windows.Forms.MessageBoxButtons.OK, System.Windows.Forms.MessageBoxIcon.Error); } else { System.Windows.Forms.MessageBox.Show(String.Format(Global_Object.messageSaveFail), Global_Object.messageTitileError, System.Windows.Forms.MessageBoxButtons.OK, System.Windows.Forms.MessageBoxIcon.Error); } } //UpdateTab4(true); } //catch { } }
private void Map_MouseMove(object sender, MouseEventArgs e) { //Get mouse props Point mousePos = e.GetPosition(map); var mouseWasDownOn = (e.Source as FrameworkElement); hoveringItemName = mouseWasDownOn.Name; //mainWindow.MouseCoor.Content = (mousePos.X- Global_Object.OriginPoint.X).ToString("0.0") + " " + (Global_Object.OriginPoint.Y - mousePos.Y ).ToString("0.0"); mainWindow.MouseCoor.Content = (Global_Object.CoorLaser(mousePos).X).ToString("0.00") + " " + (Global_Object.CoorLaser(mousePos).Y).ToString("0.00"); mainWindow.MouseCoor2.Content = ((mousePos).X).ToString("0.00") + " " + ((mousePos).Y).ToString("0.00"); //mainWindow.MouseCoor.Content = ((mousePos).X.ToString("0.0") + " " + (mousePos).Y.ToString("0.0")); //Console.WriteLine("============================================"); //Console.WriteLine("MousePos: (" + mousePos.X + "," + mousePos.Y + ")"); //Console.WriteLine("CoorLaser: (" + Global_Object.CoorLaser(mousePos).X.ToString("0.0") + "," + Global_Object.CoorLaser(mousePos).Y.ToString("0.0")+")"); //Console.WriteLine("CoorCanvas: ("+ Global_Object.CoorCanvas(Global_Object.CoorLaser(mousePos)).X.ToString("0.0") + "," + Global_Object.CoorCanvas(Global_Object.CoorLaser(mousePos)).Y.ToString("0.0") + ")"); //// // POINT OF VIEW // if ((mainWindow.drag)) { if (!map.IsMouseCaptured) { return; } Vector moveVector = startPoint - e.GetPosition(mainWindow.clipBorder); double xCoor = originalPoint.X - moveVector.X; double yCoor = originalPoint.Y - moveVector.Y; double MapWidthScaled = (map.Width * scaleTransform.ScaleX); double MapHeightScaled = (map.Height * scaleTransform.ScaleY); double ClipBorderWidth = (mainWindow.clipBorder.ActualWidth); double ClipBorderHeight = (mainWindow.clipBorder.ActualHeight); double xlim; double ylim; if (ClipBorderWidth < map.Width) { xlim = (map.Width * (scaleTransform.ScaleX - 1)) / 2; } else { xlim = Math.Abs((MapWidthScaled - ClipBorderWidth) / 2); } if (ClipBorderHeight < map.Height) { ylim = (map.Height * (scaleTransform.ScaleY - 1)) / 2; } else { ylim = Math.Abs((MapHeightScaled - ClipBorderHeight) / 2); } if (ClipBorderWidth > map.Width) { if ((xCoor >= (-xlim)) && (xCoor <= (xlim))) { translateTransform.X = xCoor; } } else { if (ClipBorderWidth < MapWidthScaled) { if ((xCoor <= (xlim)) && (xCoor >= -(MapWidthScaled - ClipBorderWidth - xlim))) { translateTransform.X = xCoor; } } else { if ((xCoor >= (xlim)) && (xCoor <= -(MapWidthScaled - ClipBorderWidth - xlim))) { translateTransform.X = xCoor; } } } if (ClipBorderHeight > map.Height) { if ((yCoor >= (-ylim)) && (yCoor <= (ylim))) { translateTransform.Y = yCoor; } } else { if (ClipBorderHeight < MapHeightScaled) { if ((yCoor <= (ylim)) && (yCoor >= -(MapHeightScaled - ClipBorderHeight - ylim))) { translateTransform.Y = yCoor; } } else { if ((yCoor >= (ylim)) && (yCoor <= -(MapHeightScaled - ClipBorderHeight - ylim))) { translateTransform.Y = yCoor; } } } } if (!mainWindow.drag) { Statectrl_MouseMove(e); } }