public PartNoWritePLC() { InitializeComponent(); ButtonProperty.SetProperty(btnSelectPartNo, true); ButtonProperty.SetProperty(btnPLCWrite, true); DefaultPartNo(); }
/// <summary> /// 預設值:設定元件屬性樣式 /// </summary> private void SetPropertyControl() { ButtonProperty.SetProperty(btnSelectPartNo, true); ButtonProperty.SetProperty(btnTraySelect, true); DataGridviewProperty.SetProperty(dataGridView1); DataGridviewProperty.SetProperty(datagvJudge); }
void Sort(int sortMode) { List <ButtonProperty> list = new List <ButtonProperty>(); ButtonProperty selected; if (MusicButtons != null) { selected = MusicButtons[center]; } else { selected = null; } switch (sortMode) { default: //0~2を想定,それ以外はエラー if (sortMode < 0 || 2 < sortMode) { break; } for (int i = 0; i < musicList.music.Length; i++) { if (musicList.music[i].difficulty[sortMode].Level != 0) { ButtonProperty button = new ButtonProperty(); button.dataIndex = i; button.difficulty = sortMode; list.Add(button); } } break; } }
private void ClearResult() { for (int i = 0; i < CA_Main.Children.Count; i++) { Button b = CA_Main.Children[i] as Button; if (b != null) { ButtonProperty bp = b.Tag as ButtonProperty; if (bp.Type == 4 || bp.Type == 5) { bp.Type = 0; bp.Distance = -1; bp.EvaDistance = -1; bp.Parent = -1; b.Style = this.FindResource("CommonButtonStyle") as Style; } if (b.Content != null) { ArrowControl ar = b.Content as ArrowControl; ar.SetDistance(0); ar.SetEvaDistance(0); ar.SetSumDistance(0); if (ar != null) { ar.Visibility = Visibility.Hidden; } } } } }
//[MenuItem("Window/UIModifier/Button &l")] //protected static void OpenButtonModifier() //{ // CurrentViewHeader = "Label"; // Initialize(); //} public static void Initialize() { CurrentViewHeader = "Button"; m_LabelProperty = new LabelProperty(); m_LabelProperty.Reset(); m_LabelProperty.OnSnap = OnSnapEvent; m_LabelProperty.OnAllPropertiesChanged = OnChangeAllEvent; m_SpriteProperty = new SpriteProperty(); m_SpriteProperty.Reset(); m_SpriteProperty.OnSnap = OnSnapEvent; m_SpriteProperty.OnAllPropertiesChanged = OnChangeAllEvent; m_ButtonProperty = new ButtonProperty(); m_ButtonProperty.Reset(); m_ButtonProperty.OnAllPropertiesChanged = OnChangeAllEvent; m_ButtonProperty.OnUpdateClick = OnButtonUpdateEvent; if (MainWindow == null) { MainWindow = GetWindow <UIQuickModifier>("UIQuick Replace", true); } MainWindow.Show(); MainWindow.Repaint(); }
static public bool ChangeButtonProperties(UIButton button, ButtonProperty value) { if (button == null) { return(false); } if (button.tweenTarget == null) { Debug.LogError("There has none TweenTarget.. Obj: " + button.gameObject.name); return(false); } if (value.EnableColor) { button.EnableColor = true; button.defaultColor = value.Normal_Color; button.hover = value.Hover_Color; button.pressed = value.Pressed_Color; button.disabledColor = value.Disabled_Color; } if (value.EnableSprite) { UISprite sprite = button.tweenTarget.GetComponent <UISprite>(); if (sprite == null) { Debug.LogError("Check State. It's not Sprtie. Obj: " + button.tweenTarget.name); return(false); } sprite.atlas = value.Atlas; sprite.spriteName = value.Normal_Sprite; sprite.type = UIBasicSprite.Type.Sliced; EditorUtility.SetDirty(sprite); button.normalSprite = value.Normal_Sprite; button.hoverSprite = value.Hover_Sprite; button.pressedSprite = value.Pressed_Sprite; button.disabledSprite = value.Disabled_Sprite; } else { UI2DSprite sprite2D = button.tweenTarget.GetComponent <UI2DSprite>(); if (sprite2D == null) { Debug.LogError("Check State. It's not Sprite2D.. Obj: " + button.tweenTarget.name); return(false); } sprite2D.sprite2D = value.Normal_Sprite2D; EditorUtility.SetDirty(sprite2D); button.normalSprite2D = value.Normal_Sprite2D; button.hoverSprite2D = value.Hover_Sprite2D; button.pressedSprite2D = value.Pressed_Sprite2D; button.disabledSprite2D = value.Disabled_Sprite2D; } EditorUtility.SetDirty(button); return(true); }
public static void CreateButton(List <ButtonProperty> target, ref int[] id) { for (int i = 0; i < target.Count; i++) { ButtonProperty temp = target[i]; id[i] = CreateButton(ref temp); } }
public TraySet() { InitializeComponent(); SetDefultEvent(); ButtonProperty.SetProperty(btnSelectTrayNo, true); DataGridviewProperty.SetProperty(dataGridView1); GetDefaultTrayNo(); }
public Reader() { InitializeComponent(); ButtonProperty.SetProperty(btnRead, true); ButtonProperty.SetProperty(btnReadWrite, true); if (GlobalParameter.UseMode.Equals("1")) { #region 測試後不用要刪除 PLCMethod.PLC_Connect(); Thread.Sleep(1000); #endregion 測試後不用要刪除 // PLC連線、條碼讀取器連線 try { if (!GlobalData.PLC初始連線是否成功) { MessageBox.Show("PLC連線失敗:請檢查PLC連線IP、機台是否異常。"); return; } if (!GlobalData.PLC線路異常) { ThreadPool.QueueUserWorkItem(DM8120讀取2D碼執行緒); } else { MessageBox.Show("PLC線路異常。"); return; } bool check = LiveviewFormProperty.ReadConnect(liveviewForm1, readerAccessor, GlobalParameter.ReadIP); if (!check) { MessageBox.Show("條碼讀取器連線異常。"); return; } } catch (Exception ex) { logger.Error(ex, "Exception錯誤"); MessageBox.Show("Exception錯誤:" + ex.Message); return; } // Hoioke機台連線 try { IPEndPoint ipe = new IPEndPoint(IPAddress.Parse(GlobalParameter.HiokiIP), 32006); this.socket = new Socket(ipe.AddressFamily, SocketType.Stream, ProtocolType.Tcp); Thread tread = new Thread(new ThreadStart(CheckSocketConnect)); tread.Start(); this.socket.Connect(ipe); } catch (Exception) { MessageBox.Show("Hiorki連線: Hiorki機台連線異常,請檢查IP位置或網路線路是否異常。"); } } }
public RecErrorReport() { InitializeComponent(); ButtonProperty.SetProperty(btnSearch, true); DateTimeProprty.SetForMonthly(dateTimePicker1); DataGridviewProperty.SetProperty(dataGridView1); dataGridView1.DataSource = new List <RecError>(); SetGridViewColumnName(); }
public static ButtonProperty Create(string text, System.Action action) { ButtonProperty bp = new ButtonProperty() { buttonText = text, action = action }; return(bp); }
void b_PreviewMouseLeftButtonDown(object sender, MouseButtonEventArgs e) { Button b = (Button)sender; ButtonProperty bp = b.Tag as ButtonProperty; if (bp.Type == 0) { bp.Type = 1; b.Tag = bp; b.Style = this.FindResource("ObstacleButtonStyle") as Style; } }
private int[,] GetMap() { if (buttonMap.GetLength(0) != map.GetLength(0)) { throw new Exception(); } this.size = map.GetLength(0); for (int i = 0; i < size; i++) { for (int j = 0; j < size; j++) { Button b = buttonMap[i, j]; ButtonProperty bp = b.Tag as ButtonProperty; this.map[i, j] = bp.Type; } } return(this.map); }
void b_PreviewMouseMove(object sender, MouseEventArgs e) { Button b = (Button)sender; ButtonProperty bp = b.Tag as ButtonProperty; if (bp != null) { StringBuilder sb = new StringBuilder(); FieldInfo[] fields = typeof(ButtonProperty).GetFields(); for (int i = 0; i < fields.Length; i++) { string name = fields[i].Name; string v = fields[i].GetValue(bp).ToString(); sb.Append(name + "=" + v + Environment.NewLine); } ShowMessage(sb.ToString()); } }
private void ShowResult(ResultCollection ret) { if (ret.parentMap != null) { for (int i = 0; i < size; i++) { for (int j = 0; j < size; j++) { Button b = buttonMap[i, j]; ArrowControl arrow = b.Content as ArrowControl; ButtonProperty bp = buttonMap[i, j].Tag as ButtonProperty; if (ret.parentMap[i, j] != -1) { arrow.Visibility = Visibility.Visible; bp.Parent = ret.parentMap[i, j]; arrow.SetDirection(ret.parentMap[i, j]); } } } } if (ret.resultMap != null) { for (int i = 0; i < size; i++) { for (int j = 0; j < size; j++) { Button b = buttonMap[i, j]; ButtonProperty bp = buttonMap[i, j].Tag as ButtonProperty; int type = ret.resultMap[i, j]; if (type == 4) { b.Style = FindResource("PathButtonStyle") as Style; bp.Type = type; b.Tag = bp; } if (type == 5) { b.Style = FindResource("TraveledButtonStyle") as Style; bp.Type = type; b.Tag = bp; } } } } if (ret.distanceMap != null) { for (int i = 0; i < size; i++) { for (int j = 0; j < size; j++) { Button b = buttonMap[i, j]; ArrowControl arrow = b.Content as ArrowControl; ButtonProperty bp = buttonMap[i, j].Tag as ButtonProperty; if (ret.distanceMap[i, j] != int.MaxValue) { arrow.Visibility = Visibility.Visible; bp.Parent = ret.parentMap[i, j]; bp.Distance = ret.distanceMap[i, j]; if (ret.evaDistanceMap != null) { bp.EvaDistance = ret.evaDistanceMap[i, j]; } arrow.SetDistance(ret.distanceMap[i, j]); if (ret.evaDistanceMap != null) { arrow.SetEvaDistance(ret.evaDistanceMap[i, j]); } else { arrow.SetEvaDistance(0); } if (ret.evaDistanceMap != null) { arrow.SetSumDistance(ret.distanceMap[i, j] + ret.evaDistanceMap[i, j]); } else { arrow.SetEvaDistance(0); } } } } } }
private void InitMap(int size) { this.st = null; this.ed = null; this.size = size; this.map = new int[size, size]; this.buttonMap = new Button[size, size]; int count = 0; for (int i = 0; i < CA_Main.Children.Count; i++) { Button b = CA_Main.Children[i] as Button; if (b != null) { count++; b.Style = this.FindResource("CommonButtonStyle") as Style; b.Visibility = Visibility.Collapsed; if (b.Content != null) { ArrowControl ar = b.Content as ArrowControl; if (ar != null) { ar.Visibility = Visibility.Hidden; } } } } if (count < size * size) { for (int i = 0; i < size * size - count; i++) { Button b = new Button(); b.Style = this.FindResource("CommonButtonStyle") as Style; b.PreviewMouseLeftButtonDown += new MouseButtonEventHandler(b_PreviewMouseLeftButtonDown); b.PreviewMouseRightButtonDown += new MouseButtonEventHandler(b_PreviewMouseRightButtonDown); b.PreviewMouseMove += new MouseEventHandler(b_PreviewMouseMove); CA_Main.Children.Add(b); ArrowControl arrow = new ArrowControl(); arrow.Width = blockWidth - 1; arrow.Height = blockWidth - 1; arrow.HorizontalAlignment = HorizontalAlignment.Center; arrow.VerticalAlignment = VerticalAlignment.Center; b.Content = arrow; arrow.Visibility = Visibility.Hidden; } } int index = 0; for (int i = 0; i < size; i++) { for (int j = 0; j < size; j++) { ButtonProperty bp = new ButtonProperty(i, j, 0); Button b = (CA_Main.Children[index] as Button); buttonMap[i, j] = b; b.Tag = bp; index++; Canvas.SetLeft(b, bp.X * blockWidth); Canvas.SetTop(b, bp.Y * blockWidth); b.Visibility = Visibility.Visible; } } }
private bool ReadFileMap(string path) { string content; try { content = File.ReadAllText(path); content = content.Replace("\r\n", "@"); } catch (System.Exception ex) { return(false); } string[] lines = content.Split('@'); if (lines.Length < 3 || lines[0].Length != lines.Length) { return(false); } this.size = lines.Length; InitMap(size); for (int j = 0; j < lines.Length; j++) { for (int i = 0; i < lines[j].Length; i++) { if (lines[j][i] == '0') { map[i, j] = 0; } if (lines[j][i] == '1') { map[i, j] = 1; Button b = buttonMap[i, j]; ButtonProperty bp = b.Tag as ButtonProperty; if (bp.Type == 0) { bp.Type = 1; b.Tag = bp; b.Style = this.FindResource("ObstacleButtonStyle") as Style; } } if (lines[j][i] == '2') { map[i, j] = 2; Button b = buttonMap[i, j]; ButtonProperty bp = b.Tag as ButtonProperty; st = bp; if (bp.Type != 2) { bp.Type = 2; b.Tag = bp; b.Style = this.FindResource("StartButtonStyle") as Style; } } if (lines[j][i] == '3') { map[i, j] = 3; Button b = buttonMap[i, j]; ButtonProperty bp = b.Tag as ButtonProperty; ed = bp; if (bp.Type != 3) { bp.Type = 3; b.Tag = bp; b.Style = this.FindResource("EndButtonStyle") as Style; } } } } return(true); }
void b_PreviewMouseRightButtonDown(object sender, MouseButtonEventArgs e) { Button b = (Button)sender; ButtonProperty bp = b.Tag as ButtonProperty; if (bp.Type != 0) { return; } setCount++; if (setCount % 2 == 1) { if (st == null) { st = bp; if (bp.Type != 2) { bp.Type = 2; b.Tag = bp; b.Style = this.FindResource("StartButtonStyle") as Style; } } else { Button pre = buttonMap[st.X, st.Y]; ButtonProperty prebp = pre.Tag as ButtonProperty; prebp.Type = 0; pre.Tag = prebp; pre.Style = this.FindResource("CommonButtonStyle") as Style; st = bp; bp.Type = 2; b.Tag = bp; b.Style = this.FindResource("StartButtonStyle") as Style; } } else { if (ed == null) { ed = bp; if (bp.Type != 3) { bp.Type = 3; b.Tag = bp; b.Style = this.FindResource("EndButtonStyle") as Style; } } else { Button pre = buttonMap[ed.X, ed.Y]; ButtonProperty prebp = pre.Tag as ButtonProperty; prebp.Type = 0; pre.Tag = prebp; pre.Style = this.FindResource("CommonButtonStyle") as Style; ed = bp; bp.Type = 3; b.Tag = bp; b.Style = this.FindResource("EndButtonStyle") as Style; } } }
public static int CreateButton(ref ButtonProperty target) { int i; for (i = 0; i < 64; i++) { if (!buff_button[i].reg) { buff_button[i].reg = true; break; } if (buff_button[i].restore) { buff_button[i].restore = false; buff_button[i].button.Visibility = Visibility.Visible; buff_button[i].button.Click -= buff_button[i].bp.click; goto label1; } } Button button = new Button(); buff_button[i].button = button; label1 :; buff_button[i].bp = target; button = buff_button[i].button; target.margin.Left = target.x; // bp.margin.Right = screenX - bp.x - bp.Width; target.margin.Top = target.y; target.margin.Bottom = screenY - target.y - target.Width; button.Margin = target.margin; button.Content = target.text; if (target.angle > 0) { RotateTransform rtf = new RotateTransform(); rtf.Angle = target.angle; button.RenderTransform = rtf; } if (target.color.A > 0) { button.Foreground = new SolidColorBrush(target.color); } else { button.Foreground = new SolidColorBrush(font_color); } if (target.bk_color.A > 0) { button.Background = new SolidColorBrush(target.bk_color); } if (target.size > 0) { button.FontSize = target.size; } if (target.click != null) { button.Click += target.click; } button.DataContext = target.data; main_canv.Children.Add(button); return(i + 256); }
set => this.SetValue(ButtonProperty, value);
/// <summary> /// 讀取料號 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void btnloadPN_Click(object sender, EventArgs e) { // 預設值 formStartModel.允許2D讀取Tag = formStartModel.允許雷射打印Tag = txtLot.Enabled = false; ButtonProperty.SetProperty(btnloadMaterial, false); // PLC:DM_8101自動AUTOREADY,正式模式才會執行此點位檢查 if (GlobalParameter.UseMode.Equals("1")) { if (!GlobalData.PLC線路異常) { if (GlobalData.DM[DmTable.DM_8101自動AUTOREADY].Equals("0")) { MessageBox.Show("PLC異常:DM_8101自動AUTOREADY,機台未準備好,請檢查機台或PLC。"); return; } } } // 驗證參數 if (ValidateUtility.DisplayMessage(ValidateUtility.CheckParameter(txtPN.Text))) { return; } try { if (MessageBox.Show("讀取確認:" + txtPN.Text, "Load", MessageBoxButtons.YesNo, MessageBoxIcon.Information).Equals(DialogResult.Yes)) { ResponseModel responseModel = new PartNoJoinTrayAndLaserService().GetConditionMain(txtPN.Text); partNoJoinTrayAndLaser = responseModel.PartNoJoinTrayAndLaser; if (partNoJoinTrayAndLaser != null) { switch (partNoJoinTrayAndLaser.UsesIten) { case "0": formStartModel.允許2D讀取Tag = formStartModel.允許雷射打印Tag = true; break; case "1": formStartModel.允許2D讀取Tag = true; break; default: formStartModel.允許雷射打印Tag = true; break; } txtLot.Enabled = true; ButtonProperty.SetProperty(btnloadMaterial, true); MessageBox.Show("讀取成功。"); } else { MessageBox.Show("查無此料號。"); } } } catch (Exception ex) { logger.Error(ex, "Exception錯誤"); MessageBox.Show(ex.Message); } }
set => SetValue(ButtonProperty, value);