示例#1
0
 /// <summary>
 /// Fügt der Liste von Darstellungen diese Darstellung hinzu
 /// </summary>
 /// <param name="control"></param>
 public void AddRepresentation(ItemControl control)
 {
     this.Representations.Add(control);
     control.EditorStateChanged   += control.Surface.Database.OnEditorStateChanged;
     control.NetworkDataAvailable += control.Surface.Database.OnNetworkDataAvailable;
     control.FocusRequested       += control.Surface.Database.OnFocusRequested;
 }
示例#2
0
    public void purchaseItem()
    {
        string itemInfo = ShopScreen.selectedItem;

        Debug.Log(itemInfo);
        if (itemInfo == null)
        {
            return;
        }
        Item item = itemHolder.itemConverter(itemInfo);

        if (checkPurchase(item))
        {
            //Update usercurrency
            shopConents.changeCurrency(item);
            ShopScreen.displayWallet(shopConents.getCurrency());
            Debug.Log("Success");
            ItemControl.transferToInventory(item);
        }
        else
        {
            ShopScreen.displayInsufficentFunds();
            return;
        }
    }
        private void EquiparItem(object sender, TappedRoutedEventArgs e)
        {
            Item       ItemSelecionado   = ListItens.SelectedItem as Item;
            Personagem PersonSelecionado = ListPersonagens.SelectedItem as Personagem;

            ItemControl.UsaItem(JogadorAtual, ItemSelecionado, PersonSelecionado);
        }
示例#4
0
 /// <summary>
 /// Entfernt ein ItemControl aus der Ansicht
 /// </summary>
 /// <param name="control"></param>
 protected virtual void HideControl(ItemControl control)
 {
     if (!control.IsHidden)
     {
         control.Hide();
     }
 }
示例#5
0
        private void mTabControl1_SelectedChanged()
        {
            #region 关闭激活
            for (int index = 0; index < dtpControl.Controls.Count; index++)
            {
                ItemControl oneCtrl = dtpControl.Controls[index] as ItemControl;

                oneCtrl.SetActive(false);
            }
            for (int index = 0; index < dtpBase.Controls.Count; index++)
            {
                ItemControl oneCtrl = dtpBase.Controls[index] as ItemControl;

                oneCtrl.SetActive(false);
            }

            for (int index = 0; index < dtpCollection.Controls.Count; index++)
            {
                ItemControl oneCtrl = dtpCollection.Controls[index] as ItemControl;


                oneCtrl.SetActive(false);
            }
            itemInfo.Text = "";
            #endregion
        }
示例#6
0
        public CResultAErreurType <CListeParametresInspiration> MajChamps()
        {
            CResultAErreur result = CResultAErreur.True;
            CResultAErreurType <CListeParametresInspiration> resRetour = new CResultAErreurType <CListeParametresInspiration>();
            CListeParametresInspiration lst = new CListeParametresInspiration();

            if (CurrentItemIndex != null)
            {
                ItemControl.MajChamps();
            }
            foreach (CCustomizableListItem item in Items)
            {
                CParametreInspirationProprieteDeType parametre = item.Tag as CParametreInspirationProprieteDeType;
                if (parametre != null)
                {
                    result = parametre.VerifieDonnees();
                    if (!result)
                    {
                        resRetour.EmpileErreur(result.Erreur);
                        return(resRetour);
                    }
                    lst.Add(parametre);
                }
            }
            resRetour.DataType = lst;
            return(resRetour);
        }
示例#7
0
    public void LoadPrefabs()
    {
        GameObject river = (GameObject)Instantiate(Resources.Load("Prefabs/River", typeof(GameObject)), Vector3.up, Quaternion.identity, null);

        river.name = "River";
        fromShore  = new ShoreControl("From");
        toShore    = new ShoreControl("To");
        boat       = new BoatControl();

        for (int i = 0; i < 3; i++)
        {
            ItemControl item = new ItemControl("Priest");
            item.item.name = "Priest" + i;
            item.item.transform.position = fromShore.GetEmptyPosition();
            item.GetOnShore(fromShore);
            fromShore.GetOnShore(item);

            itemCtrls[i] = item;
        }

        for (int i = 0; i < 3; i++)
        {
            ItemControl item = new ItemControl("Devil");
            item.item.name = "Devil" + i;
            item.item.transform.position = fromShore.GetEmptyPosition();
            item.GetOnShore(fromShore);
            fromShore.GetOnShore(item);

            itemCtrls[i + 3] = item;
        }
    }
示例#8
0
 public FrmItem()
 {
     InitializeComponent();
     _itemModel = new ItemModel();
     _itemModel.Attach(this);
     _itemControl = new ItemControl(_itemModel);
 }
示例#9
0
 public void RemoveItem(ItemControl removeItem)
 {
     if (item == removeItem)
     {
         item = null;
     }
 }
        public override void LoadData()
        {
            _allowToSave = false;

            Contents.LoadData();

            foreach (var itemControl in xtraTabControl.TabPages.OfType <ItemControl>().ToList())
            {
                xtraTabControl.TabPages.Remove(itemControl);
            }

            foreach (var itemState in SlideContainer.EditedContent.ApproachState.TabA.Items.OrderBy(item => item.Index))
            {
                var itemInfo = CustomTabInfo.ApproachItems.FirstOrDefault(item =>
                                                                          String.Equals(item.Id, itemState.Id, StringComparison.OrdinalIgnoreCase));
                if (itemInfo != null)
                {
                    var itemControl = new ItemControl(itemInfo, this);
                    xtraTabControl.TabPages.Add(itemControl);
                    itemControl.LoadData();
                }
            }

            _allowToSave = true;
        }
示例#11
0
        private void StateManager_Cleared(object sender, EventArgs e)
        {
            this.InvokeSafe(new System.Action(() =>
            {
                if (Monitor.TryEnter(lpScannedFiles, TIMEOUT))
                {
                    try
                    {
                        foreach (ItemControl cnt in lpScannedFiles.Controls)
                        {
                            cnt.Click   -= new EventHandler(ImageIconControl_Click);
                            cnt.Updated -= new EventHandler(ImageIconControl_Updated);
                            //cnt.DisposeSf();
                            ItemControl.SetInstance(cnt);
                        }

                        ToolTip1.RemoveAll();
                        lpScannedFiles.Controls.Clear();
                        tbTransferFile.Clear();

                        m_ScanFileOrganizer.Clear();
                        m_SendFileOrganizer.Clear();

                        lblItemsWithErr.Text = null;
                        lblMessage.Text      = string.Empty;
                    }
                    finally
                    {
                        Monitor.Exit(lpScannedFiles);
                    }
                }
                //m_ControlIndexes.Clear();
            }));
        }
示例#12
0
 private void StateManager_ItemRemoved(object sender, ItemEventArgs e)
 {
     this.InvokeSafe(new System.Action <ItemEventArgs>((args) =>
     {
         if (Monitor.TryEnter(lpScannedFiles, TIMEOUT))
         {
             try
             {
                 foreach (Control cnt in lpScannedFiles.Controls)
                 {
                     var icnt = (ItemControl)cnt;
                     if (icnt != null && icnt.Item != null && icnt.Item.Equals(args.Item))
                     {
                         lpScannedFiles.Controls.Remove(icnt);
                         //icnt.DisposeSf();
                         ItemControl.SetInstance(icnt);
                         break;
                     }
                 }
             }
             finally
             {
                 Monitor.Exit(lpScannedFiles);
             }
         }
     }), e);
 }
        private void OnItemStateChanged(Object sender, ItemChangedEventArgs e)
        {
            if (!_allowToSave)
            {
                return;
            }

            var itemInfo = e.ItemInfo;

            if (e.Checked)
            {
                var itemControl = new ItemControl(itemInfo, this);
                xtraTabControl.TabPages.Add(itemControl);
                itemControl.LoadData();
            }
            else
            {
                var itemControl = xtraTabControl.TabPages
                                  .OfType <ItemControl>()
                                  .FirstOrDefault(control =>
                                                  String.Equals(control.ItemInfo.Id, itemInfo.Id, StringComparison.OrdinalIgnoreCase));
                if (itemControl != null)
                {
                    SlideContainer.EditedContent.ApproachState.TabA.Items.RemoveAll(item =>
                                                                                    String.Equals(item.Id, itemControl.ItemInfo.Id, StringComparison.OrdinalIgnoreCase));
                    xtraTabControl.TabPages.Remove(itemControl);
                }
            }

            SlideContainer.RaiseSlideTypeChanged();
            RaiseEditValueChanged();
        }
示例#14
0
 private void BrokenItem()
 {
     if (isItem)
     {
         ItemControl newitem = Instantiate(_item, transform.position, Quaternion.identity, null);
     }
     gameObject.SetActive(false);
 }
    // Start is called before the first frame update
    void Start()
    {
        itemlist       = new List <Item>();
        itemController = new ItemControl();

        AddNewItem("knife", 100, ItemType.Weapon, 10, 1); // 주인공 무기
        AddNewItem("doma", 100, ItemType.Weapon, 10, 1);  // 조수 무기
    }
        public ItemControl GetItemControlById(int id)
        {
            ItemControl itemControl = db.ItemControl
                                      .Where(ic => ic.Id == id)
                                      .FirstOrDefault();

            return(itemControl);
        }
示例#17
0
 public override void AfterSettingsLoaded(ItemControl control)
 {
     DisplaySettings.DisplaySettings ds = control.DisplaySettings.CurrentDisplaySettings;
     if (!ds.Initialized)
     {
         control.Item.ExternalDataChanged += Item_ExternalDataChanged;
         ds.Initialized = true;
     }
 }
示例#18
0
 /// <summary>
 /// Zeigt eine ItemControl in dieser Ansicht an und lädt dafür die DisplaySettings.
 /// </summary>
 /// <param name="control"></param>
 protected virtual void ShowControl(ItemControl control)
 {
     VisibleControls.Add(control);
     settingsLoader.LoadSettings(control.DisplaySettings);
     if (control.IsHidden)
     {
         control.Show();
     }
 }
示例#19
0
        private void ic_FocusChangeEvent(object sender, ActiveEventArgs e)
        {
            ItemControl ic = sender as ItemControl;

            if (ic == null)
            {
                return;
            }


            // 修改鼠标状态
            ItemClass itemData = ic.getData();

            dpDrawPanel.setCursor(e.State, itemData);

            if (itemData.itemtype == ItemType.Control)
            {
                for (int index = 0; index < dtpControl.Controls.Count; index++)
                {
                    ItemControl oneCtrl = dtpControl.Controls[index] as ItemControl;

                    if (oneCtrl.Name == ic.Name)
                    {
                        continue;
                    }
                    oneCtrl.SetActive(false);
                }
            }
            else if (itemData.itemtype == ItemType.Module)
            {
                for (int index = 0; index < dtpBase.Controls.Count; index++)
                {
                    ItemControl oneCtrl = dtpBase.Controls[index] as ItemControl;

                    if (oneCtrl.Name == ic.Name)
                    {
                        continue;
                    }
                    oneCtrl.SetActive(false);
                }
            }
            else if (itemData.itemtype == ItemType.Collection)
            {
                for (int index = 0; index < dtpCollection.Controls.Count; index++)
                {
                    ItemControl oneCtrl = dtpCollection.Controls[index] as ItemControl;

                    if (oneCtrl.Name == ic.Name)
                    {
                        continue;
                    }
                    oneCtrl.SetActive(false);
                }
            }

            itemInfo.Text = itemData.itemInfo;
        }
示例#20
0
        /// <summary>
        /// Speichert die DisplaySettings einer ItemControl als XML-Element (Schritt 1 / 2)
        /// </summary>
        /// <param name="control"></param>
        /// <returns></returns>
        private XElement EncodeRepresentation(ItemControl control)
        {
            XElement root = new XElement("Representation");

            foreach (KeyValuePair <int, DisplaySettings> settings in control.DisplaySettings)
            {
                root.Add(EncodeDisplaySettings(settings));
            }
            return(root);
        }
示例#21
0
        private async void ExecuteRunDialog(object o)
        {
            var view = new ItemControl()
            {
                DataContext = new ItemControlViewModel(o as SIT2_Item)
            };

            //show the dialog
            var result = await DialogHost.Show(view, "RootDialog");
        }
        /// <summary>
        /// Setzt die DisplaySettings um
        /// </summary>
        /// <param name="settings"></param>
        protected override void LoadSettingsFinally(DisplaySettingsCollection settings)
        {
            ItemControl control = settings.Representation;

            DisplaySettings.DisplaySettings ds = settings.SetDisplaySettings(_viewMode);

            control.MoveCenter(ds.CenterX, ds.CenterY, true);
            control.Rotate(ds.Rotation, true);
            control.Scale(ds.Scale, true);
        }
 public ItemControl AddItemControlToListadoInspeccion(ItemControl itemControl, ListadoInspeccion listadoInspeccion, int orden)
 {
     db.Set <ListadoInspeccion_ItemControl>().Add(new ListadoInspeccion_ItemControl()
     {
         ItemControlId       = itemControl.Id,
         Orden               = orden,
         ListadoInspeccionId = listadoInspeccion.Id
     });
     return(itemControl);
 }
示例#24
0
        //------------------------------------------------------------
        public CResultAErreur MajChamps()
        {
            CResultAErreur result = CResultAErreur.True;

            if (ItemControl != null && CurrentItemIndex != null)
            {
                result = ItemControl.MajChamps();
            }
            return(result);
        }
示例#25
0
        private void CreateRowOfItemDetailsInto(List <int> itemRowList, int row)
        {
            try
            {
                int center = (pnlItemDetailInto.Width / 2);
                int yPos   = (row - 1) * 70;
                int xPos   = center - (itemRowList.Count() * (50 / 2));
                for (int i = 0; i < itemRowList.Count(); i++)
                {
                    CreateItemDiv item = new CreateItemDiv();

                    item = getItemsFromServer.itemsPrepared.FirstOrDefault(o => o.thisID == itemRowList[i]);

                    if (item.thisID != 0)
                    {
                        ItemControl itemControl = new ItemControl(form1, this);
                        itemControl.ItemCostLabel = item.aItem.Gold.TotalPrice.ToString();
                        string file = string.Format(@"{0}\Data\Items\Images\{1}", PublicStaticVariables.thisAppDataDir, item.thisVersion);
                        string dir  = string.Format(@"{0}\Data\Items\Images\{1}", PublicStaticVariables.thisAppDataDir, item.thisVersion);

                        if (!Directory.Exists(dir))
                        {
                            Directory.CreateDirectory(dir);
                        }

                        Image temp = Image.FromFile(string.Format(@"{0}\{1}", file, item.aItem.Image.Sprite));
                        itemControl.ItemImage = CommonMethods.cropImage(temp, new Rectangle(item.aItem.Image.X, item.aItem.Image.Y, item.aItem.Image.Width, item.aItem.Image.Height));

                        itemControl.Name = "ItemControlInto " + item.aItem.Name;

                        itemControl.item = item;

                        itemControl.Location = new Point(xPos, yPos);
                        itemControl.Click   += itemControl_Click;

                        pnlItemDetailInto.Controls.Add(itemControl);
                        xPos += 50;
                    }
                    else
                    {
                        XtraMessageBox.Show(string.Format(@"This is awkward.. So, there was a reference to an item ID that does NOT exist.
Either Rito forgot to remove this reference when they deleted an item 
or Rito for some reason has an incorrect item ID listed
or Rito is planning to add a new item but didnt finish the job (Im hoping for this one)
or something went horribly wrong.
Please continue : )"), "League Build Stats - Notice");
                    }
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.ToString());
            }
        }
示例#26
0
        public MainBarHandler()
        {
            ListView   = new ItemControl <MainBarControl>();
            HitTesting = new HitTesting {
                W = 1600, H = 200, Y = 900, X = 0
            };
            GameManager.Instance.GManager.GRef.D3OverlayControl.HitTesting.Add(HitTesting);
            Control = ListView.D3RenderControl;

            (Control as UserControl).Loaded += (s, e) => Initialize();
        }
        public ItemControl UpdateItemControlInListadoInspeccion(ItemControl itemControl, ListadoInspeccion listadoInspeccion, int orden)
        {
            ListadoInspeccion_ItemControl listItemControl = db.Set <ListadoInspeccion_ItemControl>()
                                                            .Where(x => x.ListadoInspeccionId == listadoInspeccion.Id && x.ItemControlId == itemControl.Id)
                                                            .FirstOrDefault();

            listItemControl.ItemControlId       = itemControl.Id;
            listItemControl.Orden               = orden;
            listItemControl.ListadoInspeccionId = listadoInspeccion.Id;
            db.Update(listItemControl);
            return(itemControl);
        }
		public ListView ()
		{
			background_color = Color.White;//ThemeEngine.Current.ColorWindow;
			groups = new ListViewGroupCollection (this);
			items = new ListViewItemCollection (this);
			items.Changed += new CollectionChangedHandler (OnItemsChanged);
			checked_indices = new CheckedIndexCollection (this);
			checked_items = new CheckedListViewItemCollection (this);
			columns = new ColumnHeaderCollection (this);
			foreground_color = SystemColors.WindowText;
			selected_indices = new SelectedIndexCollection (this);
			selected_items = new SelectedListViewItemCollection (this);
			items_location = new Point [16];
			items_matrix_location = new ItemMatrixLocation [16];
			reordered_items_indices = new int [16];
			item_tooltip = new ToolTip ();
			item_tooltip.Active = false;
			insertion_mark = new ListViewInsertionMark (this);

			InternalBorderStyle = BorderStyle.Fixed3D;

			header_control = new HeaderControl (this);
			header_control.Visible = false;
			Controls.AddImplicit (header_control);

			item_control = new ItemControl (this);
			Controls.AddImplicit (item_control);

			h_marker = v_marker = 0;
			keysearch_tickcnt = 0;

			// scroll bars are disabled initially
			
			h_scroll.Visible = false;
			//h_scroll.ValueChanged += new EventHandler(HorizontalScroller);
			v_scroll.Visible = false;
			//v_scroll.ValueChanged += new EventHandler(VerticalScroller);

			// event handlers
			base.KeyDown += new KeyEventHandler(ListView_KeyDown);
			SizeChanged += new EventHandler (ListView_SizeChanged);
			//GotFocus += new EventHandler (FocusChanged);
			//LostFocus += new EventHandler (FocusChanged);
			//MouseWheel += new MouseEventHandler(ListView_MouseWheel);
			//MouseEnter += new EventHandler (ListView_MouseEnter);
			Invalidated += new InvalidateEventHandler (ListView_Invalidated);

			BackgroundImageTiled = false;

			this.SetStyle (ControlStyles.UserPaint | ControlStyles.StandardClick
				| ControlStyles.UseTextForAccessibility
				, false);
		}
示例#29
0
    private void OnTriggerEnter2D(Collider2D col)
    {
        Vector3    initPos = transform.position;
        Quaternion initRot = Quaternion.identity;


        if (col.gameObject.tag == "bullet")
        {
            Destroy(this.gameObject);
            ItemControl newitem = Instantiate(_item, initPos, initRot);
        }
    }
        private static FrameworkElement ExtractItem(DisplayOption option)
        {
            var ctrl = new ItemControl {
                Margin = new Thickness(3)
            };

            ctrl.SetBinding(FrameworkElement.DataContextProperty, new Binding(option.PropertyName));
            if (option.Wide)
            {
                ctrl.SetValue(Grid.ColumnSpanProperty, 2);
            }
            return(ctrl);
        }
        public ItemControl GetItemControlInListadoInspeccion(int id, Guid IdListadoInspeccion)
        {
            ItemControl itemControl = (from li in db.ListadoInspeccion_ItemControl
                                       join i in db.ItemControl on li.ItemControlId equals i.Id
                                       where li.ListadoInspeccionId == IdListadoInspeccion && li.ItemControlId == i.Id
                                       select i)
                                      .FirstOrDefault <ItemControl>();

            //ItemControl itemControl = db.ListadoInspeccion_ItemControl
            //                            .Where(lic => lic.ItemControlId == id && lic.ListadoInspeccionId == IdListadoInspeccion)
            //                            .Select(lic => lic.ItemControl)
            //                           .FirstOrDefault();
            return(itemControl);
        }
示例#32
0
 /// <summary>
 /// Required method for Designer support - do not modify
 /// the contents of this method with the code editor.
 /// </summary>
 private void InitializeComponent()
 {
     this.ucBudget = new MoneyFlow.UI.ItemControl();
     this.SuspendLayout();
     //
     // ucBudget
     //
     this.ucBudget.ButtonCloseVisible = true;
     this.ucBudget.Dock = System.Windows.Forms.DockStyle.Fill;
     this.ucBudget.Location = new System.Drawing.Point(10, 10);
     this.ucBudget.Name = "ucBudget";
     this.ucBudget.Size = new System.Drawing.Size(374, 466);
     this.ucBudget.TabIndex = 0;
     this.ucBudget.ButtonDeleteClick += new MoneyFlow.UI.ItemControl.ButtonDeleteClickEventHandler(this.ucBudget_ButtonDeleteClick);
     this.ucBudget.ButtonCloseClick += new MoneyFlow.UI.ItemControl.ButtonCloseClickEventHandler(this.ucBudget_ButtonCloseClick);
     this.ucBudget.ButtonEditClick += new MoneyFlow.UI.ItemControl.ButtonEditClickEventHandler(this.ucBudget_ButtonEditClick);
     this.ucBudget.ButtonAddClick += new MoneyFlow.UI.ItemControl.ButtonAddClickEventHandler(this.ucBudget_ButtonAddClick);
     this.ucBudget.CellDoubleClick += new MoneyFlow.UI.ItemControl.CellDoubleClickEventHandler(this.ucBudget_CellDoubleClick);
     //
     // BudgetForm
     //
     this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
     this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
     this.ClientSize = new System.Drawing.Size(394, 486);
     this.Controls.Add(this.ucBudget);
     this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedDialog;
     this.KeyPreview = true;
     this.MaximizeBox = false;
     this.MinimizeBox = false;
     this.Name = "BudgetForm";
     this.Padding = new System.Windows.Forms.Padding(10);
     this.ShowInTaskbar = false;
     this.StartPosition = System.Windows.Forms.FormStartPosition.CenterParent;
     this.Text = "Budget";
     this.Load += new System.EventHandler(this.BudgetForm_Load);
     this.KeyDown += new System.Windows.Forms.KeyEventHandler(this.BudgetForm_KeyDown);
     this.ResumeLayout(false);
 }
示例#33
0
            private void UnsubscribeItemEvents(ItemControl itemControl)
            {
                itemControl.SelectionBoxClicked -= itemControl_SelectionBoxClicked;
                itemControl.GotFocus -= itemControl_GotFocus;

                if (itemControl.CanChangeSize)
                    itemControl.SizeChanged -= itemControl_SizeChanged;
            }
示例#34
0
 private void UnsubscribeItemEvents(ItemControl itemControl)
 {
    
     itemControl.ValueChanged -= itemControl_ValueChanged;            
 }
示例#35
0
        // Rebuild all item controls when the selected collection object has changed
        private void RebuildItemControls(object collectionObject)
        {
            m_activeCollectionNode = collectionObject;
            var array = m_context.Descriptor.GetValue(m_context.LastSelectedObject) as Array;
            m_lastKnownSize = array.Length;

            // Set index column width to be big enough to display the highest expected index,
            // using double the number of current items as first estimate.
            // This could be done more accurately with MeasureString and could also be dynamically
            // adjusted if the number exceeds the current max due to add operations.
            m_indexColumnWidth = Math.Max(30, (array.Length * 2).ToString().Length * 10);

            try
            {
                SuspendLayout();

                m_toolStrip.Enabled = false;

                // Clear and dispose all current item controls
                foreach (ItemControl itemControl in m_itemControls.Values)
                {
                    UnsubscribeItemEvents(itemControl);
                    Controls.Remove(itemControl);
                    itemControl.Dispose();
                }
                m_itemControls.Clear();


                // Add controls for added items
                // Currently only adding at the end is supported. If we ever want to support 
                // inserting in the middle, then we'd probably want to have this step before 
                // the index-reordering one.
                int top = m_toolStrip.Height;
                var controlsToAdd = new List<ItemControl>();
                int id = 0;
                foreach (object item in array)
                {
                    // Work around for a very strange bug related to the parent Control having a custom font.
                    // It seems to be important to not have this ItemControl's Font property set when adding
                    //  it to our Controls, in the call to Controls.AddRange() below.
                    // The parent Control is probably a Sce.Atf.Controls.PropertyEditing.PropertyGridView.
                    // See this tracker item: http://tracker.ship.scea.com/jira/browse/CORETEXTEDITOR-363
                    Font defaultFont = (Parent != null) ? Parent.Font : Font;

                    var itemControl = new ItemControl(m_itemControls.Count, item, m_indexColumnWidth)
                    {
                        Width = m_toolStrip.Width,
                        Anchor = AnchorStyles.Top | AnchorStyles.Left | AnchorStyles.Right,
                        Top = top,
                        Index = id,
                        Font = defaultFont
                    };

                    top += itemControl.Height;                    
                    m_itemControls.Add(id, itemControl);
                    controlsToAdd.Add(itemControl);
                    SubscribeItemEvents(itemControl);
                    id++;
                }
                Controls.AddRange(controlsToAdd.ToArray());

                Height = top; // update height of main collection control

                UpdateAddButton();
                UpdateDeleteButton(true);
                UpdateMoveButtons(true);
            }
            catch (Win32Exception ex)
            {
                // For very large collections (with 1000+ items) it is possible that Windows runs out of Window handles
                // Such collections are currently not usable with this editor. To support such collections we'd have to
                // implement some kind of virtual mode (i.e. stream items in and out) but that would pose some new
                // challenges for editing operations (add, remove, move)

                // Clean up to release some window handles and keep the application running smoothly
                foreach (ItemControl control in m_itemControls.Values)
                {
                    if (Controls.Contains(control))
                        Controls.Remove(control);
                    control.Dispose();
                }
                m_itemControls.Clear();

                // Report error. Must be done after cleaning up, as before we may not even have the resources to show the message box.
                MessageBox.Show(
                    "Failed to create item controls, probably because there were not enough Window handles available. Consider using a different editor for collections of this size and nature.\r\n\r\n"
                    + ex.GetType().ToString() + Environment.NewLine
                    + ex.Message,
                    "Failed to create item controls", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
            finally
            {
                ResumeLayout();
                m_toolStrip.Enabled = true;
            }
        }
示例#36
0
        private void SelectItemControl(ItemControl selectedControl)
        {
            bool shiftKeyDown = (ModifierKeys & Keys.Shift) != 0;
            bool ctrlKeyDown = (ModifierKeys & Keys.Control) != 0;

            int index = -1;
            if (selectedControl != null)
                index = selectedControl.Index;

            // Nothing selected: clear selection
            if (selectedControl == null || index < 0)
            {
                foreach (ItemControl c in m_itemControls.Values)
                    c.Selected = false;
                return;
            }

            if (shiftKeyDown)
            {
                if (ctrlKeyDown) // Shift+Ctrl: Expand range
                {
                    int min = index;
                    int max = index;
                    foreach (ItemControl c in m_itemControls.Values)
                    {
                        if (c.Selected)
                        {
                            if (c.Index < min)
                                min = c.Index;
                            else if (c.Index > max)
                                max = c.Index;
                        }
                    }
                    foreach (ItemControl c in m_itemControls.Values)
                        c.Selected = (c.Index >= min && c.Index <= max);
                }
                else // Shift only: Select range from first selection
                {
                    int min = Math.Min(index, m_firstSelectedIndex);
                    int max = Math.Max(index, m_firstSelectedIndex);
                    foreach (ItemControl c in m_itemControls.Values)
                        c.Selected = (c.Index >= min && c.Index <= max);
                }
            }
            else if (ctrlKeyDown) // Ctrl only: Toggle selection
            {
                m_firstSelectedIndex = index;
                selectedControl.Selected = !selectedControl.Selected;
            }
            else // No modifyer key: New, normal selection
            {
                m_firstSelectedIndex = index;
                foreach (ItemControl c in m_itemControls.Values)
                    c.Selected = (c.Index == index);
            }

            UpdateDeleteButton(true);
            UpdateMoveButtons(true);
        }
示例#37
0
 private void UnsubscribeItemEvents(ItemControl itemControl)
 {
     itemControl.SelectionBoxClicked -= itemControl_SelectionBoxClicked;
     itemControl.GotFocus -= itemControl_GotFocus;
     itemControl.ValueChanged -= itemControl_ValueChanged;            
 }
示例#38
0
 private void SubscribeItemEvents(ItemControl itemControl)
 {                
     itemControl.SizeChanged += itemControl_SizeChanged;
 }
            /// <summary>
            /// Processes all pending adds, removes, moves and changes</summary>
            private void ProcessPendingChanges()
            {
                if (m_processingPendingChanges)
                    return;
                try
                {
                    m_processingPendingChanges = true;
                    SuspendLayout();
                    //m_toolStrip.Enabled = false; //This sets the focus to the next control in the tab group, which changes the property selection

                    // Check if the selection has changed
                    object selected = m_context.LastSelectedObject;
                    if (m_activeCollectionNode != selected && selected != null)
                    {
                        ClearPendingChanges(); // no need to process pending changes as we're rebuilding anyway

                        m_activeCollectionNode = selected;

                        IEnumerable items = GetItemsFromContext();
                        int itemCount = items.Cast<object>().Count();

                        // Enable singleton mode iff the collection will always have exactly 1 item
                        // in this case we can hide toolbar and the item's index column
                        m_singletonMode =
                            (m_editor.GetItemInsertersFunc == null || !m_editor.GetItemInsertersFunc(m_context).Any()) // can't insert
                            && m_editor.RemoveItemFunc == null // can't remove
                            && itemCount == 1; // currently 1 item

                        // Set index column width to be big enough to display the highest expected index,
                        // using double the number of current items as first estimate.
                        // This could be done more accurately with MeasureString and could also be dynamically
                        // adjusted if the number exceeds the current max due to add operations.
                        m_indexColumnWidth = Math.Max(30, (itemCount * 2).ToString().Length * 10);

                        m_toolStrip.Visible = !m_singletonMode;

                        foreach (ItemControl itemControl in m_itemControls.Values)
                        {
                            itemControl.Visible = false;
                            itemControl.Clear();
                            m_unusedItemControls.Add(itemControl);
                        }
                        m_itemControls.Clear();

                        // Add items for insertion.
                        foreach (object item in items)
                            m_pendingItemsInserted.Add(item);

                        UpdateAddButton();
                    }

                    // Hide controls for removed items.
                    int smallestRemovedIndex = int.MaxValue;
                    foreach (object item in m_pendingItemsRemoved)
                    {
                        ItemControl itemControl;

                        if (m_itemControls.TryGetValue(item, out itemControl))
                        {
                            if (itemControl.Index < smallestRemovedIndex)
                                smallestRemovedIndex = itemControl.Index;

                            itemControl.Visible = false;
                            UnsubscribeItemEvents(itemControl);
                            m_itemControls.Remove(item);
                            itemControl.Clear();
                            m_unusedItemControls.Add(itemControl);
                        }
                    }

                    // Set new item selection after any deletes.
                    if (smallestRemovedIndex != int.MaxValue)
                    {
                        int i = m_itemControls.Count - 1;
                        foreach (ItemControl itemObj in m_itemControls.Values.OrderBy(itemControl => itemControl.Index))
                        {
                            if (itemObj.Index > smallestRemovedIndex || i == 0)
                            {
                                itemObj.Selected = true;
                                break;
                            }

                            --i;
                        }
                    }

                    // Refresh controls for items that have changed.
                    foreach (object item in m_pendingItemsChanged)
                    {
                        ItemControl itemControl;
                        if (m_itemControls.TryGetValue(item, out itemControl))
                            itemControl.Refresh();
                    }

                                      
                    // Reorder controls for items that have moved, either
                    // because a lower index item was deleted, or because they've been
                    // (directly or indirectly) been moved up or down.
                    int index = 0;
                    int top = m_singletonMode ? 0 : m_toolStrip.Height;
                    foreach (object item in GetItemsFromContext())
                    {                                                
                        ItemControl itemControl;
                        if (m_itemControls.TryGetValue(item, out itemControl))
                        {
                            itemControl.Index = index;
                            itemControl.Top = top;

                            index++;
                            top += itemControl.Height;
                        }
                    }

                    // Add controls for added items.
                    // Currently only adding at the end is supported. If we ever want to support 
                    // inserting in the middle, then we'd probably want to have this step before .
                    // the index-reordering one.
                    foreach (object item in m_pendingItemsInserted)
                    {
                        ItemControl itemControl;
                        if (m_unusedItemControls.Count > 0)
                        {
                            itemControl = m_unusedItemControls[m_unusedItemControls.Count - 1];
                            m_unusedItemControls.RemoveAt(m_unusedItemControls.Count - 1);
                            itemControl.Init(m_itemControls.Count, item,
                                m_singletonMode, m_indexColumnWidth, TransactionContext);
                            itemControl.Visible = true;

                        }
                        else
                        {
                            itemControl = new ItemControl(m_itemControls.Count, item,
                                m_singletonMode, m_indexColumnWidth, TransactionContext);
                            SkinService.ApplyActiveSkin(itemControl);
                            Controls.Add(itemControl);                            
                            itemControl.MouseUp += itemControl_MouseUp;
                        }
                        itemControl.Width = m_toolStrip.Width;
                        itemControl.Anchor = AnchorStyles.Top | AnchorStyles.Left | AnchorStyles.Right;
                        itemControl.Top = top;

                        if (m_singletonMode)
                            itemControl.Dock = DockStyle.Fill;

                        m_oldHeights[itemControl] = itemControl.Height;
                        top += itemControl.Height;
                        m_itemControls.Add(item, itemControl);
                        SubscribeItemEvents(itemControl);
                        
                        itemControl.Selected = false;
                    }

                    Height = top; // update height of main collection control

                    ClearPendingChanges(); // all pending changes processed

                    UpdateDeleteButton(true);
                    UpdateMoveButtons(true);
                    UpdateItemsCountLabel();
                }
                catch (Win32Exception ex)
                {
                    // For very large collections (with 1000+ items) it is possible that Windows runs out of Window handles.
                    // Such collections are currently not usable with this editor. To support such collections we'd have to
                    // implement some kind of virtual mode (i.e. stream items in and out) but that would pose some new
                    // challenges for editing operations (add, remove, move).

                    // Clean up to release some window handles and keep the application running smoothly.
                    foreach (ItemControl control in m_itemControls.Values)
                    {
                        if (Controls.Contains(control))
                            Controls.Remove(control);
                        control.Clear();
                        control.Dispose();
                    }
                    m_itemControls.Clear();

                    foreach (ItemControl control in m_unusedItemControls)
                        control.Dispose();
                    m_unusedItemControls.Clear();

                    ClearPendingChanges();

                    // Report error. Must be done after cleaning up, as before we may not even have the resources to show the message box.
                    MessageBox.Show(
                        "Failed to create item controls, probably because there were not enough Window handles available. Consider using a different editor for collections of this size and nature.\r\n\r\n"
                        + ex.GetType().ToString() + Environment.NewLine
                        + ex.Message,
                        "Failed to create item controls", MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
                finally
                {
                    //m_toolStrip.Enabled = true;
                    ResumeLayout();
                    m_processingPendingChanges = false;
                }
            }
示例#40
0
        public ItemChanger()
        {
            InitializeComponent();
            this.Closed += delegate(object sender, EventArgs args) { IsClosed = true; };
            dockpanel.Visibility = System.Windows.Visibility.Hidden;
            if (SettingsHelper.HasLolPath)
            {
                Champions = new Dictionary<string, string>();
                foreach (string path in Directory.GetFiles(SettingsHelper.LolPathImagesChampions, SettingsHelper.ChampionPortraitSearchPattern))
                {
                    FileInfo file = new FileInfo(path);
                    string name = file.Name.Substring(0, file.Name.IndexOf('_'));
                    Champions.Add(name, path);
                }
                if (Champions.Count == 0)
                {
                    this.Hide();
                    MessageBox.Show("Couldn't load Champons", "Error", MessageBoxButton.OK, MessageBoxImage.Error);
                    this.Close();
                }

                ddlHero.ItemsSource = Champions;

                if (File.Exists("items.xml"))
                {
                    //TODO parse xml
                    XmlSerializer ser = new XmlSerializer(typeof(List<Item>));
                    FileStream fs = new FileStream("items.xml", FileMode.Open);
                    items = (List<Item>)ser.Deserialize(fs);
                    fs.Close();
                }
                else
                {
                    var result = MessageBox.Show("No items.xml found, should I try to enumerate the items?\n\nNote: not all items might be found, correctly named or duplicated.\nThose that are found might not all work ingame", "Items not found!", MessageBoxButton.YesNo, MessageBoxImage.Question);
                    if (result == MessageBoxResult.Yes)
                    {
                        items = new List<Item>();
                        foreach (string path in Directory.GetFiles(SettingsHelper.LolPathImagesItems))
                        {
                            FileInfo file = new FileInfo(path);
                            int index = file.Name.IndexOf('_');
                            if (index == -1) continue;
                            string strid = file.Name.Substring(0, index);
                            string name = file.Name.Substring(index + 1, file.Name.Length - file.Extension.Length - index - 1).Replace('_', ' ');
                            int id = 0;
                            if (int.TryParse(strid, out id) && id > 1000)
                            {
                                var item = new Item(id, name, path);
                                items.Add(item);
                            }
                        }
                    }
                    else
                    {
                        this.Close();
                        return;
                    }
                }
                LoadItems();

                itemSlots = new List<ItemControl>();
                for (int i = 0; i < 6; i++)
                {
                    var itemControl = new ItemControl();
                    itemControl.IsMainSlot = true;
                    itemControl.MainSlotNumber = i;
                    itemControl.Item = null;
                    itemSlots.Add(itemControl);
                    wrapItemSlots.Children.Add(itemControl);
                }

                this.Show();
            }
            else
            {
                this.Hide();
                MessageBox.Show("League of Legends Path not Found.\nPlease make sure the settings are correct.", "Error", MessageBoxButton.OK, MessageBoxImage.Error);
                this.Close();
            }
        }
示例#41
0
        private void LoadItems()
        {
            if (items == null) return;
            List<Item> toDisplay = items.Where(x => x.Available == Item.ItemAvailability.Both).ToList();
            switch (Mode)
            {
                case 1:
                    toDisplay.AddRange(items.Where(x => x.Available == Item.ItemAvailability.Classic));
                    break;

                case 2:
                    toDisplay.AddRange(items.Where(x => x.Available == Item.ItemAvailability.Dominion));
                    break;
            }
            if (SelectedChampion == "Viktor") toDisplay.AddRange(items.Where(x => x.Available == Item.ItemAvailability.Viktor));
            wrapItems.Children.Clear();
            foreach (Item item in toDisplay)
            {
                var itemControl = new ItemControl();
                itemControl.Item = item;
                wrapItems.Children.Add(itemControl);
            }
        }
 private void UnsubscribeItemEvents(ItemControl itemControl)
 {             
     if (itemControl.CanChangeSize)
         itemControl.SizeChanged -= itemControl_SizeChanged;
 }