Ejemplo n.º 1
0
        protected virtual void ElementButtonClick(object sender, RoutedEventArgs e)
        {
            PathUIButton btn = sender as PathUIButton;

            if (btn != null)
            {
                List <string> buff = new List <string>();
                for (int i = 0; i < this.ButtonList.Count; i++)
                {
                    string tmp = (string)this.ButtonList[i].Content;
                    tmp = tmp.Trim();
                    if (i == 0)
                    {
                        tmp += "\\";
                    }
                    buff.Add(tmp.Trim());
                    if (object.ReferenceEquals(btn, this.ButtonList[i]))
                    {
                        break;
                    }
                }
                this.Path = System.IO.Path.Combine(buff.ToArray());
            }
        }
Ejemplo n.º 2
0
        protected virtual void SetPath(string path)
        {
            this.ClearDispUI();
            if (this.DispUI != null)
            {
                string tmp;
                if (string.IsNullOrWhiteSpace(path))
                {
                    tmp = Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments);
                }
                else
                {
                    if (path.EndsWith("\\"))
                    {
                        tmp = path.Substring(0, path.Length - 1);
                    }
                    else
                    {
                        tmp = path;
                    }
                }


                string[] ele = tmp.Split('\\');

                this.ButtonList = new List <PathUIButton>();
                ColumnDefinition coldef;
                GridSplitter     gsp;
                PathUIButton     btn;
                for (int i = 0; i < ele.Length; i++)
                {
                    //要素を追加
                    coldef          = new ColumnDefinition();
                    coldef.MinWidth = 10;
                    this.DispUI.ColumnDefinitions.Add(coldef);

                    btn = new PathUIButton()
                    {
                        Content = " " + ele[i] + "  "
                    };
                    btn.Click += ElementButtonClick;
                    this.ButtonList.Add(btn);
                    this.DispUI.Children.Add(btn);

                    btn.Measure(new Size(1024, 100));
                    btn.MinWidth = 10;
                    coldef.Width = new GridLength(btn.DesiredSize.Width, GridUnitType.Auto);
                    Grid.SetColumn(btn, i * 2);

                    //セパレータを追加
                    double sepwidth = 2;
                    coldef       = new ColumnDefinition();
                    coldef.Width = new GridLength(sepwidth);
                    this.DispUI.ColumnDefinitions.Add(coldef);

                    gsp = new GridSplitter();
                    gsp.ResizeDirection = GridResizeDirection.Columns;
                    LinearGradientBrush brush = new LinearGradientBrush();
                    brush.StartPoint = new Point(0, 0);
                    brush.EndPoint   = new Point(0, 1);
                    brush.GradientStops.Add(new GradientStop()
                    {
                        Color = Colors.LightGray, Offset = 0
                    });
                    brush.GradientStops.Add(new GradientStop()
                    {
                        Color = Colors.Gray, Offset = 1
                    });
                    gsp.Background          = brush;
                    gsp.Width               = sepwidth;
                    gsp.HorizontalAlignment = System.Windows.HorizontalAlignment.Stretch;
                    gsp.VerticalAlignment   = System.Windows.VerticalAlignment.Stretch;
                    gsp.ResizeBehavior      = GridResizeBehavior.BasedOnAlignment;
                    this.DispUI.Children.Add(gsp);

                    Grid.SetColumn(gsp, (i * 2) + 1);
                }

                coldef = new ColumnDefinition();
                this.DispUI.ColumnDefinitions.Add(coldef);

                btn                     = new PathUIButton();
                btn.MinWidth            = 10;
                btn.HorizontalAlignment = System.Windows.HorizontalAlignment.Stretch;
                this.DispUI.Children.Add(btn);

                Grid.SetColumn(btn, ele.Length * 2);


                btn.Click += new RoutedEventHandler(DirectInput);
            }
        }