Esempio n. 1
0
        private void OnLayoutEditorEditWare(object sender, WareBase e)
        {
            if (e is Labware)
            {
                Labware labware = e as Labware;
                if (this.ActivateEditingTab(labware.TypeName))
                {
                    return;
                }

                LabwareEditor editor = new LabwareEditor(AddInfo, this);
                editor.DataContext = labware;
                this.AddTabItem(editor);
            }
            else if (e is Carrier)
            {
                Carrier carrier = e as Carrier;
                if (this.ActivateEditingTab(carrier.TypeName))
                {
                    return;
                }

                CarrierEditor editor = new CarrierEditor(AddInfo);
                editor.DataContext = carrier;
                this.AddTabItem(editor);
            }
            else
            {
                // Bad argument
            }
        }
Esempio n. 2
0
 /// <summary>
 /// ctor
 /// </summary>
 /// <param name="ware"></param>
 public BasewareUIElement(WareBase ware)
 {
     _ware                 = ware;
     _children             = new VisualCollection(this);
     this._worktable       = Configurations.Instance.Worktable;
     ware.PropertyChanged += ware_PropertyChanged;
 }
Esempio n. 3
0
        private void AddSetCurrentMenu(WareBase ware, ContextMenu theMenu)
        {
            MenuItem menuItem = new MenuItem();

            menuItem.Header      = "设为当前";
            menuItem.DataContext = ware;
            menuItem.Click      += SetAsCurrentDitiMenuItem_Click;
            theMenu.Items.Add(menuItem);
        }
Esempio n. 4
0
        private void AddSetDitiPositionMenu(WareBase ware, ContextMenu theMenu)
        {
            MenuItem menuItem = new MenuItem();

            menuItem.Header      = "设置Diti位置";
            menuItem.DataContext = ware;
            menuItem.Click      += SetDitiPosition_Click;
            theMenu.Items.Add(menuItem);
        }
Esempio n. 5
0
        /// <summary>
        /// suggest candidate
        /// </summary>
        /// <param name="wareBase">A WareBase instance</param>
        public void SuggestCandidate(WareBase wareBase)
        {
            var uiElement = UIElementFactory.CreateUIElement(wareBase, _worktable.Children);
            int zIndex    = uiElement is CarrierUIElement ? 10 : 20;

            Grid.SetZIndex(uiElement, zIndex);
            _uiController.UIElementCandidate = uiElement;
            Mouse.OverrideCursor             = Cursors.Hand;
            _uiController.CaptureMouse();
        }
Esempio n. 6
0
        void SetDitiPosition_Click(object sender, RoutedEventArgs e)
        {
            WareBase ware = (WareBase)((MenuItem)sender).DataContext;

            if (ware is Labware)
            {
                if (((Labware)ware).IsDitiBox)
                {
                    CommandsManager.SetDitiPosition.Execute((Labware)ware, null);
                }
            }
        }
Esempio n. 7
0
        void miEdit_Click(object sender, RoutedEventArgs e)
        {
            WareBase ware = (WareBase)((MenuItem)sender).DataContext;

            if (ware is Labware)
            {
                CommandsManager.EditLabware.Execute((Labware)ware, null);
            }
            else
            {
                CommandsManager.EditCarrier.Execute((Carrier)ware, null);
            }
        }
Esempio n. 8
0
        /// <summary>
        /// update the ware, once it has been changed in editor
        /// </summary>
        /// <param name="ware"></param>
        public void UpdateWare(WareBase ware)
        {
            List <BasewareUIElement> thisTypeUIElements = FindUIElement(ware.TypeName);

            if (thisTypeUIElements.Count == 0)
            {
                return;
            }
            if (ware.GetType() == typeof(Carrier))
            {
                Carrier carrier = (Carrier)ware;
                thisTypeUIElements.ForEach(x => UpdateCarrier(carrier, (CarrierUIElement)x));
            }
            else
            {
                Labware labware = (Labware)ware;
                thisTypeUIElements.ForEach(x => ReplaceLabware(labware, (LabwareUIElement)x));
            }
        }
Esempio n. 9
0
        private System.Windows.Controls.ContextMenu BuildMenu(WareBase ware)
        {
            System.Windows.Controls.ContextMenu theMenu = new System.Windows.Controls.ContextMenu();
            MenuItem miEdit = new MenuItem();

            miEdit.Header      = "编辑";
            miEdit.DataContext = ware;
            miEdit.Click      += miEdit_Click;
            if (ware is Labware)
            {
                if (((Labware)ware).IsDitiBox)
                {
                    AddSetCurrentMenu(ware, theMenu);
                    AddSetDitiPositionMenu(ware, theMenu);
                }
            }
            theMenu.Items.Add(miEdit);

            return(theMenu);
        }
Esempio n. 10
0
        /// <summary>
        /// create UIElement
        /// </summary>
        /// <param name="wareBase"></param>
        /// <param name="existingUIElements"/>
        /// <returns></returns>
        public static BasewareUIElement CreateUIElement(WareBase wareBase, UIElementCollection existingUIElements)
        {
            BasewareUIElement newUIElement;

            if (wareBase is Labware)
            {
                Labware       labware        = ((Labware)wareBase).Clone() as Labware;
                List <string> existingLabels = GetExistingLabels(existingUIElements);
                string        newLabel       = FindNextLabelName(existingLabels);
                labware.Label = newLabel;
                newUIElement  = new LabwareUIElement(labware);
            }
            else
            {
                Carrier carrier = ((Carrier)wareBase).Clone() as Carrier;
                newUIElement = new CarrierUIElement((Carrier)carrier);
            }
            newUIElement.Selected = true;
            return(newUIElement);
        }
Esempio n. 11
0
        void Instance_onWareChanged(object sender, EventArgs e)
        {
            WareBase wareBase = ((WareEditArgs)e).WareBase;

            UpdateWare(wareBase);
        }
Esempio n. 12
0
 /// <summary>
 /// ctor
 /// </summary>
 /// <param name="wareBase2beEdit"></param>
 public WareEditArgs(WareBase wareBase2beEdit)
 {
     WareBase = wareBase2beEdit;
 }