/// <summary> /// 儲存程式編輯 /// </summary> /// <param name="macroName">程式編輯名稱</param> /// <param name="macroGuid">程式編輯 ID</param> /// <param name="shapeModelFilepath">程式編輯模型檔案路徑</param> /// <param name="note">程式編輯描述</param> /// <param name="trainingImage">程式編輯訓練影像二元檔</param> /// <param name="exportUnit">輸出單位</param> /// <param name="matchingParamData">模型參數二元檔</param> /// <param name="measureBinaryData">測量資料二元檔</param> /// <param name="measureAssistantParamData">測量參數二元檔</param> /// <param name="upperLight">上光源</param> /// <param name="bottomLight">下光源</param> /// <param name="findedShapeViewModel">Matching 模型資訊</param> /// <param name="loginUser">登入者</param> /// <param name="trainingImageFilepath">程式編輯訓練影像實體路徑</param> /// <param name="snapshot">程式編輯縮圖二元檔</param> /// <param name="objectXLength">物件大小 X</param> /// <param name="objectYLength">物件大小 Y</param> /// <param name="technicalDrawingModel">工程圖資訊</param> /// <returns></returns> public static bool SaveMacroPlan(string macroName, string macroGuid, string shapeModelFilepath, string note, Binary trainingImage , string exportUnit, Binary matchingParamData, Binary measureBinaryData, Binary measureAssistantParamData , LightChannel upperLight, LightChannel bottomLight , ShapeViewModel findedShapeViewModel, string loginUser , string trainingImageFilepath , Binary snapshot , double objectXLength, double objectYLength , XDocument technicalDrawingModel) { bool success = true; try { MacroPlan plan = _dc.MacroPlan.SingleOrDefault(p => p.MacroGuid == macroGuid); var isUpdate = (plan != null); if (!isUpdate) { plan = new MacroPlan() { CreateBy = loginUser, CreateOn = DateTime.Now, MacroGuid = macroGuid }; } plan.MacroName = macroName; plan.ShapeModelFilepath = shapeModelFilepath; plan.Note = note; plan.TrainingImage = trainingImage; plan.TrainingImageFilepath = trainingImageFilepath; plan.ExportUnit = exportUnit; plan.MatchingParamBinaryData = matchingParamData; plan.MeasureBinaryData = measureBinaryData; plan.UpperLightSwitch = (upperLight.OnOff == LightControl.LightSwitch.On); plan.UpperLightValue = upperLight.Intensity.ToString("d3"); plan.BottomLightSiwtch = (bottomLight.OnOff == LightControl.LightSwitch.On); plan.BottomLigthValue = bottomLight.Intensity.ToString("d3"); plan.ModifiedOn = DateTime.Now; plan.ModifiedBy = loginUser; plan.MeasureAssistantBinaryData = measureAssistantParamData; plan.ModelRow = findedShapeViewModel.Row; plan.ModelCol = findedShapeViewModel.Col; plan.ModelAngle = findedShapeViewModel.Angle; plan.IsDeleted = false; plan.Snapshot = snapshot; plan.ObjectXLength = objectXLength; plan.ObjectYLength = objectYLength; plan.TechnicalDrawingModel = XElement.Load(technicalDrawingModel.CreateReader()); if (!isUpdate) { _dc.MacroPlan.InsertOnSubmit(plan); } _dc.SubmitChanges(); } catch (Exception ex) { success = false; Hanbo.Log.LogManager.Error(ex.Message); } return(success); }
public ActionResult Index() { ShapeViewModel shapeViewModel = new ShapeViewModel() { Shape = Last() }; return(View(shapeViewModel)); }
void HandleRight(object sender, MouseButtonEventArgs args) { var ele = AdornedElement as FrameworkElement; ShapeViewModel shape = ele.DataContext as ShapeViewModel; shape.OffsetX = shape.Width / 2; shape.OffsetY = 0; SetFocus(ref Right); }
void HandleBottom(object sender, MouseButtonEventArgs args) { var ele = AdornedElement as FrameworkElement; ShapeViewModel shape = ele.DataContext as ShapeViewModel; shape.OffsetX = 0; shape.OffsetY = shape.Height / 2; SetFocus(ref Bottom); }
void HandleTopLeft(object sender, MouseButtonEventArgs args) { var ele = AdornedElement as FrameworkElement; ShapeViewModel shape = ele.DataContext as ShapeViewModel; shape.OffsetX = -shape.Width / 4; shape.OffsetY = -shape.Height / 2; SetFocus(ref topLeft); }
public async System.Threading.Tasks.Task <ActionResult> Index(ShapeViewModel shapeViewModel) { HttpResponseMessage response = await httpClient.PostAsyncAsJson("Calculate/Determine", shapeViewModel); if (response.IsSuccessStatusCode) { shapeViewModel.ShapeType = await response.Content.ReadAsStringAsync(); } return(View(shapeViewModel)); }
public ActionResult Save(ShapeViewModel viewModel) { ShapeModel shape = viewModel.Shape; if (ModelState.IsValid) { ShapeModel newShape = new ShapeModel { ShapeTypeId = shape.ShapeTypeId, Height = shape.Height, Label = shape.Label, LabelRow = shape.LabelRow }; Save(shape); } return(View("Index", viewModel)); }
/// <summary> /// Executes the <see cref="T:System.Windows.Input.RoutedCommand"/> on the current command target. /// Save the parameters (parameter and target) in a CommandGeneric instance and then save the instance in the command history that handle this file /// </summary> /// <param name="parameter">User defined parameter to be passed to the handler have to be a <see cref="CommandParameter"/>.</param> /// <param name="target">Element at which to being looking for command handlers.</param> /// <exception cref="T:System.InvalidOperationException"> /// <paramref name="target"/> is not a <see cref="T:System.Windows.UIElement"/> or <see cref="T:System.Windows.ContentElement"/>.</exception> /// /// <exception cref="ArgumentNullException">if parameter is null</exception> public override void Execute(CommandParameter parameter, IInputElement target) { _newShape = parameter.Parameter as ShapeViewModel; if (_newShape == null) throw new ArgumentNullException("parameter"); _oldShape = parameter.FileTargeted.RootCoatOfArm.CurrentShape; parameter.FileTargeted.RootCoatOfArm.CurrentShape = _newShape; Description = String.Format(CultureInfo.CurrentCulture, Resources.CommandDescChangeShape, _oldShape == null ? BlasonVocabulary.NoShape : _oldShape.LocalizedName, _newShape.LocalizedName ); //sauvegarde, c'est affreux, je peux pas le faire dans la classe abstraite parceque c'est cette instance que je dois cloner :( //copie de code pour tous les execute !! Parameter = parameter; Done = true; parameter.FileTargeted.CommandsApplied.CommandHistory.Add((ChangeShapeCommand)Clone()); }
public MainWindow() { InitializeComponent(); DataContext = new ShapeViewModel(); }
public static bool SaveMacroPlan(string macroName, string macroGuid, string shapeModelFilepath, string note, Binary trainingImage, string exportUnit, Binary matchingParamData, Binary measureBinaryData, Binary measureAssistantParamData, LightChannel upperLight, LightChannel bottomLight, ShapeViewModel shapeView, string loginUser , string trainingImageFilepath , double objectXLength, double objectYLength) { return(SaveMacroPlan(macroName, macroGuid, shapeModelFilepath, note, trainingImage, exportUnit, matchingParamData, measureBinaryData, measureAssistantParamData, upperLight, bottomLight, shapeView, loginUser , trainingImageFilepath, null , objectXLength, objectYLength, null)); }
public AddShapeCommand(ShapeViewModel selectedElement, MainViewModel mainViewModel) { _selectedElement = selectedElement; _mainViewModel = mainViewModel; }
public MoveShapeCommand(ShapeViewModel movedShape, Point oldPosition, Point newPosition) { _movedShape = movedShape; _oldPosition = oldPosition; _newPosition = newPosition; }
// GET: Calculate public ActionResult Index() { var shapeViewModel = new ShapeViewModel(); return(View(shapeViewModel)); }
protected virtual void OnShapeChanged(ShapeViewModel oldValue, ShapeViewModel newValue) { var args = new RoutedPropertyChangedEventArgs<ShapeViewModel>(oldValue, newValue) { RoutedEvent = ShapeChangedEvent }; RaiseEvent(args); }
/// <summary> /// Undoes this instance. /// Setting the old shape to the coat of arms /// </summary> public override void Undo() { var coaTarget = Parameter.FileTargeted.RootCoatOfArm; if (coaTarget == null) return; coaTarget.CurrentShape = _oldShape; _oldShape = _newShape; _newShape = coaTarget.CurrentShape; Done = false; }