private void ProcessCreateStickResult(AnswerId answer)
        {
            var stick = new StickViewModel();

            stick.FromStick(Client.Listener.СreatingStickerForHander(answer));
            StickCollection.Add(stick);
        }
        //---------------------------------------------------------------------
        #region RemoveSticker

        public void RemoveSticker(StickViewModel sticker)
        {
            if (!OfflineMode)
            {
                Client.Sender.DeleteSticker(Client.User.sticks.IndexOf(sticker.ToStick()));
            }
            StickCollection.Remove(sticker);
        }
        //---------------------------------------------------------------------
        #region CreateStick

        private void CreateStick(object e)
        {
            if (OfflineMode)
            {
                var stick = new StickViewModel();
                stick.Stick.Title = "Title";
                stick.Stick.Contents.Add(new TextContentFrontend("Sample text"));
                StickCollection.Add(stick);
            }
            else
            {
                Client.Sender.CreateSticker();
            }
        }
Exemple #4
0
        public void AssignCutItemToStick(CutItem cutItem)  // this is like a push (or store) in a push-pop scenario;
        {
            if (StickCollection.Capacity <= 0)
            {
                StickCollection.Add(new Stick(_stickLength));
            }

            var stickIsPlaced = false;

            foreach (var stick in StickCollection)
            {
                // assigning the condition to the variable is self-describing code; here it describes the intent w/o a comment per-se
                var cutItemWillFitInStick = (cutItem.CutItemLength <= stick.RemainingSpace); // if it fits it ships
                if (cutItemWillFitInStick)
                {
                    stick.AddCutItemToStick(cutItem);
                    stickIsPlaced = true;
                    break;
                }
            }

            if (!stickIsPlaced)
            {
                var freshStick = new Stick(_stickLength);
                if (cutItem.CutItemLength <= freshStick.RemainingSpace)
                {
                    freshStick.AddCutItemToStick(cutItem);
                    StickCollection.Add(freshStick);
                    stickIsPlaced = true;
                }
            }

            /*
             * todo: Unassigned CutItems; what if the cut is too large for the stick????
             * Example 18 foot cut for a 16 foot stick.
             */
            if (!stickIsPlaced)
            {
                UnassignedCutItems.Add(cutItem);
                stickIsPlaced = true;
            }
        }
        public MainWindowViewModel()
        {
            //---------------------------------------------------------------------
            // Preseting
            StickCollectionInit();
            //---------------------------------------------------------------------

            #region StickListTest

            Random rand = new Random();
            for (int i = 0; i < 3; i++)
            {
                var Stick = new StickModel(creatorId: 0)
                {
                    Title = $"Stick {i} Title",
                    Color = new SolidColorBrush(new Color()
                    {
                        A = 255, R = (byte)rand.Next(256), G = (byte)rand.Next(256), B = (byte)rand.Next(256)
                    })
                };
                Stick.Contents.Add(new TextContent($"Teeeee eeeee eeeeeee eeeeeeeeee eeeeeee eeeeeeeeee eeeeeeeeeeee eeeeeeeeeee eeeeeeeee ee eeext {i}"));
                Stick.Contents.Add(new CheckboxContent($"Checkbox {i}"));

                Stick.Contents.Add(new TextContent($"Text two"));
                Stick.Contents.Add(new CheckboxContent($"Checkbox two"));
                Stick.Contents.Add(new CheckboxContent($"Checkbox three"));

                for (int t = 0; t < rand.Next(5); t++)
                {
                    Stick.Tags.Add($"Tag {t}");
                }

                StickCollection.Add(new StickViewModel()
                {
                    Stick = Stick
                });
            }

            #endregion StickListTest
        }