private void cmbPostionList_SelectionChanged(object sender, SelectionChangedEventArgs e) { ViewMassMove view = DataContext as ViewMassMove; if (cmbPostionList.SelectedIndex == 0) { // read current position btnSave.IsEnabled = true; btnDelete.IsEnabled = false; btnMove.IsEnabled = false; btnStop.IsEnabled = false; for (int i = 0; i < view.AxisControlCollection.Count; i++) { Axis4MassMove _axis_view = view.AxisControlCollection[i]; LogicalAxis _log_axis = view.MotionComponent.LogicalAxisCollection[i]; _axis_view.Position = _log_axis.PhysicalAxisInst.UnitHelper.RelPosition; _axis_view.IsAbsMode = _log_axis.PhysicalAxisInst.IsAbsMode; _axis_view.Speed = 100; } } else { // load the saved position btnSave.IsEnabled = true; btnDelete.IsEnabled = true; btnMove.IsEnabled = true; btnStop.IsEnabled = true; } }
private void btnSave_Click(object sender, RoutedEventArgs e) { InputBox box = new InputBox("Input Preset Name", "Input"); bool? ret = box.ShowDialog(); if (ret.HasValue && ret == true) { ViewMassMove view = DataContext as ViewMassMove; view.SavePresetPosition(box.Input); } }
private void Window_Loaded(object sender, RoutedEventArgs e) { // set the height of window dynamically ViewMassMove view = DataContext as ViewMassMove; this.Height = 180 + view.AxisControlCollection.Count * view.AxisControlCollection[0].ActualHeight; // create the preset position list cmbPostionList.Items.Add("*"); cmbPostionList.SelectedIndex = 0; // load preset position files string[] names = view.GetPresetPositionList(); foreach (var n in names) { cmbPostionList.Items.Add(n); } int _hashcode = view.MotionComponent.GetHashCode(); txtHashCode.Text = _hashcode.ToString("X"); }
public MainWindow() { // show splash screen splashscreen = new Splash(); splashscreen.Show(); InitializeComponent(); Messenger.Default.Register <NotificationMessage <string> >(this, PopNotificationMessage); // create DocumentPanel per the logical motion components defined in the config file var service = SimpleIoc.Default.GetInstance <SystemService>(); #region Create logical motioin components panels foreach (var aligner in service.LogicalMotionComponentCollection) { // create a motion component panel control // which is the content of the document panel MotionComponentPanel uc = new MotionComponentPanel() { // set the datacontext to the LogicalMotionComponent DataContext = aligner }; // create a document panel in the window DocumentPanel panel = new DocumentPanel() { Name = string.Format("dp{0}", aligner.Caption.Replace(" ", "")), Caption = aligner.Caption, AllowMaximize = false, AllowSizing = false, AllowFloat = false, AllowDock = false, //AllowClose = false, ClosingBehavior = ClosingBehavior.HideToClosedPanelsCollection, // put the user control into the panel Content = uc }; // add the documentpanel to the documentgroup MotionComponentPanelHost.Items.Add(panel); // find the icon shown in the button var image = (BitmapFrame)TryFindResource(aligner.Icon); // add view buttons to Ribbon toolbar BarCheckItem chk = new BarCheckItem() { Content = aligner.Caption, LargeGlyph = image }; // bind the IsCheck property to the document panel's Closed property Binding b = new Binding() { Source = panel, Path = new PropertyPath("Visibility"), Mode = BindingMode.TwoWay, Converter = new VisibilityToBoolean() }; chk.SetBinding(BarCheckItem.IsCheckedProperty, b); rpgView_MotionComponent.Items.Add(chk); // add buttons to show the preset position window BarButtonItem btn = new BarButtonItem() { Content = aligner.Caption, LargeGlyph = image, DataContext = aligner }; // raise the click event btn.ItemClick += (s, e) => { var view = new ViewMassMove(service, aligner); var win = new MassMoveWindow { DataContext = view }; win.ShowDialog(); }; rpgPresetPositionButtonsHost.Items.Add(btn); } #endregion #region Create control panels for instruments ViewModelBase viewInstr; foreach (var instr in service.MeasurementInstrumentCollection) { UserControl uctrl = null; //TODO The following codes is not elegant, the code must be expanded if new type of instrument added into the system if (instr is Keithley2400) { // create the user control for k2400 viewInstr = new ViewKeithley2400(instr as Keithley2400); uctrl = new Keithley2400ControlPanel() { DataContext = viewInstr }; } else if (instr is Newport2832C) { // create the user control for k2400 viewInstr = new ViewNewport2832C(instr as Newport2832C); uctrl = new Newport2832cControlPanel() { DataContext = viewInstr }; } // create document panel in the window DocumentPanel panel = new DocumentPanel() { Name = string.Format("dp{0}", instr.DeviceClass.ToString("N")), Caption = instr.Config.Caption, AllowMaximize = false, AllowSizing = false, AllowDock = false, AllowFloat = false, ClosingBehavior = ClosingBehavior.HideToClosedPanelsCollection, // put the user control into the panel Content = uctrl }; // add the documentpanel to the documentgroup MotionComponentPanelHost.Items.Add(panel); // find the icon shown in the button var image = (BitmapFrame)TryFindResource(instr.Config.Icon); // add view buttons to Ribbon toolbar BarCheckItem chk = new BarCheckItem() { Content = instr.Config.Caption, LargeGlyph = image }; // bind the IsCheck property to the document panel's Closed property Binding b = new Binding() { Source = panel, Path = new PropertyPath("Visibility"), Mode = BindingMode.TwoWay, Converter = new VisibilityToBoolean() }; chk.SetBinding(BarCheckItem.IsCheckedProperty, b); rpgView_Equipments.Items.Add(chk); } #endregion #region Restore workspace layout var config = SimpleIoc.Default.GetInstance <ConfigManager>(); for (int i = 0; i < MotionComponentPanelHost.Items.Count; i++) { var panel = MotionComponentPanelHost.Items[i]; if (panel is DocumentPanel) { //var layout = // (from items // in config.WorkspaceLayoutHelper.WorkspaceLayout // where items.PanelName == panel.Name // select items).First(); try { var setting = ((IEnumerable)config.ConfWSLayout.WorkspaceLayout).Cast <dynamic>().Where(item => item.PanelName == panel.Name).First(); panel.Visibility = setting.IsClosed ? Visibility.Hidden : Visibility.Visible; ((DocumentPanel)panel).MDILocation = setting.MDILocation; } catch { ; // do nothing if the panel was not found in layout setting file } } } #endregion }