Inheritance: MonoBehaviour
Example #1
0
 public static Icon GetIcon(string path, ItemType type, IconSize size, ItemState state)
 {
     var flags = (uint)(Interop.SHGFI_ICON | Interop.SHGFI_USEFILEATTRIBUTES);
     var attribute = (uint)(object.Equals(type, ItemType.Folder) ? Interop.FILE_ATTRIBUTE_DIRECTORY : Interop.FILE_ATTRIBUTE_FILE);
     if (object.Equals(type, ItemType.Folder) && object.Equals(state, ItemState.Open))
     {
         flags += Interop.SHGFI_OPENICON;
     }
     if (object.Equals(size, IconSize.Small))
     {
         flags += Interop.SHGFI_SMALLICON;
     }
     else
     {
         flags += Interop.SHGFI_LARGEICON;
     }
     var shfi = new SHFileInfo();
     var res = Interop.SHGetFileInfo(path, attribute, out shfi, (uint)Marshal.SizeOf(shfi), flags);
     if (object.Equals(res, IntPtr.Zero)) throw Marshal.GetExceptionForHR(Marshal.GetHRForLastWin32Error());
     try
     {
         Icon.FromHandle(shfi.hIcon);
         return (Icon)Icon.FromHandle(shfi.hIcon).Clone();
     }
     catch
     {
         throw;
     }
     finally
     {
         Interop.DestroyIcon(shfi.hIcon);
     }
 }
Example #2
0
 public static ImageSource GetImageSource(string directory, Size size, ItemState folderType)
 {
     using (var icon = ShellManager.GetIcon(directory, ItemType.Folder, IconSize.Large, folderType))
     {
         return Imaging.CreateBitmapSourceFromHIcon(icon.Handle, System.Windows.Int32Rect.Empty, BitmapSizeOptions.FromWidthAndHeight((int)size.Width, (int)size.Height));
     }
 }
        public OpenPullRequestMonitor(TimeSpan timespan, ItemState state=ItemState.Open)
        {
            var pollingPeriod = timespan.TotalMilliseconds;
            _timer = new Timer(pollingPeriod) {AutoReset = true};
            _timer.Elapsed += (sender, eventArgs) =>
            {
                var prs = 0;
                Task.Run(async () =>
                {
                    var requests = await PollGitHub(state);
                    prs = requests.Count;
                    _pr = requests.FirstOrDefault();
                    Console.WriteLine("Polled PR count:" + prs);
                }).Wait();

                if (prs > OpenPrs)
                {
                    var soundPlayer = new SoundPlayer("fanfare3.wav");
                    soundPlayer.PlaySync();
                    if (_pr != null)
                    {
                        var speech = new SpeechSynthesizer();
                        speech.Speak("New pull request.");
                        speech.Speak(_pr.Title);
                    }

                    OpenPrs = prs;
                }
                else if (prs < OpenPrs)
                {
                    OpenPrs = prs;
                }
            };
        }
Example #4
0
 public PullRequest(Uri url, Uri htmlUrl, Uri diffUrl, Uri patchUrl, Uri issueUrl, Uri statusesUrl, int number, ItemState state, string title, string body, DateTimeOffset createdAt, DateTimeOffset updatedAt, DateTimeOffset? closedAt, DateTimeOffset? mergedAt, GitReference head, GitReference @base, User user, User assignee, bool? mergeable, User mergedBy, int comments, int commits, int additions, int deletions, int changedFiles)
 {
     Url = url;
     HtmlUrl = htmlUrl;
     DiffUrl = diffUrl;
     PatchUrl = patchUrl;
     IssueUrl = issueUrl;
     StatusesUrl = statusesUrl;
     Number = number;
     State = state;
     Title = title;
     Body = body;
     CreatedAt = createdAt;
     UpdatedAt = updatedAt;
     ClosedAt = closedAt;
     MergedAt = mergedAt;
     Head = head;
     Base = @base;
     User = user;
     Assignee = assignee;
     Mergeable = mergeable;
     MergedBy = mergedBy;
     Comments = comments;
     Commits = commits;
     Additions = additions;
     Deletions = deletions;
     ChangedFiles = changedFiles;
 }
Example #5
0
  IEnumerator ItemLoad() {
    var items = ItemManager.instance.items;

    while (_item == null) {
      if (items.ContainsKey(_itemName)) { _item = items[_itemName]; }
      yield return null;
    }
  }
Example #6
0
File: Item.cs Project: VicBoss/KR
 public Item(string name, string description, Texture2D image)
 {
     this.name = name;
     this.description = description;
     this.image = image;
     quantity = 1;
     state = ItemState.Positioned;
 }
 public async Task<IReadOnlyList<PullRequest>> PollGitHub(ItemState state = ItemState.Open)
 {
     var gitHubClient = new GitHubClient(new ProductHeaderValue("CalPEATS"));
     gitHubClient.Credentials = new Credentials("***email**", "******");
     var openPullRequests = new PullRequestRequest {State = state };
     var prs = await gitHubClient.PullRequest.GetAllForRepository("calicosol", "CalPEATS", openPullRequests);
     return prs;
 }
Example #8
0
 public TasklistItem(string taskId, string name, ItemState state, int total, int completed)
 {
     this.TaskId = taskId;
     this.Name = name;
     this.Description = String.Empty;
     this.State = state;
     this.Total = total;
     this.Completed = completed;
 }
Example #9
0
 public static void SetupSearch(this Mock<IGitHubClient> github, ItemState state, params Issue[] result)
 {
     github.Setup(x => x.Search.SearchIssues(It.Is<SearchIssuesRequest>(s => s.State == state)))
         .Returns(Task.FromResult(new SearchIssuesResult
         {
             Items = result.ToList(),
             TotalCount = result.Length
         }));
 }
Example #10
0
 /// <summary>Create <see cref="ItemPaintEventArgs"/>.</summary>
 /// <param name="graphics">Graphics surface to draw the item on.</param>
 /// <param name="clipRectangle">Clipping rectangle.</param>
 /// <param name="bounds">Rectangle that represents the bounds of the item that is being drawn.</param>
 /// <param name="index">Index value of the item that is being drawn.</param>
 /// <param name="state">State of the item being drawn.</param>
 /// <param name="hoveredPart">Hovered part of the item.</param>
 /// <param name="hostControlFocused">Host control is focused.</param>
 public SubItemPaintEventArgs(
     Graphics graphics, Rectangle clipRectangle, Rectangle bounds, int index,
     ItemState state, int hoveredPart, bool hostControlFocused,
     int columnIndex, CustomListBoxColumn column)
     : base(graphics, clipRectangle, bounds, index, state, hoveredPart, hostControlFocused)
 {
     _columnIndex = columnIndex;
     _column = column;
 }
Example #11
0
 public static ImageSource GetImageSource(string directory, ItemState folderType)
 {
     try
     {
         return GetImageSource(directory, new Size(16, 16), folderType);
     }
     catch
     {
         throw;
     }
 }
        public virtual void DrawButton(Graphics g, Rectangle rectangle, string text, Font font, StringFormat fmt, ItemState state, bool hasBorder, bool enabled)
        {
            float angle = 90;

            if (rectangle.Width > 0 && rectangle.Height > 0)
            {
                if (!enabled)
                {
                    using (Brush backBrush = new LinearGradientBrush(rectangle, Office2003Colors.Default[Office2003Color.Button1], Office2003Colors.Default[Office2003Color.Button2], angle))
                    {
                        g.FillRectangle(backBrush, rectangle);
                    }
                }
                else
                {
                    switch (state)
                    {
                        case ItemState.Normal:
                            using (Brush backBrush = new LinearGradientBrush(rectangle, Office2003Colors.Default[Office2003Color.Button1], Office2003Colors.Default[Office2003Color.Button2], angle))
                                g.FillRectangle(backBrush, rectangle);
                            break;
                        case ItemState.HotTrack:
                            using (Brush trackBrush = new LinearGradientBrush(rectangle, Office2003Colors.Default[Office2003Color.Button1Hot], Office2003Colors.Default[Office2003Color.Button2Hot], angle))
                                g.FillRectangle(trackBrush, rectangle);
                            break;
                        case ItemState.Open:
                        case ItemState.Pressed:
                            using (Brush trackBrush = new LinearGradientBrush(rectangle, Office2003Colors.Default[Office2003Color.Button1Pressed], Office2003Colors.Default[Office2003Color.Button2Pressed], angle))
                                g.FillRectangle(trackBrush, rectangle);
                            break;
                        default:
                            break;
                    }
                }

                if (!string.IsNullOrEmpty(text))
                {
                    if (enabled)
                    {
                        using (SolidBrush br = new SolidBrush(Office2003Colors.Default[Office2003Color.Text]))
                            g.DrawString(text, font, br, rectangle, fmt);
                    }
                    else
                    {
                        using (SolidBrush br = new SolidBrush(Office2003Colors.Default[Office2003Color.TextDisabled]))
                            g.DrawString(text, font, br, rectangle, fmt);
                    }
                }

                if(hasBorder)
                    DrawBorder(g, new Rectangle(rectangle.X, rectangle.Y, rectangle.Width - 1, rectangle.Height - 1), enabled);
            }
        }
Example #13
0
 public Milestone(Uri url, int number, ItemState state, string title, string description, User creator, int openIssues, int closedIssues, DateTimeOffset createdAt, DateTimeOffset? dueOn)
 {
     Url = url;
     Number = number;
     State = state;
     Title = title;
     Description = description;
     Creator = creator;
     OpenIssues = openIssues;
     ClosedIssues = closedIssues;
     CreatedAt = createdAt;
     DueOn = dueOn;
 }
        public static void StateSwitch(PointerEventData data, ItemState state,
		                               System.Action<PointerEventData> attachedAction,  
		                               System.Action<PointerEventData> attachedHighlightedAction,  
		                               System.Action<PointerEventData> draggingAction,  
		                               System.Action<PointerEventData> floatingAction,
		                               System.Action<PointerEventData> instantiateAction,
		                               System.Action<PointerEventData> noInstantiateAction)
        {
            switch (state)
            {
            case ItemState.Attached:
                if (attachedAction != null)
                {
                    attachedAction(data);
                }
                break;
            case ItemState.AttachedHighlighted:
                if (attachedHighlightedAction != null)
                {
                    attachedHighlightedAction(data);
                }
                break;
            case ItemState.Dragging:
                if (draggingAction != null)
                {
                    draggingAction(data);
                }
                break;
            case ItemState.Floating:
                if (floatingAction != null)
                {
                    floatingAction(data);
                }
                break;
            case ItemState.Instantiate:
                if (instantiateAction != null)
                {
                    instantiateAction(data);
                }
                break;
            case ItemState.NoInstantiate:
                if (noInstantiateAction != null)
                {
                    noInstantiateAction(data);
                }
                break;
            }
        }
 public override void DrawItem(Graphics g, ImageListViewItem item, ItemState state, Rectangle bounds)
 {
     base.DrawItem(g, item, state, bounds);
     PhotoInfo p = item.Tag as PhotoInfo;
     if (ImageListView.View != View.Details && p != null && p.Flickr.Uploaded != null) {
         // Draw the image
         Image img = item.ThumbnailImage;
         if (img != null) {
             Size itemPadding = new Size(4, 4);
             Rectangle pos = GetSizedImageBounds(img, new Rectangle(bounds.Location + itemPadding, ImageListView.ThumbnailSize));
             Image overlayImage = Resource1.Uploaded;
             int w = Math.Min(overlayImage.Width, pos.Width);
             int h = Math.Min(overlayImage.Height, pos.Height);
             g.DrawImage(overlayImage, pos.Left, pos.Bottom - h, w, h);
         }
     }
 }
Example #16
0
 public void loadEventItemState(ItemState state)
 {
     itemId = state.id;
     type = EVENT_TYPE;
     level = state.level;
     requiredItems = state.requiredItems;
     restrictedItems = state.restrictedItems;
     leadItems = state.leadItems;
     hideItems = state.hideItems;
     unhideItems = state.unhideItems;
     eventDialogue = state.eventDialogue;
     defaultDialogue = state.defaultDialogue;
     idleDialogue = state.idleDialogue;
     endingPoints = state.endingPoints;
     isInitiallyHidden = state.isInitiallyHidden;
     pt2DefaultDialogue = state.pt2DefaultDialogue;
     pt2EventDialogue = state.pt2EventDialogue;
 }
Example #17
0
 public Issue(Uri url, Uri htmlUrl, int number, ItemState state, string title, string body, User user, IReadOnlyList<Label> labels, User assignee, Milestone milestone, int comments, PullRequest pullRequest, DateTimeOffset? closedAt, DateTimeOffset createdAt, DateTimeOffset? updatedAt)
 {
     Url = url;
     HtmlUrl = htmlUrl;
     Number = number;
     State = state;
     Title = title;
     Body = body;
     User = user;
     Labels = labels;
     Assignee = assignee;
     Milestone = milestone;
     Comments = comments;
     PullRequest = pullRequest;
     ClosedAt = closedAt;
     CreatedAt = createdAt;
     UpdatedAt = updatedAt;
 }
        public void DrawButton(Graphics g, Rectangle rectangle, string text, Font font, StringFormat fmt, ItemState state, bool hasBorder, bool enabled)
        {
            if (rectangle.Width > 0 && rectangle.Height > 0)
            {
                if (!enabled)
                {
                    ControlPaint.DrawButton(g, rectangle, ButtonState.Inactive);
                }
                else
                {
                    switch (state)
                    {
                        case ItemState.Normal:
                            g.FillRectangle(SystemBrushes.ButtonFace, rectangle);
                            break;
                        case ItemState.HotTrack:
                            g.FillRectangle(SystemBrushes.ControlLightLight, rectangle);
                            break;
                        case ItemState.Open:
                        case ItemState.Pressed:
                            g.FillRectangle(SystemBrushes.ControlLight, rectangle);
                            break;
                        default:
                            break;
                    }
                }

                if (!string.IsNullOrEmpty(text))
                {
                    if (enabled)
                    {
                        g.DrawString(text, font, SystemBrushes.ControlText, rectangle, fmt);
                    }
                    else
                    {
                        g.DrawString(text, font, SystemBrushes.GrayText, rectangle, fmt);
                    }
                }

                if (hasBorder)
                    DrawBorder(g, new Rectangle(rectangle.X, rectangle.Y, rectangle.Width - 1, rectangle.Height - 1), enabled);
            }
        }
Example #19
0
 public void OnTouch(Transform _toucher)
 {
     Debug.LogWarning(_toucher.name);
     if(!PetNetwork.PetItemConfirmDialogVisibility && !PetNetwork.PetItemDialogVisibility) {
         //&& Application.loadedLevelName == "default" && Main3D_Component.SetContoler(gameObject)){
         toucher = _toucher;
       	switch(touchState){
         case ItemState.none:
           //if((_toucher.gameObject.GetComponent("MoveTo") as MoveTo).user.user_lite.user_id == petDetail.user_id.ToString()){
             touchState = ItemState.mytouch;
           /*}else{
             touchState = ItemState.touch;
           }*/
           break;
         case ItemState.touch:
           break;
         }
     }
 }
Example #20
0
 protected static PullRequest CreatePullRequest(User user, int id, ItemState state, string title,
     DateTimeOffset createdAt, DateTimeOffset updatedAt, int commentCount = 0, int reviewCommentCount = 0)
 {
     var uri = new Uri("https://url");
     var uris = uri.ToString();
     var repo = new Repository(uris, uris, uris, uris, uris, uris, uris,
         1, user, "Repo", "Repo", string.Empty, string.Empty, string.Empty,
         false, false, 0, 0, "master",
         0, null, createdAt, updatedAt,
         null, null, null,
         false, false, false);
     return new PullRequest(uri, uri, uri, uri, uri, uri,
         id, state, title, "", createdAt, updatedAt,
         null, null, 
         new GitReference(uri.ToString(), "foo:bar", "bar", "123", user, repo),
         new GitReference(uri.ToString(), "foo:baz", "baz", "123", user, repo),
         user, null, false, null,
         commentCount, reviewCommentCount, 0, 0, 0, 0,
         null, false);
 }
Example #21
0
        /// <summary>
        /// Draws the specified item on the given graphics.
        /// </summary>
        /// <param name="g">The System.Drawing.Graphics to draw on.</param>
        /// <param name="item">The ImageListViewItem to draw.</param>
        /// <param name="state">The current view state of item.</param>
        /// <param name="bounds">The bounding rectangle of item in client coordinates.</param>
        public override void DrawItem(Graphics g, ImageListViewItem item, ItemState state, Rectangle bounds)
        {
            if (item.Index == mImageListView.layoutManager.FirstPartiallyVisible ||
                item.Index == mImageListView.layoutManager.LastPartiallyVisible)
            {
                using (Brush b = new HatchBrush(HatchStyle.BackwardDiagonal, Color.Green, Color.Transparent))
                {
                    g.FillRectangle(b, bounds);
                }
            }
            if (item.Index == mImageListView.layoutManager.FirstVisible ||
                item.Index == mImageListView.layoutManager.LastVisible)
            {
                using (Brush b = new HatchBrush(HatchStyle.ForwardDiagonal, Color.Red, Color.Transparent))
                {
                    g.FillRectangle(b, bounds);
                }
            }

            base.DrawItem(g, item, state, bounds);
        }
Example #22
0
 public Issue(Uri url, Uri htmlUrl, Uri commentsUrl, Uri eventsUrl, int number, ItemState state, string title, string body, User closedBy, User user, IReadOnlyList<Label> labels, User assignee, Milestone milestone, int comments, PullRequest pullRequest, DateTimeOffset? closedAt, DateTimeOffset createdAt, DateTimeOffset? updatedAt, int id, bool locked, Repository repository)
 {
     Id = id;
     Url = url;
     HtmlUrl = htmlUrl;
     CommentsUrl = commentsUrl;
     EventsUrl = eventsUrl;
     Number = number;
     State = state;
     Title = title;
     Body = body;
     ClosedBy = closedBy;
     User = user;
     Labels = labels;
     Assignee = assignee;
     Milestone = milestone;
     Comments = comments;
     PullRequest = pullRequest;
     ClosedAt = closedAt;
     CreatedAt = createdAt;
     UpdatedAt = updatedAt;
     Locked = locked;
     Repository = repository;
 }
Example #23
0
 public void SetPosition(Vector3 newPosition)
 {
     position = newPosition;
     _state   = ItemState.Dynamic;
     SCALE    = 0.02f;
 }
Example #24
0
        /// <summary>
        /// Saves all the data about a changed article
        /// </summary>
        /// <param name="article">The existing article to update</param>
        /// <param name="articleStruct">The new data to be saved to the article</param>
        /// <param name="saveDocumentSpecificData"></param>
        /// <param name="addVersion">Should a new version be added</param>
        /// <param name="shouldNotify">Should notifications be sent for this update</param>
        /// <returns>The updated Sitecore item representing the article</returns>
        /// <remarks>This method could stand to be refactored into smaller chunks.</remarks>
        private ArticleItem SaveArticleDetails(ArticleItem article, ArticleStruct articleStruct, bool saveDocumentSpecificData, bool addVersion, bool shouldNotify = true)
        {
            var articleItem = _sitecoreMasterService.GetItem <Item>(article._Id);
            var publication = ArticleExtension.GetAncestorItemBasedOnTemplateID(articleItem);

            articleStruct.Publication = publication.ID.Guid;
            //IIPP-243 - Moving the location of the article if needed
            if (!article.IsPublished && article.Planned_Publish_Date != articleStruct.WebPublicationDate)
            {
                MoveArticleIfNecessary(article, articleStruct);
            }
            string userID   = articleItem.Locking.GetOwner();
            bool   loggedIn = false;

            if (!IsNullOrEmpty(userID))
            {
                loggedIn = Sitecore.Context.User.IsAuthenticated;
            }

            var newVersion = article;
            var info       = new WorkflowInfo(Guid.Empty.ToString(), Guid.Empty.ToString());

            try
            {
                Item updatedVersion;

                if (addVersion)
                {
                    using (new EditContext(articleItem))
                    {
                        ItemState itemState = articleItem.State;
                        if (itemState != null)
                        {
                            WorkflowState workflowState = itemState.GetWorkflowState();
                            if (workflowState != null)
                            {
                                IWorkflow workflow = itemState.GetWorkflow();

                                string state = workflowState.StateID;
                                if (workflow != null && state != null)
                                {
                                    info = new WorkflowInfo(workflow.WorkflowID, state);
                                    //					// remove the old version from workflow and prevent from being published
                                    //					// Note: to remove an item from workflow requires using the fields, rather than the SetWorkflowInfo
                                    //					//  method, because the SetWorkflowInfo method does not allow empty strings
                                    articleItem.Fields[Sitecore.FieldIDs.WorkflowState].Value = null;
                                    articleItem.Fields[Sitecore.FieldIDs.HideVersion].Value   = "1";
                                }
                            }
                        }
                        //newVersion = article.InnerItem.Versions.AddVersion();
                        updatedVersion = articleItem.Versions.AddVersion();
                        newVersion     = _sitecoreMasterService.GetItem <ArticleItem>(updatedVersion.ID.ToString());
                    }
                }
                else
                {
                    newVersion = article;
                }
            }
            catch (Exception ex)
            {
                var ax = new ApplicationException("Workflow: Error with versioning/workflow while saving article [" + article.Article_Number + "]!", ex);
                throw ax;
            }

            try
            {
                var newVersionItem = _sitecoreMasterService.GetItem <Item>(newVersion._Id);
                using (new EditContext(newVersionItem))
                {
                    SaveArticleFields(newVersion, article, articleStruct, saveDocumentSpecificData);
                    if (saveDocumentSpecificData)
                    {
                        RenameArticleItem(newVersion, articleStruct);
                    }


                    if (info.StateID != Guid.Empty.ToString() && info.WorkflowID != Guid.Empty.ToString())
                    {
                        // Doing this twice is intentional: when we do it once, the workflow field gets set to the empty string.
                        //  I don't know why, but it does. Doing this twice sets it properly. Doing it not at all causes the
                        //  workflow field to be set to the empty string when leaving the edit context.

                        newVersionItem.Database.DataManager.SetWorkflowInfo(newVersionItem, info);
                        newVersionItem.Database.DataManager.SetWorkflowInfo(newVersionItem, info);

                        if (articleStruct.CommandID != Guid.Empty)
                        {
                            //newVersion.NotificationTransientField.ShouldSend.Checked = true;
                            _articleUtil.ExecuteCommandAndGetWorkflowState(newVersionItem, articleStruct.CommandID.ToString());

                            if (shouldNotify)
                            {
                                _emailUtil.SendNotification(articleStruct, info);
                            }
                        }
                    }
                }

                if (loggedIn)
                {
                    _sitecoreMasterService.GetItem <Item>(newVersion._Id).Locking.Lock();
                }
            }

            catch (Exception ex)
            {
                var ax = new ApplicationException("Workflow: Error with saving details while saving article [" + article.Article_Number + "]!", ex);
                throw ax;
            }

            //  Notifying the Editors when stories are edited after pushlished
            if (articleStruct.IsPublished)
            {
                // Setting the workflow to "Edit After Publish".
                try
                {
                    var newVersionItem = _sitecoreMasterService.GetItem <Item>(newVersion._Id);
                    newVersionItem.Locking.Unlock();

                    using (new EditContext(newVersionItem))
                    {
                        newVersionItem[FieldIDs.WorkflowState] = _siteWorkflow.GetEditAfterPublishState(newVersionItem)._Id.ToString();// Constants.EditAfterPublishWorkflowCommand;
                    }

                    if (loggedIn)
                    {
                        _sitecoreMasterService.GetItem <Item>(newVersion._Id).Locking.Lock();
                    }
                }
                catch (Exception ex)
                {
                    var ax =
                        new ApplicationException(
                            "Workflow: Error with changing the workflow to Edit After Publish [" + article.Article_Number + "]!", ex);
                    throw ax;
                }

                try
                {
                    _emailUtil.EditAfterPublishSendNotification(articleStruct);
                }
                catch (Exception ex)
                {
                    Sitecore.Diagnostics.Log.Error("SitecoreSaverUtil.SaveArticleDetails EditAfterPublishSendNotification(): " + ex.ToString(), this);
                }
            }
            return(newVersion);
        }
Example #25
0
 public ItemProps(LSID name, EnumSet <ItemState> states, ItemState exclusionState)
 {
     Name           = name;
     States         = states;
     ExclusionState = exclusionState;
 }
        internal void OnContainerStateChanged(RadVirtualizingDataControlItem container, IDataSourceItem item, ItemState state)
        {
            container.UpdateItemState(state);

            if (state == ItemState.Realized)
            {
                container.Attach(this);
            }
            else if (state == ItemState.Recycled)
            {
                container.Detach();
            }

            this.OnItemStateChanged(item.Value, state);
        }
Example #27
0
        public override void DrawItem(Graphics g, ImageListViewItem item, ItemState state, Rectangle bounds)
        {
            Clip = false;

            Size      itemPadding = new Size(4, 4);
            Rectangle imageBounds = bounds;

            string text      = Path.GetFileNameWithoutExtension(item.Text);
            Size   szt       = TextRenderer.MeasureText(text, ImageListView.Font);
            int    textWidth = szt.Width + (itemPadding.Width * 2);

            if ((state & ItemState.Hovered) != ItemState.None && textWidth > bounds.Width)
            {
                bounds = new Rectangle(bounds.X + (bounds.Width / 2) - (textWidth / 2), bounds.Y, textWidth, bounds.Height);
            }

            // Paint background
            if (ImageListView.Enabled)
            {
                using (Brush bItemBack = new SolidBrush(ImageListView.Colors.BackColor))
                {
                    g.FillRectangle(bItemBack, bounds);
                }
            }
            else
            {
                using (Brush bItemBack = new SolidBrush(ImageListView.Colors.DisabledBackColor))
                {
                    g.FillRectangle(bItemBack, bounds);
                }
            }

            if ((state & ItemState.Disabled) != ItemState.None) // Paint background Disabled
            {
                using (Brush bDisabled = new LinearGradientBrush(bounds.Offset(1), ImageListView.Colors.DisabledColor1, ImageListView.Colors.DisabledColor2, LinearGradientMode.Vertical))
                {
                    g.FillRectangle(bDisabled, bounds);
                }
            }
            else if ((ImageListView.Focused && ((state & ItemState.Selected) != ItemState.None)) ||
                     (!ImageListView.Focused && ((state & ItemState.Selected) != ItemState.None) && ((state & ItemState.Hovered) != ItemState.None))) // Paint background Selected
            {
                using (Brush bSelected = new LinearGradientBrush(bounds.Offset(1), ImageListView.Colors.SelectedColor1, ImageListView.Colors.SelectedColor2, LinearGradientMode.Vertical))
                {
                    g.FillRectangle(bSelected, bounds);
                }
            }
            else if (!ImageListView.Focused && ((state & ItemState.Selected) != ItemState.None)) // Paint background unfocused
            {
                using (Brush bGray64 = new LinearGradientBrush(bounds.Offset(1), ImageListView.Colors.UnFocusedColor1, ImageListView.Colors.UnFocusedColor2, LinearGradientMode.Vertical))
                {
                    g.FillRectangle(bGray64, bounds);
                }
            }

            // Paint background Hovered
            if ((state & ItemState.Hovered) != ItemState.None)
            {
                using (Brush bHovered = new LinearGradientBrush(bounds.Offset(1), ImageListView.Colors.HoverColor1, ImageListView.Colors.HoverColor2, LinearGradientMode.Vertical))
                {
                    g.FillRectangle(bHovered, bounds);
                }
            }

            // Draw the image
            Image img = item.GetCachedImage(CachedImageType.Thumbnail);

            if (img != null)
            {
                Rectangle pos = Utility.GetSizedImageBounds(img, new Rectangle(imageBounds.Location + itemPadding, ImageListView.ThumbnailSize));
                g.DrawImage(img, pos);
            }

            // Draw item text
            Color foreColor = ImageListView.Colors.ForeColor;

            if ((state & ItemState.Disabled) != ItemState.None)
            {
                foreColor = ImageListView.Colors.DisabledForeColor;
            }
            else if ((state & ItemState.Selected) != ItemState.None)
            {
                if (ImageListView.Focused)
                {
                    foreColor = ImageListView.Colors.SelectedForeColor;
                }
                else
                {
                    foreColor = ImageListView.Colors.UnFocusedForeColor;
                }
            }

            Rectangle       rt = new Rectangle(bounds.Left, bounds.Top + (2 * itemPadding.Height) + ImageListView.ThumbnailSize.Height, bounds.Width, szt.Height);
            TextFormatFlags flags;

            if ((state & ItemState.Hovered) != ItemState.None)
            {
                flags = TextFormatFlags.HorizontalCenter | TextFormatFlags.VerticalCenter | TextFormatFlags.SingleLine | TextFormatFlags.NoClipping;
            }
            else
            {
                flags = TextFormatFlags.HorizontalCenter | TextFormatFlags.VerticalCenter | TextFormatFlags.SingleLine | TextFormatFlags.WordEllipsis;
            }

            TextRenderer.DrawText(g, text, ImageListView.Font, rt, foreColor, flags);
        }
Example #28
0
            /// <summary>
            /// Draws the specified item on the given graphics.
            /// </summary>
            /// <param name="g">The System.Drawing.Graphics to draw on.</param>
            /// <param name="item">The ImageListViewItem to draw.</param>
            /// <param name="state">The current view state of item.</param>
            /// <param name="bounds">The bounding rectangle of item in client coordinates.</param>
            public override void DrawItem(Graphics g, ImageListViewItem item, ItemState state, Rectangle bounds)
            {
                if (ImageListView.View == Manina.Windows.Forms.View.Thumbnails)
                {
                    // Zoom on mouse over
                    if ((state & ItemState.Hovered) != ItemState.None)
                    {
                        bounds.Inflate((int)(bounds.Width * mZoomRatio), (int)(bounds.Height * mZoomRatio));
                        if (bounds.Bottom > ItemAreaBounds.Bottom)
                        {
                            bounds.Y = ItemAreaBounds.Bottom - bounds.Height;
                        }
                        if (bounds.Top < ItemAreaBounds.Top)
                        {
                            bounds.Y = ItemAreaBounds.Top;
                        }
                        if (bounds.Right > ItemAreaBounds.Right)
                        {
                            bounds.X = ItemAreaBounds.Right - bounds.Width;
                        }
                        if (bounds.Left < ItemAreaBounds.Left)
                        {
                            bounds.X = ItemAreaBounds.Left;
                        }
                    }

                    // Get item image
                    Image img = null;

                    if ((state & ItemState.Hovered) != ItemState.None)
                    {
                        img = GetImageAsync(item, new Size(bounds.Width - 8, bounds.Height - 8));
                    }

                    if (img == null)
                    {
                        img = item.ThumbnailImage;
                    }

                    // Calculate image bounds
                    Rectangle pos         = Utility.GetSizedImageBounds(img, Rectangle.Inflate(bounds, -4, -4));
                    int       imageWidth  = pos.Width;
                    int       imageHeight = pos.Height;
                    int       imageX      = pos.X;
                    int       imageY      = pos.Y;

                    // Allocate space for item text
                    if ((state & ItemState.Hovered) != ItemState.None &&
                        (bounds.Height - imageHeight) / 2 < ImageListView.Font.Height + 8)
                    {
                        int delta = (ImageListView.Font.Height + 8) - (bounds.Height - imageHeight) / 2;
                        bounds.Height += 2 * delta;
                        imageY        += delta;
                    }

                    // Paint background
                    using (Brush bBack = new SolidBrush(ImageListView.BackColor))
                    {
                        Utility.FillRoundedRectangle(g, bBack, bounds, 5);
                    }
                    using (Brush bItemBack = new SolidBrush(item.BackColor))
                    {
                        Utility.FillRoundedRectangle(g, bItemBack, bounds, 5);
                    }
                    if ((ImageListView.Focused && ((state & ItemState.Selected) != ItemState.None)) ||
                        (!ImageListView.Focused && ((state & ItemState.Selected) != ItemState.None) && ((state & ItemState.Hovered) != ItemState.None)))
                    {
                        using (Brush bSelected = new LinearGradientBrush(bounds, Color.FromArgb(16, SystemColors.Highlight), Color.FromArgb(64, SystemColors.Highlight), LinearGradientMode.Vertical))
                        {
                            Utility.FillRoundedRectangle(g, bSelected, bounds, 5);
                        }
                    }
                    else if (!ImageListView.Focused && ((state & ItemState.Selected) != ItemState.None))
                    {
                        using (Brush bGray64 = new LinearGradientBrush(bounds, Color.FromArgb(16, SystemColors.GrayText), Color.FromArgb(64, SystemColors.GrayText), LinearGradientMode.Vertical))
                        {
                            Utility.FillRoundedRectangle(g, bGray64, bounds, 5);
                        }
                    }
                    if (((state & ItemState.Hovered) != ItemState.None))
                    {
                        using (Brush bHovered = new LinearGradientBrush(bounds, Color.FromArgb(8, SystemColors.Highlight), Color.FromArgb(32, SystemColors.Highlight), LinearGradientMode.Vertical))
                        {
                            Utility.FillRoundedRectangle(g, bHovered, bounds, 5);
                        }
                    }

                    // Draw the image
                    //g.DrawImage(img, pos);
                    DrawThumbnail(g, item, img, pos);

                    // Draw image border
                    if (Math.Min(imageWidth, imageHeight) > 32)
                    {
                        using (Pen pGray128 = new Pen(Color.FromArgb(128, Color.Gray)))
                        {
                            g.DrawRectangle(pGray128, imageX, imageY, imageWidth, imageHeight);
                        }
                        if (System.Math.Min(imageWidth, imageHeight) > 32)
                        {
                            using (Pen pWhite128 = new Pen(Color.FromArgb(128, Color.White)))
                            {
                                g.DrawRectangle(pWhite128, imageX + 1, imageY + 1, imageWidth - 2, imageHeight - 2);
                            }
                        }
                    }

                    // Draw item text
                    if ((state & ItemState.Hovered) != ItemState.None)
                    {
                        RectangleF rt;
                        using (StringFormat sf = new StringFormat())
                        {
                            rt               = new RectangleF(bounds.Left + 4, bounds.Top + 4, bounds.Width - 8, (bounds.Height - imageHeight) / 2 - 8);
                            sf.Alignment     = StringAlignment.Center;
                            sf.FormatFlags   = StringFormatFlags.NoWrap;
                            sf.LineAlignment = StringAlignment.Center;
                            sf.Trimming      = StringTrimming.EllipsisCharacter;
                            using (Brush bItemFore = new SolidBrush(item.ForeColor))
                            {
                                g.DrawString(item.Text, ImageListView.Font, bItemFore, rt, sf);
                            }
                            rt.Y = bounds.Bottom - (bounds.Height - imageHeight) / 2 + 4;
                            string details = "";
                            if (item.Dimensions != Size.Empty)
                            {
                                details += item.GetSubItemText(ColumnType.MediaDimensions) + " pixels ";
                            }
                            if (item.FileSize != 0)
                            {
                                details += item.GetSubItemText(ColumnType.FileSize);
                            }
                            using (Brush bGrayText = new SolidBrush(Color.Gray))
                            {
                                g.DrawString(details, ImageListView.Font, bGrayText, rt, sf);
                            }
                        }
                    }

                    // Item border
                    using (Pen pWhite128 = new Pen(Color.FromArgb(128, Color.White)))
                    {
                        Utility.DrawRoundedRectangle(g, pWhite128, bounds.Left + 1, bounds.Top + 1, bounds.Width - 3, bounds.Height - 3, 4);
                    }
                    if (ImageListView.Focused && ((state & ItemState.Selected) != ItemState.None))
                    {
                        using (Pen pHighlight128 = new Pen(Color.FromArgb(128, SystemColors.Highlight)))
                        {
                            Utility.DrawRoundedRectangle(g, pHighlight128, bounds.Left, bounds.Top, bounds.Width - 1, bounds.Height - 1, 4);
                        }
                    }
                    else if (!ImageListView.Focused && ((state & ItemState.Selected) != ItemState.None))
                    {
                        using (Pen pGray128 = new Pen(Color.FromArgb(128, SystemColors.GrayText)))
                        {
                            Utility.DrawRoundedRectangle(g, pGray128, bounds.Left, bounds.Top, bounds.Width - 1, bounds.Height - 1, 4);
                        }
                    }
                    else if ((state & ItemState.Selected) == ItemState.None)
                    {
                        using (Pen pGray64 = new Pen(Color.FromArgb(64, SystemColors.GrayText)))
                        {
                            Utility.DrawRoundedRectangle(g, pGray64, bounds.Left, bounds.Top, bounds.Width - 1, bounds.Height - 1, 4);
                        }
                    }

                    if (ImageListView.Focused && ((state & ItemState.Hovered) != ItemState.None))
                    {
                        using (Pen pHighlight64 = new Pen(Color.FromArgb(64, SystemColors.Highlight)))
                        {
                            Utility.DrawRoundedRectangle(g, pHighlight64, bounds.Left, bounds.Top, bounds.Width - 1, bounds.Height - 1, 4);
                        }
                    }
                }
                else
                {
                    base.DrawItem(g, item, state, bounds);
                }
            }
Example #29
0
    /// <summary>
    /// Used to get all of the valid actions for the current state
    /// </summary>
    /// <returns></returns>
    public List <Action> GetValidActions(AIState state)
    {
        List <Action> validActions = new List <Action>();

        //Waiting around
        validActions.Add(new IdleAction());

        //Things you can do when your hands are free
        if (state.CurrentPlayerState.HandsFree())
        {
            //Spawning items
            foreach (IngredientType type in System.Enum.GetValues(typeof(IngredientType)))
            {
                SpawnAction spawnAction = new SpawnAction(type);
                if (spawnAction.isValid(state))
                {
                    validActions.Add(spawnAction);
                }
            }

            PickUpAction pickupAction;
            //Picking up everything
            //Ingredients
            foreach (int ingredientID in state.IngredientStateIndexList)
            {
                IngredientState ingredient = state.ItemStateList[ingredientID] as IngredientState;
                if (ingredient.IsSpawned && !ingredient.IsInMeal)
                {
                    pickupAction = new PickUpAction(ingredient.ID);
                    validActions.Add(pickupAction);
                }
            }

            //Pots
            foreach (int potID in state.PotStateIndexList)
            {
                PotState pot = state.ItemStateList[potID] as PotState;
                pickupAction = new PickUpAction(pot.ID);
                validActions.Add(pickupAction);
            }

            //Plates
            foreach (int plateID in state.PlateStateIndexList)
            {
                PlateState plate = state.ItemStateList[plateID] as PlateState;
                pickupAction = new PickUpAction(plate.ID);
                validActions.Add(pickupAction);
            }

            PrepareAction prepAction;
            foreach (int boardID in state.BoardStateIndexList)
            {
                BoardState bState = state.ItemStateList[boardID] as BoardState;
                if (!bState.IsFree())
                {
                    IngredientState iState = state.ItemStateList[bState.HoldingItemID] as IngredientState;
                    if (iState != null && !iState.IsPrepared)
                    {
                        prepAction = new PrepareAction(boardID);
                        validActions.Add(prepAction);
                    }
                }
            }
        }

        //Things you can do when you have something in hand
        else
        {
            DropOffAction  dropoffAction;
            TransferAction transferAction;
            ItemState      itemState = state.ItemStateList[state.CurrentPlayerState.HoldingItemID];
            ItemType       type      = itemState.MyItemType;

            if (type == ItemType.INGREDIENT)
            {
                //Putting things on the table
                foreach (int tableID in state.TableStateIndexList)
                {
                    TableSpace table = state.ItemStateList[tableID] as TableSpace;
                    if (table.IsFree())
                    {
                        dropoffAction = new DropOffAction(table.ID);
                        validActions.Add(dropoffAction);
                    }
                }

                //Moving ingredients to a cutting board
                foreach (int boardID in state.BoardStateIndexList)
                {
                    BoardState board = state.ItemStateList[boardID] as BoardState;
                    if (board.IsFree())
                    {
                        dropoffAction = new DropOffAction(board.ID);
                        validActions.Add(dropoffAction);
                    }
                }

                if ((itemState as IngredientState).IsPrepared)
                {
                    //Moving ingredients to a pot
                    foreach (int potID in state.PotStateIndexList)
                    {
                        PotState  pot  = state.ItemStateList[potID] as PotState;
                        MealState meal = state.ItemStateList[pot.mealID] as MealState;
                        if (meal.MealSize() + 1 <= PotState.MAX_ITEMS_PER_POT && !meal.IsBurnt())
                        {
                            dropoffAction = new DropOffAction(pot.ID);
                            validActions.Add(dropoffAction);
                        }
                    }

                    //Moving ingredients to a plate
                    foreach (int plateID in state.PlateStateIndexList)
                    {
                        PlateState plate = state.ItemStateList[plateID] as PlateState;
                        MealState  meal  = state.ItemStateList[plate.mealID] as MealState;
                        if (!plate.IsSubmitted && !meal.IsBurnt())
                        {
                            dropoffAction = new DropOffAction(plate.ID);
                            validActions.Add(dropoffAction);
                        }
                    }
                }
            }

            if (type == ItemType.POT)
            {
                PotState  pot  = itemState as PotState;
                MealState meal = state.ItemStateList[pot.mealID] as MealState;

                //Putting the pot on the table
                foreach (int tableID in state.TableStateIndexList)
                {
                    TableSpace table = state.ItemStateList[tableID] as TableSpace;
                    if (table.IsFree())
                    {
                        dropoffAction = new DropOffAction(table.ID);
                        validActions.Add(dropoffAction);
                    }
                }

                //Moving meal to a pot
                transferAction = new TransferAction(Item.NOTHING_ID);
                foreach (int potID in state.PotStateIndexList)
                {
                    transferAction.id = potID;
                    if (transferAction.isValid(state))
                    {
                        validActions.Add(transferAction);
                        transferAction = new TransferAction(Item.NOTHING_ID);
                    }
                }

                //Moving the meal to another plate
                foreach (int plateID in state.PlateStateIndexList)
                {
                    transferAction.id = plateID;
                    if (transferAction.isValid(state))
                    {
                        validActions.Add(transferAction);
                        transferAction = new TransferAction(Item.NOTHING_ID);
                    }
                }
            }

            if (type == ItemType.PLATE)
            {
                PlateState plate = itemState as PlateState;

                //Putting things on the table
                foreach (int tableID in state.TableStateIndexList)
                {
                    TableSpace table = state.ItemStateList[tableID] as TableSpace;
                    if (table.IsFree())
                    {
                        dropoffAction = new DropOffAction(table.ID);
                        validActions.Add(dropoffAction);
                    }
                }

                //If the plate is non-empty
                MealState heldMeal = state.ItemStateList[plate.mealID] as MealState;
                if (heldMeal.IsSpawned())
                {
                    //Submitting the meal
                    if (heldMeal.IsCooked())
                    {
                        SubmitOrderAction submitAction = new SubmitOrderAction();
                        validActions.Add(submitAction);
                    }

                    //Moving meal to a pot
                    transferAction = new TransferAction(Item.NOTHING_ID);
                    foreach (int potID in state.PotStateIndexList)
                    {
                        transferAction.id = potID;
                        if (transferAction.isValid(state))
                        {
                            validActions.Add(transferAction);
                            transferAction = new TransferAction(Item.NOTHING_ID);
                        }
                    }

                    //Moving the meal to another plate
                    foreach (int plateID in state.PlateStateIndexList)
                    {
                        transferAction.id = plateID;
                        if (transferAction.isValid(state))
                        {
                            validActions.Add(transferAction);
                            transferAction = new TransferAction(Item.NOTHING_ID);
                        }
                    }
                }
            }
        }


        return(validActions);
    }
Example #30
0
 public virtual void Get()
 {
     State = ItemState.Held;
     Map.RemoveItem(this);
     if (IsLight)
         Map.RemoveLight(Light);
 }
Example #31
0
        /// <summary>
        /// 创建流程实例
        /// </summary>
        /// <param name="wfItem"></param>
        /// <returns></returns>
        public WfReturn CreateInstance(WfItem wfItem)
        {
            WfReturn  result    = new WfReturn();
            ItemState itemState = ItemState.Beginning;
            WfState   wfState   = WfState.Normal;
            string    orderNo   = string.Empty;

            try
            {
                ////判断该项目的状态是否可以操作
                DataTable dt          = OracleHelper.ExecuteDataTable("select * from xm_xmxx where ItemCode in (" + wfItem.ItemCode + ")");
                WfState   ItemWfState = (WfState)EnumHelper.StringValueToEnum(typeof(WfState), dt.Rows[0]["wfState"].ToString());

                if (ItemWfState != WfState.Normal)
                {
                    result.Success    = false;
                    result.ResultDesc = string.Format("该项目处于{0}状态,无法操作",
                                                      EnumHelper.GetFieldDescription(typeof(WfState), (int)ItemWfState));
                    return(result);
                }

                ////当前环节信息(0为开始环节)
                WfNode curNode = this.GetNodeInfo(this.strFlowId, wfItem.NodeId);
                if (curNode == null)
                {
                    result.Success    = false;
                    result.ResultDesc = "获取当前环节信息失败!";
                    return(result);
                }

                ////下一环节信息
                WfNode nextNode   = null;
                string perNodeId  = string.Empty;
                string nextNodeId = string.Empty;
                ////存在跳转ID
                if (!string.IsNullOrEmpty(wfItem.SwicthNode))
                {
                    perNodeId  = wfItem.SwicthNode;
                    nextNodeId = wfItem.SwicthNode;
                }
                else
                {
                    perNodeId  = curNode.PerNode;
                    nextNodeId = curNode.NextNode;
                }

                ////退回操作--上一结点
                if (wfItem.Result == WfResult.Return)
                {
                    nextNode = this.GetNodeInfo(this.strFlowId, perNodeId);
                }
                ////同意操作--下一结点
                if (wfItem.Result == WfResult.Agree)
                {
                    nextNode = this.GetNodeInfo(this.strFlowId, nextNodeId);
                }

                ArrayList strSql = new ArrayList();
                string    tmpSql = string.Empty;

                if (curNode.PerNode == ((int)WorkFlowNode.Begin).ToString())////开始结点
                {
                    //// 1 删除该项目所有进程信息
                    tmpSql = "delete from wf_instance where itemcode = '{0}'";
                    tmpSql = string.Format(tmpSql, wfItem.ItemCode);
                    strSql.Add(tmpSql);
                    //// 2 插入开始环节的已完成记录
                    tmpSql = "Insert into wf_instance(flowid,itemcode,orderno,nodeid,perNode,nextNode,userid,username,result,resultdesc,begindate,enddate,state)"
                             + " values ('{0}','{1}',1,'{2}','{3}','{4}','{5}','{6}','{7}','{8}',sysdate,sysdate,1)";
                    tmpSql = string.Format(tmpSql, strFlowId, wfItem.ItemCode, curNode.NodeId,
                                           curNode.PerNode, curNode.NextNode, wfItem.UserId, wfItem.UserName,
                                           ((int)wfItem.Result).ToString(), wfItem.ResultDesc);
                    strSql.Add(tmpSql);
                    //// 3 插入下一环节的未完成记录
                    tmpSql = "Insert into wf_instance(flowid,itemcode,orderno,nodeid,perNode,nextNode,userid,username,result,resultdesc,begindate,enddate,state)"
                             + " values ('{0}','{1}',2,'{2}','{3}','{4}','','','','',sysdate,'',0)";
                    tmpSql = string.Format(tmpSql, strFlowId, wfItem.ItemCode, nextNode.NodeId,
                                           nextNode.PerNode, nextNode.NextNode);
                    strSql.Add(tmpSql);
                    itemState = ItemState.Progressing;
                    wfState   = WfState.Normal;
                }
                else ////任务结点
                {
                    //// 更新项目进程表中当前环节的状态
                    tmpSql = "update wf_instance set enddate = sysdate, state = 1,userid = '{2}',username = '******',result = '{4}', resultdesc = '{5}'"
                             + " where itemCode in ({0}) and nodeid = {1} and state = 0";
                    tmpSql = string.Format(tmpSql, wfItem.ItemCode, wfItem.NodeId, wfItem.UserId, wfItem.UserName, ((int)wfItem.Result).ToString(), wfItem.ResultDesc);
                    strSql.Add(tmpSql);

                    //// 插入下一环节的进程信息
                    if (wfItem.Result != WfResult.Delete)
                    {
                        tmpSql = "delete from wf_instance where itemCode in ({0}) and nodeid = {1} and state = 0";
                        tmpSql = string.Format(tmpSql, wfItem.ItemCode, nextNode.NodeId);
                        strSql.Add(tmpSql);

                        ////针对批量操作
                        string[] itemAry = wfItem.ItemCode.Split(',');

                        for (int i = 0; i < itemAry.Length; i++)
                        {
                            orderNo = getOrdernoByItem(itemAry[i]);
                            //// 插入下一环节的未完成记录
                            tmpSql = "Insert into wf_instance(flowid,itemcode,orderno,nodeid,perNode,nextNode,userid,username,result,resultdesc,begindate,enddate,state)"
                                     + " values ('{0}','{1}','{2}','{3}','{4}','{5}','','','','',sysdate,'',0)";
                            tmpSql = string.Format(tmpSql, strFlowId, itemAry[i], orderNo, nextNode.NodeId,
                                                   nextNode.PerNode, nextNode.NextNode);
                            strSql.Add(tmpSql);
                        }
                    }
                    if (nextNode != null)
                    {
                        if (nextNode.NodeType == NodeType.EndNode)
                        {
                            tmpSql = "update wf_instance set enddate = sysdate, state = 1,userid = '{2}',username = '******',result = '{4}', resultdesc = '{5}'"
                                     + " where itemCode in ({0}) and nodeid = {1} and state = 0";
                            tmpSql = string.Format(tmpSql, wfItem.ItemCode, nextNode.NodeId, wfItem.UserId,
                                                   wfItem.UserName, ((int)wfItem.Result).ToString(), wfItem.ResultDesc);
                            strSql.Add(tmpSql);
                        }
                    }

                    switch (wfItem.Result)
                    {
                    case WfResult.Agree:
                        if (nextNode.NodeType == NodeType.EndNode)
                        {
                            wfState   = WfState.Normal;
                            itemState = ItemState.Ending;
                        }
                        else
                        {
                            wfState   = WfState.Normal;
                            itemState = ItemState.Progressing;
                        }
                        break;

                    case WfResult.Return:
                        wfState   = WfState.Normal;
                        itemState = ItemState.Progressing;
                        break;

                    case WfResult.Delete:
                        wfState   = WfState.Delete;
                        itemState = ItemState.Ending;
                        break;
                    }
                }

                if (wfItem.Result == WfResult.Delete)
                {
                    tmpSql = "update xm_xmxx set itemstate = '{1}', wfstate = '{2}', ItemDesc = '{3}',read = 0 where ItemCode in ({0})";
                    tmpSql = string.Format(tmpSql, wfItem.ItemCode, ((int)itemState).ToString(), ((int)wfState).ToString(), wfItem.ResultDesc);
                    strSql.Add(tmpSql);
                }
                else
                {
                    //// 更新项目主表的状态标识
                    tmpSql = "update xm_xmxx set itemstage = '{1}', nodeid = '{2}', itemstate = '{3}', wfstate = '{4}',read = 0  where ItemCode in ({0})";
                    tmpSql = string.Format(tmpSql, wfItem.ItemCode, nextNode.Stage, nextNode.NodeId, ((int)itemState).ToString(), ((int)wfState).ToString());
                    strSql.Add(tmpSql);
                }

                bool succ = OracleHelper.ExecuteCommand(strSql);

                if (succ)
                {
                    if (curNode.NotifyType != string.Empty && nextNode != null)////有消息发送设置
                    {
                        ////发送消息
                        this.notifyUser(curNode, nextNode, wfItem);
                    }
                    result.Success    = true;
                    result.ResultDesc = "成功";
                    if (nextNode != null)
                    {
                        result.Stage    = nextNode.Stage;
                        result.NodeName = nextNode.NodeName;
                        this.changeNodeQx(wfItem.ItemCode.Split(',')[0], ref nextNode);
                        result.DepartList = this.getItemName(1, nextNode.NodeDepartCode);
                        result.RoleList   = this.getItemName(2, nextNode.NodeRoleId);
                        result.UserList   = this.getItemName(3, nextNode.NodeUserId);
                    }
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }
            return(result);
        }
Example #32
0
    // ================================================================ //

    // ?꾩씠???뺣낫 ?⑦궥 痍⑤뱷 ?⑥닔.
    public void OnReceiveItemPacket(int node, PacketId id, byte[] data)
    {
        ItemPacket packet = new ItemPacket(data);
        ItemData   item   = packet.GetPacket();

        // ?쒕쾭 ?곹깭?€ ?숆린??
        ItemState istate = new ItemState();

        istate.item_id = item.itemId;
        ItemController.State state = (ItemController.State)item.state;
        istate.state = (state == ItemController.State.Dropped)? ItemController.State.None : state;
        istate.owner = item.ownerId;
        if (GlobalParam.getInstance().item_table.ContainsKey(istate.item_id))
        {
            GlobalParam.getInstance().item_table.Remove(istate.item_id);
        }
        GlobalParam.getInstance().item_table.Add(istate.item_id, istate);

        string log = "[CLIENT] Receive itempacket [" +
                     "itemId:" + item.itemId +
                     " state:" + state.ToString() +
                     " ownerId:" + item.ownerId + "]";

        Debug.Log(log);
        dbwin.console().print(log);

        if (state == ItemController.State.Picked)
        {
            Debug.Log("Receive item pick.");
            dbwin.console().print("Receive item pick.");

            // ?묐떟???덈뒗  荑쇰━瑜??먯깋.
            QueryItemPick query_pick = QueryManager.get().findQuery <QueryItemPick>(x => x.target == item.itemId);

            bool remote_pick = true;

            if (query_pick != null)
            {
                string account_name = PartyControl.get().getLocalPlayer().getAcountID();
                if (item.ownerId == account_name)
                {
                    Debug.Log("Receive item pick local:" + item.ownerId);
                    dbwin.console().print("Receive item pick local:" + item.ownerId);

                    item_query_done(query_pick, true);
                    remote_pick = false;
                }
                else
                {
                    Debug.Log("Receive item pick remote:" + item.ownerId);
                    dbwin.console().print("Receive item pick remote:" + item.ownerId);

                    item_query_done(query_pick, false);
                }
            }

            if (remote_pick == true)
            {
                Debug.Log("Remote pick item:" + item.ownerId);
                dbwin.console().print("Remote pick item:" + item.ownerId);

                // 由щえ??罹먮┃?곌? 媛€吏€寃??쒕떎.
                chrController remote = CharacterRoot.getInstance().findPlayer(item.ownerId);
                if (remote)
                {
                    // ?꾩씠???띾뱷 荑쇰━ 諛쒗뻾.
                    QueryItemPick query = remote.cmdItemQueryPick(item.itemId, false, true);
                    if (query != null)
                    {
                        item_query_done(query, true);
                    }
                }
            }

            // ?꾩씠???띾뱷 ?곹깭 蹂€寃?
            this.setItemState(item.itemId, ItemController.State.Picked, item.ownerId);
        }
        else if (state == ItemController.State.Dropped)
        {
            Debug.Log("Receive item drop.");

            // ?묐떟???덈뒗 荑쇰━瑜?寃€??
            QueryItemDrop query_drop = QueryManager.get().findQuery <QueryItemDrop>(x => x.target == item.itemId);


            bool remote_drop = true;

            if (query_drop != null)
            {
                // ?붿껌???€???묐떟???덈떎.
                string account_name = AccountManager.get().getAccountData(GlobalParam.get().global_account_id).avator_id;
                if (item.ownerId == account_name)
                {
                    // ?먯떊???띾뱷.
                    Debug.Log("Receive item drop local:" + item.ownerId);
                    item_query_done(query_drop, true);
                    remote_drop = false;
                }
                else
                {
                    // ?곷?媛€ ?띾뱷.
                    Debug.Log("Receive item pick remote:" + item.ownerId);
                    item_query_done(query_drop, false);
                }
            }

            if (remote_drop == true)
            {
                // 由щえ??罹먮┃?곌? ?띾뱷.
                chrController remote = CharacterRoot.getInstance().findPlayer(item.ownerId);
                if (remote)
                {
                    // ?꾩씠?쒗쉷??荑쇰━ 諛쒗뻾.
                    Debug.Log("QuetyitemDrop:cmdItemQueryDrop");
                    remote.cmdItemDrop(item.itemId, false);
                }
            }
        }
        else
        {
            Debug.Log("Receive item error.");
        }
    }
Example #33
0
        private ItemState ReadItem(XmlItem item)
        {
            FBuilder.Length = 0;
            ReadState state   = ReadState.FindLeft;
            int       comment = 0;
            int       i       = 0;

            do
            {
                int c = FSymbolInBuffer == -1 ? FReader.Read() : FSymbolInBuffer;
                FSymbolInBuffer = -1;
                if (c == -1)
                {
                    RaiseException();
                }

                if (state == ReadState.FindLeft)
                {
                    if (c == '<')
                    {
                        state = ReadState.FindRight;
                    }
                    else if (c != ' ' && c != '\r' && c != '\n' && c != '\t')
                    {
                        RaiseException();
                    }
                }
                else if (state == ReadState.FindRight)
                {
                    if (c == '>')
                    {
                        state = ReadState.Done;
                        break;
                    }
                    else if (c == '<')
                    {
                        RaiseException();
                    }
                    else
                    {
                        FBuilder.Append((char)c);
                        i++;
                        if (i == 3 && FBuilder[0] == '!' && FBuilder[1] == '-' && FBuilder[2] == '-')
                        {
                            state           = ReadState.FindComment;
                            comment         = 0;
                            i               = 0;
                            FBuilder.Length = 0;
                        }
                    }
                }
                else if (state == ReadState.FindComment)
                {
                    if (comment == 2)
                    {
                        if (c == '>')
                        {
                            state = ReadState.FindLeft;
                        }
                    }
                    else
                    {
                        if (c == '-')
                        {
                            comment++;
                        }
                        else
                        {
                            comment = 0;
                        }
                    }
                }
            }while (true);

            if (FBuilder[FBuilder.Length - 1] == ' ')
            {
                FBuilder.Length--;
            }

            string    itemText  = FBuilder.ToString();
            ItemState itemState = ItemState.Begin;

            if (itemText.StartsWith("/"))
            {
                itemText  = itemText.Substring(1);
                itemState = ItemState.End;
            }
            else if (itemText.EndsWith("/"))
            {
                itemText  = itemText.Substring(0, itemText.Length - 1);
                itemState = ItemState.Complete;
            }

            item.Name = itemText;
            item.Text = "";

            i = itemText.IndexOf(" ");
            if (i != -1)
            {
                item.Name = itemText.Substring(0, i);
                item.Text = itemText.Substring(i + 1);
            }

            return(itemState);
        }
        public override void DrawItem(Graphics g, ImageListViewItem item, ItemState state, Rectangle bounds)
        {
            Region oldClip = g.Clip;

            g.Clip = new Region(ClientBounds);

            // Paint background
            if ((state & ItemState.Selected) != ItemState.None)
            {
                if ((state & ItemState.Hovered) != ItemState.None)
                {
                    using (Brush bSelected = new SolidBrush(hoveredSelectedColor))
                    {
                        g.FillRectangle(bSelected, bounds);
                    }
                    using (Pen pSelected = new Pen(hoveredSelectedBorderColor))
                    {
                        g.DrawRectangle(pSelected, bounds.X, bounds.Y, bounds.Width - 1, bounds.Height - 1);
                    }
                }
                else if (!ImageListView.Focused)
                {
                    using (Brush bSelected = new SolidBrush(unfocusedSelectedColor))
                    {
                        g.FillRectangle(bSelected, bounds);
                    }
                }
                else
                {
                    using (Brush bSelected = new SolidBrush(focusedSelectedColor))
                    {
                        g.FillRectangle(bSelected, bounds);
                    }
                }
            }
            else if ((state & ItemState.Hovered) != ItemState.None)
            {
                using (Brush bHovered = new SolidBrush(hoveredColor))
                {
                    g.FillRectangle(bHovered, bounds);
                }
            }

            // Draw the image
            Image img = item.GetCachedImage(CachedImageType.Thumbnail);

            if (img != null)
            {
                Rectangle pos = Utility.GetSizedImageBounds(img, new Rectangle(bounds.Location + itemPadding, ImageListView.ThumbnailSize));
                g.DrawImage(img, pos);
            }

            // Draw item text
            Color foreColor = ImageListView.Colors.ForeColor;

            if ((state & ItemState.Disabled) != ItemState.None)
            {
                foreColor = ImageListView.Colors.DisabledForeColor;
            }
            else if ((state & ItemState.Selected) != ItemState.None)
            {
                if (ImageListView.Focused)
                {
                    foreColor = ImageListView.Colors.SelectedForeColor;
                }
                else
                {
                    foreColor = ImageListView.Colors.UnFocusedForeColor;
                }
            }
            Size      szt = System.Windows.Forms.TextRenderer.MeasureText(item.Text, ImageListView.Font);
            Rectangle rt  = new Rectangle(bounds.Left + itemPadding.Width, bounds.Top + 2 * itemPadding.Height + ImageListView.ThumbnailSize.Height, ImageListView.ThumbnailSize.Width, szt.Height);

            System.Windows.Forms.TextRenderer.DrawText(g, item.Text, ImageListView.Font, rt, foreColor,
                                                       System.Windows.Forms.TextFormatFlags.EndEllipsis | System.Windows.Forms.TextFormatFlags.HorizontalCenter | System.Windows.Forms.TextFormatFlags.VerticalCenter | System.Windows.Forms.TextFormatFlags.SingleLine);

            g.Clip = oldClip;
        }
Example #35
0
 public HeadInfo(int _index, ItemState _state = ItemState.UnBuy)
 {
     index = _index;
     state = _state;
 }
Example #36
0
    public bool Transfer(Item item, int ColumnNo)
    {
        if (ColumnNo < 6 && column [ColumnNo] != null)
        {
            stash.Add(column[ColumnNo]);
            EquipmentRemoveCheck(column[ColumnNo]);
            column [ColumnNo] = item;
            stash.Remove(item);
            EquipmentCheck(item);
            ItemState ist = FindInItemStates(item.itemID);
            if (ist != null)
            {
                if (ist.inCD)
                {
                    if (!item.canUse)
                    {
                        SyncItem();
                        return(true);
                    }
                    string   attributes = im.FindInCache(item.itemID).Attributes;
                    string[] splitArray = attributes.Split(new char[2] {
                        '_', ';'
                    }, StringSplitOptions.RemoveEmptyEntries);
                    int       type = int.Parse(splitArray [1]);
                    ItemState ist2 = new ItemState();
                    float     _CD  = 0f;
                    ist2.ID = item.itemID;
                    if (type == 1)
                    {
                        _CD = float.Parse(splitArray[7]);
                    }
                    else if (type == 2)
                    {
                        int tag = int.Parse(splitArray[3]);
                        switch (tag)
                        {
                        case 0:
                            _CD = float.Parse(splitArray[7]);
                            break;

                        case 1:
                            _CD = float.Parse(splitArray[5]);
                            break;

                        default:
                            break;
                        }
                    }
                    ist2.CD       = _CD;
                    ist2.inCD     = true;
                    ist2.inCDTime = 0f;
                    itemStates.Add(ist2);
                }
            }
            return(true);
        }
        else
        {
            return(false);
        }
    }
 public CheckableCompositionViewModel(CompositionViewModel viewModel, ItemState state)
     : this(viewModel)
 {
     State = state;
 }
Example #38
0
    public void UseItem(Item item, int ColumnNo)
    {
        if (!item.canUse)
        {
            return;
        }
        string attributes = im.FindInCache(item.itemID).Attributes;

        string[] splitArray = attributes.Split(new char[2] {
            '_', ';'
        }, StringSplitOptions.RemoveEmptyEntries);
        int type = int.Parse(splitArray [1]);

        if (type == 1)
        {
            float     _addHP      = float.Parse(splitArray[3]);
            float     _extraHP    = float.Parse(splitArray[4]);
            float     _extraSpeed = float.Parse(splitArray[5]);
            float     _lastTime   = float.Parse(splitArray[6]);
            float     _CD         = float.Parse(splitArray[7]);
            ItemState ist         = FindInItemStates(item.itemID);
            if (ist != null)
            {
                if (!ist.inCD)
                {
                    ist.inBUFF     = true;
                    ist.inCD       = true;
                    ist.inCDTime   = 0f;
                    ist.inLastTime = 0f;
                    HP            += _addHP;
                    if (HP >= maxHP)
                    {
                        HP = maxHP;
                    }
                }
                else
                {
                    return;
                }
            }
            else
            {
                ist            = new ItemState();
                ist.ID         = item.itemID;
                ist.inBUFF     = true;
                ist.inCD       = true;
                ist.inCDTime   = 0f;
                ist.inLastTime = 0f;
                ist.LastTime   = _lastTime;
                ist.CD         = _CD;
                ist.extraHP    = _extraHP;
                ist.extraSpeed = _extraSpeed;
                float ratio = HP / maxHP;
                maxHP    += ist.extraHP;
                HP        = ratio * maxHP;
                ordSpeed += ist.extraSpeed;
                HP       += _addHP;
                if (HP >= maxHP)
                {
                    HP = maxHP;
                }
                itemStates.Add(ist);
            }
            item.itemNumber--;
            if (item.itemNumber == 0)
            {
                column[ColumnNo] = null;
            }
        }
        else if (type == 2)
        {
            int tag = int.Parse(splitArray[3]);
            switch (tag)
            {
            case 0: {
                //群体治疗
                float     _heal       = float.Parse(splitArray[4]);
                float     _healRadius = float.Parse(splitArray[5]);
                float     _lastTime   = float.Parse(splitArray[6]);
                float     _CD         = float.Parse(splitArray[7]);
                ItemState ist         = FindInItemStates(item.itemID);
                if (ist != null)
                {
                    if (!ist.inCD)
                    {
                        ist.inBUFF     = true;
                        ist.inCD       = true;
                        ist.inCDTime   = 0f;
                        ist.inLastTime = 0f;
                        healCount++;
                        heal       = _heal;
                        healRadius = _healRadius;
                    }
                    else
                    {
                        return;
                    }
                }
                else
                {
                    ist            = new ItemState();
                    ist.ID         = item.itemID;
                    ist.inBUFF     = true;
                    ist.inCD       = true;
                    ist.inCDTime   = 0f;
                    ist.inLastTime = 0f;
                    ist.LastTime   = _lastTime;
                    ist.CD         = _CD;
                    healCount++;
                    heal       = _heal;
                    healRadius = _healRadius;
                    itemStates.Add(ist);
                }
                item.itemNumber--;
                if (item.itemNumber == 0)
                {
                    column[ColumnNo] = null;
                }
                Debug.Log("use");
                break;
            }

            case 1: {
                //英雄无敌
                float     _lastTime = float.Parse(splitArray[4]);
                float     _CD       = float.Parse(splitArray[5]);
                ItemState ist       = FindInItemStates(item.itemID);
                if (ist != null)
                {
                    if (!ist.inCD)
                    {
                        ist.inBUFF     = true;
                        ist.inCD       = true;
                        ist.inCDTime   = 0f;
                        ist.inLastTime = 0f;
                    }
                    else
                    {
                        return;
                    }
                }
                else
                {
                    ist            = new ItemState();
                    ist.ID         = item.itemID;
                    ist.inBUFF     = true;
                    ist.inCD       = true;
                    ist.inCDTime   = 0f;
                    ist.inLastTime = 0f;
                    ist.LastTime   = _lastTime;
                    ist.CD         = _CD;
                    ist.OP         = true;
                    itemStates.Add(ist);
                }
                item.itemNumber--;
                if (item.itemNumber == 0)
                {
                    column[ColumnNo] = null;
                }
                break;
            }
            }
        }
    }
Example #39
0
        public override void DrawButton(Graphics g, Rectangle rectangle, string text, Font font, StringFormat fmt, ItemState state, bool hasBorder, bool enabled)
        {
            if (enabled)
            {
                switch (state)
                {
                case ItemState.Open:
                case ItemState.Pressed:
                    renderer.DrawGradientItem(g, rectangle, Office2007Renderer._itemToolItemCheckPressColors);
                    break;

                case ItemState.HotTrack:
                    renderer.DrawGradientItem(g, rectangle, Office2007Renderer._itemToolItemSelectedColors);
                    break;

                case ItemState.Normal:
                    renderer.DrawGradientItem(g, rectangle, new Office2007Renderer.GradientItemColors(r1, r2, r3, r4, r1, r2, r3, r4, r5, r5));
                    break;
                }
            }
            else
            {
                renderer.DrawGradientItem(g, rectangle, Office2007Renderer._itemDisabledColors);
            }

            DrawString(g, rectangle, text, fmt, font, enabled);
        }
Example #40
0
    void Update()
    {
        if (Input.GetButton("Item1"))
        {
            if (itemState == ItemState.Item01)
            {
                //print ("Item1_Atack");
                ItemActions Item1Actions = Item01.GetComponent <ItemActions> ();
                Item1Actions.Activate();
            }
            else
            {
                itemState = ItemState.Item01;
            }
        }
        if (Input.GetButton("Item2"))
        {
            if (itemState == ItemState.Item02)
            {
                //print ("Item2_Atack");
            }
            else
            {
                itemState = ItemState.Item02;
            }
        }
        if (Input.GetAxisRaw("Item3") > 0.7)
        {
            if (itemState == ItemState.Item03)
            {
                //print ("Item3_Atack");
            }
            else
            {
                itemState = ItemState.Item03;
            }
        }
        if (Input.GetAxisRaw("Item3") < -0.7)
        {
            if (itemState == ItemState.Item04)
            {
                //print ("Item4_Atack");
            }
            else
            {
                itemState = ItemState.Item04;
            }
        }



        ItemLookdirection = this.GetComponent <CharContolerLogic_simple>().Head.transform.rotation;
        ItemLookIntensity = this.GetComponent <CharContolerLogic_simple>().LookdirectionOut.magnitude;

        rigthX = Input.GetAxisRaw("RightStickX");
        rigthY = Input.GetAxisRaw("RightStickY");

//		print ( "_Item01"+Item01.transform.localRotation+"_Item02"+Item01.transform.localRotation+"_Item03"+Item01.transform.localRotation+"_Item04"+Item01.transform.localRotation);


        //---
        switch (itemState)
        {
        case ItemState.Item01:
            //-
            Item01.transform.parent        = CharRightHand.transform;
            Item01.transform.localPosition = Vector3.zero;
            Item01.transform.localRotation = new Quaternion(0, 0, 0, 0);
            Item01.transform.localScale    = Vector3.one;
            Item01.GetComponentInChildren <Rigidbody>().detectCollisions = true;


            //-

            Item02.transform.parent        = ItemHolder02.transform;
            Item02.transform.localPosition = Vector3.zero;
            Item02.transform.localRotation = new Quaternion(0, 0, 0, 0);
            Item02.transform.localScale    = Vector3.one;
            Item02.GetComponentInChildren <Rigidbody>().detectCollisions = false;


            Item03.transform.parent        = ItemHolder03.transform;
            Item03.transform.localPosition = Vector3.zero;
            Item03.transform.localRotation = new Quaternion(0, 0, 0, 0);
            Item03.transform.localScale    = Vector3.one;
            Item03.GetComponentInChildren <Rigidbody>().detectCollisions = false;

            Item04.transform.parent        = ItemHolder04.transform;
            Item04.transform.localPosition = Vector3.zero;
            Item04.transform.localRotation = new Quaternion(0, 0, 0, 0);
            Item04.transform.localScale    = Vector3.one;
            Item04.GetComponentInChildren <Rigidbody>().detectCollisions = false;

            CharRightHandIdleRot = new Quaternion(-0.4f, 0, 0, 1);
            break;

        case ItemState.Item02:

            Item01.transform.parent        = ItemHolder01.transform;
            Item01.transform.localPosition = Vector3.zero;
            Item01.transform.localRotation = new Quaternion(0, 0, 0, 0);
            Item01.transform.localScale    = Vector3.one;
            Item01.GetComponentInChildren <Rigidbody>().detectCollisions = false;

            //-
            Item02.transform.parent        = CharRightHand.transform;
            Item02.transform.localPosition = Vector3.zero;
            Item02.transform.localRotation = new Quaternion(0, 0, 0, 0);
            Item02.transform.localScale    = Vector3.one;
            Item02.GetComponentInChildren <Rigidbody>().detectCollisions = true;
            //-

            Item03.transform.parent        = ItemHolder03.transform;
            Item03.transform.localPosition = Vector3.zero;
            Item03.transform.localRotation = new Quaternion(0, 0, 0, 0);
            Item03.transform.localScale    = Vector3.one;
            Item03.GetComponentInChildren <Rigidbody>().detectCollisions = false;

            Item04.transform.parent        = ItemHolder04.transform;
            Item04.transform.localPosition = Vector3.zero;
            Item04.transform.localRotation = new Quaternion(0, 0, 0, 0);
            Item04.transform.localScale    = Vector3.one;
            Item04.GetComponentInChildren <Rigidbody>().detectCollisions = false;

            CharRightHandIdleRot = new Quaternion(0.4f, 0, 0, 1);
            break;

        case ItemState.Item03:

            Item01.transform.parent        = ItemHolder01.transform;
            Item01.transform.localPosition = Vector3.zero;
            Item01.transform.localRotation = new Quaternion(0, 0, 0, 0);
            Item01.transform.localScale    = Vector3.one;
            Item01.GetComponentInChildren <Rigidbody>().detectCollisions = false;

            Item02.transform.parent        = ItemHolder02.transform;
            Item02.transform.localPosition = Vector3.zero;
            Item02.transform.localRotation = new Quaternion(0, 0, 0, 0);
            Item02.transform.localScale    = Vector3.one;
            Item02.GetComponentInChildren <Rigidbody>().detectCollisions = false;

            //-
            Item03.transform.parent        = CharRightHand.transform;
            Item03.transform.localPosition = Vector3.zero;
            Item03.transform.localRotation = new Quaternion(0, 0, 0, 0);
            Item03.transform.localScale    = Vector3.one;
            Item03.GetComponentInChildren <Rigidbody>().detectCollisions = true;
            //-

            Item04.transform.parent        = ItemHolder04.transform;
            Item04.transform.localPosition = Vector3.zero;
            Item04.transform.localRotation = new Quaternion(0, 0, 0, 0);
            Item04.transform.localScale    = Vector3.one;
            Item04.GetComponentInChildren <Rigidbody>().detectCollisions = false;

            CharRightHandIdleRot = new Quaternion(0.7f, 0.7f, 0.7f, 0.7f);
            break;

        case ItemState.Item04:


            Item01.transform.parent        = ItemHolder01.transform;
            Item01.transform.localPosition = Vector3.zero;
            Item01.transform.localRotation = new Quaternion(0, 0, 0, 0);
            Item01.transform.localScale    = Vector3.one;
            Item01.GetComponentInChildren <Rigidbody>().detectCollisions = false;

            Item02.transform.parent        = ItemHolder02.transform;
            Item02.transform.localPosition = Vector3.zero;
            Item02.transform.localRotation = new Quaternion(0, 0, 0, 0);
            Item02.transform.localScale    = Vector3.one;
            Item02.GetComponentInChildren <Rigidbody>().detectCollisions = false;

            Item03.transform.parent        = ItemHolder03.transform;
            Item03.transform.localPosition = Vector3.zero;
            Item03.transform.localRotation = new Quaternion(0, 0, 0, 0);
            Item03.transform.localScale    = Vector3.one;
            Item03.GetComponentInChildren <Rigidbody>().detectCollisions = false;

            //-
            Item04.transform.parent        = CharRightHand.transform;
            Item04.transform.localPosition = Vector3.zero;
            Item04.transform.localRotation = new Quaternion(0, 0, 0, 0);
            Item04.transform.localScale    = Vector3.one;
            Item04.GetComponentInChildren <Rigidbody>().detectCollisions = true;
            //-

            CharRightHandIdleRot = new Quaternion(-0.3f, 0, 0, 1);
            break;
        }

        //---

        if (rigthY == 0 && rigthX == 0)
        {
            CharRightHand.transform.parent = this.transform;

            //	CharRightHand.transform.localPosition = Vector3.Lerp(CharRightHand.transform.localPosition,CharRightHandIdlePos, 1f );
            CharRightHand.transform.localRotation = Quaternion.Slerp(CharRightHand.transform.rotation, CharRightHandIdleRot, 1f);
        }
        else
        {
            CharRightHand.transform.parent = this.GetComponent <CharContolerLogic_simple>().Head.transform;

            //print (Mathf.Min(1,ItemLookIntensity));
            CharRightHand.transform.localPosition = new Vector3((1 - ItemLookIntensity) * 0.3f, (-0.05f - CharRightHandIdlePos.y + (ItemLookIntensity * 0.05f)), Mathf.Min(1, (ItemLookIntensity) + 0.5f));

            CharRightHand.transform.rotation = Quaternion.Slerp(CharRightHand.transform.rotation, ItemLookdirection, 0.3f);
        }
    }
Example #41
0
 public ItemPaintArgs(Graphics graphics, Rectangle rectangle, ItemState itemstate)
 {
     Graphics  = graphics;
     Rectangle = rectangle;
     State     = itemstate;
 }
Example #42
0
 public override ItemState BlockBrokenItem(ItemState hand, bool silktouch)
 {
     return(new ItemState {
         Id = (uint)BlockId.Air, MetaValue = 0
     });
 }
Example #43
0
 public void Respawn()
 {
     _state = ItemState.respawning;
     respawnStart = Time.time;
 }
Example #44
0
 public static ImageSource GetImageSource(string directory, ItemState folderType)
 {
     return(GetImageSource(directory, new Size(16, 16), folderType));
 }
 public byte[] GetAndLock(string sessionId, out int lockId, out bool locked, out TimeSpan lockAge, out ItemState state)
 {
     try {
         return(GetAndGetAndLock(true, sessionId, out lockId, out locked, out lockAge, out state));
     } catch (Exception e) {
         throw new SessionStoreException(e.Message, e);
     }
 }
Example #46
0
    /// <summary>
    /// Update is called once per frame
    /// </summary>
    private void Update()
    {
        //transform.position = Vector3.Lerp(transform.position, targetPosition, 5.0f * Time.deltaTime);
        transform.localScale = Vector3.Lerp(transform.localScale, targetScale, 1.0f * Time.deltaTime);

        switch (_state)
        {
            case ItemState.isDown:
                if (transform.position.y > 2.0f)
                {
                    transform.position = new Vector3(transform.position.x, 2.0f, transform.position.z);
                }

                particleSystem.enableEmission = false;
                break;

            case ItemState.isPickedUp:
                particleSystem.enableEmission = false;
                break;

            case ItemState.respawning:
                if (Time.time > respawnStart + respawnTime)
                {
                    //SHERVIN: Can't destroy a photon game object that you don't own.
                    if (photonView.isMine)
                    {
                        // TODO : This should call ObjectPool.Recycle
                        PhotonNetwork.Destroy(gameObject);
                    }
                }
                particleSystem.enableEmission = true;
                break;

            case ItemState.disabled:
                if (Time.time > disableTime + disableTimer)
                {
                    _state = ItemState.isDown;
                }
                break;

            default:
                break;
        }
    }
Example #47
0
 public PullRequest(Uri url, Uri htmlUrl, Uri diffUrl, Uri patchUrl, Uri issueUrl, Uri statusesUrl, int number, ItemState state, string title, string body, DateTimeOffset createdAt, DateTimeOffset updatedAt, DateTimeOffset?closedAt, DateTimeOffset?mergedAt, GitReference head, GitReference @base, User user, User assignee, string mergeCommitSha, bool merged, bool?mergeable, User mergedBy, int comments, int commits, int additions, int deletions, int changedFiles)
 {
     Url            = url;
     HtmlUrl        = htmlUrl;
     DiffUrl        = diffUrl;
     PatchUrl       = patchUrl;
     IssueUrl       = issueUrl;
     StatusesUrl    = statusesUrl;
     Number         = number;
     State          = state;
     Title          = title;
     Body           = body;
     CreatedAt      = createdAt;
     UpdatedAt      = updatedAt;
     ClosedAt       = closedAt;
     MergedAt       = mergedAt;
     Head           = head;
     Base           = @base;
     User           = user;
     Assignee       = assignee;
     MergeCommitSha = mergeCommitSha;
     Merged         = merged;
     Mergeable      = mergeable;
     MergedBy       = mergedBy;
     Comments       = comments;
     Commits        = commits;
     Additions      = additions;
     Deletions      = deletions;
     ChangedFiles   = changedFiles;
 }
Example #48
0
 // FIXME the broken item is not correct
 public override ItemState BlockBrokenItem(ItemState hand, bool silktouch)
 {
     return(new ItemState {
         Id = (uint)BlockId.OakSapling, MetaValue = BlockState.MetaValue
     });
 }
Example #49
0
 public abstract ItemState BlockBrokenItem(ItemState hand, bool silktouch);
Example #50
0
 public void SetItemState(ItemState s)
 {
     state = s;
 }
Example #51
0
 private Color DropDownForegroundColor(ItemState itemState)
 {
     if (itemState == ItemState.Selected) {
         return Color.White;
     }
     else {
         return Color.Gray;
     }
 }
Example #52
0
 public Project(string ownerUrl, string url, int id, string nodeId, string name, string body, int number, ItemState state, User creator, DateTimeOffset createdAt, DateTimeOffset updatedAt)
 {
     OwnerUrl  = ownerUrl;
     Url       = url;
     Id        = id;
     NodeId    = nodeId;
     Name      = name;
     Body      = body;
     Number    = number;
     State     = state;
     Creator   = creator;
     CreatedAt = createdAt;
     UpdatedAt = updatedAt;
 }
Example #53
0
 public virtual bool Drop(int x, int y, Map map)
 {
     if (x >= 0 && x < Map.MAP_WIDTH
         && y >= 0 && y < Map.MAP_HEIGHT)
     {
         PosX = x;
         PosY = y;
         Map = map;
         State = ItemState.Dropped;
         map.AddItem(this);
         if (IsLight && LightOn)
             Light.PlaceAt(x, y, map);
         return true;
     }
     return false;
 }
Example #54
0
 public ChestItemHandler(ItemState item)
     : base(item)
 {
 }
 static PullRequest CreatePullRequest(User user, int id, ItemState state, string title,
     DateTimeOffset createdAt, DateTimeOffset updatedAt, int commentCount)
 {
     var uri = new Uri("https://url");
     return new PullRequest(uri, uri, uri, uri, uri, uri,
         id, state, title, "", createdAt, updatedAt,
         null, null, null, null, user, "", false, null, null, commentCount, 0, 0, 0,
         0);
 }
        protected async Task <int> UpdateIssueItemState(IConsole console, string issueReference, ItemState newState, string comment)
        {
            try
            {
                var(issue, repository) = await GetIssueAsync(issueReference);

                // Check if we're working with an already closed issue
                if (issue.State == newState)
                {
                    _reporter.Warn($"Issue {repository.Owner.Login}/{repository.Name}#{issue.Number} is already {newState.ToString().ToLower()}. No action taken.");

                    return(ReturnCodes.Error);
                }

                // Add an optional comment
                if (!string.IsNullOrEmpty(comment))
                {
                    await GitHubClient.Issue.Comment.Create(repository.Owner.Login, repository.Name, issue.Number, comment);
                }

                // Close the issue
                await GitHubClient.Issue.Update(repository.Owner.Login, repository.Name, issue.Number, new IssueUpdate
                {
                    State = newState
                });

                if (newState == ItemState.Closed)
                {
                    console.Write("Closed ");
                }
                else
                {
                    console.Write("Re-opened ");
                }
                console.Write($"{repository.Owner.Login}/{repository.Name}#{issue.Number}", ConsoleColor.Yellow);
                console.WriteLine();
            }
            catch (CommandValidationException e)
            {
                _reporter.Error(e.Message);

                return(ReturnCodes.Error);
            }

            return(ReturnCodes.Ok);
        }
Example #57
0
    /// <summary>
    /// Use this for initialization
    /// </summary>
    public override void Start()
    {
        base.Start();
        gameObject.tag = "Item";
        _state = ItemState.isDown;
        transform.position = new Vector3(transform.position.x, 2.0f, transform.position.z);

        //targetPosition = transform.position;
        targetScale = Vector3.one;

        transform.Rotate(Vector3.forward, 45);
        transform.Rotate(Vector3.right, 33.3f);
    }
Example #58
0
        internal static async Task <bool> UsePomander(Pomander number, uint auraId = 0)
        {
            if (Core.Me.HasAura(Auras.ItemPenalty) && number != Pomander.Serenity)
            {
                return(false);
            }

            //cannot use pomander while under the auras of rage / lust
            if (Core.Me.HasAnyAura(Auras.Lust, Auras.Rage))
            {
                return(false);
            }

            var data = DeepDungeonManager.GetInventoryItem(number);

            if (data.Count == 0)
            {
                return(false);
            }

            if (data.HasAura)
            {
                return(false);
            }

            if (Core.Me.HasAura(auraId) &&
                Core.Me.GetAuraById(auraId).TimespanLeft > TimeSpan.FromMinutes(1))
            {
                return(false);
            }

            await Coroutine.Wait(5000, () => !DeepDungeonManager.IsCasting);

            var cnt = data.Count;
            await Coroutine.Wait(5000, () => !DeepDungeonManager.IsCasting);

            var wt = new WaitTimer(TimeSpan.FromSeconds(30));

            wt.Reset();
            while (cnt == data.Count && !wt.IsFinished)
            {
                Logger.Verbose("Using Pomander: {0}", number);
                DeepDungeonManager.UsePomander(number);
                await Coroutine.Sleep(150);

                await Coroutine.Wait(5000, () => !DeepDungeonManager.IsCasting);

                data = DeepDungeonManager.GetInventoryItem(number);
            }

            //TODO this is probabbly stored somewhere in the client...
            switch (number)
            {
            case Pomander.Rage:
                PomanderState = ItemState.Rage;
                break;

            case Pomander.Lust:
                PomanderState = ItemState.Lust;
                break;

            case Pomander.Resolution:
                PomanderState = ItemState.Resolution;
                break;
            }

            return(true);
        }
Example #59
0
    /// <summary>
    /// While script is observed (in a PhotonView), this is called by PUN with a stream to write or read.
    /// </summary>
    /// <remarks>
    /// The property stream.isWriting is true for the owner of a PhotonView. This is the only client that
    /// should write into the stream. Others will receive the content written by the owner and can read it.
    ///
    /// Note: Send only what you actually want to consume/use, too!
    /// Note: If the owner doesn't write something into the stream, PUN won't send anything.
    /// </remarks>
    /// <param name="stream">Read or write stream to pass state of this GameObject (or whatever else).</param>
    /// <param name="info">Some info about the sender of this stream, who is the owner of this PhotonView (and GameObject).</param>
    public void OnPhotonSerializeView(PhotonStream stream, PhotonMessageInfo info)
    {
        if (stream.isWriting)
        {
            Vector3 pos = transform.localPosition;
            Quaternion rot = transform.rotation;
            int hlth = health;
            //ItemType itmType = itemType;
            float rspwnTime = respawnTime;
            float rspwnStrt = respawnStart;
            int st = (int)state;
            float dsbleTime = disableTime;
            int tm = (int)team;

            stream.Serialize(ref pos);
            stream.Serialize(ref rot);
            stream.Serialize(ref hlth);
            stream.Serialize(ref rspwnTime);
            stream.Serialize(ref rspwnStrt);
            stream.Serialize(ref st);
            stream.Serialize(ref dsbleTime);
            stream.Serialize(ref tm);
        }
        else
        {
            // Receive latest state information
            Vector3 pos = Vector3.zero;
            Quaternion rot = Quaternion.identity;
            int hlth = 0;
            float rspwnTime = 0;
            float rspwnStrt = 0;
            int st = 0;
            float dsbleTime = 0;
            int tm = 0;

            stream.Serialize(ref pos);
            stream.Serialize(ref rot);
            stream.Serialize(ref hlth);
            stream.Serialize(ref rspwnTime);
            stream.Serialize(ref rspwnStrt);
            stream.Serialize(ref st);
            stream.Serialize(ref dsbleTime);
            stream.Serialize(ref tm);

            transform.position = pos;
            transform.rotation = rot;          // this sample doesn't smooth rotation
            health = hlth;
            respawnTime = rspwnTime;
            respawnStart = rspwnStrt;
            state = (ItemState)st;
            disableTime = dsbleTime;
            team = (Team)tm;
        }
    }
Example #60
0
 public void changeState(ItemState s)
 {
     state = s;
 }