Esempio n. 1
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);
                }
            }
        }
Esempio n. 2
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);
        }
Esempio n. 3
0
        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);
        }
Esempio n. 4
0
        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);
        }
Esempio n. 5
0
        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());
        }
Esempio n. 6
0
        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);
        }
Esempio n. 7
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);
        }
Esempio n. 8
0
        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);
        }
Esempio n. 9
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);
        }
Esempio n. 10
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.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);
        }
Esempio n. 12
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);
        }
Esempio n. 13
0
        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;
        }
Esempio n. 14
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);
        }
Esempio n. 15
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;
        }
Esempio n. 16
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();
        }
Esempio n. 17
0
        public override PropertyCollection OnCreateSavePropertyCollection()
        {
            List<Property> props = new List<Property>();

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

            return new PropertyCollection(props);
        }
Esempio n. 18
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);
        }
Esempio n. 19
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);
        }
Esempio n. 20
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();
        }
Esempio n. 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();
        }
Esempio n. 22
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;
        }
Esempio n. 23
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;
        }
Esempio n. 24
0
                /// <summary>
                /// Traverse the tree, building up the color palette
                /// </summary>
                /// <param name="palette">The palette</param>
                /// <param name="paletteIndex">The current palette index</param>
                public void ConstructPalette(List<Color> palette, ref int paletteIndex)
                {
                    if (_leaf)
                    {
                        // Consume the next palette index
                        _paletteIndex = paletteIndex++;

                        // And set the color of the palette entry
                        int r = _red / _pixelCount;
                        int g = _green / _pixelCount;
                        int b = _blue / _pixelCount;

                        palette.Add(Color.FromArgb(r, g, b));
                    }
                    else
                    {
                        // Loop through children looking for leaves
                        for (int index = 0; index < 8; index++)
                        {
                            if (null != _children[index])
                            {
                                _children[index].ConstructPalette(palette, ref paletteIndex);
                            }
                        }
                    }
                }
Esempio n. 25
0
        private static FileTypeCollection LoadFileTypes()
        {
            List<Assembly> assemblies = new List<Assembly>();

            // add the built-in IFileTypeFactory house
            assemblies.Add(typeof(FileType).Assembly);

            // enumerate the assemblies inside the FileTypes directory
            string homeDir = Path.GetDirectoryName(Application.ExecutablePath);
            string fileTypesDir = Path.Combine(homeDir, "FileTypes");
            bool dirExists;

            try
            {
                DirectoryInfo dirInfo = new DirectoryInfo(fileTypesDir);
                dirExists = dirInfo.Exists;
            }

            catch (Exception)
            {
                dirExists = false;
            }

            if (dirExists)
            {
                foreach (string fileName in Directory.GetFiles(fileTypesDir, "*.dll"))
                {
                    bool success;
                    Assembly pluginAssembly = null;

                    try
                    {
                        pluginAssembly = Assembly.LoadFrom(fileName);
                        success = true;
                    }

                    catch (Exception)
                    {
                        success = false;
                    }

                    if (success)
                    {
                        assemblies.Add(pluginAssembly);
                    }
                }
            }

            // Get all the IFileTypeFactory implementations
            Type[] fileTypeFactories = GetFileTypeFactoriesFromAssemblies(assemblies);
            List<FileType> allFileTypes = new List<FileType>(10);

            foreach (Type type in fileTypeFactories)
            {
                ConstructorInfo ci = type.GetConstructor(System.Type.EmptyTypes);
                IFileTypeFactory factory = (IFileTypeFactory)ci.Invoke(null);
                FileType[] fileTypes = factory.GetFileTypeInstances();

                foreach (FileType fileType in fileTypes)
                {
                    allFileTypes.Add(fileType);
                }
            }

            return new FileTypeCollection(allFileTypes);
        }
Esempio n. 26
0
        public static ColorBgra[] ParsePaletteString(string paletteString)
        {
            List<ColorBgra> palette = new List<ColorBgra>();
            StringReader sr = new StringReader(paletteString);

            while (true)
            {
                string line = sr.ReadLine();

                if (line == null)
                {
                    break;
                }

                ColorBgra color;
                bool gotColor = ParsePaletteLine(line, out color);

                if (gotColor && palette.Count < PaletteColorCount)
                {
                    palette.Add(color);
                }
            }

            return palette.ToArray();
        }
Esempio n. 27
0
        protected override PropertyCollection OnCreatePropertyCollection()
        {
            List<Property> props = new List<Property>();

            props.Add(new Int32Property(PropertyNames.Amount1, 10, 0, 200));
            props.Add(new Int32Property(PropertyNames.Amount2, 0, -100, 100));
            props.Add(new DoubleVectorProperty(PropertyNames.Amount3, Pair.Create(0.0, 0.0), Pair.Create(-1.0, -1.0), Pair.Create(+1.0, +1.0)));
            props.Add(new BooleanProperty(PropertyNames.Amount4, true));

            return new PropertyCollection(props);
        }
Esempio n. 28
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);
        }
Esempio n. 29
0
        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);
        }
Esempio n. 30
0
            private WorkItemFailureAction ShowFileTransferFailedDialog(Exception ex)
            {
                WorkItemFailureAction result;
                Icon formIcon = this.progressDialog.Icon;

                string formTitle = PdnResources.GetString("DocumentWorkspace.ShowFileDialog.ItemFailureDialog.Title");

                Image taskImage = PdnResources.GetImageResource("Icons.WarningIcon.png").Reference;

                string introTextFormat = PdnResources.GetString("DocumentWorkspace.ShowFileDialog.ItemFailureDialog.IntroText.Format");
                string introText = string.Format(introTextFormat, ex.Message);

                TaskButton retryTB = new TaskButton(
                    PdnResources.GetImageResource("Icons.MenuImageRotate90CWIcon.png").Reference,
                    PdnResources.GetString("DocumentWorkspace.ShowFileDialog.RetryTB.ActionText"),
                    PdnResources.GetString("DocumentWorkspace.ShowFileDialog.RetryTB.ExplanationText"));

                TaskButton skipTB = new TaskButton(
                    PdnResources.GetImageResource("Icons.HistoryFastForwardIcon.png").Reference,
                    PdnResources.GetString("DocumentWorkspace.ShowFileDialog.SkipTB.ActionText"),
                    PdnResources.GetString("DocumentWorkspace.ShowFileDialog.SkipTB.ExplanationText"));

                TaskButton cancelTB = new TaskButton(
                    PdnResources.GetImageResource("Icons.CancelIcon.png").Reference,
                    PdnResources.GetString("DocumentWorkspace.ShowFileDialog.CancelTB.ActionText"),
                    PdnResources.GetString("DocumentWorkspace.ShowFileDialog.CancelTB.ExplanationText"));

                List<TaskButton> taskButtons = new List<TaskButton>();
                taskButtons.Add(retryTB);

                // Only have the Skip button if there is more than 1 item being transferred.
                // If only 1 item is begin transferred, Skip and Cancel are essentially synonymous.
                if (this.itemCount > 1)
                {
                    taskButtons.Add(skipTB);
                }

                taskButtons.Add(cancelTB);

                int width96 = (TaskDialog.DefaultPixelWidth96Dpi * 4) / 3; // 33% wider

                TaskButton clickedTB = TaskDialog.Show(
                    this.progressDialog,
                    formIcon,
                    formTitle,
                    taskImage,
                    true,
                    introText,
                    taskButtons.ToArray(),
                    retryTB,
                    cancelTB,
                    width96);

                if (clickedTB == retryTB)
                {
                    result = WorkItemFailureAction.RetryItem;
                }
                else if (clickedTB == skipTB)
                {
                    result = WorkItemFailureAction.SkipItem;
                }
                else
                {
                    result = WorkItemFailureAction.CancelOperation;
                }

                return result;
            }