public bool InitializeDocument(params object[] args)
        {
            if (args.Length == 0 || (args[0] != null && !(args[0] is GridStyle)))
            {
                return(false);
            }

            bool isVirgin = null == _doc;

            _doc     = (GridStyle)args[0];
            _tempdoc = _doc;

            if (_useDocument == UseDocument.Copy && null != _doc)
            {
                _tempdoc = (GridStyle)_doc.Clone();
            }
            if (null == _doc)
            {
                _doc = _tempdoc = new GridStyle();
                _tempdoc.ShowGrid = false;
                _useDocument      = UseDocument.Directly;
            }

            Initialize(true);
            return(true);
        }
Example #2
0
		private void StyleButton_Click(object sender, System.EventArgs e)
		{
			if (_mStyle == null)
			{
				MessageBox.Show("Please click GridInfo before clicking Style.");
				return;
			}

			GridStyle aStyle = _mStyle.Clone() as GridStyle;

			GridStyleForm f = new GridStyleForm();
			f.AlphaTextBox.Text = aStyle.Alpha.ToString();
			f.BrightnessBox.Text = aStyle.Brightness.ToString();
			f.ContrastBox.Text = aStyle.Contrast.ToString();
			f.GrayScale.CheckState = (aStyle.Grayscale) ? CheckState.Checked : CheckState.Unchecked;
			f.Transparency.CheckState = (aStyle.Transparent) ? CheckState.Checked : CheckState.Unchecked;
			f.DisplayHillshade.CheckState = (aStyle.DisplayHillshade) ? CheckState.Checked : CheckState.Unchecked;
			f.TransparentColor.BackColor = aStyle.TransparentColor;
			if (f.ShowDialog() == DialogResult.OK)
			{
				aStyle.Alpha = int.Parse(f.AlphaTextBox.Text);
				aStyle.Brightness = int.Parse(f.BrightnessBox.Text);
				aStyle.Contrast = int.Parse(f.ContrastBox.Text);
				aStyle.Grayscale = f.GrayScale.CheckState == CheckState.Checked ? true : false;
				aStyle.Transparent = (f.Transparency.CheckState == CheckState.Checked) ? true : false;
				aStyle.DisplayHillshade = (f.DisplayHillshade.CheckState == CheckState.Checked) ? true : false;
				aStyle.TransparentColor = f.TransparentColor.BackColor;

				// this composite style will affect the raster as intended 
				CompositeStyle csRaster = new CompositeStyle(aStyle); 
				FeatureOverrideStyleModifier fosm = 
					new FeatureOverrideStyleModifier("Style Mod", csRaster); 

				FeatureStyleModifiers modifiers = _lyr.Modifiers; 
				modifiers.Clear();
				modifiers.Append(fosm);			
			}
		}