Esempio n. 1
0
        private void sceneDot_MouseMove(object sender, MouseEventArgs e)
        {
            if (!isRectDragInProg)
            {
                return;
            }

            Border border = sender as Border;

            if (border != null)
            {
                var canvas   = VisualTreeHelpers.FindAncestor <Canvas>(border);
                var mousePos = e.GetPosition(canvas);

                double left = mousePos.X - (border.ActualWidth / 2);
                double top  = mousePos.Y - (border.ActualHeight / 2);
                border.Margin = new Thickness(left, top, 0, 0);

                var       imageWidth   = sceneImage.ActualWidth;
                var       imageHeight  = sceneImage.ActualHeight;
                SceneItem selectedItem = border.DataContext as SceneItem;
                selectedItem.XPos = ((border.Margin.Left + (border.Width / 2)) * 100) / imageWidth;
                selectedItem.YPos = ((border.Margin.Top + (border.Height / 2)) * 100) / imageHeight;
                ChangedItems.Add(selectedItem);
            }
        }
        /// <summary>
        /// Deserializes ChangedItems from an XML file.
        /// </summary>
        /// <param name="reader">XMLReader where the ChangedItems are.</param>
        /// <returns>ChangedItems.</returns>
        public static ChangedItems Deserialize(XmlReader reader)
        {
            ChangedItems lResult = null;

            if (reader.IsStartElement(DTD.Error.TagChangedItems))
            {
                lResult = new ChangedItems();

                if (!reader.IsEmptyElement)
                {
                    reader.ReadStartElement();
                    do
                    {
                        if (reader.IsStartElement(DTD.Error.ChangedItems.TagChangedItem))
                        {
                            lResult.Add(XMLChangedItemSerializer.Deserialize(reader.ReadSubtree()));
                        }
                    } while (reader.Read());
                }
                else
                {
                    reader.Skip();
                }
            }
            else
            {
                throw new ArgumentException("Xml Reader don't have the " + DTD.Error.TagChangedItems + "in Start Element.", "XmlReader reader");
            }
            return(lResult);
        }
 public bool Equals(Commit other)
 {
     return(CommitTime == other.CommitTime &&
            CreationTime == other.CreationTime &&
            Invoker == other.Invoker &&
            Name == other.Name &&
            ChangedItems.SequenceEqual(other.ChangedItems) &&
            AddedItems.SequenceEqual(other.AddedItems) &&
            CommitedAll == other.CommitedAll);
 }
Esempio n. 4
0
 public void HandleDataChangedEvent(DataChangedEvent e)
 {
     if (e.LocalAccountId == _localAccountId && e.WasLocalChanges)
     {
         var changedItems = e.NewItems.Union(e.EditedItems).OfType <T>().Select(i => i.Identifier).ToArray();
         if (changedItems.Length > 0 && ChangedItems != null)
         {
             ChangedItems.Invoke(this, changedItems);
         }
     }
 }
 public void UndoChanges()
 {
     foreach (var editable in ChangedItems.ToArray())
     {
         editable.UndoChanges();
     }
     foreach (var deleted in DeletedItems.ToArray())
     {
         deleted.UndoChanges();
     }
     _inserted.Clear();
 }
Esempio n. 6
0
        private void timePickerStart_TimeChanged(object sender, EventArgs e)
        {
            if (_haltEvents || (listBox1.SelectedItem == null))
            {
                return;
            }
            FormattedListBoxItem itemPricing = (FormattedListBoxItem)listBox1.SelectedItem;
            ItemPricingModel     pricing     = ((ItemPricingModel)itemPricing.ReferenceObject);

            pricing.StartTime = GetStartTime();
            if ((itemPricing.Id > 0) && (GetChangedItem(pricing) == null) && (pricing != null))
            {
                ChangedItems.Add(pricing);
            }
            itemPricing.Text = GenerateListBoxDescription(pricing);
            DoChangedValueEvent();
        }
Esempio n. 7
0
        private void pushComboBoxDayOfWeek_SelectedIndexChanged(object sender, EventArgs e)
        {
            if (_haltEvents || (listBox1.SelectedItem == null))
            {
                return;
            }
            FormattedListBoxItem itemPricing = (FormattedListBoxItem)listBox1.SelectedItem;
            ItemPricingModel     pricing     = ((ItemPricingModel)itemPricing.ReferenceObject);

            pricing.DayOfWeek = GetDayOfWeek();
            if ((itemPricing.Id > 0) && (GetChangedItem(pricing) == null) && (pricing != null))
            {
                ChangedItems.Add(pricing);
            }
            itemPricing.Text = GenerateListBoxDescription(pricing);
            DoChangedValueEvent();
        }
        public TElement[] CommitChanges()
        {
            var results = new List <TElement>();

            foreach (var editable in ChangedItems.ToArray())
            {
                editable.CommitChanges();
                results.Add(editable.Original);
            }
            foreach (var inserted in Inserted.ToArray())
            {
                inserted.CommitChanges();
                results.Add(inserted.Original);
            }
            _inserted.Clear();

            return(results.ToArray());
        }
Esempio n. 9
0
        public void SetValue(string key, object value)
        {
            if (key == null)
            {
                throw new ArgumentNullException();
            }

            object old = GetValue(key);

            if (old != value)
            {
                if (!ChangedItems.ContainsKey(key))
                {
                    ChangedItems.Add(key, old);
                }
                Data[key] = value;
                OnOptionChanged(key, old, value);
                Modified = true;
            }
        }
Esempio n. 10
0
 internal void UpDateInfo()
 {
     foreach (var name in ChangedItems)
     {
         var finfo = new FileInfo(Path.Combine(this.Dir, name));
         if (finfo.Exists)
         {
             var item = Items.First(x => {
                 return(x.Name.Equals(name));
             });
             if (item != null)
             {
                 item.Size          = finfo.Length;
                 item.LastWriteTime = finfo.LastWriteTime;
             }
         }
     }
     if (ChangedItems.Count > 0)
     {
         ChangedItems.Clear();
         listView.Refresh();
     }
 }
        /// <summary>
        /// Deserializes ChangedItems from an XML file.
        /// </summary>
        /// <param name="reader">XMLReader where the ChangedItems are.</param>
        /// <returns>ChangedItems.</returns>
        public static ChangedItems Deserialize(XmlReader reader)
        {
            ChangedItems lResult = null;

            if (reader.IsStartElement(DTD.Error.TagChangedItems))
            {
                lResult = new ChangedItems();

                if (!reader.IsEmptyElement)
                {
                reader.ReadStartElement();
                do
                {
                    if (reader.IsStartElement(DTD.Error.ChangedItems.TagChangedItem))
                    {
                        lResult.Add(XMLChangedItemSerializer.Deserialize(reader.ReadSubtree()));
                    }

                } while (reader.Read());
                }
                else
                {
                reader.Skip();
                }
            }
            else
            {
                throw new ArgumentException("Xml Reader don't have the " + DTD.Error.TagChangedItems + "in Start Element.", "XmlReader reader");
            }
            return lResult;
        }
Esempio n. 12
0
 private ItemPricingModel GetChangedItem(ItemPricingModel changedItem)
 {
     return((ChangedItems == null) ? null :
            ChangedItems.FirstOrDefault(pricing => pricing.Id == changedItem.Id));
 }
Esempio n. 13
0
        //FileItem lFileItem = null;

        void fileSystemWatcher1_Changed(object sender, FileSystemEventArgs e)
        {
            switch (e.ChangeType)
            {
            case System.IO.WatcherChangeTypes.Changed: {
                Console.WriteLine("ファイル 「" + e.FullPath + "」が変更されました。");
                if (!ChangedItems.Contains(e.Name))
                {
                    ChangedItems.Add(e.Name);
                    var index = (Items.FindIndex(x => {
                            return(x.Name.Equals(e.Name));
                        }));
                    if (index >= 0)
                    {
                        listView.RedrawItems(index, index, false);
                    }
                }
            }
                //if (File.Exists(e.FullPath)) {
                //    FileItem fi = null;
                //    var info = new FileInfo(e.FullPath);
                //    if (lFileItem != null && lFileItem.Name.Equals(e.Name)) {
                //        fi = lFileItem;
                //    }
                //    else if ((listView1.SelectedIndices.Count > 0 && Items[listView1.SelectedIndices[0]].Name.Equals(e.Name))) {
                //        fi = Items[listView1.SelectedIndices[0]];
                //    }else{
                //        fi = Items.First(x => {
                //            return x.Name.Equals(e.Name);
                //        });
                //    }
                //    if (fi != null) {
                //        fi.Size = info.Length;
                //        fi.LastWriteTime = info.LastWriteTime;
                //        var index = Items.IndexOf(fi);
                //        listView1.RedrawItems(index, index, false);
                //    }
                //    lFileItem = fi;
                //}
                break;

            case System.IO.WatcherChangeTypes.Created: {
                var fitem = new FileItem();
                fitem.Name = e.Name;
                if (File.Exists(e.FullPath))
                {
                    //var info = new FileInfo(e.FullPath);
                    fitem.IsFile = true;
                    fitem.type   = e.Name.Substring(e.Name.IndexOf("."));
                    //fitem.Size = info.Length;
                    //fitem.LastWriteTime = info.LastWriteTime;
                }
                else
                {
                    //var info = new DirectoryInfo(e.FullPath);
                    fitem.IsFile = false;
                    fitem.type   = "/";
                    //fitem.LastWriteTime = info.LastWriteTime;
                }
                //lFileItem = fitem;
                var index = 0;
                if (listView.SelectedIndices.Count == 0)
                {
                    index = listView.TopItem != null ? listView.TopItem.Index : 0;
                }
                else
                {
                    index = listView.SelectedIndices[listView.SelectedIndices.Count - 1];
                }
                index = index == Items.Count ? index : index + 1;
                //Items.Add(fitem);
                Items.Insert(index, fitem);

                if (!ChangedItems.Contains(e.Name))
                {
                    ChangedItems.Add(e.Name);
                    listView.RedrawItems(index, index, false);
                }

                listView1.VirtualListSize = Items.Count;
                //Console.WriteLine("ファイル 「" + e.FullPath + "」がCreatedされました。");
                break;
            }

            case System.IO.WatcherChangeTypes.Deleted: {
                //Console.WriteLine("ファイル 「" + e.FullPath + "」が削除されました。");
                Items.Remove(Items.First(x => {
                        return(x.Name.Equals(e.Name));
                    }));
                listView1.VirtualListSize = Items.Count;
                break;
            }
            }
        }
Esempio n. 14
0
 public void AcceptChanges()
 {
     ChangedItems.Clear();
     Modified = false;
 }