Interaction logic for ProductionTypeItem.xaml
Inheritance: System.Windows.Controls.UserControl
Example #1
0
        private void Add_Clicked(TrakHound_UI.Button bt)
        {
            var item = new Controls.PartCountEventItem();

            item.ParentPage      = this;
            item.RemoveClicked  += Item_RemoveClicked;
            item.SettingChanged += Item_SettingChanged;
            PartCountItems.Add(item);
        }
Example #2
0
        private void Item_RemoveClicked(Controls.PartCountEventItem item)
        {
            int i = PartCountItems.ToList().FindIndex(o => o.Id == item.Id);

            if (i >= 0)
            {
                PartCountItems.RemoveAt(i);
                SettingChanged?.Invoke(null, null, null);
            }
        }
        private void LoadPartCountEventItems(DataTable dt)
        {
            PartCountItems.Clear();

            string address = "/Parts/";
            string filter = "address LIKE '" + address + "*'";

            var rows = DataTable_Functions.GetRows(dt, filter);

            foreach (DataRow row in rows)
            {
                string lastNode = DataTable_Functions.TrakHound.GetLastNode(row);
                if (lastNode == "Event")
                {
                    var item = new Controls.PartCountEventItem();
                    item.ParentPage = this;
                    item.RemoveClicked += Item_RemoveClicked;
                    item.SettingChanged += Item_SettingChanged;

                    filter = "address LIKE '" + row["address"].ToString() + "/*'";
                    var eventRows = DataTable_Functions.GetRows(dt, filter);
                    foreach (DataRow eventRow in eventRows)
                    {
                        lastNode = DataTable_Functions.TrakHound.GetLastNode(eventRow);

                        switch (lastNode)
                        {
                            case "EventName": item.EventName = DataTable_Functions.GetRowValue("value", eventRow); break;
                            case "EventValue": item.EventValue = DataTable_Functions.GetRowValue("value", eventRow); break;
                            case "PreviousEventValue": item.PreviousEventValue = DataTable_Functions.GetRowValue("value", eventRow); break;
                            case "ValueType": item.ValueType = GetFormattedValue(DataTable_Functions.GetRowValue("value", eventRow)); break;
                            case "CaptureItemLink": item.CaptureItemLink = DataTable_Functions.GetRowValue("value", eventRow); break;
                            case "CalculationType": item.CalculationType = DataTable_Functions.GetRowValue("value", eventRow); break;
                            case "StaticIncrementValue": item.StaticIncrementValue = DataTable_Functions.GetIntegerFromRow("value", eventRow); break;
                        }
                    }

                    if (!string.IsNullOrEmpty(item.EventName)) PartCountItems.Add(item);
                }
            }

            // Try loading deprecated configuration
            if (PartCountItems.Count == 0 && rows.Length > 0)
            {
                var item = new Controls.PartCountEventItem();
                item.ParentPage = this;
                item.RemoveClicked += Item_RemoveClicked;
                item.SettingChanged += Item_SettingChanged;

                foreach (DataRow row in rows)
                {
                    string lastNode = DataTable_Functions.TrakHound.GetLastNode(row);

                    if (lastNode == "PartsEventValue") item.EventValue = GetFormattedValue(DataTable_Functions.GetRowValue("value", row));
                    if (lastNode == "PartsEventName") item.EventName = DataTable_Functions.GetRowValue("value", row);
                    else if (lastNode == "PartsCaptureItemLink") item.CaptureItemLink = DataTable_Functions.GetRowValue("value", row);
                    else if (lastNode == "CalculationType") item.CalculationType = DataTable_Functions.GetRowValue("value", row);
                }

                if (!string.IsNullOrEmpty(item.EventName)) PartCountItems.Add(item);
            }
        }
Example #4
0
        private void LoadPartCountEventItems(DataTable dt)
        {
            PartCountItems.Clear();

            string address = "/Parts/";
            string filter  = "address LIKE '" + address + "*'";

            var rows = DataTable_Functions.GetRows(dt, filter);

            foreach (DataRow row in rows)
            {
                string lastNode = DataTable_Functions.TrakHound.GetLastNode(row);
                if (lastNode == "Event")
                {
                    var item = new Controls.PartCountEventItem();
                    item.ParentPage      = this;
                    item.RemoveClicked  += Item_RemoveClicked;
                    item.SettingChanged += Item_SettingChanged;

                    filter = "address LIKE '" + row["address"].ToString() + "/*'";
                    var eventRows = DataTable_Functions.GetRows(dt, filter);
                    foreach (DataRow eventRow in eventRows)
                    {
                        lastNode = DataTable_Functions.TrakHound.GetLastNode(eventRow);

                        switch (lastNode)
                        {
                        case "EventName": item.EventName = DataTable_Functions.GetRowValue("value", eventRow); break;

                        case "EventValue": item.EventValue = DataTable_Functions.GetRowValue("value", eventRow); break;

                        case "PreviousEventValue": item.PreviousEventValue = DataTable_Functions.GetRowValue("value", eventRow); break;

                        case "ValueType": item.ValueType = GetFormattedValue(DataTable_Functions.GetRowValue("value", eventRow)); break;

                        case "CaptureItemLink": item.CaptureItemLink = DataTable_Functions.GetRowValue("value", eventRow); break;

                        case "CalculationType": item.CalculationType = DataTable_Functions.GetRowValue("value", eventRow); break;

                        case "StaticIncrementValue": item.StaticIncrementValue = DataTable_Functions.GetIntegerFromRow("value", eventRow); break;
                        }
                    }

                    if (!string.IsNullOrEmpty(item.EventName))
                    {
                        PartCountItems.Add(item);
                    }
                }
            }

            // Try loading deprecated configuration
            if (PartCountItems.Count == 0 && rows.Length > 0)
            {
                var item = new Controls.PartCountEventItem();
                item.ParentPage      = this;
                item.RemoveClicked  += Item_RemoveClicked;
                item.SettingChanged += Item_SettingChanged;

                foreach (DataRow row in rows)
                {
                    string lastNode = DataTable_Functions.TrakHound.GetLastNode(row);

                    if (lastNode == "PartsEventValue")
                    {
                        item.EventValue = GetFormattedValue(DataTable_Functions.GetRowValue("value", row));
                    }
                    if (lastNode == "PartsEventName")
                    {
                        item.EventName = DataTable_Functions.GetRowValue("value", row);
                    }
                    else if (lastNode == "PartsCaptureItemLink")
                    {
                        item.CaptureItemLink = DataTable_Functions.GetRowValue("value", row);
                    }
                    else if (lastNode == "CalculationType")
                    {
                        item.CalculationType = DataTable_Functions.GetRowValue("value", row);
                    }
                }

                if (!string.IsNullOrEmpty(item.EventName))
                {
                    PartCountItems.Add(item);
                }
            }
        }
 private void Add_Clicked(TrakHound_UI.Button bt)
 {
     var item = new Controls.PartCountEventItem();
     item.ParentPage = this;
     item.RemoveClicked += Item_RemoveClicked;
     item.SettingChanged += Item_SettingChanged;
     PartCountItems.Add(item);
 }