Ejemplo n.º 1
0
        private void CanUploadAppFile(object sender, System.Windows.Input.CanExecuteRoutedEventArgs e)
        {
            Windows.DependencyObject d       = sender as Windows.DependencyObject;
            AppFileManager           manager = (d == null ? null : d.GetValue(Windows.FrameworkElement.DataContextProperty) as AppFileManager);

            e.CanExecute = manager != null && manager.IsUploading == false;
        }
Ejemplo n.º 2
0
        public void OnImport()
        {
            //get ISE window
            Func <MainWindow> fnc = delegate() { return(Application.Current.Windows.Cast <MainWindow>().FirstOrDefault(wnd => wnd is MainWindow) as MainWindow); };

            window = Application.Current.Dispatcher.Invoke(fnc) as MainWindow;

            tabCollection = window.GetPowerShellTabCollection();

            appFileManager = new AppFileManager();
            appFileManager.Add(breakPointsFileName);
            appFileManager.Add(openFilesFileName);
            appFileManager.Add(debugLogfileName);

            solutionManager = new SolutionManager(window, appFileManager.Get(openFilesFileName).FullName);
            addonManager    = new AddOnManager(window, tabCollection);

            SetupMenu();
            SetupToolbar();

            //add handler to Event StateChanged
            var executionStateChangedEvent = tabCollection.SelectedPowerShellTab.GetType().GetEvent("ExecutionStateChanged", BindingFlags.NonPublic | BindingFlags.Instance);
            var handler = new EventHandler <PSInvocationStateChangedEventArgs>(StateChanged);

            executionStateChangedEvent.GetAddMethod(true).Invoke(tabCollection.SelectedPowerShellTab, new[] { handler });

            tabCollection.SelectedPowerShellTab.PropertyChanged += SelectedPowerShellTab_PropertyChanged_ImportBreakpoints;         //executed once
            tabCollection.SelectedPowerShellTab.PropertyChanged += solutionManager.SelectedPowerShellTab_PropertyChanged_OpenFiles; //executed once

            AppDomain.CurrentDomain.ProcessExit += CurrentDomain_ProcessExit_ExportBreakpoints;                                     //executed once
            AppDomain.CurrentDomain.ProcessExit += solutionManager.CurrentDomain_ProcessExit_SaveFiles;                             //executed once

            tabCollection.SelectedPowerShellTab.PropertyChanged += SelectedPowerShellTab_PropertyChanged;
        }
Ejemplo n.º 3
0
        private void OnUploadAppFile(object sender, System.Windows.Input.ExecutedRoutedEventArgs e)
        {
            Windows.DependencyObject d       = sender as Windows.DependencyObject;
            AppFileManager           manager = (d == null ? null : d.GetValue(Windows.FrameworkElement.DataContextProperty) as AppFileManager);

            System.Threading.ThreadPool.QueueUserWorkItem(AppFileUploadWorker, manager);
        }
Ejemplo n.º 4
0
    /** 从本地打包资源中提取信息 */
    protected void loadLinesFromResource()
    {
//		TextAsset txtAsset = Resources.Load (resPath) as TextAsset;
        TextAsset txtAsset = AppFileManager.LoadTextAsset(resPath);

        if (txtAsset == null)
        {
            Debug.LogError("在 Resource 目录里找不到相应文本文件:" + resPath);
            return;
        }
        lines = txtAsset.text.Split(lineStep, System.StringSplitOptions.None);
    }
Ejemplo n.º 5
0
 public void DeleteUserMedia(int id, UserIdentity user)
 {
     try {
         var media = MediaBiz.ReadSingle(m => m.Id == id && m.UserId == user.UserId);
         File.Delete(AppFileManager.GetMediaFilePath(media.FileName));
         MediaBiz.Remove(media);
         UnitOfWork.SaveChanges();
     }
     catch {
         throw;
     }
 }
        public bool TryGetProfileImageFilePath(int userId, ProfileImageSize profileImageSize, out string path, out string fileMime)
        {
            var userHasProfileImage = HasUserProfileImage(userId);

            if (userHasProfileImage)
            {
                path     = AppFileManager.GetUserProfileImagePath(userId, profileImageSize);
                fileMime = MimeHelper.GetMime(Path.GetExtension(path));
                return(true);
            }

            path     = null;
            fileMime = null;
            return(false);
        }
Ejemplo n.º 7
0
 private static void AppFileUploadWorker(object state)
 {
     try
     {
         AppFileManager manager = state as AppFileManager;
         System.Threading.ThreadPool.QueueUserWorkItem((param) =>
         {
             manager.SaveChange();
         }, null);
     }
     catch (Exception ex)
     {
         WebBrowserUtils.HtmlUtils.Fillers.WebFillManager.ShowMessageBox(ex.Message, "错误", MessageBoxButtons.OK, MessageBoxIcon.Error);
     }
 }
        public void CropUserProfileImages(int userId, ProfileImageCropInfoPM cropInfo)
        {
            var originalImagePath   = AppFileManager.GetUserProfileImagePath(userId, ProfileImageSize.Original);
            var extension           = Path.GetExtension(originalImagePath);
            var largeImagePath      = AppFileManager.CalculateUserProfileImagePath(userId, ProfileImageSize.Large, extension);
            var mediumImagePath     = AppFileManager.CalculateUserProfileImagePath(userId, ProfileImageSize.Medium, extension);
            var smallImagePath      = AppFileManager.CalculateUserProfileImagePath(userId, ProfileImageSize.Small, extension);
            var sourceImageCropArea = cropInfo.GetSourceImageCropArea();

            AppFileManager.RemoveUserProfileImages(userId, ProfileImageSize.Large, ProfileImageSize.Medium, ProfileImageSize.Small);
            ImageHelper.CropImage(originalImagePath, sourceImageCropArea, new Size(300, 300), largeImagePath);
            ImageHelper.CropImage(originalImagePath, sourceImageCropArea, new Size(80, 80), mediumImagePath);
            ImageHelper.CropImage(originalImagePath, sourceImageCropArea, new Size(40, 40), smallImagePath);
            File.Delete(originalImagePath);
            ProfileBiz.SetUserProfile(userId, ProfileKeyValueType.IsProfileImageSet, "1");
            UnitOfWork.SaveChanges();
        }
Ejemplo n.º 9
0
        private void OnRemoveAppFile(object sender, System.Windows.Input.ExecutedRoutedEventArgs e)
        {
            AppFileInfo file = e.Parameter as AppFileInfo;

            Windows.DependencyObject d       = sender as Windows.DependencyObject;
            AppFileManager           manager = null;

            while (d != null && manager == null)
            {
                manager = (d == null ? null : d.GetValue(Windows.FrameworkElement.DataContextProperty) as AppFileManager);
                d       = System.Windows.Media.VisualTreeHelper.GetParent(d);
            }
            if (manager != null)
            {
                manager.Items.Remove(file);
            }
        }
Ejemplo n.º 10
0
 //设置UI数据
 public void SetUI()
 {
     if (null != this.card)
     {
         this.icon.sprite = AppFileManager.LoadSprite(this.card.iconPath);
         this.type.sprite = AppFileManager.LoadSprite(this.card.typeSprite);
         this.type.SetNativeSize();
         if (this.card.type < 5)
         {
             this.number.gameObject.SetActive(true);
             this.number.sprite = AppFileManager.LoadSprite(this.card.numberSprite);
         }
         else
         {
             this.number.gameObject.SetActive(false);
         }
     }
 }
 public void SaveUserOriginalProfileImage(UserIdentity user, Stream inputStream, out int imageWidth, out int imageHeight)
 {
     AppDirectoryManager.CreateUserProfileImageDirectory(user.UserId);
     using (var image = ValidateFileAndGenerateImage(inputStream)) {
         string previousOriginalImagePath;
         var    imageFormat          = ImageHelper.GetImageFormat(image);
         var    extension            = ImageHelper.GetImageFormatFileExtension(imageFormat);
         var    newOriginalImagePath = AppFileManager.CalculateUserProfileImagePath(user.UserId, ProfileImageSize.Original, extension);
         if (AppFileManager.TryGetUserProfileImagePath(user.UserId, ProfileImageSize.Original, out previousOriginalImagePath))
         {
             if (previousOriginalImagePath != newOriginalImagePath)
             {
                 File.Delete(previousOriginalImagePath);
             }
         }
         image.Save(newOriginalImagePath, imageFormat);
         imageWidth  = image.Width;
         imageHeight = image.Height;
     }
 }
Ejemplo n.º 12
0
        private void OnAddAppFile(object sender, System.Windows.Input.ExecutedRoutedEventArgs e)
        {
            OpenFileDialog dialog = new OpenFileDialog();

            dialog.Title       = "选择文件";
            dialog.Filter      = "(所有文件)|*.*";
            dialog.Multiselect = true;
            DialogResult result = dialog.ShowDialog();

            if (result == DialogResult.OK)
            {
                Windows.DependencyObject d       = sender as Windows.DependencyObject;
                AppFileManager           manager = (d == null ? null : d.GetValue(Windows.FrameworkElement.DataContextProperty) as AppFileManager);
                try
                {
                    foreach (string name in dialog.FileNames)
                    {
                        AppFileInfo fileInfo = new AppFileInfo()
                        {
                            Version    = FileHelper.GetCurrentVersion(),
                            FileName   = name,
                            Status     = FileStatus.New,
                            Enterprise = manager.SelectedEnterprise
                        };
                        int index = manager.Items.IndexOf(fileInfo);
                        if (index > -1)
                        {
                            AppFileInfo current = manager.Items[index] as AppFileInfo;
                            current.FileName = name;
                            continue;
                        }
                        manager.Items.Add(fileInfo);
                    }
                }
                catch (Exception ex)
                {
                    MessageBox.Show(ex.Message, "错误", MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
            }
        }
 public void GetOriginalProfileImageFilePath(int userId, out string path, out string fileMime)
 {
     path     = AppFileManager.GetUserProfileImagePath(userId, ProfileImageSize.Original);
     fileMime = MimeHelper.GetMime(Path.GetExtension(path));
 }