bool BackToPixel(ref double x, ref double y) { if (cunit == 0) { return(true); } else if (cunit == 1) { x = SizeFormatWorker.CmToPx(x); y = SizeFormatWorker.CmToPx(y); return(true); } else if (cunit == 2) { x = SizeFormatWorker.InToPx(x); y = SizeFormatWorker.InToPx(y); return(true); } else if (cunit == 3) { x = SizeFormatWorker.PtToPx(x); y = SizeFormatWorker.PtToPx(y); return(true); } return(false); }
bool BackToPixel(ref double x, ref double y, ref double w, ref double h) { if (CUnit == 0) { return(true); } else if (CUnit == 1) { x = SizeFormatWorker.CmToPx(x); y = SizeFormatWorker.CmToPx(y); w = SizeFormatWorker.CmToPx(w); h = SizeFormatWorker.CmToPx(h); return(true); } else if (CUnit == 2) { x = SizeFormatWorker.InToPx(x); y = SizeFormatWorker.InToPx(y); w = SizeFormatWorker.InToPx(w); h = SizeFormatWorker.InToPx(h); return(true); } else if (CUnit == 3) { x = SizeFormatWorker.PtToPx(x); y = SizeFormatWorker.PtToPx(y); w = SizeFormatWorker.PtToPx(w); h = SizeFormatWorker.PtToPx(h); return(true); } return(false); }
bool BackToPixel(ref double x) { if (MainWindow.CUnit == 0) { return(true); } else if (MainWindow.CUnit == 1) { x = SizeFormatWorker.CmToPx(x); return(true); } else if (MainWindow.CUnit == 2) { x = SizeFormatWorker.InToPx(x); return(true); } else if (MainWindow.CUnit == 3) { x = SizeFormatWorker.PtToPx(x); return(true); } return(false); }
private void ComboBox_SizeUnits_SelectionChanged(object sender, SelectionChangedEventArgs e) { if (CanvasSizeX != null) { double sizex = 1280; double sizey = 720; bool set = true; if (double.TryParse(CanvasSizeX.Text, out sizex) == false) { set = false; } if (double.TryParse(CanvasSizeY.Text, out sizey) == false) { set = false; } if (set == false) { Debug.WriteLine("Wrong size of canvas input!"); CanvasSizeX.Text = "" + (WindowSize.Width - 2); CanvasSizeY.Text = "" + (WindowSize.Height - 2); } switch (ComboBox_SizeUnits.SelectedIndex) { case 0: BackToPixel(ref sizex, ref sizey); CanvasSizeX.Text = "" + sizex; CanvasSizeY.Text = "" + sizey; cunit = 0; Label_Unit1.Content = Strings.FormatStrings.pxO; Label_Unit2.Content = Strings.FormatStrings.pxO; break; case 1: BackToPixel(ref sizex, ref sizey); CanvasSizeX.Text = "" + SizeFormatWorker.PxToCm(sizex); CanvasSizeY.Text = "" + SizeFormatWorker.PxToCm(sizey); cunit = 1; Label_Unit1.Content = Strings.FormatStrings.cmO; Label_Unit2.Content = Strings.FormatStrings.cmO; break; case 2: BackToPixel(ref sizex, ref sizey); CanvasSizeX.Text = "" + SizeFormatWorker.PxToIn(sizex); CanvasSizeY.Text = "" + SizeFormatWorker.PxToIn(sizey); cunit = 2; Label_Unit1.Content = Strings.FormatStrings.inO; Label_Unit2.Content = Strings.FormatStrings.inO; break; case 3: BackToPixel(ref sizex, ref sizey); CanvasSizeX.Text = "" + SizeFormatWorker.PxToPt(sizex); CanvasSizeY.Text = "" + SizeFormatWorker.PxToPt(sizey); cunit = 3; Label_Unit1.Content = Strings.FormatStrings.ptO; Label_Unit2.Content = Strings.FormatStrings.ptO; break; } } }
private void ComboBox_SizeUnits_SelectionChanged(object sender, SelectionChangedEventArgs e) { if (IsInitialized) { double x = 0, w = 0; double y = 0, h = 0; bool set = true; if (double.TryParse(Box_X.Text, out x) == false) { set = false; } if (double.TryParse(Box_Y.Text, out y) == false) { set = false; } if (double.TryParse(Box_W.Text, out w) == false) { set = false; } if (double.TryParse(Box_H.Text, out h) == false) { set = false; } if (set == false) { Debug.WriteLine("Wrong inputs"); Box_X.Text = "0"; Box_Y.Text = "0"; Box_W.Text = "100"; Box_H.Text = "100"; } switch (ComboBox_SizeUnits.SelectedIndex) { case 0: BackToPixel(ref x, ref y, ref w, ref h); Box_X.Text = "" + x; Box_Y.Text = "" + y; Box_W.Text = "" + w; Box_H.Text = "" + h; MainWindow.CUnit = 0; CUnit = 0; R_Un1.Text = " (" + Strings.FormatStrings.pxO + ")"; R_Un2.Text = " (" + Strings.FormatStrings.pxO + ")"; R_Un3.Text = " (" + Strings.FormatStrings.pxO + ")"; R_Un4.Text = " (" + Strings.FormatStrings.pxO + ")"; break; case 1: BackToPixel(ref x, ref y, ref w, ref h); Box_X.Text = "" + SizeFormatWorker.PxToCm(x); Box_Y.Text = "" + SizeFormatWorker.PxToCm(y); Box_W.Text = "" + SizeFormatWorker.PxToCm(w); Box_H.Text = "" + SizeFormatWorker.PxToCm(h); MainWindow.CUnit = 1; CUnit = 1; R_Un1.Text = " (" + Strings.FormatStrings.cmO + ")"; R_Un2.Text = " (" + Strings.FormatStrings.cmO + ")"; R_Un3.Text = " (" + Strings.FormatStrings.cmO + ")"; R_Un4.Text = " (" + Strings.FormatStrings.cmO + ")"; break; case 2: BackToPixel(ref x, ref y, ref w, ref h); Box_X.Text = "" + SizeFormatWorker.PxToIn(x); Box_Y.Text = "" + SizeFormatWorker.PxToIn(y); Box_W.Text = "" + SizeFormatWorker.PxToIn(w); Box_H.Text = "" + SizeFormatWorker.PxToIn(h); MainWindow.CUnit = 2; CUnit = 2; R_Un1.Text = " (" + Strings.FormatStrings.inO + ")"; R_Un2.Text = " (" + Strings.FormatStrings.inO + ")"; R_Un3.Text = " (" + Strings.FormatStrings.inO + ")"; R_Un4.Text = " (" + Strings.FormatStrings.inO + ")"; break; case 3: BackToPixel(ref x, ref y, ref w, ref h); Box_X.Text = "" + SizeFormatWorker.PxToPt(x); Box_Y.Text = "" + SizeFormatWorker.PxToPt(y); Box_W.Text = "" + SizeFormatWorker.PxToPt(w); Box_H.Text = "" + SizeFormatWorker.PxToPt(h); MainWindow.CUnit = 3; CUnit = 3; R_Un1.Text = " (" + Strings.FormatStrings.ptO + ")"; R_Un2.Text = " (" + Strings.FormatStrings.ptO + ")"; R_Un3.Text = " (" + Strings.FormatStrings.ptO + ")"; R_Un4.Text = " (" + Strings.FormatStrings.ptO + ")"; break; } } }