コード例 #1
0
        private void ButtonClick(object sender, RoutedEventArgs e)
        {
            var main   = Owner as MainWindow;
            var name   = Sub + "_" + xName.Content + "x" + yName.Content;
            var button = (Button)main.FindName(name);

            if (button != null)
            {
                button.Background = new SolidColorBrush(xColor.SelectedColor);
                button.Foreground = new SolidColorBrush(xColorFont.SelectedColor);
                button.Content    = xCaption.Text;

                var elm = button.Tag as ClassGridGroup.Elm ?? new ClassGridGroup.Elm(
                    RepositoryXmlFile.GetPathByType(XmlDocEnum.B),
                    (byte)X,
                    (byte)Y,
                    button.Content.ToString(),
                    GetSelected(xGBFunction));

                elm.Func       = GetSelected(xGBFunction);
                elm.Background = button.Background;
                elm.Foreground = button.Foreground;
                elm.Caption    = button.Content.ToString();
                if (elm.Caption == string.Empty)
                {
                    ProductType product;
                    elm.Caption    = FunctionsTranslateService.GetTranslatedFunctionWithProd(elm.Func, out product);
                    button.Content = elm.Caption;
                }

                button.Tag = elm;

                var bReset = (Button)sender;
                if (bReset.Tag.ToString() == "Réinitialiser la configuration")
                {
                    button.Tag = "None - Vide";
                }

                if (button.Tag != null && button.Tag.ToString() == "None - Vide")
                {
                    button.ClearValue(BackgroundProperty);
                    button.Content = string.Empty;
                    button.ToolTip = Properties.Resources.LabelNone;
                }
                ClassGridGroup.Save(button);
                Close();
            }
        }
コード例 #2
0
ファイル: MainWindow.xaml.cs プロジェクト: SokolSib/FRANCE
        private void GridLoad(string s, ClassGridGroup.Elm[,] grid)
        {
            for (var i = 0; i < grid.GetLength(0); i++)
            {
                for (var j = 0; j < grid.GetLength(1); j++)
                {
                    if (grid[i, j] != null)
                    {
                        var b = (Button)FindName(s + "_" + i + "x" + j);

                        b.Content = grid[i, j].Caption;

                        if (b.Background != null)
                        {
                            b.Background = grid[i, j].Background;
                        }
                        if (grid[i, j].Foreground != null)
                        {
                            b.Foreground = grid[i, j].Foreground;
                        }

                        b.Tag = grid[i, j];

                        ProductType product;
                        b.ToolTip = FunctionsTranslateService.GetTranslatedFunctionWithProd(grid[i, j].Func, out product);
                        if (!string.IsNullOrEmpty(grid[i, j].ProductId))
                        {
                            product = RepositoryProduct.Products.FirstOrDefault(p => p.CustomerId == new Guid(grid[i, j].ProductId));
                            if (product != null)
                            {
                                b.ToolTip = product.Name;
                                if (string.IsNullOrEmpty(b.Content?.ToString()))
                                {
                                    b.Content = product.Name;
                                }
                            }
                        }
                        if (string.IsNullOrEmpty(b.ToolTip?.ToString()))
                        {
                            b.ToolTip = grid[i, j].Caption;
                        }
                    }
                }
            }
        }
コード例 #3
0
        private void Go(ProductType p)
        {
            if (p != null)
            {
                var wProduct = Owner as MainWindow;

                var el = new Class.ClassGridProduct.Elm
                {
                    Background = new SolidColorBrush(xColor.SelectedColor),
                    Font       = new SolidColorBrush(xFontColor.SelectedColor),
                    X          = Convert.ToByte(X),
                    Y          = Convert.ToByte(Y)
                };

                if (FindProduct.Product != null)
                {
                    el.Description = FindProduct.Product.Name;
                    el.CustomerId  = p.CustomerId;
                }

                var v = (Button)wProduct.FindName("_b_" + X + "x" + Y);

                if (v != null)
                {
                    ((TextBlock)v.Content).Text = el.Description;

                    ProductType product;
                    v.ToolTip = FunctionsTranslateService.GetTranslatedFunctionWithProd(
                        "Products id=[" + p.CustomerId + "]", out product);

                    v.Background = new SolidColorBrush(xColor.SelectedColor);
                    v.Foreground = new SolidColorBrush(xFontColor.SelectedColor);
                    new Class.ClassGridProduct().Save(el, wProduct.I, wProduct.J);
                    Close();
                }
            }
        }
コード例 #4
0
        public static void Save(Button b)
        {
            var windowGridPay = Window.GetWindow(b) as WGridPay;
            var cr            = "Default";
            var cr1           = "Default";
            var dd            = b.Name.Split('x');
            var x             = dd[0].Substring(2, dd[0].Length - 2);
            var y             = dd[1];
            var caption       = b.Content.ToString();
            var sBackground   = b.Background as SolidColorBrush;
            var sForeground   = b.Foreground as SolidColorBrush;

            if (sBackground != null)
            {
                cr = sBackground.Color.A + "," + sBackground.Color.R + "," + sBackground.Color.G + "," +
                     sBackground.Color.B;
            }
            if (sForeground != null)
            {
                cr1 = sForeground.Color.A + "," + sForeground.Color.R + "," + sForeground.Color.G + "," +
                      sForeground.Color.B;
            }

            string funcType = null;
            var    elmTag   = b.Tag as Elm;

            funcType = elmTag != null ? elmTag.Func : b.Tag.ToString();

            var typePayId = -1;

            if (windowGridPay != null)
            {
                typePayId = windowGridPay.TypesPay.Id;
            }

            var type = RepositoryXmlFile.ToXmlDocEnum(b.Name);

            if (type == XmlDocEnum.M)
            {
                caption = ((Label)((StackPanel)b.Content).FindName("mlb_" + x + "x" + y)).Content.ToString();
            }

            var      doc = RepositoryXmlFile.Load(type, typePayId);
            XElement target;

            try
            {
                target =
                    doc.GetXElements("Grid", "rec")
                    .Single(e => (e.GetXElementValue("X") == x) & (e.GetXElementValue("Y") == y));
            }
            catch
            {
                target = null;
            }

            if (target != null)
            {
                var d        = target.Nodes().ToArray();
                var dateUpd  = d[1] as XElement;
                var caption1 = d[4] as XElement;
                var color    = d[5] as XElement;
                var color1   = d[6] as XElement;
                var fun      = d[8] as XElement;

                dateUpd.Value  = DateTime.Now.ToString(Config.DateFormat);
                caption1.Value = caption;
                color.Value    = cr;
                color1.Value   = cr1;
                fun.Value      = funcType;

                if (cr == "Default")
                {
                    target.Remove();
                }
                if (cr1 == "Default")
                {
                    target.Remove();
                }
            }
            else
            {
                if (cr != "Default")
                {
                    doc.GetXElement("Grid").Add(
                        new XElement("rec",
                                     new XElement("id", (int.Parse(x) * int.Parse(y)).ToString()),
                                     new XElement("Date_upd", DateTime.Now.ToString(Config.DateFormat)),
                                     new XElement("X", x),
                                     new XElement("Y", y),
                                     new XElement("Caption", caption),
                                     new XElement("Color", cr),
                                     new XElement("foreground", cr1),
                                     new XElement("Img", ""),
                                     new XElement("Fun", funcType)
                                     )
                        );
                }
            }
            ProductType product;

            b.ToolTip = FunctionsTranslateService.GetTranslatedFunctionWithProd(funcType, out product);

            if (string.IsNullOrEmpty(b.Content?.ToString()) && product != null)
            {
                b.Content = product.Name;
            }

            RepositoryXmlFile.Save(doc, type, typePayId);
        }