示例#1
0
        //---B
        #region Scroll and helper label

        ///<summary> Обработка изменения скролла с панелями альбомов. </summary>
        private void Scroll_ValueChanged(object sender, EventArgs e)
        {
            // находим первую видимую плашку альбома
            AbstractEntry ent = null;

            if (ListMode)
            {
                ent = srcList?.FirstOrDefault(alb => IsUserVisible(alb.lp, scrollViewer));
            }
            else
            {
                ent = srcList?.FirstOrDefault(alb => IsUserVisible(alb.vp, scrollViewer));
            }

            if (ent != null)
            {
                scrollHelperLbl.Text = ent.sortHelper;

                if (Mouse.LeftButton == MouseButtonState.Pressed)
                {
                    scrollHelperLbl.Visibility = Visibility.Visible;
                }
                else
                {
                    scrollHelperLbl.Visibility = Visibility.Hidden;
                }
            }
        }
示例#2
0
        /// <summary>
        /// worker method for the resumable update
        /// </summary>
        /// <param name="data"></param>
        /// <param name="asyncOp"></param>
        /// <param name="completionMethodDelegate"></param>
        /// <returns></returns>
        private void AsyncUpdateWorker(AsyncResumableUploadData data, AsyncOperation asyncOp, SendOrPostCallback completionMethodDelegate)
        {
            try
            {
                AbstractEntry abstractEntry = data.Entry as AbstractEntry;
                if (abstractEntry != null)
                {
                    using (var response = Update(data.Authentication, abstractEntry, data))
                    {
                        HandleResponseStream(data, response.GetResponseStream(), -1);
                    }
                }
                else
                {
                    using (var response = Update(data.Authentication, data.UriToUse, data.DataStream, data.ContentType, data))
                    {
                        HandleResponseStream(data, response.GetResponseStream(), -1);
                    }
                }
            }
            catch (Exception e)
            {
                data.Exception = e;
            }

            CompletionMethodDelegate(data);
        }
        public void ToggleCategoryTest()
        {
            AbstractEntry target = CreateAbstractEntry();
            AtomCategory  cat    = new AtomCategory("testcat");

            target.ToggleCategory(cat, true);
            Assert.IsTrue(target.Categories.Contains(cat), "Category should now be part of it");
            target.ToggleCategory(cat, false);
            Assert.IsFalse(target.Categories.Contains(cat), "Category should be gone");
        }
        public void UpdateAsync(Authenticator authentication, AbstractEntry payload, object userData)
        {
            AsyncResumableUploadData data = new AsyncResumableUploadData(this,
                                                                         authentication,
                                                                         payload,
                                                                         HttpMethods.Put,
                                                                         this.ProgressReportDelegate,
                                                                         userData);
            WorkerResumableUploadHandler workerDelegate = new WorkerResumableUploadHandler(AsyncUpdateWorker);

            this.AsyncStarter(data, workerDelegate, userData);
        }
 public AsyncResumableUploadData(AsyncDataHandler handler,
     Authenticator authenticator,
     AbstractEntry payload,
     string httpMethod,
     SendOrPostCallback callback,
     object userData)
     : base(null, null, userData, callback) {
     this.DataHandler = handler;
     this.authenticator = authenticator;
     this.entry = payload;
     this.HttpVerb = httpMethod;
 }
示例#6
0
 ///<summary> Удаление элемента каталога или альбома. </summary>
 public void RemoveEntry(AbstractEntry ent)
 {
     Console.WriteLine($"Remove Entry {ent.Name}");
     if (ent is CatalogAlbum)
     {
         CatEng.CatRoot.AlbumsList.Remove(ent as CatalogAlbum);
     }
     else
     {
         (ent as CatalogEntry).catAlb.EntryList.Remove(ent as CatalogEntry);
     }
 }
 public AsyncResumableUploadData(AsyncDataHandler handler,
                                 Authenticator authenticator,
                                 AbstractEntry payload,
                                 string httpMethod,
                                 SendOrPostCallback callback,
                                 object userData)
     : base(null, null, userData, callback)
 {
     this.DataHandler   = handler;
     this.authenticator = authenticator;
     this.entry         = payload;
     this.HttpVerb      = httpMethod;
 }
示例#8
0
        private WebResponse Update(Authenticator authentication, AbstractEntry payload, AsyncData data)
        {
            Uri initialUri = ResumableUploader.GetResumableEditUri(payload.Links);

            if (initialUri == null)
            {
                throw new ArgumentException("payload did not contain a resumabled edit media Uri");
            }

            Uri resumeUri = InitiateUpload(initialUri, authentication, payload);

            return(UploadStream(HttpMethods.Put, resumeUri, authentication, payload.MediaSource.Data, payload.MediaSource.ContentType, data));
        }
        public void InsertAsync(Authenticator authentication, AbstractEntry payload, object userData)
        {
            AsyncResumableUploadData data = new AsyncResumableUploadData(this,
                                                                         authentication,
                                                                         payload,
                                                                         HttpMethods.Post,
                                                                         this.ProgressReportDelegate,
                                                                         userData);

            data.UriToUse = GetResumableCreateUri(payload.Links);
            WorkerResumableUploadHandler workerDelegate = new WorkerResumableUploadHandler(AsyncInsertWorker);

            this.AsyncStarter(data, workerDelegate, userData);
        }
示例#10
0
        // Draws a titlebar with a particular method entry.
        // I tried to mimic the look&feel of the regular Unity Inspector titlebar.
        bool DrawTitlebar(AbstractEntry entry)
        {
            GUIStyle inspectorTitlebar = "IN Title";

            var editorPrefsKey = string.Format("PlayModeInspector.{0}.expanded", entry.editorPrefKey);
            var isExpanded     = EditorPrefs.GetBool(editorPrefsKey, true);

            var r = GUILayoutUtility.GetRect(0, 22, GUILayout.ExpandWidth(true));

            r.y -= 1;

            var rtitlebar = r;

            GUI.Box(rtitlebar, "", inspectorTitlebar);

            var e = Event.current;

            if (e != null)
            {
                if (e.type == EventType.MouseDown && e.button == 0 && rtitlebar.Contains(e.mousePosition))
                {
                    EditorPrefs.SetBool(editorPrefsKey, !isExpanded);
                    e.Use();
                }
            }

            var rfoldout = r;

            rfoldout.x += 4; rfoldout.width = 16;
            GUI.Toggle(rfoldout, isExpanded, "", EditorStyles.foldout);

            var title = entry.title;

            var ricon = r;

            ricon.x += 20; ricon.y += 3; ricon.width = 16; ricon.height = 16;
            if (title.image != null)
            {
                GUI.DrawTexture(ricon, AssetPreview.GetMiniThumbnail(title.image));
            }

            var rlabel = r;

            rlabel.x += 38;
            GUI.Button(rlabel, title.text, EditorStyles.boldLabel);

            return(isExpanded);
        }
        private WebResponse Insert(Authenticator authentication, AbstractEntry payload, AsyncData data)
        {
            WebResponse r          = null;
            Uri         initialUri = ResumableUploader.GetResumableCreateUri(payload.Links);

            if (initialUri == null)
            {
                throw new ArgumentException("payload did not contain a resumable create media Uri");
            }

            Uri resumeUri = InitiateUpload(initialUri, authentication, payload);

            using (Stream s = payload.MediaSource.GetDataStream()) {
                r = UploadStream(HttpMethods.Post, resumeUri, authentication,
                                 s, payload.MediaSource.ContentType, data);
            }
            return(r);
        }
示例#12
0
        //---G
        #region SidePanel

        ///<summary> Открытие боковой панели для заданного элемента каталога. </summary>
        public void OpenSidePanel(AbstractEntry openerEntry)
        {
            var albPanel = GetCurrentAlbumePanel();

            // скипаем переоткрытие, иначе вылет если был фокус на датагриде
            if (albPanel.sidePanelSlot.Children.Count > 0)
            {
                var curASP = albPanel.sidePanelSlot.Children[0] as AlbumSidePanel;
                if (curASP.DataContext == openerEntry)
                {
                    return;
                }
            }

            AlbumSidePanel asp = new AlbumSidePanel();

            asp.DataContext = openerEntry;
            asp.UpdateExceptLbl();
            albPanel.SetSidePanel(asp);

            asp.tabsPanel.SelectedIndex = Properties.Settings.Default.SidePanelTab;
        }
        /// <summary>
        /// retrieves the resumable URI for the rest of the operation. This will initiate the 
        /// communication with resumable upload server by posting against the starting URI
        /// </summary>
        /// <param name="resumableUploadUri"></param>
        /// <param name="authentication"></param>
        /// <param name="entry"></param>
        /// <returns>The uri to be used for the rest of the operation</returns>
        public Uri InitiateUpload(Uri resumableUploadUri, Authenticator authentication, AbstractEntry entry, string httpMethod) {
            HttpWebRequest request = PrepareRequest(resumableUploadUri,
                authentication,
                entry.MediaSource.Name,
                entry.MediaSource.ContentType,
                entry.MediaSource.ContentLength,
                httpMethod);

            IVersionAware v = entry as IVersionAware;
            if (v != null) {
                // need to add the version header to the request
                request.Headers.Add(GDataGAuthRequestFactory.GDataVersion, v.ProtocolMajor.ToString() + "." + v.ProtocolMinor.ToString());
            }

            ISupportsEtag e = entry as ISupportsEtag;
            if (e != null && !Utilities.IsWeakETag(e)) {
                request.Headers.Add(GDataRequestFactory.IfMatch, e.Etag);
            }

            Stream outputStream = request.GetRequestStream();
            entry.SaveToXml(outputStream);
            outputStream.Close();

            /// this is the contenttype for the xml post
            request.ContentType = GDataRequestFactory.DefaultContentType;

            WebResponse response = request.GetResponse();
            return new Uri(response.Headers["Location"]);
        }
 /// <summary>
 /// retrieves the resumable URI for the rest of the operation. This will initiate the 
 /// communication with resumable upload server by posting against the starting URI
 /// </summary>
 /// <param name="resumableUploadUri"></param>
 /// <param name="authentication"></param>
 /// <param name="entry"></param>
 /// <returns>The uri to be used for the rest of the operation</returns>
 public Uri InitiateUpload(Uri resumableUploadUri, Authenticator authentication, AbstractEntry entry) {
     return InitiateUpload(resumableUploadUri, authentication, entry, HttpMethods.Post);
 }
 public void UpdateAsync(Authenticator authentication, AbstractEntry payload, object userData) {
     AsyncResumableUploadData data = new AsyncResumableUploadData(this,
         authentication,
         payload,
         HttpMethods.Put,
         this.ProgressReportDelegate,
         userData);
     WorkerResumableUploadHandler workerDelegate = new WorkerResumableUploadHandler(AsyncUpdateWorker);
     this.AsyncStarter(data, workerDelegate, userData);
 }
        private WebResponse Update(Authenticator authentication, AbstractEntry payload, AsyncData data) {
            WebResponse r = null;

            Uri initialUri = ResumableUploader.GetResumableEditUri(payload.Links);
            if (initialUri == null)
                throw new ArgumentException("payload did not contain a resumabled edit media Uri");

            Uri resumeUri = InitiateUpload(initialUri, authentication, payload, HttpMethods.Put);

            // get the stream
            using (Stream s = payload.MediaSource.GetDataStream()) {
                r = UploadStream(HttpMethods.Put, resumeUri, authentication, s, payload.MediaSource.ContentType, data);
            }
            return r;
        }
 /// <summary>
 /// Uploads an entry, including it's media to the uri given inside the entry
 /// </summary>
 /// <param name="resumableUploadUri"></param>
 /// <param name="authentication">The authentication information to be used</param>
 /// <param name="payload">The entry to be uploaded. This is a complete entry, including the metadata. 
 /// This will create a new entry on the service</param>
 /// <returns></returns>
 public WebResponse Update(Authenticator authentication, AbstractEntry payload) {
     return Update(authentication, payload, null);
 }
 /// <summary>
 /// Uploads an entry, including it's media to the uri given inside the entry. 
 /// </summary>
 /// <param name="authentication">The authentication information to be used</param>
 /// <param name="payload">The entry to be uploaded. This is a complete entry, including the metadata. 
 /// This will create a new entry on the service</param>
 /// <returns></returns>
 public WebResponse Insert(Authenticator authentication, AbstractEntry payload) {
     return Insert(authentication, payload, null);
 }
        /// <summary>
        /// retrieves the resumable URI for the rest of the operation. This will initiate the
        /// communication with resumable upload server by posting against the starting URI
        /// </summary>
        /// <param name="resumableUploadUri"></param>
        /// <param name="authentication"></param>
        /// <param name="entry"></param>
        /// <returns>The uri to be used for the rest of the operation</returns>
        public Uri InitiateUpload(Uri resumableUploadUri, Authenticator authentication, AbstractEntry entry, string httpMethod)
        {
            HttpWebRequest request = PrepareRequest(resumableUploadUri,
                                                    authentication,
                                                    entry.MediaSource.Name,
                                                    entry.MediaSource.ContentType,
                                                    entry.MediaSource.ContentLength,
                                                    httpMethod);

            IVersionAware v = entry as IVersionAware;

            if (v != null)
            {
                // need to add the version header to the request
                request.Headers.Set(GDataGAuthRequestFactory.GDataVersion, v.ProtocolMajor.ToString() + "." + v.ProtocolMinor.ToString());
            }

            ISupportsEtag e = entry as ISupportsEtag;

            if (e != null && !Utilities.IsWeakETag(e))
            {
                request.Headers.Set(GDataRequestFactory.IfMatch, e.Etag);
            }

            Stream outputStream = request.GetRequestStream();

            entry.SaveToXml(outputStream);
            outputStream.Close();

            // this is the contenttype for the xml post
            request.ContentType = GDataRequestFactory.DefaultContentType;

            WebResponse response = request.GetResponse();

            return(new Uri(response.Headers["Location"]));
        }
 /// <summary>
 /// retrieves the resumable URI for the rest of the operation. This will initiate the
 /// communication with resumable upload server by posting against the starting URI
 /// </summary>
 /// <param name="resumableUploadUri"></param>
 /// <param name="authentication"></param>
 /// <param name="entry"></param>
 /// <returns>The uri to be used for the rest of the operation</returns>
 public Uri InitiateUpload(Uri resumableUploadUri, Authenticator authentication, AbstractEntry entry)
 {
     return(InitiateUpload(resumableUploadUri, authentication, entry, HttpMethods.Post));
 }
 public void InsertAsync(Authenticator authentication, AbstractEntry payload, object userData) {
     AsyncResumableUploadData data = new AsyncResumableUploadData(this,
         authentication,
         payload,
         HttpMethods.Post,
         this.ProgressReportDelegate,
         userData);
     data.UriToUse = GetResumableCreateUri(payload.Links);
     WorkerResumableUploadHandler workerDelegate = new WorkerResumableUploadHandler(AsyncInsertWorker);
     this.AsyncStarter(data, workerDelegate, userData);
 }
 /// <summary>
 /// Uploads an entry, including its media to the uri given inside the entry
 /// </summary>
 /// <param name="resumableUploadUri"></param>
 /// <param name="authentication">The authentication information to be used</param>
 /// <param name="payload">The entry to be uploaded. This is a complete entry, including the metadata.
 /// This will create a new entry on the service</param>
 /// <returns></returns>
 public WebResponse Update(Authenticator authentication, AbstractEntry payload)
 {
     return(Update(authentication, payload, null));
 }
示例#23
0
        private WebResponse Insert(Authenticator authentication, AbstractEntry payload, AsyncData data)
        {
            Uri initialUri = ResumableUploader.GetResumableCreateUri(payload.Links);
            if (initialUri == null)
                throw new ArgumentException("payload did not contain a resumabled create media Uri");

            Uri resumeUri = InitiateUpload(initialUri, authentication, payload);
            return UploadStream(HttpMethods.Post, resumeUri,  authentication, 
                                payload.MediaSource.Data, 
                                payload.MediaSource.ContentType, data);
        }
 /// <summary>
 /// Uploads an entry, including it's media to the uri given inside the entry.
 /// </summary>
 /// <param name="authentication">The authentication information to be used</param>
 /// <param name="payload">The entry to be uploaded. This is a complete entry, including the metadata.
 /// This will create a new entry on the service</param>
 /// <returns></returns>
 public WebResponse Insert(Authenticator authentication, AbstractEntry payload)
 {
     return(Insert(authentication, payload, null));
 }
示例#25
0
 ///<summary> Удаление элемента каталога или альбома, затем обновление UI. </summary>
 public void RemoveEntryAndUpdateUI(AbstractEntry ent)
 {
     RemoveEntry(ent);
     App.MainWin.UpdateCurrentPanel();
     App.MainWin.ClearSidePanel();
 }