private HistoryStack(
     List<HistoryMemento> undoStack,
     List<HistoryMemento> redoStack)
 {
     this.undoStack = new List<HistoryMemento>(undoStack);
     this.redoStack = new List<HistoryMemento>(redoStack);
 }
 /// <summary>
 /// Construct the palette quantizer
 /// </summary>
 /// <param name="palette">The color palette to quantize to</param>
 /// <remarks>
 /// Palette quantization only requires a single quantization step
 /// </remarks>
 public PaletteQuantizer(List<Color> palette)
     : base(true)
 {
     _colorMap = new Dictionary<uint, byte>();
     _colors = new Color[palette.Count];
     palette.CopyTo(_colors);
 }
Exemple #3
0
        public static void UnhookStylus(Control control)
        {
            lock (hookedControls.SyncRoot)
            {
                List<WeakReference> deleteUs = new List<WeakReference>();

                foreach (WeakReference weakRef in hookedControls.Keys)
                {
                    object target = weakRef.Target;

                    if (target == null)
                    {
                        deleteUs.Add(weakRef);
                    }
                    else
                    {
                        Control control2 = (Control)target;

                        if (object.ReferenceEquals(control, control2))
                        {
                            deleteUs.Add(weakRef);
                        }
                    }
                }

                foreach (WeakReference weakRef in deleteUs)
                {
                    RealTimeStylus stylus = (RealTimeStylus)hookedControls[weakRef];
                    stylus.Enabled = false;
                    stylus.AsyncPluginCollection.Clear();
                    hookedControls.Remove(weakRef);
                }
            }
        }
Exemple #4
0
        private static Type[] GetFileTypeFactoriesFromAssemblies(ICollection assemblies)
        {
            List<Type> allFactories = new List<Type>();

            foreach (Assembly assembly in assemblies)
            {
                Type[] factories;

                try
                {
                    factories = GetFileTypeFactoriesFromAssembly(assembly);
                }

                catch (Exception)
                {
                    continue;
                }

                foreach (Type type in factories)
                {
                    allFactories.Add(type);
                }
            }

            return allFactories.ToArray();
        }
Exemple #5
0
        public override PropertyCollection OnCreateSavePropertyCollection()
        {
            List<Property> props = new List<Property>();

            props.Add(new Int32Property(PropertyNames.Quality, 95, 0, 100));

            return new PropertyCollection(props);
        }
Exemple #6
0
        protected override PropertyCollection OnCreatePropertyCollection()
        {
            List<Property> props = new List<Property>();

            props.Add(new DoubleProperty(PropertyNames.Angle, 0.0, -180.0, +180.0));

            return new PropertyCollection(props);
        }
        protected override PropertyCollection OnCreatePropertyCollection()
        {
            List<Property> props = new List<Property>();

            props.Add(new Int32Property(PropertyNames.Tolerance, 70, 0, 100));
            props.Add(new Int32Property(PropertyNames.Saturation, 90, 0, 100));

            return new PropertyCollection(props);
        }
Exemple #8
0
        protected override PropertyCollection OnCreatePropertyCollection()
        {
            List<Property> props = new List<Property>();

            props.Add(new Int32Property(PropertyNames.Radius, 10, 1, 200));
            props.Add(new Int32Property(PropertyNames.Percentile, 50, 0, 100));

            return new PropertyCollection(props);
        }
        protected override PropertyCollection OnCreatePropertyCollection()
        {
            List<Property> propsBuilder = new List<Property>();
            propsBuilder.Add(new DoubleProperty("X", 0.3, 0, 1));
            propsBuilder.Add(new DoubleProperty("Y", 0.5, 0, 1));
            propsBuilder.Add(new DoubleProperty("Z", 0.11, 0, 1));

            return new PropertyCollection(propsBuilder.ToArray());
        }
        protected override PropertyCollection OnCreatePropertyCollection()
        {
            List<Property> props = new List<Property>();

            props.Add(new Int32Property(PropertyNames.BrushSize, 3, 1, 8));
            props.Add(new Int32Property(PropertyNames.Coarseness, 50, 3, 255));

            return new PropertyCollection(props);
        }
        protected override PropertyCollection OnCreatePropertyCollection()
        {
            List<Property> props = new List<Property>();

            props.Add(new Int32Property(PropertyNames.Radius, 10, 0, 200));
            props.Add(new DoubleProperty(PropertyNames.Strength, 0.4, 0, 1));

            return new PropertyCollection(props);
        }
Exemple #12
0
        public override PropertyCollection OnCreateSavePropertyCollection()
        {
            List<Property> props = new List<Property>();

            props.Add(new Int32Property(PropertyNames.DitherLevel, 7, 0, 8));
            props.Add(new Int32Property(PropertyNames.Threshold, 128, 0, 255));

            return new PropertyCollection(props);
        }
Exemple #13
0
        protected override PropertyCollection OnCreatePropertyCollection()
        {
            List<Property> props = new List<Property>();

            props.Add(new Int32Property(PropertyNames.Radius, 6, 1, 20));
            props.Add(new Int32Property(PropertyNames.Brightness, 10, -100, +100));
            props.Add(new Int32Property(PropertyNames.Contrast, 10, -100, +100));

            return new PropertyCollection(props);
        }
        protected override PropertyCollection OnCreatePropertyCollection()
        {
 	        List<Property> props = new List<Property>();

            props.Add(new Int32Property(PropertyNames.Softness, 5, 0, 10));
            props.Add(new Int32Property(PropertyNames.Lighting, 0, -20, +20));
            props.Add(new Int32Property(PropertyNames.Warmth, 10, 0, 20));

            return new PropertyCollection(props);
        }
        protected override PropertyCollection OnCreatePropertyCollection()
        {
            List<Property> props = new List<Property>();

            props.Add(new Int32Property(PropertyNames.Hue, 0, -180, +180));
            props.Add(new Int32Property(PropertyNames.Saturation, 100, 0, 200));
            props.Add(new Int32Property(PropertyNames.Lightness, 0, -100, +100));

            return new PropertyCollection(props);
        }
Exemple #16
0
        protected override PropertyCollection OnCreatePropertyCollection()
        {
            List<Property> props = new List<Property>();

            props.Add(new Int32Property(PropertyNames.Intensity, 64, 0, 100));
            props.Add(new Int32Property(PropertyNames.Saturation, 100, 0, 400));
            props.Add(new DoubleProperty(PropertyNames.Coverage, 100, 0, 100));

            return new PropertyCollection(props);
        }
Exemple #17
0
        protected override PropertyCollection OnCreatePropertyCollection()
        {
            List<Property> props = new List<Property>();

            props.Add(new DoubleProperty(PropertyNames.Rotation, 30, -180, +180));
            props.Add(new DoubleProperty(PropertyNames.SquareSize, 40, 1, 800));
            props.Add(new DoubleProperty(PropertyNames.Curvature, 8, -100, 100));
            props.Add(new Int32Property(PropertyNames.Quality, 2, 1, 5));

            return new PropertyCollection(props);
        }
        protected override PropertyCollection OnCreatePropertyCollection()
        {
            List<Property> props = new List<Property>();

            props.Add(new DoubleProperty(PropertyNames.MaxScatterRadius, 3.0, 0.0, 200.0));
            props.Add(new DoubleProperty(PropertyNames.MinScatterRadius, 0.0, 0.0, 200.0));
            props.Add(new Int32Property(PropertyNames.NumSamples, 2, 1, 8));

            List<PropertyCollectionRule> propertyRules = new List<PropertyCollectionRule>();
            propertyRules.Add(new SoftMutuallyBoundMinMaxRule<double, DoubleProperty>(PropertyNames.MinScatterRadius, PropertyNames.MaxScatterRadius));

            PropertyCollection propertyCollection = new PropertyCollection(props, propertyRules);
            return propertyCollection;
        }
Exemple #19
0
        private static Type[] GetFileTypeFactoriesFromAssembly(Assembly assembly)
        {
            List<Type> fileTypeFactories = new List<Type>();

            foreach (Type type in assembly.GetTypes())
            {
                if (IsInterfaceImplemented(type, typeof(IFileTypeFactory)) && !type.IsAbstract)
                {
                    fileTypeFactories.Add(type);
                }
            }

            return fileTypeFactories.ToArray();
        }
Exemple #20
0
        protected override PropertyCollection OnCreatePropertyCollection()
        {
            List<Property> props = new List<Property>();

            props.Add(new Int32Property(PropertyNames.Amount, 45, -200, 100));

            props.Add(new DoubleVectorProperty(
                PropertyNames.Offset,
                Pair.Create(0.0, 0.0),
                Pair.Create(-1.0, -1.0),
                Pair.Create(1.0, 1.0)));

            return new PropertyCollection(props);
        }
Exemple #21
0
        /// <summary>
        /// Returns an array of Type objects that lists all of the pixel ops contained
        /// within this class. You can then use Utility.GetStaticName to retrieve the
        /// value of the StaticName property.
        /// </summary>
        /// <returns></returns>
        public static Type[] GetBlendOps()
        {
            Type[] allTypes = typeof(UserBlendOps).GetNestedTypes();
            List<Type> types = new List<Type>(allTypes.Length);

            foreach (Type type in allTypes)
            {
                if (type.IsSubclassOf(typeof(UserBlendOp)) && !type.IsAbstract)
                {
                    types.Add(type);
                }
            }

            return types.ToArray();
        }
        private void DrainThumbnailReadyInvokeList()
        {
            List<ThumbnailReadyEventDetails> invokeListCopy = null;

            lock (this.thumbnailReadyInvokeList)
            {
                invokeListCopy = this.thumbnailReadyInvokeList;
                this.thumbnailReadyInvokeList = new List<ThumbnailReadyEventDetails>();
            }

            foreach (ThumbnailReadyEventDetails invokeMe in invokeListCopy)
            {
                invokeMe.First.Invoke(invokeMe.Second, invokeMe.Third);
            }
        }
Exemple #23
0
        public override PropertyCollection OnCreateSavePropertyCollection()
        {
            List<Property> props = new List<Property>();

            props.Add(StaticListChoiceProperty.CreateForEnum<BmpBitDepthUIChoices>(PropertyNames.BitDepth, BmpBitDepthUIChoices.AutoDetect, false));
            props.Add(new Int32Property(PropertyNames.DitherLevel, 7, 0, 8));

            List<PropertyCollectionRule> rules = new List<PropertyCollectionRule>();

            rules.Add(new ReadOnlyBoundToValueRule<object, StaticListChoiceProperty>(PropertyNames.DitherLevel, PropertyNames.BitDepth, BmpBitDepthUIChoices.Bpp8, true));

            PropertyCollection pc = new PropertyCollection(props, rules);

            return pc;
        }
Exemple #24
0
        protected override PropertyCollection OnCreatePropertyCollection()
        {
            List<Property> props = new List<Property>();

            props.Add(new DoubleProperty(PropertyNames.Amount, 30.0, -200.0, 200.0));
            props.Add(new DoubleProperty(PropertyNames.Size, 1.0, 0.01, 2.0));

            props.Add(new DoubleVectorProperty(
                PropertyNames.Offset,
                Pair.Create(0.0, 0.0),
                Pair.Create(-2.0, -2.0),
                Pair.Create(+2.0, +2.0)));

            props.Add(new Int32Property(PropertyNames.Quality, 2, 1, 5));

            return new PropertyCollection(props);
        }
Exemple #25
0
        private static List<Form> GetAllPeerForms(Form form)
        {
            if (form == null)
            {
                return new List<Form>();
            }

            if (form.Owner != null)
            {
                return GetAllPeerForms(form.Owner);
            }

            List<Form> forms = new List<Form>();
            forms.Add(form);
            forms.AddRange(form.OwnedForms);

            return forms;
        }
Exemple #26
0
        protected override PropertyCollection OnCreatePropertyCollection()
        {
            List<Property> props = new List<Property>();

            props.Add(new DoubleProperty(PropertyNames.AngleChooser, 0, -180, +180));
            props.Add(new BooleanProperty(PropertyNames.CheckBox, true));
            props.Add(new DoubleProperty(PropertyNames.DoubleSlider, 0, 0, 100));
            props.Add(new DoubleVectorProperty(PropertyNames.DoubleVectorPanAndSlider, Pair.Create(0.0, 0.0), Pair.Create(-1.0, -1.0), Pair.Create(+1.0, +1.0)));
            props.Add(new DoubleVectorProperty(PropertyNames.DoubleVectorSlider, Pair.Create(0.0, 0.0), Pair.Create(-1.0, -1.0), Pair.Create(+1.0, +1.0)));
            props.Add(new Int32Property(PropertyNames.Int32ColorWheel, 0, 0, 0xffffff));
            props.Add(new Int32Property(PropertyNames.Int32IncrementButton, 0, 0, 255));
            props.Add(new Int32Property(PropertyNames.Int32Slider, 0, 0, 100));
            props.Add(StaticListChoiceProperty.CreateForEnum<System.Drawing.GraphicsUnit>(PropertyNames.StaticListDropDown, GraphicsUnit.Millimeter, false));
            props.Add(StaticListChoiceProperty.CreateForEnum<System.Drawing.GraphicsUnit>(PropertyNames.StaticListRadioButton, GraphicsUnit.Document, false));
            props.Add(new StringProperty(PropertyNames.StringText, "hello", 100));

            return new PropertyCollection(props);
        }
Exemple #27
0
        public LayerControl()
        {
            this.elementHeight = 2 + SystemLayer.UI.ScaleWidth(LayerElement.ThumbSizePreScaling);

            // This call is required by the Windows.Forms Form Designer.
            InitializeComponent();

            elementClickDelegate = new EventHandler(ElementClickHandler);
            elementDoubleClickDelegate = new EventHandler(ElementDoubleClickHandler);
            documentChangedDelegate = new EventHandler(DocumentChangedHandler);
            documentChangingDelegate = new EventHandler<Document>(DocumentChangingHandler);
            layerInsertedDelegate = new IndexEventHandler(LayerInsertedHandler);
            layerRemovedDelegate = new IndexEventHandler(LayerRemovedHandler);
            layerChangedDelegate = new EventHandler(LayerChangedHandler);
            keyUpDelegate = new KeyEventHandler(KeyUpHandler);

            this.thumbnailManager = new ThumbnailManager(this);
            this.thumbnailSize = SystemLayer.UI.ScaleWidth(LayerElement.ThumbSizePreScaling);
            layerControls = new List<LayerElement>();
        }
        public static FileType[] FilterFileTypeList(FileType[] input, bool excludeCantSave, bool excludeCantLoad)
        {
            List<FileType> filtered = new List<FileType>();

            foreach (FileType fileType in input)
            {
                if (excludeCantSave && !fileType.SupportsSaving)
                {
                    continue;
                }

                if (excludeCantLoad && !fileType.SupportsLoading)
                {
                    continue;
                }

                filtered.Add(fileType);
            }

            return filtered.ToArray();
        }
Exemple #29
0
        public static bool CloseApplication()
        {
            bool returnVal = true;

            List<Form> allFormsButMainForm = new List<Form>();

            foreach (Form form in Application.OpenForms)
            {
                if (form.Modal && !object.ReferenceEquals(form, instance.mainForm))
                {
                    allFormsButMainForm.Add(form);
                }
            }

            if (allFormsButMainForm.Count > 0)
            {
                // Cannot close application if there are modal dialogs
                return false;
            }

            returnVal = CloseForm(instance.mainForm);
            return returnVal;
        }
        protected override PropertyCollection OnCreatePropertyCollection()
        {
            List<Property> props = new List<Property>();

            props.Add(new Int32Property(PropertyNames.Amount1, 4, 1, 100));
            props.Add(new Int32Property(PropertyNames.Amount2, 16, 1, 100));
            props.Add(StaticListChoiceProperty.CreateForEnum<Amount3Options>(PropertyNames.Amount3, Amount3Options.Amount3Option3, false));
            props.Add(new Int32Property(PropertyNames.Amount4, ColorBgra.ToOpaqueInt32(ColorBgra.FromBgra(EnvironmentParameters.PrimaryColor.B, EnvironmentParameters.PrimaryColor.G, EnvironmentParameters.PrimaryColor.R, 255)), 0, 0xffffff));
            props.Add(new Int32Property(PropertyNames.Amount5, ColorBgra.ToOpaqueInt32(ColorBgra.FromBgra(EnvironmentParameters.SecondaryColor.B, EnvironmentParameters.SecondaryColor.G, EnvironmentParameters.SecondaryColor.R, 255)), 0, 0xffffff));
            props.Add(new Int32Property(PropertyNames.Amount6, ColorBgra.ToOpaqueInt32(ColorBgra.FromBgra((byte)((EnvironmentParameters.PrimaryColor.B + EnvironmentParameters.SecondaryColor.B) / 2), (byte)((EnvironmentParameters.PrimaryColor.G + EnvironmentParameters.SecondaryColor.G) / 2), (byte)((EnvironmentParameters.PrimaryColor.R + EnvironmentParameters.SecondaryColor.R) / 2), 255)), 0, 0xffffff));
            props.Add(new Int32Property(PropertyNames.Amount7, ColorBgra.ToOpaqueInt32(Color.White), 0, 0xffffff));

            return new PropertyCollection(props);
        }