Example #1
0
        protected override void OnViewStateChanged(string key)
        {
            #region LoadList

            if (key == "LoadList")
            {
                bool isRefrsh = Convert.ToBoolean(ViewData["IsRefresh"]);

                if (isRefrsh)
                {
                    LoadingControlInterface lc = LoadingControl.CreateLoading(Resources.DataLoading);

                    Thread asyncDataThread = new Thread(delegate { AsyncGetViewData(lc); });
                    asyncDataThread.IsBackground = true;
                    asyncDataThread.Start();

                    lc.ShowLoading(true);

                    if (lc.Abort)
                    {
                        asyncDataThread.Abort();
                    }
                }
                else
                {
                    try
                    {
                        FriendsListResponse newFriendsListResponse = Globals.BaseLogic.LoadFriendsList(false, false);

                        if (newFriendsListResponse != null)
                        {
                            FriendsListResponse additionalFrendListResponse = LoadAdditionalDataFromCache();

                            ViewData["OriginalFrendListResponse"]   = newFriendsListResponse;
                            ViewData["AdditionalFrendListResponse"] = additionalFrendListResponse;

                            FillListModel(newFriendsListResponse, additionalFrendListResponse, string.Empty);

                            Globals.BaseLogic.ICommunicationLogic.ClearImagesInDictionary();
                        }
                        else
                        {
                            view.Model.Clear();
                        }

                        ViewData["ListID"] = Globals.BaseLogic.IDataLogic.GetUid(); // сохраняем ID пользователя для которого был построен список

                        view.UpdateView("LoadListResponse");
                    }
                    catch
                    {
                        //
                    }
                }
            }

            #endregion

            #region ReloadList

            if (key == "ReloadList")
            {
                view.UpdateView("ReloadListResponse");
            }

            #endregion

            #region RefreshList

            if (key == "RefreshList")
            {
                view.UpdateView("RefreshListResponse");
            }

            #endregion

            #region GoToSendMessage

            if (key == "GoToSendMessage")
            {
                MasterForm.Navigate <SendMessageController>("FriendList", ViewData["Uid"]);
            }

            #endregion

            #region FilterFriendList

            if (key == "FilterFriendList")
            {
                using (new WaitWrapper(false))
                {
                    if ((string)ViewData["FilterString"] == string.Empty)
                    {
                        ViewData["OriginalModel"] = OriginalModel;
                        view.UpdateView("ResetState");
                    }
                    else
                    {
                        FillListModel((FriendsListResponse)ViewData["OriginalFrendListResponse"], (FriendsListResponse)ViewData["AdditionalFrendListResponse"], (string)ViewData["FilterString"]);
                        ViewData["OriginalModel"] = view.Model;
                        view.UpdateView("ResetState");
                    }
                }
            }

            #endregion

            #region CallNumber

            if (key == "CallNumber")
            {
                try
                {
                    if (ViewData["ABTelephone"] != null)
                    {
                        Phone phone = new Phone();

                        phone.Talk((string)ViewData["ABTelephone"], true);
                    }
                }
                catch
                {
                    // CallNumberResponseMessage_Unsuccess
                    ViewData["CallNumberResponseMessage"] = Resources.CallNumberResponseMessage_Unsuccess;
                    view.UpdateView("CallNumberResponse");
                }
            }

            #endregion

            #region SaveNumber

            if (key == "SaveNumber")
            {
                using (OutlookSession os = new OutlookSession())
                {
                    try
                    {
                        if (ViewData["ABFirstName"] != null && ViewData["ABLastName"] != null && ViewData["ABTelephone"] != null)
                        {
                            Contact contact = null;

                            foreach (var val in os.Contacts.Items)
                            {
                                if (val.FirstName == (string)ViewData["ABFirstName"] && val.LastName == (string)ViewData["ABLastName"])
                                {
                                    contact = val;
                                }
                            }

                            if (contact == null)
                            {
                                contact = new Contact();

                                contact.FirstName = (string)ViewData["ABFirstName"];
                                contact.LastName  = (string)ViewData["ABLastName"];

                                os.Contacts.Items.Add(contact);
                            }

                            contact.MobileTelephoneNumber = (string)ViewData["ABTelephone"];

                            if (ViewData["ABBD"] != null)
                            {
                                contact.Birthday = (DateTime)ViewData["ABBD"];
                            }

                            if (ViewData["ImagePath"] != null)
                            {
                                contact.SetPicture((string)ViewData["ImagePath"]);
                            }

                            contact.Update();

                            ViewData["SaveNumberResponseMessage"] = Resources.SaveNumberResponseMessage_Succsess;
                        }
                        else
                        {
                            throw new Exception();
                        }
                    }
                    catch (Exception)
                    {
                        ViewData["SaveNumberResponseMessage"] = Resources.SaveNumberResponseMessage_Unsuccess;
                    }
                }

                view.UpdateView("SaveNumberResponse");

                //contact.B

                //contact.MobileTelephoneNumber

                //using (new WaitWrapper(false))
                //{
                //    if ((string)ViewData["FilterString"] == string.Empty)
                //    {
                //        ViewData["OriginalModel"] = OriginalModel;
                //        view.UpdateView("ResetState");
                //    }
                //    else
                //    {
                //        FillListModel((FriendsListResponse) ViewData["OriginalFrendListResponse"], null, (string) ViewData["FilterString"]);
                //        ViewData["OriginalModel"] = view.Model;
                //        view.UpdateView("ResetState");
                //    }
                //}
            }

            #endregion


            #region GoToNews

            if (key == "GoToNews")
            {
                MasterForm.Navigate <StatusUpdatesListController>();
            }

            #endregion

            #region GoToMessages

            if (key == "GoToMessages")
            {
                MasterForm.Navigate <MessagesChainsListController>();
            }

            #endregion

            #region GoToPhotos

            if (key == "GoToPhotos")
            {
                MasterForm.Navigate <ShareController>();
            }

            #endregion

            #region GoToExtras

            if (key == "GoToExtras")
            {
                MasterForm.Navigate <ExtraController>();
            }

            #endregion



            #region ListActualization

            if (key == "ListActualization")
            {
                string currentID = Globals.BaseLogic.IDataLogic.GetUid();
                string listID    = (string)ViewData["ListID"];

                if (currentID != listID)
                {
                    ViewData["IsRefresh"] = false;

                    OnViewStateChanged("LoadList");
                }
            }

            #endregion

            #region GoToSettings

            if (key == "GoToSettings")
            {
                using (new WaitWrapper(false))
                {
                    Configuration.LoadConfigSettings();
                    MasterForm.Navigate <SettingsController>();
                }
            }

            #endregion

            #region GoToUserData

            if (key == "GoToUserData")
            {
                using (new WaitWrapper(false))
                {
                    MasterForm.Navigate <UserDataController>();
                }
            }

            #endregion

            #region GoToAbout

            if (key == "GoToAbout")
            {
                using (new WaitWrapper(false))
                {
                    MasterForm.Navigate <AboutController>();
                }
            }

            #endregion

            #region GoToExit

            if (key == "GoToExit")
            {
                using (new WaitWrapper(false))
                {
                    if (SystemConfiguration.DeleteOnExit)
                    {
                        Globals.BaseLogic.IDataLogic.ClearPass();
                    }
                    Application.Exit();
                }
            }

            #endregion

            if (key == "GoGoToLogin")
            {
                MasterForm.Navigate <LoginController>();
            }
        }
Example #2
0
        protected override void OnViewStateChanged(string key)
        {
            #region LoadList

            if (key == "LoadList")
            {
                bool isRefrsh = Convert.ToBoolean(ViewData["IsRefresh"]);

                if (isRefrsh)
                {
                    LoadingControlInterface lc = LoadingControl.CreateLoading(Resources.DataLoading);

                    Thread asyncDataThread = new Thread(delegate { AsyncGetViewData(lc); });
                    asyncDataThread.IsBackground = true;
                    asyncDataThread.Start();

                    lc.ShowLoading(true);

                    if (lc.Abort)
                    {
                        asyncDataThread.Abort();
                    }
                }
                else
                {
                    try
                    {
                        PhotosCommentsResponse newPhotosCommentsResponse = Globals.BaseLogic.LoadPhotosComments(25, false, false); // комментарии

                        if (newPhotosCommentsResponse != null)
                        {
                            FillListModel(newPhotosCommentsResponse);

                            Globals.BaseLogic.ICommunicationLogic.ClearImagesInDictionary();
                        }
                        else
                        {
                            view.Model.Clear();
                        }

                        ViewData["ListID"] = Globals.BaseLogic.IDataLogic.GetUid(); // сохраняем ID пользователя для которого был построен список

                        view.UpdateView("LoadListResponse");
                    }
                    catch
                    {
                        //
                    }
                }
            }

            #endregion

            #region ReloadList

            if (key == "ReloadList")
            {
                view.UpdateView("ReloadListResponse");
            }

            #endregion

            #region RefreshList

            if (key == "RefreshList")
            {
                view.UpdateView("RefreshListResponse");
            }

            #endregion

            #region GoToStatuses

            if (key == "GoToStatuses")
            {
                MasterForm.Navigate <StatusUpdatesListController>();
            }

            #endregion

            #region GoToSendMessage

            if (key == "GoToSendMessage")
            {
                MasterForm.Navigate <SendMessageController>("PhotoComments", ViewData["SenderID"], ViewData["SenderName"]);
            }

            #endregion

            #region GoDetailedView

            if (key == "GoDetailedView")
            {
                int    uid           = Convert.ToInt32((string)ViewData["Uid"]);
                int    photoID       = Convert.ToInt32((string)ViewData["PhotoID"]);
                string largePhotoURL = (string)ViewData["LargePhotoURL"];

                if (uid > 0 && photoID > 0 && !string.IsNullOrEmpty(largePhotoURL))
                {
                    MasterForm.Navigate <ImageCommentController>("Load", uid.ToString(), photoID.ToString(), largePhotoURL);
                }
            }

            #endregion

            if (key == "NewComment")
            {
                int uid     = Convert.ToInt32((string)ViewData["Uid"]);
                int photoID = Convert.ToInt32((string)ViewData["PhotoID"]);
                var url     = (string)ViewData["LargePhotoURL"];

                if (uid > 0 && photoID > 0)
                {
                    MasterForm.Navigate <SendCommentController>(uid.ToString(), photoID.ToString(), url);
                }
            }


            #region GoToMessages

            if (key == "GoToMessages")
            {
                MasterForm.Navigate <MessagesChainsListController>();
            }

            #endregion

            #region GoToFriends

            if (key == "GoToFriends")
            {
                MasterForm.Navigate <FriendsListController>();
            }

            #endregion

            #region GoToPhotos

            if (key == "GoToPhotos")
            {
                MasterForm.Navigate <ShareController>();
            }

            #endregion

            #region GoToExtras

            if (key == "GoToExtras")
            {
                MasterForm.Navigate <ExtraController>();
            }

            #endregion



            #region ListActualization

            if (key == "ListActualization")
            {
                string currentID = Globals.BaseLogic.IDataLogic.GetUid();
                string listID    = (string)ViewData["ListID"];

                if (currentID != listID)
                {
                    ViewData["IsRefresh"] = false;

                    OnViewStateChanged("LoadList");
                }
            }

            #endregion

            if (key == "GoGoToLogin")
            {
                MasterForm.Navigate <LoginController>();
            }
        }
Example #3
0
        protected override void OnViewStateChanged(string key)
        {
            #region GetCurrentStatus

            if (key == "GetCurrentStatus")
            {
                try
                {
                    User currentUser = Globals.BaseLogic.GetAuthorizedUserInfo(true, false);
                    ViewData["LastStatus"] = currentUser.Status;
                }
                catch
                {
                    //
                }
            }

            #endregion

            #region LoadList

            if (key == "LoadList")
            {
                bool isRefrsh        = Convert.ToBoolean(ViewData["IsRefresh"]);
                bool allowReloadData = ViewData["AllowReloadData"] == null || Convert.ToBoolean(ViewData["AllowReloadData"]);

                ViewData["AllowReloadData"] = null;

                if (isRefrsh)
                {
                    if (allowReloadData)
                    {
                        LoadingControlInterface lc = LoadingControl.CreateLoading(Resources.DataLoading);

                        var asyncDataThread = new Thread(() => AsyncGetViewData(lc))
                        {
                            IsBackground = true
                        };
                        asyncDataThread.Start();

                        lc.ShowLoading(true);

                        if (lc.Abort)
                        {
                            asyncDataThread.Abort();
                        }
                    }
                }
                else
                {
                    try
                    {
                        ActivityResponse newActivityResponse = Globals.BaseLogic.LoadUserActivityDataList(25, false, false);

                        if (newActivityResponse != null)
                        {
                            FillListModel(newActivityResponse, true);

                            Globals.BaseLogic.ICommunicationLogic.ClearImagesInDictionary();
                        }
                        else
                        {
                            view.Model.Statuses.Clear();
                        }

                        ViewData["ListID"] = Globals.BaseLogic.IDataLogic.GetUid(); // сохраняем ID пользователя для которого был построен список

                        view.UpdateView("LoadListResponse");
                    }
                    catch
                    {
                        //
                    }
                    finally
                    {
                        //ViewData["AllowReloadData"] = null;
                    }
                }

                //ViewData["AllowReloadData"] = null;
            }

            #endregion

            #region ReloadList

            if (key == "ReloadList")
            {
                view.UpdateView("ReloadListResponse");
            }

            #endregion

            #region RefreshList

            if (key == "RefreshList")
            {
                view.UpdateView("RefreshListResponse");
            }

            #endregion


            #region key == "LoadPhotoFromDisk"

            if (key == "LoadPhotoFromDisk")
            {
                try
                {
                    string fileName = SystemConfiguration.AppInstallPath + @"\Cache\Files\image.jpg";

                    //IImage newIImage;
                    //System.Drawing.Size imageSize;

                    //int displayAreaWidth = (int)view.ViewData["DisplayAreaWidth"];
                    //int displayAreaHeight = (int)view.ViewData["DisplayAreaHeight"];
                    //displayAreaWidth -= UISettings.CalcPix(10);
                    //displayAreaHeight -= UISettings.CalcPix(10);

                    SelectPictureDialog newSelectPictureDialog = new SelectPictureDialog();
                    newSelectPictureDialog.Filter = Resources.UploadPhoto_Controller_newOpenFileDialog_Filter;

                    if (newSelectPictureDialog.ShowDialog() == System.Windows.Forms.DialogResult.OK)
                    {
                        if (File.Exists(newSelectPictureDialog.FileName))
                        {
                            int maxLinearSize;

                            switch (Configuration.ImageMaxSize)
                            {
                            case ImageMaxSizeTypes.Res640X480:
                                maxLinearSize = 640;
                                break;

                            default:
                                maxLinearSize = ImageHelper.ImageMaxLinearSize;
                                break;
                            }

                            ImageHelper.PreProcessImageFile(newSelectPictureDialog.FileName, fileName, maxLinearSize);

                            // ???
                            //Globals.BaseLogic.IDataLogic.SetUplPhtViewPhtRtnAnglZero();

                            //newIImage = (IImage)ViewData["Image"];
                            //ViewData["Image"] = ViewData["EmptyImage"];

                            //if (newIImage != null)
                            //{
                            //    Marshal.FinalReleaseComObject(newIImage);
                            //}

                            //ImageHelper.SaveScaledImage((string)ViewData["ImageFile"], (string)ViewData["ThumbImageFile"], (int)Math.Min(displayAreaWidth, displayAreaHeight), Globals.BaseLogic.IDataLogic.GetUplPhtViewPhtRtnAngl());

                            //ImageHelper.LoadImageFromFile((string)ViewData["ThumbImageFile"], out newIImage, out imageSize);

                            //ViewData["Image"] = newIImage;
                            //ViewData["ImageWidth"] = imageSize.Width;
                            //ViewData["ImageHeight"] = imageSize.Height;

                            // ???
                            //Globals.BaseLogic.IDataLogic.SetUplPhtViewHasMdfPht(true);

                            MasterForm.Navigate <SharePhotoController>();
                        }
                    }
                }
                catch (OutOfMemoryException ex)
                {
                    ViewData["ResponseMessage"] = Resources.OutOfMemory;

                    DebugHelper.WriteLogEntry("ShareController.LoadPhotoFromDisk OutOfMemoryException Message: " + ex.Message);
                    DebugHelper.WriteLogEntry("ShareController.LoadPhotoFromDisk OutOfMemoryException StackTrace: " + ex.StackTrace);
                }
                catch (Exception ex)
                {
                    ViewData["ResponseMessage"] = Resources.ErrorMessages_OperationIsDoneUnsuccsessfully;

                    DebugHelper.WriteLogEntry("ShareController.LoadPhotoFromDisk Exception Message: " + ex.Message);
                    DebugHelper.WriteLogEntry("ShareController.LoadPhotoFromDisk Exception StackTrace: " + ex.StackTrace);
                }
                finally
                {
                    view.UpdateView("MainResponse");
                }
            }

            #endregion

            #region key == "SnapPhotoWithinCamera"

            if (key == "SnapPhotoWithinCamera")
            {
                try
                {
                    string fileName = SystemConfiguration.AppInstallPath + @"\Cache\Files\image.jpg";

                    //IImage newIImage;
                    //System.Drawing.Size imageSize;

                    //int displayAreaWidth = (int)view.ViewData["DisplayAreaWidth"];
                    //int displayAreaHeight = (int)view.ViewData["DisplayAreaHeight"];
                    //displayAreaWidth -= UISettings.CalcPix(10);
                    //displayAreaHeight -= UISettings.CalcPix(10);

                    CameraCaptureDialog newCameraCaptureDialog = new Microsoft.WindowsMobile.Forms.CameraCaptureDialog();
                    newCameraCaptureDialog.Mode = Microsoft.WindowsMobile.Forms.CameraCaptureMode.Still;

                    // На некоторых телефонах в камере кнопка "Отмена" может не обрабатываться корректно.
                    // Надатие на эту кнопку на Philips приводит к исключению, его и игнорируем.
                    DialogResult result = DialogResult.Cancel;
                    try
                    {
                        result = newCameraCaptureDialog.ShowDialog();
                    }
                    catch (InvalidOperationException)
                    {
                        result = DialogResult.Cancel;
                    }

                    if (result == System.Windows.Forms.DialogResult.OK)
                    {
                        if (File.Exists(newCameraCaptureDialog.FileName))
                        {
                            int maxLinearSize;

                            switch (Configuration.ImageMaxSize)
                            {
                            case ImageMaxSizeTypes.Res640X480:
                                maxLinearSize = 640;
                                break;

                            default:
                                maxLinearSize = ImageHelper.ImageMaxLinearSize;
                                break;
                            }

                            ImageHelper.PreProcessImageFile(newCameraCaptureDialog.FileName, fileName, maxLinearSize);

                            // ???
                            //Globals.BaseLogic.IDataLogic.SetUplPhtViewPhtRtnAnglZero();

                            //newIImage = (IImage)ViewData["Image"];
                            //ViewData["Image"] = ViewData["EmptyImage"];

                            //if (newIImage != null)
                            //{
                            //    Marshal.FinalReleaseComObject(newIImage);
                            //}

                            //ImageHelper.SaveScaledImage((string)ViewData["ImageFile"], (string)ViewData["ThumbImageFile"], (int)Math.Min(displayAreaWidth, displayAreaHeight), Globals.BaseLogic.IDataLogic.GetUplPhtViewPhtRtnAngl());

                            //ImageHelper.LoadImageFromFile((string)ViewData["ThumbImageFile"], out newIImage, out imageSize);

                            //ViewData["Image"] = newIImage;
                            //ViewData["ImageWidth"] = imageSize.Width;
                            //ViewData["ImageHeight"] = imageSize.Height;

                            //Globals.BaseLogic.IDataLogic.SetUplPhtViewHasMdfPht(true);

                            File.Delete(newCameraCaptureDialog.FileName);

                            MasterForm.Navigate <SharePhotoController>();
                        }
                    }
                }
                catch (OutOfMemoryException ex)
                {
                    ViewData["ResponseMessage"] = Resources.OutOfMemory;

                    DebugHelper.WriteLogEntry("ShareController.SnapPhotoWithinCamera OutOfMemoryException Message: " + ex.Message);
                    DebugHelper.WriteLogEntry("ShareController.SnapPhotoWithinCamera OutOfMemoryException StackTrace: " + ex.StackTrace);
                }
                catch (Exception ex)
                {
                    ViewData["ResponseMessage"] = Resources.ErrorMessages_OperationIsDoneUnsuccsessfully;

                    DebugHelper.WriteLogEntry("ShareController.SnapPhotoWithinCamera Exception Message: " + ex.Message);
                    DebugHelper.WriteLogEntry("ShareController.SnapPhotoWithinCamera Exception StackTrace: " + ex.StackTrace);
                }
                finally
                {
                    view.UpdateView("MainResponse");
                }
            }

            #endregion



            #region ChangeStatus

            if (key == "ChangeStatus")
            {
                MasterForm.Navigate <ChangeStatusController>();
            }

            #endregion



            #region переходы

            if (key == "GoToNews")
            {
                MasterForm.Navigate <StatusUpdatesListController>();
            }

            if (key == "GoToMessages")
            {
                MasterForm.Navigate <MessagesChainsListController>();
            }

            if (key == "GoToFriends")
            {
                MasterForm.Navigate <FriendsListController>();
            }

            if (key == "GoToExtras")
            {
                MasterForm.Navigate <ExtraController>();
            }

            #endregion



            #region ListActualization

            if (key == "ListActualization")
            {
                ViewData["AllowReloadData"] = null;

                string currentID = Globals.BaseLogic.IDataLogic.GetUid();
                string listID    = (string)ViewData["ListID"];

                if (currentID != listID)
                {
                    ViewData["IsRefresh"] = false;
                    OnViewStateChanged("LoadList");
                }
            }

            #endregion

            #region UserActivityCacheModification

            if (key == "UserActivityCacheModification")
            {
                if (Configuration.DataRenewType != DataRenewVariants.UpdateAlways)
                {
                    Globals.BaseLogic.UpdateCacheOfUserActivities((string)view.ViewData["ReceivedStatus"],
                                                                  Resources.Empty_Status, Resources.MessageI);
                    OnViewStateChanged("LoadList");
                }
            }

            #endregion

            if (key == "GoGoToLogin")
            {
                MasterForm.Navigate <LoginController>();
            }
        }
Example #4
0
        protected override void OnViewStateChanged(string key)
        {
            #region Check AutoLogin

            if (key == "CheckAutoLogin")
            {
                try
                {
                    using (new WaitWrapper())
                    {
                        Globals.BaseLogic.AutoLogin();
                    }

                    Initialize("LoginSuccess");
                }
                catch (VKException ex)
                {
                    string message = ExceptionTranslation.TranslateException(ex);

                    if (!string.IsNullOrEmpty(message))
                    {
                        if (ex.LocalizedMessage == ExceptionMessage.IncorrectLoginOrPassword)
                        {
                            Globals.BaseLogic.IDataLogic.SetToken(string.Empty);

                            MasterForm.Navigate <LoginController>("IncorrectLoginOrPassword");
                        }
                        else if (ex.LocalizedMessage == ExceptionMessage.NoSavedToken)
                        {
                            MasterForm.Navigate <LoginController>();
                        }
                        else if (ex.LocalizedMessage == ExceptionMessage.UnknownError)
                        {
                            MasterForm.Navigate <LoginController>("UnknownError");
                        }
                        else
                        {
                            Initialize("LoginSuccess");
                        }
                    }
                }
                catch (OutOfMemoryException)
                {
                    DialogControl.ShowQuery(Resources.OutOfMemory, DialogButtons.OK);
                }
            }

            #endregion

            #region InitializeSettings

            else if (key == "InitializeSettings")
            {
                using (new WaitWrapper())
                {
                    // если приложение запущено при остановленном нотификаторе, то очищаем кэш
                    // это единственное место, где осуществляется это действие

                    //if (!Interprocess.IsServiceRunning)
                    {
                        Cache.DeleteEntryFromCache(string.Empty, "ShortActivityResponse");
                        Cache.DeleteEntryFromCache(string.Empty, "ShortUpdatesPhotosResponse");
                        Cache.DeleteEntryFromCache(string.Empty, "ShortWallResponse");
                        Cache.DeleteEntryFromCache(string.Empty, "ShortPhotosCommentsRespounse");
                    }

                    #region SetShowEventButtons

                    if (Globals.BaseLogic.IDataLogic.GetShowButtonMessages())
                    {
                        Globals.BaseLogic.IDataLogic.SetShowButtonMessages();
                    }

                    if (Globals.BaseLogic.IDataLogic.GetShowButtonComments())
                    {
                        Globals.BaseLogic.IDataLogic.SetShowButtonComments();
                    }

                    if (Globals.BaseLogic.IDataLogic.GetShowButtonFriends())
                    {
                        Globals.BaseLogic.IDataLogic.SetShowButtonFriends();
                    }

                    if (Globals.BaseLogic.IDataLogic.GetShowButtonFriendsNews())
                    {
                        Globals.BaseLogic.IDataLogic.SetShowButtonFriendsNews();
                    }

                    if (Globals.BaseLogic.IDataLogic.GetShowButtonFriendsPhotos())
                    {
                        Globals.BaseLogic.IDataLogic.SetShowButtonFriendsPhotos();
                    }

                    if (Globals.BaseLogic.IDataLogic.GetShowButtonWallMessages())
                    {
                        Globals.BaseLogic.IDataLogic.SetShowButtonWallMessages();
                    }

                    #endregion

                    Configuration.LoadConfigSettings();
                    Configuration.SaveConfigSettings();

                    #region старт/стоп нотификатора

                    if (Configuration.BackgroundNotification != BackgroundNotificationTypes.Off)
                    {
                        Globals.BaseLogic.IDataLogic.SetNtfAutorun();

                        OnViewStateChanged("StartNotificator");
                    }
                    else
                    {
                        OnViewStateChanged("StopNotificator");

                        Globals.BaseLogic.IDataLogic.DelNtfAutorun();
                    }

                    OnViewStateChanged("StopNotificator");

                    #endregion
                }
            }

            #endregion

            #region StartNotificator

            if (key == "StartNotificator")
            {
                if (!string.IsNullOrEmpty(Globals.BaseLogic.IDataLogic.GetToken()))
                {
                    //// запуск службы нотификатора
                    //try
                    //{
                    //    if (!Interprocess.IsServiceRunning)
                    //    {
                    //        Interprocess.StartService();
                    //    }
                    //}
                    //catch (Exception ex)
                    //{
                    //    ViewData["NotificatorStartError"] = ex.Message;
                    //    view.UpdateView("NotificatorStartFail");
                    //}
                }
                else
                {
                    DialogControl.ShowQuery(Resources.MainView_Button_NotificatorCantStart, DialogButtons.OK);
                }
            }

            #endregion

            #region StopNotificator

            if (key == "StopNotificator")
            {
                // остановка службы нотификатора
                //Interprocess.StopService();
            }

            #endregion

            #region GetMainViewData

            if (key == "GetMainViewData")
            {
                LoadingControlInterface lc = LoadingControl.CreateLoading(Resources.DataLoading);

                Thread asyncDataThread = new Thread(delegate { AsyncGetMainViewData(lc); });

                asyncDataThread.IsBackground = true;
                asyncDataThread.Start();

                lc.ShowLoading(false);

                if (lc.Abort)
                {
                    asyncDataThread.Abort();
                }
            }

            #endregion

            #region GoToUploadPhoto

            if (key == "GoToUploadPhoto")
            {
                MasterForm.Navigate <UploadPhotoController>();
            }

            #endregion

            #region AutoUpdate

            if (key == "AutoUpdate")
            {
                var updateHelper = new UpdateHelper((UIViewBase)ViewData["MainViewThis"]);

                updateHelper.CheckNewVersion();
            }

            #endregion

            #region ChangeStatus

            if (key == "ChangeStatus")
            {
                MasterForm.Navigate <ChangeStatusController>((string)ViewData["UserStatus"]);
            }

            #endregion

            #region CheckNewEvents

            if (key == "CheckNewEvents")
            {
                // проверка флага необходимости обновления списка событий
                if (Globals.BaseLogic.IDataLogic.GetRefreshEventsFlag() == "1")
                {
                    try
                    {
                        // загрузка событий
                        EventsGetResponse newEventsGetResponse = Globals.BaseLogic.EventsGet(false, false, false);

                        ViewData["MessagesCount"]      = string.Empty;
                        ViewData["CommentsCount"]      = string.Empty;
                        ViewData["FriendsCount"]       = string.Empty;
                        ViewData["FriendsNewsCount"]   = string.Empty;
                        ViewData["FriendsPhotosCount"] = string.Empty;
                        ViewData["WallCount"]          = string.Empty;

                        foreach (Event newEvent in newEventsGetResponse.events)
                        {
                            switch (newEvent.type)
                            {
                            case EventType.Messages:
                                ViewData["MessagesCount"] = newEvent.number.ToString();
                                break;

                            case EventType.Comments:
                                ViewData["CommentsCount"] = newEvent.number.ToString();
                                break;

                            case EventType.Friends:
                                ViewData["FriendsCount"] = newEvent.number.ToString();
                                break;

                            case EventType.FriendsNews:
                                ViewData["FriendsNewsCount"] = newEvent.number.ToString();
                                break;

                            case EventType.FriendsPhotos:
                                ViewData["FriendsPhotosCount"] = newEvent.number.ToString();
                                break;

                            case EventType.WallMessages:
                                ViewData["WallCount"] = newEvent.number.ToString();
                                break;
                            }
                        }

                        view.UpdateView("RefreshEventsInfo");
                    }
                    catch (Exception ex)
                    {
                        //
                    }
                }
            }

            #endregion



            #region GoToNews

            if (key == "GoToNews")
            {
                MasterForm.Navigate <StatusUpdatesListController>();
            }

            #endregion

            #region GoToFriends

            if (key == "GoToFriends")
            {
                MasterForm.Navigate <FriendsListController>();
            }

            #endregion

            #region GoToMessages

            if (key == "GoToMessages")
            {
                MasterForm.Navigate <MessagesChainsListController>();
            }

            #endregion

            #region GoToExtras

            if (key == "GoToExtras")
            {
                MasterForm.Navigate <ExtraController>();
            }

            #endregion
        }
Example #5
0
        protected override void OnViewStateChanged(string key)
        {
            #region LoadList

            if (key == "LoadList")
            {
                bool isRefrsh = Convert.ToBoolean(ViewData["IsRefresh"]);

                if (isRefrsh)
                {
                    LoadingControlInterface lc = LoadingControl.CreateLoading(Resources.DataLoading);

                    Thread asyncDataThread = new Thread(delegate { AsyncGetViewData(lc); });
                    asyncDataThread.IsBackground = true;
                    asyncDataThread.Start();

                    lc.ShowLoading(true);

                    if (lc.Abort)
                    {
                        asyncDataThread.Abort();
                    }
                }
                else
                {
                    try
                    {
                        int uid = Convert.ToInt32((string)ViewData["UserID"]);

                        MessUserCorrespondence newMessUserCorrespondence = Globals.BaseLogic.RefreshUserCorrespondence(uid, false, false, null);

                        if (newMessUserCorrespondence != null)
                        {
                            FillListModel(newMessUserCorrespondence);
                        }
                        else
                        {
                            //view.Model.Clear();
                        }

                        view.UpdateView("LoadListResponse");
                    }
                    catch
                    {
                        //
                    }
                }
            }

            #endregion

            #region ReloadList

            if (key == "ReloadList")
            {
                view.UpdateView("ReloadListResponse");
            }

            #endregion

            #region RefreshList

            if (key == "RefreshList")
            {
                view.UpdateView("RefreshListResponse");
            }

            #endregion

            #region SentMessage

            if (key == "SentMessage")
            {
                /*
                 * bool result = false;
                 *
                 * int uid = Convert.ToInt32((string)ViewData["UserID"]);
                 * string text = (string)ViewData["MessageDraftOutput"];
                 *
                 * try
                 * {
                 *  // проверка на Empty во вьюхе
                 *  result = Globals.BaseLogic.SendMessage(uid, text, false);
                 * }
                 * catch (VKException ex)
                 * {
                 *  string error = ExceptionTranslation.TranslateException(ex);
                 *
                 *  ViewData["SentMessageResponseMessage"] = error;
                 *  ViewData["MessageIsSent"] = "false";
                 *
                 *  view.UpdateView("SentMessageResponse");
                 *
                 *  if (ex.LocalizedMessage.Equals(ExceptionMessage.IncorrectLoginOrPassword))
                 *  {
                 *      Globals.BaseLogic.IDataLogic.SetToken(string.Empty);
                 *      MasterForm.Navigate<LoginController>();
                 *  }
                 *
                 *  return;
                 * }
                 * catch (OutOfMemoryException)
                 * {
                 *  ViewData["SentMessageResponseMessage"] = Resources.OutOfMemory;
                 *  ViewData["MessageIsSent"] = "false";
                 *
                 *  view.UpdateView("SentMessageResponse");
                 *  return;
                 * }
                 *
                 * if (result)
                 * {
                 *  DraftMessagesDataIO.DeleteDraftMessage(uid);
                 *
                 *  ViewData["SentMessageResponseMessage"] = Resources.MessagesList_Controller_Messages_MessageSentSuccessfully;
                 *  ViewData["MessageIsSent"] = "true";
                 * }
                 * else
                 * {
                 *  ViewData["SentMessageResponseMessage"] = Resources.MessagesList_Controller_Messages_MessageSentUnsuccessfully;
                 *  ViewData["MessageIsSent"] = "false";
                 * }
                 *
                 * view.UpdateView("SentMessageResponse");
                 */

                MasterForm.Navigate <SendMessageController>("MessagesList", (string)ViewData["UserID"], (string)ViewData["UserName"]);
            }

            #endregion

            #region Back

            if (key == "Back")
            {
                int    uid  = Convert.ToInt32((string)ViewData["UserID"]);
                string text = ((string)ViewData["MessageDraftOutput"]).Trim();

                //DraftMessagesDataIO.SetDraftMessage(text, uid);

                MasterForm.Navigate <MessagesChainsListController>();
            }

            #endregion

            if (key == "GoGoToLogin")
            {
                MasterForm.Navigate <LoginController>();
            }
        }
Example #6
0
        protected override void OnViewStateChanged(string key)
        {
            #region LoadList

            if (key == "LoadList")
            {
                //LoadingControlInterface lc = LoadingControl.CreateLoading(Resources.DataLoading);

                //var asyncDataThread = new Thread(() => AsyncGetViewData(lc)) {IsBackground = true};
                //asyncDataThread.Start();

                //lc.ShowLoading(true);

                //if (lc.Abort)
                //{
                //    asyncDataThread.Abort();
                //}

                bool isRefrsh = Convert.ToBoolean(ViewData["IsRefresh"]);

                if (isRefrsh)
                {
                    LoadingControlInterface lc = LoadingControl.CreateLoading(Resources.DataLoading);

                    Thread asyncDataThread = new Thread(delegate { AsyncGetViewData(lc); });
                    asyncDataThread.IsBackground = true;
                    asyncDataThread.Start();

                    lc.ShowLoading(true);

                    if (lc.Abort)
                    {
                        asyncDataThread.Abort();
                    }
                }
                else
                {
                    try
                    {
                        FriendsListResponse newFriendsListResponse = Globals.BaseLogic.LoadFriendsList(false, false);

                        if (newFriendsListResponse != null)
                        {
                            //FriendsListResponse additionalFrendListResponse = LoadAdditionalDataFromCache();

                            ViewData["OriginalFrendListResponse"] = newFriendsListResponse;
                            //ViewData["AdditionalFrendListResponse"] = additionalFrendListResponse;

                            FillListModel(newFriendsListResponse, string.Empty);

                            Globals.BaseLogic.ICommunicationLogic.ClearImagesInDictionary();
                        }
                        else
                        {
                            //view.Model.Clear();
                        }

                        //ViewData["ListID"] = Globals.BaseLogic.IDataLogic.GetUid(); // сохраняем ID пользователя для которого был построен список

                        view.UpdateView("LoadListResponse");
                    }
                    catch
                    {
                        //
                    }
                }
            }

            #endregion

            #region ReloadList

            if (key == "ReloadList")
            {
                view.UpdateView("ReloadListResponse");
            }

            #endregion

            #region RefreshList

            if (key == "RefreshList")
            {
                view.UpdateView("RefreshListResponse");
            }

            #endregion

            #region UserChoise

            if (key == "UserChoise")
            {
                if ((string)ViewData["Uid"] != string.Empty)
                {
                    using (new WaitWrapper(false))
                    {
                        //var uid = (string) ViewData["Addressee"];
                        MasterForm.Navigate <SendMessageController>((string)ViewData["BackLink"], ViewData["Uid"]);
                    }
                }
            }

            #endregion

            #region GoBack

            if (key == "GoBack")
            {
                using (new WaitWrapper(false))
                {
                    NavigationService.GoBack();
                }
            }

            #endregion

            #region FilterFriendList

            if (key == "FilterFriendList")
            {
                using (new WaitWrapper(false))
                {
                    if ((string)ViewData["FilterString"] == string.Empty)
                    {
                        ViewData["OriginalModel"] = OriginalModel;
                        view.UpdateView("ResetState");
                    }
                    else
                    {
                        FillListModel((FriendsListResponse)ViewData["OriginalFrendListResponse"],
                                      (string)ViewData["FilterString"]);
                        ViewData["OriginalModel"] = view.Model;
                        view.UpdateView("ResetState");
                    }
                }
            }

            #endregion

            if (key == "GoGoToLogin")
            {
                MasterForm.Navigate <LoginController>();
            }
        }
        protected override void OnViewStateChanged(string key)
        {
            #region InitializeSettings

            if (key == "InitializeSettings")
            {
                using (new WaitWrapper())
                {
                    // если приложение запущено при остановленном нотификаторе, то очищаем кэш
                    // это единственное место, где осуществляется это действие
                    //if (!Interprocess.IsServiceRunning)
                    {
                        Cache.DeleteEntryFromCache(string.Empty, "ShortActivityResponse");
                        Cache.DeleteEntryFromCache(string.Empty, "ShortUpdatesPhotosResponse");
                        Cache.DeleteEntryFromCache(string.Empty, "ShortWallResponse");
                        Cache.DeleteEntryFromCache(string.Empty, "ShortPhotosCommentsRespounse");
                    }

                    Configuration.LoadConfigSettings();
                    Configuration.SaveConfigSettings();

                    #region старт/стоп нотификатора

                    if (Configuration.BackgroundNotification != BackgroundNotificationTypes.Off)
                    {
                        Globals.BaseLogic.IDataLogic.SetNtfAutorun();

                        OnViewStateChanged("StartNotificator");
                    }
                    else
                    {
                        OnViewStateChanged("StopNotificator");

                        Globals.BaseLogic.IDataLogic.DelNtfAutorun();
                    }

                    OnViewStateChanged("StopNotificator");

                    #endregion
                }
            }

            #endregion

            #region StartNotificator

            if (key == "StartNotificator")
            {
                if (!string.IsNullOrEmpty(Globals.BaseLogic.IDataLogic.GetToken()))
                {
                    // запуск службы нотификатора
                    try
                    {
                        //if (!Interprocess.IsServiceRunning)
                        //{
                        //    Interprocess.StartService();
                        //}
                    }
                    catch (Exception ex)
                    {
                        ViewData["NotificatorStartError"] = ex.Message;
                        view.UpdateView("NotificatorStartFail");
                    }
                }
                else
                {
                    DialogControl.ShowQuery(Resources.MainView_Button_NotificatorCantStart, DialogButtons.OK);
                }
            }

            #endregion

            #region StopNotificator

            if (key == "StopNotificator")
            {
                // остановка службы нотификатора
                //Interprocess.StopService();
            }

            #endregion

            #region GetViewData

            if (key == "GetViewData")
            {
                bool isRefrsh = Convert.ToBoolean(ViewData["IsRefresh"]);

                if (isRefrsh)
                {
                    LoadingControlInterface lc = LoadingControl.CreateLoading((string)ViewData["NeedChangeText"] != "1" ? Resources.DataLoading : Resources.FirstDataLoading);
                    ViewData["NeedChangeText"] = "0";

                    timerKeepAwake.Enabled = true;

                    Thread asyncDataThread = new Thread(delegate
                    {
                        try
                        {
                            timerKeepAwake.Enabled = true;

                            AsyncGetViewData(lc);
                        }
                        finally
                        {
                            timerKeepAwake.Enabled = false;
                        }
                    });
                    asyncDataThread.IsBackground = true;
                    asyncDataThread.Start();

                    lc.ShowLoading(true);

                    if (lc.Abort)
                    {
                        asyncDataThread.Abort();
                    }
                }
                else
                {
                    try
                    {
                        ActivityResponse      newActivityResponse      = Globals.BaseLogic.LoadActivityDataList(25, false, false);
                        UpdatesPhotosResponse newUpdatesPhotosResponse = Globals.BaseLogic.LoadUpdatesPhotos(25, false, false);

                        if (newActivityResponse != null)
                        {
                            FillListModel(newActivityResponse, false);
                        }
                        else
                        {
                            view.Model.Statuses.Clear();
                        }

                        if (newUpdatesPhotosResponse != null)
                        {
                            FillListModel(newUpdatesPhotosResponse, false);
                        }
                        else
                        {
                            view.Model.Photos.Clear();
                        }

                        view.UpdateView("LoadListResponse");
                    }
                    catch
                    {
                        // гасим
                    }
                }
            }

            #endregion

            #region Check AutoLogin

            if (key == "CheckAutoLogin")
            {
                try
                {
                    using (new WaitWrapper())
                    {
                        //Globals.BaseLogic.AutoLogin();
                    }

                    Initialize("AutoLoginSuccess");
                }
                catch (VKException ex)
                {
                    string message = ExceptionTranslation.TranslateException(ex);

                    //if (!string.IsNullOrEmpty(message))
                    //{
                    //    if (ex.LocalizedMessage == ExceptionMessage.IncorrectLoginOrPassword)
                    //    {
                    //        Globals.BaseLogic.IDataLogic.SetToken(string.Empty);

                    //        MasterForm.Navigate<LoginController>("IncorrectLoginOrPassword");
                    //    }
                    //    else if (ex.LocalizedMessage == ExceptionMessage.NoSavedToken)
                    //    {
                    //        MasterForm.Navigate<LoginController>("NoSavedToken");
                    //    }
                    //    else if (ex.LocalizedMessage == ExceptionMessage.UnknownError)
                    //    {
                    //        MasterForm.Navigate<LoginController>("UnknownError");
                    //    }
                    //    else
                    //    {
                    //        Initialize("LoginSuccess");
                    //    }
                    //}
                }
                catch (OutOfMemoryException)
                {
                    DialogControl.ShowQuery(Resources.OutOfMemory, DialogButtons.OK);
                }
            }

            #endregion

            #region AutoUpdate

            if (key == "AutoUpdate")
            {
                UpdateHelper updateHelper = new UpdateHelper((UIViewBase)ViewData["StatusUpdatesListView"]);
                updateHelper.CheckNewVersion();
            }

            #endregion

            #region GoToSendMessage

            if (key == "GoToSendMessage")
            {
                MasterForm.Navigate <SendMessageController>("FriendsStatus", ViewData["Uid"]);
            }

            #endregion



            // верхнее меню

            #region ReloadList

            if (key == "ReloadList")
            {
                view.UpdateView("ReloadListResponse");
            }

            #endregion

            #region RefreshList

            if (key == "RefreshList")
            {
                view.UpdateView("RefreshListResponse");
            }

            #endregion

            #region GoToPhotoComments

            if (key == "GoToPhotoComments")
            {
                MasterForm.Navigate <PhotoCommentsUpdatesListController>();
            }

            #endregion



            #region GoToMessages

            if (key == "GoToMessages")
            {
                MasterForm.Navigate <MessagesChainsListController>();
            }

            #endregion

            #region GoToFriends

            if (key == "GoToFriends")
            {
                MasterForm.Navigate <FriendsListController>();
            }

            #endregion

            #region GoToPhoto

            if (key == "GoToPhotos")
            {
                //MasterForm.Navigate<UploadPhotoController>();
                MasterForm.Navigate <ShareController>();
            }

            #endregion

            #region GoDetailedView

            if (key == "GoDetailedView")
            {
                int    uid           = Convert.ToInt32((string)ViewData["Uid"]);
                int    photoID       = Convert.ToInt32((string)ViewData["PhotoID"]);
                string largePhotoURL = (string)ViewData["LargePhotoURL"];

                if (uid > 0 && photoID > 0)
                {
                    MasterForm.Navigate <ImageCommentController>("Load", uid.ToString(), photoID.ToString(), largePhotoURL);
                }
            }

            #endregion

            #region GoToExtras

            if (key == "GoToExtras")
            {
                MasterForm.Navigate <ExtraController>();
            }

            #endregion



            #region ListActualization

            if (key == "ListActualization")
            {
                // на этой форме необходимости проверять нет, так как переход Login -> this вызывает Reload списка

                //string currentID = Globals.BaseLogic.IDataLogic.GetUid();
                //string listID = (string)ViewData["ListID"];

                //if (currentID != listID)
                //{
                //    OnViewStateChanged("GetViewData");
                //}
            }

            #endregion

            if (key == "GoGoToLogin")
            {
                MasterForm.Navigate <LoginController>();
            }
        }
Example #8
0
        protected override void OnViewStateChanged(string key)
        {
            #region LoadList

            if (key == "LoadList")
            {
                bool isRefrsh = Convert.ToBoolean(ViewData["IsRefresh"]);

                if (isRefrsh)
                {
                    LoadingControlInterface lc = LoadingControl.CreateLoading(Resources.DataLoading);

                    Thread asyncDataThread = new Thread(delegate { AsyncGetViewData(lc); });
                    asyncDataThread.IsBackground = true;
                    asyncDataThread.Start();

                    lc.ShowLoading(true);

                    if (lc.Abort)
                    {
                        asyncDataThread.Abort();
                    }
                }
                else
                {
                    try
                    {
                        int    uid           = Convert.ToInt32((string)ViewData["UserID"]);
                        int    photoID       = Convert.ToInt32((string)ViewData["PhotoID"]);
                        string largePhotoURL = (string)ViewData["LargePhotoURL"];

                        PhotosCommentsResponse newPhotosCommentsResponse = Globals.BaseLogic.LoadCommentsToPhoto(uid, photoID, 50, false, false, null);

                        if (newPhotosCommentsResponse != null)
                        {
                            FillListModel(largePhotoURL, newPhotosCommentsResponse);

                            Globals.BaseLogic.ICommunicationLogic.ClearImagesInDictionary();
                        }
                        else
                        {
                            //view.Model.Clear();

                            //NavigationService.GoBack();
                        }

                        view.UpdateView("LoadListResponse");
                    }
                    catch
                    {
                        //
                    }
                }
            }

            #endregion

            #region ReloadList

            if (key == "ReloadList")
            {
                view.UpdateView("ReloadListResponse");
            }

            #endregion

            #region RefreshList

            if (key == "RefreshList")
            {
                view.UpdateView("RefreshListResponse");
            }

            #endregion

            #region NewComment

            if (key == "NewComment")
            {
                using (new WaitWrapper(false))
                {
                    MasterForm.Navigate <SendCommentController>(ViewData["UserID"], ViewData["PhotoID"], ViewData["LargePhotoURL"]);
                }
            }

            #endregion

            #region PutInAlbum

            if (key == "PutInAlbum")
            {
                try
                {
                    byte[] file;

                    using (
                        var newBinaryReader =
                            new BinaryReader(File.Open(SystemConfiguration.AppInstallPath + @"\Cache\Files\" +
                                                       HttpUtility.GetMd5Hash((string)ViewData["LargePhotoURL"]),
                                                       FileMode.Open)))
                    {
                        file = new byte[newBinaryReader.BaseStream.Length];
                        newBinaryReader.Read(file, 0, file.Length);
                    }

                    using (new WaitWrapper())
                    {
                        Globals.BaseLogic.UploadPhoto(file, false, false);
                    }

                    ViewData["ResponseMessage"] = Resources.UploadPhoto_Controller_ResponseMessage_ImageSuccessfullyDownloaded;
                }
                catch (VKException ex)
                {
                    string errMessage;

                    switch (ex.LocalizedMessage)
                    {
                    case ExceptionMessage.UnknownError:
                        errMessage = Resources.VK_ERRORS_UnknownError;
                        break;

                    case ExceptionMessage.ServerUnavalible:
                        errMessage = Resources.VK_ERRORS_ServerUnavalible;
                        break;

                    case ExceptionMessage.NoConnection:
                        errMessage = Resources.VK_ERRORS_NoConnection;
                        break;

                    default:
                        errMessage = string.Empty;
                        break;
                    }

                    ViewData["ResponseMessage"] = errMessage;
                }
                catch (OutOfMemoryException ex)
                {
                    ViewData["ResponseMessage"] = Resources.OutOfMemory;

                    DebugHelper.WriteLogEntry("UploadPhotoController.UploadPhoto OutOfMemoryException Message: " + ex.Message);
                    DebugHelper.WriteLogEntry("UploadPhotoController.UploadPhoto OutOfMemoryException StackTrace: " + ex.StackTrace);
                }
                catch (Exception ex)
                {
                    ViewData["ResponseMessage"] = Resources.ErrorMessages_OperationIsDoneUnsuccsessfully;

                    DebugHelper.WriteLogEntry("UploadPhotoController.UploadPhoto Exception Message: " + ex.Message);
                    DebugHelper.WriteLogEntry("UploadPhotoController.UploadPhoto Exception StackTrace: " + ex.StackTrace);
                }
                finally
                {
                    view.UpdateView("MainResponse");
                }
            }

            #endregion

            #region SaveOnDisk

            if (key == "SaveOnDisk")
            {
                var sfDialog = new SaveFileDialog();

                var bmp = new Bitmap(SystemConfiguration.AppInstallPath + @"\Cache\Files\" +
                                     HttpUtility.GetMd5Hash((string)ViewData["LargePhotoURL"]));

                sfDialog.Filter = "файлы jpeg (*.jpeg)|*.jpeg";

                sfDialog.FileName = Resources.DefaultFileNameToSave;
                if (sfDialog.ShowDialog() == DialogResult.OK)
                {
                    bmp.Save(sfDialog.FileName, System.Drawing.Imaging.ImageFormat.Jpeg);
                }

                bmp.Dispose();
            }

            #endregion

            #region GoToSendMessage

            if (key == "GoToSendMessage")
            {
                MasterForm.Navigate <SendMessageController>("ImageDetailedView", ViewData["SenderID"], ViewData["SenderName"]);
            }

            #endregion

            #region GoBack

            if (key == "GoBack")
            {
                NavigationService.GoBack();
            }

            #endregion

            if (key == "GoGoToLogin")
            {
                MasterForm.Navigate <LoginController>();
            }
        }
        protected override void OnViewStateChanged(string key)
        {
            #region LoadList

            if (key == "LoadList")
            {
                bool isRefrsh = Convert.ToBoolean(ViewData["IsRefresh"]);

                if (isRefrsh)
                {
                    LoadingControlInterface lc = LoadingControl.CreateLoading(Resources.DataLoading);

                    Thread asyncDataThread = new Thread(delegate { AsyncGetViewData(lc); });
                    asyncDataThread.IsBackground = true;
                    asyncDataThread.Start();

                    lc.ShowLoading(true);

                    if (lc.Abort)
                    {
                        asyncDataThread.Abort();
                    }
                }
                else
                {
                    try
                    {
                        MessShortCorrespondence newMessShortCorrespondence = Globals.BaseLogic.GetShortCorrespondence(false, false);

                        if (newMessShortCorrespondence != null)
                        {
                            FillListModel(newMessShortCorrespondence);

                            Globals.BaseLogic.ICommunicationLogic.ClearImagesInDictionary();
                        }
                        else
                        {
                            view.Model.Clear();
                        }

                        ViewData["ListID"] = Globals.BaseLogic.IDataLogic.GetUid(); // сохраняем ID пользователя для которого был построен список

                        view.UpdateView("LoadListResponse");
                    }
                    catch
                    {
                        //
                    }
                }
            }

            #endregion

            #region ReloadList

            if (key == "ReloadList")
            {
                view.UpdateView("ReloadListResponse");
            }

            #endregion

            #region RefreshList

            if (key == "RefreshList")
            {
                view.UpdateView("RefreshListResponse");
            }

            #endregion

            #region ChangeReceiver

            if (key == "ChangeReceiver")
            {
                using (new WaitWrapper(false))
                {
                    MasterForm.Navigate <FriendsSearchListController>("");
                }
            }

            #endregion

            #region перехеды

            #region GoToNews

            if (key == "GoToNews")
            {
                MasterForm.Navigate <StatusUpdatesListController>();
            }

            #endregion

            #region GoToFriends

            if (key == "GoToFriends")
            {
                MasterForm.Navigate <FriendsListController>();
            }

            #endregion

            #region GoToPhotos

            if (key == "GoToPhotos")
            {
                MasterForm.Navigate <ShareController>();
            }

            #endregion

            #region GoToExtras

            if (key == "GoToExtras")
            {
                MasterForm.Navigate <ExtraController>();
            }

            #endregion

            #endregion



            #region ListActualization

            if (key == "ListActualization")
            {
                //string currentID = Globals.BaseLogic.IDataLogic.GetUid();
                //string listID = (string)ViewData["ListID"];

                //if (currentID != listID)
                //{
                //    ViewData["IsRefresh"] = false;

                //    OnViewStateChanged("LoadList");
                //}

                ViewData["IsRefresh"] = false;
                OnViewStateChanged("LoadList");
            }

            #endregion

            if (key == "GoGoToLogin")
            {
                MasterForm.Navigate <LoginController>();
            }
        }