예제 #1
0
        public void GetFileName()
        {
            string apkfile = $"{Path.GetDirectoryName(Assembly.GetEntryAssembly().Location)}\\AppDatas\\";

            if (!Directory.Exists(apkfile))
            {
                Directory.CreateDirectory(apkfile);
            }

            var    files       = Directory.GetFiles(apkfile, "*.apk");
            int    decId       = 0;
            int    Heightapp   = 0;
            int    Len2        = 0;
            double WidthappLen = 10;

            foreach (var fullPath in files)
            {
                string filename = System.IO.Path.GetFileName(fullPath); //文件名
                                                                        //tring strWidth =System.IO.Path.GetFileName(fullPath.Substring(fullPath.LastIndexOf(@"\")));

                InstallButton btn = new InstallButton
                {
                    Name    = "Button" + decId++,
                    Content = SystemLanguageManager.Instance.ResourceManager.GetString("Install", SystemLanguageManager.Instance.CultureInfo) + "  " + filename, //按钮标题
                    Height  = 45,                                                                                                                                //按钮高度
                    //Width = (this.Width - 100) / 4,//按钮宽度
                    HorizontalAlignment = HorizontalAlignment.Left,
                    // Margin = new Thickness(WidthappLen + Len2++ * 10, Heightapp, 0, 0),//在界面上按钮的位置
                    Margin            = new Thickness(WidthappLen),
                    VerticalAlignment = VerticalAlignment.Top,
                    Visibility        = Visibility.Visible,
                    FileName          = filename,
                    Padding           = new Thickness(5, 2, 5, 2),
                };
                //WidthappLen += btn.Width;//下一个按钮递增的距离
                if (decId % 3 == 0)
                {                      //每行3个按钮
                    Heightapp  += 100; //每行按钮之间的高度
                    WidthappLen = 10;  //每行按钮第一个按钮离左边窗口的距离
                    Len2        = 0;   //下一个按钮递增的距离
                }
                if (_runningGroupIndex != -1)
                {
                    if (appState != -1)
                    {
                        btn.Click += new RoutedEventHandler(btnInstall_Click);
                        appState   = 0;
                    }
                    else
                    {
                        btn.Click += new RoutedEventHandler(btnUninstall_Click);
                        appState   = -1;
                    }
                }
                applist.Children.Add(btn);
            }
        }
예제 #2
0
        void System.Windows.Markup.IComponentConnector.Connect(int connectionId, object target)
        {
            switch (connectionId)
            {
            case 1:
                this.applist = ((System.Windows.Controls.WrapPanel)(target));
                return;

            case 2:
                this.btnInstall = ((Wx.Qunkong360.Wpf.Views.InstallButton)(target));
                return;

            case 3:
                this.pb = ((System.Windows.Controls.ProgressBar)(target));
                return;
            }
            this._contentLoaded = true;
        }